omega_webext_proxy_script.min.js 721 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242
  1. require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. FindProxyForURL = (function () {
  3. var OmegaPac = require('omega-pac');
  4. var options = {};
  5. var state = {};
  6. var activeProfile = null;
  7. var fallbackResult = 'DIRECT';
  8. var pacCache = {};
  9. init();
  10. return FindProxyForURL;
  11. function FindProxyForURL(url, host, details) {
  12. if (!activeProfile) {
  13. warn('Warning: Proxy script not initialized on handling: ' + url);
  14. return fallbackResult;
  15. }
  16. // Moz: Neither path or query is included url regardless of scheme for now.
  17. // This is even more strict than Chromium restricting HTTPS URLs.
  18. // Therefore, it leads to different behavior than the icon and badge.
  19. // https://bugzilla.mozilla.org/show_bug.cgi?id=1337001
  20. var request = OmegaPac.Conditions.requestFromUrl(url);
  21. var profile = activeProfile;
  22. var matchResult, next;
  23. while (profile) {
  24. matchResult = OmegaPac.Profiles.match(profile, request)
  25. if (!matchResult) {
  26. if (profile.profileType === 'DirectProfile') {
  27. return 'DIRECT';
  28. } else {
  29. warn('Warning: Unsupported profile: ' + profile.profileType);
  30. return fallbackResult;
  31. }
  32. }
  33. if (Array.isArray(matchResult)) {
  34. next = matchResult[0];
  35. var proxy = matchResult[2];
  36. var auth = matchResult[3];
  37. if (proxy && !state.useLegacyStringReturn) {
  38. var proxyInfo = {
  39. type: proxy.scheme,
  40. host: proxy.host,
  41. port: proxy.port,
  42. };
  43. if (proxyInfo.type === 'socks5') {
  44. // MOZ: SOCKS5 proxies are identified by "type": "socks".
  45. // https://dxr.mozilla.org/mozilla-central/rev/ffe6cc09ccf38cca6f0e727837bbc6cb722d1e71/toolkit/components/extensions/ProxyScriptContext.jsm#51
  46. proxyInfo.type = 'socks';
  47. // Enable SOCKS5 remote DNS.
  48. // TODO(catus): Maybe allow the users to configure this?
  49. proxyInfo.proxyDNS = true;
  50. }
  51. if (auth) {
  52. proxyInfo.username = auth.username;
  53. proxyInfo.password = auth.password;
  54. }
  55. return [proxyInfo];
  56. } else if (next.charCodeAt(0) !== 43) {
  57. // MOZ: Legacy proxy support expects PAC-like string return type.
  58. // TODO(catus): Remove support for string return type.
  59. // MOZ: SOCKS5 proxies are supported under the prefix SOCKS.
  60. // https://dxr.mozilla.org/mozilla-central/rev/ffe6cc09ccf38cca6f0e727837bbc6cb722d1e71/toolkit/components/extensions/ProxyScriptContext.jsm#51
  61. // Note: We have to replace this because MOZ won't process the rest of
  62. // the list if the syntax of the first item is not recognized.
  63. return next.replace(/SOCKS5 /g, 'SOCKS ');
  64. }
  65. } else if (matchResult.profileName) {
  66. next = OmegaPac.Profiles.nameAsKey(matchResult.profileName)
  67. } else {
  68. return fallbackResult;
  69. }
  70. profile = OmegaPac.Profiles.byKey(next, options)
  71. }
  72. warn('Warning: Cannot find profile: ' + next);
  73. return fallbackResult;
  74. }
  75. function warn(message, error) {
  76. // We don't have console here and alert is not implemented.
  77. // Throwing and messaging seems to be the only ways to communicate.
  78. // MOZ: alert(): https://bugzilla.mozilla.org/show_bug.cgi?id=1353510
  79. browser.runtime.sendMessage({
  80. event: 'proxyScriptLog',
  81. message: message,
  82. error: error,
  83. level: 'warn',
  84. });
  85. }
  86. function init() {
  87. browser.runtime.onMessage.addListener(function(message) {
  88. if (message.event === 'proxyScriptStateChanged') {
  89. state = message.state;
  90. options = message.options;
  91. if (!state.currentProfileName) {
  92. activeProfile = state.tempProfile;
  93. } else {
  94. activeProfile = OmegaPac.Profiles.byName(state.currentProfileName,
  95. options);
  96. }
  97. }
  98. });
  99. browser.runtime.sendMessage({event: 'proxyScriptLoaded'});
  100. }
  101. })();
  102. },{"omega-pac":"omega-pac"}],"omega-pac":[function(require,module,exports){
  103. (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){
  104. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  105. ;(function (exports) {
  106. 'use strict';
  107. var Arr = (typeof Uint8Array !== 'undefined')
  108. ? Uint8Array
  109. : Array
  110. var PLUS = '+'.charCodeAt(0)
  111. var SLASH = '/'.charCodeAt(0)
  112. var NUMBER = '0'.charCodeAt(0)
  113. var LOWER = 'a'.charCodeAt(0)
  114. var UPPER = 'A'.charCodeAt(0)
  115. var PLUS_URL_SAFE = '-'.charCodeAt(0)
  116. var SLASH_URL_SAFE = '_'.charCodeAt(0)
  117. function decode (elt) {
  118. var code = elt.charCodeAt(0)
  119. if (code === PLUS ||
  120. code === PLUS_URL_SAFE)
  121. return 62 // '+'
  122. if (code === SLASH ||
  123. code === SLASH_URL_SAFE)
  124. return 63 // '/'
  125. if (code < NUMBER)
  126. return -1 //no match
  127. if (code < NUMBER + 10)
  128. return code - NUMBER + 26 + 26
  129. if (code < UPPER + 26)
  130. return code - UPPER
  131. if (code < LOWER + 26)
  132. return code - LOWER + 26
  133. }
  134. function b64ToByteArray (b64) {
  135. var i, j, l, tmp, placeHolders, arr
  136. if (b64.length % 4 > 0) {
  137. throw new Error('Invalid string. Length must be a multiple of 4')
  138. }
  139. // the number of equal signs (place holders)
  140. // if there are two placeholders, than the two characters before it
  141. // represent one byte
  142. // if there is only one, then the three characters before it represent 2 bytes
  143. // this is just a cheap hack to not do indexOf twice
  144. var len = b64.length
  145. placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  146. // base64 is 4/3 + up to two characters of the original data
  147. arr = new Arr(b64.length * 3 / 4 - placeHolders)
  148. // if there are placeholders, only get up to the last complete 4 chars
  149. l = placeHolders > 0 ? b64.length - 4 : b64.length
  150. var L = 0
  151. function push (v) {
  152. arr[L++] = v
  153. }
  154. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  155. tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  156. push((tmp & 0xFF0000) >> 16)
  157. push((tmp & 0xFF00) >> 8)
  158. push(tmp & 0xFF)
  159. }
  160. if (placeHolders === 2) {
  161. tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  162. push(tmp & 0xFF)
  163. } else if (placeHolders === 1) {
  164. tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  165. push((tmp >> 8) & 0xFF)
  166. push(tmp & 0xFF)
  167. }
  168. return arr
  169. }
  170. function uint8ToBase64 (uint8) {
  171. var i,
  172. extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  173. output = "",
  174. temp, length
  175. function encode (num) {
  176. return lookup.charAt(num)
  177. }
  178. function tripletToBase64 (num) {
  179. return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  180. }
  181. // go through the array every three bytes, we'll deal with trailing stuff later
  182. for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  183. temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  184. output += tripletToBase64(temp)
  185. }
  186. // pad the end with zeros, but make sure to not forget the extra bytes
  187. switch (extraBytes) {
  188. case 1:
  189. temp = uint8[uint8.length - 1]
  190. output += encode(temp >> 2)
  191. output += encode((temp << 4) & 0x3F)
  192. output += '=='
  193. break
  194. case 2:
  195. temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  196. output += encode(temp >> 10)
  197. output += encode((temp >> 4) & 0x3F)
  198. output += encode((temp << 2) & 0x3F)
  199. output += '='
  200. break
  201. }
  202. return output
  203. }
  204. exports.toByteArray = b64ToByteArray
  205. exports.fromByteArray = uint8ToBase64
  206. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  207. },{}],2:[function(require,module,exports){
  208. (function (global){
  209. /*!
  210. * The buffer module from node.js, for the browser.
  211. *
  212. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  213. * @license MIT
  214. */
  215. /* eslint-disable no-proto */
  216. 'use strict'
  217. var base64 = require('base64-js')
  218. var ieee754 = require('ieee754')
  219. var isArray = require('isarray')
  220. exports.Buffer = Buffer
  221. exports.SlowBuffer = SlowBuffer
  222. exports.INSPECT_MAX_BYTES = 50
  223. Buffer.poolSize = 8192 // not used by this implementation
  224. var rootParent = {}
  225. /**
  226. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  227. * === true Use Uint8Array implementation (fastest)
  228. * === false Use Object implementation (most compatible, even IE6)
  229. *
  230. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  231. * Opera 11.6+, iOS 4.2+.
  232. *
  233. * Due to various browser bugs, sometimes the Object implementation will be used even
  234. * when the browser supports typed arrays.
  235. *
  236. * Note:
  237. *
  238. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  239. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  240. *
  241. * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
  242. * on objects.
  243. *
  244. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  245. *
  246. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  247. * incorrect length in some situations.
  248. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  249. * get the Object implementation, which is slower but behaves correctly.
  250. */
  251. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  252. ? global.TYPED_ARRAY_SUPPORT
  253. : typedArraySupport()
  254. function typedArraySupport () {
  255. function Bar () {}
  256. try {
  257. var arr = new Uint8Array(1)
  258. arr.foo = function () { return 42 }
  259. arr.constructor = Bar
  260. return arr.foo() === 42 && // typed array instances can be augmented
  261. arr.constructor === Bar && // constructor can be set
  262. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  263. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  264. } catch (e) {
  265. return false
  266. }
  267. }
  268. function kMaxLength () {
  269. return Buffer.TYPED_ARRAY_SUPPORT
  270. ? 0x7fffffff
  271. : 0x3fffffff
  272. }
  273. /**
  274. * Class: Buffer
  275. * =============
  276. *
  277. * The Buffer constructor returns instances of `Uint8Array` that are augmented
  278. * with function properties for all the node `Buffer` API functions. We use
  279. * `Uint8Array` so that square bracket notation works as expected -- it returns
  280. * a single octet.
  281. *
  282. * By augmenting the instances, we can avoid modifying the `Uint8Array`
  283. * prototype.
  284. */
  285. function Buffer (arg) {
  286. if (!(this instanceof Buffer)) {
  287. // Avoid going through an ArgumentsAdaptorTrampoline in the common case.
  288. if (arguments.length > 1) return new Buffer(arg, arguments[1])
  289. return new Buffer(arg)
  290. }
  291. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  292. this.length = 0
  293. this.parent = undefined
  294. }
  295. // Common case.
  296. if (typeof arg === 'number') {
  297. return fromNumber(this, arg)
  298. }
  299. // Slightly less common case.
  300. if (typeof arg === 'string') {
  301. return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
  302. }
  303. // Unusual.
  304. return fromObject(this, arg)
  305. }
  306. function fromNumber (that, length) {
  307. that = allocate(that, length < 0 ? 0 : checked(length) | 0)
  308. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  309. for (var i = 0; i < length; i++) {
  310. that[i] = 0
  311. }
  312. }
  313. return that
  314. }
  315. function fromString (that, string, encoding) {
  316. if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
  317. // Assumption: byteLength() return value is always < kMaxLength.
  318. var length = byteLength(string, encoding) | 0
  319. that = allocate(that, length)
  320. that.write(string, encoding)
  321. return that
  322. }
  323. function fromObject (that, object) {
  324. if (Buffer.isBuffer(object)) return fromBuffer(that, object)
  325. if (isArray(object)) return fromArray(that, object)
  326. if (object == null) {
  327. throw new TypeError('must start with number, buffer, array or string')
  328. }
  329. if (typeof ArrayBuffer !== 'undefined') {
  330. if (object.buffer instanceof ArrayBuffer) {
  331. return fromTypedArray(that, object)
  332. }
  333. if (object instanceof ArrayBuffer) {
  334. return fromArrayBuffer(that, object)
  335. }
  336. }
  337. if (object.length) return fromArrayLike(that, object)
  338. return fromJsonObject(that, object)
  339. }
  340. function fromBuffer (that, buffer) {
  341. var length = checked(buffer.length) | 0
  342. that = allocate(that, length)
  343. buffer.copy(that, 0, 0, length)
  344. return that
  345. }
  346. function fromArray (that, array) {
  347. var length = checked(array.length) | 0
  348. that = allocate(that, length)
  349. for (var i = 0; i < length; i += 1) {
  350. that[i] = array[i] & 255
  351. }
  352. return that
  353. }
  354. // Duplicate of fromArray() to keep fromArray() monomorphic.
  355. function fromTypedArray (that, array) {
  356. var length = checked(array.length) | 0
  357. that = allocate(that, length)
  358. // Truncating the elements is probably not what people expect from typed
  359. // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
  360. // of the old Buffer constructor.
  361. for (var i = 0; i < length; i += 1) {
  362. that[i] = array[i] & 255
  363. }
  364. return that
  365. }
  366. function fromArrayBuffer (that, array) {
  367. if (Buffer.TYPED_ARRAY_SUPPORT) {
  368. // Return an augmented `Uint8Array` instance, for best performance
  369. array.byteLength
  370. that = Buffer._augment(new Uint8Array(array))
  371. } else {
  372. // Fallback: Return an object instance of the Buffer class
  373. that = fromTypedArray(that, new Uint8Array(array))
  374. }
  375. return that
  376. }
  377. function fromArrayLike (that, array) {
  378. var length = checked(array.length) | 0
  379. that = allocate(that, length)
  380. for (var i = 0; i < length; i += 1) {
  381. that[i] = array[i] & 255
  382. }
  383. return that
  384. }
  385. // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
  386. // Returns a zero-length buffer for inputs that don't conform to the spec.
  387. function fromJsonObject (that, object) {
  388. var array
  389. var length = 0
  390. if (object.type === 'Buffer' && isArray(object.data)) {
  391. array = object.data
  392. length = checked(array.length) | 0
  393. }
  394. that = allocate(that, length)
  395. for (var i = 0; i < length; i += 1) {
  396. that[i] = array[i] & 255
  397. }
  398. return that
  399. }
  400. if (Buffer.TYPED_ARRAY_SUPPORT) {
  401. Buffer.prototype.__proto__ = Uint8Array.prototype
  402. Buffer.__proto__ = Uint8Array
  403. } else {
  404. // pre-set for values that may exist in the future
  405. Buffer.prototype.length = undefined
  406. Buffer.prototype.parent = undefined
  407. }
  408. function allocate (that, length) {
  409. if (Buffer.TYPED_ARRAY_SUPPORT) {
  410. // Return an augmented `Uint8Array` instance, for best performance
  411. that = Buffer._augment(new Uint8Array(length))
  412. that.__proto__ = Buffer.prototype
  413. } else {
  414. // Fallback: Return an object instance of the Buffer class
  415. that.length = length
  416. that._isBuffer = true
  417. }
  418. var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
  419. if (fromPool) that.parent = rootParent
  420. return that
  421. }
  422. function checked (length) {
  423. // Note: cannot use `length < kMaxLength` here because that fails when
  424. // length is NaN (which is otherwise coerced to zero.)
  425. if (length >= kMaxLength()) {
  426. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  427. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  428. }
  429. return length | 0
  430. }
  431. function SlowBuffer (subject, encoding) {
  432. if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
  433. var buf = new Buffer(subject, encoding)
  434. delete buf.parent
  435. return buf
  436. }
  437. Buffer.isBuffer = function isBuffer (b) {
  438. return !!(b != null && b._isBuffer)
  439. }
  440. Buffer.compare = function compare (a, b) {
  441. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  442. throw new TypeError('Arguments must be Buffers')
  443. }
  444. if (a === b) return 0
  445. var x = a.length
  446. var y = b.length
  447. var i = 0
  448. var len = Math.min(x, y)
  449. while (i < len) {
  450. if (a[i] !== b[i]) break
  451. ++i
  452. }
  453. if (i !== len) {
  454. x = a[i]
  455. y = b[i]
  456. }
  457. if (x < y) return -1
  458. if (y < x) return 1
  459. return 0
  460. }
  461. Buffer.isEncoding = function isEncoding (encoding) {
  462. switch (String(encoding).toLowerCase()) {
  463. case 'hex':
  464. case 'utf8':
  465. case 'utf-8':
  466. case 'ascii':
  467. case 'binary':
  468. case 'base64':
  469. case 'raw':
  470. case 'ucs2':
  471. case 'ucs-2':
  472. case 'utf16le':
  473. case 'utf-16le':
  474. return true
  475. default:
  476. return false
  477. }
  478. }
  479. Buffer.concat = function concat (list, length) {
  480. if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
  481. if (list.length === 0) {
  482. return new Buffer(0)
  483. }
  484. var i
  485. if (length === undefined) {
  486. length = 0
  487. for (i = 0; i < list.length; i++) {
  488. length += list[i].length
  489. }
  490. }
  491. var buf = new Buffer(length)
  492. var pos = 0
  493. for (i = 0; i < list.length; i++) {
  494. var item = list[i]
  495. item.copy(buf, pos)
  496. pos += item.length
  497. }
  498. return buf
  499. }
  500. function byteLength (string, encoding) {
  501. if (typeof string !== 'string') string = '' + string
  502. var len = string.length
  503. if (len === 0) return 0
  504. // Use a for loop to avoid recursion
  505. var loweredCase = false
  506. for (;;) {
  507. switch (encoding) {
  508. case 'ascii':
  509. case 'binary':
  510. // Deprecated
  511. case 'raw':
  512. case 'raws':
  513. return len
  514. case 'utf8':
  515. case 'utf-8':
  516. return utf8ToBytes(string).length
  517. case 'ucs2':
  518. case 'ucs-2':
  519. case 'utf16le':
  520. case 'utf-16le':
  521. return len * 2
  522. case 'hex':
  523. return len >>> 1
  524. case 'base64':
  525. return base64ToBytes(string).length
  526. default:
  527. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  528. encoding = ('' + encoding).toLowerCase()
  529. loweredCase = true
  530. }
  531. }
  532. }
  533. Buffer.byteLength = byteLength
  534. function slowToString (encoding, start, end) {
  535. var loweredCase = false
  536. start = start | 0
  537. end = end === undefined || end === Infinity ? this.length : end | 0
  538. if (!encoding) encoding = 'utf8'
  539. if (start < 0) start = 0
  540. if (end > this.length) end = this.length
  541. if (end <= start) return ''
  542. while (true) {
  543. switch (encoding) {
  544. case 'hex':
  545. return hexSlice(this, start, end)
  546. case 'utf8':
  547. case 'utf-8':
  548. return utf8Slice(this, start, end)
  549. case 'ascii':
  550. return asciiSlice(this, start, end)
  551. case 'binary':
  552. return binarySlice(this, start, end)
  553. case 'base64':
  554. return base64Slice(this, start, end)
  555. case 'ucs2':
  556. case 'ucs-2':
  557. case 'utf16le':
  558. case 'utf-16le':
  559. return utf16leSlice(this, start, end)
  560. default:
  561. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  562. encoding = (encoding + '').toLowerCase()
  563. loweredCase = true
  564. }
  565. }
  566. }
  567. Buffer.prototype.toString = function toString () {
  568. var length = this.length | 0
  569. if (length === 0) return ''
  570. if (arguments.length === 0) return utf8Slice(this, 0, length)
  571. return slowToString.apply(this, arguments)
  572. }
  573. Buffer.prototype.equals = function equals (b) {
  574. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  575. if (this === b) return true
  576. return Buffer.compare(this, b) === 0
  577. }
  578. Buffer.prototype.inspect = function inspect () {
  579. var str = ''
  580. var max = exports.INSPECT_MAX_BYTES
  581. if (this.length > 0) {
  582. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  583. if (this.length > max) str += ' ... '
  584. }
  585. return '<Buffer ' + str + '>'
  586. }
  587. Buffer.prototype.compare = function compare (b) {
  588. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  589. if (this === b) return 0
  590. return Buffer.compare(this, b)
  591. }
  592. Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
  593. if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
  594. else if (byteOffset < -0x80000000) byteOffset = -0x80000000
  595. byteOffset >>= 0
  596. if (this.length === 0) return -1
  597. if (byteOffset >= this.length) return -1
  598. // Negative offsets start from the end of the buffer
  599. if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
  600. if (typeof val === 'string') {
  601. if (val.length === 0) return -1 // special case: looking for empty string always fails
  602. return String.prototype.indexOf.call(this, val, byteOffset)
  603. }
  604. if (Buffer.isBuffer(val)) {
  605. return arrayIndexOf(this, val, byteOffset)
  606. }
  607. if (typeof val === 'number') {
  608. if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
  609. return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
  610. }
  611. return arrayIndexOf(this, [ val ], byteOffset)
  612. }
  613. function arrayIndexOf (arr, val, byteOffset) {
  614. var foundIndex = -1
  615. for (var i = 0; byteOffset + i < arr.length; i++) {
  616. if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
  617. if (foundIndex === -1) foundIndex = i
  618. if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
  619. } else {
  620. foundIndex = -1
  621. }
  622. }
  623. return -1
  624. }
  625. throw new TypeError('val must be string, number or Buffer')
  626. }
  627. // `get` is deprecated
  628. Buffer.prototype.get = function get (offset) {
  629. console.log('.get() is deprecated. Access using array indexes instead.')
  630. return this.readUInt8(offset)
  631. }
  632. // `set` is deprecated
  633. Buffer.prototype.set = function set (v, offset) {
  634. console.log('.set() is deprecated. Access using array indexes instead.')
  635. return this.writeUInt8(v, offset)
  636. }
  637. function hexWrite (buf, string, offset, length) {
  638. offset = Number(offset) || 0
  639. var remaining = buf.length - offset
  640. if (!length) {
  641. length = remaining
  642. } else {
  643. length = Number(length)
  644. if (length > remaining) {
  645. length = remaining
  646. }
  647. }
  648. // must be an even number of digits
  649. var strLen = string.length
  650. if (strLen % 2 !== 0) throw new Error('Invalid hex string')
  651. if (length > strLen / 2) {
  652. length = strLen / 2
  653. }
  654. for (var i = 0; i < length; i++) {
  655. var parsed = parseInt(string.substr(i * 2, 2), 16)
  656. if (isNaN(parsed)) throw new Error('Invalid hex string')
  657. buf[offset + i] = parsed
  658. }
  659. return i
  660. }
  661. function utf8Write (buf, string, offset, length) {
  662. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  663. }
  664. function asciiWrite (buf, string, offset, length) {
  665. return blitBuffer(asciiToBytes(string), buf, offset, length)
  666. }
  667. function binaryWrite (buf, string, offset, length) {
  668. return asciiWrite(buf, string, offset, length)
  669. }
  670. function base64Write (buf, string, offset, length) {
  671. return blitBuffer(base64ToBytes(string), buf, offset, length)
  672. }
  673. function ucs2Write (buf, string, offset, length) {
  674. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  675. }
  676. Buffer.prototype.write = function write (string, offset, length, encoding) {
  677. // Buffer#write(string)
  678. if (offset === undefined) {
  679. encoding = 'utf8'
  680. length = this.length
  681. offset = 0
  682. // Buffer#write(string, encoding)
  683. } else if (length === undefined && typeof offset === 'string') {
  684. encoding = offset
  685. length = this.length
  686. offset = 0
  687. // Buffer#write(string, offset[, length][, encoding])
  688. } else if (isFinite(offset)) {
  689. offset = offset | 0
  690. if (isFinite(length)) {
  691. length = length | 0
  692. if (encoding === undefined) encoding = 'utf8'
  693. } else {
  694. encoding = length
  695. length = undefined
  696. }
  697. // legacy write(string, encoding, offset, length) - remove in v0.13
  698. } else {
  699. var swap = encoding
  700. encoding = offset
  701. offset = length | 0
  702. length = swap
  703. }
  704. var remaining = this.length - offset
  705. if (length === undefined || length > remaining) length = remaining
  706. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  707. throw new RangeError('attempt to write outside buffer bounds')
  708. }
  709. if (!encoding) encoding = 'utf8'
  710. var loweredCase = false
  711. for (;;) {
  712. switch (encoding) {
  713. case 'hex':
  714. return hexWrite(this, string, offset, length)
  715. case 'utf8':
  716. case 'utf-8':
  717. return utf8Write(this, string, offset, length)
  718. case 'ascii':
  719. return asciiWrite(this, string, offset, length)
  720. case 'binary':
  721. return binaryWrite(this, string, offset, length)
  722. case 'base64':
  723. // Warning: maxLength not taken into account in base64Write
  724. return base64Write(this, string, offset, length)
  725. case 'ucs2':
  726. case 'ucs-2':
  727. case 'utf16le':
  728. case 'utf-16le':
  729. return ucs2Write(this, string, offset, length)
  730. default:
  731. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  732. encoding = ('' + encoding).toLowerCase()
  733. loweredCase = true
  734. }
  735. }
  736. }
  737. Buffer.prototype.toJSON = function toJSON () {
  738. return {
  739. type: 'Buffer',
  740. data: Array.prototype.slice.call(this._arr || this, 0)
  741. }
  742. }
  743. function base64Slice (buf, start, end) {
  744. if (start === 0 && end === buf.length) {
  745. return base64.fromByteArray(buf)
  746. } else {
  747. return base64.fromByteArray(buf.slice(start, end))
  748. }
  749. }
  750. function utf8Slice (buf, start, end) {
  751. end = Math.min(buf.length, end)
  752. var res = []
  753. var i = start
  754. while (i < end) {
  755. var firstByte = buf[i]
  756. var codePoint = null
  757. var bytesPerSequence = (firstByte > 0xEF) ? 4
  758. : (firstByte > 0xDF) ? 3
  759. : (firstByte > 0xBF) ? 2
  760. : 1
  761. if (i + bytesPerSequence <= end) {
  762. var secondByte, thirdByte, fourthByte, tempCodePoint
  763. switch (bytesPerSequence) {
  764. case 1:
  765. if (firstByte < 0x80) {
  766. codePoint = firstByte
  767. }
  768. break
  769. case 2:
  770. secondByte = buf[i + 1]
  771. if ((secondByte & 0xC0) === 0x80) {
  772. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  773. if (tempCodePoint > 0x7F) {
  774. codePoint = tempCodePoint
  775. }
  776. }
  777. break
  778. case 3:
  779. secondByte = buf[i + 1]
  780. thirdByte = buf[i + 2]
  781. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  782. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  783. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  784. codePoint = tempCodePoint
  785. }
  786. }
  787. break
  788. case 4:
  789. secondByte = buf[i + 1]
  790. thirdByte = buf[i + 2]
  791. fourthByte = buf[i + 3]
  792. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  793. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  794. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  795. codePoint = tempCodePoint
  796. }
  797. }
  798. }
  799. }
  800. if (codePoint === null) {
  801. // we did not generate a valid codePoint so insert a
  802. // replacement char (U+FFFD) and advance only 1 byte
  803. codePoint = 0xFFFD
  804. bytesPerSequence = 1
  805. } else if (codePoint > 0xFFFF) {
  806. // encode to utf16 (surrogate pair dance)
  807. codePoint -= 0x10000
  808. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  809. codePoint = 0xDC00 | codePoint & 0x3FF
  810. }
  811. res.push(codePoint)
  812. i += bytesPerSequence
  813. }
  814. return decodeCodePointsArray(res)
  815. }
  816. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  817. // the lowest limit is Chrome, with 0x10000 args.
  818. // We go 1 magnitude less, for safety
  819. var MAX_ARGUMENTS_LENGTH = 0x1000
  820. function decodeCodePointsArray (codePoints) {
  821. var len = codePoints.length
  822. if (len <= MAX_ARGUMENTS_LENGTH) {
  823. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  824. }
  825. // Decode in chunks to avoid "call stack size exceeded".
  826. var res = ''
  827. var i = 0
  828. while (i < len) {
  829. res += String.fromCharCode.apply(
  830. String,
  831. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  832. )
  833. }
  834. return res
  835. }
  836. function asciiSlice (buf, start, end) {
  837. var ret = ''
  838. end = Math.min(buf.length, end)
  839. for (var i = start; i < end; i++) {
  840. ret += String.fromCharCode(buf[i] & 0x7F)
  841. }
  842. return ret
  843. }
  844. function binarySlice (buf, start, end) {
  845. var ret = ''
  846. end = Math.min(buf.length, end)
  847. for (var i = start; i < end; i++) {
  848. ret += String.fromCharCode(buf[i])
  849. }
  850. return ret
  851. }
  852. function hexSlice (buf, start, end) {
  853. var len = buf.length
  854. if (!start || start < 0) start = 0
  855. if (!end || end < 0 || end > len) end = len
  856. var out = ''
  857. for (var i = start; i < end; i++) {
  858. out += toHex(buf[i])
  859. }
  860. return out
  861. }
  862. function utf16leSlice (buf, start, end) {
  863. var bytes = buf.slice(start, end)
  864. var res = ''
  865. for (var i = 0; i < bytes.length; i += 2) {
  866. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  867. }
  868. return res
  869. }
  870. Buffer.prototype.slice = function slice (start, end) {
  871. var len = this.length
  872. start = ~~start
  873. end = end === undefined ? len : ~~end
  874. if (start < 0) {
  875. start += len
  876. if (start < 0) start = 0
  877. } else if (start > len) {
  878. start = len
  879. }
  880. if (end < 0) {
  881. end += len
  882. if (end < 0) end = 0
  883. } else if (end > len) {
  884. end = len
  885. }
  886. if (end < start) end = start
  887. var newBuf
  888. if (Buffer.TYPED_ARRAY_SUPPORT) {
  889. newBuf = Buffer._augment(this.subarray(start, end))
  890. } else {
  891. var sliceLen = end - start
  892. newBuf = new Buffer(sliceLen, undefined)
  893. for (var i = 0; i < sliceLen; i++) {
  894. newBuf[i] = this[i + start]
  895. }
  896. }
  897. if (newBuf.length) newBuf.parent = this.parent || this
  898. return newBuf
  899. }
  900. /*
  901. * Need to make sure that buffer isn't trying to write out of bounds.
  902. */
  903. function checkOffset (offset, ext, length) {
  904. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  905. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  906. }
  907. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  908. offset = offset | 0
  909. byteLength = byteLength | 0
  910. if (!noAssert) checkOffset(offset, byteLength, this.length)
  911. var val = this[offset]
  912. var mul = 1
  913. var i = 0
  914. while (++i < byteLength && (mul *= 0x100)) {
  915. val += this[offset + i] * mul
  916. }
  917. return val
  918. }
  919. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  920. offset = offset | 0
  921. byteLength = byteLength | 0
  922. if (!noAssert) {
  923. checkOffset(offset, byteLength, this.length)
  924. }
  925. var val = this[offset + --byteLength]
  926. var mul = 1
  927. while (byteLength > 0 && (mul *= 0x100)) {
  928. val += this[offset + --byteLength] * mul
  929. }
  930. return val
  931. }
  932. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  933. if (!noAssert) checkOffset(offset, 1, this.length)
  934. return this[offset]
  935. }
  936. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  937. if (!noAssert) checkOffset(offset, 2, this.length)
  938. return this[offset] | (this[offset + 1] << 8)
  939. }
  940. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  941. if (!noAssert) checkOffset(offset, 2, this.length)
  942. return (this[offset] << 8) | this[offset + 1]
  943. }
  944. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  945. if (!noAssert) checkOffset(offset, 4, this.length)
  946. return ((this[offset]) |
  947. (this[offset + 1] << 8) |
  948. (this[offset + 2] << 16)) +
  949. (this[offset + 3] * 0x1000000)
  950. }
  951. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  952. if (!noAssert) checkOffset(offset, 4, this.length)
  953. return (this[offset] * 0x1000000) +
  954. ((this[offset + 1] << 16) |
  955. (this[offset + 2] << 8) |
  956. this[offset + 3])
  957. }
  958. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  959. offset = offset | 0
  960. byteLength = byteLength | 0
  961. if (!noAssert) checkOffset(offset, byteLength, this.length)
  962. var val = this[offset]
  963. var mul = 1
  964. var i = 0
  965. while (++i < byteLength && (mul *= 0x100)) {
  966. val += this[offset + i] * mul
  967. }
  968. mul *= 0x80
  969. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  970. return val
  971. }
  972. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  973. offset = offset | 0
  974. byteLength = byteLength | 0
  975. if (!noAssert) checkOffset(offset, byteLength, this.length)
  976. var i = byteLength
  977. var mul = 1
  978. var val = this[offset + --i]
  979. while (i > 0 && (mul *= 0x100)) {
  980. val += this[offset + --i] * mul
  981. }
  982. mul *= 0x80
  983. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  984. return val
  985. }
  986. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  987. if (!noAssert) checkOffset(offset, 1, this.length)
  988. if (!(this[offset] & 0x80)) return (this[offset])
  989. return ((0xff - this[offset] + 1) * -1)
  990. }
  991. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  992. if (!noAssert) checkOffset(offset, 2, this.length)
  993. var val = this[offset] | (this[offset + 1] << 8)
  994. return (val & 0x8000) ? val | 0xFFFF0000 : val
  995. }
  996. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  997. if (!noAssert) checkOffset(offset, 2, this.length)
  998. var val = this[offset + 1] | (this[offset] << 8)
  999. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1000. }
  1001. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1002. if (!noAssert) checkOffset(offset, 4, this.length)
  1003. return (this[offset]) |
  1004. (this[offset + 1] << 8) |
  1005. (this[offset + 2] << 16) |
  1006. (this[offset + 3] << 24)
  1007. }
  1008. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1009. if (!noAssert) checkOffset(offset, 4, this.length)
  1010. return (this[offset] << 24) |
  1011. (this[offset + 1] << 16) |
  1012. (this[offset + 2] << 8) |
  1013. (this[offset + 3])
  1014. }
  1015. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1016. if (!noAssert) checkOffset(offset, 4, this.length)
  1017. return ieee754.read(this, offset, true, 23, 4)
  1018. }
  1019. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1020. if (!noAssert) checkOffset(offset, 4, this.length)
  1021. return ieee754.read(this, offset, false, 23, 4)
  1022. }
  1023. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1024. if (!noAssert) checkOffset(offset, 8, this.length)
  1025. return ieee754.read(this, offset, true, 52, 8)
  1026. }
  1027. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1028. if (!noAssert) checkOffset(offset, 8, this.length)
  1029. return ieee754.read(this, offset, false, 52, 8)
  1030. }
  1031. function checkInt (buf, value, offset, ext, max, min) {
  1032. if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
  1033. if (value > max || value < min) throw new RangeError('value is out of bounds')
  1034. if (offset + ext > buf.length) throw new RangeError('index out of range')
  1035. }
  1036. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1037. value = +value
  1038. offset = offset | 0
  1039. byteLength = byteLength | 0
  1040. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  1041. var mul = 1
  1042. var i = 0
  1043. this[offset] = value & 0xFF
  1044. while (++i < byteLength && (mul *= 0x100)) {
  1045. this[offset + i] = (value / mul) & 0xFF
  1046. }
  1047. return offset + byteLength
  1048. }
  1049. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1050. value = +value
  1051. offset = offset | 0
  1052. byteLength = byteLength | 0
  1053. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  1054. var i = byteLength - 1
  1055. var mul = 1
  1056. this[offset + i] = value & 0xFF
  1057. while (--i >= 0 && (mul *= 0x100)) {
  1058. this[offset + i] = (value / mul) & 0xFF
  1059. }
  1060. return offset + byteLength
  1061. }
  1062. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1063. value = +value
  1064. offset = offset | 0
  1065. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1066. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1067. this[offset] = (value & 0xff)
  1068. return offset + 1
  1069. }
  1070. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1071. if (value < 0) value = 0xffff + value + 1
  1072. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
  1073. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1074. (littleEndian ? i : 1 - i) * 8
  1075. }
  1076. }
  1077. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1078. value = +value
  1079. offset = offset | 0
  1080. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1081. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1082. this[offset] = (value & 0xff)
  1083. this[offset + 1] = (value >>> 8)
  1084. } else {
  1085. objectWriteUInt16(this, value, offset, true)
  1086. }
  1087. return offset + 2
  1088. }
  1089. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1090. value = +value
  1091. offset = offset | 0
  1092. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1093. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1094. this[offset] = (value >>> 8)
  1095. this[offset + 1] = (value & 0xff)
  1096. } else {
  1097. objectWriteUInt16(this, value, offset, false)
  1098. }
  1099. return offset + 2
  1100. }
  1101. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1102. if (value < 0) value = 0xffffffff + value + 1
  1103. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
  1104. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1105. }
  1106. }
  1107. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1108. value = +value
  1109. offset = offset | 0
  1110. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1111. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1112. this[offset + 3] = (value >>> 24)
  1113. this[offset + 2] = (value >>> 16)
  1114. this[offset + 1] = (value >>> 8)
  1115. this[offset] = (value & 0xff)
  1116. } else {
  1117. objectWriteUInt32(this, value, offset, true)
  1118. }
  1119. return offset + 4
  1120. }
  1121. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1122. value = +value
  1123. offset = offset | 0
  1124. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1125. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1126. this[offset] = (value >>> 24)
  1127. this[offset + 1] = (value >>> 16)
  1128. this[offset + 2] = (value >>> 8)
  1129. this[offset + 3] = (value & 0xff)
  1130. } else {
  1131. objectWriteUInt32(this, value, offset, false)
  1132. }
  1133. return offset + 4
  1134. }
  1135. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1136. value = +value
  1137. offset = offset | 0
  1138. if (!noAssert) {
  1139. var limit = Math.pow(2, 8 * byteLength - 1)
  1140. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1141. }
  1142. var i = 0
  1143. var mul = 1
  1144. var sub = value < 0 ? 1 : 0
  1145. this[offset] = value & 0xFF
  1146. while (++i < byteLength && (mul *= 0x100)) {
  1147. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1148. }
  1149. return offset + byteLength
  1150. }
  1151. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1152. value = +value
  1153. offset = offset | 0
  1154. if (!noAssert) {
  1155. var limit = Math.pow(2, 8 * byteLength - 1)
  1156. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1157. }
  1158. var i = byteLength - 1
  1159. var mul = 1
  1160. var sub = value < 0 ? 1 : 0
  1161. this[offset + i] = value & 0xFF
  1162. while (--i >= 0 && (mul *= 0x100)) {
  1163. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1164. }
  1165. return offset + byteLength
  1166. }
  1167. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1168. value = +value
  1169. offset = offset | 0
  1170. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1171. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1172. if (value < 0) value = 0xff + value + 1
  1173. this[offset] = (value & 0xff)
  1174. return offset + 1
  1175. }
  1176. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1177. value = +value
  1178. offset = offset | 0
  1179. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1180. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1181. this[offset] = (value & 0xff)
  1182. this[offset + 1] = (value >>> 8)
  1183. } else {
  1184. objectWriteUInt16(this, value, offset, true)
  1185. }
  1186. return offset + 2
  1187. }
  1188. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1189. value = +value
  1190. offset = offset | 0
  1191. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1192. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1193. this[offset] = (value >>> 8)
  1194. this[offset + 1] = (value & 0xff)
  1195. } else {
  1196. objectWriteUInt16(this, value, offset, false)
  1197. }
  1198. return offset + 2
  1199. }
  1200. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1201. value = +value
  1202. offset = offset | 0
  1203. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1204. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1205. this[offset] = (value & 0xff)
  1206. this[offset + 1] = (value >>> 8)
  1207. this[offset + 2] = (value >>> 16)
  1208. this[offset + 3] = (value >>> 24)
  1209. } else {
  1210. objectWriteUInt32(this, value, offset, true)
  1211. }
  1212. return offset + 4
  1213. }
  1214. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1215. value = +value
  1216. offset = offset | 0
  1217. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1218. if (value < 0) value = 0xffffffff + value + 1
  1219. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1220. this[offset] = (value >>> 24)
  1221. this[offset + 1] = (value >>> 16)
  1222. this[offset + 2] = (value >>> 8)
  1223. this[offset + 3] = (value & 0xff)
  1224. } else {
  1225. objectWriteUInt32(this, value, offset, false)
  1226. }
  1227. return offset + 4
  1228. }
  1229. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1230. if (value > max || value < min) throw new RangeError('value is out of bounds')
  1231. if (offset + ext > buf.length) throw new RangeError('index out of range')
  1232. if (offset < 0) throw new RangeError('index out of range')
  1233. }
  1234. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1235. if (!noAssert) {
  1236. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1237. }
  1238. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1239. return offset + 4
  1240. }
  1241. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1242. return writeFloat(this, value, offset, true, noAssert)
  1243. }
  1244. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1245. return writeFloat(this, value, offset, false, noAssert)
  1246. }
  1247. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1248. if (!noAssert) {
  1249. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1250. }
  1251. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1252. return offset + 8
  1253. }
  1254. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1255. return writeDouble(this, value, offset, true, noAssert)
  1256. }
  1257. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1258. return writeDouble(this, value, offset, false, noAssert)
  1259. }
  1260. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1261. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1262. if (!start) start = 0
  1263. if (!end && end !== 0) end = this.length
  1264. if (targetStart >= target.length) targetStart = target.length
  1265. if (!targetStart) targetStart = 0
  1266. if (end > 0 && end < start) end = start
  1267. // Copy 0 bytes; we're done
  1268. if (end === start) return 0
  1269. if (target.length === 0 || this.length === 0) return 0
  1270. // Fatal error conditions
  1271. if (targetStart < 0) {
  1272. throw new RangeError('targetStart out of bounds')
  1273. }
  1274. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1275. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1276. // Are we oob?
  1277. if (end > this.length) end = this.length
  1278. if (target.length - targetStart < end - start) {
  1279. end = target.length - targetStart + start
  1280. }
  1281. var len = end - start
  1282. var i
  1283. if (this === target && start < targetStart && targetStart < end) {
  1284. // descending copy from end
  1285. for (i = len - 1; i >= 0; i--) {
  1286. target[i + targetStart] = this[i + start]
  1287. }
  1288. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1289. // ascending copy from start
  1290. for (i = 0; i < len; i++) {
  1291. target[i + targetStart] = this[i + start]
  1292. }
  1293. } else {
  1294. target._set(this.subarray(start, start + len), targetStart)
  1295. }
  1296. return len
  1297. }
  1298. // fill(value, start=0, end=buffer.length)
  1299. Buffer.prototype.fill = function fill (value, start, end) {
  1300. if (!value) value = 0
  1301. if (!start) start = 0
  1302. if (!end) end = this.length
  1303. if (end < start) throw new RangeError('end < start')
  1304. // Fill 0 bytes; we're done
  1305. if (end === start) return
  1306. if (this.length === 0) return
  1307. if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
  1308. if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
  1309. var i
  1310. if (typeof value === 'number') {
  1311. for (i = start; i < end; i++) {
  1312. this[i] = value
  1313. }
  1314. } else {
  1315. var bytes = utf8ToBytes(value.toString())
  1316. var len = bytes.length
  1317. for (i = start; i < end; i++) {
  1318. this[i] = bytes[i % len]
  1319. }
  1320. }
  1321. return this
  1322. }
  1323. /**
  1324. * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
  1325. * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
  1326. */
  1327. Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
  1328. if (typeof Uint8Array !== 'undefined') {
  1329. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1330. return (new Buffer(this)).buffer
  1331. } else {
  1332. var buf = new Uint8Array(this.length)
  1333. for (var i = 0, len = buf.length; i < len; i += 1) {
  1334. buf[i] = this[i]
  1335. }
  1336. return buf.buffer
  1337. }
  1338. } else {
  1339. throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
  1340. }
  1341. }
  1342. // HELPER FUNCTIONS
  1343. // ================
  1344. var BP = Buffer.prototype
  1345. /**
  1346. * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
  1347. */
  1348. Buffer._augment = function _augment (arr) {
  1349. arr.constructor = Buffer
  1350. arr._isBuffer = true
  1351. // save reference to original Uint8Array set method before overwriting
  1352. arr._set = arr.set
  1353. // deprecated
  1354. arr.get = BP.get
  1355. arr.set = BP.set
  1356. arr.write = BP.write
  1357. arr.toString = BP.toString
  1358. arr.toLocaleString = BP.toString
  1359. arr.toJSON = BP.toJSON
  1360. arr.equals = BP.equals
  1361. arr.compare = BP.compare
  1362. arr.indexOf = BP.indexOf
  1363. arr.copy = BP.copy
  1364. arr.slice = BP.slice
  1365. arr.readUIntLE = BP.readUIntLE
  1366. arr.readUIntBE = BP.readUIntBE
  1367. arr.readUInt8 = BP.readUInt8
  1368. arr.readUInt16LE = BP.readUInt16LE
  1369. arr.readUInt16BE = BP.readUInt16BE
  1370. arr.readUInt32LE = BP.readUInt32LE
  1371. arr.readUInt32BE = BP.readUInt32BE
  1372. arr.readIntLE = BP.readIntLE
  1373. arr.readIntBE = BP.readIntBE
  1374. arr.readInt8 = BP.readInt8
  1375. arr.readInt16LE = BP.readInt16LE
  1376. arr.readInt16BE = BP.readInt16BE
  1377. arr.readInt32LE = BP.readInt32LE
  1378. arr.readInt32BE = BP.readInt32BE
  1379. arr.readFloatLE = BP.readFloatLE
  1380. arr.readFloatBE = BP.readFloatBE
  1381. arr.readDoubleLE = BP.readDoubleLE
  1382. arr.readDoubleBE = BP.readDoubleBE
  1383. arr.writeUInt8 = BP.writeUInt8
  1384. arr.writeUIntLE = BP.writeUIntLE
  1385. arr.writeUIntBE = BP.writeUIntBE
  1386. arr.writeUInt16LE = BP.writeUInt16LE
  1387. arr.writeUInt16BE = BP.writeUInt16BE
  1388. arr.writeUInt32LE = BP.writeUInt32LE
  1389. arr.writeUInt32BE = BP.writeUInt32BE
  1390. arr.writeIntLE = BP.writeIntLE
  1391. arr.writeIntBE = BP.writeIntBE
  1392. arr.writeInt8 = BP.writeInt8
  1393. arr.writeInt16LE = BP.writeInt16LE
  1394. arr.writeInt16BE = BP.writeInt16BE
  1395. arr.writeInt32LE = BP.writeInt32LE
  1396. arr.writeInt32BE = BP.writeInt32BE
  1397. arr.writeFloatLE = BP.writeFloatLE
  1398. arr.writeFloatBE = BP.writeFloatBE
  1399. arr.writeDoubleLE = BP.writeDoubleLE
  1400. arr.writeDoubleBE = BP.writeDoubleBE
  1401. arr.fill = BP.fill
  1402. arr.inspect = BP.inspect
  1403. arr.toArrayBuffer = BP.toArrayBuffer
  1404. return arr
  1405. }
  1406. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1407. function base64clean (str) {
  1408. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1409. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1410. // Node converts strings with length < 2 to ''
  1411. if (str.length < 2) return ''
  1412. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1413. while (str.length % 4 !== 0) {
  1414. str = str + '='
  1415. }
  1416. return str
  1417. }
  1418. function stringtrim (str) {
  1419. if (str.trim) return str.trim()
  1420. return str.replace(/^\s+|\s+$/g, '')
  1421. }
  1422. function toHex (n) {
  1423. if (n < 16) return '0' + n.toString(16)
  1424. return n.toString(16)
  1425. }
  1426. function utf8ToBytes (string, units) {
  1427. units = units || Infinity
  1428. var codePoint
  1429. var length = string.length
  1430. var leadSurrogate = null
  1431. var bytes = []
  1432. for (var i = 0; i < length; i++) {
  1433. codePoint = string.charCodeAt(i)
  1434. // is surrogate component
  1435. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1436. // last char was a lead
  1437. if (!leadSurrogate) {
  1438. // no lead yet
  1439. if (codePoint > 0xDBFF) {
  1440. // unexpected trail
  1441. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1442. continue
  1443. } else if (i + 1 === length) {
  1444. // unpaired lead
  1445. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1446. continue
  1447. }
  1448. // valid lead
  1449. leadSurrogate = codePoint
  1450. continue
  1451. }
  1452. // 2 leads in a row
  1453. if (codePoint < 0xDC00) {
  1454. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1455. leadSurrogate = codePoint
  1456. continue
  1457. }
  1458. // valid surrogate pair
  1459. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1460. } else if (leadSurrogate) {
  1461. // valid bmp char, but last char was a lead
  1462. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1463. }
  1464. leadSurrogate = null
  1465. // encode utf8
  1466. if (codePoint < 0x80) {
  1467. if ((units -= 1) < 0) break
  1468. bytes.push(codePoint)
  1469. } else if (codePoint < 0x800) {
  1470. if ((units -= 2) < 0) break
  1471. bytes.push(
  1472. codePoint >> 0x6 | 0xC0,
  1473. codePoint & 0x3F | 0x80
  1474. )
  1475. } else if (codePoint < 0x10000) {
  1476. if ((units -= 3) < 0) break
  1477. bytes.push(
  1478. codePoint >> 0xC | 0xE0,
  1479. codePoint >> 0x6 & 0x3F | 0x80,
  1480. codePoint & 0x3F | 0x80
  1481. )
  1482. } else if (codePoint < 0x110000) {
  1483. if ((units -= 4) < 0) break
  1484. bytes.push(
  1485. codePoint >> 0x12 | 0xF0,
  1486. codePoint >> 0xC & 0x3F | 0x80,
  1487. codePoint >> 0x6 & 0x3F | 0x80,
  1488. codePoint & 0x3F | 0x80
  1489. )
  1490. } else {
  1491. throw new Error('Invalid code point')
  1492. }
  1493. }
  1494. return bytes
  1495. }
  1496. function asciiToBytes (str) {
  1497. var byteArray = []
  1498. for (var i = 0; i < str.length; i++) {
  1499. // Node's code seems to be doing this and not & 0x7F..
  1500. byteArray.push(str.charCodeAt(i) & 0xFF)
  1501. }
  1502. return byteArray
  1503. }
  1504. function utf16leToBytes (str, units) {
  1505. var c, hi, lo
  1506. var byteArray = []
  1507. for (var i = 0; i < str.length; i++) {
  1508. if ((units -= 2) < 0) break
  1509. c = str.charCodeAt(i)
  1510. hi = c >> 8
  1511. lo = c % 256
  1512. byteArray.push(lo)
  1513. byteArray.push(hi)
  1514. }
  1515. return byteArray
  1516. }
  1517. function base64ToBytes (str) {
  1518. return base64.toByteArray(base64clean(str))
  1519. }
  1520. function blitBuffer (src, dst, offset, length) {
  1521. for (var i = 0; i < length; i++) {
  1522. if ((i + offset >= dst.length) || (i >= src.length)) break
  1523. dst[i + offset] = src[i]
  1524. }
  1525. return i
  1526. }
  1527. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1528. },{"base64-js":1,"ieee754":4,"isarray":3}],3:[function(require,module,exports){
  1529. var toString = {}.toString;
  1530. module.exports = Array.isArray || function (arr) {
  1531. return toString.call(arr) == '[object Array]';
  1532. };
  1533. },{}],4:[function(require,module,exports){
  1534. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  1535. var e, m
  1536. var eLen = (nBytes * 8) - mLen - 1
  1537. var eMax = (1 << eLen) - 1
  1538. var eBias = eMax >> 1
  1539. var nBits = -7
  1540. var i = isLE ? (nBytes - 1) : 0
  1541. var d = isLE ? -1 : 1
  1542. var s = buffer[offset + i]
  1543. i += d
  1544. e = s & ((1 << (-nBits)) - 1)
  1545. s >>= (-nBits)
  1546. nBits += eLen
  1547. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1548. m = e & ((1 << (-nBits)) - 1)
  1549. e >>= (-nBits)
  1550. nBits += mLen
  1551. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1552. if (e === 0) {
  1553. e = 1 - eBias
  1554. } else if (e === eMax) {
  1555. return m ? NaN : ((s ? -1 : 1) * Infinity)
  1556. } else {
  1557. m = m + Math.pow(2, mLen)
  1558. e = e - eBias
  1559. }
  1560. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  1561. }
  1562. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  1563. var e, m, c
  1564. var eLen = (nBytes * 8) - mLen - 1
  1565. var eMax = (1 << eLen) - 1
  1566. var eBias = eMax >> 1
  1567. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  1568. var i = isLE ? 0 : (nBytes - 1)
  1569. var d = isLE ? 1 : -1
  1570. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  1571. value = Math.abs(value)
  1572. if (isNaN(value) || value === Infinity) {
  1573. m = isNaN(value) ? 1 : 0
  1574. e = eMax
  1575. } else {
  1576. e = Math.floor(Math.log(value) / Math.LN2)
  1577. if (value * (c = Math.pow(2, -e)) < 1) {
  1578. e--
  1579. c *= 2
  1580. }
  1581. if (e + eBias >= 1) {
  1582. value += rt / c
  1583. } else {
  1584. value += rt * Math.pow(2, 1 - eBias)
  1585. }
  1586. if (value * c >= 2) {
  1587. e++
  1588. c /= 2
  1589. }
  1590. if (e + eBias >= eMax) {
  1591. m = 0
  1592. e = eMax
  1593. } else if (e + eBias >= 1) {
  1594. m = ((value * c) - 1) * Math.pow(2, mLen)
  1595. e = e + eBias
  1596. } else {
  1597. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  1598. e = 0
  1599. }
  1600. }
  1601. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  1602. e = (e << mLen) | m
  1603. eLen += mLen
  1604. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  1605. buffer[offset + i - d] |= s * 128
  1606. }
  1607. },{}],5:[function(require,module,exports){
  1608. exports.v4 = require('./lib/ipv4.js').v4;
  1609. exports.v6 = require('./lib/ipv6.js').v6;
  1610. },{"./lib/ipv4.js":7,"./lib/ipv6.js":8}],6:[function(require,module,exports){
  1611. 'use strict';
  1612. var repeatString = exports.repeatString = function (s, n) {
  1613. var result = '';
  1614. var i;
  1615. for (i = 0; i < n; i++) {
  1616. result += s;
  1617. }
  1618. return result;
  1619. };
  1620. exports.zeroPad = function (s, n) {
  1621. return String(repeatString(0, n) + s).slice(n * -1);
  1622. };
  1623. // A wrapper function that returns false if the address is not valid; used to
  1624. // avoid boilerplate checks for `if (!this.valid) { return false; }`
  1625. var falseIfInvalid = exports.falseIfInvalid = function (fn) {
  1626. return function () {
  1627. if (!this.valid) {
  1628. return false;
  1629. }
  1630. return fn.apply(this, arguments);
  1631. };
  1632. };
  1633. exports.isInSubnet = falseIfInvalid(function (address) {
  1634. if (this.subnetMask < address.subnetMask) {
  1635. return false;
  1636. }
  1637. if (this.mask(address.subnetMask) === address.mask()) {
  1638. return true;
  1639. }
  1640. return false;
  1641. });
  1642. exports.isCorrect = function (defaultBits) {
  1643. return falseIfInvalid(function () {
  1644. if (this.addressMinusSuffix !== this.correctForm()) {
  1645. return false;
  1646. }
  1647. if (this.subnetMask === defaultBits && !this.parsedSubnet) {
  1648. return true;
  1649. }
  1650. return this.parsedSubnet === String(this.subnetMask);
  1651. });
  1652. };
  1653. },{}],7:[function(require,module,exports){
  1654. 'use strict';
  1655. var BigInteger = require('jsbn');
  1656. var common = require('./common.js');
  1657. var merge = require('lodash.merge');
  1658. var sprintf = require('sprintf').sprintf;
  1659. var v4 = exports.v4 = {};
  1660. merge(v4, require('./v4/constants.js'));
  1661. /*
  1662. * Instantiates an IPv4 address
  1663. */
  1664. v4.Address = function (address) {
  1665. this.valid = false;
  1666. this.address = address;
  1667. this.groups = v4.GROUPS;
  1668. this.v4 = true;
  1669. this.subnet = '/32';
  1670. this.subnetMask = 32;
  1671. var subnet = v4.RE_SUBNET_STRING.exec(address);
  1672. if (subnet) {
  1673. this.parsedSubnet = subnet[0].replace('/', '');
  1674. this.subnetMask = parseInt(this.parsedSubnet, 10);
  1675. this.subnet = '/' + this.subnetMask;
  1676. if (this.subnetMask < 0 || this.subnetMask > v4.BITS) {
  1677. this.valid = false;
  1678. this.error = 'Invalid subnet mask.';
  1679. return;
  1680. }
  1681. address = address.replace(v4.RE_SUBNET_STRING, '');
  1682. }
  1683. this.addressMinusSuffix = address;
  1684. this.parsedAddress = this.parse(address);
  1685. };
  1686. /*
  1687. * Parses a v4 address
  1688. */
  1689. v4.Address.prototype.parse = function (address) {
  1690. var groups = address.split('.');
  1691. if (address.match(v4.RE_ADDRESS)) {
  1692. this.valid = true;
  1693. } else {
  1694. this.error = 'Invalid IPv4 address.';
  1695. }
  1696. return groups;
  1697. };
  1698. /*
  1699. * Returns true if the address is valid
  1700. */
  1701. v4.Address.prototype.isValid = function () {
  1702. return this.valid;
  1703. };
  1704. /*
  1705. * Returns the correct form of an address
  1706. */
  1707. v4.Address.prototype.correctForm = function () {
  1708. return this.parsedAddress.map(function (part) {
  1709. return parseInt(part, 10);
  1710. }).join('.');
  1711. };
  1712. /*
  1713. * Returns true if the address is correct, false otherwise
  1714. */
  1715. v4.Address.prototype.isCorrect = common.isCorrect(v4.BITS);
  1716. /*
  1717. * Converts a hex string to an IPv4 address object
  1718. */
  1719. v4.Address.fromHex = function (hex) {
  1720. var padded = common.zeroPad(hex.replace(/:/g, ''), 8);
  1721. var groups = [];
  1722. var i;
  1723. for (i = 0; i < 8; i += 2) {
  1724. var h = padded.slice(i, i + 2);
  1725. groups.push(parseInt(h, 16));
  1726. }
  1727. return new v4.Address(groups.join('.'));
  1728. };
  1729. /*
  1730. * Converts an integer into a IPv4 address object
  1731. */
  1732. v4.Address.fromInteger = function (integer) {
  1733. return v4.Address.fromHex(integer.toString(16));
  1734. };
  1735. /*
  1736. * Converts an IPv4 address object to a hex string
  1737. */
  1738. v4.Address.prototype.toHex = function () {
  1739. return this.parsedAddress.map(function (part) {
  1740. return sprintf('%02x', parseInt(part, 10));
  1741. }).join(':');
  1742. };
  1743. /*
  1744. * Converts an IPv4 address object to an array of bytes
  1745. */
  1746. v4.Address.prototype.toArray = function () {
  1747. return this.parsedAddress.map(function (part) {
  1748. return parseInt(part, 10);
  1749. });
  1750. };
  1751. /*
  1752. * Converts an IPv4 address object to an IPv6 address group
  1753. */
  1754. v4.Address.prototype.toV6Group = function () {
  1755. var output = [];
  1756. var i;
  1757. for (i = 0; i < v4.GROUPS; i += 2) {
  1758. var hex = sprintf('%02x%02x',
  1759. parseInt(this.parsedAddress[i], 10),
  1760. parseInt(this.parsedAddress[i + 1], 10));
  1761. output.push(sprintf('%x', parseInt(hex, 16)));
  1762. }
  1763. return output.join(':');
  1764. };
  1765. /*
  1766. * Returns the address as a BigInteger
  1767. */
  1768. v4.Address.prototype.bigInteger = function () {
  1769. if (!this.valid) {
  1770. return null;
  1771. }
  1772. return new BigInteger(this.parsedAddress.map(function (n) {
  1773. return sprintf('%02x', parseInt(n, 10));
  1774. }).join(''), 16);
  1775. };
  1776. /*
  1777. * The first address in the range given by this address' subnet.
  1778. * Often referred to as the Network Address.
  1779. */
  1780. v4.Address.prototype.startAddress = function () {
  1781. var startAddress = new BigInteger(this.mask() +
  1782. common.repeatString(0, v4.BITS - this.subnetMask), 2);
  1783. return v4.Address.fromBigInteger(startAddress);
  1784. };
  1785. /*
  1786. * The last address in the range given by this address' subnet
  1787. * Often referred to as the Broadcast
  1788. */
  1789. v4.Address.prototype.endAddress = function () {
  1790. var endAddress = new BigInteger(this.mask() +
  1791. common.repeatString(1, v4.BITS - this.subnetMask), 2);
  1792. return v4.Address.fromBigInteger(endAddress);
  1793. };
  1794. /*
  1795. * Converts a BigInteger to a v4 address object
  1796. */
  1797. v4.Address.fromBigInteger = function (bigInteger) {
  1798. return v4.Address.fromInteger(parseInt(bigInteger.toString(), 10));
  1799. };
  1800. /*
  1801. * Returns the first n bits of the address, defaulting to the
  1802. * subnet mask
  1803. */
  1804. v4.Address.prototype.mask = function (optionalMask) {
  1805. if (optionalMask === undefined) {
  1806. optionalMask = this.subnetMask;
  1807. }
  1808. return this.getBitsBase2(0, optionalMask);
  1809. };
  1810. /*
  1811. * Returns the bits in the given range as a base-2 string
  1812. */
  1813. v4.Address.prototype.getBitsBase2 = function (start, end) {
  1814. return this.binaryZeroPad().slice(start, end);
  1815. };
  1816. /*
  1817. * Returns true if the given address is in the subnet of the current address
  1818. */
  1819. v4.Address.prototype.isInSubnet = common.isInSubnet;
  1820. /*
  1821. * Returns a zero-padded base-2 string representation of the address
  1822. */
  1823. v4.Address.prototype.binaryZeroPad = function () {
  1824. return common.zeroPad(this.bigInteger().toString(2), v4.BITS);
  1825. };
  1826. },{"./common.js":6,"./v4/constants.js":9,"jsbn":15,"lodash.merge":36,"sprintf":44}],8:[function(require,module,exports){
  1827. 'use strict';
  1828. var BigInteger = require('jsbn');
  1829. var common = require('./common.js');
  1830. var find = require('lodash.find');
  1831. var merge = require('lodash.merge');
  1832. var sprintf = require('sprintf').sprintf;
  1833. var v4 = require('./ipv4.js').v4;
  1834. var v6 = exports.v6 = {
  1835. helpers: require('./v6/helpers.js')
  1836. };
  1837. merge(v6, require('./v6/constants.js'));
  1838. function addCommas(number) {
  1839. var r = /(\d+)(\d{3})/;
  1840. while (r.test(number)) {
  1841. number = number.replace(r, '$1,$2');
  1842. }
  1843. return number;
  1844. }
  1845. function spanLeadingZeroes4(n) {
  1846. n = n.replace(/^(0{1,})([1-9]+)$/, '<span class="parse-error">$1</span>$2');
  1847. n = n.replace(/^(0{1,})(0)$/, '<span class="parse-error">$1</span>$2');
  1848. return n;
  1849. }
  1850. /*
  1851. * Instantiates an IPv6 address
  1852. */
  1853. v6.Address = function (address, optionalGroups) {
  1854. if (optionalGroups === undefined) {
  1855. this.groups = v6.GROUPS;
  1856. } else {
  1857. this.groups = optionalGroups;
  1858. }
  1859. this.v4 = false;
  1860. this.subnet = '/128';
  1861. this.subnetMask = 128;
  1862. this.zone = '';
  1863. this.address = address;
  1864. var subnet = v6.RE_SUBNET_STRING.exec(address);
  1865. if (subnet) {
  1866. this.parsedSubnet = subnet[0].replace('/', '');
  1867. this.subnetMask = parseInt(this.parsedSubnet, 10);
  1868. this.subnet = '/' + this.subnetMask;
  1869. if (isNaN(this.subnetMask) ||
  1870. this.subnetMask < 0 ||
  1871. this.subnetMask > v6.BITS) {
  1872. this.valid = false;
  1873. this.error = 'Invalid subnet mask.';
  1874. return;
  1875. }
  1876. address = address.replace(v6.RE_SUBNET_STRING, '');
  1877. } else if (/\//.test(address)) {
  1878. this.valid = false;
  1879. this.error = 'Invalid subnet mask.';
  1880. return;
  1881. }
  1882. var zone = v6.RE_ZONE_STRING.exec(address);
  1883. if (zone) {
  1884. this.zone = zone[0];
  1885. address = address.replace(v6.RE_ZONE_STRING, '');
  1886. }
  1887. this.addressMinusSuffix = address;
  1888. this.parsedAddress = this.parse(this.addressMinusSuffix);
  1889. };
  1890. merge(v6.Address.prototype, require('./v6/attributes.js'));
  1891. merge(v6.Address.prototype, require('./v6/html.js'));
  1892. merge(v6.Address.prototype, require('./v6/regular-expressions.js'));
  1893. /*
  1894. * Converts a BigInteger to a v6 address object
  1895. */
  1896. v6.Address.fromBigInteger = function (bigInteger) {
  1897. var hex = common.zeroPad(bigInteger.toString(16), 32);
  1898. var groups = [];
  1899. var i;
  1900. for (i = 0; i < v6.GROUPS; i++) {
  1901. groups.push(hex.slice(i * 4, (i + 1) * 4));
  1902. }
  1903. return new v6.Address(groups.join(':'));
  1904. };
  1905. /*
  1906. * Converts a URL (optional port number) to an address object
  1907. */
  1908. v6.Address.fromURL = function (url) {
  1909. var host;
  1910. var port;
  1911. var result;
  1912. // If we have brackets parse them and find a port
  1913. if (url.indexOf('[') !== -1 && url.indexOf(']:') !== -1) {
  1914. result = v6.RE_URL_WITH_PORT.exec(url);
  1915. if (result === null) {
  1916. return {
  1917. error: 'failed to parse address with port',
  1918. address: null,
  1919. port: null
  1920. };
  1921. }
  1922. host = result[1];
  1923. port = result[2];
  1924. // If there's a URL extract the address
  1925. } else if (url.indexOf('/') !== -1) {
  1926. // Remove the protocol prefix
  1927. url = url.replace(/^[a-z0-9]+:\/\//, '');
  1928. // Parse the address
  1929. result = v6.RE_URL.exec(url);
  1930. if (result === null) {
  1931. return {
  1932. error: 'failed to parse address from URL',
  1933. address: null,
  1934. port: null
  1935. };
  1936. }
  1937. host = result[1];
  1938. // Otherwise just assign the URL to the host and let the library parse it
  1939. } else {
  1940. host = url;
  1941. }
  1942. // If there's a port convert it to an integer
  1943. if (port) {
  1944. port = parseInt(port, 10);
  1945. //squelch out of range ports
  1946. if (port < 0 || port > 65536) {
  1947. port = null;
  1948. }
  1949. } else {
  1950. // Standardize `undefined` to `null`
  1951. port = null;
  1952. }
  1953. return {
  1954. address: new v6.Address(host),
  1955. port: port
  1956. };
  1957. };
  1958. /*
  1959. * Create an IPv6-mapped address given an IPv4 address
  1960. */
  1961. v6.Address.fromAddress4 = function (address4) {
  1962. return new v6.Address('::ffff:' + address4);
  1963. };
  1964. /*
  1965. * A helper function to compact an array
  1966. */
  1967. v6.Address.compact = function (address, slice) {
  1968. var s1 = [];
  1969. var s2 = [];
  1970. var i;
  1971. for (i = 0; i < address.length; i++) {
  1972. if (i < slice[0]) {
  1973. s1.push(address[i]);
  1974. } else if (i > slice[1]) {
  1975. s2.push(address[i]);
  1976. }
  1977. }
  1978. return s1.concat(['compact']).concat(s2);
  1979. };
  1980. /*
  1981. * Returns the Microsoft UNC transcription of the address
  1982. */
  1983. v6.Address.prototype.microsoftTranscription = function () {
  1984. return sprintf('%s.ipv6-literal.net',
  1985. this.correctForm().replace(/:/g, '-'));
  1986. };
  1987. /*
  1988. * Returns the first n bits of the address, defaulting to the
  1989. * subnet mask
  1990. */
  1991. v6.Address.prototype.mask = function (optionalMask) {
  1992. if (optionalMask === undefined) {
  1993. optionalMask = this.subnetMask;
  1994. }
  1995. return this.getBitsBase2(0, optionalMask);
  1996. };
  1997. /*
  1998. * Returns the number of possible subnets of a given size in the address
  1999. */
  2000. v6.Address.prototype.possibleSubnets = function (optionalSubnetSize) {
  2001. if (optionalSubnetSize === undefined) {
  2002. optionalSubnetSize = 128;
  2003. }
  2004. var availableBits = v6.BITS - this.subnetMask;
  2005. var subnetBits = Math.abs(optionalSubnetSize - v6.BITS);
  2006. var subnetPowers = availableBits - subnetBits;
  2007. if (subnetPowers < 0) {
  2008. return '0';
  2009. }
  2010. return addCommas(new BigInteger('2', 10).pow(subnetPowers).toString(10));
  2011. };
  2012. /*
  2013. * The first address in the range given by this address' subnet
  2014. */
  2015. v6.Address.prototype.startAddress = function () {
  2016. var startAddress = new BigInteger(this.mask() +
  2017. common.repeatString(0, v6.BITS - this.subnetMask), 2);
  2018. return v6.Address.fromBigInteger(startAddress);
  2019. };
  2020. /*
  2021. * The last address in the range given by this address' subnet
  2022. */
  2023. v6.Address.prototype.endAddress = function () {
  2024. var endAddress = new BigInteger(this.mask() +
  2025. common.repeatString(1, v6.BITS - this.subnetMask), 2);
  2026. return v6.Address.fromBigInteger(endAddress);
  2027. };
  2028. /*
  2029. * Returns the scope of the address
  2030. */
  2031. v6.Address.prototype.getScope = function () {
  2032. var scope = v6.SCOPES[this.getBits(12, 16)];
  2033. if (this.getType() === 'Global unicast' &&
  2034. scope !== 'Link local') {
  2035. scope = 'Global';
  2036. }
  2037. return scope;
  2038. };
  2039. /*
  2040. * Returns the type of the address
  2041. */
  2042. v6.Address.prototype.getType = function () {
  2043. var self = this;
  2044. function isType(name, type) {
  2045. return self.isInSubnet(new v6.Address(type));
  2046. }
  2047. return find(v6.TYPES, isType) || 'Global unicast';
  2048. };
  2049. /*
  2050. * Returns the bits in the given range as a BigInteger
  2051. */
  2052. v6.Address.prototype.getBits = function (start, end) {
  2053. return new BigInteger(this.getBitsBase2(start, end), 2);
  2054. };
  2055. /*
  2056. * Returns the bits in the given range as a base-2 string
  2057. */
  2058. v6.Address.prototype.getBitsBase2 = function (start, end) {
  2059. return this.binaryZeroPad().slice(start, end);
  2060. };
  2061. /*
  2062. * Returns the bits in the given range as a base-16 string
  2063. */
  2064. v6.Address.prototype.getBitsBase16 = function (start, end) {
  2065. var length = end - start;
  2066. if (length % 4 !== 0) {
  2067. return null;
  2068. }
  2069. return common.zeroPad(this.getBits(start, end).toString(16), length / 4);
  2070. };
  2071. /*
  2072. * Returns the bits that are set past the subnet mask length
  2073. */
  2074. v6.Address.prototype.getBitsPastSubnet = function () {
  2075. return this.getBitsBase2(this.subnetMask, v6.BITS);
  2076. };
  2077. /*
  2078. * Returns the reversed ip6.arpa form of the address
  2079. */
  2080. v6.Address.prototype.reverseForm = function () {
  2081. var characters = Math.floor(this.subnetMask / 4);
  2082. var reversed = this.canonicalForm()
  2083. .replace(/:/g, '')
  2084. .split('')
  2085. .slice(0, characters)
  2086. .reverse()
  2087. .join('.');
  2088. if (characters > 0) {
  2089. return sprintf('%s.ip6.arpa.', reversed);
  2090. }
  2091. return 'ip6.arpa.';
  2092. };
  2093. /*
  2094. * Returns the correct form of the address
  2095. */
  2096. v6.Address.prototype.correctForm = function () {
  2097. if (!this.parsedAddress) {
  2098. return null;
  2099. }
  2100. var i;
  2101. var groups = [];
  2102. var zeroCounter = 0;
  2103. var zeroes = [];
  2104. for (i = 0; i < this.parsedAddress.length; i++) {
  2105. var value = parseInt(this.parsedAddress[i], 16);
  2106. if (value === 0) {
  2107. zeroCounter++;
  2108. }
  2109. if (value !== 0 && zeroCounter > 0) {
  2110. if (zeroCounter > 1) {
  2111. zeroes.push([i - zeroCounter, i - 1]);
  2112. }
  2113. zeroCounter = 0;
  2114. }
  2115. }
  2116. // Do we end with a string of zeroes?
  2117. if (zeroCounter > 1) {
  2118. zeroes.push([this.parsedAddress.length - zeroCounter,
  2119. this.parsedAddress.length - 1]);
  2120. }
  2121. var zeroLengths = zeroes.map(function (n) {
  2122. return (n[1] - n[0]) + 1;
  2123. });
  2124. if (zeroes.length > 0) {
  2125. var max = Math.max.apply(Math, zeroLengths);
  2126. var index = zeroLengths.indexOf(max);
  2127. groups = v6.Address.compact(this.parsedAddress, zeroes[index]);
  2128. } else {
  2129. groups = this.parsedAddress;
  2130. }
  2131. for (i = 0; i < groups.length; i++) {
  2132. if (groups[i] !== 'compact') {
  2133. groups[i] = parseInt(groups[i], 16).toString(16);
  2134. }
  2135. }
  2136. var correct = groups.join(':');
  2137. correct = correct.replace(/^compact$/, '::');
  2138. correct = correct.replace(/^compact|compact$/, ':');
  2139. correct = correct.replace(/compact/, '');
  2140. return correct;
  2141. };
  2142. /*
  2143. * Returns a zero-padded base-2 string representation of the address
  2144. */
  2145. v6.Address.prototype.binaryZeroPad = function () {
  2146. return common.zeroPad(this.bigInteger().toString(2), v6.BITS);
  2147. };
  2148. // TODO: Improve the semantics of this helper function
  2149. v6.Address.prototype.parse4in6 = function (address) {
  2150. var groups = address.split(':');
  2151. var lastGroup = groups.slice(-1)[0];
  2152. var address4 = lastGroup.match(v4.RE_ADDRESS);
  2153. if (address4) {
  2154. var temp4 = new v4.Address(address4[0]);
  2155. for (var i = 0; i < temp4.groups; i++) {
  2156. if (/^0[0-9]+/.test(temp4.parsedAddress[i])) {
  2157. this.valid = false;
  2158. this.error = 'IPv4 addresses can not have leading zeroes.';
  2159. this.parseError = address.replace(v4.RE_ADDRESS,
  2160. temp4.parsedAddress.map(spanLeadingZeroes4).join('.'));
  2161. return null;
  2162. }
  2163. }
  2164. this.v4 = true;
  2165. groups[groups.length - 1] = temp4.toV6Group();
  2166. address = groups.join(':');
  2167. }
  2168. return address;
  2169. };
  2170. // TODO: Make private?
  2171. v6.Address.prototype.parse = function (address) {
  2172. address = this.parse4in6(address);
  2173. if (this.error) {
  2174. return null;
  2175. }
  2176. var badCharacters = address.match(v6.RE_BAD_CHARACTERS);
  2177. if (badCharacters) {
  2178. this.valid = false;
  2179. this.error = sprintf('Bad character%s detected in address: %s',
  2180. badCharacters.length > 1 ? 's' : '', badCharacters.join(''));
  2181. this.parseError = address.replace(v6.RE_BAD_CHARACTERS,
  2182. '<span class="parse-error">$1</span>');
  2183. return null;
  2184. }
  2185. var badAddress = address.match(v6.RE_BAD_ADDRESS);
  2186. if (badAddress) {
  2187. this.valid = false;
  2188. this.error = sprintf('Address failed regex: %s', badAddress.join(''));
  2189. this.parseError = address.replace(v6.RE_BAD_ADDRESS,
  2190. '<span class="parse-error">$1</span>');
  2191. return null;
  2192. }
  2193. var groups = [];
  2194. var halves = address.split('::');
  2195. if (halves.length === 2) {
  2196. var first = halves[0].split(':');
  2197. var last = halves[1].split(':');
  2198. if (first.length === 1 &&
  2199. first[0] === '') {
  2200. first = [];
  2201. }
  2202. if (last.length === 1 &&
  2203. last[0] === '') {
  2204. last = [];
  2205. }
  2206. var remaining = this.groups - (first.length + last.length);
  2207. if (!remaining) {
  2208. this.valid = false;
  2209. this.error = 'Error parsing groups';
  2210. return null;
  2211. }
  2212. this.elidedGroups = remaining;
  2213. this.elisionBegin = first.length;
  2214. this.elisionEnd = first.length + this.elidedGroups;
  2215. first.forEach(function (group) {
  2216. groups.push(group);
  2217. });
  2218. for (var i = 0; i < remaining; i++) {
  2219. groups.push(0);
  2220. }
  2221. last.forEach(function (group) {
  2222. groups.push(group);
  2223. });
  2224. } else if (halves.length === 1) {
  2225. groups = address.split(':');
  2226. this.elidedGroups = 0;
  2227. } else {
  2228. this.valid = false;
  2229. this.error = 'Too many :: groups found';
  2230. return null;
  2231. }
  2232. groups = groups.map(function (g) {
  2233. return sprintf('%x', parseInt(g, 16));
  2234. });
  2235. if (groups.length !== this.groups) {
  2236. this.valid = false;
  2237. this.error = 'Incorrect number of groups found';
  2238. return null;
  2239. }
  2240. this.valid = true;
  2241. return groups;
  2242. };
  2243. /*
  2244. * Returns the canonical form of the address
  2245. */
  2246. v6.Address.prototype.canonicalForm = function () {
  2247. if (!this.valid) {
  2248. return null;
  2249. }
  2250. return this.parsedAddress.map(function (n) {
  2251. return sprintf('%04x', parseInt(n, 16));
  2252. }).join(':');
  2253. };
  2254. /*
  2255. * Returns the decimal form of the address
  2256. */
  2257. v6.Address.prototype.decimal = function () {
  2258. if (!this.valid) {
  2259. return null;
  2260. }
  2261. return this.parsedAddress.map(function (n) {
  2262. return sprintf('%05d', parseInt(n, 16));
  2263. }).join(':');
  2264. };
  2265. /*
  2266. * Returns the address as a BigInteger
  2267. */
  2268. v6.Address.prototype.bigInteger = function () {
  2269. if (!this.valid) {
  2270. return null;
  2271. }
  2272. return new BigInteger(this.parsedAddress.map(function (n) {
  2273. return sprintf('%04x', parseInt(n, 16));
  2274. }).join(''), 16);
  2275. };
  2276. v6.Address.prototype.tov4 = function () {
  2277. var binary = this.binaryZeroPad().split('');
  2278. return v4.Address.fromHex(new BigInteger(binary.slice(96, 128)
  2279. .join(''), 2).toString(16));
  2280. };
  2281. /*
  2282. * Returns the v4-in-v6 form of the address
  2283. */
  2284. v6.Address.prototype.v4inv6 = function () {
  2285. var address4 = this.tov4();
  2286. var address6 = new v6.Address(this.parsedAddress.slice(0, 6).join(':'), 6);
  2287. var correct = address6.correctForm();
  2288. var infix = '';
  2289. if (!/:$/.test(correct)) {
  2290. infix = ':';
  2291. }
  2292. return address6.correctForm() + infix + address4.address;
  2293. };
  2294. /*
  2295. * Returns an object containing the Teredo properties of the address
  2296. */
  2297. v6.Address.prototype.teredo = function () {
  2298. /*
  2299. - Bits 0 to 31 are set to the Teredo prefix (normally 2001:0000::/32).
  2300. - Bits 32 to 63 embed the primary IPv4 address of the Teredo server that
  2301. is used.
  2302. - Bits 64 to 79 can be used to define some flags. Currently only the
  2303. higher order bit is used; it is set to 1 if the Teredo client is
  2304. located behind a cone NAT, 0 otherwise. For Microsoft's Windows Vista
  2305. and Windows Server 2008 implementations, more bits are used. In those
  2306. implementations, the format for these 16 bits is "CRAAAAUG AAAAAAAA",
  2307. where "C" remains the "Cone" flag. The "R" bit is reserved for future
  2308. use. The "U" bit is for the Universal/Local flag (set to 0). The "G" bit
  2309. is Individual/Group flag (set to 0). The A bits are set to a 12-bit
  2310. randomly generated number chosen by the Teredo client to introduce
  2311. additional protection for the Teredo node against IPv6-based scanning
  2312. attacks.
  2313. - Bits 80 to 95 contains the obfuscated UDP port number. This is the
  2314. port number that is mapped by the NAT to the Teredo client with all
  2315. bits inverted.
  2316. - Bits 96 to 127 contains the obfuscated IPv4 address. This is the
  2317. public IPv4 address of the NAT with all bits inverted.
  2318. */
  2319. var prefix = this.getBitsBase16(0, 32);
  2320. var udpPort = this.getBits(80, 96).xor(new BigInteger('ffff', 16)).toString();
  2321. var server4 = v4.Address.fromHex(this.getBitsBase16(32, 64));
  2322. var client4 = v4.Address.fromHex(this.getBits(96, 128)
  2323. .xor(new BigInteger('ffffffff', 16)).toString(16));
  2324. var flags = this.getBits(64, 80);
  2325. var flagsBase2 = this.getBitsBase2(64, 80);
  2326. var coneNat = flags.testBit(15);
  2327. var reserved = flags.testBit(14);
  2328. var groupIndividual = flags.testBit(8);
  2329. var universalLocal = flags.testBit(9);
  2330. var nonce = new BigInteger(flagsBase2.slice(2, 6) +
  2331. flagsBase2.slice(8, 16), 2).toString(10);
  2332. return {
  2333. prefix: sprintf('%s:%s', prefix.slice(0, 4), prefix.slice(4, 8)),
  2334. server4: server4.address,
  2335. client4: client4.address,
  2336. flags: flagsBase2,
  2337. coneNat: coneNat,
  2338. microsoft: {
  2339. reserved: reserved,
  2340. universalLocal: universalLocal,
  2341. groupIndividual: groupIndividual,
  2342. nonce: nonce
  2343. },
  2344. udpPort: udpPort
  2345. };
  2346. };
  2347. /*
  2348. * Returns an object containing the 6to4 properties of the address
  2349. */
  2350. v6.Address.prototype.six2four = function () {
  2351. /*
  2352. - Bits 0 to 15 are set to the 6to4 prefix (2002::/16).
  2353. - Bits 16 to 48 embed the IPv4 address of the 6to4 gateway that is used.
  2354. */
  2355. var prefix = this.getBitsBase16(0, 16);
  2356. var gateway = v4.Address.fromHex(this.getBitsBase16(16, 48));
  2357. return {
  2358. prefix: sprintf('%s', prefix.slice(0, 4)),
  2359. gateway: gateway.address
  2360. };
  2361. };
  2362. /*
  2363. * Returns a v6 6to4 address from a v6 v4inv6 address.
  2364. */
  2365. v6.Address.prototype.get6to4 = function () {
  2366. if (!this.is4()) {
  2367. return null;
  2368. }
  2369. var addr6to4 = [
  2370. '2002',
  2371. this.getBitsBase16(96, 112),
  2372. this.getBitsBase16(112, 128),
  2373. '',
  2374. '/16'
  2375. ].join(':');
  2376. return new v6.Address(addr6to4);
  2377. };
  2378. v6.Address.prototype.toByteArray = function () {
  2379. return this.bigInteger().toByteArray();
  2380. };
  2381. v6.Address.prototype.toUnsignedByteArray = function () {
  2382. return this.toByteArray().map(function (b) {
  2383. return b & 0xFF;
  2384. });
  2385. };
  2386. v6.Address.fromUnsignedByteArray = function (bytes) {
  2387. var BYTE_MAX = new BigInteger('256', 10);
  2388. var result = new BigInteger('0', 10);
  2389. var multiplier = new BigInteger('1', 10);
  2390. for (var i = bytes.length - 1; i >= 0; i--) {
  2391. result = result.add(
  2392. multiplier.multiply(new BigInteger(bytes[i].toString(10), 10)));
  2393. multiplier = multiplier.multiply(BYTE_MAX);
  2394. }
  2395. return v6.Address.fromBigInteger(result);
  2396. };
  2397. v6.Address.fromByteArray = function (bytes) {
  2398. return this.fromUnsignedByteArray(bytes.map(function (b) {
  2399. return b & 0xFF;
  2400. }));
  2401. };
  2402. },{"./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){
  2403. exports.BITS = 32;
  2404. exports.GROUPS = 4;
  2405. 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;
  2406. exports.RE_SUBNET_STRING = /\/\d{1,2}$/;
  2407. },{}],10:[function(require,module,exports){
  2408. 'use strict';
  2409. var common = require('../common.js');
  2410. var v6 = require('./constants.js');
  2411. /*
  2412. * Returns true if the address is valid, false otherwise
  2413. */
  2414. exports.isValid = function () {
  2415. return this.valid;
  2416. };
  2417. /*
  2418. * Returns true if the given address is in the subnet of the current address
  2419. */
  2420. exports.isInSubnet = common.isInSubnet;
  2421. /*
  2422. * Returns true if the address is correct, false otherwise
  2423. */
  2424. exports.isCorrect = common.isCorrect(v6.BITS);
  2425. /*
  2426. * Returns true if the address is in the canonical form, false otherwise
  2427. */
  2428. exports.isCanonical = common.falseIfInvalid(function () {
  2429. return this.addressMinusSuffix === this.canonicalForm();
  2430. });
  2431. /*
  2432. * Returns true if the address is a link local address, false otherwise
  2433. */
  2434. exports.isLinkLocal = common.falseIfInvalid(function () {
  2435. // Zeroes are required, i.e. we can't check isInSubnet with 'fe80::/10'
  2436. if (this.getBitsBase2(0, 64) ===
  2437. '1111111010000000000000000000000000000000000000000000000000000000') {
  2438. return true;
  2439. }
  2440. return false;
  2441. });
  2442. /*
  2443. * Returns true if the address is a multicast address, false otherwise
  2444. */
  2445. exports.isMulticast = common.falseIfInvalid(function () {
  2446. return this.getType() === 'Multicast';
  2447. });
  2448. /*
  2449. * Returns true if the address is a v4-in-v6 address, false otherwise
  2450. */
  2451. exports.is4 = common.falseIfInvalid(function () {
  2452. return this.v4;
  2453. });
  2454. /*
  2455. * Returns true if the address is a Teredo address, false otherwise
  2456. */
  2457. exports.isTeredo = common.falseIfInvalid(function () {
  2458. return this.isInSubnet(new this.constructor('2001::/32'));
  2459. });
  2460. /*
  2461. * Returns true if the address is a 6to4 address, false otherwise
  2462. */
  2463. exports.is6to4 = common.falseIfInvalid(function () {
  2464. return this.isInSubnet(new this.constructor('2002::/16'));
  2465. });
  2466. /*
  2467. * Returns true if the address is a loopback address, false otherwise
  2468. */
  2469. exports.isLoopback = common.falseIfInvalid(function () {
  2470. return this.getType() === 'Loopback';
  2471. });
  2472. },{"../common.js":6,"./constants.js":11}],11:[function(require,module,exports){
  2473. exports.BITS = 128;
  2474. exports.GROUPS = 8;
  2475. exports.SCOPES = {
  2476. 0: 'Reserved',
  2477. 1: 'Interface local',
  2478. 2: 'Link local',
  2479. 4: 'Admin local',
  2480. 5: 'Site local',
  2481. 8: 'Organization local',
  2482. 15: 'Global',
  2483. 16: 'Reserved'
  2484. };
  2485. // TODO: Add ff0x::fb, etc. for multicast DNS
  2486. exports.TYPES = {
  2487. 'ff01::1/128': 'Multicast (All nodes on this interface)',
  2488. 'ff01::2/128': 'Multicast (All routers on this interface)',
  2489. 'ff02::1/128': 'Multicast (All nodes on this link)',
  2490. 'ff02::2/128': 'Multicast (All routers on this link)',
  2491. 'ff05::2/128': 'Multicast (All routers in this site)',
  2492. 'ff02::5/128': 'Multicast (OSPFv3 AllSPF routers)',
  2493. 'ff02::6/128': 'Multicast (OSPFv3 AllDR routers)',
  2494. 'ff02::9/128': 'Multicast (RIP routers)',
  2495. 'ff02::a/128': 'Multicast (EIGRP routers)',
  2496. 'ff02::d/128': 'Multicast (PIM routers)',
  2497. 'ff02::16/128': 'Multicast (MLDv2 reports)',
  2498. 'ff01::fb/128': 'Multicast (mDNSv6)',
  2499. 'ff02::fb/128': 'Multicast (mDNSv6)',
  2500. 'ff05::fb/128': 'Multicast (mDNSv6)',
  2501. 'ff02::1:2/128': 'Multicast (All DHCP servers and relay agents on this link)',
  2502. 'ff05::1:2/128': 'Multicast (All DHCP servers and relay agents in this site)',
  2503. 'ff02::1:3/128': 'Multicast (All DHCP servers on this link)',
  2504. 'ff05::1:3/128': 'Multicast (All DHCP servers in this site)',
  2505. '::/128': 'Unspecified',
  2506. '::1/128': 'Loopback',
  2507. 'ff00::/8': 'Multicast',
  2508. 'fe80::/10': 'Link-local unicast'
  2509. };
  2510. exports.RE_BAD_CHARACTERS = /([^0-9a-f:\/%])/ig;
  2511. exports.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/ig;
  2512. exports.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
  2513. exports.RE_ZONE_STRING = /%.*$/;
  2514. exports.RE_URL = new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);
  2515. exports.RE_URL_WITH_PORT = new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);
  2516. },{}],12:[function(require,module,exports){
  2517. 'use strict';
  2518. var sprintf = require('sprintf');
  2519. /*
  2520. * Returns the string with all zeroes contained in a <span>
  2521. */
  2522. var spanAllZeroes = exports.spanAllZeroes = function (s) {
  2523. return s.replace(/(0+)/g, '<span class="zero">$1</span>');
  2524. };
  2525. /*
  2526. * Returns the string with each character contained in a <span>
  2527. */
  2528. exports.spanAll = function (s, optionalOffset) {
  2529. if (optionalOffset === undefined) {
  2530. optionalOffset = 0;
  2531. }
  2532. var letters = s.split('');
  2533. return letters.map(function (n, i) {
  2534. return sprintf('<span class="digit value-%s position-%d">%s</span>', n,
  2535. i + optionalOffset,
  2536. spanAllZeroes(n)); // XXX Use #base-2 .value-0 instead?
  2537. }).join('');
  2538. };
  2539. function spanLeadingZeroesSimple(group) {
  2540. return group.replace(/^(0+)/, '<span class="zero">$1</span>');
  2541. }
  2542. /*
  2543. * Returns the string with leading zeroes contained in a <span>
  2544. */
  2545. exports.spanLeadingZeroes = function (address) {
  2546. var groups = address.split(':');
  2547. return groups.map(function (g) {
  2548. return spanLeadingZeroesSimple(g);
  2549. }).join(':');
  2550. };
  2551. /*
  2552. * Groups an address
  2553. */
  2554. exports.simpleGroup = function (addressString, offset) {
  2555. var groups = addressString.split(':');
  2556. if (!offset) {
  2557. offset = 0;
  2558. }
  2559. return groups.map(function (g, i) {
  2560. if (/group-v4/.test(g)) {
  2561. return g;
  2562. }
  2563. return sprintf('<span class="hover-group group-%d">%s</span>',
  2564. i + offset,
  2565. spanLeadingZeroesSimple(g));
  2566. }).join(':');
  2567. };
  2568. },{"sprintf":44}],13:[function(require,module,exports){
  2569. 'use strict';
  2570. var constants4 = require('../v4/constants.js');
  2571. var helpers = require('./helpers.js');
  2572. var sprintf = require('sprintf').sprintf;
  2573. /*
  2574. * Returns the address in link form with a default port of 80
  2575. */
  2576. exports.href = function (optionalPort) {
  2577. if (optionalPort === undefined) {
  2578. optionalPort = '';
  2579. } else {
  2580. optionalPort = sprintf(':%s', optionalPort);
  2581. }
  2582. return sprintf('http://[%s]%s/', this.correctForm(), optionalPort);
  2583. };
  2584. /*
  2585. * Returns a link suitable for conveying the address via a URL hash
  2586. */
  2587. exports.link = function (options) {
  2588. if (!options) {
  2589. options = {};
  2590. }
  2591. if (options.className === undefined) {
  2592. options.className = '';
  2593. }
  2594. if (options.prefix === undefined) {
  2595. options.prefix = '/#address=';
  2596. }
  2597. if (options.v4 === undefined) {
  2598. options.v4 = false;
  2599. }
  2600. var formFunction = this.correctForm;
  2601. if (options.v4) {
  2602. formFunction = this.v4inv6;
  2603. }
  2604. if (options.className) {
  2605. return sprintf('<a href="%1$s%2$s" class="%3$s">%2$s</a>',
  2606. options.prefix, formFunction.call(this), options.className);
  2607. }
  2608. return sprintf('<a href="%1$s%2$s">%2$s</a>', options.prefix,
  2609. formFunction.call(this));
  2610. };
  2611. /*
  2612. * Groups an address
  2613. */
  2614. exports.group = function () {
  2615. var address4 = this.address.match(constants4.RE_ADDRESS);
  2616. var i;
  2617. if (address4) {
  2618. // The IPv4 case
  2619. var segments = address4[0].split('.');
  2620. this.address = this.address.replace(constants4.RE_ADDRESS,
  2621. sprintf('<span class="hover-group group-v4 group-6">%s</span>' +
  2622. '.' +
  2623. '<span class="hover-group group-v4 group-7">%s</span>',
  2624. segments.slice(0, 2).join('.'),
  2625. segments.slice(2, 4).join('.')));
  2626. }
  2627. if (this.elidedGroups === 0) {
  2628. // The simple case
  2629. return helpers.simpleGroup(this.address);
  2630. }
  2631. // The elided case
  2632. var output = [];
  2633. var halves = this.address.split('::');
  2634. if (halves[0].length) {
  2635. output.push(helpers.simpleGroup(halves[0]));
  2636. } else {
  2637. output.push('');
  2638. }
  2639. var classes = ['hover-group'];
  2640. for (i = this.elisionBegin;
  2641. i < this.elisionBegin + this.elidedGroups; i++) {
  2642. classes.push(sprintf('group-%d', i));
  2643. }
  2644. output.push(sprintf('<span class="%s"></span>', classes.join(' ')));
  2645. if (halves[1].length) {
  2646. output.push(helpers.simpleGroup(halves[1], this.elisionEnd));
  2647. } else {
  2648. output.push('');
  2649. }
  2650. return output.join(':');
  2651. };
  2652. },{"../v4/constants.js":9,"./helpers.js":12,"sprintf":44}],14:[function(require,module,exports){
  2653. 'use strict';
  2654. var sprintf = require('sprintf').sprintf;
  2655. var v6 = require('./constants.js');
  2656. function groupPossibilities(possibilities) {
  2657. return sprintf('(%s)', possibilities.join('|'));
  2658. }
  2659. function padGroup(group) {
  2660. if (group.length < 4) {
  2661. return sprintf('0{0,%d}%s', 4 - group.length, group);
  2662. }
  2663. return group;
  2664. }
  2665. function simpleRegularExpression(groups) {
  2666. var zeroIndexes = [];
  2667. groups.forEach(function (group, i) {
  2668. var groupInteger = parseInt(group, 16);
  2669. if (groupInteger === 0) {
  2670. zeroIndexes.push(i);
  2671. }
  2672. });
  2673. // You can technically elide a single 0, this creates the regular expressions
  2674. // to match that eventuality
  2675. var possibilities = zeroIndexes.map(function (zeroIndex) {
  2676. return groups.map(function (group, i) {
  2677. if (i === zeroIndex) {
  2678. var elision = (i === 0 || i === v6.GROUPS - 1) ? ':' : '';
  2679. return groupPossibilities([padGroup(group), elision]);
  2680. }
  2681. return padGroup(group);
  2682. }).join(':');
  2683. });
  2684. // The simplest case
  2685. possibilities.push(groups.map(padGroup).join(':'));
  2686. return groupPossibilities(possibilities);
  2687. }
  2688. function possibleElisions(elidedGroups, moreLeft, moreRight) {
  2689. var left = moreLeft ? '' : ':';
  2690. var right = moreRight ? '' : ':';
  2691. var possibilities = [];
  2692. // 1. elision of everything (::)
  2693. if (!moreLeft && !moreRight) {
  2694. possibilities.push('::');
  2695. }
  2696. // 2. complete elision of the middle
  2697. if (moreLeft && moreRight) {
  2698. possibilities.push('');
  2699. }
  2700. if ((moreRight && !moreLeft) || (!moreRight && moreLeft)) {
  2701. // 3. complete elision of one side
  2702. possibilities.push(':');
  2703. }
  2704. // 4. elision from the left side
  2705. possibilities.push(sprintf('%s(:0{1,4}){1,%d}', left, elidedGroups - 1));
  2706. // 5. elision from the right side
  2707. possibilities.push(sprintf('(0{1,4}:){1,%d}%s', elidedGroups - 1, right));
  2708. // 6. no elision
  2709. possibilities.push(sprintf('(0{1,4}:){%d}0{1,4}', elidedGroups - 1));
  2710. // 7. elision (including sloppy elision) from the middle
  2711. for (var groups = 1; groups < elidedGroups - 1; groups++) {
  2712. for (var position = 1; position < elidedGroups - groups; position++) {
  2713. possibilities.push(sprintf('(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}',
  2714. position,
  2715. elidedGroups - position - groups - 1));
  2716. }
  2717. }
  2718. return groupPossibilities(possibilities);
  2719. }
  2720. /*
  2721. * Generate a regular expression string that can be used to find or validate all
  2722. * variations of this address.
  2723. */
  2724. exports.regularExpressionString = function (optionalSubString) {
  2725. if (optionalSubString === undefined) {
  2726. optionalSubString = false;
  2727. }
  2728. var output = [];
  2729. // TODO: revisit why this is necessary
  2730. var address6 = new this.constructor(this.correctForm());
  2731. if (address6.elidedGroups === 0) {
  2732. // The simple case
  2733. output.push(simpleRegularExpression(address6.parsedAddress));
  2734. } else if (address6.elidedGroups === v6.GROUPS) {
  2735. // A completely elided address
  2736. output.push(possibleElisions(v6.GROUPS));
  2737. } else {
  2738. // A partially elided address
  2739. var halves = address6.address.split('::');
  2740. if (halves[0].length) {
  2741. output.push(simpleRegularExpression(halves[0].split(':')));
  2742. }
  2743. output.push(possibleElisions(address6.elidedGroups,
  2744. halves[0].length !== 0,
  2745. halves[1].length !== 0));
  2746. if (halves[1].length) {
  2747. output.push(simpleRegularExpression(halves[1].split(':')));
  2748. }
  2749. output = [output.join(':')];
  2750. }
  2751. if (!optionalSubString) {
  2752. output = [].concat('(?=^|\\b|[^\\w\\:])(', output, ')(?=[^\\w\\:]|\\b|$)');
  2753. }
  2754. return output.join('');
  2755. };
  2756. /*
  2757. * Generate a regular expression that can be used to find or validate all
  2758. * variations of this address.
  2759. */
  2760. exports.regularExpression = function (optionalSubstring) {
  2761. return new RegExp(this.regularExpressionString(optionalSubstring), 'i');
  2762. };
  2763. },{"./constants.js":11,"sprintf":44}],15:[function(require,module,exports){
  2764. (function(){
  2765. // Copyright (c) 2005 Tom Wu
  2766. // All Rights Reserved.
  2767. // See "LICENSE" for details.
  2768. // Basic JavaScript BN library - subset useful for RSA encryption.
  2769. // Bits per digit
  2770. var dbits;
  2771. // JavaScript engine analysis
  2772. var canary = 0xdeadbeefcafe;
  2773. var j_lm = ((canary&0xffffff)==0xefcafe);
  2774. // (public) Constructor
  2775. function BigInteger(a,b,c) {
  2776. if(a != null)
  2777. if("number" == typeof a) this.fromNumber(a,b,c);
  2778. else if(b == null && "string" != typeof a) this.fromString(a,256);
  2779. else this.fromString(a,b);
  2780. }
  2781. // return new, unset BigInteger
  2782. function nbi() { return new BigInteger(null); }
  2783. // am: Compute w_j += (x*this_i), propagate carries,
  2784. // c is initial carry, returns final carry.
  2785. // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
  2786. // We need to select the fastest one that works in this environment.
  2787. // am1: use a single mult and divide to get the high bits,
  2788. // max digit bits should be 26 because
  2789. // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
  2790. function am1(i,x,w,j,c,n) {
  2791. while(--n >= 0) {
  2792. var v = x*this[i++]+w[j]+c;
  2793. c = Math.floor(v/0x4000000);
  2794. w[j++] = v&0x3ffffff;
  2795. }
  2796. return c;
  2797. }
  2798. // am2 avoids a big mult-and-extract completely.
  2799. // Max digit bits should be <= 30 because we do bitwise ops
  2800. // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
  2801. function am2(i,x,w,j,c,n) {
  2802. var xl = x&0x7fff, xh = x>>15;
  2803. while(--n >= 0) {
  2804. var l = this[i]&0x7fff;
  2805. var h = this[i++]>>15;
  2806. var m = xh*l+h*xl;
  2807. l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
  2808. c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
  2809. w[j++] = l&0x3fffffff;
  2810. }
  2811. return c;
  2812. }
  2813. // Alternately, set max digit bits to 28 since some
  2814. // browsers slow down when dealing with 32-bit numbers.
  2815. function am3(i,x,w,j,c,n) {
  2816. var xl = x&0x3fff, xh = x>>14;
  2817. while(--n >= 0) {
  2818. var l = this[i]&0x3fff;
  2819. var h = this[i++]>>14;
  2820. var m = xh*l+h*xl;
  2821. l = xl*l+((m&0x3fff)<<14)+w[j]+c;
  2822. c = (l>>28)+(m>>14)+xh*h;
  2823. w[j++] = l&0xfffffff;
  2824. }
  2825. return c;
  2826. }
  2827. var inBrowser = typeof navigator !== "undefined";
  2828. if(inBrowser && j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
  2829. BigInteger.prototype.am = am2;
  2830. dbits = 30;
  2831. }
  2832. else if(inBrowser && j_lm && (navigator.appName != "Netscape")) {
  2833. BigInteger.prototype.am = am1;
  2834. dbits = 26;
  2835. }
  2836. else { // Mozilla/Netscape seems to prefer am3
  2837. BigInteger.prototype.am = am3;
  2838. dbits = 28;
  2839. }
  2840. BigInteger.prototype.DB = dbits;
  2841. BigInteger.prototype.DM = ((1<<dbits)-1);
  2842. BigInteger.prototype.DV = (1<<dbits);
  2843. var BI_FP = 52;
  2844. BigInteger.prototype.FV = Math.pow(2,BI_FP);
  2845. BigInteger.prototype.F1 = BI_FP-dbits;
  2846. BigInteger.prototype.F2 = 2*dbits-BI_FP;
  2847. // Digit conversions
  2848. var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
  2849. var BI_RC = new Array();
  2850. var rr,vv;
  2851. rr = "0".charCodeAt(0);
  2852. for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
  2853. rr = "a".charCodeAt(0);
  2854. for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  2855. rr = "A".charCodeAt(0);
  2856. for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  2857. function int2char(n) { return BI_RM.charAt(n); }
  2858. function intAt(s,i) {
  2859. var c = BI_RC[s.charCodeAt(i)];
  2860. return (c==null)?-1:c;
  2861. }
  2862. // (protected) copy this to r
  2863. function bnpCopyTo(r) {
  2864. for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
  2865. r.t = this.t;
  2866. r.s = this.s;
  2867. }
  2868. // (protected) set from integer value x, -DV <= x < DV
  2869. function bnpFromInt(x) {
  2870. this.t = 1;
  2871. this.s = (x<0)?-1:0;
  2872. if(x > 0) this[0] = x;
  2873. else if(x < -1) this[0] = x+DV;
  2874. else this.t = 0;
  2875. }
  2876. // return bigint initialized to value
  2877. function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
  2878. // (protected) set from string and radix
  2879. function bnpFromString(s,b) {
  2880. var k;
  2881. if(b == 16) k = 4;
  2882. else if(b == 8) k = 3;
  2883. else if(b == 256) k = 8; // byte array
  2884. else if(b == 2) k = 1;
  2885. else if(b == 32) k = 5;
  2886. else if(b == 4) k = 2;
  2887. else { this.fromRadix(s,b); return; }
  2888. this.t = 0;
  2889. this.s = 0;
  2890. var i = s.length, mi = false, sh = 0;
  2891. while(--i >= 0) {
  2892. var x = (k==8)?s[i]&0xff:intAt(s,i);
  2893. if(x < 0) {
  2894. if(s.charAt(i) == "-") mi = true;
  2895. continue;
  2896. }
  2897. mi = false;
  2898. if(sh == 0)
  2899. this[this.t++] = x;
  2900. else if(sh+k > this.DB) {
  2901. this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
  2902. this[this.t++] = (x>>(this.DB-sh));
  2903. }
  2904. else
  2905. this[this.t-1] |= x<<sh;
  2906. sh += k;
  2907. if(sh >= this.DB) sh -= this.DB;
  2908. }
  2909. if(k == 8 && (s[0]&0x80) != 0) {
  2910. this.s = -1;
  2911. if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
  2912. }
  2913. this.clamp();
  2914. if(mi) BigInteger.ZERO.subTo(this,this);
  2915. }
  2916. // (protected) clamp off excess high words
  2917. function bnpClamp() {
  2918. var c = this.s&this.DM;
  2919. while(this.t > 0 && this[this.t-1] == c) --this.t;
  2920. }
  2921. // (public) return string representation in given radix
  2922. function bnToString(b) {
  2923. if(this.s < 0) return "-"+this.negate().toString(b);
  2924. var k;
  2925. if(b == 16) k = 4;
  2926. else if(b == 8) k = 3;
  2927. else if(b == 2) k = 1;
  2928. else if(b == 32) k = 5;
  2929. else if(b == 4) k = 2;
  2930. else return this.toRadix(b);
  2931. var km = (1<<k)-1, d, m = false, r = "", i = this.t;
  2932. var p = this.DB-(i*this.DB)%k;
  2933. if(i-- > 0) {
  2934. if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
  2935. while(i >= 0) {
  2936. if(p < k) {
  2937. d = (this[i]&((1<<p)-1))<<(k-p);
  2938. d |= this[--i]>>(p+=this.DB-k);
  2939. }
  2940. else {
  2941. d = (this[i]>>(p-=k))&km;
  2942. if(p <= 0) { p += this.DB; --i; }
  2943. }
  2944. if(d > 0) m = true;
  2945. if(m) r += int2char(d);
  2946. }
  2947. }
  2948. return m?r:"0";
  2949. }
  2950. // (public) -this
  2951. function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
  2952. // (public) |this|
  2953. function bnAbs() { return (this.s<0)?this.negate():this; }
  2954. // (public) return + if this > a, - if this < a, 0 if equal
  2955. function bnCompareTo(a) {
  2956. var r = this.s-a.s;
  2957. if(r != 0) return r;
  2958. var i = this.t;
  2959. r = i-a.t;
  2960. if(r != 0) return (this.s<0)?-r:r;
  2961. while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
  2962. return 0;
  2963. }
  2964. // returns bit length of the integer x
  2965. function nbits(x) {
  2966. var r = 1, t;
  2967. if((t=x>>>16) != 0) { x = t; r += 16; }
  2968. if((t=x>>8) != 0) { x = t; r += 8; }
  2969. if((t=x>>4) != 0) { x = t; r += 4; }
  2970. if((t=x>>2) != 0) { x = t; r += 2; }
  2971. if((t=x>>1) != 0) { x = t; r += 1; }
  2972. return r;
  2973. }
  2974. // (public) return the number of bits in "this"
  2975. function bnBitLength() {
  2976. if(this.t <= 0) return 0;
  2977. return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
  2978. }
  2979. // (protected) r = this << n*DB
  2980. function bnpDLShiftTo(n,r) {
  2981. var i;
  2982. for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
  2983. for(i = n-1; i >= 0; --i) r[i] = 0;
  2984. r.t = this.t+n;
  2985. r.s = this.s;
  2986. }
  2987. // (protected) r = this >> n*DB
  2988. function bnpDRShiftTo(n,r) {
  2989. for(var i = n; i < this.t; ++i) r[i-n] = this[i];
  2990. r.t = Math.max(this.t-n,0);
  2991. r.s = this.s;
  2992. }
  2993. // (protected) r = this << n
  2994. function bnpLShiftTo(n,r) {
  2995. var bs = n%this.DB;
  2996. var cbs = this.DB-bs;
  2997. var bm = (1<<cbs)-1;
  2998. var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
  2999. for(i = this.t-1; i >= 0; --i) {
  3000. r[i+ds+1] = (this[i]>>cbs)|c;
  3001. c = (this[i]&bm)<<bs;
  3002. }
  3003. for(i = ds-1; i >= 0; --i) r[i] = 0;
  3004. r[ds] = c;
  3005. r.t = this.t+ds+1;
  3006. r.s = this.s;
  3007. r.clamp();
  3008. }
  3009. // (protected) r = this >> n
  3010. function bnpRShiftTo(n,r) {
  3011. r.s = this.s;
  3012. var ds = Math.floor(n/this.DB);
  3013. if(ds >= this.t) { r.t = 0; return; }
  3014. var bs = n%this.DB;
  3015. var cbs = this.DB-bs;
  3016. var bm = (1<<bs)-1;
  3017. r[0] = this[ds]>>bs;
  3018. for(var i = ds+1; i < this.t; ++i) {
  3019. r[i-ds-1] |= (this[i]&bm)<<cbs;
  3020. r[i-ds] = this[i]>>bs;
  3021. }
  3022. if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
  3023. r.t = this.t-ds;
  3024. r.clamp();
  3025. }
  3026. // (protected) r = this - a
  3027. function bnpSubTo(a,r) {
  3028. var i = 0, c = 0, m = Math.min(a.t,this.t);
  3029. while(i < m) {
  3030. c += this[i]-a[i];
  3031. r[i++] = c&this.DM;
  3032. c >>= this.DB;
  3033. }
  3034. if(a.t < this.t) {
  3035. c -= a.s;
  3036. while(i < this.t) {
  3037. c += this[i];
  3038. r[i++] = c&this.DM;
  3039. c >>= this.DB;
  3040. }
  3041. c += this.s;
  3042. }
  3043. else {
  3044. c += this.s;
  3045. while(i < a.t) {
  3046. c -= a[i];
  3047. r[i++] = c&this.DM;
  3048. c >>= this.DB;
  3049. }
  3050. c -= a.s;
  3051. }
  3052. r.s = (c<0)?-1:0;
  3053. if(c < -1) r[i++] = this.DV+c;
  3054. else if(c > 0) r[i++] = c;
  3055. r.t = i;
  3056. r.clamp();
  3057. }
  3058. // (protected) r = this * a, r != this,a (HAC 14.12)
  3059. // "this" should be the larger one if appropriate.
  3060. function bnpMultiplyTo(a,r) {
  3061. var x = this.abs(), y = a.abs();
  3062. var i = x.t;
  3063. r.t = i+y.t;
  3064. while(--i >= 0) r[i] = 0;
  3065. for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
  3066. r.s = 0;
  3067. r.clamp();
  3068. if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
  3069. }
  3070. // (protected) r = this^2, r != this (HAC 14.16)
  3071. function bnpSquareTo(r) {
  3072. var x = this.abs();
  3073. var i = r.t = 2*x.t;
  3074. while(--i >= 0) r[i] = 0;
  3075. for(i = 0; i < x.t-1; ++i) {
  3076. var c = x.am(i,x[i],r,2*i,0,1);
  3077. if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
  3078. r[i+x.t] -= x.DV;
  3079. r[i+x.t+1] = 1;
  3080. }
  3081. }
  3082. if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
  3083. r.s = 0;
  3084. r.clamp();
  3085. }
  3086. // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
  3087. // r != q, this != m. q or r may be null.
  3088. function bnpDivRemTo(m,q,r) {
  3089. var pm = m.abs();
  3090. if(pm.t <= 0) return;
  3091. var pt = this.abs();
  3092. if(pt.t < pm.t) {
  3093. if(q != null) q.fromInt(0);
  3094. if(r != null) this.copyTo(r);
  3095. return;
  3096. }
  3097. if(r == null) r = nbi();
  3098. var y = nbi(), ts = this.s, ms = m.s;
  3099. var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus
  3100. if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
  3101. else { pm.copyTo(y); pt.copyTo(r); }
  3102. var ys = y.t;
  3103. var y0 = y[ys-1];
  3104. if(y0 == 0) return;
  3105. var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);
  3106. var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
  3107. var i = r.t, j = i-ys, t = (q==null)?nbi():q;
  3108. y.dlShiftTo(j,t);
  3109. if(r.compareTo(t) >= 0) {
  3110. r[r.t++] = 1;
  3111. r.subTo(t,r);
  3112. }
  3113. BigInteger.ONE.dlShiftTo(ys,t);
  3114. t.subTo(y,y); // "negative" y so we can replace sub with am later
  3115. while(y.t < ys) y[y.t++] = 0;
  3116. while(--j >= 0) {
  3117. // Estimate quotient digit
  3118. var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
  3119. if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
  3120. y.dlShiftTo(j,t);
  3121. r.subTo(t,r);
  3122. while(r[i] < --qd) r.subTo(t,r);
  3123. }
  3124. }
  3125. if(q != null) {
  3126. r.drShiftTo(ys,q);
  3127. if(ts != ms) BigInteger.ZERO.subTo(q,q);
  3128. }
  3129. r.t = ys;
  3130. r.clamp();
  3131. if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
  3132. if(ts < 0) BigInteger.ZERO.subTo(r,r);
  3133. }
  3134. // (public) this mod a
  3135. function bnMod(a) {
  3136. var r = nbi();
  3137. this.abs().divRemTo(a,null,r);
  3138. if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
  3139. return r;
  3140. }
  3141. // Modular reduction using "classic" algorithm
  3142. function Classic(m) { this.m = m; }
  3143. function cConvert(x) {
  3144. if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
  3145. else return x;
  3146. }
  3147. function cRevert(x) { return x; }
  3148. function cReduce(x) { x.divRemTo(this.m,null,x); }
  3149. function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
  3150. function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
  3151. Classic.prototype.convert = cConvert;
  3152. Classic.prototype.revert = cRevert;
  3153. Classic.prototype.reduce = cReduce;
  3154. Classic.prototype.mulTo = cMulTo;
  3155. Classic.prototype.sqrTo = cSqrTo;
  3156. // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
  3157. // justification:
  3158. // xy == 1 (mod m)
  3159. // xy = 1+km
  3160. // xy(2-xy) = (1+km)(1-km)
  3161. // x[y(2-xy)] = 1-k^2m^2
  3162. // x[y(2-xy)] == 1 (mod m^2)
  3163. // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
  3164. // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
  3165. // JS multiply "overflows" differently from C/C++, so care is needed here.
  3166. function bnpInvDigit() {
  3167. if(this.t < 1) return 0;
  3168. var x = this[0];
  3169. if((x&1) == 0) return 0;
  3170. var y = x&3; // y == 1/x mod 2^2
  3171. y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
  3172. y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
  3173. y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
  3174. // last step - calculate inverse mod DV directly;
  3175. // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
  3176. y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
  3177. // we really want the negative inverse, and -DV < y < DV
  3178. return (y>0)?this.DV-y:-y;
  3179. }
  3180. // Montgomery reduction
  3181. function Montgomery(m) {
  3182. this.m = m;
  3183. this.mp = m.invDigit();
  3184. this.mpl = this.mp&0x7fff;
  3185. this.mph = this.mp>>15;
  3186. this.um = (1<<(m.DB-15))-1;
  3187. this.mt2 = 2*m.t;
  3188. }
  3189. // xR mod m
  3190. function montConvert(x) {
  3191. var r = nbi();
  3192. x.abs().dlShiftTo(this.m.t,r);
  3193. r.divRemTo(this.m,null,r);
  3194. if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
  3195. return r;
  3196. }
  3197. // x/R mod m
  3198. function montRevert(x) {
  3199. var r = nbi();
  3200. x.copyTo(r);
  3201. this.reduce(r);
  3202. return r;
  3203. }
  3204. // x = x/R mod m (HAC 14.32)
  3205. function montReduce(x) {
  3206. while(x.t <= this.mt2) // pad x so am has enough room later
  3207. x[x.t++] = 0;
  3208. for(var i = 0; i < this.m.t; ++i) {
  3209. // faster way of calculating u0 = x[i]*mp mod DV
  3210. var j = x[i]&0x7fff;
  3211. var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
  3212. // use am to combine the multiply-shift-add into one call
  3213. j = i+this.m.t;
  3214. x[j] += this.m.am(0,u0,x,i,0,this.m.t);
  3215. // propagate carry
  3216. while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
  3217. }
  3218. x.clamp();
  3219. x.drShiftTo(this.m.t,x);
  3220. if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
  3221. }
  3222. // r = "x^2/R mod m"; x != r
  3223. function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
  3224. // r = "xy/R mod m"; x,y != r
  3225. function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
  3226. Montgomery.prototype.convert = montConvert;
  3227. Montgomery.prototype.revert = montRevert;
  3228. Montgomery.prototype.reduce = montReduce;
  3229. Montgomery.prototype.mulTo = montMulTo;
  3230. Montgomery.prototype.sqrTo = montSqrTo;
  3231. // (protected) true iff this is even
  3232. function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
  3233. // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
  3234. function bnpExp(e,z) {
  3235. if(e > 0xffffffff || e < 1) return BigInteger.ONE;
  3236. var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
  3237. g.copyTo(r);
  3238. while(--i >= 0) {
  3239. z.sqrTo(r,r2);
  3240. if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
  3241. else { var t = r; r = r2; r2 = t; }
  3242. }
  3243. return z.revert(r);
  3244. }
  3245. // (public) this^e % m, 0 <= e < 2^32
  3246. function bnModPowInt(e,m) {
  3247. var z;
  3248. if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
  3249. return this.exp(e,z);
  3250. }
  3251. // protected
  3252. BigInteger.prototype.copyTo = bnpCopyTo;
  3253. BigInteger.prototype.fromInt = bnpFromInt;
  3254. BigInteger.prototype.fromString = bnpFromString;
  3255. BigInteger.prototype.clamp = bnpClamp;
  3256. BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
  3257. BigInteger.prototype.drShiftTo = bnpDRShiftTo;
  3258. BigInteger.prototype.lShiftTo = bnpLShiftTo;
  3259. BigInteger.prototype.rShiftTo = bnpRShiftTo;
  3260. BigInteger.prototype.subTo = bnpSubTo;
  3261. BigInteger.prototype.multiplyTo = bnpMultiplyTo;
  3262. BigInteger.prototype.squareTo = bnpSquareTo;
  3263. BigInteger.prototype.divRemTo = bnpDivRemTo;
  3264. BigInteger.prototype.invDigit = bnpInvDigit;
  3265. BigInteger.prototype.isEven = bnpIsEven;
  3266. BigInteger.prototype.exp = bnpExp;
  3267. // public
  3268. BigInteger.prototype.toString = bnToString;
  3269. BigInteger.prototype.negate = bnNegate;
  3270. BigInteger.prototype.abs = bnAbs;
  3271. BigInteger.prototype.compareTo = bnCompareTo;
  3272. BigInteger.prototype.bitLength = bnBitLength;
  3273. BigInteger.prototype.mod = bnMod;
  3274. BigInteger.prototype.modPowInt = bnModPowInt;
  3275. // "constants"
  3276. BigInteger.ZERO = nbv(0);
  3277. BigInteger.ONE = nbv(1);
  3278. // Copyright (c) 2005-2009 Tom Wu
  3279. // All Rights Reserved.
  3280. // See "LICENSE" for details.
  3281. // Extended JavaScript BN functions, required for RSA private ops.
  3282. // Version 1.1: new BigInteger("0", 10) returns "proper" zero
  3283. // Version 1.2: square() API, isProbablePrime fix
  3284. // (public)
  3285. function bnClone() { var r = nbi(); this.copyTo(r); return r; }
  3286. // (public) return value as integer
  3287. function bnIntValue() {
  3288. if(this.s < 0) {
  3289. if(this.t == 1) return this[0]-this.DV;
  3290. else if(this.t == 0) return -1;
  3291. }
  3292. else if(this.t == 1) return this[0];
  3293. else if(this.t == 0) return 0;
  3294. // assumes 16 < DB < 32
  3295. return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
  3296. }
  3297. // (public) return value as byte
  3298. function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
  3299. // (public) return value as short (assumes DB>=16)
  3300. function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
  3301. // (protected) return x s.t. r^x < DV
  3302. function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
  3303. // (public) 0 if this == 0, 1 if this > 0
  3304. function bnSigNum() {
  3305. if(this.s < 0) return -1;
  3306. else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
  3307. else return 1;
  3308. }
  3309. // (protected) convert to radix string
  3310. function bnpToRadix(b) {
  3311. if(b == null) b = 10;
  3312. if(this.signum() == 0 || b < 2 || b > 36) return "0";
  3313. var cs = this.chunkSize(b);
  3314. var a = Math.pow(b,cs);
  3315. var d = nbv(a), y = nbi(), z = nbi(), r = "";
  3316. this.divRemTo(d,y,z);
  3317. while(y.signum() > 0) {
  3318. r = (a+z.intValue()).toString(b).substr(1) + r;
  3319. y.divRemTo(d,y,z);
  3320. }
  3321. return z.intValue().toString(b) + r;
  3322. }
  3323. // (protected) convert from radix string
  3324. function bnpFromRadix(s,b) {
  3325. this.fromInt(0);
  3326. if(b == null) b = 10;
  3327. var cs = this.chunkSize(b);
  3328. var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
  3329. for(var i = 0; i < s.length; ++i) {
  3330. var x = intAt(s,i);
  3331. if(x < 0) {
  3332. if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
  3333. continue;
  3334. }
  3335. w = b*w+x;
  3336. if(++j >= cs) {
  3337. this.dMultiply(d);
  3338. this.dAddOffset(w,0);
  3339. j = 0;
  3340. w = 0;
  3341. }
  3342. }
  3343. if(j > 0) {
  3344. this.dMultiply(Math.pow(b,j));
  3345. this.dAddOffset(w,0);
  3346. }
  3347. if(mi) BigInteger.ZERO.subTo(this,this);
  3348. }
  3349. // (protected) alternate constructor
  3350. function bnpFromNumber(a,b,c) {
  3351. if("number" == typeof b) {
  3352. // new BigInteger(int,int,RNG)
  3353. if(a < 2) this.fromInt(1);
  3354. else {
  3355. this.fromNumber(a,c);
  3356. if(!this.testBit(a-1)) // force MSB set
  3357. this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
  3358. if(this.isEven()) this.dAddOffset(1,0); // force odd
  3359. while(!this.isProbablePrime(b)) {
  3360. this.dAddOffset(2,0);
  3361. if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
  3362. }
  3363. }
  3364. }
  3365. else {
  3366. // new BigInteger(int,RNG)
  3367. var x = new Array(), t = a&7;
  3368. x.length = (a>>3)+1;
  3369. b.nextBytes(x);
  3370. if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
  3371. this.fromString(x,256);
  3372. }
  3373. }
  3374. // (public) convert to bigendian byte array
  3375. function bnToByteArray() {
  3376. var i = this.t, r = new Array();
  3377. r[0] = this.s;
  3378. var p = this.DB-(i*this.DB)%8, d, k = 0;
  3379. if(i-- > 0) {
  3380. if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p)
  3381. r[k++] = d|(this.s<<(this.DB-p));
  3382. while(i >= 0) {
  3383. if(p < 8) {
  3384. d = (this[i]&((1<<p)-1))<<(8-p);
  3385. d |= this[--i]>>(p+=this.DB-8);
  3386. }
  3387. else {
  3388. d = (this[i]>>(p-=8))&0xff;
  3389. if(p <= 0) { p += this.DB; --i; }
  3390. }
  3391. if((d&0x80) != 0) d |= -256;
  3392. if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
  3393. if(k > 0 || d != this.s) r[k++] = d;
  3394. }
  3395. }
  3396. return r;
  3397. }
  3398. function bnEquals(a) { return(this.compareTo(a)==0); }
  3399. function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
  3400. function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
  3401. // (protected) r = this op a (bitwise)
  3402. function bnpBitwiseTo(a,op,r) {
  3403. var i, f, m = Math.min(a.t,this.t);
  3404. for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
  3405. if(a.t < this.t) {
  3406. f = a.s&this.DM;
  3407. for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
  3408. r.t = this.t;
  3409. }
  3410. else {
  3411. f = this.s&this.DM;
  3412. for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
  3413. r.t = a.t;
  3414. }
  3415. r.s = op(this.s,a.s);
  3416. r.clamp();
  3417. }
  3418. // (public) this & a
  3419. function op_and(x,y) { return x&y; }
  3420. function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
  3421. // (public) this | a
  3422. function op_or(x,y) { return x|y; }
  3423. function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
  3424. // (public) this ^ a
  3425. function op_xor(x,y) { return x^y; }
  3426. function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
  3427. // (public) this & ~a
  3428. function op_andnot(x,y) { return x&~y; }
  3429. function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
  3430. // (public) ~this
  3431. function bnNot() {
  3432. var r = nbi();
  3433. for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
  3434. r.t = this.t;
  3435. r.s = ~this.s;
  3436. return r;
  3437. }
  3438. // (public) this << n
  3439. function bnShiftLeft(n) {
  3440. var r = nbi();
  3441. if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
  3442. return r;
  3443. }
  3444. // (public) this >> n
  3445. function bnShiftRight(n) {
  3446. var r = nbi();
  3447. if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
  3448. return r;
  3449. }
  3450. // return index of lowest 1-bit in x, x < 2^31
  3451. function lbit(x) {
  3452. if(x == 0) return -1;
  3453. var r = 0;
  3454. if((x&0xffff) == 0) { x >>= 16; r += 16; }
  3455. if((x&0xff) == 0) { x >>= 8; r += 8; }
  3456. if((x&0xf) == 0) { x >>= 4; r += 4; }
  3457. if((x&3) == 0) { x >>= 2; r += 2; }
  3458. if((x&1) == 0) ++r;
  3459. return r;
  3460. }
  3461. // (public) returns index of lowest 1-bit (or -1 if none)
  3462. function bnGetLowestSetBit() {
  3463. for(var i = 0; i < this.t; ++i)
  3464. if(this[i] != 0) return i*this.DB+lbit(this[i]);
  3465. if(this.s < 0) return this.t*this.DB;
  3466. return -1;
  3467. }
  3468. // return number of 1 bits in x
  3469. function cbit(x) {
  3470. var r = 0;
  3471. while(x != 0) { x &= x-1; ++r; }
  3472. return r;
  3473. }
  3474. // (public) return number of set bits
  3475. function bnBitCount() {
  3476. var r = 0, x = this.s&this.DM;
  3477. for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
  3478. return r;
  3479. }
  3480. // (public) true iff nth bit is set
  3481. function bnTestBit(n) {
  3482. var j = Math.floor(n/this.DB);
  3483. if(j >= this.t) return(this.s!=0);
  3484. return((this[j]&(1<<(n%this.DB)))!=0);
  3485. }
  3486. // (protected) this op (1<<n)
  3487. function bnpChangeBit(n,op) {
  3488. var r = BigInteger.ONE.shiftLeft(n);
  3489. this.bitwiseTo(r,op,r);
  3490. return r;
  3491. }
  3492. // (public) this | (1<<n)
  3493. function bnSetBit(n) { return this.changeBit(n,op_or); }
  3494. // (public) this & ~(1<<n)
  3495. function bnClearBit(n) { return this.changeBit(n,op_andnot); }
  3496. // (public) this ^ (1<<n)
  3497. function bnFlipBit(n) { return this.changeBit(n,op_xor); }
  3498. // (protected) r = this + a
  3499. function bnpAddTo(a,r) {
  3500. var i = 0, c = 0, m = Math.min(a.t,this.t);
  3501. while(i < m) {
  3502. c += this[i]+a[i];
  3503. r[i++] = c&this.DM;
  3504. c >>= this.DB;
  3505. }
  3506. if(a.t < this.t) {
  3507. c += a.s;
  3508. while(i < this.t) {
  3509. c += this[i];
  3510. r[i++] = c&this.DM;
  3511. c >>= this.DB;
  3512. }
  3513. c += this.s;
  3514. }
  3515. else {
  3516. c += this.s;
  3517. while(i < a.t) {
  3518. c += a[i];
  3519. r[i++] = c&this.DM;
  3520. c >>= this.DB;
  3521. }
  3522. c += a.s;
  3523. }
  3524. r.s = (c<0)?-1:0;
  3525. if(c > 0) r[i++] = c;
  3526. else if(c < -1) r[i++] = this.DV+c;
  3527. r.t = i;
  3528. r.clamp();
  3529. }
  3530. // (public) this + a
  3531. function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
  3532. // (public) this - a
  3533. function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
  3534. // (public) this * a
  3535. function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
  3536. // (public) this^2
  3537. function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
  3538. // (public) this / a
  3539. function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
  3540. // (public) this % a
  3541. function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
  3542. // (public) [this/a,this%a]
  3543. function bnDivideAndRemainder(a) {
  3544. var q = nbi(), r = nbi();
  3545. this.divRemTo(a,q,r);
  3546. return new Array(q,r);
  3547. }
  3548. // (protected) this *= n, this >= 0, 1 < n < DV
  3549. function bnpDMultiply(n) {
  3550. this[this.t] = this.am(0,n-1,this,0,0,this.t);
  3551. ++this.t;
  3552. this.clamp();
  3553. }
  3554. // (protected) this += n << w words, this >= 0
  3555. function bnpDAddOffset(n,w) {
  3556. if(n == 0) return;
  3557. while(this.t <= w) this[this.t++] = 0;
  3558. this[w] += n;
  3559. while(this[w] >= this.DV) {
  3560. this[w] -= this.DV;
  3561. if(++w >= this.t) this[this.t++] = 0;
  3562. ++this[w];
  3563. }
  3564. }
  3565. // A "null" reducer
  3566. function NullExp() {}
  3567. function nNop(x) { return x; }
  3568. function nMulTo(x,y,r) { x.multiplyTo(y,r); }
  3569. function nSqrTo(x,r) { x.squareTo(r); }
  3570. NullExp.prototype.convert = nNop;
  3571. NullExp.prototype.revert = nNop;
  3572. NullExp.prototype.mulTo = nMulTo;
  3573. NullExp.prototype.sqrTo = nSqrTo;
  3574. // (public) this^e
  3575. function bnPow(e) { return this.exp(e,new NullExp()); }
  3576. // (protected) r = lower n words of "this * a", a.t <= n
  3577. // "this" should be the larger one if appropriate.
  3578. function bnpMultiplyLowerTo(a,n,r) {
  3579. var i = Math.min(this.t+a.t,n);
  3580. r.s = 0; // assumes a,this >= 0
  3581. r.t = i;
  3582. while(i > 0) r[--i] = 0;
  3583. var j;
  3584. for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
  3585. for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
  3586. r.clamp();
  3587. }
  3588. // (protected) r = "this * a" without lower n words, n > 0
  3589. // "this" should be the larger one if appropriate.
  3590. function bnpMultiplyUpperTo(a,n,r) {
  3591. --n;
  3592. var i = r.t = this.t+a.t-n;
  3593. r.s = 0; // assumes a,this >= 0
  3594. while(--i >= 0) r[i] = 0;
  3595. for(i = Math.max(n-this.t,0); i < a.t; ++i)
  3596. r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
  3597. r.clamp();
  3598. r.drShiftTo(1,r);
  3599. }
  3600. // Barrett modular reduction
  3601. function Barrett(m) {
  3602. // setup Barrett
  3603. this.r2 = nbi();
  3604. this.q3 = nbi();
  3605. BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
  3606. this.mu = this.r2.divide(m);
  3607. this.m = m;
  3608. }
  3609. function barrettConvert(x) {
  3610. if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
  3611. else if(x.compareTo(this.m) < 0) return x;
  3612. else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
  3613. }
  3614. function barrettRevert(x) { return x; }
  3615. // x = x mod m (HAC 14.42)
  3616. function barrettReduce(x) {
  3617. x.drShiftTo(this.m.t-1,this.r2);
  3618. if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }
  3619. this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);
  3620. this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);
  3621. while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);
  3622. x.subTo(this.r2,x);
  3623. while(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
  3624. }
  3625. // r = x^2 mod m; x != r
  3626. function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
  3627. // r = x*y mod m; x,y != r
  3628. function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
  3629. Barrett.prototype.convert = barrettConvert;
  3630. Barrett.prototype.revert = barrettRevert;
  3631. Barrett.prototype.reduce = barrettReduce;
  3632. Barrett.prototype.mulTo = barrettMulTo;
  3633. Barrett.prototype.sqrTo = barrettSqrTo;
  3634. // (public) this^e % m (HAC 14.85)
  3635. function bnModPow(e,m) {
  3636. var i = e.bitLength(), k, r = nbv(1), z;
  3637. if(i <= 0) return r;
  3638. else if(i < 18) k = 1;
  3639. else if(i < 48) k = 3;
  3640. else if(i < 144) k = 4;
  3641. else if(i < 768) k = 5;
  3642. else k = 6;
  3643. if(i < 8)
  3644. z = new Classic(m);
  3645. else if(m.isEven())
  3646. z = new Barrett(m);
  3647. else
  3648. z = new Montgomery(m);
  3649. // precomputation
  3650. var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
  3651. g[1] = z.convert(this);
  3652. if(k > 1) {
  3653. var g2 = nbi();
  3654. z.sqrTo(g[1],g2);
  3655. while(n <= km) {
  3656. g[n] = nbi();
  3657. z.mulTo(g2,g[n-2],g[n]);
  3658. n += 2;
  3659. }
  3660. }
  3661. var j = e.t-1, w, is1 = true, r2 = nbi(), t;
  3662. i = nbits(e[j])-1;
  3663. while(j >= 0) {
  3664. if(i >= k1) w = (e[j]>>(i-k1))&km;
  3665. else {
  3666. w = (e[j]&((1<<(i+1))-1))<<(k1-i);
  3667. if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
  3668. }
  3669. n = k;
  3670. while((w&1) == 0) { w >>= 1; --n; }
  3671. if((i -= n) < 0) { i += this.DB; --j; }
  3672. if(is1) { // ret == 1, don't bother squaring or multiplying it
  3673. g[w].copyTo(r);
  3674. is1 = false;
  3675. }
  3676. else {
  3677. while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
  3678. if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
  3679. z.mulTo(r2,g[w],r);
  3680. }
  3681. while(j >= 0 && (e[j]&(1<<i)) == 0) {
  3682. z.sqrTo(r,r2); t = r; r = r2; r2 = t;
  3683. if(--i < 0) { i = this.DB-1; --j; }
  3684. }
  3685. }
  3686. return z.revert(r);
  3687. }
  3688. // (public) gcd(this,a) (HAC 14.54)
  3689. function bnGCD(a) {
  3690. var x = (this.s<0)?this.negate():this.clone();
  3691. var y = (a.s<0)?a.negate():a.clone();
  3692. if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
  3693. var i = x.getLowestSetBit(), g = y.getLowestSetBit();
  3694. if(g < 0) return x;
  3695. if(i < g) g = i;
  3696. if(g > 0) {
  3697. x.rShiftTo(g,x);
  3698. y.rShiftTo(g,y);
  3699. }
  3700. while(x.signum() > 0) {
  3701. if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
  3702. if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
  3703. if(x.compareTo(y) >= 0) {
  3704. x.subTo(y,x);
  3705. x.rShiftTo(1,x);
  3706. }
  3707. else {
  3708. y.subTo(x,y);
  3709. y.rShiftTo(1,y);
  3710. }
  3711. }
  3712. if(g > 0) y.lShiftTo(g,y);
  3713. return y;
  3714. }
  3715. // (protected) this % n, n < 2^26
  3716. function bnpModInt(n) {
  3717. if(n <= 0) return 0;
  3718. var d = this.DV%n, r = (this.s<0)?n-1:0;
  3719. if(this.t > 0)
  3720. if(d == 0) r = this[0]%n;
  3721. else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
  3722. return r;
  3723. }
  3724. // (public) 1/this % m (HAC 14.61)
  3725. function bnModInverse(m) {
  3726. var ac = m.isEven();
  3727. if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
  3728. var u = m.clone(), v = this.clone();
  3729. var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
  3730. while(u.signum() != 0) {
  3731. while(u.isEven()) {
  3732. u.rShiftTo(1,u);
  3733. if(ac) {
  3734. if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
  3735. a.rShiftTo(1,a);
  3736. }
  3737. else if(!b.isEven()) b.subTo(m,b);
  3738. b.rShiftTo(1,b);
  3739. }
  3740. while(v.isEven()) {
  3741. v.rShiftTo(1,v);
  3742. if(ac) {
  3743. if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
  3744. c.rShiftTo(1,c);
  3745. }
  3746. else if(!d.isEven()) d.subTo(m,d);
  3747. d.rShiftTo(1,d);
  3748. }
  3749. if(u.compareTo(v) >= 0) {
  3750. u.subTo(v,u);
  3751. if(ac) a.subTo(c,a);
  3752. b.subTo(d,b);
  3753. }
  3754. else {
  3755. v.subTo(u,v);
  3756. if(ac) c.subTo(a,c);
  3757. d.subTo(b,d);
  3758. }
  3759. }
  3760. if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
  3761. if(d.compareTo(m) >= 0) return d.subtract(m);
  3762. if(d.signum() < 0) d.addTo(m,d); else return d;
  3763. if(d.signum() < 0) return d.add(m); else return d;
  3764. }
  3765. 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];
  3766. var lplim = (1<<26)/lowprimes[lowprimes.length-1];
  3767. // (public) test primality with certainty >= 1-.5^t
  3768. function bnIsProbablePrime(t) {
  3769. var i, x = this.abs();
  3770. if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) {
  3771. for(i = 0; i < lowprimes.length; ++i)
  3772. if(x[0] == lowprimes[i]) return true;
  3773. return false;
  3774. }
  3775. if(x.isEven()) return false;
  3776. i = 1;
  3777. while(i < lowprimes.length) {
  3778. var m = lowprimes[i], j = i+1;
  3779. while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];
  3780. m = x.modInt(m);
  3781. while(i < j) if(m%lowprimes[i++] == 0) return false;
  3782. }
  3783. return x.millerRabin(t);
  3784. }
  3785. // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
  3786. function bnpMillerRabin(t) {
  3787. var n1 = this.subtract(BigInteger.ONE);
  3788. var k = n1.getLowestSetBit();
  3789. if(k <= 0) return false;
  3790. var r = n1.shiftRight(k);
  3791. t = (t+1)>>1;
  3792. if(t > lowprimes.length) t = lowprimes.length;
  3793. var a = nbi();
  3794. for(var i = 0; i < t; ++i) {
  3795. //Pick bases at random, instead of starting at 2
  3796. a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);
  3797. var y = a.modPow(r,this);
  3798. if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
  3799. var j = 1;
  3800. while(j++ < k && y.compareTo(n1) != 0) {
  3801. y = y.modPowInt(2,this);
  3802. if(y.compareTo(BigInteger.ONE) == 0) return false;
  3803. }
  3804. if(y.compareTo(n1) != 0) return false;
  3805. }
  3806. }
  3807. return true;
  3808. }
  3809. // protected
  3810. BigInteger.prototype.chunkSize = bnpChunkSize;
  3811. BigInteger.prototype.toRadix = bnpToRadix;
  3812. BigInteger.prototype.fromRadix = bnpFromRadix;
  3813. BigInteger.prototype.fromNumber = bnpFromNumber;
  3814. BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
  3815. BigInteger.prototype.changeBit = bnpChangeBit;
  3816. BigInteger.prototype.addTo = bnpAddTo;
  3817. BigInteger.prototype.dMultiply = bnpDMultiply;
  3818. BigInteger.prototype.dAddOffset = bnpDAddOffset;
  3819. BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
  3820. BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
  3821. BigInteger.prototype.modInt = bnpModInt;
  3822. BigInteger.prototype.millerRabin = bnpMillerRabin;
  3823. // public
  3824. BigInteger.prototype.clone = bnClone;
  3825. BigInteger.prototype.intValue = bnIntValue;
  3826. BigInteger.prototype.byteValue = bnByteValue;
  3827. BigInteger.prototype.shortValue = bnShortValue;
  3828. BigInteger.prototype.signum = bnSigNum;
  3829. BigInteger.prototype.toByteArray = bnToByteArray;
  3830. BigInteger.prototype.equals = bnEquals;
  3831. BigInteger.prototype.min = bnMin;
  3832. BigInteger.prototype.max = bnMax;
  3833. BigInteger.prototype.and = bnAnd;
  3834. BigInteger.prototype.or = bnOr;
  3835. BigInteger.prototype.xor = bnXor;
  3836. BigInteger.prototype.andNot = bnAndNot;
  3837. BigInteger.prototype.not = bnNot;
  3838. BigInteger.prototype.shiftLeft = bnShiftLeft;
  3839. BigInteger.prototype.shiftRight = bnShiftRight;
  3840. BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
  3841. BigInteger.prototype.bitCount = bnBitCount;
  3842. BigInteger.prototype.testBit = bnTestBit;
  3843. BigInteger.prototype.setBit = bnSetBit;
  3844. BigInteger.prototype.clearBit = bnClearBit;
  3845. BigInteger.prototype.flipBit = bnFlipBit;
  3846. BigInteger.prototype.add = bnAdd;
  3847. BigInteger.prototype.subtract = bnSubtract;
  3848. BigInteger.prototype.multiply = bnMultiply;
  3849. BigInteger.prototype.divide = bnDivide;
  3850. BigInteger.prototype.remainder = bnRemainder;
  3851. BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
  3852. BigInteger.prototype.modPow = bnModPow;
  3853. BigInteger.prototype.modInverse = bnModInverse;
  3854. BigInteger.prototype.pow = bnPow;
  3855. BigInteger.prototype.gcd = bnGCD;
  3856. BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
  3857. // JSBN-specific extension
  3858. BigInteger.prototype.square = bnSquare;
  3859. // BigInteger interfaces not implemented in jsbn:
  3860. // BigInteger(int signum, byte[] magnitude)
  3861. // double doubleValue()
  3862. // float floatValue()
  3863. // int hashCode()
  3864. // long longValue()
  3865. // static BigInteger valueOf(long val)
  3866. if (typeof exports !== 'undefined') {
  3867. exports = module.exports = BigInteger;
  3868. } else {
  3869. this.BigInteger = BigInteger;
  3870. }
  3871. }).call(this);
  3872. },{}],16:[function(require,module,exports){
  3873. /**
  3874. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  3875. * Build: `lodash modern modularize exports="npm" -o ./`
  3876. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  3877. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  3878. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  3879. * Available under MIT license <https://lodash.com/license>
  3880. */
  3881. /**
  3882. * Copies the values of `source` to `array`.
  3883. *
  3884. * @private
  3885. * @param {Array} source The array to copy values from.
  3886. * @param {Array} [array=[]] The array to copy values to.
  3887. * @returns {Array} Returns `array`.
  3888. */
  3889. function arrayCopy(source, array) {
  3890. var index = -1,
  3891. length = source.length;
  3892. array || (array = Array(length));
  3893. while (++index < length) {
  3894. array[index] = source[index];
  3895. }
  3896. return array;
  3897. }
  3898. module.exports = arrayCopy;
  3899. },{}],17:[function(require,module,exports){
  3900. /**
  3901. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  3902. * Build: `lodash modern modularize exports="npm" -o ./`
  3903. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  3904. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  3905. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  3906. * Available under MIT license <https://lodash.com/license>
  3907. */
  3908. /**
  3909. * A specialized version of `_.forEach` for arrays without support for callback
  3910. * shorthands or `this` binding.
  3911. *
  3912. * @private
  3913. * @param {Array} array The array to iterate over.
  3914. * @param {Function} iteratee The function invoked per iteration.
  3915. * @returns {Array} Returns `array`.
  3916. */
  3917. function arrayEach(array, iteratee) {
  3918. var index = -1,
  3919. length = array.length;
  3920. while (++index < length) {
  3921. if (iteratee(array[index], index, array) === false) {
  3922. break;
  3923. }
  3924. }
  3925. return array;
  3926. }
  3927. module.exports = arrayEach;
  3928. },{}],18:[function(require,module,exports){
  3929. /**
  3930. * lodash 3.3.1 (Custom Build) <https://lodash.com/>
  3931. * Build: `lodash modern modularize exports="npm" -o ./`
  3932. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  3933. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  3934. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  3935. * Available under MIT license <https://lodash.com/license>
  3936. */
  3937. var baseIsEqual = require('lodash._baseisequal'),
  3938. bindCallback = require('lodash._bindcallback'),
  3939. isArray = require('lodash.isarray'),
  3940. pairs = require('lodash.pairs');
  3941. /** Used to match property names within property paths. */
  3942. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
  3943. reIsPlainProp = /^\w*$/,
  3944. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  3945. /** Used to match backslashes in property paths. */
  3946. var reEscapeChar = /\\(\\)?/g;
  3947. /**
  3948. * Converts `value` to a string if it's not one. An empty string is returned
  3949. * for `null` or `undefined` values.
  3950. *
  3951. * @private
  3952. * @param {*} value The value to process.
  3953. * @returns {string} Returns the string.
  3954. */
  3955. function baseToString(value) {
  3956. return value == null ? '' : (value + '');
  3957. }
  3958. /**
  3959. * The base implementation of `_.callback` which supports specifying the
  3960. * number of arguments to provide to `func`.
  3961. *
  3962. * @private
  3963. * @param {*} [func=_.identity] The value to convert to a callback.
  3964. * @param {*} [thisArg] The `this` binding of `func`.
  3965. * @param {number} [argCount] The number of arguments to provide to `func`.
  3966. * @returns {Function} Returns the callback.
  3967. */
  3968. function baseCallback(func, thisArg, argCount) {
  3969. var type = typeof func;
  3970. if (type == 'function') {
  3971. return thisArg === undefined
  3972. ? func
  3973. : bindCallback(func, thisArg, argCount);
  3974. }
  3975. if (func == null) {
  3976. return identity;
  3977. }
  3978. if (type == 'object') {
  3979. return baseMatches(func);
  3980. }
  3981. return thisArg === undefined
  3982. ? property(func)
  3983. : baseMatchesProperty(func, thisArg);
  3984. }
  3985. /**
  3986. * The base implementation of `get` without support for string paths
  3987. * and default values.
  3988. *
  3989. * @private
  3990. * @param {Object} object The object to query.
  3991. * @param {Array} path The path of the property to get.
  3992. * @param {string} [pathKey] The key representation of path.
  3993. * @returns {*} Returns the resolved value.
  3994. */
  3995. function baseGet(object, path, pathKey) {
  3996. if (object == null) {
  3997. return;
  3998. }
  3999. if (pathKey !== undefined && pathKey in toObject(object)) {
  4000. path = [pathKey];
  4001. }
  4002. var index = 0,
  4003. length = path.length;
  4004. while (object != null && index < length) {
  4005. object = object[path[index++]];
  4006. }
  4007. return (index && index == length) ? object : undefined;
  4008. }
  4009. /**
  4010. * The base implementation of `_.isMatch` without support for callback
  4011. * shorthands and `this` binding.
  4012. *
  4013. * @private
  4014. * @param {Object} object The object to inspect.
  4015. * @param {Array} matchData The propery names, values, and compare flags to match.
  4016. * @param {Function} [customizer] The function to customize comparing objects.
  4017. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  4018. */
  4019. function baseIsMatch(object, matchData, customizer) {
  4020. var index = matchData.length,
  4021. length = index,
  4022. noCustomizer = !customizer;
  4023. if (object == null) {
  4024. return !length;
  4025. }
  4026. object = toObject(object);
  4027. while (index--) {
  4028. var data = matchData[index];
  4029. if ((noCustomizer && data[2])
  4030. ? data[1] !== object[data[0]]
  4031. : !(data[0] in object)
  4032. ) {
  4033. return false;
  4034. }
  4035. }
  4036. while (++index < length) {
  4037. data = matchData[index];
  4038. var key = data[0],
  4039. objValue = object[key],
  4040. srcValue = data[1];
  4041. if (noCustomizer && data[2]) {
  4042. if (objValue === undefined && !(key in object)) {
  4043. return false;
  4044. }
  4045. } else {
  4046. var result = customizer ? customizer(objValue, srcValue, key) : undefined;
  4047. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
  4048. return false;
  4049. }
  4050. }
  4051. }
  4052. return true;
  4053. }
  4054. /**
  4055. * The base implementation of `_.matches` which does not clone `source`.
  4056. *
  4057. * @private
  4058. * @param {Object} source The object of property values to match.
  4059. * @returns {Function} Returns the new function.
  4060. */
  4061. function baseMatches(source) {
  4062. var matchData = getMatchData(source);
  4063. if (matchData.length == 1 && matchData[0][2]) {
  4064. var key = matchData[0][0],
  4065. value = matchData[0][1];
  4066. return function(object) {
  4067. if (object == null) {
  4068. return false;
  4069. }
  4070. return object[key] === value && (value !== undefined || (key in toObject(object)));
  4071. };
  4072. }
  4073. return function(object) {
  4074. return baseIsMatch(object, matchData);
  4075. };
  4076. }
  4077. /**
  4078. * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
  4079. *
  4080. * @private
  4081. * @param {string} path The path of the property to get.
  4082. * @param {*} srcValue The value to compare.
  4083. * @returns {Function} Returns the new function.
  4084. */
  4085. function baseMatchesProperty(path, srcValue) {
  4086. var isArr = isArray(path),
  4087. isCommon = isKey(path) && isStrictComparable(srcValue),
  4088. pathKey = (path + '');
  4089. path = toPath(path);
  4090. return function(object) {
  4091. if (object == null) {
  4092. return false;
  4093. }
  4094. var key = pathKey;
  4095. object = toObject(object);
  4096. if ((isArr || !isCommon) && !(key in object)) {
  4097. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  4098. if (object == null) {
  4099. return false;
  4100. }
  4101. key = last(path);
  4102. object = toObject(object);
  4103. }
  4104. return object[key] === srcValue
  4105. ? (srcValue !== undefined || (key in object))
  4106. : baseIsEqual(srcValue, object[key], undefined, true);
  4107. };
  4108. }
  4109. /**
  4110. * The base implementation of `_.property` without support for deep paths.
  4111. *
  4112. * @private
  4113. * @param {string} key The key of the property to get.
  4114. * @returns {Function} Returns the new function.
  4115. */
  4116. function baseProperty(key) {
  4117. return function(object) {
  4118. return object == null ? undefined : object[key];
  4119. };
  4120. }
  4121. /**
  4122. * A specialized version of `baseProperty` which supports deep paths.
  4123. *
  4124. * @private
  4125. * @param {Array|string} path The path of the property to get.
  4126. * @returns {Function} Returns the new function.
  4127. */
  4128. function basePropertyDeep(path) {
  4129. var pathKey = (path + '');
  4130. path = toPath(path);
  4131. return function(object) {
  4132. return baseGet(object, path, pathKey);
  4133. };
  4134. }
  4135. /**
  4136. * The base implementation of `_.slice` without an iteratee call guard.
  4137. *
  4138. * @private
  4139. * @param {Array} array The array to slice.
  4140. * @param {number} [start=0] The start position.
  4141. * @param {number} [end=array.length] The end position.
  4142. * @returns {Array} Returns the slice of `array`.
  4143. */
  4144. function baseSlice(array, start, end) {
  4145. var index = -1,
  4146. length = array.length;
  4147. start = start == null ? 0 : (+start || 0);
  4148. if (start < 0) {
  4149. start = -start > length ? 0 : (length + start);
  4150. }
  4151. end = (end === undefined || end > length) ? length : (+end || 0);
  4152. if (end < 0) {
  4153. end += length;
  4154. }
  4155. length = start > end ? 0 : ((end - start) >>> 0);
  4156. start >>>= 0;
  4157. var result = Array(length);
  4158. while (++index < length) {
  4159. result[index] = array[index + start];
  4160. }
  4161. return result;
  4162. }
  4163. /**
  4164. * Gets the propery names, values, and compare flags of `object`.
  4165. *
  4166. * @private
  4167. * @param {Object} object The object to query.
  4168. * @returns {Array} Returns the match data of `object`.
  4169. */
  4170. function getMatchData(object) {
  4171. var result = pairs(object),
  4172. length = result.length;
  4173. while (length--) {
  4174. result[length][2] = isStrictComparable(result[length][1]);
  4175. }
  4176. return result;
  4177. }
  4178. /**
  4179. * Checks if `value` is a property name and not a property path.
  4180. *
  4181. * @private
  4182. * @param {*} value The value to check.
  4183. * @param {Object} [object] The object to query keys on.
  4184. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  4185. */
  4186. function isKey(value, object) {
  4187. var type = typeof value;
  4188. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  4189. return true;
  4190. }
  4191. if (isArray(value)) {
  4192. return false;
  4193. }
  4194. var result = !reIsDeepProp.test(value);
  4195. return result || (object != null && value in toObject(object));
  4196. }
  4197. /**
  4198. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  4199. *
  4200. * @private
  4201. * @param {*} value The value to check.
  4202. * @returns {boolean} Returns `true` if `value` if suitable for strict
  4203. * equality comparisons, else `false`.
  4204. */
  4205. function isStrictComparable(value) {
  4206. return value === value && !isObject(value);
  4207. }
  4208. /**
  4209. * Converts `value` to an object if it's not one.
  4210. *
  4211. * @private
  4212. * @param {*} value The value to process.
  4213. * @returns {Object} Returns the object.
  4214. */
  4215. function toObject(value) {
  4216. return isObject(value) ? value : Object(value);
  4217. }
  4218. /**
  4219. * Converts `value` to property path array if it's not one.
  4220. *
  4221. * @private
  4222. * @param {*} value The value to process.
  4223. * @returns {Array} Returns the property path array.
  4224. */
  4225. function toPath(value) {
  4226. if (isArray(value)) {
  4227. return value;
  4228. }
  4229. var result = [];
  4230. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  4231. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  4232. });
  4233. return result;
  4234. }
  4235. /**
  4236. * Gets the last element of `array`.
  4237. *
  4238. * @static
  4239. * @memberOf _
  4240. * @category Array
  4241. * @param {Array} array The array to query.
  4242. * @returns {*} Returns the last element of `array`.
  4243. * @example
  4244. *
  4245. * _.last([1, 2, 3]);
  4246. * // => 3
  4247. */
  4248. function last(array) {
  4249. var length = array ? array.length : 0;
  4250. return length ? array[length - 1] : undefined;
  4251. }
  4252. /**
  4253. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  4254. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4255. *
  4256. * @static
  4257. * @memberOf _
  4258. * @category Lang
  4259. * @param {*} value The value to check.
  4260. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4261. * @example
  4262. *
  4263. * _.isObject({});
  4264. * // => true
  4265. *
  4266. * _.isObject([1, 2, 3]);
  4267. * // => true
  4268. *
  4269. * _.isObject(1);
  4270. * // => false
  4271. */
  4272. function isObject(value) {
  4273. // Avoid a V8 JIT bug in Chrome 19-20.
  4274. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  4275. var type = typeof value;
  4276. return !!value && (type == 'object' || type == 'function');
  4277. }
  4278. /**
  4279. * This method returns the first argument provided to it.
  4280. *
  4281. * @static
  4282. * @memberOf _
  4283. * @category Utility
  4284. * @param {*} value Any value.
  4285. * @returns {*} Returns `value`.
  4286. * @example
  4287. *
  4288. * var object = { 'user': 'fred' };
  4289. *
  4290. * _.identity(object) === object;
  4291. * // => true
  4292. */
  4293. function identity(value) {
  4294. return value;
  4295. }
  4296. /**
  4297. * Creates a function that returns the property value at `path` on a
  4298. * given object.
  4299. *
  4300. * @static
  4301. * @memberOf _
  4302. * @category Utility
  4303. * @param {Array|string} path The path of the property to get.
  4304. * @returns {Function} Returns the new function.
  4305. * @example
  4306. *
  4307. * var objects = [
  4308. * { 'a': { 'b': { 'c': 2 } } },
  4309. * { 'a': { 'b': { 'c': 1 } } }
  4310. * ];
  4311. *
  4312. * _.map(objects, _.property('a.b.c'));
  4313. * // => [2, 1]
  4314. *
  4315. * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
  4316. * // => [1, 2]
  4317. */
  4318. function property(path) {
  4319. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  4320. }
  4321. module.exports = baseCallback;
  4322. },{"lodash._baseisequal":24,"lodash._bindcallback":25,"lodash.isarray":31,"lodash.pairs":37}],19:[function(require,module,exports){
  4323. /**
  4324. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  4325. * Build: `lodash modern modularize exports="npm" -o ./`
  4326. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4327. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4328. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4329. * Available under MIT license <https://lodash.com/license>
  4330. */
  4331. /**
  4332. * Copies properties of `source` to `object`.
  4333. *
  4334. * @private
  4335. * @param {Object} source The object to copy properties from.
  4336. * @param {Array} props The property names to copy.
  4337. * @param {Object} [object={}] The object to copy properties to.
  4338. * @returns {Object} Returns `object`.
  4339. */
  4340. function baseCopy(source, props, object) {
  4341. object || (object = {});
  4342. var index = -1,
  4343. length = props.length;
  4344. while (++index < length) {
  4345. var key = props[index];
  4346. object[key] = source[key];
  4347. }
  4348. return object;
  4349. }
  4350. module.exports = baseCopy;
  4351. },{}],20:[function(require,module,exports){
  4352. /**
  4353. * lodash 3.0.4 (Custom Build) <https://lodash.com/>
  4354. * Build: `lodash modern modularize exports="npm" -o ./`
  4355. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4356. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4357. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4358. * Available under MIT license <https://lodash.com/license>
  4359. */
  4360. var keys = require('lodash.keys');
  4361. /**
  4362. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  4363. * of an array-like value.
  4364. */
  4365. var MAX_SAFE_INTEGER = 9007199254740991;
  4366. /**
  4367. * The base implementation of `_.forEach` without support for callback
  4368. * shorthands and `this` binding.
  4369. *
  4370. * @private
  4371. * @param {Array|Object|string} collection The collection to iterate over.
  4372. * @param {Function} iteratee The function invoked per iteration.
  4373. * @returns {Array|Object|string} Returns `collection`.
  4374. */
  4375. var baseEach = createBaseEach(baseForOwn);
  4376. /**
  4377. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  4378. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  4379. * each property. Iteratee functions may exit iteration early by explicitly
  4380. * returning `false`.
  4381. *
  4382. * @private
  4383. * @param {Object} object The object to iterate over.
  4384. * @param {Function} iteratee The function invoked per iteration.
  4385. * @param {Function} keysFunc The function to get the keys of `object`.
  4386. * @returns {Object} Returns `object`.
  4387. */
  4388. var baseFor = createBaseFor();
  4389. /**
  4390. * The base implementation of `_.forOwn` without support for callback
  4391. * shorthands and `this` binding.
  4392. *
  4393. * @private
  4394. * @param {Object} object The object to iterate over.
  4395. * @param {Function} iteratee The function invoked per iteration.
  4396. * @returns {Object} Returns `object`.
  4397. */
  4398. function baseForOwn(object, iteratee) {
  4399. return baseFor(object, iteratee, keys);
  4400. }
  4401. /**
  4402. * The base implementation of `_.property` without support for deep paths.
  4403. *
  4404. * @private
  4405. * @param {string} key The key of the property to get.
  4406. * @returns {Function} Returns the new function.
  4407. */
  4408. function baseProperty(key) {
  4409. return function(object) {
  4410. return object == null ? undefined : object[key];
  4411. };
  4412. }
  4413. /**
  4414. * Creates a `baseEach` or `baseEachRight` function.
  4415. *
  4416. * @private
  4417. * @param {Function} eachFunc The function to iterate over a collection.
  4418. * @param {boolean} [fromRight] Specify iterating from right to left.
  4419. * @returns {Function} Returns the new base function.
  4420. */
  4421. function createBaseEach(eachFunc, fromRight) {
  4422. return function(collection, iteratee) {
  4423. var length = collection ? getLength(collection) : 0;
  4424. if (!isLength(length)) {
  4425. return eachFunc(collection, iteratee);
  4426. }
  4427. var index = fromRight ? length : -1,
  4428. iterable = toObject(collection);
  4429. while ((fromRight ? index-- : ++index < length)) {
  4430. if (iteratee(iterable[index], index, iterable) === false) {
  4431. break;
  4432. }
  4433. }
  4434. return collection;
  4435. };
  4436. }
  4437. /**
  4438. * Creates a base function for `_.forIn` or `_.forInRight`.
  4439. *
  4440. * @private
  4441. * @param {boolean} [fromRight] Specify iterating from right to left.
  4442. * @returns {Function} Returns the new base function.
  4443. */
  4444. function createBaseFor(fromRight) {
  4445. return function(object, iteratee, keysFunc) {
  4446. var iterable = toObject(object),
  4447. props = keysFunc(object),
  4448. length = props.length,
  4449. index = fromRight ? length : -1;
  4450. while ((fromRight ? index-- : ++index < length)) {
  4451. var key = props[index];
  4452. if (iteratee(iterable[key], key, iterable) === false) {
  4453. break;
  4454. }
  4455. }
  4456. return object;
  4457. };
  4458. }
  4459. /**
  4460. * Gets the "length" property value of `object`.
  4461. *
  4462. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  4463. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  4464. *
  4465. * @private
  4466. * @param {Object} object The object to query.
  4467. * @returns {*} Returns the "length" value.
  4468. */
  4469. var getLength = baseProperty('length');
  4470. /**
  4471. * Checks if `value` is a valid array-like length.
  4472. *
  4473. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  4474. *
  4475. * @private
  4476. * @param {*} value The value to check.
  4477. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  4478. */
  4479. function isLength(value) {
  4480. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  4481. }
  4482. /**
  4483. * Converts `value` to an object if it's not one.
  4484. *
  4485. * @private
  4486. * @param {*} value The value to process.
  4487. * @returns {Object} Returns the object.
  4488. */
  4489. function toObject(value) {
  4490. return isObject(value) ? value : Object(value);
  4491. }
  4492. /**
  4493. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  4494. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4495. *
  4496. * @static
  4497. * @memberOf _
  4498. * @category Lang
  4499. * @param {*} value The value to check.
  4500. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4501. * @example
  4502. *
  4503. * _.isObject({});
  4504. * // => true
  4505. *
  4506. * _.isObject([1, 2, 3]);
  4507. * // => true
  4508. *
  4509. * _.isObject(1);
  4510. * // => false
  4511. */
  4512. function isObject(value) {
  4513. // Avoid a V8 JIT bug in Chrome 19-20.
  4514. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  4515. var type = typeof value;
  4516. return !!value && (type == 'object' || type == 'function');
  4517. }
  4518. module.exports = baseEach;
  4519. },{"lodash.keys":34}],21:[function(require,module,exports){
  4520. /**
  4521. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  4522. * Build: `lodash modern modularize exports="npm" -o ./`
  4523. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4524. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  4525. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4526. * Available under MIT license <https://lodash.com/license>
  4527. */
  4528. /**
  4529. * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
  4530. * without support for callback shorthands and `this` binding, which iterates
  4531. * over `collection` using the provided `eachFunc`.
  4532. *
  4533. * @private
  4534. * @param {Array|Object|string} collection The collection to search.
  4535. * @param {Function} predicate The function invoked per iteration.
  4536. * @param {Function} eachFunc The function to iterate over `collection`.
  4537. * @param {boolean} [retKey] Specify returning the key of the found element
  4538. * instead of the element itself.
  4539. * @returns {*} Returns the found element or its key, else `undefined`.
  4540. */
  4541. function baseFind(collection, predicate, eachFunc, retKey) {
  4542. var result;
  4543. eachFunc(collection, function(value, key, collection) {
  4544. if (predicate(value, key, collection)) {
  4545. result = retKey ? key : value;
  4546. return false;
  4547. }
  4548. });
  4549. return result;
  4550. }
  4551. module.exports = baseFind;
  4552. },{}],22:[function(require,module,exports){
  4553. /**
  4554. * lodash 3.6.0 (Custom Build) <https://lodash.com/>
  4555. * Build: `lodash modern modularize exports="npm" -o ./`
  4556. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4557. * Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
  4558. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4559. * Available under MIT license <https://lodash.com/license>
  4560. */
  4561. /**
  4562. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  4563. * support for callback shorthands and `this` binding.
  4564. *
  4565. * @private
  4566. * @param {Array} array The array to search.
  4567. * @param {Function} predicate The function invoked per iteration.
  4568. * @param {boolean} [fromRight] Specify iterating from right to left.
  4569. * @returns {number} Returns the index of the matched value, else `-1`.
  4570. */
  4571. function baseFindIndex(array, predicate, fromRight) {
  4572. var length = array.length,
  4573. index = fromRight ? length : -1;
  4574. while ((fromRight ? index-- : ++index < length)) {
  4575. if (predicate(array[index], index, array)) {
  4576. return index;
  4577. }
  4578. }
  4579. return -1;
  4580. }
  4581. module.exports = baseFindIndex;
  4582. },{}],23:[function(require,module,exports){
  4583. /**
  4584. * lodash 3.0.3 (Custom Build) <https://lodash.com/>
  4585. * Build: `lodash modularize exports="npm" -o ./`
  4586. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  4587. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4588. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4589. * Available under MIT license <https://lodash.com/license>
  4590. */
  4591. /**
  4592. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  4593. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  4594. * each property. Iteratee functions may exit iteration early by explicitly
  4595. * returning `false`.
  4596. *
  4597. * @private
  4598. * @param {Object} object The object to iterate over.
  4599. * @param {Function} iteratee The function invoked per iteration.
  4600. * @param {Function} keysFunc The function to get the keys of `object`.
  4601. * @returns {Object} Returns `object`.
  4602. */
  4603. var baseFor = createBaseFor();
  4604. /**
  4605. * Creates a base function for methods like `_.forIn`.
  4606. *
  4607. * @private
  4608. * @param {boolean} [fromRight] Specify iterating from right to left.
  4609. * @returns {Function} Returns the new base function.
  4610. */
  4611. function createBaseFor(fromRight) {
  4612. return function(object, iteratee, keysFunc) {
  4613. var index = -1,
  4614. iterable = Object(object),
  4615. props = keysFunc(object),
  4616. length = props.length;
  4617. while (length--) {
  4618. var key = props[fromRight ? length : ++index];
  4619. if (iteratee(iterable[key], key, iterable) === false) {
  4620. break;
  4621. }
  4622. }
  4623. return object;
  4624. };
  4625. }
  4626. module.exports = baseFor;
  4627. },{}],24:[function(require,module,exports){
  4628. /**
  4629. * lodash 3.0.7 (Custom Build) <https://lodash.com/>
  4630. * Build: `lodash modern modularize exports="npm" -o ./`
  4631. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4632. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4633. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4634. * Available under MIT license <https://lodash.com/license>
  4635. */
  4636. var isArray = require('lodash.isarray'),
  4637. isTypedArray = require('lodash.istypedarray'),
  4638. keys = require('lodash.keys');
  4639. /** `Object#toString` result references. */
  4640. var argsTag = '[object Arguments]',
  4641. arrayTag = '[object Array]',
  4642. boolTag = '[object Boolean]',
  4643. dateTag = '[object Date]',
  4644. errorTag = '[object Error]',
  4645. numberTag = '[object Number]',
  4646. objectTag = '[object Object]',
  4647. regexpTag = '[object RegExp]',
  4648. stringTag = '[object String]';
  4649. /**
  4650. * Checks if `value` is object-like.
  4651. *
  4652. * @private
  4653. * @param {*} value The value to check.
  4654. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4655. */
  4656. function isObjectLike(value) {
  4657. return !!value && typeof value == 'object';
  4658. }
  4659. /** Used for native method references. */
  4660. var objectProto = Object.prototype;
  4661. /** Used to check objects for own properties. */
  4662. var hasOwnProperty = objectProto.hasOwnProperty;
  4663. /**
  4664. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  4665. * of values.
  4666. */
  4667. var objToString = objectProto.toString;
  4668. /**
  4669. * A specialized version of `_.some` for arrays without support for callback
  4670. * shorthands and `this` binding.
  4671. *
  4672. * @private
  4673. * @param {Array} array The array to iterate over.
  4674. * @param {Function} predicate The function invoked per iteration.
  4675. * @returns {boolean} Returns `true` if any element passes the predicate check,
  4676. * else `false`.
  4677. */
  4678. function arraySome(array, predicate) {
  4679. var index = -1,
  4680. length = array.length;
  4681. while (++index < length) {
  4682. if (predicate(array[index], index, array)) {
  4683. return true;
  4684. }
  4685. }
  4686. return false;
  4687. }
  4688. /**
  4689. * The base implementation of `_.isEqual` without support for `this` binding
  4690. * `customizer` functions.
  4691. *
  4692. * @private
  4693. * @param {*} value The value to compare.
  4694. * @param {*} other The other value to compare.
  4695. * @param {Function} [customizer] The function to customize comparing values.
  4696. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4697. * @param {Array} [stackA] Tracks traversed `value` objects.
  4698. * @param {Array} [stackB] Tracks traversed `other` objects.
  4699. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4700. */
  4701. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  4702. if (value === other) {
  4703. return true;
  4704. }
  4705. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  4706. return value !== value && other !== other;
  4707. }
  4708. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  4709. }
  4710. /**
  4711. * A specialized version of `baseIsEqual` for arrays and objects which performs
  4712. * deep comparisons and tracks traversed objects enabling objects with circular
  4713. * references to be compared.
  4714. *
  4715. * @private
  4716. * @param {Object} object The object to compare.
  4717. * @param {Object} other The other object to compare.
  4718. * @param {Function} equalFunc The function to determine equivalents of values.
  4719. * @param {Function} [customizer] The function to customize comparing objects.
  4720. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4721. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  4722. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  4723. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4724. */
  4725. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  4726. var objIsArr = isArray(object),
  4727. othIsArr = isArray(other),
  4728. objTag = arrayTag,
  4729. othTag = arrayTag;
  4730. if (!objIsArr) {
  4731. objTag = objToString.call(object);
  4732. if (objTag == argsTag) {
  4733. objTag = objectTag;
  4734. } else if (objTag != objectTag) {
  4735. objIsArr = isTypedArray(object);
  4736. }
  4737. }
  4738. if (!othIsArr) {
  4739. othTag = objToString.call(other);
  4740. if (othTag == argsTag) {
  4741. othTag = objectTag;
  4742. } else if (othTag != objectTag) {
  4743. othIsArr = isTypedArray(other);
  4744. }
  4745. }
  4746. var objIsObj = objTag == objectTag,
  4747. othIsObj = othTag == objectTag,
  4748. isSameTag = objTag == othTag;
  4749. if (isSameTag && !(objIsArr || objIsObj)) {
  4750. return equalByTag(object, other, objTag);
  4751. }
  4752. if (!isLoose) {
  4753. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  4754. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  4755. if (objIsWrapped || othIsWrapped) {
  4756. return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  4757. }
  4758. }
  4759. if (!isSameTag) {
  4760. return false;
  4761. }
  4762. // Assume cyclic values are equal.
  4763. // For more information on detecting circular references see https://es5.github.io/#JO.
  4764. stackA || (stackA = []);
  4765. stackB || (stackB = []);
  4766. var length = stackA.length;
  4767. while (length--) {
  4768. if (stackA[length] == object) {
  4769. return stackB[length] == other;
  4770. }
  4771. }
  4772. // Add `object` and `other` to the stack of traversed objects.
  4773. stackA.push(object);
  4774. stackB.push(other);
  4775. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  4776. stackA.pop();
  4777. stackB.pop();
  4778. return result;
  4779. }
  4780. /**
  4781. * A specialized version of `baseIsEqualDeep` for arrays with support for
  4782. * partial deep comparisons.
  4783. *
  4784. * @private
  4785. * @param {Array} array The array to compare.
  4786. * @param {Array} other The other array to compare.
  4787. * @param {Function} equalFunc The function to determine equivalents of values.
  4788. * @param {Function} [customizer] The function to customize comparing arrays.
  4789. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4790. * @param {Array} [stackA] Tracks traversed `value` objects.
  4791. * @param {Array} [stackB] Tracks traversed `other` objects.
  4792. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  4793. */
  4794. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  4795. var index = -1,
  4796. arrLength = array.length,
  4797. othLength = other.length;
  4798. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  4799. return false;
  4800. }
  4801. // Ignore non-index properties.
  4802. while (++index < arrLength) {
  4803. var arrValue = array[index],
  4804. othValue = other[index],
  4805. result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
  4806. if (result !== undefined) {
  4807. if (result) {
  4808. continue;
  4809. }
  4810. return false;
  4811. }
  4812. // Recursively compare arrays (susceptible to call stack limits).
  4813. if (isLoose) {
  4814. if (!arraySome(other, function(othValue) {
  4815. return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  4816. })) {
  4817. return false;
  4818. }
  4819. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
  4820. return false;
  4821. }
  4822. }
  4823. return true;
  4824. }
  4825. /**
  4826. * A specialized version of `baseIsEqualDeep` for comparing objects of
  4827. * the same `toStringTag`.
  4828. *
  4829. * **Note:** This function only supports comparing values with tags of
  4830. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  4831. *
  4832. * @private
  4833. * @param {Object} value The object to compare.
  4834. * @param {Object} other The other object to compare.
  4835. * @param {string} tag The `toStringTag` of the objects to compare.
  4836. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4837. */
  4838. function equalByTag(object, other, tag) {
  4839. switch (tag) {
  4840. case boolTag:
  4841. case dateTag:
  4842. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  4843. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  4844. return +object == +other;
  4845. case errorTag:
  4846. return object.name == other.name && object.message == other.message;
  4847. case numberTag:
  4848. // Treat `NaN` vs. `NaN` as equal.
  4849. return (object != +object)
  4850. ? other != +other
  4851. : object == +other;
  4852. case regexpTag:
  4853. case stringTag:
  4854. // Coerce regexes to strings and treat strings primitives and string
  4855. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  4856. return object == (other + '');
  4857. }
  4858. return false;
  4859. }
  4860. /**
  4861. * A specialized version of `baseIsEqualDeep` for objects with support for
  4862. * partial deep comparisons.
  4863. *
  4864. * @private
  4865. * @param {Object} object The object to compare.
  4866. * @param {Object} other The other object to compare.
  4867. * @param {Function} equalFunc The function to determine equivalents of values.
  4868. * @param {Function} [customizer] The function to customize comparing values.
  4869. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4870. * @param {Array} [stackA] Tracks traversed `value` objects.
  4871. * @param {Array} [stackB] Tracks traversed `other` objects.
  4872. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4873. */
  4874. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  4875. var objProps = keys(object),
  4876. objLength = objProps.length,
  4877. othProps = keys(other),
  4878. othLength = othProps.length;
  4879. if (objLength != othLength && !isLoose) {
  4880. return false;
  4881. }
  4882. var index = objLength;
  4883. while (index--) {
  4884. var key = objProps[index];
  4885. if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
  4886. return false;
  4887. }
  4888. }
  4889. var skipCtor = isLoose;
  4890. while (++index < objLength) {
  4891. key = objProps[index];
  4892. var objValue = object[key],
  4893. othValue = other[key],
  4894. result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
  4895. // Recursively compare objects (susceptible to call stack limits).
  4896. if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
  4897. return false;
  4898. }
  4899. skipCtor || (skipCtor = key == 'constructor');
  4900. }
  4901. if (!skipCtor) {
  4902. var objCtor = object.constructor,
  4903. othCtor = other.constructor;
  4904. // Non `Object` object instances with different constructors are not equal.
  4905. if (objCtor != othCtor &&
  4906. ('constructor' in object && 'constructor' in other) &&
  4907. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  4908. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  4909. return false;
  4910. }
  4911. }
  4912. return true;
  4913. }
  4914. /**
  4915. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  4916. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4917. *
  4918. * @static
  4919. * @memberOf _
  4920. * @category Lang
  4921. * @param {*} value The value to check.
  4922. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4923. * @example
  4924. *
  4925. * _.isObject({});
  4926. * // => true
  4927. *
  4928. * _.isObject([1, 2, 3]);
  4929. * // => true
  4930. *
  4931. * _.isObject(1);
  4932. * // => false
  4933. */
  4934. function isObject(value) {
  4935. // Avoid a V8 JIT bug in Chrome 19-20.
  4936. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  4937. var type = typeof value;
  4938. return !!value && (type == 'object' || type == 'function');
  4939. }
  4940. module.exports = baseIsEqual;
  4941. },{"lodash.isarray":31,"lodash.istypedarray":33,"lodash.keys":34}],25:[function(require,module,exports){
  4942. /**
  4943. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  4944. * Build: `lodash modern modularize exports="npm" -o ./`
  4945. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4946. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4947. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4948. * Available under MIT license <https://lodash.com/license>
  4949. */
  4950. /**
  4951. * A specialized version of `baseCallback` which only supports `this` binding
  4952. * and specifying the number of arguments to provide to `func`.
  4953. *
  4954. * @private
  4955. * @param {Function} func The function to bind.
  4956. * @param {*} thisArg The `this` binding of `func`.
  4957. * @param {number} [argCount] The number of arguments to provide to `func`.
  4958. * @returns {Function} Returns the callback.
  4959. */
  4960. function bindCallback(func, thisArg, argCount) {
  4961. if (typeof func != 'function') {
  4962. return identity;
  4963. }
  4964. if (thisArg === undefined) {
  4965. return func;
  4966. }
  4967. switch (argCount) {
  4968. case 1: return function(value) {
  4969. return func.call(thisArg, value);
  4970. };
  4971. case 3: return function(value, index, collection) {
  4972. return func.call(thisArg, value, index, collection);
  4973. };
  4974. case 4: return function(accumulator, value, index, collection) {
  4975. return func.call(thisArg, accumulator, value, index, collection);
  4976. };
  4977. case 5: return function(value, other, key, object, source) {
  4978. return func.call(thisArg, value, other, key, object, source);
  4979. };
  4980. }
  4981. return function() {
  4982. return func.apply(thisArg, arguments);
  4983. };
  4984. }
  4985. /**
  4986. * This method returns the first argument provided to it.
  4987. *
  4988. * @static
  4989. * @memberOf _
  4990. * @category Utility
  4991. * @param {*} value Any value.
  4992. * @returns {*} Returns `value`.
  4993. * @example
  4994. *
  4995. * var object = { 'user': 'fred' };
  4996. *
  4997. * _.identity(object) === object;
  4998. * // => true
  4999. */
  5000. function identity(value) {
  5001. return value;
  5002. }
  5003. module.exports = bindCallback;
  5004. },{}],26:[function(require,module,exports){
  5005. /**
  5006. * lodash 3.1.1 (Custom Build) <https://lodash.com/>
  5007. * Build: `lodash modern modularize exports="npm" -o ./`
  5008. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5009. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5010. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5011. * Available under MIT license <https://lodash.com/license>
  5012. */
  5013. var bindCallback = require('lodash._bindcallback'),
  5014. isIterateeCall = require('lodash._isiterateecall'),
  5015. restParam = require('lodash.restparam');
  5016. /**
  5017. * Creates a function that assigns properties of source object(s) to a given
  5018. * destination object.
  5019. *
  5020. * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
  5021. *
  5022. * @private
  5023. * @param {Function} assigner The function to assign values.
  5024. * @returns {Function} Returns the new assigner function.
  5025. */
  5026. function createAssigner(assigner) {
  5027. return restParam(function(object, sources) {
  5028. var index = -1,
  5029. length = object == null ? 0 : sources.length,
  5030. customizer = length > 2 ? sources[length - 2] : undefined,
  5031. guard = length > 2 ? sources[2] : undefined,
  5032. thisArg = length > 1 ? sources[length - 1] : undefined;
  5033. if (typeof customizer == 'function') {
  5034. customizer = bindCallback(customizer, thisArg, 5);
  5035. length -= 2;
  5036. } else {
  5037. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  5038. length -= (customizer ? 1 : 0);
  5039. }
  5040. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  5041. customizer = length < 3 ? undefined : customizer;
  5042. length = 1;
  5043. }
  5044. while (++index < length) {
  5045. var source = sources[index];
  5046. if (source) {
  5047. assigner(object, source, customizer);
  5048. }
  5049. }
  5050. return object;
  5051. });
  5052. }
  5053. module.exports = createAssigner;
  5054. },{"lodash._bindcallback":25,"lodash._isiterateecall":28,"lodash.restparam":38}],27:[function(require,module,exports){
  5055. /**
  5056. * lodash 3.9.1 (Custom Build) <https://lodash.com/>
  5057. * Build: `lodash modern modularize exports="npm" -o ./`
  5058. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5059. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5060. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5061. * Available under MIT license <https://lodash.com/license>
  5062. */
  5063. /** `Object#toString` result references. */
  5064. var funcTag = '[object Function]';
  5065. /** Used to detect host constructors (Safari > 5). */
  5066. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  5067. /**
  5068. * Checks if `value` is object-like.
  5069. *
  5070. * @private
  5071. * @param {*} value The value to check.
  5072. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5073. */
  5074. function isObjectLike(value) {
  5075. return !!value && typeof value == 'object';
  5076. }
  5077. /** Used for native method references. */
  5078. var objectProto = Object.prototype;
  5079. /** Used to resolve the decompiled source of functions. */
  5080. var fnToString = Function.prototype.toString;
  5081. /** Used to check objects for own properties. */
  5082. var hasOwnProperty = objectProto.hasOwnProperty;
  5083. /**
  5084. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5085. * of values.
  5086. */
  5087. var objToString = objectProto.toString;
  5088. /** Used to detect if a method is native. */
  5089. var reIsNative = RegExp('^' +
  5090. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  5091. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  5092. );
  5093. /**
  5094. * Gets the native function at `key` of `object`.
  5095. *
  5096. * @private
  5097. * @param {Object} object The object to query.
  5098. * @param {string} key The key of the method to get.
  5099. * @returns {*} Returns the function if it's native, else `undefined`.
  5100. */
  5101. function getNative(object, key) {
  5102. var value = object == null ? undefined : object[key];
  5103. return isNative(value) ? value : undefined;
  5104. }
  5105. /**
  5106. * Checks if `value` is classified as a `Function` object.
  5107. *
  5108. * @static
  5109. * @memberOf _
  5110. * @category Lang
  5111. * @param {*} value The value to check.
  5112. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  5113. * @example
  5114. *
  5115. * _.isFunction(_);
  5116. * // => true
  5117. *
  5118. * _.isFunction(/abc/);
  5119. * // => false
  5120. */
  5121. function isFunction(value) {
  5122. // The use of `Object#toString` avoids issues with the `typeof` operator
  5123. // in older versions of Chrome and Safari which return 'function' for regexes
  5124. // and Safari 8 equivalents which return 'object' for typed array constructors.
  5125. return isObject(value) && objToString.call(value) == funcTag;
  5126. }
  5127. /**
  5128. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  5129. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5130. *
  5131. * @static
  5132. * @memberOf _
  5133. * @category Lang
  5134. * @param {*} value The value to check.
  5135. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5136. * @example
  5137. *
  5138. * _.isObject({});
  5139. * // => true
  5140. *
  5141. * _.isObject([1, 2, 3]);
  5142. * // => true
  5143. *
  5144. * _.isObject(1);
  5145. * // => false
  5146. */
  5147. function isObject(value) {
  5148. // Avoid a V8 JIT bug in Chrome 19-20.
  5149. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  5150. var type = typeof value;
  5151. return !!value && (type == 'object' || type == 'function');
  5152. }
  5153. /**
  5154. * Checks if `value` is a native function.
  5155. *
  5156. * @static
  5157. * @memberOf _
  5158. * @category Lang
  5159. * @param {*} value The value to check.
  5160. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  5161. * @example
  5162. *
  5163. * _.isNative(Array.prototype.push);
  5164. * // => true
  5165. *
  5166. * _.isNative(_);
  5167. * // => false
  5168. */
  5169. function isNative(value) {
  5170. if (value == null) {
  5171. return false;
  5172. }
  5173. if (isFunction(value)) {
  5174. return reIsNative.test(fnToString.call(value));
  5175. }
  5176. return isObjectLike(value) && reIsHostCtor.test(value);
  5177. }
  5178. module.exports = getNative;
  5179. },{}],28:[function(require,module,exports){
  5180. /**
  5181. * lodash 3.0.9 (Custom Build) <https://lodash.com/>
  5182. * Build: `lodash modern modularize exports="npm" -o ./`
  5183. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5184. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5185. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5186. * Available under MIT license <https://lodash.com/license>
  5187. */
  5188. /** Used to detect unsigned integer values. */
  5189. var reIsUint = /^\d+$/;
  5190. /**
  5191. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  5192. * of an array-like value.
  5193. */
  5194. var MAX_SAFE_INTEGER = 9007199254740991;
  5195. /**
  5196. * The base implementation of `_.property` without support for deep paths.
  5197. *
  5198. * @private
  5199. * @param {string} key The key of the property to get.
  5200. * @returns {Function} Returns the new function.
  5201. */
  5202. function baseProperty(key) {
  5203. return function(object) {
  5204. return object == null ? undefined : object[key];
  5205. };
  5206. }
  5207. /**
  5208. * Gets the "length" property value of `object`.
  5209. *
  5210. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  5211. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  5212. *
  5213. * @private
  5214. * @param {Object} object The object to query.
  5215. * @returns {*} Returns the "length" value.
  5216. */
  5217. var getLength = baseProperty('length');
  5218. /**
  5219. * Checks if `value` is array-like.
  5220. *
  5221. * @private
  5222. * @param {*} value The value to check.
  5223. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  5224. */
  5225. function isArrayLike(value) {
  5226. return value != null && isLength(getLength(value));
  5227. }
  5228. /**
  5229. * Checks if `value` is a valid array-like index.
  5230. *
  5231. * @private
  5232. * @param {*} value The value to check.
  5233. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  5234. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  5235. */
  5236. function isIndex(value, length) {
  5237. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  5238. length = length == null ? MAX_SAFE_INTEGER : length;
  5239. return value > -1 && value % 1 == 0 && value < length;
  5240. }
  5241. /**
  5242. * Checks if the provided arguments are from an iteratee call.
  5243. *
  5244. * @private
  5245. * @param {*} value The potential iteratee value argument.
  5246. * @param {*} index The potential iteratee index or key argument.
  5247. * @param {*} object The potential iteratee object argument.
  5248. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  5249. */
  5250. function isIterateeCall(value, index, object) {
  5251. if (!isObject(object)) {
  5252. return false;
  5253. }
  5254. var type = typeof index;
  5255. if (type == 'number'
  5256. ? (isArrayLike(object) && isIndex(index, object.length))
  5257. : (type == 'string' && index in object)) {
  5258. var other = object[index];
  5259. return value === value ? (value === other) : (other !== other);
  5260. }
  5261. return false;
  5262. }
  5263. /**
  5264. * Checks if `value` is a valid array-like length.
  5265. *
  5266. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  5267. *
  5268. * @private
  5269. * @param {*} value The value to check.
  5270. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5271. */
  5272. function isLength(value) {
  5273. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5274. }
  5275. /**
  5276. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  5277. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5278. *
  5279. * @static
  5280. * @memberOf _
  5281. * @category Lang
  5282. * @param {*} value The value to check.
  5283. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5284. * @example
  5285. *
  5286. * _.isObject({});
  5287. * // => true
  5288. *
  5289. * _.isObject([1, 2, 3]);
  5290. * // => true
  5291. *
  5292. * _.isObject(1);
  5293. * // => false
  5294. */
  5295. function isObject(value) {
  5296. // Avoid a V8 JIT bug in Chrome 19-20.
  5297. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  5298. var type = typeof value;
  5299. return !!value && (type == 'object' || type == 'function');
  5300. }
  5301. module.exports = isIterateeCall;
  5302. },{}],29:[function(require,module,exports){
  5303. /**
  5304. * lodash 3.2.1 (Custom Build) <https://lodash.com/>
  5305. * Build: `lodash modern modularize exports="npm" -o ./`
  5306. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5307. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5308. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5309. * Available under MIT license <https://lodash.com/license>
  5310. */
  5311. var baseCallback = require('lodash._basecallback'),
  5312. baseEach = require('lodash._baseeach'),
  5313. baseFind = require('lodash._basefind'),
  5314. baseFindIndex = require('lodash._basefindindex'),
  5315. isArray = require('lodash.isarray');
  5316. /**
  5317. * Creates a `_.find` or `_.findLast` function.
  5318. *
  5319. * @private
  5320. * @param {Function} eachFunc The function to iterate over a collection.
  5321. * @param {boolean} [fromRight] Specify iterating from right to left.
  5322. * @returns {Function} Returns the new find function.
  5323. */
  5324. function createFind(eachFunc, fromRight) {
  5325. return function(collection, predicate, thisArg) {
  5326. predicate = baseCallback(predicate, thisArg, 3);
  5327. if (isArray(collection)) {
  5328. var index = baseFindIndex(collection, predicate, fromRight);
  5329. return index > -1 ? collection[index] : undefined;
  5330. }
  5331. return baseFind(collection, predicate, eachFunc);
  5332. };
  5333. }
  5334. /**
  5335. * Iterates over elements of `collection`, returning the first element
  5336. * `predicate` returns truthy for. The predicate is bound to `thisArg` and
  5337. * invoked with three arguments: (value, index|key, collection).
  5338. *
  5339. * If a property name is provided for `predicate` the created `_.property`
  5340. * style callback returns the property value of the given element.
  5341. *
  5342. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  5343. * style callback returns `true` for elements that have a matching property
  5344. * value, else `false`.
  5345. *
  5346. * If an object is provided for `predicate` the created `_.matches` style
  5347. * callback returns `true` for elements that have the properties of the given
  5348. * object, else `false`.
  5349. *
  5350. * @static
  5351. * @memberOf _
  5352. * @alias detect
  5353. * @category Collection
  5354. * @param {Array|Object|string} collection The collection to search.
  5355. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  5356. * per iteration.
  5357. * @param {*} [thisArg] The `this` binding of `predicate`.
  5358. * @returns {*} Returns the matched element, else `undefined`.
  5359. * @example
  5360. *
  5361. * var users = [
  5362. * { 'user': 'barney', 'age': 36, 'active': true },
  5363. * { 'user': 'fred', 'age': 40, 'active': false },
  5364. * { 'user': 'pebbles', 'age': 1, 'active': true }
  5365. * ];
  5366. *
  5367. * _.result(_.find(users, function(chr) {
  5368. * return chr.age < 40;
  5369. * }), 'user');
  5370. * // => 'barney'
  5371. *
  5372. * // using the `_.matches` callback shorthand
  5373. * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
  5374. * // => 'pebbles'
  5375. *
  5376. * // using the `_.matchesProperty` callback shorthand
  5377. * _.result(_.find(users, 'active', false), 'user');
  5378. * // => 'fred'
  5379. *
  5380. * // using the `_.property` callback shorthand
  5381. * _.result(_.find(users, 'active'), 'user');
  5382. * // => 'barney'
  5383. */
  5384. var find = createFind(baseEach);
  5385. module.exports = find;
  5386. },{"lodash._basecallback":18,"lodash._baseeach":20,"lodash._basefind":21,"lodash._basefindindex":22,"lodash.isarray":31}],30:[function(require,module,exports){
  5387. /**
  5388. * lodash (Custom Build) <https://lodash.com/>
  5389. * Build: `lodash modularize exports="npm" -o ./`
  5390. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  5391. * Released under MIT license <https://lodash.com/license>
  5392. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5393. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5394. */
  5395. /** Used as references for various `Number` constants. */
  5396. var MAX_SAFE_INTEGER = 9007199254740991;
  5397. /** `Object#toString` result references. */
  5398. var argsTag = '[object Arguments]',
  5399. funcTag = '[object Function]',
  5400. genTag = '[object GeneratorFunction]';
  5401. /** Used for built-in method references. */
  5402. var objectProto = Object.prototype;
  5403. /** Used to check objects for own properties. */
  5404. var hasOwnProperty = objectProto.hasOwnProperty;
  5405. /**
  5406. * Used to resolve the
  5407. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  5408. * of values.
  5409. */
  5410. var objectToString = objectProto.toString;
  5411. /** Built-in value references. */
  5412. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  5413. /**
  5414. * Checks if `value` is likely an `arguments` object.
  5415. *
  5416. * @static
  5417. * @memberOf _
  5418. * @since 0.1.0
  5419. * @category Lang
  5420. * @param {*} value The value to check.
  5421. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  5422. * else `false`.
  5423. * @example
  5424. *
  5425. * _.isArguments(function() { return arguments; }());
  5426. * // => true
  5427. *
  5428. * _.isArguments([1, 2, 3]);
  5429. * // => false
  5430. */
  5431. function isArguments(value) {
  5432. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  5433. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  5434. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  5435. }
  5436. /**
  5437. * Checks if `value` is array-like. A value is considered array-like if it's
  5438. * not a function and has a `value.length` that's an integer greater than or
  5439. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  5440. *
  5441. * @static
  5442. * @memberOf _
  5443. * @since 4.0.0
  5444. * @category Lang
  5445. * @param {*} value The value to check.
  5446. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  5447. * @example
  5448. *
  5449. * _.isArrayLike([1, 2, 3]);
  5450. * // => true
  5451. *
  5452. * _.isArrayLike(document.body.children);
  5453. * // => true
  5454. *
  5455. * _.isArrayLike('abc');
  5456. * // => true
  5457. *
  5458. * _.isArrayLike(_.noop);
  5459. * // => false
  5460. */
  5461. function isArrayLike(value) {
  5462. return value != null && isLength(value.length) && !isFunction(value);
  5463. }
  5464. /**
  5465. * This method is like `_.isArrayLike` except that it also checks if `value`
  5466. * is an object.
  5467. *
  5468. * @static
  5469. * @memberOf _
  5470. * @since 4.0.0
  5471. * @category Lang
  5472. * @param {*} value The value to check.
  5473. * @returns {boolean} Returns `true` if `value` is an array-like object,
  5474. * else `false`.
  5475. * @example
  5476. *
  5477. * _.isArrayLikeObject([1, 2, 3]);
  5478. * // => true
  5479. *
  5480. * _.isArrayLikeObject(document.body.children);
  5481. * // => true
  5482. *
  5483. * _.isArrayLikeObject('abc');
  5484. * // => false
  5485. *
  5486. * _.isArrayLikeObject(_.noop);
  5487. * // => false
  5488. */
  5489. function isArrayLikeObject(value) {
  5490. return isObjectLike(value) && isArrayLike(value);
  5491. }
  5492. /**
  5493. * Checks if `value` is classified as a `Function` object.
  5494. *
  5495. * @static
  5496. * @memberOf _
  5497. * @since 0.1.0
  5498. * @category Lang
  5499. * @param {*} value The value to check.
  5500. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  5501. * @example
  5502. *
  5503. * _.isFunction(_);
  5504. * // => true
  5505. *
  5506. * _.isFunction(/abc/);
  5507. * // => false
  5508. */
  5509. function isFunction(value) {
  5510. // The use of `Object#toString` avoids issues with the `typeof` operator
  5511. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  5512. var tag = isObject(value) ? objectToString.call(value) : '';
  5513. return tag == funcTag || tag == genTag;
  5514. }
  5515. /**
  5516. * Checks if `value` is a valid array-like length.
  5517. *
  5518. * **Note:** This method is loosely based on
  5519. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  5520. *
  5521. * @static
  5522. * @memberOf _
  5523. * @since 4.0.0
  5524. * @category Lang
  5525. * @param {*} value The value to check.
  5526. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5527. * @example
  5528. *
  5529. * _.isLength(3);
  5530. * // => true
  5531. *
  5532. * _.isLength(Number.MIN_VALUE);
  5533. * // => false
  5534. *
  5535. * _.isLength(Infinity);
  5536. * // => false
  5537. *
  5538. * _.isLength('3');
  5539. * // => false
  5540. */
  5541. function isLength(value) {
  5542. return typeof value == 'number' &&
  5543. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5544. }
  5545. /**
  5546. * Checks if `value` is the
  5547. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  5548. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5549. *
  5550. * @static
  5551. * @memberOf _
  5552. * @since 0.1.0
  5553. * @category Lang
  5554. * @param {*} value The value to check.
  5555. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5556. * @example
  5557. *
  5558. * _.isObject({});
  5559. * // => true
  5560. *
  5561. * _.isObject([1, 2, 3]);
  5562. * // => true
  5563. *
  5564. * _.isObject(_.noop);
  5565. * // => true
  5566. *
  5567. * _.isObject(null);
  5568. * // => false
  5569. */
  5570. function isObject(value) {
  5571. var type = typeof value;
  5572. return !!value && (type == 'object' || type == 'function');
  5573. }
  5574. /**
  5575. * Checks if `value` is object-like. A value is object-like if it's not `null`
  5576. * and has a `typeof` result of "object".
  5577. *
  5578. * @static
  5579. * @memberOf _
  5580. * @since 4.0.0
  5581. * @category Lang
  5582. * @param {*} value The value to check.
  5583. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5584. * @example
  5585. *
  5586. * _.isObjectLike({});
  5587. * // => true
  5588. *
  5589. * _.isObjectLike([1, 2, 3]);
  5590. * // => true
  5591. *
  5592. * _.isObjectLike(_.noop);
  5593. * // => false
  5594. *
  5595. * _.isObjectLike(null);
  5596. * // => false
  5597. */
  5598. function isObjectLike(value) {
  5599. return !!value && typeof value == 'object';
  5600. }
  5601. module.exports = isArguments;
  5602. },{}],31:[function(require,module,exports){
  5603. /**
  5604. * lodash 3.0.4 (Custom Build) <https://lodash.com/>
  5605. * Build: `lodash modern modularize exports="npm" -o ./`
  5606. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5607. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5608. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5609. * Available under MIT license <https://lodash.com/license>
  5610. */
  5611. /** `Object#toString` result references. */
  5612. var arrayTag = '[object Array]',
  5613. funcTag = '[object Function]';
  5614. /** Used to detect host constructors (Safari > 5). */
  5615. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  5616. /**
  5617. * Checks if `value` is object-like.
  5618. *
  5619. * @private
  5620. * @param {*} value The value to check.
  5621. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5622. */
  5623. function isObjectLike(value) {
  5624. return !!value && typeof value == 'object';
  5625. }
  5626. /** Used for native method references. */
  5627. var objectProto = Object.prototype;
  5628. /** Used to resolve the decompiled source of functions. */
  5629. var fnToString = Function.prototype.toString;
  5630. /** Used to check objects for own properties. */
  5631. var hasOwnProperty = objectProto.hasOwnProperty;
  5632. /**
  5633. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5634. * of values.
  5635. */
  5636. var objToString = objectProto.toString;
  5637. /** Used to detect if a method is native. */
  5638. var reIsNative = RegExp('^' +
  5639. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  5640. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  5641. );
  5642. /* Native method references for those with the same name as other `lodash` methods. */
  5643. var nativeIsArray = getNative(Array, 'isArray');
  5644. /**
  5645. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  5646. * of an array-like value.
  5647. */
  5648. var MAX_SAFE_INTEGER = 9007199254740991;
  5649. /**
  5650. * Gets the native function at `key` of `object`.
  5651. *
  5652. * @private
  5653. * @param {Object} object The object to query.
  5654. * @param {string} key The key of the method to get.
  5655. * @returns {*} Returns the function if it's native, else `undefined`.
  5656. */
  5657. function getNative(object, key) {
  5658. var value = object == null ? undefined : object[key];
  5659. return isNative(value) ? value : undefined;
  5660. }
  5661. /**
  5662. * Checks if `value` is a valid array-like length.
  5663. *
  5664. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  5665. *
  5666. * @private
  5667. * @param {*} value The value to check.
  5668. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5669. */
  5670. function isLength(value) {
  5671. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5672. }
  5673. /**
  5674. * Checks if `value` is classified as an `Array` object.
  5675. *
  5676. * @static
  5677. * @memberOf _
  5678. * @category Lang
  5679. * @param {*} value The value to check.
  5680. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  5681. * @example
  5682. *
  5683. * _.isArray([1, 2, 3]);
  5684. * // => true
  5685. *
  5686. * _.isArray(function() { return arguments; }());
  5687. * // => false
  5688. */
  5689. var isArray = nativeIsArray || function(value) {
  5690. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  5691. };
  5692. /**
  5693. * Checks if `value` is classified as a `Function` object.
  5694. *
  5695. * @static
  5696. * @memberOf _
  5697. * @category Lang
  5698. * @param {*} value The value to check.
  5699. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  5700. * @example
  5701. *
  5702. * _.isFunction(_);
  5703. * // => true
  5704. *
  5705. * _.isFunction(/abc/);
  5706. * // => false
  5707. */
  5708. function isFunction(value) {
  5709. // The use of `Object#toString` avoids issues with the `typeof` operator
  5710. // in older versions of Chrome and Safari which return 'function' for regexes
  5711. // and Safari 8 equivalents which return 'object' for typed array constructors.
  5712. return isObject(value) && objToString.call(value) == funcTag;
  5713. }
  5714. /**
  5715. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  5716. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5717. *
  5718. * @static
  5719. * @memberOf _
  5720. * @category Lang
  5721. * @param {*} value The value to check.
  5722. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5723. * @example
  5724. *
  5725. * _.isObject({});
  5726. * // => true
  5727. *
  5728. * _.isObject([1, 2, 3]);
  5729. * // => true
  5730. *
  5731. * _.isObject(1);
  5732. * // => false
  5733. */
  5734. function isObject(value) {
  5735. // Avoid a V8 JIT bug in Chrome 19-20.
  5736. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  5737. var type = typeof value;
  5738. return !!value && (type == 'object' || type == 'function');
  5739. }
  5740. /**
  5741. * Checks if `value` is a native function.
  5742. *
  5743. * @static
  5744. * @memberOf _
  5745. * @category Lang
  5746. * @param {*} value The value to check.
  5747. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  5748. * @example
  5749. *
  5750. * _.isNative(Array.prototype.push);
  5751. * // => true
  5752. *
  5753. * _.isNative(_);
  5754. * // => false
  5755. */
  5756. function isNative(value) {
  5757. if (value == null) {
  5758. return false;
  5759. }
  5760. if (isFunction(value)) {
  5761. return reIsNative.test(fnToString.call(value));
  5762. }
  5763. return isObjectLike(value) && reIsHostCtor.test(value);
  5764. }
  5765. module.exports = isArray;
  5766. },{}],32:[function(require,module,exports){
  5767. /**
  5768. * lodash 3.2.0 (Custom Build) <https://lodash.com/>
  5769. * Build: `lodash modern modularize exports="npm" -o ./`
  5770. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5771. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5772. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5773. * Available under MIT license <https://lodash.com/license>
  5774. */
  5775. var baseFor = require('lodash._basefor'),
  5776. isArguments = require('lodash.isarguments'),
  5777. keysIn = require('lodash.keysin');
  5778. /** `Object#toString` result references. */
  5779. var objectTag = '[object Object]';
  5780. /**
  5781. * Checks if `value` is object-like.
  5782. *
  5783. * @private
  5784. * @param {*} value The value to check.
  5785. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5786. */
  5787. function isObjectLike(value) {
  5788. return !!value && typeof value == 'object';
  5789. }
  5790. /** Used for native method references. */
  5791. var objectProto = Object.prototype;
  5792. /** Used to check objects for own properties. */
  5793. var hasOwnProperty = objectProto.hasOwnProperty;
  5794. /**
  5795. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5796. * of values.
  5797. */
  5798. var objToString = objectProto.toString;
  5799. /**
  5800. * The base implementation of `_.forIn` without support for callback
  5801. * shorthands and `this` binding.
  5802. *
  5803. * @private
  5804. * @param {Object} object The object to iterate over.
  5805. * @param {Function} iteratee The function invoked per iteration.
  5806. * @returns {Object} Returns `object`.
  5807. */
  5808. function baseForIn(object, iteratee) {
  5809. return baseFor(object, iteratee, keysIn);
  5810. }
  5811. /**
  5812. * Checks if `value` is a plain object, that is, an object created by the
  5813. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  5814. *
  5815. * **Note:** This method assumes objects created by the `Object` constructor
  5816. * have no inherited enumerable properties.
  5817. *
  5818. * @static
  5819. * @memberOf _
  5820. * @category Lang
  5821. * @param {*} value The value to check.
  5822. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  5823. * @example
  5824. *
  5825. * function Foo() {
  5826. * this.a = 1;
  5827. * }
  5828. *
  5829. * _.isPlainObject(new Foo);
  5830. * // => false
  5831. *
  5832. * _.isPlainObject([1, 2, 3]);
  5833. * // => false
  5834. *
  5835. * _.isPlainObject({ 'x': 0, 'y': 0 });
  5836. * // => true
  5837. *
  5838. * _.isPlainObject(Object.create(null));
  5839. * // => true
  5840. */
  5841. function isPlainObject(value) {
  5842. var Ctor;
  5843. // Exit early for non `Object` objects.
  5844. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
  5845. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  5846. return false;
  5847. }
  5848. // IE < 9 iterates inherited properties before own properties. If the first
  5849. // iterated property is an object's own property then there are no inherited
  5850. // enumerable properties.
  5851. var result;
  5852. // In most environments an object's own properties are iterated before
  5853. // its inherited properties. If the last iterated property is an object's
  5854. // own property then there are no inherited enumerable properties.
  5855. baseForIn(value, function(subValue, key) {
  5856. result = key;
  5857. });
  5858. return result === undefined || hasOwnProperty.call(value, result);
  5859. }
  5860. module.exports = isPlainObject;
  5861. },{"lodash._basefor":23,"lodash.isarguments":30,"lodash.keysin":35}],33:[function(require,module,exports){
  5862. /**
  5863. * lodash 3.0.6 (Custom Build) <https://lodash.com/>
  5864. * Build: `lodash modularize exports="npm" -o ./`
  5865. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  5866. * Released under MIT license <https://lodash.com/license>
  5867. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5868. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5869. */
  5870. /** Used as references for various `Number` constants. */
  5871. var MAX_SAFE_INTEGER = 9007199254740991;
  5872. /** `Object#toString` result references. */
  5873. var argsTag = '[object Arguments]',
  5874. arrayTag = '[object Array]',
  5875. boolTag = '[object Boolean]',
  5876. dateTag = '[object Date]',
  5877. errorTag = '[object Error]',
  5878. funcTag = '[object Function]',
  5879. mapTag = '[object Map]',
  5880. numberTag = '[object Number]',
  5881. objectTag = '[object Object]',
  5882. regexpTag = '[object RegExp]',
  5883. setTag = '[object Set]',
  5884. stringTag = '[object String]',
  5885. weakMapTag = '[object WeakMap]';
  5886. var arrayBufferTag = '[object ArrayBuffer]',
  5887. dataViewTag = '[object DataView]',
  5888. float32Tag = '[object Float32Array]',
  5889. float64Tag = '[object Float64Array]',
  5890. int8Tag = '[object Int8Array]',
  5891. int16Tag = '[object Int16Array]',
  5892. int32Tag = '[object Int32Array]',
  5893. uint8Tag = '[object Uint8Array]',
  5894. uint8ClampedTag = '[object Uint8ClampedArray]',
  5895. uint16Tag = '[object Uint16Array]',
  5896. uint32Tag = '[object Uint32Array]';
  5897. /** Used to identify `toStringTag` values of typed arrays. */
  5898. var typedArrayTags = {};
  5899. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  5900. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  5901. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  5902. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  5903. typedArrayTags[uint32Tag] = true;
  5904. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  5905. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  5906. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  5907. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  5908. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  5909. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  5910. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  5911. typedArrayTags[weakMapTag] = false;
  5912. /** Used for built-in method references. */
  5913. var objectProto = Object.prototype;
  5914. /**
  5915. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5916. * of values.
  5917. */
  5918. var objectToString = objectProto.toString;
  5919. /**
  5920. * Checks if `value` is a valid array-like length.
  5921. *
  5922. * **Note:** This function is loosely based on
  5923. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  5924. *
  5925. * @static
  5926. * @memberOf _
  5927. * @since 4.0.0
  5928. * @category Lang
  5929. * @param {*} value The value to check.
  5930. * @returns {boolean} Returns `true` if `value` is a valid length,
  5931. * else `false`.
  5932. * @example
  5933. *
  5934. * _.isLength(3);
  5935. * // => true
  5936. *
  5937. * _.isLength(Number.MIN_VALUE);
  5938. * // => false
  5939. *
  5940. * _.isLength(Infinity);
  5941. * // => false
  5942. *
  5943. * _.isLength('3');
  5944. * // => false
  5945. */
  5946. function isLength(value) {
  5947. return typeof value == 'number' &&
  5948. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5949. }
  5950. /**
  5951. * Checks if `value` is object-like. A value is object-like if it's not `null`
  5952. * and has a `typeof` result of "object".
  5953. *
  5954. * @static
  5955. * @memberOf _
  5956. * @since 4.0.0
  5957. * @category Lang
  5958. * @param {*} value The value to check.
  5959. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5960. * @example
  5961. *
  5962. * _.isObjectLike({});
  5963. * // => true
  5964. *
  5965. * _.isObjectLike([1, 2, 3]);
  5966. * // => true
  5967. *
  5968. * _.isObjectLike(_.noop);
  5969. * // => false
  5970. *
  5971. * _.isObjectLike(null);
  5972. * // => false
  5973. */
  5974. function isObjectLike(value) {
  5975. return !!value && typeof value == 'object';
  5976. }
  5977. /**
  5978. * Checks if `value` is classified as a typed array.
  5979. *
  5980. * @static
  5981. * @memberOf _
  5982. * @since 3.0.0
  5983. * @category Lang
  5984. * @param {*} value The value to check.
  5985. * @returns {boolean} Returns `true` if `value` is correctly classified,
  5986. * else `false`.
  5987. * @example
  5988. *
  5989. * _.isTypedArray(new Uint8Array);
  5990. * // => true
  5991. *
  5992. * _.isTypedArray([]);
  5993. * // => false
  5994. */
  5995. function isTypedArray(value) {
  5996. return isObjectLike(value) &&
  5997. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  5998. }
  5999. module.exports = isTypedArray;
  6000. },{}],34:[function(require,module,exports){
  6001. /**
  6002. * lodash 3.1.2 (Custom Build) <https://lodash.com/>
  6003. * Build: `lodash modern modularize exports="npm" -o ./`
  6004. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6005. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6006. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6007. * Available under MIT license <https://lodash.com/license>
  6008. */
  6009. var getNative = require('lodash._getnative'),
  6010. isArguments = require('lodash.isarguments'),
  6011. isArray = require('lodash.isarray');
  6012. /** Used to detect unsigned integer values. */
  6013. var reIsUint = /^\d+$/;
  6014. /** Used for native method references. */
  6015. var objectProto = Object.prototype;
  6016. /** Used to check objects for own properties. */
  6017. var hasOwnProperty = objectProto.hasOwnProperty;
  6018. /* Native method references for those with the same name as other `lodash` methods. */
  6019. var nativeKeys = getNative(Object, 'keys');
  6020. /**
  6021. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  6022. * of an array-like value.
  6023. */
  6024. var MAX_SAFE_INTEGER = 9007199254740991;
  6025. /**
  6026. * The base implementation of `_.property` without support for deep paths.
  6027. *
  6028. * @private
  6029. * @param {string} key The key of the property to get.
  6030. * @returns {Function} Returns the new function.
  6031. */
  6032. function baseProperty(key) {
  6033. return function(object) {
  6034. return object == null ? undefined : object[key];
  6035. };
  6036. }
  6037. /**
  6038. * Gets the "length" property value of `object`.
  6039. *
  6040. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  6041. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  6042. *
  6043. * @private
  6044. * @param {Object} object The object to query.
  6045. * @returns {*} Returns the "length" value.
  6046. */
  6047. var getLength = baseProperty('length');
  6048. /**
  6049. * Checks if `value` is array-like.
  6050. *
  6051. * @private
  6052. * @param {*} value The value to check.
  6053. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  6054. */
  6055. function isArrayLike(value) {
  6056. return value != null && isLength(getLength(value));
  6057. }
  6058. /**
  6059. * Checks if `value` is a valid array-like index.
  6060. *
  6061. * @private
  6062. * @param {*} value The value to check.
  6063. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6064. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6065. */
  6066. function isIndex(value, length) {
  6067. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  6068. length = length == null ? MAX_SAFE_INTEGER : length;
  6069. return value > -1 && value % 1 == 0 && value < length;
  6070. }
  6071. /**
  6072. * Checks if `value` is a valid array-like length.
  6073. *
  6074. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  6075. *
  6076. * @private
  6077. * @param {*} value The value to check.
  6078. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  6079. */
  6080. function isLength(value) {
  6081. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  6082. }
  6083. /**
  6084. * A fallback implementation of `Object.keys` which creates an array of the
  6085. * own enumerable property names of `object`.
  6086. *
  6087. * @private
  6088. * @param {Object} object The object to query.
  6089. * @returns {Array} Returns the array of property names.
  6090. */
  6091. function shimKeys(object) {
  6092. var props = keysIn(object),
  6093. propsLength = props.length,
  6094. length = propsLength && object.length;
  6095. var allowIndexes = !!length && isLength(length) &&
  6096. (isArray(object) || isArguments(object));
  6097. var index = -1,
  6098. result = [];
  6099. while (++index < propsLength) {
  6100. var key = props[index];
  6101. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  6102. result.push(key);
  6103. }
  6104. }
  6105. return result;
  6106. }
  6107. /**
  6108. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6109. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6110. *
  6111. * @static
  6112. * @memberOf _
  6113. * @category Lang
  6114. * @param {*} value The value to check.
  6115. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6116. * @example
  6117. *
  6118. * _.isObject({});
  6119. * // => true
  6120. *
  6121. * _.isObject([1, 2, 3]);
  6122. * // => true
  6123. *
  6124. * _.isObject(1);
  6125. * // => false
  6126. */
  6127. function isObject(value) {
  6128. // Avoid a V8 JIT bug in Chrome 19-20.
  6129. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6130. var type = typeof value;
  6131. return !!value && (type == 'object' || type == 'function');
  6132. }
  6133. /**
  6134. * Creates an array of the own enumerable property names of `object`.
  6135. *
  6136. * **Note:** Non-object values are coerced to objects. See the
  6137. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  6138. * for more details.
  6139. *
  6140. * @static
  6141. * @memberOf _
  6142. * @category Object
  6143. * @param {Object} object The object to query.
  6144. * @returns {Array} Returns the array of property names.
  6145. * @example
  6146. *
  6147. * function Foo() {
  6148. * this.a = 1;
  6149. * this.b = 2;
  6150. * }
  6151. *
  6152. * Foo.prototype.c = 3;
  6153. *
  6154. * _.keys(new Foo);
  6155. * // => ['a', 'b'] (iteration order is not guaranteed)
  6156. *
  6157. * _.keys('hi');
  6158. * // => ['0', '1']
  6159. */
  6160. var keys = !nativeKeys ? shimKeys : function(object) {
  6161. var Ctor = object == null ? undefined : object.constructor;
  6162. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  6163. (typeof object != 'function' && isArrayLike(object))) {
  6164. return shimKeys(object);
  6165. }
  6166. return isObject(object) ? nativeKeys(object) : [];
  6167. };
  6168. /**
  6169. * Creates an array of the own and inherited enumerable property names of `object`.
  6170. *
  6171. * **Note:** Non-object values are coerced to objects.
  6172. *
  6173. * @static
  6174. * @memberOf _
  6175. * @category Object
  6176. * @param {Object} object The object to query.
  6177. * @returns {Array} Returns the array of property names.
  6178. * @example
  6179. *
  6180. * function Foo() {
  6181. * this.a = 1;
  6182. * this.b = 2;
  6183. * }
  6184. *
  6185. * Foo.prototype.c = 3;
  6186. *
  6187. * _.keysIn(new Foo);
  6188. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  6189. */
  6190. function keysIn(object) {
  6191. if (object == null) {
  6192. return [];
  6193. }
  6194. if (!isObject(object)) {
  6195. object = Object(object);
  6196. }
  6197. var length = object.length;
  6198. length = (length && isLength(length) &&
  6199. (isArray(object) || isArguments(object)) && length) || 0;
  6200. var Ctor = object.constructor,
  6201. index = -1,
  6202. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  6203. result = Array(length),
  6204. skipIndexes = length > 0;
  6205. while (++index < length) {
  6206. result[index] = (index + '');
  6207. }
  6208. for (var key in object) {
  6209. if (!(skipIndexes && isIndex(key, length)) &&
  6210. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  6211. result.push(key);
  6212. }
  6213. }
  6214. return result;
  6215. }
  6216. module.exports = keys;
  6217. },{"lodash._getnative":27,"lodash.isarguments":30,"lodash.isarray":31}],35:[function(require,module,exports){
  6218. /**
  6219. * lodash 3.0.8 (Custom Build) <https://lodash.com/>
  6220. * Build: `lodash modern modularize exports="npm" -o ./`
  6221. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6222. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6223. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6224. * Available under MIT license <https://lodash.com/license>
  6225. */
  6226. var isArguments = require('lodash.isarguments'),
  6227. isArray = require('lodash.isarray');
  6228. /** Used to detect unsigned integer values. */
  6229. var reIsUint = /^\d+$/;
  6230. /** Used for native method references. */
  6231. var objectProto = Object.prototype;
  6232. /** Used to check objects for own properties. */
  6233. var hasOwnProperty = objectProto.hasOwnProperty;
  6234. /**
  6235. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  6236. * of an array-like value.
  6237. */
  6238. var MAX_SAFE_INTEGER = 9007199254740991;
  6239. /**
  6240. * Checks if `value` is a valid array-like index.
  6241. *
  6242. * @private
  6243. * @param {*} value The value to check.
  6244. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6245. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6246. */
  6247. function isIndex(value, length) {
  6248. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  6249. length = length == null ? MAX_SAFE_INTEGER : length;
  6250. return value > -1 && value % 1 == 0 && value < length;
  6251. }
  6252. /**
  6253. * Checks if `value` is a valid array-like length.
  6254. *
  6255. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  6256. *
  6257. * @private
  6258. * @param {*} value The value to check.
  6259. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  6260. */
  6261. function isLength(value) {
  6262. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  6263. }
  6264. /**
  6265. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6266. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6267. *
  6268. * @static
  6269. * @memberOf _
  6270. * @category Lang
  6271. * @param {*} value The value to check.
  6272. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6273. * @example
  6274. *
  6275. * _.isObject({});
  6276. * // => true
  6277. *
  6278. * _.isObject([1, 2, 3]);
  6279. * // => true
  6280. *
  6281. * _.isObject(1);
  6282. * // => false
  6283. */
  6284. function isObject(value) {
  6285. // Avoid a V8 JIT bug in Chrome 19-20.
  6286. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6287. var type = typeof value;
  6288. return !!value && (type == 'object' || type == 'function');
  6289. }
  6290. /**
  6291. * Creates an array of the own and inherited enumerable property names of `object`.
  6292. *
  6293. * **Note:** Non-object values are coerced to objects.
  6294. *
  6295. * @static
  6296. * @memberOf _
  6297. * @category Object
  6298. * @param {Object} object The object to query.
  6299. * @returns {Array} Returns the array of property names.
  6300. * @example
  6301. *
  6302. * function Foo() {
  6303. * this.a = 1;
  6304. * this.b = 2;
  6305. * }
  6306. *
  6307. * Foo.prototype.c = 3;
  6308. *
  6309. * _.keysIn(new Foo);
  6310. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  6311. */
  6312. function keysIn(object) {
  6313. if (object == null) {
  6314. return [];
  6315. }
  6316. if (!isObject(object)) {
  6317. object = Object(object);
  6318. }
  6319. var length = object.length;
  6320. length = (length && isLength(length) &&
  6321. (isArray(object) || isArguments(object)) && length) || 0;
  6322. var Ctor = object.constructor,
  6323. index = -1,
  6324. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  6325. result = Array(length),
  6326. skipIndexes = length > 0;
  6327. while (++index < length) {
  6328. result[index] = (index + '');
  6329. }
  6330. for (var key in object) {
  6331. if (!(skipIndexes && isIndex(key, length)) &&
  6332. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  6333. result.push(key);
  6334. }
  6335. }
  6336. return result;
  6337. }
  6338. module.exports = keysIn;
  6339. },{"lodash.isarguments":30,"lodash.isarray":31}],36:[function(require,module,exports){
  6340. /**
  6341. * lodash 3.3.2 (Custom Build) <https://lodash.com/>
  6342. * Build: `lodash modern modularize exports="npm" -o ./`
  6343. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6344. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6345. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6346. * Available under MIT license <https://lodash.com/license>
  6347. */
  6348. var arrayCopy = require('lodash._arraycopy'),
  6349. arrayEach = require('lodash._arrayeach'),
  6350. createAssigner = require('lodash._createassigner'),
  6351. isArguments = require('lodash.isarguments'),
  6352. isArray = require('lodash.isarray'),
  6353. isPlainObject = require('lodash.isplainobject'),
  6354. isTypedArray = require('lodash.istypedarray'),
  6355. keys = require('lodash.keys'),
  6356. toPlainObject = require('lodash.toplainobject');
  6357. /**
  6358. * Checks if `value` is object-like.
  6359. *
  6360. * @private
  6361. * @param {*} value The value to check.
  6362. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  6363. */
  6364. function isObjectLike(value) {
  6365. return !!value && typeof value == 'object';
  6366. }
  6367. /**
  6368. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  6369. * of an array-like value.
  6370. */
  6371. var MAX_SAFE_INTEGER = 9007199254740991;
  6372. /**
  6373. * The base implementation of `_.merge` without support for argument juggling,
  6374. * multiple sources, and `this` binding `customizer` functions.
  6375. *
  6376. * @private
  6377. * @param {Object} object The destination object.
  6378. * @param {Object} source The source object.
  6379. * @param {Function} [customizer] The function to customize merged values.
  6380. * @param {Array} [stackA=[]] Tracks traversed source objects.
  6381. * @param {Array} [stackB=[]] Associates values with source counterparts.
  6382. * @returns {Object} Returns `object`.
  6383. */
  6384. function baseMerge(object, source, customizer, stackA, stackB) {
  6385. if (!isObject(object)) {
  6386. return object;
  6387. }
  6388. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
  6389. props = isSrcArr ? undefined : keys(source);
  6390. arrayEach(props || source, function(srcValue, key) {
  6391. if (props) {
  6392. key = srcValue;
  6393. srcValue = source[key];
  6394. }
  6395. if (isObjectLike(srcValue)) {
  6396. stackA || (stackA = []);
  6397. stackB || (stackB = []);
  6398. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  6399. }
  6400. else {
  6401. var value = object[key],
  6402. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  6403. isCommon = result === undefined;
  6404. if (isCommon) {
  6405. result = srcValue;
  6406. }
  6407. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  6408. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  6409. object[key] = result;
  6410. }
  6411. }
  6412. });
  6413. return object;
  6414. }
  6415. /**
  6416. * A specialized version of `baseMerge` for arrays and objects which performs
  6417. * deep merges and tracks traversed objects enabling objects with circular
  6418. * references to be merged.
  6419. *
  6420. * @private
  6421. * @param {Object} object The destination object.
  6422. * @param {Object} source The source object.
  6423. * @param {string} key The key of the value to merge.
  6424. * @param {Function} mergeFunc The function to merge values.
  6425. * @param {Function} [customizer] The function to customize merged values.
  6426. * @param {Array} [stackA=[]] Tracks traversed source objects.
  6427. * @param {Array} [stackB=[]] Associates values with source counterparts.
  6428. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6429. */
  6430. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  6431. var length = stackA.length,
  6432. srcValue = source[key];
  6433. while (length--) {
  6434. if (stackA[length] == srcValue) {
  6435. object[key] = stackB[length];
  6436. return;
  6437. }
  6438. }
  6439. var value = object[key],
  6440. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  6441. isCommon = result === undefined;
  6442. if (isCommon) {
  6443. result = srcValue;
  6444. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  6445. result = isArray(value)
  6446. ? value
  6447. : (isArrayLike(value) ? arrayCopy(value) : []);
  6448. }
  6449. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  6450. result = isArguments(value)
  6451. ? toPlainObject(value)
  6452. : (isPlainObject(value) ? value : {});
  6453. }
  6454. else {
  6455. isCommon = false;
  6456. }
  6457. }
  6458. // Add the source value to the stack of traversed objects and associate
  6459. // it with its merged value.
  6460. stackA.push(srcValue);
  6461. stackB.push(result);
  6462. if (isCommon) {
  6463. // Recursively merge objects and arrays (susceptible to call stack limits).
  6464. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  6465. } else if (result === result ? (result !== value) : (value === value)) {
  6466. object[key] = result;
  6467. }
  6468. }
  6469. /**
  6470. * The base implementation of `_.property` without support for deep paths.
  6471. *
  6472. * @private
  6473. * @param {string} key The key of the property to get.
  6474. * @returns {Function} Returns the new function.
  6475. */
  6476. function baseProperty(key) {
  6477. return function(object) {
  6478. return object == null ? undefined : object[key];
  6479. };
  6480. }
  6481. /**
  6482. * Gets the "length" property value of `object`.
  6483. *
  6484. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  6485. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  6486. *
  6487. * @private
  6488. * @param {Object} object The object to query.
  6489. * @returns {*} Returns the "length" value.
  6490. */
  6491. var getLength = baseProperty('length');
  6492. /**
  6493. * Checks if `value` is array-like.
  6494. *
  6495. * @private
  6496. * @param {*} value The value to check.
  6497. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  6498. */
  6499. function isArrayLike(value) {
  6500. return value != null && isLength(getLength(value));
  6501. }
  6502. /**
  6503. * Checks if `value` is a valid array-like length.
  6504. *
  6505. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  6506. *
  6507. * @private
  6508. * @param {*} value The value to check.
  6509. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  6510. */
  6511. function isLength(value) {
  6512. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  6513. }
  6514. /**
  6515. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6516. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6517. *
  6518. * @static
  6519. * @memberOf _
  6520. * @category Lang
  6521. * @param {*} value The value to check.
  6522. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6523. * @example
  6524. *
  6525. * _.isObject({});
  6526. * // => true
  6527. *
  6528. * _.isObject([1, 2, 3]);
  6529. * // => true
  6530. *
  6531. * _.isObject(1);
  6532. * // => false
  6533. */
  6534. function isObject(value) {
  6535. // Avoid a V8 JIT bug in Chrome 19-20.
  6536. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6537. var type = typeof value;
  6538. return !!value && (type == 'object' || type == 'function');
  6539. }
  6540. /**
  6541. * Recursively merges own enumerable properties of the source object(s), that
  6542. * don't resolve to `undefined` into the destination object. Subsequent sources
  6543. * overwrite property assignments of previous sources. If `customizer` is
  6544. * provided it is invoked to produce the merged values of the destination and
  6545. * source properties. If `customizer` returns `undefined` merging is handled
  6546. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  6547. * with five arguments: (objectValue, sourceValue, key, object, source).
  6548. *
  6549. * @static
  6550. * @memberOf _
  6551. * @category Object
  6552. * @param {Object} object The destination object.
  6553. * @param {...Object} [sources] The source objects.
  6554. * @param {Function} [customizer] The function to customize assigned values.
  6555. * @param {*} [thisArg] The `this` binding of `customizer`.
  6556. * @returns {Object} Returns `object`.
  6557. * @example
  6558. *
  6559. * var users = {
  6560. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  6561. * };
  6562. *
  6563. * var ages = {
  6564. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  6565. * };
  6566. *
  6567. * _.merge(users, ages);
  6568. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  6569. *
  6570. * // using a customizer callback
  6571. * var object = {
  6572. * 'fruits': ['apple'],
  6573. * 'vegetables': ['beet']
  6574. * };
  6575. *
  6576. * var other = {
  6577. * 'fruits': ['banana'],
  6578. * 'vegetables': ['carrot']
  6579. * };
  6580. *
  6581. * _.merge(object, other, function(a, b) {
  6582. * if (_.isArray(a)) {
  6583. * return a.concat(b);
  6584. * }
  6585. * });
  6586. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  6587. */
  6588. var merge = createAssigner(baseMerge);
  6589. module.exports = merge;
  6590. },{"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){
  6591. /**
  6592. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  6593. * Build: `lodash modern modularize exports="npm" -o ./`
  6594. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6595. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6596. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6597. * Available under MIT license <https://lodash.com/license>
  6598. */
  6599. var keys = require('lodash.keys');
  6600. /**
  6601. * Converts `value` to an object if it's not one.
  6602. *
  6603. * @private
  6604. * @param {*} value The value to process.
  6605. * @returns {Object} Returns the object.
  6606. */
  6607. function toObject(value) {
  6608. return isObject(value) ? value : Object(value);
  6609. }
  6610. /**
  6611. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6612. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6613. *
  6614. * @static
  6615. * @memberOf _
  6616. * @category Lang
  6617. * @param {*} value The value to check.
  6618. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6619. * @example
  6620. *
  6621. * _.isObject({});
  6622. * // => true
  6623. *
  6624. * _.isObject([1, 2, 3]);
  6625. * // => true
  6626. *
  6627. * _.isObject(1);
  6628. * // => false
  6629. */
  6630. function isObject(value) {
  6631. // Avoid a V8 JIT bug in Chrome 19-20.
  6632. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6633. var type = typeof value;
  6634. return !!value && (type == 'object' || type == 'function');
  6635. }
  6636. /**
  6637. * Creates a two dimensional array of the key-value pairs for `object`,
  6638. * e.g. `[[key1, value1], [key2, value2]]`.
  6639. *
  6640. * @static
  6641. * @memberOf _
  6642. * @category Object
  6643. * @param {Object} object The object to query.
  6644. * @returns {Array} Returns the new array of key-value pairs.
  6645. * @example
  6646. *
  6647. * _.pairs({ 'barney': 36, 'fred': 40 });
  6648. * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
  6649. */
  6650. function pairs(object) {
  6651. object = toObject(object);
  6652. var index = -1,
  6653. props = keys(object),
  6654. length = props.length,
  6655. result = Array(length);
  6656. while (++index < length) {
  6657. var key = props[index];
  6658. result[index] = [key, object[key]];
  6659. }
  6660. return result;
  6661. }
  6662. module.exports = pairs;
  6663. },{"lodash.keys":34}],38:[function(require,module,exports){
  6664. /**
  6665. * lodash 3.6.1 (Custom Build) <https://lodash.com/>
  6666. * Build: `lodash modern modularize exports="npm" -o ./`
  6667. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6668. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6669. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6670. * Available under MIT license <https://lodash.com/license>
  6671. */
  6672. /** Used as the `TypeError` message for "Functions" methods. */
  6673. var FUNC_ERROR_TEXT = 'Expected a function';
  6674. /* Native method references for those with the same name as other `lodash` methods. */
  6675. var nativeMax = Math.max;
  6676. /**
  6677. * Creates a function that invokes `func` with the `this` binding of the
  6678. * created function and arguments from `start` and beyond provided as an array.
  6679. *
  6680. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
  6681. *
  6682. * @static
  6683. * @memberOf _
  6684. * @category Function
  6685. * @param {Function} func The function to apply a rest parameter to.
  6686. * @param {number} [start=func.length-1] The start position of the rest parameter.
  6687. * @returns {Function} Returns the new function.
  6688. * @example
  6689. *
  6690. * var say = _.restParam(function(what, names) {
  6691. * return what + ' ' + _.initial(names).join(', ') +
  6692. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  6693. * });
  6694. *
  6695. * say('hello', 'fred', 'barney', 'pebbles');
  6696. * // => 'hello fred, barney, & pebbles'
  6697. */
  6698. function restParam(func, start) {
  6699. if (typeof func != 'function') {
  6700. throw new TypeError(FUNC_ERROR_TEXT);
  6701. }
  6702. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  6703. return function() {
  6704. var args = arguments,
  6705. index = -1,
  6706. length = nativeMax(args.length - start, 0),
  6707. rest = Array(length);
  6708. while (++index < length) {
  6709. rest[index] = args[start + index];
  6710. }
  6711. switch (start) {
  6712. case 0: return func.call(this, rest);
  6713. case 1: return func.call(this, args[0], rest);
  6714. case 2: return func.call(this, args[0], args[1], rest);
  6715. }
  6716. var otherArgs = Array(start + 1);
  6717. index = -1;
  6718. while (++index < start) {
  6719. otherArgs[index] = args[index];
  6720. }
  6721. otherArgs[start] = rest;
  6722. return func.apply(this, otherArgs);
  6723. };
  6724. }
  6725. module.exports = restParam;
  6726. },{}],39:[function(require,module,exports){
  6727. /**
  6728. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  6729. * Build: `lodash modern modularize exports="npm" -o ./`
  6730. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6731. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  6732. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6733. * Available under MIT license <https://lodash.com/license>
  6734. */
  6735. var baseCopy = require('lodash._basecopy'),
  6736. keysIn = require('lodash.keysin');
  6737. /**
  6738. * Converts `value` to a plain object flattening inherited enumerable
  6739. * properties of `value` to own properties of the plain object.
  6740. *
  6741. * @static
  6742. * @memberOf _
  6743. * @category Lang
  6744. * @param {*} value The value to convert.
  6745. * @returns {Object} Returns the converted plain object.
  6746. * @example
  6747. *
  6748. * function Foo() {
  6749. * this.b = 2;
  6750. * }
  6751. *
  6752. * Foo.prototype.c = 3;
  6753. *
  6754. * _.assign({ 'a': 1 }, new Foo);
  6755. * // => { 'a': 1, 'b': 2 }
  6756. *
  6757. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  6758. * // => { 'a': 1, 'b': 2, 'c': 3 }
  6759. */
  6760. function toPlainObject(value) {
  6761. return baseCopy(value, keysIn(value));
  6762. }
  6763. module.exports = toPlainObject;
  6764. },{"lodash._basecopy":19,"lodash.keysin":35}],40:[function(require,module,exports){
  6765. (function (global){
  6766. /*! https://mths.be/punycode v1.4.1 by @mathias */
  6767. ;(function(root) {
  6768. /** Detect free variables */
  6769. var freeExports = typeof exports == 'object' && exports &&
  6770. !exports.nodeType && exports;
  6771. var freeModule = typeof module == 'object' && module &&
  6772. !module.nodeType && module;
  6773. var freeGlobal = typeof global == 'object' && global;
  6774. if (
  6775. freeGlobal.global === freeGlobal ||
  6776. freeGlobal.window === freeGlobal ||
  6777. freeGlobal.self === freeGlobal
  6778. ) {
  6779. root = freeGlobal;
  6780. }
  6781. /**
  6782. * The `punycode` object.
  6783. * @name punycode
  6784. * @type Object
  6785. */
  6786. var punycode,
  6787. /** Highest positive signed 32-bit float value */
  6788. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  6789. /** Bootstring parameters */
  6790. base = 36,
  6791. tMin = 1,
  6792. tMax = 26,
  6793. skew = 38,
  6794. damp = 700,
  6795. initialBias = 72,
  6796. initialN = 128, // 0x80
  6797. delimiter = '-', // '\x2D'
  6798. /** Regular expressions */
  6799. regexPunycode = /^xn--/,
  6800. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  6801. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  6802. /** Error messages */
  6803. errors = {
  6804. 'overflow': 'Overflow: input needs wider integers to process',
  6805. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  6806. 'invalid-input': 'Invalid input'
  6807. },
  6808. /** Convenience shortcuts */
  6809. baseMinusTMin = base - tMin,
  6810. floor = Math.floor,
  6811. stringFromCharCode = String.fromCharCode,
  6812. /** Temporary variable */
  6813. key;
  6814. /*--------------------------------------------------------------------------*/
  6815. /**
  6816. * A generic error utility function.
  6817. * @private
  6818. * @param {String} type The error type.
  6819. * @returns {Error} Throws a `RangeError` with the applicable error message.
  6820. */
  6821. function error(type) {
  6822. throw new RangeError(errors[type]);
  6823. }
  6824. /**
  6825. * A generic `Array#map` utility function.
  6826. * @private
  6827. * @param {Array} array The array to iterate over.
  6828. * @param {Function} callback The function that gets called for every array
  6829. * item.
  6830. * @returns {Array} A new array of values returned by the callback function.
  6831. */
  6832. function map(array, fn) {
  6833. var length = array.length;
  6834. var result = [];
  6835. while (length--) {
  6836. result[length] = fn(array[length]);
  6837. }
  6838. return result;
  6839. }
  6840. /**
  6841. * A simple `Array#map`-like wrapper to work with domain name strings or email
  6842. * addresses.
  6843. * @private
  6844. * @param {String} domain The domain name or email address.
  6845. * @param {Function} callback The function that gets called for every
  6846. * character.
  6847. * @returns {Array} A new string of characters returned by the callback
  6848. * function.
  6849. */
  6850. function mapDomain(string, fn) {
  6851. var parts = string.split('@');
  6852. var result = '';
  6853. if (parts.length > 1) {
  6854. // In email addresses, only the domain name should be punycoded. Leave
  6855. // the local part (i.e. everything up to `@`) intact.
  6856. result = parts[0] + '@';
  6857. string = parts[1];
  6858. }
  6859. // Avoid `split(regex)` for IE8 compatibility. See #17.
  6860. string = string.replace(regexSeparators, '\x2E');
  6861. var labels = string.split('.');
  6862. var encoded = map(labels, fn).join('.');
  6863. return result + encoded;
  6864. }
  6865. /**
  6866. * Creates an array containing the numeric code points of each Unicode
  6867. * character in the string. While JavaScript uses UCS-2 internally,
  6868. * this function will convert a pair of surrogate halves (each of which
  6869. * UCS-2 exposes as separate characters) into a single code point,
  6870. * matching UTF-16.
  6871. * @see `punycode.ucs2.encode`
  6872. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6873. * @memberOf punycode.ucs2
  6874. * @name decode
  6875. * @param {String} string The Unicode input string (UCS-2).
  6876. * @returns {Array} The new array of code points.
  6877. */
  6878. function ucs2decode(string) {
  6879. var output = [],
  6880. counter = 0,
  6881. length = string.length,
  6882. value,
  6883. extra;
  6884. while (counter < length) {
  6885. value = string.charCodeAt(counter++);
  6886. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  6887. // high surrogate, and there is a next character
  6888. extra = string.charCodeAt(counter++);
  6889. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  6890. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  6891. } else {
  6892. // unmatched surrogate; only append this code unit, in case the next
  6893. // code unit is the high surrogate of a surrogate pair
  6894. output.push(value);
  6895. counter--;
  6896. }
  6897. } else {
  6898. output.push(value);
  6899. }
  6900. }
  6901. return output;
  6902. }
  6903. /**
  6904. * Creates a string based on an array of numeric code points.
  6905. * @see `punycode.ucs2.decode`
  6906. * @memberOf punycode.ucs2
  6907. * @name encode
  6908. * @param {Array} codePoints The array of numeric code points.
  6909. * @returns {String} The new Unicode string (UCS-2).
  6910. */
  6911. function ucs2encode(array) {
  6912. return map(array, function(value) {
  6913. var output = '';
  6914. if (value > 0xFFFF) {
  6915. value -= 0x10000;
  6916. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  6917. value = 0xDC00 | value & 0x3FF;
  6918. }
  6919. output += stringFromCharCode(value);
  6920. return output;
  6921. }).join('');
  6922. }
  6923. /**
  6924. * Converts a basic code point into a digit/integer.
  6925. * @see `digitToBasic()`
  6926. * @private
  6927. * @param {Number} codePoint The basic numeric code point value.
  6928. * @returns {Number} The numeric value of a basic code point (for use in
  6929. * representing integers) in the range `0` to `base - 1`, or `base` if
  6930. * the code point does not represent a value.
  6931. */
  6932. function basicToDigit(codePoint) {
  6933. if (codePoint - 48 < 10) {
  6934. return codePoint - 22;
  6935. }
  6936. if (codePoint - 65 < 26) {
  6937. return codePoint - 65;
  6938. }
  6939. if (codePoint - 97 < 26) {
  6940. return codePoint - 97;
  6941. }
  6942. return base;
  6943. }
  6944. /**
  6945. * Converts a digit/integer into a basic code point.
  6946. * @see `basicToDigit()`
  6947. * @private
  6948. * @param {Number} digit The numeric value of a basic code point.
  6949. * @returns {Number} The basic code point whose value (when used for
  6950. * representing integers) is `digit`, which needs to be in the range
  6951. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  6952. * used; else, the lowercase form is used. The behavior is undefined
  6953. * if `flag` is non-zero and `digit` has no uppercase form.
  6954. */
  6955. function digitToBasic(digit, flag) {
  6956. // 0..25 map to ASCII a..z or A..Z
  6957. // 26..35 map to ASCII 0..9
  6958. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  6959. }
  6960. /**
  6961. * Bias adaptation function as per section 3.4 of RFC 3492.
  6962. * https://tools.ietf.org/html/rfc3492#section-3.4
  6963. * @private
  6964. */
  6965. function adapt(delta, numPoints, firstTime) {
  6966. var k = 0;
  6967. delta = firstTime ? floor(delta / damp) : delta >> 1;
  6968. delta += floor(delta / numPoints);
  6969. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  6970. delta = floor(delta / baseMinusTMin);
  6971. }
  6972. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  6973. }
  6974. /**
  6975. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  6976. * symbols.
  6977. * @memberOf punycode
  6978. * @param {String} input The Punycode string of ASCII-only symbols.
  6979. * @returns {String} The resulting string of Unicode symbols.
  6980. */
  6981. function decode(input) {
  6982. // Don't use UCS-2
  6983. var output = [],
  6984. inputLength = input.length,
  6985. out,
  6986. i = 0,
  6987. n = initialN,
  6988. bias = initialBias,
  6989. basic,
  6990. j,
  6991. index,
  6992. oldi,
  6993. w,
  6994. k,
  6995. digit,
  6996. t,
  6997. /** Cached calculation results */
  6998. baseMinusT;
  6999. // Handle the basic code points: let `basic` be the number of input code
  7000. // points before the last delimiter, or `0` if there is none, then copy
  7001. // the first basic code points to the output.
  7002. basic = input.lastIndexOf(delimiter);
  7003. if (basic < 0) {
  7004. basic = 0;
  7005. }
  7006. for (j = 0; j < basic; ++j) {
  7007. // if it's not a basic code point
  7008. if (input.charCodeAt(j) >= 0x80) {
  7009. error('not-basic');
  7010. }
  7011. output.push(input.charCodeAt(j));
  7012. }
  7013. // Main decoding loop: start just after the last delimiter if any basic code
  7014. // points were copied; start at the beginning otherwise.
  7015. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  7016. // `index` is the index of the next character to be consumed.
  7017. // Decode a generalized variable-length integer into `delta`,
  7018. // which gets added to `i`. The overflow checking is easier
  7019. // if we increase `i` as we go, then subtract off its starting
  7020. // value at the end to obtain `delta`.
  7021. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  7022. if (index >= inputLength) {
  7023. error('invalid-input');
  7024. }
  7025. digit = basicToDigit(input.charCodeAt(index++));
  7026. if (digit >= base || digit > floor((maxInt - i) / w)) {
  7027. error('overflow');
  7028. }
  7029. i += digit * w;
  7030. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  7031. if (digit < t) {
  7032. break;
  7033. }
  7034. baseMinusT = base - t;
  7035. if (w > floor(maxInt / baseMinusT)) {
  7036. error('overflow');
  7037. }
  7038. w *= baseMinusT;
  7039. }
  7040. out = output.length + 1;
  7041. bias = adapt(i - oldi, out, oldi == 0);
  7042. // `i` was supposed to wrap around from `out` to `0`,
  7043. // incrementing `n` each time, so we'll fix that now:
  7044. if (floor(i / out) > maxInt - n) {
  7045. error('overflow');
  7046. }
  7047. n += floor(i / out);
  7048. i %= out;
  7049. // Insert `n` at position `i` of the output
  7050. output.splice(i++, 0, n);
  7051. }
  7052. return ucs2encode(output);
  7053. }
  7054. /**
  7055. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  7056. * Punycode string of ASCII-only symbols.
  7057. * @memberOf punycode
  7058. * @param {String} input The string of Unicode symbols.
  7059. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  7060. */
  7061. function encode(input) {
  7062. var n,
  7063. delta,
  7064. handledCPCount,
  7065. basicLength,
  7066. bias,
  7067. j,
  7068. m,
  7069. q,
  7070. k,
  7071. t,
  7072. currentValue,
  7073. output = [],
  7074. /** `inputLength` will hold the number of code points in `input`. */
  7075. inputLength,
  7076. /** Cached calculation results */
  7077. handledCPCountPlusOne,
  7078. baseMinusT,
  7079. qMinusT;
  7080. // Convert the input in UCS-2 to Unicode
  7081. input = ucs2decode(input);
  7082. // Cache the length
  7083. inputLength = input.length;
  7084. // Initialize the state
  7085. n = initialN;
  7086. delta = 0;
  7087. bias = initialBias;
  7088. // Handle the basic code points
  7089. for (j = 0; j < inputLength; ++j) {
  7090. currentValue = input[j];
  7091. if (currentValue < 0x80) {
  7092. output.push(stringFromCharCode(currentValue));
  7093. }
  7094. }
  7095. handledCPCount = basicLength = output.length;
  7096. // `handledCPCount` is the number of code points that have been handled;
  7097. // `basicLength` is the number of basic code points.
  7098. // Finish the basic string - if it is not empty - with a delimiter
  7099. if (basicLength) {
  7100. output.push(delimiter);
  7101. }
  7102. // Main encoding loop:
  7103. while (handledCPCount < inputLength) {
  7104. // All non-basic code points < n have been handled already. Find the next
  7105. // larger one:
  7106. for (m = maxInt, j = 0; j < inputLength; ++j) {
  7107. currentValue = input[j];
  7108. if (currentValue >= n && currentValue < m) {
  7109. m = currentValue;
  7110. }
  7111. }
  7112. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  7113. // but guard against overflow
  7114. handledCPCountPlusOne = handledCPCount + 1;
  7115. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  7116. error('overflow');
  7117. }
  7118. delta += (m - n) * handledCPCountPlusOne;
  7119. n = m;
  7120. for (j = 0; j < inputLength; ++j) {
  7121. currentValue = input[j];
  7122. if (currentValue < n && ++delta > maxInt) {
  7123. error('overflow');
  7124. }
  7125. if (currentValue == n) {
  7126. // Represent delta as a generalized variable-length integer
  7127. for (q = delta, k = base; /* no condition */; k += base) {
  7128. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  7129. if (q < t) {
  7130. break;
  7131. }
  7132. qMinusT = q - t;
  7133. baseMinusT = base - t;
  7134. output.push(
  7135. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  7136. );
  7137. q = floor(qMinusT / baseMinusT);
  7138. }
  7139. output.push(stringFromCharCode(digitToBasic(q, 0)));
  7140. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  7141. delta = 0;
  7142. ++handledCPCount;
  7143. }
  7144. }
  7145. ++delta;
  7146. ++n;
  7147. }
  7148. return output.join('');
  7149. }
  7150. /**
  7151. * Converts a Punycode string representing a domain name or an email address
  7152. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  7153. * it doesn't matter if you call it on a string that has already been
  7154. * converted to Unicode.
  7155. * @memberOf punycode
  7156. * @param {String} input The Punycoded domain name or email address to
  7157. * convert to Unicode.
  7158. * @returns {String} The Unicode representation of the given Punycode
  7159. * string.
  7160. */
  7161. function toUnicode(input) {
  7162. return mapDomain(input, function(string) {
  7163. return regexPunycode.test(string)
  7164. ? decode(string.slice(4).toLowerCase())
  7165. : string;
  7166. });
  7167. }
  7168. /**
  7169. * Converts a Unicode string representing a domain name or an email address to
  7170. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  7171. * i.e. it doesn't matter if you call it with a domain that's already in
  7172. * ASCII.
  7173. * @memberOf punycode
  7174. * @param {String} input The domain name or email address to convert, as a
  7175. * Unicode string.
  7176. * @returns {String} The Punycode representation of the given domain name or
  7177. * email address.
  7178. */
  7179. function toASCII(input) {
  7180. return mapDomain(input, function(string) {
  7181. return regexNonASCII.test(string)
  7182. ? 'xn--' + encode(string)
  7183. : string;
  7184. });
  7185. }
  7186. /*--------------------------------------------------------------------------*/
  7187. /** Define the public API */
  7188. punycode = {
  7189. /**
  7190. * A string representing the current Punycode.js version number.
  7191. * @memberOf punycode
  7192. * @type String
  7193. */
  7194. 'version': '1.4.1',
  7195. /**
  7196. * An object of methods to convert from JavaScript's internal character
  7197. * representation (UCS-2) to Unicode code points, and back.
  7198. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  7199. * @memberOf punycode
  7200. * @type Object
  7201. */
  7202. 'ucs2': {
  7203. 'decode': ucs2decode,
  7204. 'encode': ucs2encode
  7205. },
  7206. 'decode': decode,
  7207. 'encode': encode,
  7208. 'toASCII': toASCII,
  7209. 'toUnicode': toUnicode
  7210. };
  7211. /** Expose `punycode` */
  7212. // Some AMD build optimizers, like r.js, check for specific condition patterns
  7213. // like the following:
  7214. if (
  7215. typeof define == 'function' &&
  7216. typeof define.amd == 'object' &&
  7217. define.amd
  7218. ) {
  7219. define('punycode', function() {
  7220. return punycode;
  7221. });
  7222. } else if (freeExports && freeModule) {
  7223. if (module.exports == freeExports) {
  7224. // in Node.js, io.js, or RingoJS v0.8.0+
  7225. freeModule.exports = punycode;
  7226. } else {
  7227. // in Narwhal or RingoJS v0.7.0-
  7228. for (key in punycode) {
  7229. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  7230. }
  7231. }
  7232. } else {
  7233. // in Rhino or a web browser
  7234. root.punycode = punycode;
  7235. }
  7236. }(this));
  7237. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  7238. },{}],41:[function(require,module,exports){
  7239. // Copyright Joyent, Inc. and other Node contributors.
  7240. //
  7241. // Permission is hereby granted, free of charge, to any person obtaining a
  7242. // copy of this software and associated documentation files (the
  7243. // "Software"), to deal in the Software without restriction, including
  7244. // without limitation the rights to use, copy, modify, merge, publish,
  7245. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7246. // persons to whom the Software is furnished to do so, subject to the
  7247. // following conditions:
  7248. //
  7249. // The above copyright notice and this permission notice shall be included
  7250. // in all copies or substantial portions of the Software.
  7251. //
  7252. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7253. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7254. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7255. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7256. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7257. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7258. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7259. 'use strict';
  7260. // If obj.hasOwnProperty has been overridden, then calling
  7261. // obj.hasOwnProperty(prop) will break.
  7262. // See: https://github.com/joyent/node/issues/1707
  7263. function hasOwnProperty(obj, prop) {
  7264. return Object.prototype.hasOwnProperty.call(obj, prop);
  7265. }
  7266. module.exports = function(qs, sep, eq, options) {
  7267. sep = sep || '&';
  7268. eq = eq || '=';
  7269. var obj = {};
  7270. if (typeof qs !== 'string' || qs.length === 0) {
  7271. return obj;
  7272. }
  7273. var regexp = /\+/g;
  7274. qs = qs.split(sep);
  7275. var maxKeys = 1000;
  7276. if (options && typeof options.maxKeys === 'number') {
  7277. maxKeys = options.maxKeys;
  7278. }
  7279. var len = qs.length;
  7280. // maxKeys <= 0 means that we should not limit keys count
  7281. if (maxKeys > 0 && len > maxKeys) {
  7282. len = maxKeys;
  7283. }
  7284. for (var i = 0; i < len; ++i) {
  7285. var x = qs[i].replace(regexp, '%20'),
  7286. idx = x.indexOf(eq),
  7287. kstr, vstr, k, v;
  7288. if (idx >= 0) {
  7289. kstr = x.substr(0, idx);
  7290. vstr = x.substr(idx + 1);
  7291. } else {
  7292. kstr = x;
  7293. vstr = '';
  7294. }
  7295. k = decodeURIComponent(kstr);
  7296. v = decodeURIComponent(vstr);
  7297. if (!hasOwnProperty(obj, k)) {
  7298. obj[k] = v;
  7299. } else if (isArray(obj[k])) {
  7300. obj[k].push(v);
  7301. } else {
  7302. obj[k] = [obj[k], v];
  7303. }
  7304. }
  7305. return obj;
  7306. };
  7307. var isArray = Array.isArray || function (xs) {
  7308. return Object.prototype.toString.call(xs) === '[object Array]';
  7309. };
  7310. },{}],42:[function(require,module,exports){
  7311. // Copyright Joyent, Inc. and other Node contributors.
  7312. //
  7313. // Permission is hereby granted, free of charge, to any person obtaining a
  7314. // copy of this software and associated documentation files (the
  7315. // "Software"), to deal in the Software without restriction, including
  7316. // without limitation the rights to use, copy, modify, merge, publish,
  7317. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7318. // persons to whom the Software is furnished to do so, subject to the
  7319. // following conditions:
  7320. //
  7321. // The above copyright notice and this permission notice shall be included
  7322. // in all copies or substantial portions of the Software.
  7323. //
  7324. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7325. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7326. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7327. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7328. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7329. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7330. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7331. 'use strict';
  7332. var stringifyPrimitive = function(v) {
  7333. switch (typeof v) {
  7334. case 'string':
  7335. return v;
  7336. case 'boolean':
  7337. return v ? 'true' : 'false';
  7338. case 'number':
  7339. return isFinite(v) ? v : '';
  7340. default:
  7341. return '';
  7342. }
  7343. };
  7344. module.exports = function(obj, sep, eq, name) {
  7345. sep = sep || '&';
  7346. eq = eq || '=';
  7347. if (obj === null) {
  7348. obj = undefined;
  7349. }
  7350. if (typeof obj === 'object') {
  7351. return map(objectKeys(obj), function(k) {
  7352. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  7353. if (isArray(obj[k])) {
  7354. return map(obj[k], function(v) {
  7355. return ks + encodeURIComponent(stringifyPrimitive(v));
  7356. }).join(sep);
  7357. } else {
  7358. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  7359. }
  7360. }).join(sep);
  7361. }
  7362. if (!name) return '';
  7363. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  7364. encodeURIComponent(stringifyPrimitive(obj));
  7365. };
  7366. var isArray = Array.isArray || function (xs) {
  7367. return Object.prototype.toString.call(xs) === '[object Array]';
  7368. };
  7369. function map (xs, f) {
  7370. if (xs.map) return xs.map(f);
  7371. var res = [];
  7372. for (var i = 0; i < xs.length; i++) {
  7373. res.push(f(xs[i], i));
  7374. }
  7375. return res;
  7376. }
  7377. var objectKeys = Object.keys || function (obj) {
  7378. var res = [];
  7379. for (var key in obj) {
  7380. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  7381. }
  7382. return res;
  7383. };
  7384. },{}],43:[function(require,module,exports){
  7385. 'use strict';
  7386. exports.decode = exports.parse = require('./decode');
  7387. exports.encode = exports.stringify = require('./encode');
  7388. },{"./decode":41,"./encode":42}],44:[function(require,module,exports){
  7389. /**
  7390. sprintf() for JavaScript 0.7-beta1
  7391. http://www.diveintojavascript.com/projects/javascript-sprintf
  7392. Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
  7393. All rights reserved.
  7394. Redistribution and use in source and binary forms, with or without
  7395. modification, are permitted provided that the following conditions are met:
  7396. * Redistributions of source code must retain the above copyright
  7397. notice, this list of conditions and the following disclaimer.
  7398. * Redistributions in binary form must reproduce the above copyright
  7399. notice, this list of conditions and the following disclaimer in the
  7400. documentation and/or other materials provided with the distribution.
  7401. * Neither the name of sprintf() for JavaScript nor the
  7402. names of its contributors may be used to endorse or promote products
  7403. derived from this software without specific prior written permission.
  7404. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  7405. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7406. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  7407. DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
  7408. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7409. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7410. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7411. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7412. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7413. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7414. Changelog:
  7415. 2010.11.07 - 0.7-beta1-node
  7416. - converted it to a node.js compatible module
  7417. 2010.09.06 - 0.7-beta1
  7418. - features: vsprintf, support for named placeholders
  7419. - enhancements: format cache, reduced global namespace pollution
  7420. 2010.05.22 - 0.6:
  7421. - reverted to 0.4 and fixed the bug regarding the sign of the number 0
  7422. Note:
  7423. Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/)
  7424. who warned me about a bug in 0.5, I discovered that the last update was
  7425. a regress. I appologize for that.
  7426. 2010.05.09 - 0.5:
  7427. - bug fix: 0 is now preceeded with a + sign
  7428. - bug fix: the sign was not at the right position on padded results (Kamal Abdali)
  7429. - switched from GPL to BSD license
  7430. 2007.10.21 - 0.4:
  7431. - unit test and patch (David Baird)
  7432. 2007.09.17 - 0.3:
  7433. - bug fix: no longer throws exception on empty paramenters (Hans Pufal)
  7434. 2007.09.11 - 0.2:
  7435. - feature: added argument swapping
  7436. 2007.04.03 - 0.1:
  7437. - initial release
  7438. **/
  7439. var sprintf = (function() {
  7440. function get_type(variable) {
  7441. return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
  7442. }
  7443. function str_repeat(input, multiplier) {
  7444. for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
  7445. return output.join('');
  7446. }
  7447. var str_format = function() {
  7448. if (!str_format.cache.hasOwnProperty(arguments[0])) {
  7449. str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
  7450. }
  7451. return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
  7452. };
  7453. // convert object to simple one line string without indentation or
  7454. // newlines. Note that this implementation does not print array
  7455. // values to their actual place for sparse arrays.
  7456. //
  7457. // For example sparse array like this
  7458. // l = []
  7459. // l[4] = 1
  7460. // Would be printed as "[1]" instead of "[, , , , 1]"
  7461. //
  7462. // If argument 'seen' is not null and array the function will check for
  7463. // circular object references from argument.
  7464. str_format.object_stringify = function(obj, depth, maxdepth, seen) {
  7465. var str = '';
  7466. if (obj != null) {
  7467. switch( typeof(obj) ) {
  7468. case 'function':
  7469. return '[Function' + (obj.name ? ': '+obj.name : '') + ']';
  7470. break;
  7471. case 'object':
  7472. if ( obj instanceof Error) { return '[' + obj.toString() + ']' };
  7473. if (depth >= maxdepth) return '[Object]'
  7474. if (seen) {
  7475. // add object to seen list
  7476. seen = seen.slice(0)
  7477. seen.push(obj);
  7478. }
  7479. if (obj.length != null) { //array
  7480. str += '[';
  7481. var arr = []
  7482. for (var i in obj) {
  7483. if (seen && seen.indexOf(obj[i]) >= 0) arr.push('[Circular]');
  7484. else arr.push(str_format.object_stringify(obj[i], depth+1, maxdepth, seen));
  7485. }
  7486. str += arr.join(', ') + ']';
  7487. } else if ('getMonth' in obj) { // date
  7488. return 'Date(' + obj + ')';
  7489. } else { // object
  7490. str += '{';
  7491. var arr = []
  7492. for (var k in obj) {
  7493. if(obj.hasOwnProperty(k)) {
  7494. if (seen && seen.indexOf(obj[k]) >= 0) arr.push(k + ': [Circular]');
  7495. else arr.push(k +': ' +str_format.object_stringify(obj[k], depth+1, maxdepth, seen));
  7496. }
  7497. }
  7498. str += arr.join(', ') + '}';
  7499. }
  7500. return str;
  7501. break;
  7502. case 'string':
  7503. return '"' + obj + '"';
  7504. break
  7505. }
  7506. }
  7507. return '' + obj;
  7508. }
  7509. str_format.format = function(parse_tree, argv) {
  7510. var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
  7511. for (i = 0; i < tree_length; i++) {
  7512. node_type = get_type(parse_tree[i]);
  7513. if (node_type === 'string') {
  7514. output.push(parse_tree[i]);
  7515. }
  7516. else if (node_type === 'array') {
  7517. match = parse_tree[i]; // convenience purposes only
  7518. if (match[2]) { // keyword argument
  7519. arg = argv[cursor];
  7520. for (k = 0; k < match[2].length; k++) {
  7521. if (!arg.hasOwnProperty(match[2][k])) {
  7522. throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
  7523. }
  7524. arg = arg[match[2][k]];
  7525. }
  7526. }
  7527. else if (match[1]) { // positional argument (explicit)
  7528. arg = argv[match[1]];
  7529. }
  7530. else { // positional argument (implicit)
  7531. arg = argv[cursor++];
  7532. }
  7533. if (/[^sO]/.test(match[8]) && (get_type(arg) != 'number')) {
  7534. throw new Error(sprintf('[sprintf] expecting number but found %s "' + arg + '"', get_type(arg)));
  7535. }
  7536. switch (match[8]) {
  7537. case 'b': arg = arg.toString(2); break;
  7538. case 'c': arg = String.fromCharCode(arg); break;
  7539. case 'd': arg = parseInt(arg, 10); break;
  7540. case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
  7541. case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
  7542. case 'O': arg = str_format.object_stringify(arg, 0, parseInt(match[7]) || 5); break;
  7543. case 'o': arg = arg.toString(8); break;
  7544. case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
  7545. case 'u': arg = Math.abs(arg); break;
  7546. case 'x': arg = arg.toString(16); break;
  7547. case 'X': arg = arg.toString(16).toUpperCase(); break;
  7548. }
  7549. arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
  7550. pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
  7551. pad_length = match[6] - String(arg).length;
  7552. pad = match[6] ? str_repeat(pad_character, pad_length) : '';
  7553. output.push(match[5] ? arg + pad : pad + arg);
  7554. }
  7555. }
  7556. return output.join('');
  7557. };
  7558. str_format.cache = {};
  7559. str_format.parse = function(fmt) {
  7560. var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
  7561. while (_fmt) {
  7562. if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
  7563. parse_tree.push(match[0]);
  7564. }
  7565. else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
  7566. parse_tree.push('%');
  7567. }
  7568. else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(_fmt)) !== null) {
  7569. if (match[2]) {
  7570. arg_names |= 1;
  7571. var field_list = [], replacement_field = match[2], field_match = [];
  7572. if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  7573. field_list.push(field_match[1]);
  7574. while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
  7575. if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  7576. field_list.push(field_match[1]);
  7577. }
  7578. else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
  7579. field_list.push(field_match[1]);
  7580. }
  7581. else {
  7582. throw new Error('[sprintf] ' + replacement_field);
  7583. }
  7584. }
  7585. }
  7586. else {
  7587. throw new Error('[sprintf] ' + replacement_field);
  7588. }
  7589. match[2] = field_list;
  7590. }
  7591. else {
  7592. arg_names |= 2;
  7593. }
  7594. if (arg_names === 3) {
  7595. throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported');
  7596. }
  7597. parse_tree.push(match);
  7598. }
  7599. else {
  7600. throw new Error('[sprintf] ' + _fmt);
  7601. }
  7602. _fmt = _fmt.substring(match[0].length);
  7603. }
  7604. return parse_tree;
  7605. };
  7606. return str_format;
  7607. })();
  7608. var vsprintf = function(fmt, argv) {
  7609. var argvClone = argv.slice();
  7610. argvClone.unshift(fmt);
  7611. return sprintf.apply(null, argvClone);
  7612. };
  7613. module.exports = sprintf;
  7614. sprintf.sprintf = sprintf;
  7615. sprintf.vsprintf = vsprintf;
  7616. },{}],45:[function(require,module,exports){
  7617. "use strict";
  7618. var allRules = require('./rules.json');
  7619. var cleanHostValue = require('./lib/clean-host.js');
  7620. var escapeRegExp = require('./lib/escape-regexp.js');
  7621. var getRulesForTld = require('./lib/tld-rules.js');
  7622. var getDomain = require('./lib/domain.js');
  7623. var getSubdomain = require('./lib/subdomain.js');
  7624. var isValid = require('./lib/is-valid.js');
  7625. var getPublicSuffix = require('./lib/public-suffix.js');
  7626. var tldExists = require('./lib/tld-exists.js');
  7627. /**
  7628. * Creates a new instance of tldjs
  7629. * @param {Object.<rules,validHosts>} options [description]
  7630. * @return {tldjs|Object} [description]
  7631. */
  7632. function factory(options) {
  7633. var rules = options.rules || allRules || {};
  7634. var validHosts = options.validHosts || [];
  7635. return {
  7636. cleanHostValue: cleanHostValue,
  7637. escapeRegExp: escapeRegExp,
  7638. getRulesForTld: getRulesForTld,
  7639. getDomain: function (host) {
  7640. return getDomain(rules, validHosts, host);
  7641. },
  7642. getSubdomain: function (host) {
  7643. return getSubdomain(rules, validHosts, host);
  7644. },
  7645. isValid: function (host) {
  7646. return isValid(validHosts, host);
  7647. },
  7648. getPublicSuffix: function (host) {
  7649. return getPublicSuffix(rules, host);
  7650. },
  7651. tldExists: function (tld) {
  7652. return tldExists(rules, tld);
  7653. },
  7654. fromUserSettings: factory
  7655. };
  7656. }
  7657. module.exports = factory({ validHosts: [], rules: allRules });
  7658. },{"./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){
  7659. var some = require('./polyfills/array-some.js');
  7660. /**
  7661. * Returns the best rule for a given host based on candidates
  7662. *
  7663. * @static
  7664. * @param host {String} Hostname to check rules against
  7665. * @param rules {Array} List of rules used to work on
  7666. * @return {Object} Candidate object, with a normal and exception state
  7667. */
  7668. module.exports = function getCandidateRule (host, rules, options) {
  7669. var rule = {'normal': null, 'exception': null};
  7670. options = options || { lazy: false };
  7671. some(rules, function (r) {
  7672. var pattern;
  7673. // sld matching or validHost? escape the loop immediately (except if it's an exception)
  7674. if ('.' + host === r.getNormalXld()) {
  7675. if (options.lazy || r.exception || r.isHost) {
  7676. rule.normal = r;
  7677. }
  7678. return true;
  7679. }
  7680. // otherwise check as a complete host
  7681. // if it's an exception, we want to loop a bit more to a normal rule
  7682. pattern = '.+' + r.getNormalPattern() + '$';
  7683. if ((new RegExp(pattern)).test(host)) {
  7684. rule[r.exception ? 'exception' : 'normal'] = r;
  7685. return !r.exception;
  7686. }
  7687. return false;
  7688. });
  7689. // favouring the exception if encountered
  7690. // previously we were copy-altering a rule, creating inconsistent results based on rule order order
  7691. // @see https://github.com/oncletom/tld.js/pull/35
  7692. if (rule.normal && rule.exception) {
  7693. return rule.exception;
  7694. }
  7695. return rule.normal;
  7696. };
  7697. },{"./polyfills/array-some.js":53}],47:[function(require,module,exports){
  7698. var URL = require('url');
  7699. /**
  7700. * Utility to cleanup the base host value. Also removes url fragments.
  7701. *
  7702. * Works for:
  7703. * - hostname
  7704. * - //hostname
  7705. * - scheme://hostname
  7706. * - scheme+scheme://hostname
  7707. *
  7708. * @param {string} value
  7709. * @return {String}
  7710. */
  7711. // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
  7712. var hasPrefixRE = /^(([a-z][a-z0-9+.-]*)?:)?\/\//;
  7713. var invalidHostnameChars = /[^A-Za-z0-9.-]/;
  7714. //@see https://github.com/oncletom/tld.js/issues/95
  7715. function rtrim(value) {
  7716. return String(value).replace(/[.]+$/g, '');
  7717. }
  7718. module.exports = function cleanHostValue(value){
  7719. value = String(value).trim().toLowerCase();
  7720. var parts = URL.parse(hasPrefixRE.test(value) ? value : '//' + value, null, true);
  7721. if (parts.hostname && !invalidHostnameChars.test(parts.hostname)) { return rtrim(parts.hostname); }
  7722. if (!invalidHostnameChars.test(value)) { return rtrim(value); }
  7723. return '';
  7724. };
  7725. },{"url":60}],48:[function(require,module,exports){
  7726. var Rule = require('./rule.js');
  7727. var isValid = require('./is-valid.js');
  7728. var cleanHostValue = require('./clean-host.js');
  7729. var extractTldFromHost = require('./from-host.js');
  7730. var getCandidateRule = require('./canditate-rule.js');
  7731. var getRulesForTld = require('./tld-rules.js');
  7732. /**
  7733. * Detects the domain based on rules and upon and a host string
  7734. *
  7735. * @api
  7736. * @param {string} host
  7737. * @return {String}
  7738. */
  7739. module.exports = function getDomain (allRules, validHosts, host) {
  7740. var domain = null, hostTld, rules, rule;
  7741. var _validHosts = validHosts || [];
  7742. if (isValid(_validHosts, host) === false) {
  7743. return null;
  7744. }
  7745. host = cleanHostValue(host);
  7746. hostTld = extractTldFromHost(host);
  7747. rules = getRulesForTld(allRules, hostTld, new Rule({"firstLevel": hostTld, "isHost": _validHosts.indexOf(hostTld) !== -1}));
  7748. rule = getCandidateRule(host, rules);
  7749. if (rule === null) {
  7750. return null;
  7751. }
  7752. host.replace(new RegExp(rule.getPattern()), function (m, d) {
  7753. domain = d;
  7754. });
  7755. return domain;
  7756. };
  7757. },{"./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){
  7758. /**
  7759. * Escapes RegExp specific chars.
  7760. *
  7761. * @since 1.3.1
  7762. * @see https://github.com/oncletom/tld.js/pull/33
  7763. * @param {String|Mixed} s
  7764. * @returns {string} Escaped string for a safe use in a `new RegExp` expression
  7765. */
  7766. module.exports = function escapeRegExp(s) {
  7767. return String(s).replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
  7768. };
  7769. },{}],50:[function(require,module,exports){
  7770. /**
  7771. * Utility to extract the TLD from a host string
  7772. *
  7773. * @param {string} host
  7774. * @return {String}
  7775. */
  7776. module.exports = function extractTldFromHost(host){
  7777. return host.split('.').pop();
  7778. };
  7779. },{}],51:[function(require,module,exports){
  7780. /**
  7781. * Checking if a host string is valid
  7782. * It's usually a preliminary check before trying to use getDomain or anything else
  7783. *
  7784. * Beware: it does not check if the TLD exists.
  7785. *
  7786. * @api
  7787. * @param host {String}
  7788. * @return {Boolean}
  7789. */
  7790. module.exports = function isValid (validHosts, host) {
  7791. return typeof host === 'string' && (validHosts.indexOf(host) !== -1 || (host.indexOf('.') !== -1 && host[0] !== '.'));
  7792. };
  7793. },{}],52:[function(require,module,exports){
  7794. // Array.map polyfill for IE8
  7795. module.exports = function _mapFunction(thisVal, fun /*, thisArg */) {
  7796. "use strict";
  7797. if (thisVal === void 0 || thisVal === null) {
  7798. throw new TypeError();
  7799. }
  7800. var t = Object(thisVal);
  7801. var len = t.length >>> 0;
  7802. if (typeof fun !== "function") {
  7803. throw new TypeError();
  7804. }
  7805. var res = new Array(len);
  7806. var thisArg = arguments.length >= 3 ? arguments[2] : void 0;
  7807. for (var i = 0; i < len; i++)
  7808. {
  7809. // NOTE: Absolute correctness would demand Object.defineProperty
  7810. // be used. But this method is fairly new, and failure is
  7811. // possible only if Object.prototype or Array.prototype
  7812. // has a property |i| (very unlikely), so use a lesscorrect
  7813. // but more portable alternative.
  7814. if (i in t) {
  7815. res[i] = fun.call(thisArg, t[i], i, t);
  7816. }
  7817. }
  7818. return res;
  7819. };
  7820. },{}],53:[function(require,module,exports){
  7821. // Array.some() polyfill for IE8
  7822. module.exports = function _someFunction(value, fun /*, thisArg */) {
  7823. 'use strict';
  7824. if (value === void 0 || value === null) {
  7825. throw new TypeError();
  7826. }
  7827. var t = Object(value);
  7828. var len = t.length >>> 0;
  7829. if (typeof fun !== 'function') {
  7830. throw new TypeError();
  7831. }
  7832. var thisArg = arguments.length >= 3 ? arguments[2] : void 0;
  7833. for (var i = 0; i < len; i++)
  7834. {
  7835. if (i in t && fun.call(thisArg, t[i], i, t)) {
  7836. return true;
  7837. }
  7838. }
  7839. return false;
  7840. };
  7841. },{}],54:[function(require,module,exports){
  7842. var cleanHostValue = require('./clean-host.js');
  7843. var extractTldFromHost = require('./from-host.js');
  7844. var getCandidateRule = require('./canditate-rule.js');
  7845. var getRulesForTld = require('./tld-rules.js');
  7846. /**
  7847. * Returns the public suffix (including exact matches)
  7848. *
  7849. * @api
  7850. * @since 1.5
  7851. * @param {string} host
  7852. * @return {String}
  7853. */
  7854. module.exports = function getPublicSuffix(allRules, host) {
  7855. var hostTld, rules, rule;
  7856. if (host in allRules){
  7857. return host;
  7858. }
  7859. host = cleanHostValue(host);
  7860. hostTld = extractTldFromHost(host);
  7861. rules = getRulesForTld(allRules, hostTld);
  7862. rule = getCandidateRule(host, rules, { lazy: true });
  7863. if (rule === null) {
  7864. return null;
  7865. }
  7866. return rule.getNormalXld().slice(1);
  7867. };
  7868. },{"./canditate-rule.js":46,"./clean-host.js":47,"./from-host.js":50,"./tld-rules.js":58}],55:[function(require,module,exports){
  7869. "use strict";
  7870. function Rule (data){
  7871. data = data || {};
  7872. this.exception = data.exception || false;
  7873. this.firstLevel = data.firstLevel || '';
  7874. this.secondLevel = data.secondLevel || null;
  7875. this.isHost = data.isHost || false;
  7876. this.source = data.source || '';
  7877. this.wildcard = data.wildcard || false;
  7878. }
  7879. /**
  7880. * Returns the TLD or SLD (Second Level Domain) pattern for a rule
  7881. *
  7882. * @return {String}
  7883. */
  7884. Rule.prototype.getNormalXld = function getNormalXld(){
  7885. return (this.secondLevel ? '.' + this.secondLevel : '') + '.' + this.firstLevel;
  7886. };
  7887. /**
  7888. * Returns a pattern suitable for normal rule
  7889. * Mostly for internal use
  7890. *
  7891. * @return {String}
  7892. */
  7893. Rule.prototype.getNormalPattern = function getNormalPattern(){
  7894. return (this.secondLevel ? '\\.' + this.secondLevel : '') + '\\.' + this.firstLevel;
  7895. };
  7896. /**
  7897. * Returns a pattern suitable for wildcard rule
  7898. * Mostly for internal use
  7899. *
  7900. * @return {String}
  7901. */
  7902. Rule.prototype.getWildcardPattern = function getWildcardPattern(){
  7903. return '\\.[^\\.]+' + this.getNormalXld().replace(/\./g, '\\.');
  7904. };
  7905. /**
  7906. * Returns a pattern suitable for exception rule
  7907. * Mostly for internal use
  7908. *
  7909. * @return {String}
  7910. */
  7911. Rule.prototype.getExceptionPattern = function getExceptionPattern(){
  7912. return (this.secondLevel || '') + '\\.' + this.firstLevel;
  7913. };
  7914. /**
  7915. * Returns the best pattern possible for a rule
  7916. * You just have to test a value against it to check or extract a hostname
  7917. *
  7918. * @api
  7919. * @param {string|undefined} before
  7920. * @param {string|undefined} after
  7921. * @return {String} A pattern to challenge some string against
  7922. */
  7923. Rule.prototype.getPattern = function getPattern(before, after){
  7924. var pattern = '';
  7925. before = (before === undefined) ? '(': before+'';
  7926. after = (after === undefined) ? ')$': after+'';
  7927. if (this.exception === true){
  7928. pattern = this.getExceptionPattern();
  7929. }
  7930. else if (this.isHost === true) {
  7931. pattern = this.firstLevel;
  7932. }
  7933. else{
  7934. pattern = '[^\\.]+' + (this.wildcard ? this.getWildcardPattern() : this.getNormalPattern());
  7935. }
  7936. return before + pattern + after;
  7937. };
  7938. module.exports = Rule;
  7939. },{}],56:[function(require,module,exports){
  7940. var cleanHostValue = require('./clean-host.js');
  7941. var getDomain = require('./domain.js');
  7942. var escapeRegExp = require('./escape-regexp.js');
  7943. /**
  7944. * Returns the subdomain of a host string
  7945. *
  7946. * @api
  7947. * @param {string} host
  7948. * @return {string|null} a subdomain string if any, blank string if subdomain is empty, otherwise null
  7949. */
  7950. module.exports = function getSubdomain(allRules, validHosts, host){
  7951. var domain, r, subdomain;
  7952. host = cleanHostValue(host);
  7953. domain = getDomain(allRules, validHosts, host);
  7954. // No domain found? Just abort, abort!
  7955. if (domain === null){
  7956. return null;
  7957. }
  7958. r = '\\.?'+ escapeRegExp(domain)+'$';
  7959. subdomain = host.replace(new RegExp(r, 'i'), '');
  7960. return subdomain;
  7961. };
  7962. },{"./clean-host.js":47,"./domain.js":48,"./escape-regexp.js":49}],57:[function(require,module,exports){
  7963. var cleanHostValue = require('./clean-host.js');
  7964. var extractTldFromHost = require('./from-host.js');
  7965. /**
  7966. * Checks if the TLD exists for a given host
  7967. *
  7968. * @api
  7969. * @param {string} host
  7970. * @return {boolean}
  7971. */
  7972. module.exports = function tldExists(rules, host){
  7973. var hostTld;
  7974. host = cleanHostValue(host);
  7975. // Easy case, it's a TLD
  7976. if (rules[host]){
  7977. return true;
  7978. }
  7979. // Popping only the TLD of the hostname
  7980. hostTld = extractTldFromHost(host);
  7981. return rules[hostTld] !== undefined;
  7982. };
  7983. },{"./clean-host.js":47,"./from-host.js":50}],58:[function(require,module,exports){
  7984. "use strict";
  7985. var Rule = require('./rule.js');
  7986. var map = require('./polyfills/array-map.js');
  7987. /**
  7988. * Retrieve a subset of rules for a Top-Level-Domain string
  7989. *
  7990. * @param tld {String} Top-Level-Domain string
  7991. * @return {Array} Rules subset
  7992. */
  7993. module.exports = function getRulesForTld (allRules, tld, default_rule) {
  7994. var exception = '!';
  7995. var wildcard = '*';
  7996. var append_tld_rule = true;
  7997. var rules = allRules[tld];
  7998. // Already parsed
  7999. // Array.isArray polyfill for IE8
  8000. if (Object.prototype.toString.call(rules) === '[object Array]') {
  8001. return rules;
  8002. }
  8003. // Nothing found, apply some default value
  8004. if (rules === void 0) {
  8005. return default_rule ? [ default_rule ] : [];
  8006. }
  8007. // Parsing needed
  8008. rules = map(rules.split('|'), function transformAsRule (sld) {
  8009. var first_bit = sld[0];
  8010. if (first_bit === exception || first_bit === wildcard) {
  8011. sld = sld.slice(1);
  8012. if (!sld) {
  8013. append_tld_rule = false;
  8014. }
  8015. }
  8016. return new Rule({
  8017. "firstLevel": tld,
  8018. "secondLevel": sld,
  8019. "exception": first_bit === exception,
  8020. "wildcard": first_bit === wildcard
  8021. });
  8022. });
  8023. // Always prepend to make it the latest rule to be applied
  8024. if (append_tld_rule) {
  8025. rules.unshift(new Rule({
  8026. "firstLevel": tld
  8027. }));
  8028. }
  8029. allRules[tld] = rules.reverse();
  8030. return rules;
  8031. };
  8032. },{"./polyfills/array-map.js":52,"./rule.js":55}],59:[function(require,module,exports){
  8033. 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":""}
  8034. },{}],60:[function(require,module,exports){
  8035. // Copyright Joyent, Inc. and other Node contributors.
  8036. //
  8037. // Permission is hereby granted, free of charge, to any person obtaining a
  8038. // copy of this software and associated documentation files (the
  8039. // "Software"), to deal in the Software without restriction, including
  8040. // without limitation the rights to use, copy, modify, merge, publish,
  8041. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8042. // persons to whom the Software is furnished to do so, subject to the
  8043. // following conditions:
  8044. //
  8045. // The above copyright notice and this permission notice shall be included
  8046. // in all copies or substantial portions of the Software.
  8047. //
  8048. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8049. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8050. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8051. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8052. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8053. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8054. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8055. var punycode = require('punycode');
  8056. exports.parse = urlParse;
  8057. exports.resolve = urlResolve;
  8058. exports.resolveObject = urlResolveObject;
  8059. exports.format = urlFormat;
  8060. exports.Url = Url;
  8061. function Url() {
  8062. this.protocol = null;
  8063. this.slashes = null;
  8064. this.auth = null;
  8065. this.host = null;
  8066. this.port = null;
  8067. this.hostname = null;
  8068. this.hash = null;
  8069. this.search = null;
  8070. this.query = null;
  8071. this.pathname = null;
  8072. this.path = null;
  8073. this.href = null;
  8074. }
  8075. // Reference: RFC 3986, RFC 1808, RFC 2396
  8076. // define these here so at least they only have to be
  8077. // compiled once on the first module load.
  8078. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  8079. portPattern = /:[0-9]*$/,
  8080. // RFC 2396: characters reserved for delimiting URLs.
  8081. // We actually just auto-escape these.
  8082. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  8083. // RFC 2396: characters not allowed for various reasons.
  8084. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  8085. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  8086. autoEscape = ['\''].concat(unwise),
  8087. // Characters that are never ever allowed in a hostname.
  8088. // Note that any invalid chars are also handled, but these
  8089. // are the ones that are *expected* to be seen, so we fast-path
  8090. // them.
  8091. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  8092. hostEndingChars = ['/', '?', '#'],
  8093. hostnameMaxLen = 255,
  8094. hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/,
  8095. hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/,
  8096. // protocols that can allow "unsafe" and "unwise" chars.
  8097. unsafeProtocol = {
  8098. 'javascript': true,
  8099. 'javascript:': true
  8100. },
  8101. // protocols that never have a hostname.
  8102. hostlessProtocol = {
  8103. 'javascript': true,
  8104. 'javascript:': true
  8105. },
  8106. // protocols that always contain a // bit.
  8107. slashedProtocol = {
  8108. 'http': true,
  8109. 'https': true,
  8110. 'ftp': true,
  8111. 'gopher': true,
  8112. 'file': true,
  8113. 'http:': true,
  8114. 'https:': true,
  8115. 'ftp:': true,
  8116. 'gopher:': true,
  8117. 'file:': true
  8118. },
  8119. querystring = require('querystring');
  8120. function urlParse(url, parseQueryString, slashesDenoteHost) {
  8121. if (url && isObject(url) && url instanceof Url) return url;
  8122. var u = new Url;
  8123. u.parse(url, parseQueryString, slashesDenoteHost);
  8124. return u;
  8125. }
  8126. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  8127. if (!isString(url)) {
  8128. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  8129. }
  8130. var rest = url;
  8131. // trim before proceeding.
  8132. // This is to support parse stuff like " http://foo.com \n"
  8133. rest = rest.trim();
  8134. var proto = protocolPattern.exec(rest);
  8135. if (proto) {
  8136. proto = proto[0];
  8137. var lowerProto = proto.toLowerCase();
  8138. this.protocol = lowerProto;
  8139. rest = rest.substr(proto.length);
  8140. }
  8141. // figure out if it's got a host
  8142. // user@server is *always* interpreted as a hostname, and url
  8143. // resolution will treat //foo/bar as host=foo,path=bar because that's
  8144. // how the browser resolves relative URLs.
  8145. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  8146. var slashes = rest.substr(0, 2) === '//';
  8147. if (slashes && !(proto && hostlessProtocol[proto])) {
  8148. rest = rest.substr(2);
  8149. this.slashes = true;
  8150. }
  8151. }
  8152. if (!hostlessProtocol[proto] &&
  8153. (slashes || (proto && !slashedProtocol[proto]))) {
  8154. // there's a hostname.
  8155. // the first instance of /, ?, ;, or # ends the host.
  8156. //
  8157. // If there is an @ in the hostname, then non-host chars *are* allowed
  8158. // to the left of the last @ sign, unless some host-ending character
  8159. // comes *before* the @-sign.
  8160. // URLs are obnoxious.
  8161. //
  8162. // ex:
  8163. // http://a@b@c/ => user:a@b host:c
  8164. // http://a@b?@c => user:a host:c path:/?@c
  8165. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  8166. // Review our test case against browsers more comprehensively.
  8167. // find the first instance of any hostEndingChars
  8168. var hostEnd = -1;
  8169. for (var i = 0; i < hostEndingChars.length; i++) {
  8170. var hec = rest.indexOf(hostEndingChars[i]);
  8171. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  8172. hostEnd = hec;
  8173. }
  8174. // at this point, either we have an explicit point where the
  8175. // auth portion cannot go past, or the last @ char is the decider.
  8176. var auth, atSign;
  8177. if (hostEnd === -1) {
  8178. // atSign can be anywhere.
  8179. atSign = rest.lastIndexOf('@');
  8180. } else {
  8181. // atSign must be in auth portion.
  8182. // http://a@b/c@d => host:b auth:a path:/c@d
  8183. atSign = rest.lastIndexOf('@', hostEnd);
  8184. }
  8185. // Now we have a portion which is definitely the auth.
  8186. // Pull that off.
  8187. if (atSign !== -1) {
  8188. auth = rest.slice(0, atSign);
  8189. rest = rest.slice(atSign + 1);
  8190. this.auth = decodeURIComponent(auth);
  8191. }
  8192. // the host is the remaining to the left of the first non-host char
  8193. hostEnd = -1;
  8194. for (var i = 0; i < nonHostChars.length; i++) {
  8195. var hec = rest.indexOf(nonHostChars[i]);
  8196. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  8197. hostEnd = hec;
  8198. }
  8199. // if we still have not hit it, then the entire thing is a host.
  8200. if (hostEnd === -1)
  8201. hostEnd = rest.length;
  8202. this.host = rest.slice(0, hostEnd);
  8203. rest = rest.slice(hostEnd);
  8204. // pull out port.
  8205. this.parseHost();
  8206. // we've indicated that there is a hostname,
  8207. // so even if it's empty, it has to be present.
  8208. this.hostname = this.hostname || '';
  8209. // if hostname begins with [ and ends with ]
  8210. // assume that it's an IPv6 address.
  8211. var ipv6Hostname = this.hostname[0] === '[' &&
  8212. this.hostname[this.hostname.length - 1] === ']';
  8213. // validate a little.
  8214. if (!ipv6Hostname) {
  8215. var hostparts = this.hostname.split(/\./);
  8216. for (var i = 0, l = hostparts.length; i < l; i++) {
  8217. var part = hostparts[i];
  8218. if (!part) continue;
  8219. if (!part.match(hostnamePartPattern)) {
  8220. var newpart = '';
  8221. for (var j = 0, k = part.length; j < k; j++) {
  8222. if (part.charCodeAt(j) > 127) {
  8223. // we replace non-ASCII char with a temporary placeholder
  8224. // we need this to make sure size of hostname is not
  8225. // broken by replacing non-ASCII by nothing
  8226. newpart += 'x';
  8227. } else {
  8228. newpart += part[j];
  8229. }
  8230. }
  8231. // we test again with ASCII char only
  8232. if (!newpart.match(hostnamePartPattern)) {
  8233. var validParts = hostparts.slice(0, i);
  8234. var notHost = hostparts.slice(i + 1);
  8235. var bit = part.match(hostnamePartStart);
  8236. if (bit) {
  8237. validParts.push(bit[1]);
  8238. notHost.unshift(bit[2]);
  8239. }
  8240. if (notHost.length) {
  8241. rest = '/' + notHost.join('.') + rest;
  8242. }
  8243. this.hostname = validParts.join('.');
  8244. break;
  8245. }
  8246. }
  8247. }
  8248. }
  8249. if (this.hostname.length > hostnameMaxLen) {
  8250. this.hostname = '';
  8251. } else {
  8252. // hostnames are always lower case.
  8253. this.hostname = this.hostname.toLowerCase();
  8254. }
  8255. if (!ipv6Hostname) {
  8256. // IDNA Support: Returns a puny coded representation of "domain".
  8257. // It only converts the part of the domain name that
  8258. // has non ASCII characters. I.e. it dosent matter if
  8259. // you call it with a domain that already is in ASCII.
  8260. var domainArray = this.hostname.split('.');
  8261. var newOut = [];
  8262. for (var i = 0; i < domainArray.length; ++i) {
  8263. var s = domainArray[i];
  8264. newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
  8265. 'xn--' + punycode.encode(s) : s);
  8266. }
  8267. this.hostname = newOut.join('.');
  8268. }
  8269. var p = this.port ? ':' + this.port : '';
  8270. var h = this.hostname || '';
  8271. this.host = h + p;
  8272. this.href += this.host;
  8273. // strip [ and ] from the hostname
  8274. // the host field still retains them, though
  8275. if (ipv6Hostname) {
  8276. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  8277. if (rest[0] !== '/') {
  8278. rest = '/' + rest;
  8279. }
  8280. }
  8281. }
  8282. // now rest is set to the post-host stuff.
  8283. // chop off any delim chars.
  8284. if (!unsafeProtocol[lowerProto]) {
  8285. // First, make 100% sure that any "autoEscape" chars get
  8286. // escaped, even if encodeURIComponent doesn't think they
  8287. // need to be.
  8288. for (var i = 0, l = autoEscape.length; i < l; i++) {
  8289. var ae = autoEscape[i];
  8290. var esc = encodeURIComponent(ae);
  8291. if (esc === ae) {
  8292. esc = escape(ae);
  8293. }
  8294. rest = rest.split(ae).join(esc);
  8295. }
  8296. }
  8297. // chop off from the tail first.
  8298. var hash = rest.indexOf('#');
  8299. if (hash !== -1) {
  8300. // got a fragment string.
  8301. this.hash = rest.substr(hash);
  8302. rest = rest.slice(0, hash);
  8303. }
  8304. var qm = rest.indexOf('?');
  8305. if (qm !== -1) {
  8306. this.search = rest.substr(qm);
  8307. this.query = rest.substr(qm + 1);
  8308. if (parseQueryString) {
  8309. this.query = querystring.parse(this.query);
  8310. }
  8311. rest = rest.slice(0, qm);
  8312. } else if (parseQueryString) {
  8313. // no query string, but parseQueryString still requested
  8314. this.search = '';
  8315. this.query = {};
  8316. }
  8317. if (rest) this.pathname = rest;
  8318. if (slashedProtocol[lowerProto] &&
  8319. this.hostname && !this.pathname) {
  8320. this.pathname = '/';
  8321. }
  8322. //to support http.request
  8323. if (this.pathname || this.search) {
  8324. var p = this.pathname || '';
  8325. var s = this.search || '';
  8326. this.path = p + s;
  8327. }
  8328. // finally, reconstruct the href based on what has been validated.
  8329. this.href = this.format();
  8330. return this;
  8331. };
  8332. // format a parsed object into a url string
  8333. function urlFormat(obj) {
  8334. // ensure it's an object, and not a string url.
  8335. // If it's an obj, this is a no-op.
  8336. // this way, you can call url_format() on strings
  8337. // to clean up potentially wonky urls.
  8338. if (isString(obj)) obj = urlParse(obj);
  8339. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  8340. return obj.format();
  8341. }
  8342. Url.prototype.format = function() {
  8343. var auth = this.auth || '';
  8344. if (auth) {
  8345. auth = encodeURIComponent(auth);
  8346. auth = auth.replace(/%3A/i, ':');
  8347. auth += '@';
  8348. }
  8349. var protocol = this.protocol || '',
  8350. pathname = this.pathname || '',
  8351. hash = this.hash || '',
  8352. host = false,
  8353. query = '';
  8354. if (this.host) {
  8355. host = auth + this.host;
  8356. } else if (this.hostname) {
  8357. host = auth + (this.hostname.indexOf(':') === -1 ?
  8358. this.hostname :
  8359. '[' + this.hostname + ']');
  8360. if (this.port) {
  8361. host += ':' + this.port;
  8362. }
  8363. }
  8364. if (this.query &&
  8365. isObject(this.query) &&
  8366. Object.keys(this.query).length) {
  8367. query = querystring.stringify(this.query);
  8368. }
  8369. var search = this.search || (query && ('?' + query)) || '';
  8370. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  8371. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  8372. // unless they had them to begin with.
  8373. if (this.slashes ||
  8374. (!protocol || slashedProtocol[protocol]) && host !== false) {
  8375. host = '//' + (host || '');
  8376. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  8377. } else if (!host) {
  8378. host = '';
  8379. }
  8380. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  8381. if (search && search.charAt(0) !== '?') search = '?' + search;
  8382. pathname = pathname.replace(/[?#]/g, function(match) {
  8383. return encodeURIComponent(match);
  8384. });
  8385. search = search.replace('#', '%23');
  8386. return protocol + host + pathname + search + hash;
  8387. };
  8388. function urlResolve(source, relative) {
  8389. return urlParse(source, false, true).resolve(relative);
  8390. }
  8391. Url.prototype.resolve = function(relative) {
  8392. return this.resolveObject(urlParse(relative, false, true)).format();
  8393. };
  8394. function urlResolveObject(source, relative) {
  8395. if (!source) return relative;
  8396. return urlParse(source, false, true).resolveObject(relative);
  8397. }
  8398. Url.prototype.resolveObject = function(relative) {
  8399. if (isString(relative)) {
  8400. var rel = new Url();
  8401. rel.parse(relative, false, true);
  8402. relative = rel;
  8403. }
  8404. var result = new Url();
  8405. Object.keys(this).forEach(function(k) {
  8406. result[k] = this[k];
  8407. }, this);
  8408. // hash is always overridden, no matter what.
  8409. // even href="" will remove it.
  8410. result.hash = relative.hash;
  8411. // if the relative url is empty, then there's nothing left to do here.
  8412. if (relative.href === '') {
  8413. result.href = result.format();
  8414. return result;
  8415. }
  8416. // hrefs like //foo/bar always cut to the protocol.
  8417. if (relative.slashes && !relative.protocol) {
  8418. // take everything except the protocol from relative
  8419. Object.keys(relative).forEach(function(k) {
  8420. if (k !== 'protocol')
  8421. result[k] = relative[k];
  8422. });
  8423. //urlParse appends trailing / to urls like http://www.example.com
  8424. if (slashedProtocol[result.protocol] &&
  8425. result.hostname && !result.pathname) {
  8426. result.path = result.pathname = '/';
  8427. }
  8428. result.href = result.format();
  8429. return result;
  8430. }
  8431. if (relative.protocol && relative.protocol !== result.protocol) {
  8432. // if it's a known url protocol, then changing
  8433. // the protocol does weird things
  8434. // first, if it's not file:, then we MUST have a host,
  8435. // and if there was a path
  8436. // to begin with, then we MUST have a path.
  8437. // if it is file:, then the host is dropped,
  8438. // because that's known to be hostless.
  8439. // anything else is assumed to be absolute.
  8440. if (!slashedProtocol[relative.protocol]) {
  8441. Object.keys(relative).forEach(function(k) {
  8442. result[k] = relative[k];
  8443. });
  8444. result.href = result.format();
  8445. return result;
  8446. }
  8447. result.protocol = relative.protocol;
  8448. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  8449. var relPath = (relative.pathname || '').split('/');
  8450. while (relPath.length && !(relative.host = relPath.shift()));
  8451. if (!relative.host) relative.host = '';
  8452. if (!relative.hostname) relative.hostname = '';
  8453. if (relPath[0] !== '') relPath.unshift('');
  8454. if (relPath.length < 2) relPath.unshift('');
  8455. result.pathname = relPath.join('/');
  8456. } else {
  8457. result.pathname = relative.pathname;
  8458. }
  8459. result.search = relative.search;
  8460. result.query = relative.query;
  8461. result.host = relative.host || '';
  8462. result.auth = relative.auth;
  8463. result.hostname = relative.hostname || relative.host;
  8464. result.port = relative.port;
  8465. // to support http.request
  8466. if (result.pathname || result.search) {
  8467. var p = result.pathname || '';
  8468. var s = result.search || '';
  8469. result.path = p + s;
  8470. }
  8471. result.slashes = result.slashes || relative.slashes;
  8472. result.href = result.format();
  8473. return result;
  8474. }
  8475. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  8476. isRelAbs = (
  8477. relative.host ||
  8478. relative.pathname && relative.pathname.charAt(0) === '/'
  8479. ),
  8480. mustEndAbs = (isRelAbs || isSourceAbs ||
  8481. (result.host && relative.pathname)),
  8482. removeAllDots = mustEndAbs,
  8483. srcPath = result.pathname && result.pathname.split('/') || [],
  8484. relPath = relative.pathname && relative.pathname.split('/') || [],
  8485. psychotic = result.protocol && !slashedProtocol[result.protocol];
  8486. // if the url is a non-slashed url, then relative
  8487. // links like ../.. should be able
  8488. // to crawl up to the hostname, as well. This is strange.
  8489. // result.protocol has already been set by now.
  8490. // Later on, put the first path part into the host field.
  8491. if (psychotic) {
  8492. result.hostname = '';
  8493. result.port = null;
  8494. if (result.host) {
  8495. if (srcPath[0] === '') srcPath[0] = result.host;
  8496. else srcPath.unshift(result.host);
  8497. }
  8498. result.host = '';
  8499. if (relative.protocol) {
  8500. relative.hostname = null;
  8501. relative.port = null;
  8502. if (relative.host) {
  8503. if (relPath[0] === '') relPath[0] = relative.host;
  8504. else relPath.unshift(relative.host);
  8505. }
  8506. relative.host = null;
  8507. }
  8508. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  8509. }
  8510. if (isRelAbs) {
  8511. // it's absolute.
  8512. result.host = (relative.host || relative.host === '') ?
  8513. relative.host : result.host;
  8514. result.hostname = (relative.hostname || relative.hostname === '') ?
  8515. relative.hostname : result.hostname;
  8516. result.search = relative.search;
  8517. result.query = relative.query;
  8518. srcPath = relPath;
  8519. // fall through to the dot-handling below.
  8520. } else if (relPath.length) {
  8521. // it's relative
  8522. // throw away the existing file, and take the new path instead.
  8523. if (!srcPath) srcPath = [];
  8524. srcPath.pop();
  8525. srcPath = srcPath.concat(relPath);
  8526. result.search = relative.search;
  8527. result.query = relative.query;
  8528. } else if (!isNullOrUndefined(relative.search)) {
  8529. // just pull out the search.
  8530. // like href='?foo'.
  8531. // Put this after the other two cases because it simplifies the booleans
  8532. if (psychotic) {
  8533. result.hostname = result.host = srcPath.shift();
  8534. //occationaly the auth can get stuck only in host
  8535. //this especialy happens in cases like
  8536. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  8537. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  8538. result.host.split('@') : false;
  8539. if (authInHost) {
  8540. result.auth = authInHost.shift();
  8541. result.host = result.hostname = authInHost.shift();
  8542. }
  8543. }
  8544. result.search = relative.search;
  8545. result.query = relative.query;
  8546. //to support http.request
  8547. if (!isNull(result.pathname) || !isNull(result.search)) {
  8548. result.path = (result.pathname ? result.pathname : '') +
  8549. (result.search ? result.search : '');
  8550. }
  8551. result.href = result.format();
  8552. return result;
  8553. }
  8554. if (!srcPath.length) {
  8555. // no path at all. easy.
  8556. // we've already handled the other stuff above.
  8557. result.pathname = null;
  8558. //to support http.request
  8559. if (result.search) {
  8560. result.path = '/' + result.search;
  8561. } else {
  8562. result.path = null;
  8563. }
  8564. result.href = result.format();
  8565. return result;
  8566. }
  8567. // if a url ENDs in . or .., then it must get a trailing slash.
  8568. // however, if it ends in anything else non-slashy,
  8569. // then it must NOT get a trailing slash.
  8570. var last = srcPath.slice(-1)[0];
  8571. var hasTrailingSlash = (
  8572. (result.host || relative.host) && (last === '.' || last === '..') ||
  8573. last === '');
  8574. // strip single dots, resolve double dots to parent dir
  8575. // if the path tries to go above the root, `up` ends up > 0
  8576. var up = 0;
  8577. for (var i = srcPath.length; i >= 0; i--) {
  8578. last = srcPath[i];
  8579. if (last == '.') {
  8580. srcPath.splice(i, 1);
  8581. } else if (last === '..') {
  8582. srcPath.splice(i, 1);
  8583. up++;
  8584. } else if (up) {
  8585. srcPath.splice(i, 1);
  8586. up--;
  8587. }
  8588. }
  8589. // if the path is allowed to go above the root, restore leading ..s
  8590. if (!mustEndAbs && !removeAllDots) {
  8591. for (; up--; up) {
  8592. srcPath.unshift('..');
  8593. }
  8594. }
  8595. if (mustEndAbs && srcPath[0] !== '' &&
  8596. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  8597. srcPath.unshift('');
  8598. }
  8599. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  8600. srcPath.push('');
  8601. }
  8602. var isAbsolute = srcPath[0] === '' ||
  8603. (srcPath[0] && srcPath[0].charAt(0) === '/');
  8604. // put the host back
  8605. if (psychotic) {
  8606. result.hostname = result.host = isAbsolute ? '' :
  8607. srcPath.length ? srcPath.shift() : '';
  8608. //occationaly the auth can get stuck only in host
  8609. //this especialy happens in cases like
  8610. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  8611. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  8612. result.host.split('@') : false;
  8613. if (authInHost) {
  8614. result.auth = authInHost.shift();
  8615. result.host = result.hostname = authInHost.shift();
  8616. }
  8617. }
  8618. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  8619. if (mustEndAbs && !isAbsolute) {
  8620. srcPath.unshift('');
  8621. }
  8622. if (!srcPath.length) {
  8623. result.pathname = null;
  8624. result.path = null;
  8625. } else {
  8626. result.pathname = srcPath.join('/');
  8627. }
  8628. //to support request.http
  8629. if (!isNull(result.pathname) || !isNull(result.search)) {
  8630. result.path = (result.pathname ? result.pathname : '') +
  8631. (result.search ? result.search : '');
  8632. }
  8633. result.auth = relative.auth || result.auth;
  8634. result.slashes = result.slashes || relative.slashes;
  8635. result.href = result.format();
  8636. return result;
  8637. };
  8638. Url.prototype.parseHost = function() {
  8639. var host = this.host;
  8640. var port = portPattern.exec(host);
  8641. if (port) {
  8642. port = port[0];
  8643. if (port !== ':') {
  8644. this.port = port.substr(1);
  8645. }
  8646. host = host.substr(0, host.length - port.length);
  8647. }
  8648. if (host) this.hostname = host;
  8649. };
  8650. function isString(arg) {
  8651. return typeof arg === "string";
  8652. }
  8653. function isObject(arg) {
  8654. return typeof arg === 'object' && arg !== null;
  8655. }
  8656. function isNull(arg) {
  8657. return arg === null;
  8658. }
  8659. function isNullOrUndefined(arg) {
  8660. return arg == null;
  8661. }
  8662. },{"punycode":40,"querystring":43}],61:[function(require,module,exports){
  8663. var AttachedCache, IP, U2, Url, escapeSlash, exports, ref, shExp2RegExp,
  8664. hasProp = {}.hasOwnProperty;
  8665. U2 = require('uglify-js');
  8666. IP = require('ip-address');
  8667. Url = require('url');
  8668. ref = require('./shexp_utils'), shExp2RegExp = ref.shExp2RegExp, escapeSlash = ref.escapeSlash;
  8669. AttachedCache = require('./utils').AttachedCache;
  8670. module.exports = exports = {
  8671. requestFromUrl: function(url) {
  8672. var req;
  8673. if (typeof url === 'string') {
  8674. url = Url.parse(url);
  8675. }
  8676. return req = {
  8677. url: Url.format(url),
  8678. host: url.hostname,
  8679. scheme: url.protocol.replace(':', '')
  8680. };
  8681. },
  8682. urlWildcard2HostWildcard: function(pattern) {
  8683. var result;
  8684. result = pattern.match(/^\*:\/\/((?:\w|[?*._\-])+)\/\*$/);
  8685. return result != null ? result[1] : void 0;
  8686. },
  8687. tag: function(condition) {
  8688. return exports._condCache.tag(condition);
  8689. },
  8690. analyze: function(condition) {
  8691. return exports._condCache.get(condition, function() {
  8692. return {
  8693. analyzed: exports._handler(condition.conditionType).analyze.call(exports, condition)
  8694. };
  8695. });
  8696. },
  8697. match: function(condition, request) {
  8698. var cache;
  8699. cache = exports.analyze(condition);
  8700. return exports._handler(condition.conditionType).match.call(exports, condition, request, cache);
  8701. },
  8702. compile: function(condition) {
  8703. var cache, handler;
  8704. cache = exports.analyze(condition);
  8705. if (cache.compiled) {
  8706. return cache.compiled;
  8707. }
  8708. handler = exports._handler(condition.conditionType);
  8709. return cache.compiled = handler.compile.call(exports, condition, cache);
  8710. },
  8711. str: function(condition, arg) {
  8712. var abbr, endCode, handler, part, result, str, typeStr;
  8713. abbr = (arg != null ? arg : {
  8714. abbr: -1
  8715. }).abbr;
  8716. handler = exports._handler(condition.conditionType);
  8717. if (handler.abbrs[0].length === 0) {
  8718. endCode = condition.pattern.charCodeAt(condition.pattern.length - 1);
  8719. if (endCode !== exports.colonCharCode && condition.pattern.indexOf(' ') < 0) {
  8720. return condition.pattern;
  8721. }
  8722. }
  8723. str = handler.str;
  8724. typeStr = typeof abbr === 'number' ? handler.abbrs[(handler.abbrs.length + abbr) % handler.abbrs.length] : condition.conditionType;
  8725. result = typeStr + ':';
  8726. part = str ? str.call(exports, condition) : condition.pattern;
  8727. if (part) {
  8728. result += ' ' + part;
  8729. }
  8730. return result;
  8731. },
  8732. colonCharCode: ':'.charCodeAt(0),
  8733. fromStr: function(str) {
  8734. var condition, conditionType, fromStr, i;
  8735. str = str.trim();
  8736. i = str.indexOf(' ');
  8737. if (i < 0) {
  8738. i = str.length;
  8739. }
  8740. if (str.charCodeAt(i - 1) === exports.colonCharCode) {
  8741. conditionType = str.substr(0, i - 1);
  8742. str = str.substr(i + 1).trim();
  8743. } else {
  8744. conditionType = '';
  8745. }
  8746. conditionType = exports.typeFromAbbr(conditionType);
  8747. if (!conditionType) {
  8748. return null;
  8749. }
  8750. condition = {
  8751. conditionType: conditionType
  8752. };
  8753. fromStr = exports._handler(condition.conditionType).fromStr;
  8754. if (fromStr) {
  8755. return fromStr.call(exports, str, condition);
  8756. } else {
  8757. condition.pattern = str;
  8758. return condition;
  8759. }
  8760. },
  8761. _abbrs: null,
  8762. typeFromAbbr: function(abbr) {
  8763. var ab, abbrs, j, len, ref1, type;
  8764. if (!exports._abbrs) {
  8765. exports._abbrs = {};
  8766. ref1 = exports._conditionTypes;
  8767. for (type in ref1) {
  8768. if (!hasProp.call(ref1, type)) continue;
  8769. abbrs = ref1[type].abbrs;
  8770. exports._abbrs[type.toUpperCase()] = type;
  8771. for (j = 0, len = abbrs.length; j < len; j++) {
  8772. ab = abbrs[j];
  8773. exports._abbrs[ab.toUpperCase()] = type;
  8774. }
  8775. }
  8776. }
  8777. return exports._abbrs[abbr.toUpperCase()];
  8778. },
  8779. comment: function(comment, node) {
  8780. var base;
  8781. if (!comment) {
  8782. return node;
  8783. }
  8784. if (node.start == null) {
  8785. node.start = {};
  8786. }
  8787. Object.defineProperty(node.start, '_comments_dumped', {
  8788. get: function() {
  8789. return false;
  8790. },
  8791. set: function() {
  8792. return false;
  8793. }
  8794. });
  8795. if ((base = node.start).comments_before == null) {
  8796. base.comments_before = [];
  8797. }
  8798. node.start.comments_before.push({
  8799. type: 'comment2',
  8800. value: comment
  8801. });
  8802. return node;
  8803. },
  8804. safeRegex: function(expr) {
  8805. var _;
  8806. try {
  8807. return new RegExp(expr);
  8808. } catch (error) {
  8809. _ = error;
  8810. return /(?!)/;
  8811. }
  8812. },
  8813. regTest: function(expr, regexp) {
  8814. if (typeof regexp === 'string') {
  8815. regexp = regexSafe(escapeSlash(regexp));
  8816. }
  8817. if (typeof expr === 'string') {
  8818. expr = new U2.AST_SymbolRef({
  8819. name: expr
  8820. });
  8821. }
  8822. return new U2.AST_Call({
  8823. args: [expr],
  8824. expression: new U2.AST_Dot({
  8825. property: 'test',
  8826. expression: new U2.AST_RegExp({
  8827. value: regexp
  8828. })
  8829. })
  8830. });
  8831. },
  8832. isInt: function(num) {
  8833. return typeof num === 'number' && !isNaN(num) && parseFloat(num) === parseInt(num, 10);
  8834. },
  8835. between: function(val, min, max, comment) {
  8836. var pos, str, tmpl;
  8837. if (min === max) {
  8838. if (typeof min === 'number') {
  8839. min = new U2.AST_Number({
  8840. value: min
  8841. });
  8842. }
  8843. return exports.comment(comment, new U2.AST_Binary({
  8844. left: val,
  8845. operator: '===',
  8846. right: min
  8847. }));
  8848. }
  8849. if (min > max) {
  8850. return exports.comment(comment, new U2.AST_False);
  8851. }
  8852. if (exports.isInt(min) && exports.isInt(max) && max - min < 32) {
  8853. comment || (comment = min + " <= value && value <= " + max);
  8854. tmpl = "0123456789abcdefghijklmnopqrstuvwxyz";
  8855. str = max < tmpl.length ? tmpl.substr(min, max - min + 1) : tmpl.substr(0, max - min + 1);
  8856. pos = min === 0 ? val : new U2.AST_Binary({
  8857. left: val,
  8858. operator: '-',
  8859. right: new U2.AST_Number({
  8860. value: min
  8861. })
  8862. });
  8863. return exports.comment(comment, new U2.AST_Binary({
  8864. left: new U2.AST_Call({
  8865. expression: new U2.AST_Dot({
  8866. expression: new U2.AST_String({
  8867. value: str
  8868. }),
  8869. property: 'charCodeAt'
  8870. }),
  8871. args: [pos]
  8872. }),
  8873. operator: '>',
  8874. right: new U2.AST_Number({
  8875. value: 0
  8876. })
  8877. }));
  8878. }
  8879. if (typeof min === 'number') {
  8880. min = new U2.AST_Number({
  8881. value: min
  8882. });
  8883. }
  8884. if (typeof max === 'number') {
  8885. max = new U2.AST_Number({
  8886. value: max
  8887. });
  8888. }
  8889. return exports.comment(comment, new U2.AST_Call({
  8890. args: [val, min, max],
  8891. expression: new U2.AST_Function({
  8892. argnames: [
  8893. new U2.AST_SymbolFunarg({
  8894. name: 'value'
  8895. }), new U2.AST_SymbolFunarg({
  8896. name: 'min'
  8897. }), new U2.AST_SymbolFunarg({
  8898. name: 'max'
  8899. })
  8900. ],
  8901. body: [
  8902. new U2.AST_Return({
  8903. value: new U2.AST_Binary({
  8904. left: new U2.AST_Binary({
  8905. left: new U2.AST_SymbolRef({
  8906. name: 'min'
  8907. }),
  8908. operator: '<=',
  8909. right: new U2.AST_SymbolRef({
  8910. name: 'value'
  8911. })
  8912. }),
  8913. operator: '&&',
  8914. right: new U2.AST_Binary({
  8915. left: new U2.AST_SymbolRef({
  8916. name: 'value'
  8917. }),
  8918. operator: '<=',
  8919. right: new U2.AST_SymbolRef({
  8920. name: 'max'
  8921. })
  8922. })
  8923. })
  8924. })
  8925. ]
  8926. })
  8927. }));
  8928. },
  8929. parseIp: function(ip) {
  8930. var addr;
  8931. if (ip.charCodeAt(0) === '['.charCodeAt(0)) {
  8932. ip = ip.substr(1, ip.length - 2);
  8933. }
  8934. addr = new IP.v4.Address(ip);
  8935. if (!addr.isValid()) {
  8936. addr = new IP.v6.Address(ip);
  8937. if (!addr.isValid()) {
  8938. return null;
  8939. }
  8940. }
  8941. return addr;
  8942. },
  8943. normalizeIp: function(addr) {
  8944. var ref1;
  8945. return ((ref1 = addr.correctForm) != null ? ref1 : addr.canonicalForm).call(addr);
  8946. },
  8947. ipv6Max: new IP.v6.Address('::/0').endAddress().canonicalForm(),
  8948. localHosts: ["127.0.0.1", "[::1]", "localhost"],
  8949. getWeekdayList: function(condition) {
  8950. var i, j, k, results, results1;
  8951. if (condition.days) {
  8952. results = [];
  8953. for (i = j = 0; j < 7; i = ++j) {
  8954. results.push(condition.days.charCodeAt(i) > 64);
  8955. }
  8956. return results;
  8957. } else {
  8958. results1 = [];
  8959. for (i = k = 0; k < 7; i = ++k) {
  8960. results1.push((condition.startDay <= i && i <= condition.endDay));
  8961. }
  8962. return results1;
  8963. }
  8964. },
  8965. _condCache: new AttachedCache(function(condition) {
  8966. var result, tag;
  8967. tag = exports._handler(condition.conditionType).tag;
  8968. result = tag ? tag.apply(exports, arguments) : exports.str(condition);
  8969. return condition.conditionType + '$' + result;
  8970. }),
  8971. _setProp: function(obj, prop, value) {
  8972. if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
  8973. Object.defineProperty(obj, prop, {
  8974. writable: true
  8975. });
  8976. }
  8977. return obj[prop] = value;
  8978. },
  8979. _handler: function(conditionType) {
  8980. var handler;
  8981. if (typeof conditionType !== 'string') {
  8982. conditionType = conditionType.conditionType;
  8983. }
  8984. handler = exports._conditionTypes[conditionType];
  8985. if (handler == null) {
  8986. throw new Error("Unknown condition type: " + conditionType);
  8987. }
  8988. return handler;
  8989. },
  8990. _conditionTypes: {
  8991. 'TrueCondition': {
  8992. abbrs: ['True'],
  8993. analyze: function(condition) {
  8994. return null;
  8995. },
  8996. match: function() {
  8997. return true;
  8998. },
  8999. compile: function(condition) {
  9000. return new U2.AST_True;
  9001. },
  9002. str: function(condition) {
  9003. return '';
  9004. },
  9005. fromStr: function(str, condition) {
  9006. return condition;
  9007. }
  9008. },
  9009. 'FalseCondition': {
  9010. abbrs: ['False', 'Disabled'],
  9011. analyze: function(condition) {
  9012. return null;
  9013. },
  9014. match: function() {
  9015. return false;
  9016. },
  9017. compile: function(condition) {
  9018. return new U2.AST_False;
  9019. },
  9020. fromStr: function(str, condition) {
  9021. if (str.length > 0) {
  9022. condition.pattern = str;
  9023. }
  9024. return condition;
  9025. }
  9026. },
  9027. 'UrlRegexCondition': {
  9028. abbrs: ['UR', 'URegex', 'UrlR', 'UrlRegex'],
  9029. analyze: function(condition) {
  9030. return this.safeRegex(escapeSlash(condition.pattern));
  9031. },
  9032. match: function(condition, request, cache) {
  9033. return cache.analyzed.test(request.url);
  9034. },
  9035. compile: function(condition, cache) {
  9036. return this.regTest('url', cache.analyzed);
  9037. }
  9038. },
  9039. 'UrlWildcardCondition': {
  9040. abbrs: ['U', 'UW', 'Url', 'UrlW', 'UWild', 'UWildcard', 'UrlWild', 'UrlWildcard'],
  9041. analyze: function(condition) {
  9042. var parts, pattern;
  9043. parts = (function() {
  9044. var j, len, ref1, results;
  9045. ref1 = condition.pattern.split('|');
  9046. results = [];
  9047. for (j = 0, len = ref1.length; j < len; j++) {
  9048. pattern = ref1[j];
  9049. if (pattern) {
  9050. results.push(shExp2RegExp(pattern, {
  9051. trimAsterisk: true
  9052. }));
  9053. }
  9054. }
  9055. return results;
  9056. })();
  9057. return this.safeRegex(parts.join('|'));
  9058. },
  9059. match: function(condition, request, cache) {
  9060. return cache.analyzed.test(request.url);
  9061. },
  9062. compile: function(condition, cache) {
  9063. return this.regTest('url', cache.analyzed);
  9064. }
  9065. },
  9066. 'HostRegexCondition': {
  9067. abbrs: ['R', 'HR', 'Regex', 'HostR', 'HRegex', 'HostRegex'],
  9068. analyze: function(condition) {
  9069. return this.safeRegex(escapeSlash(condition.pattern));
  9070. },
  9071. match: function(condition, request, cache) {
  9072. return cache.analyzed.test(request.host);
  9073. },
  9074. compile: function(condition, cache) {
  9075. return this.regTest('host', cache.analyzed);
  9076. }
  9077. },
  9078. 'HostWildcardCondition': {
  9079. abbrs: ['', 'H', 'W', 'HW', 'Wild', 'Wildcard', 'Host', 'HostW', 'HWild', 'HWildcard', 'HostWild', 'HostWildcard'],
  9080. analyze: function(condition) {
  9081. var parts, pattern;
  9082. parts = (function() {
  9083. var j, len, ref1, results;
  9084. ref1 = condition.pattern.split('|');
  9085. results = [];
  9086. for (j = 0, len = ref1.length; j < len; j++) {
  9087. pattern = ref1[j];
  9088. if (!(pattern)) {
  9089. continue;
  9090. }
  9091. if (pattern.charCodeAt(0) === '.'.charCodeAt(0)) {
  9092. pattern = '*' + pattern;
  9093. }
  9094. if (pattern.indexOf('**.') === 0) {
  9095. results.push(shExp2RegExp(pattern.substring(1), {
  9096. trimAsterisk: true
  9097. }));
  9098. } else if (pattern.indexOf('*.') === 0) {
  9099. results.push(shExp2RegExp(pattern.substring(2), {
  9100. trimAsterisk: false
  9101. }).replace(/./, '(?:^|\\.)').replace(/\.\*\$$/, ''));
  9102. } else {
  9103. results.push(shExp2RegExp(pattern, {
  9104. trimAsterisk: true
  9105. }));
  9106. }
  9107. }
  9108. return results;
  9109. })();
  9110. return this.safeRegex(parts.join('|'));
  9111. },
  9112. match: function(condition, request, cache) {
  9113. return cache.analyzed.test(request.host);
  9114. },
  9115. compile: function(condition, cache) {
  9116. return this.regTest('host', cache.analyzed);
  9117. }
  9118. },
  9119. 'BypassCondition': {
  9120. abbrs: ['B', 'Bypass'],
  9121. analyze: function(condition) {
  9122. var addr, cache, matchPort, parts, pos, prefixLen, ref1, scheme, server, serverIp, serverRegex;
  9123. cache = {
  9124. host: null,
  9125. ip: null,
  9126. scheme: null,
  9127. url: null,
  9128. normalizedPattern: ''
  9129. };
  9130. server = condition.pattern;
  9131. if (server === '<local>') {
  9132. cache.host = server;
  9133. return cache;
  9134. }
  9135. parts = server.split('://');
  9136. if (parts.length > 1) {
  9137. cache.scheme = parts[0];
  9138. cache.normalizedPattern = cache.scheme + '://';
  9139. server = parts[1];
  9140. }
  9141. parts = server.split('/');
  9142. if (parts.length > 1) {
  9143. addr = this.parseIp(parts[0]);
  9144. prefixLen = parseInt(parts[1]);
  9145. if (addr && !isNaN(prefixLen)) {
  9146. cache.ip = {
  9147. conditionType: 'IpCondition',
  9148. ip: this.normalizeIp(addr),
  9149. prefixLength: prefixLen
  9150. };
  9151. cache.normalizedPattern += cache.ip.ip + '/' + cache.ip.prefixLength;
  9152. return cache;
  9153. }
  9154. }
  9155. serverIp = this.parseIp(server);
  9156. if (serverIp == null) {
  9157. pos = server.lastIndexOf(':');
  9158. if (pos >= 0) {
  9159. matchPort = server.substring(pos + 1);
  9160. server = server.substring(0, pos);
  9161. }
  9162. serverIp = this.parseIp(server);
  9163. }
  9164. if (serverIp != null) {
  9165. server = this.normalizeIp(serverIp);
  9166. if (serverIp.v4) {
  9167. cache.normalizedPattern += server;
  9168. } else {
  9169. cache.normalizedPattern += '[' + server + ']';
  9170. }
  9171. } else {
  9172. if (server.charCodeAt(0) === '.'.charCodeAt(0)) {
  9173. server = '*' + server;
  9174. }
  9175. cache.normalizedPattern = server;
  9176. }
  9177. if (matchPort) {
  9178. cache.port = matchPort;
  9179. cache.normalizedPattern += ':' + cache.port;
  9180. if ((serverIp != null) && !serverIp.v4) {
  9181. server = '[' + server + ']';
  9182. }
  9183. serverRegex = shExp2RegExp(server);
  9184. serverRegex = serverRegex.substring(1, serverRegex.length - 1);
  9185. scheme = (ref1 = cache.scheme) != null ? ref1 : '[^:]+';
  9186. cache.url = this.safeRegex('^' + scheme + ':\\/\\/' + serverRegex + ':' + matchPort + '\\/');
  9187. } else if (server !== '*') {
  9188. serverRegex = shExp2RegExp(server, {
  9189. trimAsterisk: true
  9190. });
  9191. cache.host = this.safeRegex(serverRegex);
  9192. }
  9193. return cache;
  9194. },
  9195. match: function(condition, request, cache) {
  9196. cache = cache.analyzed;
  9197. if ((cache.scheme != null) && cache.scheme !== request.scheme) {
  9198. return false;
  9199. }
  9200. if ((cache.ip != null) && !this.match(cache.ip, request)) {
  9201. return false;
  9202. }
  9203. if (cache.host != null) {
  9204. if (cache.host === '<local>') {
  9205. return request.host === '127.0.0.1' || request.host === '::1' || request.host.indexOf('.') < 0;
  9206. } else {
  9207. if (!cache.host.test(request.host)) {
  9208. return false;
  9209. }
  9210. }
  9211. }
  9212. if ((cache.url != null) && !cache.url.test(request.url)) {
  9213. return false;
  9214. }
  9215. return true;
  9216. },
  9217. str: function(condition) {
  9218. var analyze, cache;
  9219. analyze = this._handler(condition).analyze;
  9220. cache = analyze.call(exports, condition);
  9221. if (cache.normalizedPattern) {
  9222. return cache.normalizedPattern;
  9223. } else {
  9224. return condition.pattern;
  9225. }
  9226. },
  9227. compile: function(condition, cache) {
  9228. var conditions, hostEquals;
  9229. cache = cache.analyzed;
  9230. if (cache.url != null) {
  9231. return this.regTest('url', cache.url);
  9232. }
  9233. conditions = [];
  9234. if (cache.host === '<local>') {
  9235. hostEquals = function(host) {
  9236. return new U2.AST_Binary({
  9237. left: new U2.AST_SymbolRef({
  9238. name: 'host'
  9239. }),
  9240. operator: '===',
  9241. right: new U2.AST_String({
  9242. value: host
  9243. })
  9244. });
  9245. };
  9246. return new U2.AST_Binary({
  9247. left: new U2.AST_Binary({
  9248. left: hostEquals('127.0.0.1'),
  9249. operator: '||',
  9250. right: hostEquals('::1')
  9251. }),
  9252. operator: '||',
  9253. right: new U2.AST_Binary({
  9254. left: new U2.AST_Call({
  9255. expression: new U2.AST_Dot({
  9256. expression: new U2.AST_SymbolRef({
  9257. name: 'host'
  9258. }),
  9259. property: 'indexOf'
  9260. }),
  9261. args: [
  9262. new U2.AST_String({
  9263. value: '.'
  9264. })
  9265. ]
  9266. }),
  9267. operator: '<',
  9268. right: new U2.AST_Number({
  9269. value: 0
  9270. })
  9271. })
  9272. });
  9273. }
  9274. if (cache.scheme != null) {
  9275. conditions.push(new U2.AST_Binary({
  9276. left: new U2.AST_SymbolRef({
  9277. name: 'scheme'
  9278. }),
  9279. operator: '===',
  9280. right: new U2.AST_String({
  9281. value: cache.scheme
  9282. })
  9283. }));
  9284. }
  9285. if (cache.host != null) {
  9286. conditions.push(this.regTest('host', cache.host));
  9287. } else if (cache.ip != null) {
  9288. conditions.push(this.compile(cache.ip));
  9289. }
  9290. switch (conditions.length) {
  9291. case 0:
  9292. return new U2.AST_True;
  9293. case 1:
  9294. return conditions[0];
  9295. case 2:
  9296. return new U2.AST_Binary({
  9297. left: conditions[0],
  9298. operator: '&&',
  9299. right: conditions[1]
  9300. });
  9301. }
  9302. }
  9303. },
  9304. 'KeywordCondition': {
  9305. abbrs: ['K', 'KW', 'Keyword'],
  9306. analyze: function(condition) {
  9307. return null;
  9308. },
  9309. match: function(condition, request) {
  9310. return request.scheme === 'http' && request.url.indexOf(condition.pattern) >= 0;
  9311. },
  9312. compile: function(condition) {
  9313. return new U2.AST_Binary({
  9314. left: new U2.AST_Binary({
  9315. left: new U2.AST_SymbolRef({
  9316. name: 'scheme'
  9317. }),
  9318. operator: '===',
  9319. right: new U2.AST_String({
  9320. value: 'http'
  9321. })
  9322. }),
  9323. operator: '&&',
  9324. right: new U2.AST_Binary({
  9325. left: new U2.AST_Call({
  9326. expression: new U2.AST_Dot({
  9327. expression: new U2.AST_SymbolRef({
  9328. name: 'url'
  9329. }),
  9330. property: 'indexOf'
  9331. }),
  9332. args: [
  9333. new U2.AST_String({
  9334. value: condition.pattern
  9335. })
  9336. ]
  9337. }),
  9338. operator: '>=',
  9339. right: new U2.AST_Number({
  9340. value: 0
  9341. })
  9342. })
  9343. });
  9344. }
  9345. },
  9346. 'IpCondition': {
  9347. abbrs: ['Ip'],
  9348. analyze: function(condition) {
  9349. var addr, cache, ip, mask;
  9350. cache = {
  9351. addr: null,
  9352. normalized: null
  9353. };
  9354. ip = condition.ip;
  9355. if (ip.charCodeAt(0) === '['.charCodeAt(0)) {
  9356. ip = ip.substr(1, ip.length - 2);
  9357. }
  9358. addr = ip + '/' + condition.prefixLength;
  9359. cache.addr = this.parseIp(addr);
  9360. if (cache.addr == null) {
  9361. throw new Error("Invalid IP address " + addr);
  9362. }
  9363. cache.normalized = this.normalizeIp(cache.addr);
  9364. mask = cache.addr.v4 ? new IP.v4.Address('255.255.255.255/' + cache.addr.subnetMask) : new IP.v6.Address(this.ipv6Max + '/' + cache.addr.subnetMask);
  9365. cache.mask = this.normalizeIp(mask.startAddress());
  9366. return cache;
  9367. },
  9368. match: function(condition, request, cache) {
  9369. var addr;
  9370. addr = this.parseIp(request.host);
  9371. if (addr == null) {
  9372. return false;
  9373. }
  9374. cache = cache.analyzed;
  9375. if (addr.v4 !== cache.addr.v4) {
  9376. return false;
  9377. }
  9378. return addr.isInSubnet(cache.addr);
  9379. },
  9380. compile: function(condition, cache) {
  9381. var hostIsInNet, hostIsInNetEx, hostLooksLikeIp;
  9382. cache = cache.analyzed;
  9383. hostLooksLikeIp = cache.addr.v4 ? new U2.AST_Binary({
  9384. left: new U2.AST_Sub({
  9385. expression: new U2.AST_SymbolRef({
  9386. name: 'host'
  9387. }),
  9388. property: new U2.AST_Binary({
  9389. left: new U2.AST_Dot({
  9390. expression: new U2.AST_SymbolRef({
  9391. name: 'host'
  9392. }),
  9393. property: 'length'
  9394. }),
  9395. operator: '-',
  9396. right: new U2.AST_Number({
  9397. value: 1
  9398. })
  9399. })
  9400. }),
  9401. operator: '>=',
  9402. right: new U2.AST_Number({
  9403. value: 0
  9404. })
  9405. }) : new U2.AST_Binary({
  9406. left: new U2.AST_Call({
  9407. expression: new U2.AST_Dot({
  9408. expression: new U2.AST_SymbolRef({
  9409. name: 'host'
  9410. }),
  9411. property: 'indexOf'
  9412. }),
  9413. args: [
  9414. new U2.AST_String({
  9415. value: ':'
  9416. })
  9417. ]
  9418. }),
  9419. operator: '>=',
  9420. right: new U2.AST_Number({
  9421. value: 0
  9422. })
  9423. });
  9424. if (cache.addr.subnetMask === 0) {
  9425. return hostLooksLikeIp;
  9426. }
  9427. hostIsInNet = new U2.AST_Call({
  9428. expression: new U2.AST_SymbolRef({
  9429. name: 'isInNet'
  9430. }),
  9431. args: [
  9432. new U2.AST_SymbolRef({
  9433. name: 'host'
  9434. }), new U2.AST_String({
  9435. value: cache.normalized
  9436. }), new U2.AST_String({
  9437. value: cache.mask
  9438. })
  9439. ]
  9440. });
  9441. if (!cache.addr.v4) {
  9442. hostIsInNetEx = new U2.AST_Call({
  9443. expression: new U2.AST_SymbolRef({
  9444. name: 'isInNetEx'
  9445. }),
  9446. args: [
  9447. new U2.AST_SymbolRef({
  9448. name: 'host'
  9449. }), new U2.AST_String({
  9450. value: cache.normalized + cache.addr.subnet
  9451. })
  9452. ]
  9453. });
  9454. hostIsInNet = new U2.AST_Conditional({
  9455. condition: new U2.AST_Binary({
  9456. left: new U2.AST_UnaryPrefix({
  9457. operator: 'typeof',
  9458. expression: new U2.AST_SymbolRef({
  9459. name: 'isInNetEx'
  9460. })
  9461. }),
  9462. operator: '===',
  9463. right: new U2.AST_String({
  9464. value: 'function'
  9465. })
  9466. }),
  9467. consequent: hostIsInNetEx,
  9468. alternative: hostIsInNet
  9469. });
  9470. }
  9471. return new U2.AST_Binary({
  9472. left: hostLooksLikeIp,
  9473. operator: '&&',
  9474. right: hostIsInNet
  9475. });
  9476. },
  9477. str: function(condition) {
  9478. return condition.ip + '/' + condition.prefixLength;
  9479. },
  9480. fromStr: function(str, condition) {
  9481. var addr;
  9482. addr = this.parseIp(str);
  9483. if (addr != null) {
  9484. condition.ip = addr.addressMinusSuffix;
  9485. condition.prefixLength = addr.subnetMask;
  9486. } else {
  9487. condition.ip = '0.0.0.0';
  9488. condition.prefixLength = 0;
  9489. }
  9490. return condition;
  9491. }
  9492. },
  9493. 'HostLevelsCondition': {
  9494. abbrs: ['Lv', 'Level', 'Levels', 'HL', 'HLv', 'HLevel', 'HLevels', 'HostL', 'HostLv', 'HostLevel', 'HostLevels'],
  9495. analyze: function(condition) {
  9496. return '.'.charCodeAt(0);
  9497. },
  9498. match: function(condition, request, cache) {
  9499. var dotCharCode, dotCount, i, j, ref1;
  9500. dotCharCode = cache.analyzed;
  9501. dotCount = 0;
  9502. for (i = j = 0, ref1 = request.host.length; 0 <= ref1 ? j < ref1 : j > ref1; i = 0 <= ref1 ? ++j : --j) {
  9503. if (request.host.charCodeAt(i) === dotCharCode) {
  9504. dotCount++;
  9505. if (dotCount > condition.maxValue) {
  9506. return false;
  9507. }
  9508. }
  9509. }
  9510. return dotCount >= condition.minValue;
  9511. },
  9512. compile: function(condition) {
  9513. var val;
  9514. val = new U2.AST_Dot({
  9515. property: 'length',
  9516. expression: new U2.AST_Call({
  9517. args: [
  9518. new U2.AST_String({
  9519. value: '.'
  9520. })
  9521. ],
  9522. expression: new U2.AST_Dot({
  9523. expression: new U2.AST_SymbolRef({
  9524. name: 'host'
  9525. }),
  9526. property: 'split'
  9527. })
  9528. })
  9529. });
  9530. return this.between(val, condition.minValue + 1, condition.maxValue + 1, condition.minValue + " <= hostLevels <= " + condition.maxValue);
  9531. },
  9532. str: function(condition) {
  9533. return condition.minValue + '~' + condition.maxValue;
  9534. },
  9535. fromStr: function(str, condition) {
  9536. var maxValue, minValue, ref1;
  9537. ref1 = str.split('~'), minValue = ref1[0], maxValue = ref1[1];
  9538. condition.minValue = parseInt(minValue, 10);
  9539. condition.maxValue = parseInt(maxValue, 10);
  9540. if (!(condition.minValue > 0)) {
  9541. condition.minValue = 1;
  9542. }
  9543. if (!(condition.maxValue > 0)) {
  9544. condition.maxValue = 1;
  9545. }
  9546. return condition;
  9547. }
  9548. },
  9549. 'WeekdayCondition': {
  9550. abbrs: ['WD', 'Week', 'Day', 'Weekday'],
  9551. analyze: function(condition) {
  9552. return null;
  9553. },
  9554. match: function(condition, request) {
  9555. var day;
  9556. day = new Date().getDay();
  9557. if (condition.days) {
  9558. return condition.days.charCodeAt(day) > 64;
  9559. }
  9560. return condition.startDay <= day && day <= condition.endDay;
  9561. },
  9562. compile: function(condition) {
  9563. var getDay;
  9564. getDay = new U2.AST_Call({
  9565. args: [],
  9566. expression: new U2.AST_Dot({
  9567. property: 'getDay',
  9568. expression: new U2.AST_New({
  9569. args: [],
  9570. expression: new U2.AST_SymbolRef({
  9571. name: 'Date'
  9572. })
  9573. })
  9574. })
  9575. });
  9576. if (condition.days) {
  9577. return new U2.AST_Binary({
  9578. left: new U2.AST_Call({
  9579. expression: new U2.AST_Dot({
  9580. expression: new U2.AST_String({
  9581. value: condition.days
  9582. }),
  9583. property: 'charCodeAt'
  9584. }),
  9585. args: [getDay]
  9586. }),
  9587. operator: '>',
  9588. right: new U2.AST_Number({
  9589. value: 64
  9590. })
  9591. });
  9592. } else {
  9593. return this.between(getDay, condition.startDay, condition.endDay);
  9594. }
  9595. },
  9596. str: function(condition) {
  9597. if (condition.days) {
  9598. return condition.days;
  9599. } else {
  9600. return condition.startDay + '~' + condition.endDay;
  9601. }
  9602. },
  9603. fromStr: function(str, condition) {
  9604. var endDay, ref1, ref2, ref3, startDay;
  9605. if (str.indexOf('~') < 0 && str.length === 7) {
  9606. condition.days = str;
  9607. } else {
  9608. ref1 = str.split('~'), startDay = ref1[0], endDay = ref1[1];
  9609. condition.startDay = parseInt(startDay, 10);
  9610. condition.endDay = parseInt(endDay, 10);
  9611. if (!((0 <= (ref2 = condition.startDay) && ref2 <= 6))) {
  9612. condition.startDay = 0;
  9613. }
  9614. if (!((0 <= (ref3 = condition.endDay) && ref3 <= 6))) {
  9615. condition.endDay = 0;
  9616. }
  9617. }
  9618. return condition;
  9619. }
  9620. },
  9621. 'TimeCondition': {
  9622. abbrs: ['T', 'Time', 'Hour'],
  9623. analyze: function(condition) {
  9624. return null;
  9625. },
  9626. match: function(condition, request) {
  9627. var hour;
  9628. hour = new Date().getHours();
  9629. return condition.startHour <= hour && hour <= condition.endHour;
  9630. },
  9631. compile: function(condition) {
  9632. var val;
  9633. val = new U2.AST_Call({
  9634. args: [],
  9635. expression: new U2.AST_Dot({
  9636. property: 'getHours',
  9637. expression: new U2.AST_New({
  9638. args: [],
  9639. expression: new U2.AST_SymbolRef({
  9640. name: 'Date'
  9641. })
  9642. })
  9643. })
  9644. });
  9645. return this.between(val, condition.startHour, condition.endHour);
  9646. },
  9647. str: function(condition) {
  9648. return condition.startHour + '~' + condition.endHour;
  9649. },
  9650. fromStr: function(str, condition) {
  9651. var endHour, ref1, ref2, ref3, startHour;
  9652. ref1 = str.split('~'), startHour = ref1[0], endHour = ref1[1];
  9653. condition.startHour = parseInt(startHour, 10);
  9654. condition.endHour = parseInt(endHour, 10);
  9655. if (!((0 <= (ref2 = condition.startHour) && ref2 < 24))) {
  9656. condition.startHour = 0;
  9657. }
  9658. if (!((0 <= (ref3 = condition.endHour) && ref3 < 24))) {
  9659. condition.endHour = 0;
  9660. }
  9661. return condition;
  9662. }
  9663. }
  9664. }
  9665. };
  9666. },{"./shexp_utils":65,"./utils":66,"ip-address":5,"uglify-js":67,"url":60}],62:[function(require,module,exports){
  9667. var Profiles, U2;
  9668. U2 = require('uglify-js');
  9669. Profiles = require('./profiles');
  9670. module.exports = {
  9671. ascii: function(str) {
  9672. return str.replace(/[\u0080-\uffff]/g, function(char) {
  9673. var _, hex, i, ref, result;
  9674. hex = char.charCodeAt(0).toString(16);
  9675. result = '\\u';
  9676. for (_ = i = ref = hex.length; ref <= 4 ? i < 4 : i > 4; _ = ref <= 4 ? ++i : --i) {
  9677. result += '0';
  9678. }
  9679. result += hex;
  9680. return result;
  9681. });
  9682. },
  9683. compress: function(ast) {
  9684. var compressed_ast, compressor;
  9685. ast.figure_out_scope();
  9686. compressor = U2.Compressor({
  9687. warnings: false,
  9688. keep_fargs: true
  9689. }, {
  9690. if_return: false
  9691. });
  9692. compressed_ast = ast.transform(compressor);
  9693. compressed_ast.figure_out_scope();
  9694. compressed_ast.compute_char_frequency();
  9695. compressed_ast.mangle_names();
  9696. return compressed_ast;
  9697. },
  9698. script: function(options, profile, args) {
  9699. var factory, key, name, p, profiles, refs;
  9700. if (typeof profile === 'string') {
  9701. profile = Profiles.byName(profile, options);
  9702. }
  9703. refs = Profiles.allReferenceSet(profile, options, {
  9704. profileNotFound: args != null ? args.profileNotFound : void 0
  9705. });
  9706. profiles = new U2.AST_Object({
  9707. properties: (function() {
  9708. var results;
  9709. results = [];
  9710. for (key in refs) {
  9711. name = refs[key];
  9712. if (!(key !== '+direct')) {
  9713. continue;
  9714. }
  9715. p = typeof profile === 'object' && profile.name === name ? profile : Profiles.byName(name, options);
  9716. if (p == null) {
  9717. p = Profiles.profileNotFound(name, args != null ? args.profileNotFound : void 0);
  9718. }
  9719. results.push(new U2.AST_ObjectKeyVal({
  9720. key: key,
  9721. value: Profiles.compile(p)
  9722. }));
  9723. }
  9724. return results;
  9725. })()
  9726. });
  9727. factory = new U2.AST_Function({
  9728. argnames: [
  9729. new U2.AST_SymbolFunarg({
  9730. name: 'init'
  9731. }), new U2.AST_SymbolFunarg({
  9732. name: 'profiles'
  9733. })
  9734. ],
  9735. body: [
  9736. new U2.AST_Return({
  9737. value: new U2.AST_Function({
  9738. argnames: [
  9739. new U2.AST_SymbolFunarg({
  9740. name: 'url'
  9741. }), new U2.AST_SymbolFunarg({
  9742. name: 'host'
  9743. })
  9744. ],
  9745. body: [
  9746. new U2.AST_Directive({
  9747. value: 'use strict'
  9748. }), new U2.AST_Var({
  9749. definitions: [
  9750. new U2.AST_VarDef({
  9751. name: new U2.AST_SymbolVar({
  9752. name: 'result'
  9753. }),
  9754. value: new U2.AST_SymbolRef({
  9755. name: 'init'
  9756. })
  9757. }), new U2.AST_VarDef({
  9758. name: new U2.AST_SymbolVar({
  9759. name: 'scheme'
  9760. }),
  9761. value: new U2.AST_Call({
  9762. expression: new U2.AST_Dot({
  9763. expression: new U2.AST_SymbolRef({
  9764. name: 'url'
  9765. }),
  9766. property: 'substr'
  9767. }),
  9768. args: [
  9769. new U2.AST_Number({
  9770. value: 0
  9771. }), new U2.AST_Call({
  9772. expression: new U2.AST_Dot({
  9773. expression: new U2.AST_SymbolRef({
  9774. name: 'url'
  9775. }),
  9776. property: 'indexOf'
  9777. }),
  9778. args: [
  9779. new U2.AST_String({
  9780. value: ':'
  9781. })
  9782. ]
  9783. })
  9784. ]
  9785. })
  9786. })
  9787. ]
  9788. }), new U2.AST_Do({
  9789. body: new U2.AST_BlockStatement({
  9790. body: [
  9791. new U2.AST_SimpleStatement({
  9792. body: new U2.AST_Assign({
  9793. left: new U2.AST_SymbolRef({
  9794. name: 'result'
  9795. }),
  9796. operator: '=',
  9797. right: new U2.AST_Sub({
  9798. expression: new U2.AST_SymbolRef({
  9799. name: 'profiles'
  9800. }),
  9801. property: new U2.AST_SymbolRef({
  9802. name: 'result'
  9803. })
  9804. })
  9805. })
  9806. }), new U2.AST_If({
  9807. condition: new U2.AST_Binary({
  9808. left: new U2.AST_UnaryPrefix({
  9809. operator: 'typeof',
  9810. expression: new U2.AST_SymbolRef({
  9811. name: 'result'
  9812. })
  9813. }),
  9814. operator: '===',
  9815. right: new U2.AST_String({
  9816. value: 'function'
  9817. })
  9818. }),
  9819. body: new U2.AST_SimpleStatement({
  9820. body: new U2.AST_Assign({
  9821. left: new U2.AST_SymbolRef({
  9822. name: 'result'
  9823. }),
  9824. operator: '=',
  9825. right: new U2.AST_Call({
  9826. expression: new U2.AST_SymbolRef({
  9827. name: 'result'
  9828. }),
  9829. args: [
  9830. new U2.AST_SymbolRef({
  9831. name: 'url'
  9832. }), new U2.AST_SymbolRef({
  9833. name: 'host'
  9834. }), new U2.AST_SymbolRef({
  9835. name: 'scheme'
  9836. })
  9837. ]
  9838. })
  9839. })
  9840. })
  9841. })
  9842. ]
  9843. }),
  9844. condition: new U2.AST_Binary({
  9845. left: new U2.AST_Binary({
  9846. left: new U2.AST_UnaryPrefix({
  9847. operator: 'typeof',
  9848. expression: new U2.AST_SymbolRef({
  9849. name: 'result'
  9850. })
  9851. }),
  9852. operator: '!==',
  9853. right: new U2.AST_String({
  9854. value: 'string'
  9855. })
  9856. }),
  9857. operator: '||',
  9858. right: new U2.AST_Binary({
  9859. left: new U2.AST_Call({
  9860. expression: new U2.AST_Dot({
  9861. expression: new U2.AST_SymbolRef({
  9862. name: 'result'
  9863. }),
  9864. property: 'charCodeAt'
  9865. }),
  9866. args: [
  9867. new U2.AST_Number({
  9868. value: 0
  9869. })
  9870. ]
  9871. }),
  9872. operator: '===',
  9873. right: new U2.AST_Number({
  9874. value: '+'.charCodeAt(0)
  9875. })
  9876. })
  9877. })
  9878. }), new U2.AST_Return({
  9879. value: new U2.AST_SymbolRef({
  9880. name: 'result'
  9881. })
  9882. })
  9883. ]
  9884. })
  9885. })
  9886. ]
  9887. });
  9888. return new U2.AST_Toplevel({
  9889. body: [
  9890. new U2.AST_Var({
  9891. definitions: [
  9892. new U2.AST_VarDef({
  9893. name: new U2.AST_SymbolVar({
  9894. name: 'FindProxyForURL'
  9895. }),
  9896. value: new U2.AST_Call({
  9897. expression: factory,
  9898. args: [Profiles.profileResult(profile.name), profiles]
  9899. })
  9900. })
  9901. ]
  9902. })
  9903. ]
  9904. });
  9905. }
  9906. };
  9907. },{"./profiles":63,"uglify-js":67}],63:[function(require,module,exports){
  9908. var AST_Raw, AttachedCache, Conditions, Revision, RuleList, ShexpUtils, U2, exports, ref1,
  9909. 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; },
  9910. hasProp = {}.hasOwnProperty;
  9911. U2 = require('uglify-js');
  9912. ShexpUtils = require('./shexp_utils');
  9913. Conditions = require('./conditions');
  9914. RuleList = require('./rule_list');
  9915. ref1 = require('./utils'), AttachedCache = ref1.AttachedCache, Revision = ref1.Revision;
  9916. AST_Raw = (function(superClass) {
  9917. extend(AST_Raw, superClass);
  9918. function AST_Raw(raw) {
  9919. U2.AST_SymbolRef.call(this, {
  9920. name: raw
  9921. });
  9922. this.aborts = function() {
  9923. return false;
  9924. };
  9925. }
  9926. return AST_Raw;
  9927. })(U2.AST_SymbolRef);
  9928. module.exports = exports = {
  9929. builtinProfiles: {
  9930. '+direct': {
  9931. name: 'direct',
  9932. profileType: 'DirectProfile',
  9933. color: '#aaaaaa',
  9934. builtin: true
  9935. },
  9936. '+system': {
  9937. name: 'system',
  9938. profileType: 'SystemProfile',
  9939. color: '#000000',
  9940. builtin: true
  9941. }
  9942. },
  9943. schemes: [
  9944. {
  9945. scheme: 'http',
  9946. prop: 'proxyForHttp'
  9947. }, {
  9948. scheme: 'https',
  9949. prop: 'proxyForHttps'
  9950. }, {
  9951. scheme: 'ftp',
  9952. prop: 'proxyForFtp'
  9953. }, {
  9954. scheme: '',
  9955. prop: 'fallbackProxy'
  9956. }
  9957. ],
  9958. pacProtocols: {
  9959. 'http': 'PROXY',
  9960. 'https': 'HTTPS',
  9961. 'socks4': 'SOCKS',
  9962. 'socks5': 'SOCKS5'
  9963. },
  9964. formatByType: {
  9965. 'SwitchyRuleListProfile': 'Switchy',
  9966. 'AutoProxyRuleListProfile': 'AutoProxy'
  9967. },
  9968. ruleListFormats: ['Switchy', 'AutoProxy'],
  9969. parseHostPort: function(str, scheme) {
  9970. var host, port, sep;
  9971. sep = str.lastIndexOf(':');
  9972. if (sep < 0) {
  9973. return;
  9974. }
  9975. port = parseInt(str.substr(sep + 1)) || 80;
  9976. host = str.substr(0, sep);
  9977. if (!host) {
  9978. return;
  9979. }
  9980. return {
  9981. scheme: scheme,
  9982. host: host,
  9983. port: port
  9984. };
  9985. },
  9986. pacResult: function(proxy) {
  9987. if (proxy) {
  9988. if (proxy.scheme === 'socks5') {
  9989. return "SOCKS5 " + proxy.host + ":" + proxy.port + "; SOCKS " + proxy.host + ":" + proxy.port;
  9990. } else {
  9991. return exports.pacProtocols[proxy.scheme] + " " + proxy.host + ":" + proxy.port;
  9992. }
  9993. } else {
  9994. return 'DIRECT';
  9995. }
  9996. },
  9997. isFileUrl: function(url) {
  9998. return !!((url != null ? url.substr(0, 5).toUpperCase() : void 0) === 'FILE:');
  9999. },
  10000. nameAsKey: function(profileName) {
  10001. if (typeof profileName !== 'string') {
  10002. profileName = profileName.name;
  10003. }
  10004. return '+' + profileName;
  10005. },
  10006. byName: function(profileName, options) {
  10007. var key, ref2;
  10008. if (typeof profileName === 'string') {
  10009. key = exports.nameAsKey(profileName);
  10010. profileName = (ref2 = exports.builtinProfiles[key]) != null ? ref2 : options[key];
  10011. }
  10012. return profileName;
  10013. },
  10014. byKey: function(key, options) {
  10015. var ref2;
  10016. if (typeof key === 'string') {
  10017. key = (ref2 = exports.builtinProfiles[key]) != null ? ref2 : options[key];
  10018. }
  10019. return key;
  10020. },
  10021. each: function(options, callback) {
  10022. var charCodePlus, key, profile, ref2, results;
  10023. charCodePlus = '+'.charCodeAt(0);
  10024. for (key in options) {
  10025. profile = options[key];
  10026. if (key.charCodeAt(0) === charCodePlus) {
  10027. callback(key, profile);
  10028. }
  10029. }
  10030. ref2 = exports.builtinProfiles;
  10031. results = [];
  10032. for (key in ref2) {
  10033. profile = ref2[key];
  10034. if (key.charCodeAt(0) === charCodePlus) {
  10035. results.push(callback(key, profile));
  10036. } else {
  10037. results.push(void 0);
  10038. }
  10039. }
  10040. return results;
  10041. },
  10042. profileResult: function(profileName) {
  10043. var key;
  10044. key = exports.nameAsKey(profileName);
  10045. if (key === '+direct') {
  10046. key = exports.pacResult();
  10047. }
  10048. return new U2.AST_String({
  10049. value: key
  10050. });
  10051. },
  10052. isIncludable: function(profile) {
  10053. var includable;
  10054. includable = exports._handler(profile).includable;
  10055. if (typeof includable === 'function') {
  10056. includable = includable.call(exports, profile);
  10057. }
  10058. return !!includable;
  10059. },
  10060. isInclusive: function(profile) {
  10061. return !!exports._handler(profile).inclusive;
  10062. },
  10063. updateUrl: function(profile) {
  10064. var ref2;
  10065. return (ref2 = exports._handler(profile).updateUrl) != null ? ref2.call(exports, profile) : void 0;
  10066. },
  10067. updateContentTypeHints: function(profile) {
  10068. var ref2;
  10069. return (ref2 = exports._handler(profile).updateContentTypeHints) != null ? ref2.call(exports, profile) : void 0;
  10070. },
  10071. update: function(profile, data) {
  10072. return exports._handler(profile).update.call(exports, profile, data);
  10073. },
  10074. tag: function(profile) {
  10075. return exports._profileCache.tag(profile);
  10076. },
  10077. create: function(profile, opt_profileType) {
  10078. var create;
  10079. if (typeof profile === 'string') {
  10080. profile = {
  10081. name: profile,
  10082. profileType: opt_profileType
  10083. };
  10084. } else if (opt_profileType) {
  10085. profile.profileType = opt_profileType;
  10086. }
  10087. create = exports._handler(profile).create;
  10088. if (!create) {
  10089. return profile;
  10090. }
  10091. create.call(exports, profile);
  10092. return profile;
  10093. },
  10094. updateRevision: function(profile, revision) {
  10095. if (revision == null) {
  10096. revision = Revision.fromTime();
  10097. }
  10098. return profile.revision = revision;
  10099. },
  10100. replaceRef: function(profile, fromName, toName) {
  10101. var handler;
  10102. if (!exports.isInclusive(profile)) {
  10103. return false;
  10104. }
  10105. handler = exports._handler(profile);
  10106. return handler.replaceRef.call(exports, profile, fromName, toName);
  10107. },
  10108. analyze: function(profile) {
  10109. var analyze, cache, result;
  10110. cache = exports._profileCache.get(profile, {});
  10111. if (!Object.prototype.hasOwnProperty.call(cache, 'analyzed')) {
  10112. analyze = exports._handler(profile).analyze;
  10113. result = analyze != null ? analyze.call(exports, profile) : void 0;
  10114. cache.analyzed = result;
  10115. }
  10116. return cache;
  10117. },
  10118. dropCache: function(profile) {
  10119. return exports._profileCache.drop(profile);
  10120. },
  10121. directReferenceSet: function(profile) {
  10122. var cache, handler;
  10123. if (!exports.isInclusive(profile)) {
  10124. return {};
  10125. }
  10126. cache = exports._profileCache.get(profile, {});
  10127. if (cache.directReferenceSet) {
  10128. return cache.directReferenceSet;
  10129. }
  10130. handler = exports._handler(profile);
  10131. return cache.directReferenceSet = handler.directReferenceSet.call(exports, profile);
  10132. },
  10133. profileNotFound: function(name, action) {
  10134. if (action == null) {
  10135. throw new Error("Profile " + name + " does not exist!");
  10136. }
  10137. if (typeof action === 'function') {
  10138. action = action(name);
  10139. }
  10140. if (typeof action === 'object' && action.profileType) {
  10141. return action;
  10142. }
  10143. switch (action) {
  10144. case 'ignore':
  10145. return null;
  10146. case 'dumb':
  10147. return exports.create({
  10148. name: name,
  10149. profileType: 'VirtualProfile',
  10150. defaultProfileName: 'direct'
  10151. });
  10152. }
  10153. throw action;
  10154. },
  10155. allReferenceSet: function(profile, options, opt_args) {
  10156. var has_out, key, name, o_profile, ref2, result;
  10157. o_profile = profile;
  10158. profile = exports.byName(profile, options);
  10159. if (profile == null) {
  10160. profile = typeof exports.profileNotFound === "function" ? exports.profileNotFound(o_profile, opt_args.profileNotFound) : void 0;
  10161. }
  10162. if (opt_args == null) {
  10163. opt_args = {};
  10164. }
  10165. has_out = opt_args.out != null;
  10166. result = opt_args.out != null ? opt_args.out : opt_args.out = {};
  10167. if (profile) {
  10168. result[exports.nameAsKey(profile.name)] = profile.name;
  10169. ref2 = exports.directReferenceSet(profile);
  10170. for (key in ref2) {
  10171. name = ref2[key];
  10172. exports.allReferenceSet(name, options, opt_args);
  10173. }
  10174. }
  10175. if (!has_out) {
  10176. delete opt_args.out;
  10177. }
  10178. return result;
  10179. },
  10180. referencedBySet: function(profile, options, opt_args) {
  10181. var has_out, profileKey, result;
  10182. profileKey = exports.nameAsKey(profile);
  10183. if (opt_args == null) {
  10184. opt_args = {};
  10185. }
  10186. has_out = opt_args.out != null;
  10187. result = opt_args.out != null ? opt_args.out : opt_args.out = {};
  10188. exports.each(options, function(key, prof) {
  10189. if (exports.directReferenceSet(prof)[profileKey]) {
  10190. result[key] = prof.name;
  10191. return exports.referencedBySet(prof, options, opt_args);
  10192. }
  10193. });
  10194. if (!has_out) {
  10195. delete opt_args.out;
  10196. }
  10197. return result;
  10198. },
  10199. validResultProfilesFor: function(profile, options) {
  10200. var profileKey, ref, result;
  10201. profile = exports.byName(profile, options);
  10202. if (!exports.isInclusive(profile)) {
  10203. return [];
  10204. }
  10205. profileKey = exports.nameAsKey(profile);
  10206. ref = exports.referencedBySet(profile, options);
  10207. ref[profileKey] = profileKey;
  10208. result = [];
  10209. exports.each(options, function(key, prof) {
  10210. if (!ref[key] && exports.isIncludable(prof)) {
  10211. return result.push(prof);
  10212. }
  10213. });
  10214. return result;
  10215. },
  10216. match: function(profile, request, opt_profileType) {
  10217. var cache, match;
  10218. if (opt_profileType == null) {
  10219. opt_profileType = profile.profileType;
  10220. }
  10221. cache = exports.analyze(profile);
  10222. match = exports._handler(opt_profileType).match;
  10223. return match != null ? match.call(exports, profile, request, cache) : void 0;
  10224. },
  10225. compile: function(profile, opt_profileType) {
  10226. var cache, handler;
  10227. if (opt_profileType == null) {
  10228. opt_profileType = profile.profileType;
  10229. }
  10230. cache = exports.analyze(profile);
  10231. if (cache.compiled) {
  10232. return cache.compiled;
  10233. }
  10234. handler = exports._handler(opt_profileType);
  10235. return cache.compiled = handler.compile.call(exports, profile, cache);
  10236. },
  10237. _profileCache: new AttachedCache(function(profile) {
  10238. return profile.revision;
  10239. }),
  10240. _handler: function(profileType) {
  10241. var handler;
  10242. if (typeof profileType !== 'string') {
  10243. profileType = profileType.profileType;
  10244. }
  10245. handler = profileType;
  10246. while (typeof handler === 'string') {
  10247. handler = exports._profileTypes[handler];
  10248. }
  10249. if (handler == null) {
  10250. throw new Error("Unknown profile type: " + profileType);
  10251. }
  10252. return handler;
  10253. },
  10254. _profileTypes: {
  10255. 'SystemProfile': {
  10256. compile: function(profile) {
  10257. throw new Error("SystemProfile cannot be used in PAC scripts");
  10258. }
  10259. },
  10260. 'DirectProfile': {
  10261. includable: true,
  10262. compile: function(profile) {
  10263. return new U2.AST_String({
  10264. value: this.pacResult()
  10265. });
  10266. }
  10267. },
  10268. 'FixedProfile': {
  10269. includable: true,
  10270. create: function(profile) {
  10271. return profile.bypassList != null ? profile.bypassList : profile.bypassList = [
  10272. {
  10273. conditionType: 'BypassCondition',
  10274. pattern: '127.0.0.1'
  10275. }, {
  10276. conditionType: 'BypassCondition',
  10277. pattern: '[::1]'
  10278. }, {
  10279. conditionType: 'BypassCondition',
  10280. pattern: 'localhost'
  10281. }
  10282. ];
  10283. },
  10284. match: function(profile, request) {
  10285. var cond, i, j, len, len1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, s;
  10286. if (profile.bypassList) {
  10287. ref2 = profile.bypassList;
  10288. for (i = 0, len = ref2.length; i < len; i++) {
  10289. cond = ref2[i];
  10290. if (Conditions.match(cond, request)) {
  10291. return [
  10292. this.pacResult(), cond, {
  10293. scheme: 'direct'
  10294. }, void 0
  10295. ];
  10296. }
  10297. }
  10298. }
  10299. ref3 = this.schemes;
  10300. for (j = 0, len1 = ref3.length; j < len1; j++) {
  10301. s = ref3[j];
  10302. if (s.scheme === request.scheme && profile[s.prop]) {
  10303. 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];
  10304. }
  10305. }
  10306. 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];
  10307. },
  10308. compile: function(profile) {
  10309. var body, cond, condition, conditions, i, len, ref2, ret, s;
  10310. if ((!profile.bypassList || !profile.fallbackProxy) && !profile.proxyForHttp && !profile.proxyForHttps && !profile.proxyForFtp) {
  10311. return new U2.AST_String({
  10312. value: this.pacResult(profile.fallbackProxy)
  10313. });
  10314. }
  10315. body = [
  10316. new U2.AST_Directive({
  10317. value: 'use strict'
  10318. })
  10319. ];
  10320. if (profile.bypassList && profile.bypassList.length) {
  10321. conditions = null;
  10322. ref2 = profile.bypassList;
  10323. for (i = 0, len = ref2.length; i < len; i++) {
  10324. cond = ref2[i];
  10325. condition = Conditions.compile(cond);
  10326. if (conditions != null) {
  10327. conditions = new U2.AST_Binary({
  10328. left: conditions,
  10329. operator: '||',
  10330. right: condition
  10331. });
  10332. } else {
  10333. conditions = condition;
  10334. }
  10335. }
  10336. body.push(new U2.AST_If({
  10337. condition: conditions,
  10338. body: new U2.AST_Return({
  10339. value: new U2.AST_String({
  10340. value: this.pacResult()
  10341. })
  10342. })
  10343. }));
  10344. }
  10345. if (!profile.proxyForHttp && !profile.proxyForHttps && !profile.proxyForFtp) {
  10346. body.push(new U2.AST_Return({
  10347. value: new U2.AST_String({
  10348. value: this.pacResult(profile.fallbackProxy)
  10349. })
  10350. }));
  10351. } else {
  10352. body.push(new U2.AST_Switch({
  10353. expression: new U2.AST_SymbolRef({
  10354. name: 'scheme'
  10355. }),
  10356. body: (function() {
  10357. var j, len1, ref3, results;
  10358. ref3 = this.schemes;
  10359. results = [];
  10360. for (j = 0, len1 = ref3.length; j < len1; j++) {
  10361. s = ref3[j];
  10362. if (!(!s.scheme || profile[s.prop])) {
  10363. continue;
  10364. }
  10365. ret = [
  10366. new U2.AST_Return({
  10367. value: new U2.AST_String({
  10368. value: this.pacResult(profile[s.prop])
  10369. })
  10370. })
  10371. ];
  10372. if (s.scheme) {
  10373. results.push(new U2.AST_Case({
  10374. expression: new U2.AST_String({
  10375. value: s.scheme
  10376. }),
  10377. body: ret
  10378. }));
  10379. } else {
  10380. results.push(new U2.AST_Default({
  10381. body: ret
  10382. }));
  10383. }
  10384. }
  10385. return results;
  10386. }).call(this)
  10387. }));
  10388. }
  10389. return new U2.AST_Function({
  10390. argnames: [
  10391. new U2.AST_SymbolFunarg({
  10392. name: 'url'
  10393. }), new U2.AST_SymbolFunarg({
  10394. name: 'host'
  10395. }), new U2.AST_SymbolFunarg({
  10396. name: 'scheme'
  10397. })
  10398. ],
  10399. body: body
  10400. });
  10401. }
  10402. },
  10403. 'PacProfile': {
  10404. includable: function(profile) {
  10405. return !this.isFileUrl(profile.pacUrl);
  10406. },
  10407. create: function(profile) {
  10408. return profile.pacScript != null ? profile.pacScript : profile.pacScript = 'function FindProxyForURL(url, host) {\n return "DIRECT";\n}';
  10409. },
  10410. compile: function(profile) {
  10411. return new U2.AST_Call({
  10412. args: [new U2.AST_This],
  10413. expression: new U2.AST_Dot({
  10414. property: 'call',
  10415. expression: new U2.AST_Function({
  10416. argnames: [],
  10417. body: [
  10418. new AST_Raw(';\n' + profile.pacScript + '\n\n/* End of PAC */;'), new U2.AST_Return({
  10419. value: new U2.AST_SymbolRef({
  10420. name: 'FindProxyForURL'
  10421. })
  10422. })
  10423. ]
  10424. })
  10425. })
  10426. });
  10427. },
  10428. updateUrl: function(profile) {
  10429. if (this.isFileUrl(profile.pacUrl)) {
  10430. return void 0;
  10431. } else {
  10432. return profile.pacUrl;
  10433. }
  10434. },
  10435. updateContentTypeHints: function() {
  10436. return ['!text/html', '!application/xhtml+xml', 'application/x-ns-proxy-autoconfig', 'application/x-javascript-config'];
  10437. },
  10438. update: function(profile, data) {
  10439. if (profile.pacScript === data) {
  10440. return false;
  10441. }
  10442. profile.pacScript = data;
  10443. return true;
  10444. }
  10445. },
  10446. 'AutoDetectProfile': 'PacProfile',
  10447. 'SwitchProfile': {
  10448. includable: true,
  10449. inclusive: true,
  10450. create: function(profile) {
  10451. if (profile.defaultProfileName == null) {
  10452. profile.defaultProfileName = 'direct';
  10453. }
  10454. return profile.rules != null ? profile.rules : profile.rules = [];
  10455. },
  10456. directReferenceSet: function(profile) {
  10457. var i, len, ref2, refs, rule;
  10458. refs = {};
  10459. refs[exports.nameAsKey(profile.defaultProfileName)] = profile.defaultProfileName;
  10460. ref2 = profile.rules;
  10461. for (i = 0, len = ref2.length; i < len; i++) {
  10462. rule = ref2[i];
  10463. refs[exports.nameAsKey(rule.profileName)] = rule.profileName;
  10464. }
  10465. return refs;
  10466. },
  10467. analyze: function(profile) {
  10468. return profile.rules;
  10469. },
  10470. replaceRef: function(profile, fromName, toName) {
  10471. var changed, i, len, ref2, rule;
  10472. changed = false;
  10473. if (profile.defaultProfileName === fromName) {
  10474. profile.defaultProfileName = toName;
  10475. changed = true;
  10476. }
  10477. ref2 = profile.rules;
  10478. for (i = 0, len = ref2.length; i < len; i++) {
  10479. rule = ref2[i];
  10480. if (rule.profileName === fromName) {
  10481. rule.profileName = toName;
  10482. changed = true;
  10483. }
  10484. }
  10485. return changed;
  10486. },
  10487. match: function(profile, request, cache) {
  10488. var i, len, ref2, rule;
  10489. ref2 = cache.analyzed;
  10490. for (i = 0, len = ref2.length; i < len; i++) {
  10491. rule = ref2[i];
  10492. if (Conditions.match(rule.condition, request)) {
  10493. return rule;
  10494. }
  10495. }
  10496. return [exports.nameAsKey(profile.defaultProfileName), null];
  10497. },
  10498. compile: function(profile, cache) {
  10499. var body, i, len, rule, rules;
  10500. rules = cache.analyzed;
  10501. if (rules.length === 0) {
  10502. return this.profileResult(profile.defaultProfileName);
  10503. }
  10504. body = [
  10505. new U2.AST_Directive({
  10506. value: 'use strict'
  10507. })
  10508. ];
  10509. for (i = 0, len = rules.length; i < len; i++) {
  10510. rule = rules[i];
  10511. body.push(new U2.AST_If({
  10512. condition: Conditions.compile(rule.condition),
  10513. body: new U2.AST_Return({
  10514. value: this.profileResult(rule.profileName)
  10515. })
  10516. }));
  10517. }
  10518. body.push(new U2.AST_Return({
  10519. value: this.profileResult(profile.defaultProfileName)
  10520. }));
  10521. return new U2.AST_Function({
  10522. argnames: [
  10523. new U2.AST_SymbolFunarg({
  10524. name: 'url'
  10525. }), new U2.AST_SymbolFunarg({
  10526. name: 'host'
  10527. }), new U2.AST_SymbolFunarg({
  10528. name: 'scheme'
  10529. })
  10530. ],
  10531. body: body
  10532. });
  10533. }
  10534. },
  10535. 'VirtualProfile': 'SwitchProfile',
  10536. 'RuleListProfile': {
  10537. includable: true,
  10538. inclusive: true,
  10539. create: function(profile) {
  10540. var ref2;
  10541. if (profile.profileType == null) {
  10542. profile.profileType = 'RuleListProfile';
  10543. }
  10544. if (profile.format == null) {
  10545. profile.format = (ref2 = exports.formatByType[profile.profileType]) != null ? ref2 : 'Switchy';
  10546. }
  10547. if (profile.defaultProfileName == null) {
  10548. profile.defaultProfileName = 'direct';
  10549. }
  10550. if (profile.matchProfileName == null) {
  10551. profile.matchProfileName = 'direct';
  10552. }
  10553. return profile.ruleList != null ? profile.ruleList : profile.ruleList = '';
  10554. },
  10555. directReferenceSet: function(profile) {
  10556. var i, len, name, ref2, ref3, refs;
  10557. if (profile.ruleList != null) {
  10558. refs = (ref2 = RuleList[profile.format]) != null ? typeof ref2.directReferenceSet === "function" ? ref2.directReferenceSet(profile) : void 0 : void 0;
  10559. if (refs) {
  10560. return refs;
  10561. }
  10562. }
  10563. refs = {};
  10564. ref3 = [profile.matchProfileName, profile.defaultProfileName];
  10565. for (i = 0, len = ref3.length; i < len; i++) {
  10566. name = ref3[i];
  10567. refs[exports.nameAsKey(name)] = name;
  10568. }
  10569. return refs;
  10570. },
  10571. replaceRef: function(profile, fromName, toName) {
  10572. var changed;
  10573. changed = false;
  10574. if (profile.defaultProfileName === fromName) {
  10575. profile.defaultProfileName = toName;
  10576. changed = true;
  10577. }
  10578. if (profile.matchProfileName === fromName) {
  10579. profile.matchProfileName = toName;
  10580. changed = true;
  10581. }
  10582. return changed;
  10583. },
  10584. analyze: function(profile) {
  10585. var format, formatHandler, ref2, ref3, ruleList;
  10586. format = (ref2 = profile.format) != null ? ref2 : exports.formatByType[profile.profileType];
  10587. formatHandler = RuleList[format];
  10588. if (!formatHandler) {
  10589. throw new Error("Unsupported rule list format " + format + "!");
  10590. }
  10591. ruleList = ((ref3 = profile.ruleList) != null ? ref3.trim() : void 0) || '';
  10592. if (formatHandler.preprocess != null) {
  10593. ruleList = formatHandler.preprocess(ruleList);
  10594. }
  10595. return formatHandler.parse(ruleList, profile.matchProfileName, profile.defaultProfileName);
  10596. },
  10597. match: function(profile, request) {
  10598. var result;
  10599. return result = exports.match(profile, request, 'SwitchProfile');
  10600. },
  10601. compile: function(profile) {
  10602. return exports.compile(profile, 'SwitchProfile');
  10603. },
  10604. updateUrl: function(profile) {
  10605. return profile.sourceUrl;
  10606. },
  10607. updateContentTypeHints: function() {
  10608. return ['!text/html', '!application/xhtml+xml', 'text/plain', '*'];
  10609. },
  10610. update: function(profile, data) {
  10611. var base, base1, format, formatHandler, formatName, original, ref2, result;
  10612. data = data.trim();
  10613. original = (ref2 = profile.format) != null ? ref2 : exports.formatByType[profile.profileType];
  10614. profile.profileType = 'RuleListProfile';
  10615. format = original;
  10616. if ((typeof (base = RuleList[format]).detect === "function" ? base.detect(data) : void 0) === false) {
  10617. format = null;
  10618. }
  10619. for (formatName in RuleList) {
  10620. if (!hasProp.call(RuleList, formatName)) continue;
  10621. result = typeof (base1 = RuleList[formatName]).detect === "function" ? base1.detect(data) : void 0;
  10622. if (result === true || (result !== false && (format == null))) {
  10623. profile.format = format = formatName;
  10624. }
  10625. }
  10626. if (format == null) {
  10627. format = original;
  10628. }
  10629. formatHandler = RuleList[format];
  10630. if (formatHandler.preprocess != null) {
  10631. data = formatHandler.preprocess(data);
  10632. }
  10633. if (profile.ruleList === data) {
  10634. return false;
  10635. }
  10636. profile.ruleList = data;
  10637. return true;
  10638. }
  10639. },
  10640. 'SwitchyRuleListProfile': 'RuleListProfile',
  10641. 'AutoProxyRuleListProfile': 'RuleListProfile'
  10642. }
  10643. };
  10644. },{"./conditions":61,"./rule_list":64,"./shexp_utils":65,"./utils":66,"uglify-js":67}],64:[function(require,module,exports){
  10645. var Buffer, Conditions, exports, strStartsWith,
  10646. hasProp = {}.hasOwnProperty;
  10647. Buffer = require('buffer').Buffer;
  10648. Conditions = require('./conditions');
  10649. strStartsWith = function(str, prefix) {
  10650. return str.substr(0, prefix.length) === prefix;
  10651. };
  10652. module.exports = exports = {
  10653. 'AutoProxy': {
  10654. magicPrefix: 'W0F1dG9Qcm94',
  10655. detect: function(text) {
  10656. if (strStartsWith(text, exports['AutoProxy'].magicPrefix)) {
  10657. return true;
  10658. } else if (strStartsWith(text, '[AutoProxy')) {
  10659. return true;
  10660. }
  10661. },
  10662. preprocess: function(text) {
  10663. if (strStartsWith(text, exports['AutoProxy'].magicPrefix)) {
  10664. text = new Buffer(text, 'base64').toString('utf8');
  10665. }
  10666. return text;
  10667. },
  10668. parse: function(text, matchProfileName, defaultProfileName) {
  10669. var cond, exclusive_rules, i, len, line, list, normal_rules, profile, ref, source;
  10670. normal_rules = [];
  10671. exclusive_rules = [];
  10672. ref = text.split(/\n|\r/);
  10673. for (i = 0, len = ref.length; i < len; i++) {
  10674. line = ref[i];
  10675. line = line.trim();
  10676. if (line.length === 0 || line[0] === '!' || line[0] === '[') {
  10677. continue;
  10678. }
  10679. source = line;
  10680. profile = matchProfileName;
  10681. list = normal_rules;
  10682. if (line[0] === '@' && line[1] === '@') {
  10683. profile = defaultProfileName;
  10684. list = exclusive_rules;
  10685. line = line.substring(2);
  10686. }
  10687. cond = line[0] === '/' ? {
  10688. conditionType: 'UrlRegexCondition',
  10689. pattern: line.substring(1, line.length - 1)
  10690. } : line[0] === '|' ? line[1] === '|' ? {
  10691. conditionType: 'HostWildcardCondition',
  10692. pattern: "*." + line.substring(2)
  10693. } : {
  10694. conditionType: 'UrlWildcardCondition',
  10695. pattern: line.substring(1) + "*"
  10696. } : line.indexOf('*') < 0 ? {
  10697. conditionType: 'KeywordCondition',
  10698. pattern: line
  10699. } : {
  10700. conditionType: 'UrlWildcardCondition',
  10701. pattern: 'http://*' + line + '*'
  10702. };
  10703. list.push({
  10704. condition: cond,
  10705. profileName: profile,
  10706. source: source
  10707. });
  10708. }
  10709. return exclusive_rules.concat(normal_rules);
  10710. }
  10711. },
  10712. 'Switchy': {
  10713. omegaPrefix: '[SwitchyOmega Conditions',
  10714. specialLineStart: "[;#@!",
  10715. detect: function(text) {
  10716. if (strStartsWith(text, exports['Switchy'].omegaPrefix)) {
  10717. return true;
  10718. }
  10719. },
  10720. parse: function(text, matchProfileName, defaultProfileName) {
  10721. var parser, switchy;
  10722. switchy = exports['Switchy'];
  10723. parser = switchy.getParser(text);
  10724. return switchy[parser](text, matchProfileName, defaultProfileName);
  10725. },
  10726. directReferenceSet: function(arg) {
  10727. var defaultProfileName, i, iSpace, len, line, matchProfileName, parser, profile, ref, refs, ruleList, switchy, text;
  10728. ruleList = arg.ruleList, matchProfileName = arg.matchProfileName, defaultProfileName = arg.defaultProfileName;
  10729. text = ruleList.trim();
  10730. switchy = exports['Switchy'];
  10731. parser = switchy.getParser(text);
  10732. if (parser !== 'parseOmega') {
  10733. return;
  10734. }
  10735. if (!/(^|\n)@with\s+results?(\r|\n|$)/i.test(text)) {
  10736. return;
  10737. }
  10738. refs = {};
  10739. ref = text.split(/\n|\r/);
  10740. for (i = 0, len = ref.length; i < len; i++) {
  10741. line = ref[i];
  10742. line = line.trim();
  10743. if (switchy.specialLineStart.indexOf(line[0]) < 0) {
  10744. iSpace = line.lastIndexOf(' +');
  10745. if (iSpace < 0) {
  10746. profile = defaultProfileName || 'direct';
  10747. } else {
  10748. profile = line.substr(iSpace + 2).trim();
  10749. }
  10750. refs['+' + profile] = profile;
  10751. }
  10752. }
  10753. return refs;
  10754. },
  10755. compose: function(arg, arg1) {
  10756. var defaultProfileName, eol, i, len, line, ref, rule, ruleList, rules, specialLineStart, useExclusive, withResult;
  10757. rules = arg.rules, defaultProfileName = arg.defaultProfileName;
  10758. ref = arg1 != null ? arg1 : {}, withResult = ref.withResult, useExclusive = ref.useExclusive;
  10759. eol = '\r\n';
  10760. ruleList = '[SwitchyOmega Conditions]' + eol;
  10761. if (useExclusive == null) {
  10762. useExclusive = !withResult;
  10763. }
  10764. if (withResult) {
  10765. ruleList += '@with result' + eol + eol;
  10766. } else {
  10767. ruleList += eol;
  10768. }
  10769. specialLineStart = exports['Switchy'].specialLineStart + '+';
  10770. for (i = 0, len = rules.length; i < len; i++) {
  10771. rule = rules[i];
  10772. if (rule.note) {
  10773. ruleList += '@note ' + rule.note + eol;
  10774. }
  10775. line = Conditions.str(rule.condition);
  10776. if (useExclusive && rule.profileName === defaultProfileName) {
  10777. line = '!' + line;
  10778. } else {
  10779. if (specialLineStart.indexOf(line[0]) >= 0) {
  10780. line = ': ' + line;
  10781. }
  10782. if (withResult) {
  10783. line += ' +' + rule.profileName;
  10784. }
  10785. }
  10786. ruleList += line + eol;
  10787. }
  10788. if (withResult) {
  10789. ruleList += eol + '* +' + defaultProfileName + eol;
  10790. }
  10791. return ruleList;
  10792. },
  10793. getParser: function(text) {
  10794. var parser, switchy;
  10795. switchy = exports['Switchy'];
  10796. parser = 'parseOmega';
  10797. if (!strStartsWith(text, switchy.omegaPrefix)) {
  10798. if (text[0] === '#' || text.indexOf('\n#') >= 0) {
  10799. parser = 'parseLegacy';
  10800. }
  10801. }
  10802. return parser;
  10803. },
  10804. conditionFromLegacyWildcard: function(pattern) {
  10805. var host;
  10806. if (pattern[0] === '@') {
  10807. pattern = pattern.substring(1);
  10808. } else {
  10809. if (pattern.indexOf('://') <= 0 && pattern[0] !== '*') {
  10810. pattern = '*' + pattern;
  10811. }
  10812. if (pattern[pattern.length - 1] !== '*') {
  10813. pattern += '*';
  10814. }
  10815. }
  10816. host = Conditions.urlWildcard2HostWildcard(pattern);
  10817. if (host) {
  10818. return {
  10819. conditionType: 'HostWildcardCondition',
  10820. pattern: host
  10821. };
  10822. } else {
  10823. return {
  10824. conditionType: 'UrlWildcardCondition',
  10825. pattern: pattern
  10826. };
  10827. }
  10828. },
  10829. parseLegacy: function(text, matchProfileName, defaultProfileName) {
  10830. var begin, cond, exclusive_rules, i, len, line, list, normal_rules, profile, ref, section, source;
  10831. normal_rules = [];
  10832. exclusive_rules = [];
  10833. begin = false;
  10834. section = 'WILDCARD';
  10835. ref = text.split(/\n|\r/);
  10836. for (i = 0, len = ref.length; i < len; i++) {
  10837. line = ref[i];
  10838. line = line.trim();
  10839. if (line.length === 0 || line[0] === ';') {
  10840. continue;
  10841. }
  10842. if (!begin) {
  10843. if (line.toUpperCase() === '#BEGIN') {
  10844. begin = true;
  10845. }
  10846. continue;
  10847. }
  10848. if (line.toUpperCase() === '#END') {
  10849. break;
  10850. }
  10851. if (line[0] === '[' && line[line.length - 1] === ']') {
  10852. section = line.substring(1, line.length - 1).toUpperCase();
  10853. continue;
  10854. }
  10855. source = line;
  10856. profile = matchProfileName;
  10857. list = normal_rules;
  10858. if (line[0] === '!') {
  10859. profile = defaultProfileName;
  10860. list = exclusive_rules;
  10861. line = line.substring(1);
  10862. }
  10863. cond = (function() {
  10864. switch (section) {
  10865. case 'WILDCARD':
  10866. return exports['Switchy'].conditionFromLegacyWildcard(line);
  10867. case 'REGEXP':
  10868. return {
  10869. conditionType: 'UrlRegexCondition',
  10870. pattern: line
  10871. };
  10872. default:
  10873. return null;
  10874. }
  10875. })();
  10876. if (cond != null) {
  10877. list.push({
  10878. condition: cond,
  10879. profileName: profile,
  10880. source: source
  10881. });
  10882. }
  10883. }
  10884. return exclusive_rules.concat(normal_rules);
  10885. },
  10886. parseOmega: function(text, matchProfileName, defaultProfileName, args) {
  10887. var cond, directive, error, exclusiveProfile, feature, i, iSpace, includeSource, j, len, len1, line, lno, noteForNextRule, profile, ref, ref1, rule, rules, rulesWithDefaultProfile, source, strict, withResult;
  10888. if (args == null) {
  10889. args = {};
  10890. }
  10891. strict = args.strict;
  10892. if (strict) {
  10893. error = function(fields) {
  10894. var err, key, value;
  10895. err = new Error(fields.message);
  10896. for (key in fields) {
  10897. if (!hasProp.call(fields, key)) continue;
  10898. value = fields[key];
  10899. err[key] = value;
  10900. }
  10901. throw err;
  10902. };
  10903. }
  10904. includeSource = (ref = args.source) != null ? ref : true;
  10905. rules = [];
  10906. rulesWithDefaultProfile = [];
  10907. withResult = false;
  10908. exclusiveProfile = null;
  10909. noteForNextRule = null;
  10910. lno = 0;
  10911. ref1 = text.split(/\n|\r/);
  10912. for (i = 0, len = ref1.length; i < len; i++) {
  10913. line = ref1[i];
  10914. lno++;
  10915. line = line.trim();
  10916. if (line.length === 0) {
  10917. continue;
  10918. }
  10919. switch (line[0]) {
  10920. case '[':
  10921. continue;
  10922. case ';':
  10923. continue;
  10924. case '@':
  10925. iSpace = line.indexOf(' ');
  10926. if (iSpace < 0) {
  10927. iSpace = line.length;
  10928. }
  10929. directive = line.substr(1, iSpace - 1);
  10930. line = line.substr(iSpace + 1).trim();
  10931. switch (directive.toUpperCase()) {
  10932. case 'WITH':
  10933. feature = line.toUpperCase();
  10934. if (feature === 'RESULT' || feature === 'RESULTS') {
  10935. withResult = true;
  10936. }
  10937. break;
  10938. case 'NOTE':
  10939. noteForNextRule = line;
  10940. }
  10941. continue;
  10942. }
  10943. source = null;
  10944. if (strict) {
  10945. exclusiveProfile = null;
  10946. }
  10947. if (line[0] === '!') {
  10948. profile = withResult ? null : defaultProfileName;
  10949. source = line;
  10950. line = line.substr(1);
  10951. } else if (withResult) {
  10952. iSpace = line.lastIndexOf(' +');
  10953. if (iSpace < 0) {
  10954. if (typeof error === "function") {
  10955. error({
  10956. message: "Missing result profile name: " + line,
  10957. reason: 'missingResultProfile',
  10958. source: line,
  10959. sourceLineNo: lno
  10960. });
  10961. }
  10962. continue;
  10963. }
  10964. profile = line.substr(iSpace + 2).trim();
  10965. line = line.substr(0, iSpace).trim();
  10966. if (line === '*') {
  10967. exclusiveProfile = profile;
  10968. }
  10969. } else {
  10970. profile = matchProfileName;
  10971. }
  10972. cond = Conditions.fromStr(line);
  10973. if (!cond) {
  10974. if (typeof error === "function") {
  10975. error({
  10976. message: "Invalid rule: " + line,
  10977. reason: 'invalidRule',
  10978. source: source != null ? source : line,
  10979. sourceLineNo: lno
  10980. });
  10981. }
  10982. continue;
  10983. }
  10984. rule = {
  10985. condition: cond,
  10986. profileName: profile,
  10987. source: includeSource ? source != null ? source : line : void 0
  10988. };
  10989. if (noteForNextRule != null) {
  10990. rule.note = noteForNextRule;
  10991. noteForNextRule = null;
  10992. }
  10993. rules.push(rule);
  10994. if (!profile) {
  10995. rulesWithDefaultProfile.push(rule);
  10996. }
  10997. }
  10998. if (withResult) {
  10999. if (!exclusiveProfile) {
  11000. if (strict) {
  11001. if (typeof error === "function") {
  11002. error({
  11003. message: "Missing default rule with catch-all '*' condition",
  11004. reason: 'noDefaultRule'
  11005. });
  11006. }
  11007. }
  11008. exclusiveProfile = defaultProfileName || 'direct';
  11009. }
  11010. for (j = 0, len1 = rulesWithDefaultProfile.length; j < len1; j++) {
  11011. rule = rulesWithDefaultProfile[j];
  11012. rule.profileName = exclusiveProfile;
  11013. }
  11014. }
  11015. return rules;
  11016. }
  11017. }
  11018. };
  11019. },{"./conditions":61,"buffer":2}],65:[function(require,module,exports){
  11020. var exports;
  11021. module.exports = exports = {
  11022. regExpMetaChars: (function() {
  11023. var chars, i, j, ref, set;
  11024. chars = '\\[\^$.|?*+(){}/';
  11025. set = {};
  11026. for (i = j = 0, ref = chars.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
  11027. set[chars.charCodeAt(i)] = true;
  11028. }
  11029. return set;
  11030. })(),
  11031. escapeSlash: function(pattern) {
  11032. var charCodeBackSlash, charCodeSlash, code, escaped, i, j, ref, result, start;
  11033. charCodeSlash = 47;
  11034. charCodeBackSlash = 92;
  11035. escaped = false;
  11036. start = 0;
  11037. result = '';
  11038. for (i = j = 0, ref = pattern.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
  11039. code = pattern.charCodeAt(i);
  11040. if (code === charCodeSlash && !escaped) {
  11041. result += pattern.substring(start, i);
  11042. result += '\\';
  11043. start = i;
  11044. }
  11045. escaped = code === charCodeBackSlash && !escaped;
  11046. }
  11047. return result += pattern.substr(start);
  11048. },
  11049. shExp2RegExp: function(pattern, options) {
  11050. var charCodeAsterisk, charCodeQuestion, code, end, i, j, ref, ref1, regex, start, trimAsterisk;
  11051. trimAsterisk = (options != null ? options.trimAsterisk : void 0) || false;
  11052. start = 0;
  11053. end = pattern.length;
  11054. charCodeAsterisk = 42;
  11055. charCodeQuestion = 63;
  11056. if (trimAsterisk) {
  11057. while (start < end && pattern.charCodeAt(start) === charCodeAsterisk) {
  11058. start++;
  11059. }
  11060. while (start < end && pattern.charCodeAt(end - 1) === charCodeAsterisk) {
  11061. end--;
  11062. }
  11063. if (end - start === 1 && pattern.charCodeAt(start) === charCodeAsterisk) {
  11064. return '';
  11065. }
  11066. }
  11067. regex = '';
  11068. if (start === 0) {
  11069. regex += '^';
  11070. }
  11071. for (i = j = ref = start, ref1 = end; ref <= ref1 ? j < ref1 : j > ref1; i = ref <= ref1 ? ++j : --j) {
  11072. code = pattern.charCodeAt(i);
  11073. switch (code) {
  11074. case charCodeAsterisk:
  11075. regex += '.*';
  11076. break;
  11077. case charCodeQuestion:
  11078. regex += '.';
  11079. break;
  11080. default:
  11081. if (exports.regExpMetaChars[code] >= 0) {
  11082. regex += '\\';
  11083. }
  11084. regex += pattern[i];
  11085. }
  11086. }
  11087. if (end === pattern.length) {
  11088. regex += '$';
  11089. }
  11090. return regex;
  11091. }
  11092. };
  11093. },{}],66:[function(require,module,exports){
  11094. var AttachedCache, Revision, Url, tld;
  11095. Revision = {
  11096. fromTime: function(time) {
  11097. time = time ? new Date(time) : new Date();
  11098. return time.getTime().toString(16);
  11099. },
  11100. compare: function(a, b) {
  11101. if (!a && !b) {
  11102. return 0;
  11103. }
  11104. if (!a) {
  11105. return -1;
  11106. }
  11107. if (!b) {
  11108. return 1;
  11109. }
  11110. if (a.length > b.length) {
  11111. return 1;
  11112. }
  11113. if (a.length < b.length) {
  11114. return -1;
  11115. }
  11116. if (a > b) {
  11117. return 1;
  11118. }
  11119. if (a < b) {
  11120. return -1;
  11121. }
  11122. return 0;
  11123. }
  11124. };
  11125. exports.Revision = Revision;
  11126. AttachedCache = (function() {
  11127. function AttachedCache(opt_prop, tag1) {
  11128. this.tag = tag1;
  11129. this.prop = opt_prop;
  11130. if (typeof this.tag === 'undefined') {
  11131. this.tag = opt_prop;
  11132. this.prop = '_cache';
  11133. }
  11134. }
  11135. AttachedCache.prototype.get = function(obj, otherwise) {
  11136. var cache, tag, value;
  11137. tag = this.tag(obj);
  11138. cache = this._getCache(obj);
  11139. if ((cache != null) && cache.tag === tag) {
  11140. return cache.value;
  11141. }
  11142. value = typeof otherwise === 'function' ? otherwise() : otherwise;
  11143. this._setCache(obj, {
  11144. tag: tag,
  11145. value: value
  11146. });
  11147. return value;
  11148. };
  11149. AttachedCache.prototype.drop = function(obj) {
  11150. if (obj[this.prop] != null) {
  11151. return obj[this.prop] = void 0;
  11152. }
  11153. };
  11154. AttachedCache.prototype._getCache = function(obj) {
  11155. return obj[this.prop];
  11156. };
  11157. AttachedCache.prototype._setCache = function(obj, value) {
  11158. if (!Object.prototype.hasOwnProperty.call(obj, this.prop)) {
  11159. Object.defineProperty(obj, this.prop, {
  11160. writable: true
  11161. });
  11162. }
  11163. return obj[this.prop] = value;
  11164. };
  11165. return AttachedCache;
  11166. })();
  11167. exports.AttachedCache = AttachedCache;
  11168. tld = require('tldjs');
  11169. exports.isIp = function(domain) {
  11170. var lastCharCode;
  11171. if (domain.indexOf(':') > 0) {
  11172. return true;
  11173. }
  11174. lastCharCode = domain.charCodeAt(domain.length - 1);
  11175. if ((48 <= lastCharCode && lastCharCode <= 57)) {
  11176. return true;
  11177. }
  11178. return false;
  11179. };
  11180. exports.getBaseDomain = function(domain) {
  11181. var ref;
  11182. if (exports.isIp(domain)) {
  11183. return domain;
  11184. }
  11185. return (ref = tld.getDomain(domain)) != null ? ref : domain;
  11186. };
  11187. exports.wildcardForDomain = function(domain) {
  11188. if (exports.isIp(domain)) {
  11189. return domain;
  11190. }
  11191. return '*.' + exports.getBaseDomain(domain);
  11192. };
  11193. Url = require('url');
  11194. exports.wildcardForUrl = function(url) {
  11195. var domain;
  11196. domain = Url.parse(url).hostname;
  11197. return exports.wildcardForDomain(domain);
  11198. };
  11199. },{"tldjs":45,"url":60}],67:[function(require,module,exports){
  11200. require('uglify-js-real');
  11201. module.exports = UglifyJS;
  11202. },{"uglify-js-real":68}],68:[function(require,module,exports){
  11203. (function(exports, global) {
  11204. global["UglifyJS"] = exports;
  11205. "use strict";
  11206. function array_to_hash(a) {
  11207. var ret = Object.create(null);
  11208. for (var i = 0; i < a.length; ++i) ret[a[i]] = true;
  11209. return ret;
  11210. }
  11211. function slice(a, start) {
  11212. return Array.prototype.slice.call(a, start || 0);
  11213. }
  11214. function characters(str) {
  11215. return str.split("");
  11216. }
  11217. function member(name, array) {
  11218. for (var i = array.length; --i >= 0; ) if (array[i] == name) return true;
  11219. return false;
  11220. }
  11221. function find_if(func, array) {
  11222. for (var i = 0, n = array.length; i < n; ++i) {
  11223. if (func(array[i])) return array[i];
  11224. }
  11225. }
  11226. function repeat_string(str, i) {
  11227. if (i <= 0) return "";
  11228. if (i == 1) return str;
  11229. var d = repeat_string(str, i >> 1);
  11230. d += d;
  11231. if (i & 1) d += str;
  11232. return d;
  11233. }
  11234. function DefaultsError(msg, defs) {
  11235. Error.call(this, msg);
  11236. this.msg = msg;
  11237. this.defs = defs;
  11238. }
  11239. DefaultsError.prototype = Object.create(Error.prototype);
  11240. DefaultsError.prototype.constructor = DefaultsError;
  11241. DefaultsError.croak = function(msg, defs) {
  11242. throw new DefaultsError(msg, defs);
  11243. };
  11244. function defaults(args, defs, croak) {
  11245. if (args === true) args = {};
  11246. var ret = args || {};
  11247. if (croak) for (var i in ret) if (ret.hasOwnProperty(i) && !defs.hasOwnProperty(i)) DefaultsError.croak("`" + i + "` is not a supported option", defs);
  11248. for (var i in defs) if (defs.hasOwnProperty(i)) {
  11249. ret[i] = args && args.hasOwnProperty(i) ? args[i] : defs[i];
  11250. }
  11251. return ret;
  11252. }
  11253. function merge(obj, ext) {
  11254. for (var i in ext) if (ext.hasOwnProperty(i)) {
  11255. obj[i] = ext[i];
  11256. }
  11257. return obj;
  11258. }
  11259. function noop() {}
  11260. var MAP = function() {
  11261. function MAP(a, f, backwards) {
  11262. var ret = [], top = [], i;
  11263. function doit() {
  11264. var val = f(a[i], i);
  11265. var is_last = val instanceof Last;
  11266. if (is_last) val = val.v;
  11267. if (val instanceof AtTop) {
  11268. val = val.v;
  11269. if (val instanceof Splice) {
  11270. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  11271. } else {
  11272. top.push(val);
  11273. }
  11274. } else if (val !== skip) {
  11275. if (val instanceof Splice) {
  11276. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  11277. } else {
  11278. ret.push(val);
  11279. }
  11280. }
  11281. return is_last;
  11282. }
  11283. if (a instanceof Array) {
  11284. if (backwards) {
  11285. for (i = a.length; --i >= 0; ) if (doit()) break;
  11286. ret.reverse();
  11287. top.reverse();
  11288. } else {
  11289. for (i = 0; i < a.length; ++i) if (doit()) break;
  11290. }
  11291. } else {
  11292. for (i in a) if (a.hasOwnProperty(i)) if (doit()) break;
  11293. }
  11294. return top.concat(ret);
  11295. }
  11296. MAP.at_top = function(val) {
  11297. return new AtTop(val);
  11298. };
  11299. MAP.splice = function(val) {
  11300. return new Splice(val);
  11301. };
  11302. MAP.last = function(val) {
  11303. return new Last(val);
  11304. };
  11305. var skip = MAP.skip = {};
  11306. function AtTop(val) {
  11307. this.v = val;
  11308. }
  11309. function Splice(val) {
  11310. this.v = val;
  11311. }
  11312. function Last(val) {
  11313. this.v = val;
  11314. }
  11315. return MAP;
  11316. }();
  11317. function push_uniq(array, el) {
  11318. if (array.indexOf(el) < 0) array.push(el);
  11319. }
  11320. function string_template(text, props) {
  11321. return text.replace(/\{(.+?)\}/g, function(str, p) {
  11322. return props[p];
  11323. });
  11324. }
  11325. function remove(array, el) {
  11326. for (var i = array.length; --i >= 0; ) {
  11327. if (array[i] === el) array.splice(i, 1);
  11328. }
  11329. }
  11330. function mergeSort(array, cmp) {
  11331. if (array.length < 2) return array.slice();
  11332. function merge(a, b) {
  11333. var r = [], ai = 0, bi = 0, i = 0;
  11334. while (ai < a.length && bi < b.length) {
  11335. cmp(a[ai], b[bi]) <= 0 ? r[i++] = a[ai++] : r[i++] = b[bi++];
  11336. }
  11337. if (ai < a.length) r.push.apply(r, a.slice(ai));
  11338. if (bi < b.length) r.push.apply(r, b.slice(bi));
  11339. return r;
  11340. }
  11341. function _ms(a) {
  11342. if (a.length <= 1) return a;
  11343. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  11344. left = _ms(left);
  11345. right = _ms(right);
  11346. return merge(left, right);
  11347. }
  11348. return _ms(array);
  11349. }
  11350. function set_difference(a, b) {
  11351. return a.filter(function(el) {
  11352. return b.indexOf(el) < 0;
  11353. });
  11354. }
  11355. function set_intersection(a, b) {
  11356. return a.filter(function(el) {
  11357. return b.indexOf(el) >= 0;
  11358. });
  11359. }
  11360. function makePredicate(words) {
  11361. if (!(words instanceof Array)) words = words.split(" ");
  11362. if (typeof UglifyJS_NoUnsafeEval !== "undefined") {
  11363. return function(str) {
  11364. return words.indexOf(str) >= 0;
  11365. };
  11366. }
  11367. var f = "", cats = [];
  11368. out: for (var i = 0; i < words.length; ++i) {
  11369. for (var j = 0; j < cats.length; ++j) if (cats[j][0].length == words[i].length) {
  11370. cats[j].push(words[i]);
  11371. continue out;
  11372. }
  11373. cats.push([ words[i] ]);
  11374. }
  11375. function compareTo(arr) {
  11376. if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";";
  11377. f += "switch(str){";
  11378. for (var i = 0; i < arr.length; ++i) f += "case " + JSON.stringify(arr[i]) + ":";
  11379. f += "return true}return false;";
  11380. }
  11381. if (cats.length > 3) {
  11382. cats.sort(function(a, b) {
  11383. return b.length - a.length;
  11384. });
  11385. f += "switch(str.length){";
  11386. for (var i = 0; i < cats.length; ++i) {
  11387. var cat = cats[i];
  11388. f += "case " + cat[0].length + ":";
  11389. compareTo(cat);
  11390. }
  11391. f += "}";
  11392. } else {
  11393. compareTo(words);
  11394. }
  11395. return new Function("str", f);
  11396. }
  11397. function all(array, predicate) {
  11398. for (var i = array.length; --i >= 0; ) if (!predicate(array[i])) return false;
  11399. return true;
  11400. }
  11401. function Dictionary() {
  11402. this._values = Object.create(null);
  11403. this._size = 0;
  11404. }
  11405. Dictionary.prototype = {
  11406. set: function(key, val) {
  11407. if (!this.has(key)) ++this._size;
  11408. this._values["$" + key] = val;
  11409. return this;
  11410. },
  11411. add: function(key, val) {
  11412. if (this.has(key)) {
  11413. this.get(key).push(val);
  11414. } else {
  11415. this.set(key, [ val ]);
  11416. }
  11417. return this;
  11418. },
  11419. get: function(key) {
  11420. return this._values["$" + key];
  11421. },
  11422. del: function(key) {
  11423. if (this.has(key)) {
  11424. --this._size;
  11425. delete this._values["$" + key];
  11426. }
  11427. return this;
  11428. },
  11429. has: function(key) {
  11430. return "$" + key in this._values;
  11431. },
  11432. each: function(f) {
  11433. for (var i in this._values) f(this._values[i], i.substr(1));
  11434. },
  11435. size: function() {
  11436. return this._size;
  11437. },
  11438. map: function(f) {
  11439. var ret = [];
  11440. for (var i in this._values) ret.push(f(this._values[i], i.substr(1)));
  11441. return ret;
  11442. }
  11443. };
  11444. "use strict";
  11445. function DEFNODE(type, props, methods, base) {
  11446. if (arguments.length < 4) base = AST_Node;
  11447. if (!props) props = []; else props = props.split(/\s+/);
  11448. var self_props = props;
  11449. if (base && base.PROPS) props = props.concat(base.PROPS);
  11450. var proto = base && new base();
  11451. var ctor;
  11452. if (typeof UglifyJS_NoUnsafeEval === "undefined") {
  11453. var code = "return function AST_" + type + "(props){ if (props) { ";
  11454. for (var i = props.length; --i >= 0; ) {
  11455. code += "this." + props[i] + " = props." + props[i] + ";";
  11456. }
  11457. if (proto && proto.initialize || methods && methods.initialize) code += "this.initialize();";
  11458. code += "}}";
  11459. ctor = new Function(code)();
  11460. } else {
  11461. ctor = function(values) {
  11462. if (values) {
  11463. for (var i = props.length; --i >= 0; ) this[props[i]] = values[props[i]];
  11464. if (proto && proto.initialize || methods && methods.initialize) this.initialize();
  11465. }
  11466. };
  11467. }
  11468. if (proto) {
  11469. ctor.prototype = proto;
  11470. ctor.BASE = base;
  11471. }
  11472. if (base) base.SUBCLASSES.push(ctor);
  11473. ctor.prototype.CTOR = ctor;
  11474. ctor.PROPS = props || null;
  11475. ctor.SELF_PROPS = self_props;
  11476. ctor.SUBCLASSES = [];
  11477. if (type) {
  11478. ctor.prototype.TYPE = ctor.TYPE = type;
  11479. }
  11480. if (methods) for (i in methods) if (methods.hasOwnProperty(i)) {
  11481. if (/^\$/.test(i)) {
  11482. ctor[i.substr(1)] = methods[i];
  11483. } else {
  11484. ctor.prototype[i] = methods[i];
  11485. }
  11486. }
  11487. ctor.DEFMETHOD = function(name, method) {
  11488. this.prototype[name] = method;
  11489. };
  11490. return ctor;
  11491. }
  11492. var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", {}, null);
  11493. var AST_Node = DEFNODE("Node", "start end", {
  11494. clone: function() {
  11495. return new this.CTOR(this);
  11496. },
  11497. $documentation: "Base class of all AST nodes",
  11498. $propdoc: {
  11499. start: "[AST_Token] The first token of this node",
  11500. end: "[AST_Token] The last token of this node"
  11501. },
  11502. _walk: function(visitor) {
  11503. return visitor._visit(this);
  11504. },
  11505. walk: function(visitor) {
  11506. return this._walk(visitor);
  11507. }
  11508. }, null);
  11509. AST_Node.warn_function = null;
  11510. AST_Node.warn = function(txt, props) {
  11511. if (AST_Node.warn_function) AST_Node.warn_function(string_template(txt, props));
  11512. };
  11513. var AST_Statement = DEFNODE("Statement", null, {
  11514. $documentation: "Base class of all statements"
  11515. });
  11516. var AST_Debugger = DEFNODE("Debugger", null, {
  11517. $documentation: "Represents a debugger statement"
  11518. }, AST_Statement);
  11519. var AST_Directive = DEFNODE("Directive", "value scope", {
  11520. $documentation: 'Represents a directive, like "use strict";',
  11521. $propdoc: {
  11522. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  11523. scope: "[AST_Scope/S] The scope that this directive affects"
  11524. }
  11525. }, AST_Statement);
  11526. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
  11527. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  11528. $propdoc: {
  11529. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  11530. },
  11531. _walk: function(visitor) {
  11532. return visitor._visit(this, function() {
  11533. this.body._walk(visitor);
  11534. });
  11535. }
  11536. }, AST_Statement);
  11537. function walk_body(node, visitor) {
  11538. if (node.body instanceof AST_Statement) {
  11539. node.body._walk(visitor);
  11540. } else node.body.forEach(function(stat) {
  11541. stat._walk(visitor);
  11542. });
  11543. }
  11544. var AST_Block = DEFNODE("Block", "body", {
  11545. $documentation: "A body of statements (usually bracketed)",
  11546. $propdoc: {
  11547. body: "[AST_Statement*] an array of statements"
  11548. },
  11549. _walk: function(visitor) {
  11550. return visitor._visit(this, function() {
  11551. walk_body(this, visitor);
  11552. });
  11553. }
  11554. }, AST_Statement);
  11555. var AST_BlockStatement = DEFNODE("BlockStatement", null, {
  11556. $documentation: "A block statement"
  11557. }, AST_Block);
  11558. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
  11559. $documentation: "The empty statement (empty block or simply a semicolon)",
  11560. _walk: function(visitor) {
  11561. return visitor._visit(this);
  11562. }
  11563. }, AST_Statement);
  11564. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", {
  11565. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  11566. $propdoc: {
  11567. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  11568. },
  11569. _walk: function(visitor) {
  11570. return visitor._visit(this, function() {
  11571. this.body._walk(visitor);
  11572. });
  11573. }
  11574. }, AST_Statement);
  11575. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
  11576. $documentation: "Statement with a label",
  11577. $propdoc: {
  11578. label: "[AST_Label] a label definition"
  11579. },
  11580. _walk: function(visitor) {
  11581. return visitor._visit(this, function() {
  11582. this.label._walk(visitor);
  11583. this.body._walk(visitor);
  11584. });
  11585. }
  11586. }, AST_StatementWithBody);
  11587. var AST_IterationStatement = DEFNODE("IterationStatement", null, {
  11588. $documentation: "Internal class. All loops inherit from it."
  11589. }, AST_StatementWithBody);
  11590. var AST_DWLoop = DEFNODE("DWLoop", "condition", {
  11591. $documentation: "Base class for do/while statements",
  11592. $propdoc: {
  11593. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  11594. },
  11595. _walk: function(visitor) {
  11596. return visitor._visit(this, function() {
  11597. this.condition._walk(visitor);
  11598. this.body._walk(visitor);
  11599. });
  11600. }
  11601. }, AST_IterationStatement);
  11602. var AST_Do = DEFNODE("Do", null, {
  11603. $documentation: "A `do` statement"
  11604. }, AST_DWLoop);
  11605. var AST_While = DEFNODE("While", null, {
  11606. $documentation: "A `while` statement"
  11607. }, AST_DWLoop);
  11608. var AST_For = DEFNODE("For", "init condition step", {
  11609. $documentation: "A `for` statement",
  11610. $propdoc: {
  11611. init: "[AST_Node?] the `for` initialization code, or null if empty",
  11612. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  11613. step: "[AST_Node?] the `for` update clause, or null if empty"
  11614. },
  11615. _walk: function(visitor) {
  11616. return visitor._visit(this, function() {
  11617. if (this.init) this.init._walk(visitor);
  11618. if (this.condition) this.condition._walk(visitor);
  11619. if (this.step) this.step._walk(visitor);
  11620. this.body._walk(visitor);
  11621. });
  11622. }
  11623. }, AST_IterationStatement);
  11624. var AST_ForIn = DEFNODE("ForIn", "init name object", {
  11625. $documentation: "A `for ... in` statement",
  11626. $propdoc: {
  11627. init: "[AST_Node] the `for/in` initialization code",
  11628. name: "[AST_SymbolRef?] the loop variable, only if `init` is AST_Var",
  11629. object: "[AST_Node] the object that we're looping through"
  11630. },
  11631. _walk: function(visitor) {
  11632. return visitor._visit(this, function() {
  11633. this.init._walk(visitor);
  11634. this.object._walk(visitor);
  11635. this.body._walk(visitor);
  11636. });
  11637. }
  11638. }, AST_IterationStatement);
  11639. var AST_With = DEFNODE("With", "expression", {
  11640. $documentation: "A `with` statement",
  11641. $propdoc: {
  11642. expression: "[AST_Node] the `with` expression"
  11643. },
  11644. _walk: function(visitor) {
  11645. return visitor._visit(this, function() {
  11646. this.expression._walk(visitor);
  11647. this.body._walk(visitor);
  11648. });
  11649. }
  11650. }, AST_StatementWithBody);
  11651. var AST_Scope = DEFNODE("Scope", "directives variables functions uses_with uses_eval parent_scope enclosed cname", {
  11652. $documentation: "Base class for all statements introducing a lexical scope",
  11653. $propdoc: {
  11654. directives: "[string*/S] an array of directives declared in this scope",
  11655. variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  11656. functions: "[Object/S] like `variables`, but only lists function declarations",
  11657. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  11658. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  11659. parent_scope: "[AST_Scope?/S] link to the parent scope",
  11660. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  11661. cname: "[integer/S] current index for mangling variables (used internally by the mangler)"
  11662. }
  11663. }, AST_Block);
  11664. var AST_Toplevel = DEFNODE("Toplevel", "globals", {
  11665. $documentation: "The toplevel scope",
  11666. $propdoc: {
  11667. globals: "[Object/S] a map of name -> SymbolDef for all undeclared names"
  11668. },
  11669. wrap_enclose: function(arg_parameter_pairs) {
  11670. var self = this;
  11671. var args = [];
  11672. var parameters = [];
  11673. arg_parameter_pairs.forEach(function(pair) {
  11674. var splitAt = pair.lastIndexOf(":");
  11675. args.push(pair.substr(0, splitAt));
  11676. parameters.push(pair.substr(splitAt + 1));
  11677. });
  11678. var wrapped_tl = "(function(" + parameters.join(",") + "){ '$ORIG'; })(" + args.join(",") + ")";
  11679. wrapped_tl = parse(wrapped_tl);
  11680. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node) {
  11681. if (node instanceof AST_Directive && node.value == "$ORIG") {
  11682. return MAP.splice(self.body);
  11683. }
  11684. }));
  11685. return wrapped_tl;
  11686. },
  11687. wrap_commonjs: function(name, export_all) {
  11688. var self = this;
  11689. var to_export = [];
  11690. if (export_all) {
  11691. self.figure_out_scope();
  11692. self.walk(new TreeWalker(function(node) {
  11693. if (node instanceof AST_SymbolDeclaration && node.definition().global) {
  11694. if (!find_if(function(n) {
  11695. return n.name == node.name;
  11696. }, to_export)) to_export.push(node);
  11697. }
  11698. }));
  11699. }
  11700. var wrapped_tl = "(function(exports, global){ global['" + name + "'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";
  11701. wrapped_tl = parse(wrapped_tl);
  11702. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node) {
  11703. if (node instanceof AST_SimpleStatement) {
  11704. node = node.body;
  11705. if (node instanceof AST_String) switch (node.getValue()) {
  11706. case "$ORIG":
  11707. return MAP.splice(self.body);
  11708. case "$EXPORTS":
  11709. var body = [];
  11710. to_export.forEach(function(sym) {
  11711. body.push(new AST_SimpleStatement({
  11712. body: new AST_Assign({
  11713. left: new AST_Sub({
  11714. expression: new AST_SymbolRef({
  11715. name: "exports"
  11716. }),
  11717. property: new AST_String({
  11718. value: sym.name
  11719. })
  11720. }),
  11721. operator: "=",
  11722. right: new AST_SymbolRef(sym)
  11723. })
  11724. }));
  11725. });
  11726. return MAP.splice(body);
  11727. }
  11728. }
  11729. }));
  11730. return wrapped_tl;
  11731. }
  11732. }, AST_Scope);
  11733. var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments", {
  11734. $documentation: "Base class for functions",
  11735. $propdoc: {
  11736. name: "[AST_SymbolDeclaration?] the name of this function",
  11737. argnames: "[AST_SymbolFunarg*] array of function arguments",
  11738. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array"
  11739. },
  11740. _walk: function(visitor) {
  11741. return visitor._visit(this, function() {
  11742. if (this.name) this.name._walk(visitor);
  11743. this.argnames.forEach(function(arg) {
  11744. arg._walk(visitor);
  11745. });
  11746. walk_body(this, visitor);
  11747. });
  11748. }
  11749. }, AST_Scope);
  11750. var AST_Accessor = DEFNODE("Accessor", null, {
  11751. $documentation: "A setter/getter function. The `name` property is always null."
  11752. }, AST_Lambda);
  11753. var AST_Function = DEFNODE("Function", null, {
  11754. $documentation: "A function expression"
  11755. }, AST_Lambda);
  11756. var AST_Defun = DEFNODE("Defun", null, {
  11757. $documentation: "A function definition"
  11758. }, AST_Lambda);
  11759. var AST_Jump = DEFNODE("Jump", null, {
  11760. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  11761. }, AST_Statement);
  11762. var AST_Exit = DEFNODE("Exit", "value", {
  11763. $documentation: "Base class for “exits” (`return` and `throw`)",
  11764. $propdoc: {
  11765. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  11766. },
  11767. _walk: function(visitor) {
  11768. return visitor._visit(this, this.value && function() {
  11769. this.value._walk(visitor);
  11770. });
  11771. }
  11772. }, AST_Jump);
  11773. var AST_Return = DEFNODE("Return", null, {
  11774. $documentation: "A `return` statement"
  11775. }, AST_Exit);
  11776. var AST_Throw = DEFNODE("Throw", null, {
  11777. $documentation: "A `throw` statement"
  11778. }, AST_Exit);
  11779. var AST_LoopControl = DEFNODE("LoopControl", "label", {
  11780. $documentation: "Base class for loop control statements (`break` and `continue`)",
  11781. $propdoc: {
  11782. label: "[AST_LabelRef?] the label, or null if none"
  11783. },
  11784. _walk: function(visitor) {
  11785. return visitor._visit(this, this.label && function() {
  11786. this.label._walk(visitor);
  11787. });
  11788. }
  11789. }, AST_Jump);
  11790. var AST_Break = DEFNODE("Break", null, {
  11791. $documentation: "A `break` statement"
  11792. }, AST_LoopControl);
  11793. var AST_Continue = DEFNODE("Continue", null, {
  11794. $documentation: "A `continue` statement"
  11795. }, AST_LoopControl);
  11796. var AST_If = DEFNODE("If", "condition alternative", {
  11797. $documentation: "A `if` statement",
  11798. $propdoc: {
  11799. condition: "[AST_Node] the `if` condition",
  11800. alternative: "[AST_Statement?] the `else` part, or null if not present"
  11801. },
  11802. _walk: function(visitor) {
  11803. return visitor._visit(this, function() {
  11804. this.condition._walk(visitor);
  11805. this.body._walk(visitor);
  11806. if (this.alternative) this.alternative._walk(visitor);
  11807. });
  11808. }
  11809. }, AST_StatementWithBody);
  11810. var AST_Switch = DEFNODE("Switch", "expression", {
  11811. $documentation: "A `switch` statement",
  11812. $propdoc: {
  11813. expression: "[AST_Node] the `switch` “discriminant”"
  11814. },
  11815. _walk: function(visitor) {
  11816. return visitor._visit(this, function() {
  11817. this.expression._walk(visitor);
  11818. walk_body(this, visitor);
  11819. });
  11820. }
  11821. }, AST_Block);
  11822. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
  11823. $documentation: "Base class for `switch` branches"
  11824. }, AST_Block);
  11825. var AST_Default = DEFNODE("Default", null, {
  11826. $documentation: "A `default` switch branch"
  11827. }, AST_SwitchBranch);
  11828. var AST_Case = DEFNODE("Case", "expression", {
  11829. $documentation: "A `case` switch branch",
  11830. $propdoc: {
  11831. expression: "[AST_Node] the `case` expression"
  11832. },
  11833. _walk: function(visitor) {
  11834. return visitor._visit(this, function() {
  11835. this.expression._walk(visitor);
  11836. walk_body(this, visitor);
  11837. });
  11838. }
  11839. }, AST_SwitchBranch);
  11840. var AST_Try = DEFNODE("Try", "bcatch bfinally", {
  11841. $documentation: "A `try` statement",
  11842. $propdoc: {
  11843. bcatch: "[AST_Catch?] the catch block, or null if not present",
  11844. bfinally: "[AST_Finally?] the finally block, or null if not present"
  11845. },
  11846. _walk: function(visitor) {
  11847. return visitor._visit(this, function() {
  11848. walk_body(this, visitor);
  11849. if (this.bcatch) this.bcatch._walk(visitor);
  11850. if (this.bfinally) this.bfinally._walk(visitor);
  11851. });
  11852. }
  11853. }, AST_Block);
  11854. var AST_Catch = DEFNODE("Catch", "argname", {
  11855. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  11856. $propdoc: {
  11857. argname: "[AST_SymbolCatch] symbol for the exception"
  11858. },
  11859. _walk: function(visitor) {
  11860. return visitor._visit(this, function() {
  11861. this.argname._walk(visitor);
  11862. walk_body(this, visitor);
  11863. });
  11864. }
  11865. }, AST_Block);
  11866. var AST_Finally = DEFNODE("Finally", null, {
  11867. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  11868. }, AST_Block);
  11869. var AST_Definitions = DEFNODE("Definitions", "definitions", {
  11870. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  11871. $propdoc: {
  11872. definitions: "[AST_VarDef*] array of variable definitions"
  11873. },
  11874. _walk: function(visitor) {
  11875. return visitor._visit(this, function() {
  11876. this.definitions.forEach(function(def) {
  11877. def._walk(visitor);
  11878. });
  11879. });
  11880. }
  11881. }, AST_Statement);
  11882. var AST_Var = DEFNODE("Var", null, {
  11883. $documentation: "A `var` statement"
  11884. }, AST_Definitions);
  11885. var AST_Const = DEFNODE("Const", null, {
  11886. $documentation: "A `const` statement"
  11887. }, AST_Definitions);
  11888. var AST_VarDef = DEFNODE("VarDef", "name value", {
  11889. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  11890. $propdoc: {
  11891. name: "[AST_SymbolVar|AST_SymbolConst] name of the variable",
  11892. value: "[AST_Node?] initializer, or null of there's no initializer"
  11893. },
  11894. _walk: function(visitor) {
  11895. return visitor._visit(this, function() {
  11896. this.name._walk(visitor);
  11897. if (this.value) this.value._walk(visitor);
  11898. });
  11899. }
  11900. });
  11901. var AST_Call = DEFNODE("Call", "expression args", {
  11902. $documentation: "A function call expression",
  11903. $propdoc: {
  11904. expression: "[AST_Node] expression to invoke as function",
  11905. args: "[AST_Node*] array of arguments"
  11906. },
  11907. _walk: function(visitor) {
  11908. return visitor._visit(this, function() {
  11909. this.expression._walk(visitor);
  11910. this.args.forEach(function(arg) {
  11911. arg._walk(visitor);
  11912. });
  11913. });
  11914. }
  11915. });
  11916. var AST_New = DEFNODE("New", null, {
  11917. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  11918. }, AST_Call);
  11919. var AST_Seq = DEFNODE("Seq", "car cdr", {
  11920. $documentation: "A sequence expression (two comma-separated expressions)",
  11921. $propdoc: {
  11922. car: "[AST_Node] first element in sequence",
  11923. cdr: "[AST_Node] second element in sequence"
  11924. },
  11925. $cons: function(x, y) {
  11926. var seq = new AST_Seq(x);
  11927. seq.car = x;
  11928. seq.cdr = y;
  11929. return seq;
  11930. },
  11931. $from_array: function(array) {
  11932. if (array.length == 0) return null;
  11933. if (array.length == 1) return array[0].clone();
  11934. var list = null;
  11935. for (var i = array.length; --i >= 0; ) {
  11936. list = AST_Seq.cons(array[i], list);
  11937. }
  11938. var p = list;
  11939. while (p) {
  11940. if (p.cdr && !p.cdr.cdr) {
  11941. p.cdr = p.cdr.car;
  11942. break;
  11943. }
  11944. p = p.cdr;
  11945. }
  11946. return list;
  11947. },
  11948. to_array: function() {
  11949. var p = this, a = [];
  11950. while (p) {
  11951. a.push(p.car);
  11952. if (p.cdr && !(p.cdr instanceof AST_Seq)) {
  11953. a.push(p.cdr);
  11954. break;
  11955. }
  11956. p = p.cdr;
  11957. }
  11958. return a;
  11959. },
  11960. add: function(node) {
  11961. var p = this;
  11962. while (p) {
  11963. if (!(p.cdr instanceof AST_Seq)) {
  11964. var cell = AST_Seq.cons(p.cdr, node);
  11965. return p.cdr = cell;
  11966. }
  11967. p = p.cdr;
  11968. }
  11969. },
  11970. _walk: function(visitor) {
  11971. return visitor._visit(this, function() {
  11972. this.car._walk(visitor);
  11973. if (this.cdr) this.cdr._walk(visitor);
  11974. });
  11975. }
  11976. });
  11977. var AST_PropAccess = DEFNODE("PropAccess", "expression property", {
  11978. $documentation: 'Base class for property access expressions, i.e. `a.foo` or `a["foo"]`',
  11979. $propdoc: {
  11980. expression: "[AST_Node] the “container” expression",
  11981. 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"
  11982. }
  11983. });
  11984. var AST_Dot = DEFNODE("Dot", null, {
  11985. $documentation: "A dotted property access expression",
  11986. _walk: function(visitor) {
  11987. return visitor._visit(this, function() {
  11988. this.expression._walk(visitor);
  11989. });
  11990. }
  11991. }, AST_PropAccess);
  11992. var AST_Sub = DEFNODE("Sub", null, {
  11993. $documentation: 'Index-style property access, i.e. `a["foo"]`',
  11994. _walk: function(visitor) {
  11995. return visitor._visit(this, function() {
  11996. this.expression._walk(visitor);
  11997. this.property._walk(visitor);
  11998. });
  11999. }
  12000. }, AST_PropAccess);
  12001. var AST_Unary = DEFNODE("Unary", "operator expression", {
  12002. $documentation: "Base class for unary expressions",
  12003. $propdoc: {
  12004. operator: "[string] the operator",
  12005. expression: "[AST_Node] expression that this unary operator applies to"
  12006. },
  12007. _walk: function(visitor) {
  12008. return visitor._visit(this, function() {
  12009. this.expression._walk(visitor);
  12010. });
  12011. }
  12012. });
  12013. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, {
  12014. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  12015. }, AST_Unary);
  12016. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, {
  12017. $documentation: "Unary postfix expression, i.e. `i++`"
  12018. }, AST_Unary);
  12019. var AST_Binary = DEFNODE("Binary", "left operator right", {
  12020. $documentation: "Binary expression, i.e. `a + b`",
  12021. $propdoc: {
  12022. left: "[AST_Node] left-hand side expression",
  12023. operator: "[string] the operator",
  12024. right: "[AST_Node] right-hand side expression"
  12025. },
  12026. _walk: function(visitor) {
  12027. return visitor._visit(this, function() {
  12028. this.left._walk(visitor);
  12029. this.right._walk(visitor);
  12030. });
  12031. }
  12032. });
  12033. var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative", {
  12034. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  12035. $propdoc: {
  12036. condition: "[AST_Node]",
  12037. consequent: "[AST_Node]",
  12038. alternative: "[AST_Node]"
  12039. },
  12040. _walk: function(visitor) {
  12041. return visitor._visit(this, function() {
  12042. this.condition._walk(visitor);
  12043. this.consequent._walk(visitor);
  12044. this.alternative._walk(visitor);
  12045. });
  12046. }
  12047. });
  12048. var AST_Assign = DEFNODE("Assign", null, {
  12049. $documentation: "An assignment expression — `a = b + 5`"
  12050. }, AST_Binary);
  12051. var AST_Array = DEFNODE("Array", "elements", {
  12052. $documentation: "An array literal",
  12053. $propdoc: {
  12054. elements: "[AST_Node*] array of elements"
  12055. },
  12056. _walk: function(visitor) {
  12057. return visitor._visit(this, function() {
  12058. this.elements.forEach(function(el) {
  12059. el._walk(visitor);
  12060. });
  12061. });
  12062. }
  12063. });
  12064. var AST_Object = DEFNODE("Object", "properties", {
  12065. $documentation: "An object literal",
  12066. $propdoc: {
  12067. properties: "[AST_ObjectProperty*] array of properties"
  12068. },
  12069. _walk: function(visitor) {
  12070. return visitor._visit(this, function() {
  12071. this.properties.forEach(function(prop) {
  12072. prop._walk(visitor);
  12073. });
  12074. });
  12075. }
  12076. });
  12077. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
  12078. $documentation: "Base class for literal object properties",
  12079. $propdoc: {
  12080. key: "[string] the property name converted to a string for ObjectKeyVal. For setters and getters this is an arbitrary AST_Node.",
  12081. value: "[AST_Node] property value. For setters and getters this is an AST_Function."
  12082. },
  12083. _walk: function(visitor) {
  12084. return visitor._visit(this, function() {
  12085. this.value._walk(visitor);
  12086. });
  12087. }
  12088. });
  12089. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", null, {
  12090. $documentation: "A key: value object property"
  12091. }, AST_ObjectProperty);
  12092. var AST_ObjectSetter = DEFNODE("ObjectSetter", null, {
  12093. $documentation: "An object setter property"
  12094. }, AST_ObjectProperty);
  12095. var AST_ObjectGetter = DEFNODE("ObjectGetter", null, {
  12096. $documentation: "An object getter property"
  12097. }, AST_ObjectProperty);
  12098. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
  12099. $propdoc: {
  12100. name: "[string] name of this symbol",
  12101. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  12102. thedef: "[SymbolDef/S] the definition of this symbol"
  12103. },
  12104. $documentation: "Base class for all symbols"
  12105. });
  12106. var AST_SymbolAccessor = DEFNODE("SymbolAccessor", null, {
  12107. $documentation: "The name of a property accessor (setter/getter function)"
  12108. }, AST_Symbol);
  12109. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
  12110. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  12111. $propdoc: {
  12112. init: "[AST_Node*/S] array of initializers for this declaration."
  12113. }
  12114. }, AST_Symbol);
  12115. var AST_SymbolVar = DEFNODE("SymbolVar", null, {
  12116. $documentation: "Symbol defining a variable"
  12117. }, AST_SymbolDeclaration);
  12118. var AST_SymbolConst = DEFNODE("SymbolConst", null, {
  12119. $documentation: "A constant declaration"
  12120. }, AST_SymbolDeclaration);
  12121. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
  12122. $documentation: "Symbol naming a function argument"
  12123. }, AST_SymbolVar);
  12124. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
  12125. $documentation: "Symbol defining a function"
  12126. }, AST_SymbolDeclaration);
  12127. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
  12128. $documentation: "Symbol naming a function expression"
  12129. }, AST_SymbolDeclaration);
  12130. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
  12131. $documentation: "Symbol naming the exception in catch"
  12132. }, AST_SymbolDeclaration);
  12133. var AST_Label = DEFNODE("Label", "references", {
  12134. $documentation: "Symbol naming a label (declaration)",
  12135. $propdoc: {
  12136. references: "[AST_LoopControl*] a list of nodes referring to this label"
  12137. },
  12138. initialize: function() {
  12139. this.references = [];
  12140. this.thedef = this;
  12141. }
  12142. }, AST_Symbol);
  12143. var AST_SymbolRef = DEFNODE("SymbolRef", null, {
  12144. $documentation: "Reference to some symbol (not definition/declaration)"
  12145. }, AST_Symbol);
  12146. var AST_LabelRef = DEFNODE("LabelRef", null, {
  12147. $documentation: "Reference to a label symbol"
  12148. }, AST_Symbol);
  12149. var AST_This = DEFNODE("This", null, {
  12150. $documentation: "The `this` symbol"
  12151. }, AST_Symbol);
  12152. var AST_Constant = DEFNODE("Constant", null, {
  12153. $documentation: "Base class for all constants",
  12154. getValue: function() {
  12155. return this.value;
  12156. }
  12157. });
  12158. var AST_String = DEFNODE("String", "value", {
  12159. $documentation: "A string literal",
  12160. $propdoc: {
  12161. value: "[string] the contents of this string"
  12162. }
  12163. }, AST_Constant);
  12164. var AST_Number = DEFNODE("Number", "value", {
  12165. $documentation: "A number literal",
  12166. $propdoc: {
  12167. value: "[number] the numeric value"
  12168. }
  12169. }, AST_Constant);
  12170. var AST_RegExp = DEFNODE("RegExp", "value", {
  12171. $documentation: "A regexp literal",
  12172. $propdoc: {
  12173. value: "[RegExp] the actual regexp"
  12174. }
  12175. }, AST_Constant);
  12176. var AST_Atom = DEFNODE("Atom", null, {
  12177. $documentation: "Base class for atoms"
  12178. }, AST_Constant);
  12179. var AST_Null = DEFNODE("Null", null, {
  12180. $documentation: "The `null` atom",
  12181. value: null
  12182. }, AST_Atom);
  12183. var AST_NaN = DEFNODE("NaN", null, {
  12184. $documentation: "The impossible value",
  12185. value: 0 / 0
  12186. }, AST_Atom);
  12187. var AST_Undefined = DEFNODE("Undefined", null, {
  12188. $documentation: "The `undefined` value",
  12189. value: function() {}()
  12190. }, AST_Atom);
  12191. var AST_Hole = DEFNODE("Hole", null, {
  12192. $documentation: "A hole in an array",
  12193. value: function() {}()
  12194. }, AST_Atom);
  12195. var AST_Infinity = DEFNODE("Infinity", null, {
  12196. $documentation: "The `Infinity` value",
  12197. value: 1 / 0
  12198. }, AST_Atom);
  12199. var AST_Boolean = DEFNODE("Boolean", null, {
  12200. $documentation: "Base class for booleans"
  12201. }, AST_Atom);
  12202. var AST_False = DEFNODE("False", null, {
  12203. $documentation: "The `false` atom",
  12204. value: false
  12205. }, AST_Boolean);
  12206. var AST_True = DEFNODE("True", null, {
  12207. $documentation: "The `true` atom",
  12208. value: true
  12209. }, AST_Boolean);
  12210. function TreeWalker(callback) {
  12211. this.visit = callback;
  12212. this.stack = [];
  12213. }
  12214. TreeWalker.prototype = {
  12215. _visit: function(node, descend) {
  12216. this.stack.push(node);
  12217. var ret = this.visit(node, descend ? function() {
  12218. descend.call(node);
  12219. } : noop);
  12220. if (!ret && descend) {
  12221. descend.call(node);
  12222. }
  12223. this.stack.pop();
  12224. return ret;
  12225. },
  12226. parent: function(n) {
  12227. return this.stack[this.stack.length - 2 - (n || 0)];
  12228. },
  12229. push: function(node) {
  12230. this.stack.push(node);
  12231. },
  12232. pop: function() {
  12233. return this.stack.pop();
  12234. },
  12235. self: function() {
  12236. return this.stack[this.stack.length - 1];
  12237. },
  12238. find_parent: function(type) {
  12239. var stack = this.stack;
  12240. for (var i = stack.length; --i >= 0; ) {
  12241. var x = stack[i];
  12242. if (x instanceof type) return x;
  12243. }
  12244. },
  12245. has_directive: function(type) {
  12246. return this.find_parent(AST_Scope).has_directive(type);
  12247. },
  12248. in_boolean_context: function() {
  12249. var stack = this.stack;
  12250. var i = stack.length, self = stack[--i];
  12251. while (i > 0) {
  12252. var p = stack[--i];
  12253. 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) {
  12254. return true;
  12255. }
  12256. if (!(p instanceof AST_Binary && (p.operator == "&&" || p.operator == "||"))) return false;
  12257. self = p;
  12258. }
  12259. },
  12260. loopcontrol_target: function(label) {
  12261. var stack = this.stack;
  12262. if (label) for (var i = stack.length; --i >= 0; ) {
  12263. var x = stack[i];
  12264. if (x instanceof AST_LabeledStatement && x.label.name == label.name) {
  12265. return x.body;
  12266. }
  12267. } else for (var i = stack.length; --i >= 0; ) {
  12268. var x = stack[i];
  12269. if (x instanceof AST_Switch || x instanceof AST_IterationStatement) return x;
  12270. }
  12271. }
  12272. };
  12273. "use strict";
  12274. 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";
  12275. var KEYWORDS_ATOM = "false null true";
  12276. 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;
  12277. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case";
  12278. KEYWORDS = makePredicate(KEYWORDS);
  12279. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  12280. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  12281. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  12282. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  12283. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  12284. var RE_OCT_NUMBER = /^0[0-7]+$/;
  12285. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  12286. var OPERATORS = makePredicate([ "in", "instanceof", "typeof", "new", "void", "delete", "++", "--", "+", "-", "!", "~", "&", "|", "^", "*", "/", "%", ">>", "<<", ">>>", "<", ">", "<=", ">=", "==", "===", "!=", "!==", "?", "=", "+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=", "&&", "||" ]);
  12287. var WHITESPACE_CHARS = makePredicate(characters("  \n\r \f ​᠎              "));
  12288. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,.;:"));
  12289. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  12290. var REGEXP_MODIFIERS = makePredicate(characters("gmsiy"));
  12291. var UNICODE = {
  12292. 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]"),
  12293. 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]"),
  12294. 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]"),
  12295. connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
  12296. };
  12297. function is_letter(code) {
  12298. return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 170 && UNICODE.letter.test(String.fromCharCode(code));
  12299. }
  12300. function is_digit(code) {
  12301. return code >= 48 && code <= 57;
  12302. }
  12303. function is_alphanumeric_char(code) {
  12304. return is_digit(code) || is_letter(code);
  12305. }
  12306. function is_unicode_combining_mark(ch) {
  12307. return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
  12308. }
  12309. function is_unicode_connector_punctuation(ch) {
  12310. return UNICODE.connector_punctuation.test(ch);
  12311. }
  12312. function is_identifier(name) {
  12313. return !RESERVED_WORDS(name) && /^[a-z_$][a-z0-9_$]*$/i.test(name);
  12314. }
  12315. function is_identifier_start(code) {
  12316. return code == 36 || code == 95 || is_letter(code);
  12317. }
  12318. function is_identifier_char(ch) {
  12319. var code = ch.charCodeAt(0);
  12320. return is_identifier_start(code) || is_digit(code) || code == 8204 || code == 8205 || is_unicode_combining_mark(ch) || is_unicode_connector_punctuation(ch);
  12321. }
  12322. function is_identifier_string(str) {
  12323. return /^[a-z_$][a-z0-9_$]*$/i.test(str);
  12324. }
  12325. function parse_js_number(num) {
  12326. if (RE_HEX_NUMBER.test(num)) {
  12327. return parseInt(num.substr(2), 16);
  12328. } else if (RE_OCT_NUMBER.test(num)) {
  12329. return parseInt(num.substr(1), 8);
  12330. } else if (RE_DEC_NUMBER.test(num)) {
  12331. return parseFloat(num);
  12332. }
  12333. }
  12334. function JS_Parse_Error(message, line, col, pos) {
  12335. this.message = message;
  12336. this.line = line;
  12337. this.col = col;
  12338. this.pos = pos;
  12339. this.stack = new Error().stack;
  12340. }
  12341. JS_Parse_Error.prototype.toString = function() {
  12342. return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
  12343. };
  12344. function js_error(message, filename, line, col, pos) {
  12345. throw new JS_Parse_Error(message, line, col, pos);
  12346. }
  12347. function is_token(token, type, val) {
  12348. return token.type == type && (val == null || token.value == val);
  12349. }
  12350. var EX_EOF = {};
  12351. function tokenizer($TEXT, filename, html5_comments) {
  12352. var S = {
  12353. text: $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/\uFEFF/g, ""),
  12354. filename: filename,
  12355. pos: 0,
  12356. tokpos: 0,
  12357. line: 1,
  12358. tokline: 0,
  12359. col: 0,
  12360. tokcol: 0,
  12361. newline_before: false,
  12362. regex_allowed: false,
  12363. comments_before: []
  12364. };
  12365. function peek() {
  12366. return S.text.charAt(S.pos);
  12367. }
  12368. function next(signal_eof, in_string) {
  12369. var ch = S.text.charAt(S.pos++);
  12370. if (signal_eof && !ch) throw EX_EOF;
  12371. if (ch == "\n") {
  12372. S.newline_before = S.newline_before || !in_string;
  12373. ++S.line;
  12374. S.col = 0;
  12375. } else {
  12376. ++S.col;
  12377. }
  12378. return ch;
  12379. }
  12380. function forward(i) {
  12381. while (i-- > 0) next();
  12382. }
  12383. function looking_at(str) {
  12384. return S.text.substr(S.pos, str.length) == str;
  12385. }
  12386. function find(what, signal_eof) {
  12387. var pos = S.text.indexOf(what, S.pos);
  12388. if (signal_eof && pos == -1) throw EX_EOF;
  12389. return pos;
  12390. }
  12391. function start_token() {
  12392. S.tokline = S.line;
  12393. S.tokcol = S.col;
  12394. S.tokpos = S.pos;
  12395. }
  12396. var prev_was_dot = false;
  12397. function token(type, value, is_comment) {
  12398. S.regex_allowed = type == "operator" && !UNARY_POSTFIX(value) || type == "keyword" && KEYWORDS_BEFORE_EXPRESSION(value) || type == "punc" && PUNC_BEFORE_EXPRESSION(value);
  12399. prev_was_dot = type == "punc" && value == ".";
  12400. var ret = {
  12401. type: type,
  12402. value: value,
  12403. line: S.tokline,
  12404. col: S.tokcol,
  12405. pos: S.tokpos,
  12406. endpos: S.pos,
  12407. nlb: S.newline_before,
  12408. file: filename
  12409. };
  12410. if (!is_comment) {
  12411. ret.comments_before = S.comments_before;
  12412. S.comments_before = [];
  12413. for (var i = 0, len = ret.comments_before.length; i < len; i++) {
  12414. ret.nlb = ret.nlb || ret.comments_before[i].nlb;
  12415. }
  12416. }
  12417. S.newline_before = false;
  12418. return new AST_Token(ret);
  12419. }
  12420. function skip_whitespace() {
  12421. while (WHITESPACE_CHARS(peek())) next();
  12422. }
  12423. function read_while(pred) {
  12424. var ret = "", ch, i = 0;
  12425. while ((ch = peek()) && pred(ch, i++)) ret += next();
  12426. return ret;
  12427. }
  12428. function parse_error(err) {
  12429. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  12430. }
  12431. function read_num(prefix) {
  12432. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".";
  12433. var num = read_while(function(ch, i) {
  12434. var code = ch.charCodeAt(0);
  12435. switch (code) {
  12436. case 120:
  12437. case 88:
  12438. return has_x ? false : has_x = true;
  12439. case 101:
  12440. case 69:
  12441. return has_x ? true : has_e ? false : has_e = after_e = true;
  12442. case 45:
  12443. return after_e || i == 0 && !prefix;
  12444. case 43:
  12445. return after_e;
  12446. case after_e = false, 46:
  12447. return !has_dot && !has_x && !has_e ? has_dot = true : false;
  12448. }
  12449. return is_alphanumeric_char(code);
  12450. });
  12451. if (prefix) num = prefix + num;
  12452. var valid = parse_js_number(num);
  12453. if (!isNaN(valid)) {
  12454. return token("num", valid);
  12455. } else {
  12456. parse_error("Invalid syntax: " + num);
  12457. }
  12458. }
  12459. function read_escaped_char(in_string) {
  12460. var ch = next(true, in_string);
  12461. switch (ch.charCodeAt(0)) {
  12462. case 110:
  12463. return "\n";
  12464. case 114:
  12465. return "\r";
  12466. case 116:
  12467. return " ";
  12468. case 98:
  12469. return "\b";
  12470. case 118:
  12471. return " ";
  12472. case 102:
  12473. return "\f";
  12474. case 48:
  12475. return "\x00";
  12476. case 120:
  12477. return String.fromCharCode(hex_bytes(2));
  12478. case 117:
  12479. return String.fromCharCode(hex_bytes(4));
  12480. case 10:
  12481. return "";
  12482. default:
  12483. return ch;
  12484. }
  12485. }
  12486. function hex_bytes(n) {
  12487. var num = 0;
  12488. for (;n > 0; --n) {
  12489. var digit = parseInt(next(true), 16);
  12490. if (isNaN(digit)) parse_error("Invalid hex-character pattern in string");
  12491. num = num << 4 | digit;
  12492. }
  12493. return num;
  12494. }
  12495. var read_string = with_eof_error("Unterminated string constant", function() {
  12496. var quote = next(), ret = "";
  12497. for (;;) {
  12498. var ch = next(true);
  12499. if (ch == "\\") {
  12500. var octal_len = 0, first = null;
  12501. ch = read_while(function(ch) {
  12502. if (ch >= "0" && ch <= "7") {
  12503. if (!first) {
  12504. first = ch;
  12505. return ++octal_len;
  12506. } else if (first <= "3" && octal_len <= 2) return ++octal_len; else if (first >= "4" && octal_len <= 1) return ++octal_len;
  12507. }
  12508. return false;
  12509. });
  12510. if (octal_len > 0) ch = String.fromCharCode(parseInt(ch, 8)); else ch = read_escaped_char(true);
  12511. } else if (ch == quote) break;
  12512. ret += ch;
  12513. }
  12514. return token("string", ret);
  12515. });
  12516. function skip_line_comment(type) {
  12517. var regex_allowed = S.regex_allowed;
  12518. var i = find("\n"), ret;
  12519. if (i == -1) {
  12520. ret = S.text.substr(S.pos);
  12521. S.pos = S.text.length;
  12522. } else {
  12523. ret = S.text.substring(S.pos, i);
  12524. S.pos = i;
  12525. }
  12526. S.comments_before.push(token(type, ret, true));
  12527. S.regex_allowed = regex_allowed;
  12528. return next_token();
  12529. }
  12530. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  12531. var regex_allowed = S.regex_allowed;
  12532. var i = find("*/", true);
  12533. var text = S.text.substring(S.pos, i);
  12534. var a = text.split("\n"), n = a.length;
  12535. S.pos = i + 2;
  12536. S.line += n - 1;
  12537. if (n > 1) S.col = a[n - 1].length; else S.col += a[n - 1].length;
  12538. S.col += 2;
  12539. var nlb = S.newline_before = S.newline_before || text.indexOf("\n") >= 0;
  12540. S.comments_before.push(token("comment2", text, true));
  12541. S.regex_allowed = regex_allowed;
  12542. S.newline_before = nlb;
  12543. return next_token();
  12544. });
  12545. function read_name() {
  12546. var backslash = false, name = "", ch, escaped = false, hex;
  12547. while ((ch = peek()) != null) {
  12548. if (!backslash) {
  12549. if (ch == "\\") escaped = backslash = true, next(); else if (is_identifier_char(ch)) name += next(); else break;
  12550. } else {
  12551. if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX");
  12552. ch = read_escaped_char();
  12553. if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier");
  12554. name += ch;
  12555. backslash = false;
  12556. }
  12557. }
  12558. if (KEYWORDS(name) && escaped) {
  12559. hex = name.charCodeAt(0).toString(16).toUpperCase();
  12560. name = "\\u" + "0000".substr(hex.length) + hex + name.slice(1);
  12561. }
  12562. return name;
  12563. }
  12564. var read_regexp = with_eof_error("Unterminated regular expression", function(regexp) {
  12565. var prev_backslash = false, ch, in_class = false;
  12566. while (ch = next(true)) if (prev_backslash) {
  12567. regexp += "\\" + ch;
  12568. prev_backslash = false;
  12569. } else if (ch == "[") {
  12570. in_class = true;
  12571. regexp += ch;
  12572. } else if (ch == "]" && in_class) {
  12573. in_class = false;
  12574. regexp += ch;
  12575. } else if (ch == "/" && !in_class) {
  12576. break;
  12577. } else if (ch == "\\") {
  12578. prev_backslash = true;
  12579. } else {
  12580. regexp += ch;
  12581. }
  12582. var mods = read_name();
  12583. return token("regexp", new RegExp(regexp, mods));
  12584. });
  12585. function read_operator(prefix) {
  12586. function grow(op) {
  12587. if (!peek()) return op;
  12588. var bigger = op + peek();
  12589. if (OPERATORS(bigger)) {
  12590. next();
  12591. return grow(bigger);
  12592. } else {
  12593. return op;
  12594. }
  12595. }
  12596. return token("operator", grow(prefix || next()));
  12597. }
  12598. function handle_slash() {
  12599. next();
  12600. switch (peek()) {
  12601. case "/":
  12602. next();
  12603. return skip_line_comment("comment1");
  12604. case "*":
  12605. next();
  12606. return skip_multiline_comment();
  12607. }
  12608. return S.regex_allowed ? read_regexp("") : read_operator("/");
  12609. }
  12610. function handle_dot() {
  12611. next();
  12612. return is_digit(peek().charCodeAt(0)) ? read_num(".") : token("punc", ".");
  12613. }
  12614. function read_word() {
  12615. var word = read_name();
  12616. if (prev_was_dot) return token("name", word);
  12617. return KEYWORDS_ATOM(word) ? token("atom", word) : !KEYWORDS(word) ? token("name", word) : OPERATORS(word) ? token("operator", word) : token("keyword", word);
  12618. }
  12619. function with_eof_error(eof_error, cont) {
  12620. return function(x) {
  12621. try {
  12622. return cont(x);
  12623. } catch (ex) {
  12624. if (ex === EX_EOF) parse_error(eof_error); else throw ex;
  12625. }
  12626. };
  12627. }
  12628. function next_token(force_regexp) {
  12629. if (force_regexp != null) return read_regexp(force_regexp);
  12630. skip_whitespace();
  12631. start_token();
  12632. if (html5_comments) {
  12633. if (looking_at("<!--")) {
  12634. forward(4);
  12635. return skip_line_comment("comment3");
  12636. }
  12637. if (looking_at("-->") && S.newline_before) {
  12638. forward(3);
  12639. return skip_line_comment("comment4");
  12640. }
  12641. }
  12642. var ch = peek();
  12643. if (!ch) return token("eof");
  12644. var code = ch.charCodeAt(0);
  12645. switch (code) {
  12646. case 34:
  12647. case 39:
  12648. return read_string();
  12649. case 46:
  12650. return handle_dot();
  12651. case 47:
  12652. return handle_slash();
  12653. }
  12654. if (is_digit(code)) return read_num();
  12655. if (PUNC_CHARS(ch)) return token("punc", next());
  12656. if (OPERATOR_CHARS(ch)) return read_operator();
  12657. if (code == 92 || is_identifier_start(code)) return read_word();
  12658. parse_error("Unexpected character '" + ch + "'");
  12659. }
  12660. next_token.context = function(nc) {
  12661. if (nc) S = nc;
  12662. return S;
  12663. };
  12664. return next_token;
  12665. }
  12666. var UNARY_PREFIX = makePredicate([ "typeof", "void", "delete", "--", "++", "!", "~", "-", "+" ]);
  12667. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  12668. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  12669. var PRECEDENCE = function(a, ret) {
  12670. for (var i = 0; i < a.length; ++i) {
  12671. var b = a[i];
  12672. for (var j = 0; j < b.length; ++j) {
  12673. ret[b[j]] = i + 1;
  12674. }
  12675. }
  12676. return ret;
  12677. }([ [ "||" ], [ "&&" ], [ "|" ], [ "^" ], [ "&" ], [ "==", "===", "!=", "!==" ], [ "<", ">", "<=", ">=", "in", "instanceof" ], [ ">>", "<<", ">>>" ], [ "+", "-" ], [ "*", "/", "%" ] ], {});
  12678. var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]);
  12679. var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]);
  12680. function parse($TEXT, options) {
  12681. options = defaults(options, {
  12682. strict: false,
  12683. filename: null,
  12684. toplevel: null,
  12685. expression: false,
  12686. html5_comments: true
  12687. });
  12688. var S = {
  12689. input: typeof $TEXT == "string" ? tokenizer($TEXT, options.filename, options.html5_comments) : $TEXT,
  12690. token: null,
  12691. prev: null,
  12692. peeked: null,
  12693. in_function: 0,
  12694. in_directives: true,
  12695. in_loop: 0,
  12696. labels: []
  12697. };
  12698. S.token = next();
  12699. function is(type, value) {
  12700. return is_token(S.token, type, value);
  12701. }
  12702. function peek() {
  12703. return S.peeked || (S.peeked = S.input());
  12704. }
  12705. function next() {
  12706. S.prev = S.token;
  12707. if (S.peeked) {
  12708. S.token = S.peeked;
  12709. S.peeked = null;
  12710. } else {
  12711. S.token = S.input();
  12712. }
  12713. S.in_directives = S.in_directives && (S.token.type == "string" || is("punc", ";"));
  12714. return S.token;
  12715. }
  12716. function prev() {
  12717. return S.prev;
  12718. }
  12719. function croak(msg, line, col, pos) {
  12720. var ctx = S.input.context();
  12721. js_error(msg, ctx.filename, line != null ? line : ctx.tokline, col != null ? col : ctx.tokcol, pos != null ? pos : ctx.tokpos);
  12722. }
  12723. function token_error(token, msg) {
  12724. croak(msg, token.line, token.col);
  12725. }
  12726. function unexpected(token) {
  12727. if (token == null) token = S.token;
  12728. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  12729. }
  12730. function expect_token(type, val) {
  12731. if (is(type, val)) {
  12732. return next();
  12733. }
  12734. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  12735. }
  12736. function expect(punc) {
  12737. return expect_token("punc", punc);
  12738. }
  12739. function can_insert_semicolon() {
  12740. return !options.strict && (S.token.nlb || is("eof") || is("punc", "}"));
  12741. }
  12742. function semicolon() {
  12743. if (is("punc", ";")) next(); else if (!can_insert_semicolon()) unexpected();
  12744. }
  12745. function parenthesised() {
  12746. expect("(");
  12747. var exp = expression(true);
  12748. expect(")");
  12749. return exp;
  12750. }
  12751. function embed_tokens(parser) {
  12752. return function() {
  12753. var start = S.token;
  12754. var expr = parser();
  12755. var end = prev();
  12756. expr.start = start;
  12757. expr.end = end;
  12758. return expr;
  12759. };
  12760. }
  12761. function handle_regexp() {
  12762. if (is("operator", "/") || is("operator", "/=")) {
  12763. S.peeked = null;
  12764. S.token = S.input(S.token.value.substr(1));
  12765. }
  12766. }
  12767. var statement = embed_tokens(function() {
  12768. var tmp;
  12769. handle_regexp();
  12770. switch (S.token.type) {
  12771. case "string":
  12772. var dir = S.in_directives, stat = simple_statement();
  12773. if (dir && stat.body instanceof AST_String && !is("punc", ",")) return new AST_Directive({
  12774. value: stat.body.value
  12775. });
  12776. return stat;
  12777. case "num":
  12778. case "regexp":
  12779. case "operator":
  12780. case "atom":
  12781. return simple_statement();
  12782. case "name":
  12783. return is_token(peek(), "punc", ":") ? labeled_statement() : simple_statement();
  12784. case "punc":
  12785. switch (S.token.value) {
  12786. case "{":
  12787. return new AST_BlockStatement({
  12788. start: S.token,
  12789. body: block_(),
  12790. end: prev()
  12791. });
  12792. case "[":
  12793. case "(":
  12794. return simple_statement();
  12795. case ";":
  12796. next();
  12797. return new AST_EmptyStatement();
  12798. default:
  12799. unexpected();
  12800. }
  12801. case "keyword":
  12802. switch (tmp = S.token.value, next(), tmp) {
  12803. case "break":
  12804. return break_cont(AST_Break);
  12805. case "continue":
  12806. return break_cont(AST_Continue);
  12807. case "debugger":
  12808. semicolon();
  12809. return new AST_Debugger();
  12810. case "do":
  12811. return new AST_Do({
  12812. body: in_loop(statement),
  12813. condition: (expect_token("keyword", "while"), tmp = parenthesised(), semicolon(),
  12814. tmp)
  12815. });
  12816. case "while":
  12817. return new AST_While({
  12818. condition: parenthesised(),
  12819. body: in_loop(statement)
  12820. });
  12821. case "for":
  12822. return for_();
  12823. case "function":
  12824. return function_(AST_Defun);
  12825. case "if":
  12826. return if_();
  12827. case "return":
  12828. if (S.in_function == 0) croak("'return' outside of function");
  12829. return new AST_Return({
  12830. value: is("punc", ";") ? (next(), null) : can_insert_semicolon() ? null : (tmp = expression(true),
  12831. semicolon(), tmp)
  12832. });
  12833. case "switch":
  12834. return new AST_Switch({
  12835. expression: parenthesised(),
  12836. body: in_loop(switch_body_)
  12837. });
  12838. case "throw":
  12839. if (S.token.nlb) croak("Illegal newline after 'throw'");
  12840. return new AST_Throw({
  12841. value: (tmp = expression(true), semicolon(), tmp)
  12842. });
  12843. case "try":
  12844. return try_();
  12845. case "var":
  12846. return tmp = var_(), semicolon(), tmp;
  12847. case "const":
  12848. return tmp = const_(), semicolon(), tmp;
  12849. case "with":
  12850. return new AST_With({
  12851. expression: parenthesised(),
  12852. body: statement()
  12853. });
  12854. default:
  12855. unexpected();
  12856. }
  12857. }
  12858. });
  12859. function labeled_statement() {
  12860. var label = as_symbol(AST_Label);
  12861. if (find_if(function(l) {
  12862. return l.name == label.name;
  12863. }, S.labels)) {
  12864. croak("Label " + label.name + " defined twice");
  12865. }
  12866. expect(":");
  12867. S.labels.push(label);
  12868. var stat = statement();
  12869. S.labels.pop();
  12870. if (!(stat instanceof AST_IterationStatement)) {
  12871. label.references.forEach(function(ref) {
  12872. if (ref instanceof AST_Continue) {
  12873. ref = ref.label.start;
  12874. croak("Continue label `" + label.name + "` refers to non-IterationStatement.", ref.line, ref.col, ref.pos);
  12875. }
  12876. });
  12877. }
  12878. return new AST_LabeledStatement({
  12879. body: stat,
  12880. label: label
  12881. });
  12882. }
  12883. function simple_statement(tmp) {
  12884. return new AST_SimpleStatement({
  12885. body: (tmp = expression(true), semicolon(), tmp)
  12886. });
  12887. }
  12888. function break_cont(type) {
  12889. var label = null, ldef;
  12890. if (!can_insert_semicolon()) {
  12891. label = as_symbol(AST_LabelRef, true);
  12892. }
  12893. if (label != null) {
  12894. ldef = find_if(function(l) {
  12895. return l.name == label.name;
  12896. }, S.labels);
  12897. if (!ldef) croak("Undefined label " + label.name);
  12898. label.thedef = ldef;
  12899. } else if (S.in_loop == 0) croak(type.TYPE + " not inside a loop or switch");
  12900. semicolon();
  12901. var stat = new type({
  12902. label: label
  12903. });
  12904. if (ldef) ldef.references.push(stat);
  12905. return stat;
  12906. }
  12907. function for_() {
  12908. expect("(");
  12909. var init = null;
  12910. if (!is("punc", ";")) {
  12911. init = is("keyword", "var") ? (next(), var_(true)) : expression(true, true);
  12912. if (is("operator", "in")) {
  12913. if (init instanceof AST_Var && init.definitions.length > 1) croak("Only one variable declaration allowed in for..in loop");
  12914. next();
  12915. return for_in(init);
  12916. }
  12917. }
  12918. return regular_for(init);
  12919. }
  12920. function regular_for(init) {
  12921. expect(";");
  12922. var test = is("punc", ";") ? null : expression(true);
  12923. expect(";");
  12924. var step = is("punc", ")") ? null : expression(true);
  12925. expect(")");
  12926. return new AST_For({
  12927. init: init,
  12928. condition: test,
  12929. step: step,
  12930. body: in_loop(statement)
  12931. });
  12932. }
  12933. function for_in(init) {
  12934. var lhs = init instanceof AST_Var ? init.definitions[0].name : null;
  12935. var obj = expression(true);
  12936. expect(")");
  12937. return new AST_ForIn({
  12938. init: init,
  12939. name: lhs,
  12940. object: obj,
  12941. body: in_loop(statement)
  12942. });
  12943. }
  12944. var function_ = function(ctor) {
  12945. var in_statement = ctor === AST_Defun;
  12946. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  12947. if (in_statement && !name) unexpected();
  12948. expect("(");
  12949. return new ctor({
  12950. name: name,
  12951. argnames: function(first, a) {
  12952. while (!is("punc", ")")) {
  12953. if (first) first = false; else expect(",");
  12954. a.push(as_symbol(AST_SymbolFunarg));
  12955. }
  12956. next();
  12957. return a;
  12958. }(true, []),
  12959. body: function(loop, labels) {
  12960. ++S.in_function;
  12961. S.in_directives = true;
  12962. S.in_loop = 0;
  12963. S.labels = [];
  12964. var a = block_();
  12965. --S.in_function;
  12966. S.in_loop = loop;
  12967. S.labels = labels;
  12968. return a;
  12969. }(S.in_loop, S.labels)
  12970. });
  12971. };
  12972. function if_() {
  12973. var cond = parenthesised(), body = statement(), belse = null;
  12974. if (is("keyword", "else")) {
  12975. next();
  12976. belse = statement();
  12977. }
  12978. return new AST_If({
  12979. condition: cond,
  12980. body: body,
  12981. alternative: belse
  12982. });
  12983. }
  12984. function block_() {
  12985. expect("{");
  12986. var a = [];
  12987. while (!is("punc", "}")) {
  12988. if (is("eof")) unexpected();
  12989. a.push(statement());
  12990. }
  12991. next();
  12992. return a;
  12993. }
  12994. function switch_body_() {
  12995. expect("{");
  12996. var a = [], cur = null, branch = null, tmp;
  12997. while (!is("punc", "}")) {
  12998. if (is("eof")) unexpected();
  12999. if (is("keyword", "case")) {
  13000. if (branch) branch.end = prev();
  13001. cur = [];
  13002. branch = new AST_Case({
  13003. start: (tmp = S.token, next(), tmp),
  13004. expression: expression(true),
  13005. body: cur
  13006. });
  13007. a.push(branch);
  13008. expect(":");
  13009. } else if (is("keyword", "default")) {
  13010. if (branch) branch.end = prev();
  13011. cur = [];
  13012. branch = new AST_Default({
  13013. start: (tmp = S.token, next(), expect(":"), tmp),
  13014. body: cur
  13015. });
  13016. a.push(branch);
  13017. } else {
  13018. if (!cur) unexpected();
  13019. cur.push(statement());
  13020. }
  13021. }
  13022. if (branch) branch.end = prev();
  13023. next();
  13024. return a;
  13025. }
  13026. function try_() {
  13027. var body = block_(), bcatch = null, bfinally = null;
  13028. if (is("keyword", "catch")) {
  13029. var start = S.token;
  13030. next();
  13031. expect("(");
  13032. var name = as_symbol(AST_SymbolCatch);
  13033. expect(")");
  13034. bcatch = new AST_Catch({
  13035. start: start,
  13036. argname: name,
  13037. body: block_(),
  13038. end: prev()
  13039. });
  13040. }
  13041. if (is("keyword", "finally")) {
  13042. var start = S.token;
  13043. next();
  13044. bfinally = new AST_Finally({
  13045. start: start,
  13046. body: block_(),
  13047. end: prev()
  13048. });
  13049. }
  13050. if (!bcatch && !bfinally) croak("Missing catch/finally blocks");
  13051. return new AST_Try({
  13052. body: body,
  13053. bcatch: bcatch,
  13054. bfinally: bfinally
  13055. });
  13056. }
  13057. function vardefs(no_in, in_const) {
  13058. var a = [];
  13059. for (;;) {
  13060. a.push(new AST_VarDef({
  13061. start: S.token,
  13062. name: as_symbol(in_const ? AST_SymbolConst : AST_SymbolVar),
  13063. value: is("operator", "=") ? (next(), expression(false, no_in)) : null,
  13064. end: prev()
  13065. }));
  13066. if (!is("punc", ",")) break;
  13067. next();
  13068. }
  13069. return a;
  13070. }
  13071. var var_ = function(no_in) {
  13072. return new AST_Var({
  13073. start: prev(),
  13074. definitions: vardefs(no_in, false),
  13075. end: prev()
  13076. });
  13077. };
  13078. var const_ = function() {
  13079. return new AST_Const({
  13080. start: prev(),
  13081. definitions: vardefs(false, true),
  13082. end: prev()
  13083. });
  13084. };
  13085. var new_ = function() {
  13086. var start = S.token;
  13087. expect_token("operator", "new");
  13088. var newexp = expr_atom(false), args;
  13089. if (is("punc", "(")) {
  13090. next();
  13091. args = expr_list(")");
  13092. } else {
  13093. args = [];
  13094. }
  13095. return subscripts(new AST_New({
  13096. start: start,
  13097. expression: newexp,
  13098. args: args,
  13099. end: prev()
  13100. }), true);
  13101. };
  13102. function as_atom_node() {
  13103. var tok = S.token, ret;
  13104. switch (tok.type) {
  13105. case "name":
  13106. case "keyword":
  13107. ret = _make_symbol(AST_SymbolRef);
  13108. break;
  13109. case "num":
  13110. ret = new AST_Number({
  13111. start: tok,
  13112. end: tok,
  13113. value: tok.value
  13114. });
  13115. break;
  13116. case "string":
  13117. ret = new AST_String({
  13118. start: tok,
  13119. end: tok,
  13120. value: tok.value
  13121. });
  13122. break;
  13123. case "regexp":
  13124. ret = new AST_RegExp({
  13125. start: tok,
  13126. end: tok,
  13127. value: tok.value
  13128. });
  13129. break;
  13130. case "atom":
  13131. switch (tok.value) {
  13132. case "false":
  13133. ret = new AST_False({
  13134. start: tok,
  13135. end: tok
  13136. });
  13137. break;
  13138. case "true":
  13139. ret = new AST_True({
  13140. start: tok,
  13141. end: tok
  13142. });
  13143. break;
  13144. case "null":
  13145. ret = new AST_Null({
  13146. start: tok,
  13147. end: tok
  13148. });
  13149. break;
  13150. }
  13151. break;
  13152. }
  13153. next();
  13154. return ret;
  13155. }
  13156. var expr_atom = function(allow_calls) {
  13157. if (is("operator", "new")) {
  13158. return new_();
  13159. }
  13160. var start = S.token;
  13161. if (is("punc")) {
  13162. switch (start.value) {
  13163. case "(":
  13164. next();
  13165. var ex = expression(true);
  13166. ex.start = start;
  13167. ex.end = S.token;
  13168. expect(")");
  13169. return subscripts(ex, allow_calls);
  13170. case "[":
  13171. return subscripts(array_(), allow_calls);
  13172. case "{":
  13173. return subscripts(object_(), allow_calls);
  13174. }
  13175. unexpected();
  13176. }
  13177. if (is("keyword", "function")) {
  13178. next();
  13179. var func = function_(AST_Function);
  13180. func.start = start;
  13181. func.end = prev();
  13182. return subscripts(func, allow_calls);
  13183. }
  13184. if (ATOMIC_START_TOKEN[S.token.type]) {
  13185. return subscripts(as_atom_node(), allow_calls);
  13186. }
  13187. unexpected();
  13188. };
  13189. function expr_list(closing, allow_trailing_comma, allow_empty) {
  13190. var first = true, a = [];
  13191. while (!is("punc", closing)) {
  13192. if (first) first = false; else expect(",");
  13193. if (allow_trailing_comma && is("punc", closing)) break;
  13194. if (is("punc", ",") && allow_empty) {
  13195. a.push(new AST_Hole({
  13196. start: S.token,
  13197. end: S.token
  13198. }));
  13199. } else {
  13200. a.push(expression(false));
  13201. }
  13202. }
  13203. next();
  13204. return a;
  13205. }
  13206. var array_ = embed_tokens(function() {
  13207. expect("[");
  13208. return new AST_Array({
  13209. elements: expr_list("]", !options.strict, true)
  13210. });
  13211. });
  13212. var object_ = embed_tokens(function() {
  13213. expect("{");
  13214. var first = true, a = [];
  13215. while (!is("punc", "}")) {
  13216. if (first) first = false; else expect(",");
  13217. if (!options.strict && is("punc", "}")) break;
  13218. var start = S.token;
  13219. var type = start.type;
  13220. var name = as_property_name();
  13221. if (type == "name" && !is("punc", ":")) {
  13222. if (name == "get") {
  13223. a.push(new AST_ObjectGetter({
  13224. start: start,
  13225. key: as_atom_node(),
  13226. value: function_(AST_Accessor),
  13227. end: prev()
  13228. }));
  13229. continue;
  13230. }
  13231. if (name == "set") {
  13232. a.push(new AST_ObjectSetter({
  13233. start: start,
  13234. key: as_atom_node(),
  13235. value: function_(AST_Accessor),
  13236. end: prev()
  13237. }));
  13238. continue;
  13239. }
  13240. }
  13241. expect(":");
  13242. a.push(new AST_ObjectKeyVal({
  13243. start: start,
  13244. key: name,
  13245. value: expression(false),
  13246. end: prev()
  13247. }));
  13248. }
  13249. next();
  13250. return new AST_Object({
  13251. properties: a
  13252. });
  13253. });
  13254. function as_property_name() {
  13255. var tmp = S.token;
  13256. next();
  13257. switch (tmp.type) {
  13258. case "num":
  13259. case "string":
  13260. case "name":
  13261. case "operator":
  13262. case "keyword":
  13263. case "atom":
  13264. return tmp.value;
  13265. default:
  13266. unexpected();
  13267. }
  13268. }
  13269. function as_name() {
  13270. var tmp = S.token;
  13271. next();
  13272. switch (tmp.type) {
  13273. case "name":
  13274. case "operator":
  13275. case "keyword":
  13276. case "atom":
  13277. return tmp.value;
  13278. default:
  13279. unexpected();
  13280. }
  13281. }
  13282. function _make_symbol(type) {
  13283. var name = S.token.value;
  13284. return new (name == "this" ? AST_This : type)({
  13285. name: String(name),
  13286. start: S.token,
  13287. end: S.token
  13288. });
  13289. }
  13290. function as_symbol(type, noerror) {
  13291. if (!is("name")) {
  13292. if (!noerror) croak("Name expected");
  13293. return null;
  13294. }
  13295. var sym = _make_symbol(type);
  13296. next();
  13297. return sym;
  13298. }
  13299. var subscripts = function(expr, allow_calls) {
  13300. var start = expr.start;
  13301. if (is("punc", ".")) {
  13302. next();
  13303. return subscripts(new AST_Dot({
  13304. start: start,
  13305. expression: expr,
  13306. property: as_name(),
  13307. end: prev()
  13308. }), allow_calls);
  13309. }
  13310. if (is("punc", "[")) {
  13311. next();
  13312. var prop = expression(true);
  13313. expect("]");
  13314. return subscripts(new AST_Sub({
  13315. start: start,
  13316. expression: expr,
  13317. property: prop,
  13318. end: prev()
  13319. }), allow_calls);
  13320. }
  13321. if (allow_calls && is("punc", "(")) {
  13322. next();
  13323. return subscripts(new AST_Call({
  13324. start: start,
  13325. expression: expr,
  13326. args: expr_list(")"),
  13327. end: prev()
  13328. }), true);
  13329. }
  13330. return expr;
  13331. };
  13332. var maybe_unary = function(allow_calls) {
  13333. var start = S.token;
  13334. if (is("operator") && UNARY_PREFIX(start.value)) {
  13335. next();
  13336. handle_regexp();
  13337. var ex = make_unary(AST_UnaryPrefix, start.value, maybe_unary(allow_calls));
  13338. ex.start = start;
  13339. ex.end = prev();
  13340. return ex;
  13341. }
  13342. var val = expr_atom(allow_calls);
  13343. while (is("operator") && UNARY_POSTFIX(S.token.value) && !S.token.nlb) {
  13344. val = make_unary(AST_UnaryPostfix, S.token.value, val);
  13345. val.start = start;
  13346. val.end = S.token;
  13347. next();
  13348. }
  13349. return val;
  13350. };
  13351. function make_unary(ctor, op, expr) {
  13352. if ((op == "++" || op == "--") && !is_assignable(expr)) croak("Invalid use of " + op + " operator");
  13353. return new ctor({
  13354. operator: op,
  13355. expression: expr
  13356. });
  13357. }
  13358. var expr_op = function(left, min_prec, no_in) {
  13359. var op = is("operator") ? S.token.value : null;
  13360. if (op == "in" && no_in) op = null;
  13361. var prec = op != null ? PRECEDENCE[op] : null;
  13362. if (prec != null && prec > min_prec) {
  13363. next();
  13364. var right = expr_op(maybe_unary(true), prec, no_in);
  13365. return expr_op(new AST_Binary({
  13366. start: left.start,
  13367. left: left,
  13368. operator: op,
  13369. right: right,
  13370. end: right.end
  13371. }), min_prec, no_in);
  13372. }
  13373. return left;
  13374. };
  13375. function expr_ops(no_in) {
  13376. return expr_op(maybe_unary(true), 0, no_in);
  13377. }
  13378. var maybe_conditional = function(no_in) {
  13379. var start = S.token;
  13380. var expr = expr_ops(no_in);
  13381. if (is("operator", "?")) {
  13382. next();
  13383. var yes = expression(false);
  13384. expect(":");
  13385. return new AST_Conditional({
  13386. start: start,
  13387. condition: expr,
  13388. consequent: yes,
  13389. alternative: expression(false, no_in),
  13390. end: prev()
  13391. });
  13392. }
  13393. return expr;
  13394. };
  13395. function is_assignable(expr) {
  13396. if (!options.strict) return true;
  13397. if (expr instanceof AST_This) return false;
  13398. return expr instanceof AST_PropAccess || expr instanceof AST_Symbol;
  13399. }
  13400. var maybe_assign = function(no_in) {
  13401. var start = S.token;
  13402. var left = maybe_conditional(no_in), val = S.token.value;
  13403. if (is("operator") && ASSIGNMENT(val)) {
  13404. if (is_assignable(left)) {
  13405. next();
  13406. return new AST_Assign({
  13407. start: start,
  13408. left: left,
  13409. operator: val,
  13410. right: maybe_assign(no_in),
  13411. end: prev()
  13412. });
  13413. }
  13414. croak("Invalid assignment");
  13415. }
  13416. return left;
  13417. };
  13418. var expression = function(commas, no_in) {
  13419. var start = S.token;
  13420. var expr = maybe_assign(no_in);
  13421. if (commas && is("punc", ",")) {
  13422. next();
  13423. return new AST_Seq({
  13424. start: start,
  13425. car: expr,
  13426. cdr: expression(true, no_in),
  13427. end: peek()
  13428. });
  13429. }
  13430. return expr;
  13431. };
  13432. function in_loop(cont) {
  13433. ++S.in_loop;
  13434. var ret = cont();
  13435. --S.in_loop;
  13436. return ret;
  13437. }
  13438. if (options.expression) {
  13439. return expression(true);
  13440. }
  13441. return function() {
  13442. var start = S.token;
  13443. var body = [];
  13444. while (!is("eof")) body.push(statement());
  13445. var end = prev();
  13446. var toplevel = options.toplevel;
  13447. if (toplevel) {
  13448. toplevel.body = toplevel.body.concat(body);
  13449. toplevel.end = end;
  13450. } else {
  13451. toplevel = new AST_Toplevel({
  13452. start: start,
  13453. body: body,
  13454. end: end
  13455. });
  13456. }
  13457. return toplevel;
  13458. }();
  13459. }
  13460. "use strict";
  13461. function TreeTransformer(before, after) {
  13462. TreeWalker.call(this);
  13463. this.before = before;
  13464. this.after = after;
  13465. }
  13466. TreeTransformer.prototype = new TreeWalker();
  13467. (function(undefined) {
  13468. function _(node, descend) {
  13469. node.DEFMETHOD("transform", function(tw, in_list) {
  13470. var x, y;
  13471. tw.push(this);
  13472. if (tw.before) x = tw.before(this, descend, in_list);
  13473. if (x === undefined) {
  13474. if (!tw.after) {
  13475. x = this;
  13476. descend(x, tw);
  13477. } else {
  13478. tw.stack[tw.stack.length - 1] = x = this.clone();
  13479. descend(x, tw);
  13480. y = tw.after(x, in_list);
  13481. if (y !== undefined) x = y;
  13482. }
  13483. }
  13484. tw.pop();
  13485. return x;
  13486. });
  13487. }
  13488. function do_list(list, tw) {
  13489. return MAP(list, function(node) {
  13490. return node.transform(tw, true);
  13491. });
  13492. }
  13493. _(AST_Node, noop);
  13494. _(AST_LabeledStatement, function(self, tw) {
  13495. self.label = self.label.transform(tw);
  13496. self.body = self.body.transform(tw);
  13497. });
  13498. _(AST_SimpleStatement, function(self, tw) {
  13499. self.body = self.body.transform(tw);
  13500. });
  13501. _(AST_Block, function(self, tw) {
  13502. self.body = do_list(self.body, tw);
  13503. });
  13504. _(AST_DWLoop, function(self, tw) {
  13505. self.condition = self.condition.transform(tw);
  13506. self.body = self.body.transform(tw);
  13507. });
  13508. _(AST_For, function(self, tw) {
  13509. if (self.init) self.init = self.init.transform(tw);
  13510. if (self.condition) self.condition = self.condition.transform(tw);
  13511. if (self.step) self.step = self.step.transform(tw);
  13512. self.body = self.body.transform(tw);
  13513. });
  13514. _(AST_ForIn, function(self, tw) {
  13515. self.init = self.init.transform(tw);
  13516. self.object = self.object.transform(tw);
  13517. self.body = self.body.transform(tw);
  13518. });
  13519. _(AST_With, function(self, tw) {
  13520. self.expression = self.expression.transform(tw);
  13521. self.body = self.body.transform(tw);
  13522. });
  13523. _(AST_Exit, function(self, tw) {
  13524. if (self.value) self.value = self.value.transform(tw);
  13525. });
  13526. _(AST_LoopControl, function(self, tw) {
  13527. if (self.label) self.label = self.label.transform(tw);
  13528. });
  13529. _(AST_If, function(self, tw) {
  13530. self.condition = self.condition.transform(tw);
  13531. self.body = self.body.transform(tw);
  13532. if (self.alternative) self.alternative = self.alternative.transform(tw);
  13533. });
  13534. _(AST_Switch, function(self, tw) {
  13535. self.expression = self.expression.transform(tw);
  13536. self.body = do_list(self.body, tw);
  13537. });
  13538. _(AST_Case, function(self, tw) {
  13539. self.expression = self.expression.transform(tw);
  13540. self.body = do_list(self.body, tw);
  13541. });
  13542. _(AST_Try, function(self, tw) {
  13543. self.body = do_list(self.body, tw);
  13544. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  13545. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  13546. });
  13547. _(AST_Catch, function(self, tw) {
  13548. self.argname = self.argname.transform(tw);
  13549. self.body = do_list(self.body, tw);
  13550. });
  13551. _(AST_Definitions, function(self, tw) {
  13552. self.definitions = do_list(self.definitions, tw);
  13553. });
  13554. _(AST_VarDef, function(self, tw) {
  13555. self.name = self.name.transform(tw);
  13556. if (self.value) self.value = self.value.transform(tw);
  13557. });
  13558. _(AST_Lambda, function(self, tw) {
  13559. if (self.name) self.name = self.name.transform(tw);
  13560. self.argnames = do_list(self.argnames, tw);
  13561. self.body = do_list(self.body, tw);
  13562. });
  13563. _(AST_Call, function(self, tw) {
  13564. self.expression = self.expression.transform(tw);
  13565. self.args = do_list(self.args, tw);
  13566. });
  13567. _(AST_Seq, function(self, tw) {
  13568. self.car = self.car.transform(tw);
  13569. self.cdr = self.cdr.transform(tw);
  13570. });
  13571. _(AST_Dot, function(self, tw) {
  13572. self.expression = self.expression.transform(tw);
  13573. });
  13574. _(AST_Sub, function(self, tw) {
  13575. self.expression = self.expression.transform(tw);
  13576. self.property = self.property.transform(tw);
  13577. });
  13578. _(AST_Unary, function(self, tw) {
  13579. self.expression = self.expression.transform(tw);
  13580. });
  13581. _(AST_Binary, function(self, tw) {
  13582. self.left = self.left.transform(tw);
  13583. self.right = self.right.transform(tw);
  13584. });
  13585. _(AST_Conditional, function(self, tw) {
  13586. self.condition = self.condition.transform(tw);
  13587. self.consequent = self.consequent.transform(tw);
  13588. self.alternative = self.alternative.transform(tw);
  13589. });
  13590. _(AST_Array, function(self, tw) {
  13591. self.elements = do_list(self.elements, tw);
  13592. });
  13593. _(AST_Object, function(self, tw) {
  13594. self.properties = do_list(self.properties, tw);
  13595. });
  13596. _(AST_ObjectProperty, function(self, tw) {
  13597. self.value = self.value.transform(tw);
  13598. });
  13599. })();
  13600. "use strict";
  13601. function SymbolDef(scope, index, orig) {
  13602. this.name = orig.name;
  13603. this.orig = [ orig ];
  13604. this.scope = scope;
  13605. this.references = [];
  13606. this.global = false;
  13607. this.mangled_name = null;
  13608. this.undeclared = false;
  13609. this.constant = false;
  13610. this.index = index;
  13611. }
  13612. SymbolDef.prototype = {
  13613. unmangleable: function(options) {
  13614. return this.global && !(options && options.toplevel) || this.undeclared || !(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with);
  13615. },
  13616. mangle: function(options) {
  13617. if (!this.mangled_name && !this.unmangleable(options)) {
  13618. var s = this.scope;
  13619. if (!options.screw_ie8 && this.orig[0] instanceof AST_SymbolLambda) s = s.parent_scope;
  13620. this.mangled_name = s.next_mangled(options, this);
  13621. }
  13622. }
  13623. };
  13624. AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
  13625. options = defaults(options, {
  13626. screw_ie8: false
  13627. });
  13628. var self = this;
  13629. var scope = self.parent_scope = null;
  13630. var defun = null;
  13631. var nesting = 0;
  13632. var tw = new TreeWalker(function(node, descend) {
  13633. if (options.screw_ie8 && node instanceof AST_Catch) {
  13634. var save_scope = scope;
  13635. scope = new AST_Scope(node);
  13636. scope.init_scope_vars(nesting);
  13637. scope.parent_scope = save_scope;
  13638. descend();
  13639. scope = save_scope;
  13640. return true;
  13641. }
  13642. if (node instanceof AST_Scope) {
  13643. node.init_scope_vars(nesting);
  13644. var save_scope = node.parent_scope = scope;
  13645. var save_defun = defun;
  13646. defun = scope = node;
  13647. ++nesting;
  13648. descend();
  13649. --nesting;
  13650. scope = save_scope;
  13651. defun = save_defun;
  13652. return true;
  13653. }
  13654. if (node instanceof AST_Directive) {
  13655. node.scope = scope;
  13656. push_uniq(scope.directives, node.value);
  13657. return true;
  13658. }
  13659. if (node instanceof AST_With) {
  13660. for (var s = scope; s; s = s.parent_scope) s.uses_with = true;
  13661. return;
  13662. }
  13663. if (node instanceof AST_Symbol) {
  13664. node.scope = scope;
  13665. }
  13666. if (node instanceof AST_SymbolLambda) {
  13667. defun.def_function(node);
  13668. } else if (node instanceof AST_SymbolDefun) {
  13669. (node.scope = defun.parent_scope).def_function(node);
  13670. } else if (node instanceof AST_SymbolVar || node instanceof AST_SymbolConst) {
  13671. var def = defun.def_variable(node);
  13672. def.constant = node instanceof AST_SymbolConst;
  13673. def.init = tw.parent().value;
  13674. } else if (node instanceof AST_SymbolCatch) {
  13675. (options.screw_ie8 ? scope : defun).def_variable(node);
  13676. }
  13677. });
  13678. self.walk(tw);
  13679. var func = null;
  13680. var globals = self.globals = new Dictionary();
  13681. var tw = new TreeWalker(function(node, descend) {
  13682. if (node instanceof AST_Lambda) {
  13683. var prev_func = func;
  13684. func = node;
  13685. descend();
  13686. func = prev_func;
  13687. return true;
  13688. }
  13689. if (node instanceof AST_SymbolRef) {
  13690. var name = node.name;
  13691. var sym = node.scope.find_variable(name);
  13692. if (!sym) {
  13693. var g;
  13694. if (globals.has(name)) {
  13695. g = globals.get(name);
  13696. } else {
  13697. g = new SymbolDef(self, globals.size(), node);
  13698. g.undeclared = true;
  13699. g.global = true;
  13700. globals.set(name, g);
  13701. }
  13702. node.thedef = g;
  13703. if (name == "eval" && tw.parent() instanceof AST_Call) {
  13704. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) s.uses_eval = true;
  13705. }
  13706. if (func && name == "arguments") {
  13707. func.uses_arguments = true;
  13708. }
  13709. } else {
  13710. node.thedef = sym;
  13711. }
  13712. node.reference();
  13713. return true;
  13714. }
  13715. });
  13716. self.walk(tw);
  13717. });
  13718. AST_Scope.DEFMETHOD("init_scope_vars", function(nesting) {
  13719. this.directives = [];
  13720. this.variables = new Dictionary();
  13721. this.functions = new Dictionary();
  13722. this.uses_with = false;
  13723. this.uses_eval = false;
  13724. this.parent_scope = null;
  13725. this.enclosed = [];
  13726. this.cname = -1;
  13727. this.nesting = nesting;
  13728. });
  13729. AST_Scope.DEFMETHOD("strict", function() {
  13730. return this.has_directive("use strict");
  13731. });
  13732. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  13733. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  13734. this.uses_arguments = false;
  13735. });
  13736. AST_SymbolRef.DEFMETHOD("reference", function() {
  13737. var def = this.definition();
  13738. def.references.push(this);
  13739. var s = this.scope;
  13740. while (s) {
  13741. push_uniq(s.enclosed, def);
  13742. if (s === def.scope) break;
  13743. s = s.parent_scope;
  13744. }
  13745. this.frame = this.scope.nesting - def.scope.nesting;
  13746. });
  13747. AST_Scope.DEFMETHOD("find_variable", function(name) {
  13748. if (name instanceof AST_Symbol) name = name.name;
  13749. return this.variables.get(name) || this.parent_scope && this.parent_scope.find_variable(name);
  13750. });
  13751. AST_Scope.DEFMETHOD("has_directive", function(value) {
  13752. return this.parent_scope && this.parent_scope.has_directive(value) || (this.directives.indexOf(value) >= 0 ? this : null);
  13753. });
  13754. AST_Scope.DEFMETHOD("def_function", function(symbol) {
  13755. this.functions.set(symbol.name, this.def_variable(symbol));
  13756. });
  13757. AST_Scope.DEFMETHOD("def_variable", function(symbol) {
  13758. var def;
  13759. if (!this.variables.has(symbol.name)) {
  13760. def = new SymbolDef(this, this.variables.size(), symbol);
  13761. this.variables.set(symbol.name, def);
  13762. def.global = !this.parent_scope;
  13763. } else {
  13764. def = this.variables.get(symbol.name);
  13765. def.orig.push(symbol);
  13766. }
  13767. return symbol.thedef = def;
  13768. });
  13769. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  13770. var ext = this.enclosed;
  13771. out: while (true) {
  13772. var m = base54(++this.cname);
  13773. if (!is_identifier(m)) continue;
  13774. if (options.except.indexOf(m) >= 0) continue;
  13775. for (var i = ext.length; --i >= 0; ) {
  13776. var sym = ext[i];
  13777. var name = sym.mangled_name || sym.unmangleable(options) && sym.name;
  13778. if (m == name) continue out;
  13779. }
  13780. return m;
  13781. }
  13782. });
  13783. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  13784. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  13785. while (true) {
  13786. var name = AST_Lambda.prototype.next_mangled.call(this, options, def);
  13787. if (!(tricky_def && tricky_def.mangled_name == name)) return name;
  13788. }
  13789. });
  13790. AST_Scope.DEFMETHOD("references", function(sym) {
  13791. if (sym instanceof AST_Symbol) sym = sym.definition();
  13792. return this.enclosed.indexOf(sym) < 0 ? null : sym;
  13793. });
  13794. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  13795. return this.definition().unmangleable(options);
  13796. });
  13797. AST_SymbolAccessor.DEFMETHOD("unmangleable", function() {
  13798. return true;
  13799. });
  13800. AST_Label.DEFMETHOD("unmangleable", function() {
  13801. return false;
  13802. });
  13803. AST_Symbol.DEFMETHOD("unreferenced", function() {
  13804. return this.definition().references.length == 0 && !(this.scope.uses_eval || this.scope.uses_with);
  13805. });
  13806. AST_Symbol.DEFMETHOD("undeclared", function() {
  13807. return this.definition().undeclared;
  13808. });
  13809. AST_LabelRef.DEFMETHOD("undeclared", function() {
  13810. return false;
  13811. });
  13812. AST_Label.DEFMETHOD("undeclared", function() {
  13813. return false;
  13814. });
  13815. AST_Symbol.DEFMETHOD("definition", function() {
  13816. return this.thedef;
  13817. });
  13818. AST_Symbol.DEFMETHOD("global", function() {
  13819. return this.definition().global;
  13820. });
  13821. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  13822. return defaults(options, {
  13823. except: [],
  13824. eval: false,
  13825. sort: false,
  13826. toplevel: false,
  13827. screw_ie8: false
  13828. });
  13829. });
  13830. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  13831. options = this._default_mangler_options(options);
  13832. var lname = -1;
  13833. var to_mangle = [];
  13834. var tw = new TreeWalker(function(node, descend) {
  13835. if (node instanceof AST_LabeledStatement) {
  13836. var save_nesting = lname;
  13837. descend();
  13838. lname = save_nesting;
  13839. return true;
  13840. }
  13841. if (node instanceof AST_Scope) {
  13842. var p = tw.parent(), a = [];
  13843. node.variables.each(function(symbol) {
  13844. if (options.except.indexOf(symbol.name) < 0) {
  13845. a.push(symbol);
  13846. }
  13847. });
  13848. if (options.sort) a.sort(function(a, b) {
  13849. return b.references.length - a.references.length;
  13850. });
  13851. to_mangle.push.apply(to_mangle, a);
  13852. return;
  13853. }
  13854. if (node instanceof AST_Label) {
  13855. var name;
  13856. do name = base54(++lname); while (!is_identifier(name));
  13857. node.mangled_name = name;
  13858. return true;
  13859. }
  13860. if (options.screw_ie8 && node instanceof AST_SymbolCatch) {
  13861. to_mangle.push(node.definition());
  13862. return;
  13863. }
  13864. });
  13865. this.walk(tw);
  13866. to_mangle.forEach(function(def) {
  13867. def.mangle(options);
  13868. });
  13869. });
  13870. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  13871. options = this._default_mangler_options(options);
  13872. var tw = new TreeWalker(function(node) {
  13873. 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) {
  13874. base54.consider("if");
  13875. if (node.alternative) base54.consider("else");
  13876. } 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);
  13877. });
  13878. this.walk(tw);
  13879. base54.sort();
  13880. });
  13881. var base54 = function() {
  13882. var string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
  13883. var chars, frequency;
  13884. function reset() {
  13885. frequency = Object.create(null);
  13886. chars = string.split("").map(function(ch) {
  13887. return ch.charCodeAt(0);
  13888. });
  13889. chars.forEach(function(ch) {
  13890. frequency[ch] = 0;
  13891. });
  13892. }
  13893. base54.consider = function(str) {
  13894. for (var i = str.length; --i >= 0; ) {
  13895. var code = str.charCodeAt(i);
  13896. if (code in frequency) ++frequency[code];
  13897. }
  13898. };
  13899. base54.sort = function() {
  13900. chars = mergeSort(chars, function(a, b) {
  13901. if (is_digit(a) && !is_digit(b)) return 1;
  13902. if (is_digit(b) && !is_digit(a)) return -1;
  13903. return frequency[b] - frequency[a];
  13904. });
  13905. };
  13906. base54.reset = reset;
  13907. reset();
  13908. base54.get = function() {
  13909. return chars;
  13910. };
  13911. base54.freq = function() {
  13912. return frequency;
  13913. };
  13914. function base54(num) {
  13915. var ret = "", base = 54;
  13916. do {
  13917. ret += String.fromCharCode(chars[num % base]);
  13918. num = Math.floor(num / base);
  13919. base = 64;
  13920. } while (num > 0);
  13921. return ret;
  13922. }
  13923. return base54;
  13924. }();
  13925. AST_Toplevel.DEFMETHOD("scope_warnings", function(options) {
  13926. options = defaults(options, {
  13927. undeclared: false,
  13928. unreferenced: true,
  13929. assign_to_global: true,
  13930. func_arguments: true,
  13931. nested_defuns: true,
  13932. eval: true
  13933. });
  13934. var tw = new TreeWalker(function(node) {
  13935. if (options.undeclared && node instanceof AST_SymbolRef && node.undeclared()) {
  13936. AST_Node.warn("Undeclared symbol: {name} [{file}:{line},{col}]", {
  13937. name: node.name,
  13938. file: node.start.file,
  13939. line: node.start.line,
  13940. col: node.start.col
  13941. });
  13942. }
  13943. if (options.assign_to_global) {
  13944. var sym = null;
  13945. 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;
  13946. if (sym && (sym.undeclared() || sym.global() && sym.scope !== sym.definition().scope)) {
  13947. AST_Node.warn("{msg}: {name} [{file}:{line},{col}]", {
  13948. msg: sym.undeclared() ? "Accidental global?" : "Assignment to global",
  13949. name: sym.name,
  13950. file: sym.start.file,
  13951. line: sym.start.line,
  13952. col: sym.start.col
  13953. });
  13954. }
  13955. }
  13956. if (options.eval && node instanceof AST_SymbolRef && node.undeclared() && node.name == "eval") {
  13957. AST_Node.warn("Eval is used [{file}:{line},{col}]", node.start);
  13958. }
  13959. if (options.unreferenced && (node instanceof AST_SymbolDeclaration || node instanceof AST_Label) && node.unreferenced()) {
  13960. AST_Node.warn("{type} {name} is declared but not referenced [{file}:{line},{col}]", {
  13961. type: node instanceof AST_Label ? "Label" : "Symbol",
  13962. name: node.name,
  13963. file: node.start.file,
  13964. line: node.start.line,
  13965. col: node.start.col
  13966. });
  13967. }
  13968. if (options.func_arguments && node instanceof AST_Lambda && node.uses_arguments) {
  13969. AST_Node.warn("arguments used in function {name} [{file}:{line},{col}]", {
  13970. name: node.name ? node.name.name : "anonymous",
  13971. file: node.start.file,
  13972. line: node.start.line,
  13973. col: node.start.col
  13974. });
  13975. }
  13976. if (options.nested_defuns && node instanceof AST_Defun && !(tw.parent() instanceof AST_Scope)) {
  13977. AST_Node.warn('Function {name} declared in nested statement "{type}" [{file}:{line},{col}]', {
  13978. name: node.name.name,
  13979. type: tw.parent().TYPE,
  13980. file: node.start.file,
  13981. line: node.start.line,
  13982. col: node.start.col
  13983. });
  13984. }
  13985. });
  13986. this.walk(tw);
  13987. });
  13988. "use strict";
  13989. function OutputStream(options) {
  13990. options = defaults(options, {
  13991. indent_start: 0,
  13992. indent_level: 4,
  13993. quote_keys: false,
  13994. space_colon: true,
  13995. ascii_only: false,
  13996. unescape_regexps: false,
  13997. inline_script: false,
  13998. width: 80,
  13999. max_line_len: 32e3,
  14000. beautify: false,
  14001. source_map: null,
  14002. bracketize: false,
  14003. semicolons: true,
  14004. comments: false,
  14005. preserve_line: false,
  14006. screw_ie8: false,
  14007. preamble: null
  14008. }, true);
  14009. var indentation = 0;
  14010. var current_col = 0;
  14011. var current_line = 1;
  14012. var current_pos = 0;
  14013. var OUTPUT = "";
  14014. function to_ascii(str, identifier) {
  14015. return str.replace(/[\u0080-\uffff]/g, function(ch) {
  14016. var code = ch.charCodeAt(0).toString(16);
  14017. if (code.length <= 2 && !identifier) {
  14018. while (code.length < 2) code = "0" + code;
  14019. return "\\x" + code;
  14020. } else {
  14021. while (code.length < 4) code = "0" + code;
  14022. return "\\u" + code;
  14023. }
  14024. });
  14025. }
  14026. function make_string(str) {
  14027. var dq = 0, sq = 0;
  14028. str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g, function(s) {
  14029. switch (s) {
  14030. case "\\":
  14031. return "\\\\";
  14032. case "\b":
  14033. return "\\b";
  14034. case "\f":
  14035. return "\\f";
  14036. case "\n":
  14037. return "\\n";
  14038. case "\r":
  14039. return "\\r";
  14040. case "\u2028":
  14041. return "\\u2028";
  14042. case "\u2029":
  14043. return "\\u2029";
  14044. case '"':
  14045. ++dq;
  14046. return '"';
  14047. case "'":
  14048. ++sq;
  14049. return "'";
  14050. case "\x00":
  14051. return "\\x00";
  14052. }
  14053. return s;
  14054. });
  14055. if (options.ascii_only) str = to_ascii(str);
  14056. if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'"; else return '"' + str.replace(/\x22/g, '\\"') + '"';
  14057. }
  14058. function encode_string(str) {
  14059. var ret = make_string(str);
  14060. if (options.inline_script) ret = ret.replace(/<\x2fscript([>\/\t\n\f\r ])/gi, "<\\/script$1");
  14061. return ret;
  14062. }
  14063. function make_name(name) {
  14064. name = name.toString();
  14065. if (options.ascii_only) name = to_ascii(name, true);
  14066. return name;
  14067. }
  14068. function make_indent(back) {
  14069. return repeat_string(" ", options.indent_start + indentation - back * options.indent_level);
  14070. }
  14071. var might_need_space = false;
  14072. var might_need_semicolon = false;
  14073. var last = null;
  14074. function last_char() {
  14075. return last.charAt(last.length - 1);
  14076. }
  14077. function maybe_newline() {
  14078. if (options.max_line_len && current_col > options.max_line_len) print("\n");
  14079. }
  14080. var requireSemicolonChars = makePredicate("( [ + * / - , .");
  14081. function print(str) {
  14082. str = String(str);
  14083. var ch = str.charAt(0);
  14084. if (might_need_semicolon) {
  14085. if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) {
  14086. if (options.semicolons || requireSemicolonChars(ch)) {
  14087. OUTPUT += ";";
  14088. current_col++;
  14089. current_pos++;
  14090. } else {
  14091. OUTPUT += "\n";
  14092. current_pos++;
  14093. current_line++;
  14094. current_col = 0;
  14095. }
  14096. if (!options.beautify) might_need_space = false;
  14097. }
  14098. might_need_semicolon = false;
  14099. maybe_newline();
  14100. }
  14101. if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {
  14102. var target_line = stack[stack.length - 1].start.line;
  14103. while (current_line < target_line) {
  14104. OUTPUT += "\n";
  14105. current_pos++;
  14106. current_line++;
  14107. current_col = 0;
  14108. might_need_space = false;
  14109. }
  14110. }
  14111. if (might_need_space) {
  14112. var prev = last_char();
  14113. if (is_identifier_char(prev) && (is_identifier_char(ch) || ch == "\\") || /^[\+\-\/]$/.test(ch) && ch == prev) {
  14114. OUTPUT += " ";
  14115. current_col++;
  14116. current_pos++;
  14117. }
  14118. might_need_space = false;
  14119. }
  14120. var a = str.split(/\r?\n/), n = a.length - 1;
  14121. current_line += n;
  14122. if (n == 0) {
  14123. current_col += a[n].length;
  14124. } else {
  14125. current_col = a[n].length;
  14126. }
  14127. current_pos += str.length;
  14128. last = str;
  14129. OUTPUT += str;
  14130. }
  14131. var space = options.beautify ? function() {
  14132. print(" ");
  14133. } : function() {
  14134. might_need_space = true;
  14135. };
  14136. var indent = options.beautify ? function(half) {
  14137. if (options.beautify) {
  14138. print(make_indent(half ? .5 : 0));
  14139. }
  14140. } : noop;
  14141. var with_indent = options.beautify ? function(col, cont) {
  14142. if (col === true) col = next_indent();
  14143. var save_indentation = indentation;
  14144. indentation = col;
  14145. var ret = cont();
  14146. indentation = save_indentation;
  14147. return ret;
  14148. } : function(col, cont) {
  14149. return cont();
  14150. };
  14151. var newline = options.beautify ? function() {
  14152. print("\n");
  14153. } : noop;
  14154. var semicolon = options.beautify ? function() {
  14155. print(";");
  14156. } : function() {
  14157. might_need_semicolon = true;
  14158. };
  14159. function force_semicolon() {
  14160. might_need_semicolon = false;
  14161. print(";");
  14162. }
  14163. function next_indent() {
  14164. return indentation + options.indent_level;
  14165. }
  14166. function with_block(cont) {
  14167. var ret;
  14168. print("{");
  14169. newline();
  14170. with_indent(next_indent(), function() {
  14171. ret = cont();
  14172. });
  14173. indent();
  14174. print("}");
  14175. return ret;
  14176. }
  14177. function with_parens(cont) {
  14178. print("(");
  14179. var ret = cont();
  14180. print(")");
  14181. return ret;
  14182. }
  14183. function with_square(cont) {
  14184. print("[");
  14185. var ret = cont();
  14186. print("]");
  14187. return ret;
  14188. }
  14189. function comma() {
  14190. print(",");
  14191. space();
  14192. }
  14193. function colon() {
  14194. print(":");
  14195. if (options.space_colon) space();
  14196. }
  14197. var add_mapping = options.source_map ? function(token, name) {
  14198. try {
  14199. if (token) options.source_map.add(token.file || "?", current_line, current_col, token.line, token.col, !name && token.type == "name" ? token.value : name);
  14200. } catch (ex) {
  14201. AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", {
  14202. file: token.file,
  14203. line: token.line,
  14204. col: token.col,
  14205. cline: current_line,
  14206. ccol: current_col,
  14207. name: name || ""
  14208. });
  14209. }
  14210. } : noop;
  14211. function get() {
  14212. return OUTPUT;
  14213. }
  14214. if (options.preamble) {
  14215. print(options.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  14216. }
  14217. var stack = [];
  14218. return {
  14219. get: get,
  14220. toString: get,
  14221. indent: indent,
  14222. indentation: function() {
  14223. return indentation;
  14224. },
  14225. current_width: function() {
  14226. return current_col - indentation;
  14227. },
  14228. should_break: function() {
  14229. return options.width && this.current_width() >= options.width;
  14230. },
  14231. newline: newline,
  14232. print: print,
  14233. space: space,
  14234. comma: comma,
  14235. colon: colon,
  14236. last: function() {
  14237. return last;
  14238. },
  14239. semicolon: semicolon,
  14240. force_semicolon: force_semicolon,
  14241. to_ascii: to_ascii,
  14242. print_name: function(name) {
  14243. print(make_name(name));
  14244. },
  14245. print_string: function(str) {
  14246. print(encode_string(str));
  14247. },
  14248. next_indent: next_indent,
  14249. with_indent: with_indent,
  14250. with_block: with_block,
  14251. with_parens: with_parens,
  14252. with_square: with_square,
  14253. add_mapping: add_mapping,
  14254. option: function(opt) {
  14255. return options[opt];
  14256. },
  14257. line: function() {
  14258. return current_line;
  14259. },
  14260. col: function() {
  14261. return current_col;
  14262. },
  14263. pos: function() {
  14264. return current_pos;
  14265. },
  14266. push_node: function(node) {
  14267. stack.push(node);
  14268. },
  14269. pop_node: function() {
  14270. return stack.pop();
  14271. },
  14272. stack: function() {
  14273. return stack;
  14274. },
  14275. parent: function(n) {
  14276. return stack[stack.length - 2 - (n || 0)];
  14277. }
  14278. };
  14279. }
  14280. (function() {
  14281. function DEFPRINT(nodetype, generator) {
  14282. nodetype.DEFMETHOD("_codegen", generator);
  14283. }
  14284. AST_Node.DEFMETHOD("print", function(stream, force_parens) {
  14285. var self = this, generator = self._codegen;
  14286. function doit() {
  14287. self.add_comments(stream);
  14288. self.add_source_map(stream);
  14289. generator(self, stream);
  14290. }
  14291. stream.push_node(self);
  14292. if (force_parens || self.needs_parens(stream)) {
  14293. stream.with_parens(doit);
  14294. } else {
  14295. doit();
  14296. }
  14297. stream.pop_node();
  14298. });
  14299. AST_Node.DEFMETHOD("print_to_string", function(options) {
  14300. var s = OutputStream(options);
  14301. this.print(s);
  14302. return s.get();
  14303. });
  14304. AST_Node.DEFMETHOD("add_comments", function(output) {
  14305. var c = output.option("comments"), self = this;
  14306. if (c) {
  14307. var start = self.start;
  14308. if (start && !start._comments_dumped) {
  14309. start._comments_dumped = true;
  14310. var comments = start.comments_before || [];
  14311. if (self instanceof AST_Exit && self.value) {
  14312. self.value.walk(new TreeWalker(function(node) {
  14313. if (node.start && node.start.comments_before) {
  14314. comments = comments.concat(node.start.comments_before);
  14315. node.start.comments_before = [];
  14316. }
  14317. if (node instanceof AST_Function || node instanceof AST_Array || node instanceof AST_Object) {
  14318. return true;
  14319. }
  14320. }));
  14321. }
  14322. if (c.test) {
  14323. comments = comments.filter(function(comment) {
  14324. return c.test(comment.value);
  14325. });
  14326. } else if (typeof c == "function") {
  14327. comments = comments.filter(function(comment) {
  14328. return c(self, comment);
  14329. });
  14330. }
  14331. comments.forEach(function(c) {
  14332. if (/comment[134]/.test(c.type)) {
  14333. output.print("//" + c.value + "\n");
  14334. output.indent();
  14335. } else if (c.type == "comment2") {
  14336. output.print("/*" + c.value + "*/");
  14337. if (start.nlb) {
  14338. output.print("\n");
  14339. output.indent();
  14340. } else {
  14341. output.space();
  14342. }
  14343. }
  14344. });
  14345. }
  14346. }
  14347. });
  14348. function PARENS(nodetype, func) {
  14349. if (Array.isArray(nodetype)) {
  14350. nodetype.forEach(function(nodetype) {
  14351. PARENS(nodetype, func);
  14352. });
  14353. } else {
  14354. nodetype.DEFMETHOD("needs_parens", func);
  14355. }
  14356. }
  14357. PARENS(AST_Node, function() {
  14358. return false;
  14359. });
  14360. PARENS(AST_Function, function(output) {
  14361. return first_in_statement(output);
  14362. });
  14363. PARENS(AST_Object, function(output) {
  14364. return first_in_statement(output);
  14365. });
  14366. PARENS([ AST_Unary, AST_Undefined ], function(output) {
  14367. var p = output.parent();
  14368. return p instanceof AST_PropAccess && p.expression === this;
  14369. });
  14370. PARENS(AST_Seq, function(output) {
  14371. var p = output.parent();
  14372. 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;
  14373. });
  14374. PARENS(AST_Binary, function(output) {
  14375. var p = output.parent();
  14376. if (p instanceof AST_Call && p.expression === this) return true;
  14377. if (p instanceof AST_Unary) return true;
  14378. if (p instanceof AST_PropAccess && p.expression === this) return true;
  14379. if (p instanceof AST_Binary) {
  14380. var po = p.operator, pp = PRECEDENCE[po];
  14381. var so = this.operator, sp = PRECEDENCE[so];
  14382. if (pp > sp || pp == sp && this === p.right) {
  14383. return true;
  14384. }
  14385. }
  14386. });
  14387. PARENS(AST_PropAccess, function(output) {
  14388. var p = output.parent();
  14389. if (p instanceof AST_New && p.expression === this) {
  14390. try {
  14391. this.walk(new TreeWalker(function(node) {
  14392. if (node instanceof AST_Call) throw p;
  14393. }));
  14394. } catch (ex) {
  14395. if (ex !== p) throw ex;
  14396. return true;
  14397. }
  14398. }
  14399. });
  14400. PARENS(AST_Call, function(output) {
  14401. var p = output.parent(), p1;
  14402. if (p instanceof AST_New && p.expression === this) return true;
  14403. return this.expression instanceof AST_Function && p instanceof AST_PropAccess && p.expression === this && (p1 = output.parent(1)) instanceof AST_Assign && p1.left === p;
  14404. });
  14405. PARENS(AST_New, function(output) {
  14406. var p = output.parent();
  14407. if (no_constructor_parens(this, output) && (p instanceof AST_PropAccess || p instanceof AST_Call && p.expression === this)) return true;
  14408. });
  14409. PARENS(AST_Number, function(output) {
  14410. var p = output.parent();
  14411. if (this.getValue() < 0 && p instanceof AST_PropAccess && p.expression === this) return true;
  14412. });
  14413. PARENS(AST_NaN, function(output) {
  14414. var p = output.parent();
  14415. if (p instanceof AST_PropAccess && p.expression === this) return true;
  14416. });
  14417. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  14418. var p = output.parent();
  14419. if (p instanceof AST_Unary) return true;
  14420. if (p instanceof AST_Binary && !(p instanceof AST_Assign)) return true;
  14421. if (p instanceof AST_Call && p.expression === this) return true;
  14422. if (p instanceof AST_Conditional && p.condition === this) return true;
  14423. if (p instanceof AST_PropAccess && p.expression === this) return true;
  14424. });
  14425. DEFPRINT(AST_Directive, function(self, output) {
  14426. output.print_string(self.value);
  14427. output.semicolon();
  14428. });
  14429. DEFPRINT(AST_Debugger, function(self, output) {
  14430. output.print("debugger");
  14431. output.semicolon();
  14432. });
  14433. function display_body(body, is_toplevel, output) {
  14434. var last = body.length - 1;
  14435. body.forEach(function(stmt, i) {
  14436. if (!(stmt instanceof AST_EmptyStatement)) {
  14437. output.indent();
  14438. stmt.print(output);
  14439. if (!(i == last && is_toplevel)) {
  14440. output.newline();
  14441. if (is_toplevel) output.newline();
  14442. }
  14443. }
  14444. });
  14445. }
  14446. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  14447. force_statement(this.body, output);
  14448. });
  14449. DEFPRINT(AST_Statement, function(self, output) {
  14450. self.body.print(output);
  14451. output.semicolon();
  14452. });
  14453. DEFPRINT(AST_Toplevel, function(self, output) {
  14454. display_body(self.body, true, output);
  14455. output.print("");
  14456. });
  14457. DEFPRINT(AST_LabeledStatement, function(self, output) {
  14458. self.label.print(output);
  14459. output.colon();
  14460. self.body.print(output);
  14461. });
  14462. DEFPRINT(AST_SimpleStatement, function(self, output) {
  14463. self.body.print(output);
  14464. output.semicolon();
  14465. });
  14466. function print_bracketed(body, output) {
  14467. if (body.length > 0) output.with_block(function() {
  14468. display_body(body, false, output);
  14469. }); else output.print("{}");
  14470. }
  14471. DEFPRINT(AST_BlockStatement, function(self, output) {
  14472. print_bracketed(self.body, output);
  14473. });
  14474. DEFPRINT(AST_EmptyStatement, function(self, output) {
  14475. output.semicolon();
  14476. });
  14477. DEFPRINT(AST_Do, function(self, output) {
  14478. output.print("do");
  14479. output.space();
  14480. self._do_print_body(output);
  14481. output.space();
  14482. output.print("while");
  14483. output.space();
  14484. output.with_parens(function() {
  14485. self.condition.print(output);
  14486. });
  14487. output.semicolon();
  14488. });
  14489. DEFPRINT(AST_While, function(self, output) {
  14490. output.print("while");
  14491. output.space();
  14492. output.with_parens(function() {
  14493. self.condition.print(output);
  14494. });
  14495. output.space();
  14496. self._do_print_body(output);
  14497. });
  14498. DEFPRINT(AST_For, function(self, output) {
  14499. output.print("for");
  14500. output.space();
  14501. output.with_parens(function() {
  14502. if (self.init && !(self.init instanceof AST_EmptyStatement)) {
  14503. if (self.init instanceof AST_Definitions) {
  14504. self.init.print(output);
  14505. } else {
  14506. parenthesize_for_noin(self.init, output, true);
  14507. }
  14508. output.print(";");
  14509. output.space();
  14510. } else {
  14511. output.print(";");
  14512. }
  14513. if (self.condition) {
  14514. self.condition.print(output);
  14515. output.print(";");
  14516. output.space();
  14517. } else {
  14518. output.print(";");
  14519. }
  14520. if (self.step) {
  14521. self.step.print(output);
  14522. }
  14523. });
  14524. output.space();
  14525. self._do_print_body(output);
  14526. });
  14527. DEFPRINT(AST_ForIn, function(self, output) {
  14528. output.print("for");
  14529. output.space();
  14530. output.with_parens(function() {
  14531. self.init.print(output);
  14532. output.space();
  14533. output.print("in");
  14534. output.space();
  14535. self.object.print(output);
  14536. });
  14537. output.space();
  14538. self._do_print_body(output);
  14539. });
  14540. DEFPRINT(AST_With, function(self, output) {
  14541. output.print("with");
  14542. output.space();
  14543. output.with_parens(function() {
  14544. self.expression.print(output);
  14545. });
  14546. output.space();
  14547. self._do_print_body(output);
  14548. });
  14549. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  14550. var self = this;
  14551. if (!nokeyword) {
  14552. output.print("function");
  14553. }
  14554. if (self.name) {
  14555. output.space();
  14556. self.name.print(output);
  14557. }
  14558. output.with_parens(function() {
  14559. self.argnames.forEach(function(arg, i) {
  14560. if (i) output.comma();
  14561. arg.print(output);
  14562. });
  14563. });
  14564. output.space();
  14565. print_bracketed(self.body, output);
  14566. });
  14567. DEFPRINT(AST_Lambda, function(self, output) {
  14568. self._do_print(output);
  14569. });
  14570. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  14571. output.print(kind);
  14572. if (this.value) {
  14573. output.space();
  14574. this.value.print(output);
  14575. }
  14576. output.semicolon();
  14577. });
  14578. DEFPRINT(AST_Return, function(self, output) {
  14579. self._do_print(output, "return");
  14580. });
  14581. DEFPRINT(AST_Throw, function(self, output) {
  14582. self._do_print(output, "throw");
  14583. });
  14584. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  14585. output.print(kind);
  14586. if (this.label) {
  14587. output.space();
  14588. this.label.print(output);
  14589. }
  14590. output.semicolon();
  14591. });
  14592. DEFPRINT(AST_Break, function(self, output) {
  14593. self._do_print(output, "break");
  14594. });
  14595. DEFPRINT(AST_Continue, function(self, output) {
  14596. self._do_print(output, "continue");
  14597. });
  14598. function make_then(self, output) {
  14599. if (output.option("bracketize")) {
  14600. make_block(self.body, output);
  14601. return;
  14602. }
  14603. if (!self.body) return output.force_semicolon();
  14604. if (self.body instanceof AST_Do && !output.option("screw_ie8")) {
  14605. make_block(self.body, output);
  14606. return;
  14607. }
  14608. var b = self.body;
  14609. while (true) {
  14610. if (b instanceof AST_If) {
  14611. if (!b.alternative) {
  14612. make_block(self.body, output);
  14613. return;
  14614. }
  14615. b = b.alternative;
  14616. } else if (b instanceof AST_StatementWithBody) {
  14617. b = b.body;
  14618. } else break;
  14619. }
  14620. force_statement(self.body, output);
  14621. }
  14622. DEFPRINT(AST_If, function(self, output) {
  14623. output.print("if");
  14624. output.space();
  14625. output.with_parens(function() {
  14626. self.condition.print(output);
  14627. });
  14628. output.space();
  14629. if (self.alternative) {
  14630. make_then(self, output);
  14631. output.space();
  14632. output.print("else");
  14633. output.space();
  14634. force_statement(self.alternative, output);
  14635. } else {
  14636. self._do_print_body(output);
  14637. }
  14638. });
  14639. DEFPRINT(AST_Switch, function(self, output) {
  14640. output.print("switch");
  14641. output.space();
  14642. output.with_parens(function() {
  14643. self.expression.print(output);
  14644. });
  14645. output.space();
  14646. if (self.body.length > 0) output.with_block(function() {
  14647. self.body.forEach(function(stmt, i) {
  14648. if (i) output.newline();
  14649. output.indent(true);
  14650. stmt.print(output);
  14651. });
  14652. }); else output.print("{}");
  14653. });
  14654. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  14655. if (this.body.length > 0) {
  14656. output.newline();
  14657. this.body.forEach(function(stmt) {
  14658. output.indent();
  14659. stmt.print(output);
  14660. output.newline();
  14661. });
  14662. }
  14663. });
  14664. DEFPRINT(AST_Default, function(self, output) {
  14665. output.print("default:");
  14666. self._do_print_body(output);
  14667. });
  14668. DEFPRINT(AST_Case, function(self, output) {
  14669. output.print("case");
  14670. output.space();
  14671. self.expression.print(output);
  14672. output.print(":");
  14673. self._do_print_body(output);
  14674. });
  14675. DEFPRINT(AST_Try, function(self, output) {
  14676. output.print("try");
  14677. output.space();
  14678. print_bracketed(self.body, output);
  14679. if (self.bcatch) {
  14680. output.space();
  14681. self.bcatch.print(output);
  14682. }
  14683. if (self.bfinally) {
  14684. output.space();
  14685. self.bfinally.print(output);
  14686. }
  14687. });
  14688. DEFPRINT(AST_Catch, function(self, output) {
  14689. output.print("catch");
  14690. output.space();
  14691. output.with_parens(function() {
  14692. self.argname.print(output);
  14693. });
  14694. output.space();
  14695. print_bracketed(self.body, output);
  14696. });
  14697. DEFPRINT(AST_Finally, function(self, output) {
  14698. output.print("finally");
  14699. output.space();
  14700. print_bracketed(self.body, output);
  14701. });
  14702. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  14703. output.print(kind);
  14704. output.space();
  14705. this.definitions.forEach(function(def, i) {
  14706. if (i) output.comma();
  14707. def.print(output);
  14708. });
  14709. var p = output.parent();
  14710. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  14711. var avoid_semicolon = in_for && p.init === this;
  14712. if (!avoid_semicolon) output.semicolon();
  14713. });
  14714. DEFPRINT(AST_Var, function(self, output) {
  14715. self._do_print(output, "var");
  14716. });
  14717. DEFPRINT(AST_Const, function(self, output) {
  14718. self._do_print(output, "const");
  14719. });
  14720. function parenthesize_for_noin(node, output, noin) {
  14721. if (!noin) node.print(output); else try {
  14722. node.walk(new TreeWalker(function(node) {
  14723. if (node instanceof AST_Binary && node.operator == "in") throw output;
  14724. }));
  14725. node.print(output);
  14726. } catch (ex) {
  14727. if (ex !== output) throw ex;
  14728. node.print(output, true);
  14729. }
  14730. }
  14731. DEFPRINT(AST_VarDef, function(self, output) {
  14732. self.name.print(output);
  14733. if (self.value) {
  14734. output.space();
  14735. output.print("=");
  14736. output.space();
  14737. var p = output.parent(1);
  14738. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  14739. parenthesize_for_noin(self.value, output, noin);
  14740. }
  14741. });
  14742. DEFPRINT(AST_Call, function(self, output) {
  14743. self.expression.print(output);
  14744. if (self instanceof AST_New && no_constructor_parens(self, output)) return;
  14745. output.with_parens(function() {
  14746. self.args.forEach(function(expr, i) {
  14747. if (i) output.comma();
  14748. expr.print(output);
  14749. });
  14750. });
  14751. });
  14752. DEFPRINT(AST_New, function(self, output) {
  14753. output.print("new");
  14754. output.space();
  14755. AST_Call.prototype._codegen(self, output);
  14756. });
  14757. AST_Seq.DEFMETHOD("_do_print", function(output) {
  14758. this.car.print(output);
  14759. if (this.cdr) {
  14760. output.comma();
  14761. if (output.should_break()) {
  14762. output.newline();
  14763. output.indent();
  14764. }
  14765. this.cdr.print(output);
  14766. }
  14767. });
  14768. DEFPRINT(AST_Seq, function(self, output) {
  14769. self._do_print(output);
  14770. });
  14771. DEFPRINT(AST_Dot, function(self, output) {
  14772. var expr = self.expression;
  14773. expr.print(output);
  14774. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  14775. if (!/[xa-f.]/i.test(output.last())) {
  14776. output.print(".");
  14777. }
  14778. }
  14779. output.print(".");
  14780. output.add_mapping(self.end);
  14781. output.print_name(self.property);
  14782. });
  14783. DEFPRINT(AST_Sub, function(self, output) {
  14784. self.expression.print(output);
  14785. output.print("[");
  14786. self.property.print(output);
  14787. output.print("]");
  14788. });
  14789. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  14790. var op = self.operator;
  14791. output.print(op);
  14792. if (/^[a-z]/i.test(op) || /[+-]$/.test(op) && self.expression instanceof AST_UnaryPrefix && /^[+-]/.test(self.expression.operator)) {
  14793. output.space();
  14794. }
  14795. self.expression.print(output);
  14796. });
  14797. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  14798. self.expression.print(output);
  14799. output.print(self.operator);
  14800. });
  14801. DEFPRINT(AST_Binary, function(self, output) {
  14802. self.left.print(output);
  14803. output.space();
  14804. output.print(self.operator);
  14805. if (self.operator == "<" && self.right instanceof AST_UnaryPrefix && self.right.operator == "!" && self.right.expression instanceof AST_UnaryPrefix && self.right.expression.operator == "--") {
  14806. output.print(" ");
  14807. } else {
  14808. output.space();
  14809. }
  14810. self.right.print(output);
  14811. });
  14812. DEFPRINT(AST_Conditional, function(self, output) {
  14813. self.condition.print(output);
  14814. output.space();
  14815. output.print("?");
  14816. output.space();
  14817. self.consequent.print(output);
  14818. output.space();
  14819. output.colon();
  14820. self.alternative.print(output);
  14821. });
  14822. DEFPRINT(AST_Array, function(self, output) {
  14823. output.with_square(function() {
  14824. var a = self.elements, len = a.length;
  14825. if (len > 0) output.space();
  14826. a.forEach(function(exp, i) {
  14827. if (i) output.comma();
  14828. exp.print(output);
  14829. if (i === len - 1 && exp instanceof AST_Hole) output.comma();
  14830. });
  14831. if (len > 0) output.space();
  14832. });
  14833. });
  14834. DEFPRINT(AST_Object, function(self, output) {
  14835. if (self.properties.length > 0) output.with_block(function() {
  14836. self.properties.forEach(function(prop, i) {
  14837. if (i) {
  14838. output.print(",");
  14839. output.newline();
  14840. }
  14841. output.indent();
  14842. prop.print(output);
  14843. });
  14844. output.newline();
  14845. }); else output.print("{}");
  14846. });
  14847. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  14848. var key = self.key;
  14849. if (output.option("quote_keys")) {
  14850. output.print_string(key + "");
  14851. } else if ((typeof key == "number" || !output.option("beautify") && +key + "" == key) && parseFloat(key) >= 0) {
  14852. output.print(make_num(key));
  14853. } else if (RESERVED_WORDS(key) ? output.option("screw_ie8") : is_identifier_string(key)) {
  14854. output.print_name(key);
  14855. } else {
  14856. output.print_string(key);
  14857. }
  14858. output.colon();
  14859. self.value.print(output);
  14860. });
  14861. DEFPRINT(AST_ObjectSetter, function(self, output) {
  14862. output.print("set");
  14863. output.space();
  14864. self.key.print(output);
  14865. self.value._do_print(output, true);
  14866. });
  14867. DEFPRINT(AST_ObjectGetter, function(self, output) {
  14868. output.print("get");
  14869. output.space();
  14870. self.key.print(output);
  14871. self.value._do_print(output, true);
  14872. });
  14873. DEFPRINT(AST_Symbol, function(self, output) {
  14874. var def = self.definition();
  14875. output.print_name(def ? def.mangled_name || def.name : self.name);
  14876. });
  14877. DEFPRINT(AST_Undefined, function(self, output) {
  14878. output.print("void 0");
  14879. });
  14880. DEFPRINT(AST_Hole, noop);
  14881. DEFPRINT(AST_Infinity, function(self, output) {
  14882. output.print("1/0");
  14883. });
  14884. DEFPRINT(AST_NaN, function(self, output) {
  14885. output.print("0/0");
  14886. });
  14887. DEFPRINT(AST_This, function(self, output) {
  14888. output.print("this");
  14889. });
  14890. DEFPRINT(AST_Constant, function(self, output) {
  14891. output.print(self.getValue());
  14892. });
  14893. DEFPRINT(AST_String, function(self, output) {
  14894. output.print_string(self.getValue());
  14895. });
  14896. DEFPRINT(AST_Number, function(self, output) {
  14897. output.print(make_num(self.getValue()));
  14898. });
  14899. function regexp_safe_literal(code) {
  14900. 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;
  14901. }
  14902. DEFPRINT(AST_RegExp, function(self, output) {
  14903. var str = self.getValue().toString();
  14904. if (output.option("ascii_only")) {
  14905. str = output.to_ascii(str);
  14906. } else if (output.option("unescape_regexps")) {
  14907. str = str.split("\\\\").map(function(str) {
  14908. return str.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g, function(s) {
  14909. var code = parseInt(s.substr(2), 16);
  14910. return regexp_safe_literal(code) ? String.fromCharCode(code) : s;
  14911. });
  14912. }).join("\\\\");
  14913. }
  14914. output.print(str);
  14915. var p = output.parent();
  14916. if (p instanceof AST_Binary && /^in/.test(p.operator) && p.left === self) output.print(" ");
  14917. });
  14918. function force_statement(stat, output) {
  14919. if (output.option("bracketize")) {
  14920. if (!stat || stat instanceof AST_EmptyStatement) output.print("{}"); else if (stat instanceof AST_BlockStatement) stat.print(output); else output.with_block(function() {
  14921. output.indent();
  14922. stat.print(output);
  14923. output.newline();
  14924. });
  14925. } else {
  14926. if (!stat || stat instanceof AST_EmptyStatement) output.force_semicolon(); else stat.print(output);
  14927. }
  14928. }
  14929. function first_in_statement(output) {
  14930. var a = output.stack(), i = a.length, node = a[--i], p = a[--i];
  14931. while (i > 0) {
  14932. if (p instanceof AST_Statement && p.body === node) return true;
  14933. 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) {
  14934. node = p;
  14935. p = a[--i];
  14936. } else {
  14937. return false;
  14938. }
  14939. }
  14940. }
  14941. function no_constructor_parens(self, output) {
  14942. return self.args.length == 0 && !output.option("beautify");
  14943. }
  14944. function best_of(a) {
  14945. var best = a[0], len = best.length;
  14946. for (var i = 1; i < a.length; ++i) {
  14947. if (a[i].length < len) {
  14948. best = a[i];
  14949. len = best.length;
  14950. }
  14951. }
  14952. return best;
  14953. }
  14954. function make_num(num) {
  14955. var str = num.toString(10), a = [ str.replace(/^0\./, ".").replace("e+", "e") ], m;
  14956. if (Math.floor(num) === num) {
  14957. if (num >= 0) {
  14958. a.push("0x" + num.toString(16).toLowerCase(), "0" + num.toString(8));
  14959. } else {
  14960. a.push("-0x" + (-num).toString(16).toLowerCase(), "-0" + (-num).toString(8));
  14961. }
  14962. if (m = /^(.*?)(0+)$/.exec(num)) {
  14963. a.push(m[1] + "e" + m[2].length);
  14964. }
  14965. } else if (m = /^0?\.(0+)(.*)$/.exec(num)) {
  14966. a.push(m[2] + "e-" + (m[1].length + m[2].length), str.substr(str.indexOf(".")));
  14967. }
  14968. return best_of(a);
  14969. }
  14970. function make_block(stmt, output) {
  14971. if (stmt instanceof AST_BlockStatement) {
  14972. stmt.print(output);
  14973. return;
  14974. }
  14975. output.with_block(function() {
  14976. output.indent();
  14977. stmt.print(output);
  14978. output.newline();
  14979. });
  14980. }
  14981. function DEFMAP(nodetype, generator) {
  14982. nodetype.DEFMETHOD("add_source_map", function(stream) {
  14983. generator(this, stream);
  14984. });
  14985. }
  14986. DEFMAP(AST_Node, noop);
  14987. function basic_sourcemap_gen(self, output) {
  14988. output.add_mapping(self.start);
  14989. }
  14990. DEFMAP(AST_Directive, basic_sourcemap_gen);
  14991. DEFMAP(AST_Debugger, basic_sourcemap_gen);
  14992. DEFMAP(AST_Symbol, basic_sourcemap_gen);
  14993. DEFMAP(AST_Jump, basic_sourcemap_gen);
  14994. DEFMAP(AST_StatementWithBody, basic_sourcemap_gen);
  14995. DEFMAP(AST_LabeledStatement, noop);
  14996. DEFMAP(AST_Lambda, basic_sourcemap_gen);
  14997. DEFMAP(AST_Switch, basic_sourcemap_gen);
  14998. DEFMAP(AST_SwitchBranch, basic_sourcemap_gen);
  14999. DEFMAP(AST_BlockStatement, basic_sourcemap_gen);
  15000. DEFMAP(AST_Toplevel, noop);
  15001. DEFMAP(AST_New, basic_sourcemap_gen);
  15002. DEFMAP(AST_Try, basic_sourcemap_gen);
  15003. DEFMAP(AST_Catch, basic_sourcemap_gen);
  15004. DEFMAP(AST_Finally, basic_sourcemap_gen);
  15005. DEFMAP(AST_Definitions, basic_sourcemap_gen);
  15006. DEFMAP(AST_Constant, basic_sourcemap_gen);
  15007. DEFMAP(AST_ObjectProperty, function(self, output) {
  15008. output.add_mapping(self.start, self.key);
  15009. });
  15010. })();
  15011. "use strict";
  15012. function Compressor(options, false_by_default) {
  15013. if (!(this instanceof Compressor)) return new Compressor(options, false_by_default);
  15014. TreeTransformer.call(this, this.before, this.after);
  15015. this.options = defaults(options, {
  15016. sequences: !false_by_default,
  15017. properties: !false_by_default,
  15018. dead_code: !false_by_default,
  15019. drop_debugger: !false_by_default,
  15020. unsafe: false,
  15021. unsafe_comps: false,
  15022. conditionals: !false_by_default,
  15023. comparisons: !false_by_default,
  15024. evaluate: !false_by_default,
  15025. booleans: !false_by_default,
  15026. loops: !false_by_default,
  15027. unused: !false_by_default,
  15028. hoist_funs: !false_by_default,
  15029. keep_fargs: false,
  15030. hoist_vars: false,
  15031. if_return: !false_by_default,
  15032. join_vars: !false_by_default,
  15033. cascade: !false_by_default,
  15034. side_effects: !false_by_default,
  15035. pure_getters: false,
  15036. pure_funcs: null,
  15037. negate_iife: !false_by_default,
  15038. screw_ie8: false,
  15039. drop_console: false,
  15040. angular: false,
  15041. warnings: true,
  15042. global_defs: {}
  15043. }, true);
  15044. }
  15045. Compressor.prototype = new TreeTransformer();
  15046. merge(Compressor.prototype, {
  15047. option: function(key) {
  15048. return this.options[key];
  15049. },
  15050. warn: function() {
  15051. if (this.options.warnings) AST_Node.warn.apply(AST_Node, arguments);
  15052. },
  15053. before: function(node, descend, in_list) {
  15054. if (node._squeezed) return node;
  15055. var was_scope = false;
  15056. if (node instanceof AST_Scope) {
  15057. node = node.hoist_declarations(this);
  15058. was_scope = true;
  15059. }
  15060. descend(node, this);
  15061. node = node.optimize(this);
  15062. if (was_scope && node instanceof AST_Scope) {
  15063. node.drop_unused(this);
  15064. descend(node, this);
  15065. }
  15066. node._squeezed = true;
  15067. return node;
  15068. }
  15069. });
  15070. (function() {
  15071. function OPT(node, optimizer) {
  15072. node.DEFMETHOD("optimize", function(compressor) {
  15073. var self = this;
  15074. if (self._optimized) return self;
  15075. var opt = optimizer(self, compressor);
  15076. opt._optimized = true;
  15077. if (opt === self) return opt;
  15078. return opt.transform(compressor);
  15079. });
  15080. }
  15081. OPT(AST_Node, function(self, compressor) {
  15082. return self;
  15083. });
  15084. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  15085. return this.print_to_string() == node.print_to_string();
  15086. });
  15087. function make_node(ctor, orig, props) {
  15088. if (!props) props = {};
  15089. if (orig) {
  15090. if (!props.start) props.start = orig.start;
  15091. if (!props.end) props.end = orig.end;
  15092. }
  15093. return new ctor(props);
  15094. }
  15095. function make_node_from_constant(compressor, val, orig) {
  15096. if (val instanceof AST_Node) return val.transform(compressor);
  15097. switch (typeof val) {
  15098. case "string":
  15099. return make_node(AST_String, orig, {
  15100. value: val
  15101. }).optimize(compressor);
  15102. case "number":
  15103. return make_node(isNaN(val) ? AST_NaN : AST_Number, orig, {
  15104. value: val
  15105. }).optimize(compressor);
  15106. case "boolean":
  15107. return make_node(val ? AST_True : AST_False, orig).optimize(compressor);
  15108. case "undefined":
  15109. return make_node(AST_Undefined, orig).optimize(compressor);
  15110. default:
  15111. if (val === null) {
  15112. return make_node(AST_Null, orig).optimize(compressor);
  15113. }
  15114. if (val instanceof RegExp) {
  15115. return make_node(AST_RegExp, orig).optimize(compressor);
  15116. }
  15117. throw new Error(string_template("Can't handle constant of type: {type}", {
  15118. type: typeof val
  15119. }));
  15120. }
  15121. }
  15122. function as_statement_array(thing) {
  15123. if (thing === null) return [];
  15124. if (thing instanceof AST_BlockStatement) return thing.body;
  15125. if (thing instanceof AST_EmptyStatement) return [];
  15126. if (thing instanceof AST_Statement) return [ thing ];
  15127. throw new Error("Can't convert thing to statement array");
  15128. }
  15129. function is_empty(thing) {
  15130. if (thing === null) return true;
  15131. if (thing instanceof AST_EmptyStatement) return true;
  15132. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  15133. return false;
  15134. }
  15135. function loop_body(x) {
  15136. if (x instanceof AST_Switch) return x;
  15137. if (x instanceof AST_For || x instanceof AST_ForIn || x instanceof AST_DWLoop) {
  15138. return x.body instanceof AST_BlockStatement ? x.body : x;
  15139. }
  15140. return x;
  15141. }
  15142. function tighten_body(statements, compressor) {
  15143. var CHANGED;
  15144. do {
  15145. CHANGED = false;
  15146. if (compressor.option("angular")) {
  15147. statements = process_for_angular(statements);
  15148. }
  15149. statements = eliminate_spurious_blocks(statements);
  15150. if (compressor.option("dead_code")) {
  15151. statements = eliminate_dead_code(statements, compressor);
  15152. }
  15153. if (compressor.option("if_return")) {
  15154. statements = handle_if_return(statements, compressor);
  15155. }
  15156. if (compressor.option("sequences")) {
  15157. statements = sequencesize(statements, compressor);
  15158. }
  15159. if (compressor.option("join_vars")) {
  15160. statements = join_consecutive_vars(statements, compressor);
  15161. }
  15162. } while (CHANGED);
  15163. if (compressor.option("negate_iife")) {
  15164. negate_iifes(statements, compressor);
  15165. }
  15166. return statements;
  15167. function process_for_angular(statements) {
  15168. function make_injector(func, name) {
  15169. return make_node(AST_SimpleStatement, func, {
  15170. body: make_node(AST_Assign, func, {
  15171. operator: "=",
  15172. left: make_node(AST_Dot, name, {
  15173. expression: make_node(AST_SymbolRef, name, name),
  15174. property: "$inject"
  15175. }),
  15176. right: make_node(AST_Array, func, {
  15177. elements: func.argnames.map(function(sym) {
  15178. return make_node(AST_String, sym, {
  15179. value: sym.name
  15180. });
  15181. })
  15182. })
  15183. })
  15184. });
  15185. }
  15186. return statements.reduce(function(a, stat) {
  15187. a.push(stat);
  15188. var token = stat.start;
  15189. var comments = token.comments_before;
  15190. if (comments && comments.length > 0) {
  15191. var last = comments.pop();
  15192. if (/@ngInject/.test(last.value)) {
  15193. if (stat instanceof AST_Defun) {
  15194. a.push(make_injector(stat, stat.name));
  15195. } else if (stat instanceof AST_Definitions) {
  15196. stat.definitions.forEach(function(def) {
  15197. if (def.value && def.value instanceof AST_Lambda) {
  15198. a.push(make_injector(def.value, def.name));
  15199. }
  15200. });
  15201. } else {
  15202. compressor.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]", token);
  15203. }
  15204. }
  15205. }
  15206. return a;
  15207. }, []);
  15208. }
  15209. function eliminate_spurious_blocks(statements) {
  15210. var seen_dirs = [];
  15211. return statements.reduce(function(a, stat) {
  15212. if (stat instanceof AST_BlockStatement) {
  15213. CHANGED = true;
  15214. a.push.apply(a, eliminate_spurious_blocks(stat.body));
  15215. } else if (stat instanceof AST_EmptyStatement) {
  15216. CHANGED = true;
  15217. } else if (stat instanceof AST_Directive) {
  15218. if (seen_dirs.indexOf(stat.value) < 0) {
  15219. a.push(stat);
  15220. seen_dirs.push(stat.value);
  15221. } else {
  15222. CHANGED = true;
  15223. }
  15224. } else {
  15225. a.push(stat);
  15226. }
  15227. return a;
  15228. }, []);
  15229. }
  15230. function handle_if_return(statements, compressor) {
  15231. var self = compressor.self();
  15232. var in_lambda = self instanceof AST_Lambda;
  15233. var ret = [];
  15234. loop: for (var i = statements.length; --i >= 0; ) {
  15235. var stat = statements[i];
  15236. switch (true) {
  15237. case in_lambda && stat instanceof AST_Return && !stat.value && ret.length == 0:
  15238. CHANGED = true;
  15239. continue loop;
  15240. case stat instanceof AST_If:
  15241. if (stat.body instanceof AST_Return) {
  15242. if ((in_lambda && ret.length == 0 || ret[0] instanceof AST_Return && !ret[0].value) && !stat.body.value && !stat.alternative) {
  15243. CHANGED = true;
  15244. var cond = make_node(AST_SimpleStatement, stat.condition, {
  15245. body: stat.condition
  15246. });
  15247. ret.unshift(cond);
  15248. continue loop;
  15249. }
  15250. if (ret[0] instanceof AST_Return && stat.body.value && ret[0].value && !stat.alternative) {
  15251. CHANGED = true;
  15252. stat = stat.clone();
  15253. stat.alternative = ret[0];
  15254. ret[0] = stat.transform(compressor);
  15255. continue loop;
  15256. }
  15257. if ((ret.length == 0 || ret[0] instanceof AST_Return) && stat.body.value && !stat.alternative && in_lambda) {
  15258. CHANGED = true;
  15259. stat = stat.clone();
  15260. stat.alternative = ret[0] || make_node(AST_Return, stat, {
  15261. value: make_node(AST_Undefined, stat)
  15262. });
  15263. ret[0] = stat.transform(compressor);
  15264. continue loop;
  15265. }
  15266. if (!stat.body.value && in_lambda) {
  15267. CHANGED = true;
  15268. stat = stat.clone();
  15269. stat.condition = stat.condition.negate(compressor);
  15270. stat.body = make_node(AST_BlockStatement, stat, {
  15271. body: as_statement_array(stat.alternative).concat(ret)
  15272. });
  15273. stat.alternative = null;
  15274. ret = [ stat.transform(compressor) ];
  15275. continue loop;
  15276. }
  15277. if (ret.length == 1 && in_lambda && ret[0] instanceof AST_SimpleStatement && (!stat.alternative || stat.alternative instanceof AST_SimpleStatement)) {
  15278. CHANGED = true;
  15279. ret.push(make_node(AST_Return, ret[0], {
  15280. value: make_node(AST_Undefined, ret[0])
  15281. }).transform(compressor));
  15282. ret = as_statement_array(stat.alternative).concat(ret);
  15283. ret.unshift(stat);
  15284. continue loop;
  15285. }
  15286. }
  15287. var ab = aborts(stat.body);
  15288. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab.label) : null;
  15289. 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)) {
  15290. if (ab.label) {
  15291. remove(ab.label.thedef.references, ab);
  15292. }
  15293. CHANGED = true;
  15294. var body = as_statement_array(stat.body).slice(0, -1);
  15295. stat = stat.clone();
  15296. stat.condition = stat.condition.negate(compressor);
  15297. stat.body = make_node(AST_BlockStatement, stat, {
  15298. body: as_statement_array(stat.alternative).concat(ret)
  15299. });
  15300. stat.alternative = make_node(AST_BlockStatement, stat, {
  15301. body: body
  15302. });
  15303. ret = [ stat.transform(compressor) ];
  15304. continue loop;
  15305. }
  15306. var ab = aborts(stat.alternative);
  15307. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab.label) : null;
  15308. 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)) {
  15309. if (ab.label) {
  15310. remove(ab.label.thedef.references, ab);
  15311. }
  15312. CHANGED = true;
  15313. stat = stat.clone();
  15314. stat.body = make_node(AST_BlockStatement, stat.body, {
  15315. body: as_statement_array(stat.body).concat(ret)
  15316. });
  15317. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  15318. body: as_statement_array(stat.alternative).slice(0, -1)
  15319. });
  15320. ret = [ stat.transform(compressor) ];
  15321. continue loop;
  15322. }
  15323. ret.unshift(stat);
  15324. break;
  15325. default:
  15326. ret.unshift(stat);
  15327. break;
  15328. }
  15329. }
  15330. return ret;
  15331. }
  15332. function eliminate_dead_code(statements, compressor) {
  15333. var has_quit = false;
  15334. var orig = statements.length;
  15335. var self = compressor.self();
  15336. statements = statements.reduce(function(a, stat) {
  15337. if (has_quit) {
  15338. extract_declarations_from_unreachable_code(compressor, stat, a);
  15339. } else {
  15340. if (stat instanceof AST_LoopControl) {
  15341. var lct = compressor.loopcontrol_target(stat.label);
  15342. if (stat instanceof AST_Break && lct instanceof AST_BlockStatement && loop_body(lct) === self || stat instanceof AST_Continue && loop_body(lct) === self) {
  15343. if (stat.label) {
  15344. remove(stat.label.thedef.references, stat);
  15345. }
  15346. } else {
  15347. a.push(stat);
  15348. }
  15349. } else {
  15350. a.push(stat);
  15351. }
  15352. if (aborts(stat)) has_quit = true;
  15353. }
  15354. return a;
  15355. }, []);
  15356. CHANGED = statements.length != orig;
  15357. return statements;
  15358. }
  15359. function sequencesize(statements, compressor) {
  15360. if (statements.length < 2) return statements;
  15361. var seq = [], ret = [];
  15362. function push_seq() {
  15363. seq = AST_Seq.from_array(seq);
  15364. if (seq) ret.push(make_node(AST_SimpleStatement, seq, {
  15365. body: seq
  15366. }));
  15367. seq = [];
  15368. }
  15369. statements.forEach(function(stat) {
  15370. if (stat instanceof AST_SimpleStatement) seq.push(stat.body); else push_seq(), ret.push(stat);
  15371. });
  15372. push_seq();
  15373. ret = sequencesize_2(ret, compressor);
  15374. CHANGED = ret.length != statements.length;
  15375. return ret;
  15376. }
  15377. function sequencesize_2(statements, compressor) {
  15378. function cons_seq(right) {
  15379. ret.pop();
  15380. var left = prev.body;
  15381. if (left instanceof AST_Seq) {
  15382. left.add(right);
  15383. } else {
  15384. left = AST_Seq.cons(left, right);
  15385. }
  15386. return left.transform(compressor);
  15387. }
  15388. var ret = [], prev = null;
  15389. statements.forEach(function(stat) {
  15390. if (prev) {
  15391. if (stat instanceof AST_For) {
  15392. var opera = {};
  15393. try {
  15394. prev.body.walk(new TreeWalker(function(node) {
  15395. if (node instanceof AST_Binary && node.operator == "in") throw opera;
  15396. }));
  15397. if (stat.init && !(stat.init instanceof AST_Definitions)) {
  15398. stat.init = cons_seq(stat.init);
  15399. } else if (!stat.init) {
  15400. stat.init = prev.body;
  15401. ret.pop();
  15402. }
  15403. } catch (ex) {
  15404. if (ex !== opera) throw ex;
  15405. }
  15406. } else if (stat instanceof AST_If) {
  15407. stat.condition = cons_seq(stat.condition);
  15408. } else if (stat instanceof AST_With) {
  15409. stat.expression = cons_seq(stat.expression);
  15410. } else if (stat instanceof AST_Exit && stat.value) {
  15411. stat.value = cons_seq(stat.value);
  15412. } else if (stat instanceof AST_Exit) {
  15413. stat.value = cons_seq(make_node(AST_Undefined, stat));
  15414. } else if (stat instanceof AST_Switch) {
  15415. stat.expression = cons_seq(stat.expression);
  15416. }
  15417. }
  15418. ret.push(stat);
  15419. prev = stat instanceof AST_SimpleStatement ? stat : null;
  15420. });
  15421. return ret;
  15422. }
  15423. function join_consecutive_vars(statements, compressor) {
  15424. var prev = null;
  15425. return statements.reduce(function(a, stat) {
  15426. if (stat instanceof AST_Definitions && prev && prev.TYPE == stat.TYPE) {
  15427. prev.definitions = prev.definitions.concat(stat.definitions);
  15428. CHANGED = true;
  15429. } else if (stat instanceof AST_For && prev instanceof AST_Definitions && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  15430. CHANGED = true;
  15431. a.pop();
  15432. if (stat.init) {
  15433. stat.init.definitions = prev.definitions.concat(stat.init.definitions);
  15434. } else {
  15435. stat.init = prev;
  15436. }
  15437. a.push(stat);
  15438. prev = stat;
  15439. } else {
  15440. prev = stat;
  15441. a.push(stat);
  15442. }
  15443. return a;
  15444. }, []);
  15445. }
  15446. function negate_iifes(statements, compressor) {
  15447. statements.forEach(function(stat) {
  15448. if (stat instanceof AST_SimpleStatement) {
  15449. stat.body = function transform(thing) {
  15450. return thing.transform(new TreeTransformer(function(node) {
  15451. if (node instanceof AST_Call && node.expression instanceof AST_Function) {
  15452. return make_node(AST_UnaryPrefix, node, {
  15453. operator: "!",
  15454. expression: node
  15455. });
  15456. } else if (node instanceof AST_Call) {
  15457. node.expression = transform(node.expression);
  15458. } else if (node instanceof AST_Seq) {
  15459. node.car = transform(node.car);
  15460. } else if (node instanceof AST_Conditional) {
  15461. var expr = transform(node.condition);
  15462. if (expr !== node.condition) {
  15463. node.condition = expr;
  15464. var tmp = node.consequent;
  15465. node.consequent = node.alternative;
  15466. node.alternative = tmp;
  15467. }
  15468. }
  15469. return node;
  15470. }));
  15471. }(stat.body);
  15472. }
  15473. });
  15474. }
  15475. }
  15476. function extract_declarations_from_unreachable_code(compressor, stat, target) {
  15477. compressor.warn("Dropping unreachable code [{file}:{line},{col}]", stat.start);
  15478. stat.walk(new TreeWalker(function(node) {
  15479. if (node instanceof AST_Definitions) {
  15480. compressor.warn("Declarations in unreachable code! [{file}:{line},{col}]", node.start);
  15481. node.remove_initializers();
  15482. target.push(node);
  15483. return true;
  15484. }
  15485. if (node instanceof AST_Defun) {
  15486. target.push(node);
  15487. return true;
  15488. }
  15489. if (node instanceof AST_Scope) {
  15490. return true;
  15491. }
  15492. }));
  15493. }
  15494. (function(def) {
  15495. var unary_bool = [ "!", "delete" ];
  15496. var binary_bool = [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ];
  15497. def(AST_Node, function() {
  15498. return false;
  15499. });
  15500. def(AST_UnaryPrefix, function() {
  15501. return member(this.operator, unary_bool);
  15502. });
  15503. def(AST_Binary, function() {
  15504. return member(this.operator, binary_bool) || (this.operator == "&&" || this.operator == "||") && this.left.is_boolean() && this.right.is_boolean();
  15505. });
  15506. def(AST_Conditional, function() {
  15507. return this.consequent.is_boolean() && this.alternative.is_boolean();
  15508. });
  15509. def(AST_Assign, function() {
  15510. return this.operator == "=" && this.right.is_boolean();
  15511. });
  15512. def(AST_Seq, function() {
  15513. return this.cdr.is_boolean();
  15514. });
  15515. def(AST_True, function() {
  15516. return true;
  15517. });
  15518. def(AST_False, function() {
  15519. return true;
  15520. });
  15521. })(function(node, func) {
  15522. node.DEFMETHOD("is_boolean", func);
  15523. });
  15524. (function(def) {
  15525. def(AST_Node, function() {
  15526. return false;
  15527. });
  15528. def(AST_String, function() {
  15529. return true;
  15530. });
  15531. def(AST_UnaryPrefix, function() {
  15532. return this.operator == "typeof";
  15533. });
  15534. def(AST_Binary, function(compressor) {
  15535. return this.operator == "+" && (this.left.is_string(compressor) || this.right.is_string(compressor));
  15536. });
  15537. def(AST_Assign, function(compressor) {
  15538. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  15539. });
  15540. def(AST_Seq, function(compressor) {
  15541. return this.cdr.is_string(compressor);
  15542. });
  15543. def(AST_Conditional, function(compressor) {
  15544. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  15545. });
  15546. def(AST_Call, function(compressor) {
  15547. return compressor.option("unsafe") && this.expression instanceof AST_SymbolRef && this.expression.name == "String" && this.expression.undeclared();
  15548. });
  15549. })(function(node, func) {
  15550. node.DEFMETHOD("is_string", func);
  15551. });
  15552. function best_of(ast1, ast2) {
  15553. return ast1.print_to_string().length > ast2.print_to_string().length ? ast2 : ast1;
  15554. }
  15555. (function(def) {
  15556. AST_Node.DEFMETHOD("evaluate", function(compressor) {
  15557. if (!compressor.option("evaluate")) return [ this ];
  15558. try {
  15559. var val = this._eval(compressor);
  15560. return [ best_of(make_node_from_constant(compressor, val, this), this), val ];
  15561. } catch (ex) {
  15562. if (ex !== def) throw ex;
  15563. return [ this ];
  15564. }
  15565. });
  15566. def(AST_Statement, function() {
  15567. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  15568. });
  15569. def(AST_Function, function() {
  15570. throw def;
  15571. });
  15572. function ev(node, compressor) {
  15573. if (!compressor) throw new Error("Compressor must be passed");
  15574. return node._eval(compressor);
  15575. }
  15576. def(AST_Node, function() {
  15577. throw def;
  15578. });
  15579. def(AST_Constant, function() {
  15580. return this.getValue();
  15581. });
  15582. def(AST_UnaryPrefix, function(compressor) {
  15583. var e = this.expression;
  15584. switch (this.operator) {
  15585. case "!":
  15586. return !ev(e, compressor);
  15587. case "typeof":
  15588. if (e instanceof AST_Function) return typeof function() {};
  15589. e = ev(e, compressor);
  15590. if (e instanceof RegExp) throw def;
  15591. return typeof e;
  15592. case "void":
  15593. return void ev(e, compressor);
  15594. case "~":
  15595. return ~ev(e, compressor);
  15596. case "-":
  15597. e = ev(e, compressor);
  15598. if (e === 0) throw def;
  15599. return -e;
  15600. case "+":
  15601. return +ev(e, compressor);
  15602. }
  15603. throw def;
  15604. });
  15605. def(AST_Binary, function(c) {
  15606. var left = this.left, right = this.right;
  15607. switch (this.operator) {
  15608. case "&&":
  15609. return ev(left, c) && ev(right, c);
  15610. case "||":
  15611. return ev(left, c) || ev(right, c);
  15612. case "|":
  15613. return ev(left, c) | ev(right, c);
  15614. case "&":
  15615. return ev(left, c) & ev(right, c);
  15616. case "^":
  15617. return ev(left, c) ^ ev(right, c);
  15618. case "+":
  15619. return ev(left, c) + ev(right, c);
  15620. case "*":
  15621. return ev(left, c) * ev(right, c);
  15622. case "/":
  15623. return ev(left, c) / ev(right, c);
  15624. case "%":
  15625. return ev(left, c) % ev(right, c);
  15626. case "-":
  15627. return ev(left, c) - ev(right, c);
  15628. case "<<":
  15629. return ev(left, c) << ev(right, c);
  15630. case ">>":
  15631. return ev(left, c) >> ev(right, c);
  15632. case ">>>":
  15633. return ev(left, c) >>> ev(right, c);
  15634. case "==":
  15635. return ev(left, c) == ev(right, c);
  15636. case "===":
  15637. return ev(left, c) === ev(right, c);
  15638. case "!=":
  15639. return ev(left, c) != ev(right, c);
  15640. case "!==":
  15641. return ev(left, c) !== ev(right, c);
  15642. case "<":
  15643. return ev(left, c) < ev(right, c);
  15644. case "<=":
  15645. return ev(left, c) <= ev(right, c);
  15646. case ">":
  15647. return ev(left, c) > ev(right, c);
  15648. case ">=":
  15649. return ev(left, c) >= ev(right, c);
  15650. case "in":
  15651. return ev(left, c) in ev(right, c);
  15652. case "instanceof":
  15653. return ev(left, c) instanceof ev(right, c);
  15654. }
  15655. throw def;
  15656. });
  15657. def(AST_Conditional, function(compressor) {
  15658. return ev(this.condition, compressor) ? ev(this.consequent, compressor) : ev(this.alternative, compressor);
  15659. });
  15660. def(AST_SymbolRef, function(compressor) {
  15661. var d = this.definition();
  15662. if (d && d.constant && d.init) return ev(d.init, compressor);
  15663. throw def;
  15664. });
  15665. def(AST_Dot, function(compressor) {
  15666. if (compressor.option("unsafe") && this.property == "length") {
  15667. var str = ev(this.expression, compressor);
  15668. if (typeof str == "string") return str.length;
  15669. }
  15670. throw def;
  15671. });
  15672. })(function(node, func) {
  15673. node.DEFMETHOD("_eval", func);
  15674. });
  15675. (function(def) {
  15676. function basic_negation(exp) {
  15677. return make_node(AST_UnaryPrefix, exp, {
  15678. operator: "!",
  15679. expression: exp
  15680. });
  15681. }
  15682. def(AST_Node, function() {
  15683. return basic_negation(this);
  15684. });
  15685. def(AST_Statement, function() {
  15686. throw new Error("Cannot negate a statement");
  15687. });
  15688. def(AST_Function, function() {
  15689. return basic_negation(this);
  15690. });
  15691. def(AST_UnaryPrefix, function() {
  15692. if (this.operator == "!") return this.expression;
  15693. return basic_negation(this);
  15694. });
  15695. def(AST_Seq, function(compressor) {
  15696. var self = this.clone();
  15697. self.cdr = self.cdr.negate(compressor);
  15698. return self;
  15699. });
  15700. def(AST_Conditional, function(compressor) {
  15701. var self = this.clone();
  15702. self.consequent = self.consequent.negate(compressor);
  15703. self.alternative = self.alternative.negate(compressor);
  15704. return best_of(basic_negation(this), self);
  15705. });
  15706. def(AST_Binary, function(compressor) {
  15707. var self = this.clone(), op = this.operator;
  15708. if (compressor.option("unsafe_comps")) {
  15709. switch (op) {
  15710. case "<=":
  15711. self.operator = ">";
  15712. return self;
  15713. case "<":
  15714. self.operator = ">=";
  15715. return self;
  15716. case ">=":
  15717. self.operator = "<";
  15718. return self;
  15719. case ">":
  15720. self.operator = "<=";
  15721. return self;
  15722. }
  15723. }
  15724. switch (op) {
  15725. case "==":
  15726. self.operator = "!=";
  15727. return self;
  15728. case "!=":
  15729. self.operator = "==";
  15730. return self;
  15731. case "===":
  15732. self.operator = "!==";
  15733. return self;
  15734. case "!==":
  15735. self.operator = "===";
  15736. return self;
  15737. case "&&":
  15738. self.operator = "||";
  15739. self.left = self.left.negate(compressor);
  15740. self.right = self.right.negate(compressor);
  15741. return best_of(basic_negation(this), self);
  15742. case "||":
  15743. self.operator = "&&";
  15744. self.left = self.left.negate(compressor);
  15745. self.right = self.right.negate(compressor);
  15746. return best_of(basic_negation(this), self);
  15747. }
  15748. return basic_negation(this);
  15749. });
  15750. })(function(node, func) {
  15751. node.DEFMETHOD("negate", function(compressor) {
  15752. return func.call(this, compressor);
  15753. });
  15754. });
  15755. (function(def) {
  15756. def(AST_Node, function(compressor) {
  15757. return true;
  15758. });
  15759. def(AST_EmptyStatement, function(compressor) {
  15760. return false;
  15761. });
  15762. def(AST_Constant, function(compressor) {
  15763. return false;
  15764. });
  15765. def(AST_This, function(compressor) {
  15766. return false;
  15767. });
  15768. def(AST_Call, function(compressor) {
  15769. var pure = compressor.option("pure_funcs");
  15770. if (!pure) return true;
  15771. return pure.indexOf(this.expression.print_to_string()) < 0;
  15772. });
  15773. def(AST_Block, function(compressor) {
  15774. for (var i = this.body.length; --i >= 0; ) {
  15775. if (this.body[i].has_side_effects(compressor)) return true;
  15776. }
  15777. return false;
  15778. });
  15779. def(AST_SimpleStatement, function(compressor) {
  15780. return this.body.has_side_effects(compressor);
  15781. });
  15782. def(AST_Defun, function(compressor) {
  15783. return true;
  15784. });
  15785. def(AST_Function, function(compressor) {
  15786. return false;
  15787. });
  15788. def(AST_Binary, function(compressor) {
  15789. return this.left.has_side_effects(compressor) || this.right.has_side_effects(compressor);
  15790. });
  15791. def(AST_Assign, function(compressor) {
  15792. return true;
  15793. });
  15794. def(AST_Conditional, function(compressor) {
  15795. return this.condition.has_side_effects(compressor) || this.consequent.has_side_effects(compressor) || this.alternative.has_side_effects(compressor);
  15796. });
  15797. def(AST_Unary, function(compressor) {
  15798. return this.operator == "delete" || this.operator == "++" || this.operator == "--" || this.expression.has_side_effects(compressor);
  15799. });
  15800. def(AST_SymbolRef, function(compressor) {
  15801. return false;
  15802. });
  15803. def(AST_Object, function(compressor) {
  15804. for (var i = this.properties.length; --i >= 0; ) if (this.properties[i].has_side_effects(compressor)) return true;
  15805. return false;
  15806. });
  15807. def(AST_ObjectProperty, function(compressor) {
  15808. return this.value.has_side_effects(compressor);
  15809. });
  15810. def(AST_Array, function(compressor) {
  15811. for (var i = this.elements.length; --i >= 0; ) if (this.elements[i].has_side_effects(compressor)) return true;
  15812. return false;
  15813. });
  15814. def(AST_Dot, function(compressor) {
  15815. if (!compressor.option("pure_getters")) return true;
  15816. return this.expression.has_side_effects(compressor);
  15817. });
  15818. def(AST_Sub, function(compressor) {
  15819. if (!compressor.option("pure_getters")) return true;
  15820. return this.expression.has_side_effects(compressor) || this.property.has_side_effects(compressor);
  15821. });
  15822. def(AST_PropAccess, function(compressor) {
  15823. return !compressor.option("pure_getters");
  15824. });
  15825. def(AST_Seq, function(compressor) {
  15826. return this.car.has_side_effects(compressor) || this.cdr.has_side_effects(compressor);
  15827. });
  15828. })(function(node, func) {
  15829. node.DEFMETHOD("has_side_effects", func);
  15830. });
  15831. function aborts(thing) {
  15832. return thing && thing.aborts();
  15833. }
  15834. (function(def) {
  15835. def(AST_Statement, function() {
  15836. return null;
  15837. });
  15838. def(AST_Jump, function() {
  15839. return this;
  15840. });
  15841. function block_aborts() {
  15842. var n = this.body.length;
  15843. return n > 0 && aborts(this.body[n - 1]);
  15844. }
  15845. def(AST_BlockStatement, block_aborts);
  15846. def(AST_SwitchBranch, block_aborts);
  15847. def(AST_If, function() {
  15848. return this.alternative && aborts(this.body) && aborts(this.alternative);
  15849. });
  15850. })(function(node, func) {
  15851. node.DEFMETHOD("aborts", func);
  15852. });
  15853. OPT(AST_Directive, function(self, compressor) {
  15854. if (self.scope.has_directive(self.value) !== self.scope) {
  15855. return make_node(AST_EmptyStatement, self);
  15856. }
  15857. return self;
  15858. });
  15859. OPT(AST_Debugger, function(self, compressor) {
  15860. if (compressor.option("drop_debugger")) return make_node(AST_EmptyStatement, self);
  15861. return self;
  15862. });
  15863. OPT(AST_LabeledStatement, function(self, compressor) {
  15864. if (self.body instanceof AST_Break && compressor.loopcontrol_target(self.body.label) === self.body) {
  15865. return make_node(AST_EmptyStatement, self);
  15866. }
  15867. return self.label.references.length == 0 ? self.body : self;
  15868. });
  15869. OPT(AST_Block, function(self, compressor) {
  15870. self.body = tighten_body(self.body, compressor);
  15871. return self;
  15872. });
  15873. OPT(AST_BlockStatement, function(self, compressor) {
  15874. self.body = tighten_body(self.body, compressor);
  15875. switch (self.body.length) {
  15876. case 1:
  15877. return self.body[0];
  15878. case 0:
  15879. return make_node(AST_EmptyStatement, self);
  15880. }
  15881. return self;
  15882. });
  15883. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  15884. var self = this;
  15885. if (compressor.option("unused") && !(self instanceof AST_Toplevel) && !self.uses_eval) {
  15886. var in_use = [];
  15887. var initializations = new Dictionary();
  15888. var scope = this;
  15889. var tw = new TreeWalker(function(node, descend) {
  15890. if (node !== self) {
  15891. if (node instanceof AST_Defun) {
  15892. initializations.add(node.name.name, node);
  15893. return true;
  15894. }
  15895. if (node instanceof AST_Definitions && scope === self) {
  15896. node.definitions.forEach(function(def) {
  15897. if (def.value) {
  15898. initializations.add(def.name.name, def.value);
  15899. if (def.value.has_side_effects(compressor)) {
  15900. def.value.walk(tw);
  15901. }
  15902. }
  15903. });
  15904. return true;
  15905. }
  15906. if (node instanceof AST_SymbolRef) {
  15907. push_uniq(in_use, node.definition());
  15908. return true;
  15909. }
  15910. if (node instanceof AST_Scope) {
  15911. var save_scope = scope;
  15912. scope = node;
  15913. descend();
  15914. scope = save_scope;
  15915. return true;
  15916. }
  15917. }
  15918. });
  15919. self.walk(tw);
  15920. for (var i = 0; i < in_use.length; ++i) {
  15921. in_use[i].orig.forEach(function(decl) {
  15922. var init = initializations.get(decl.name);
  15923. if (init) init.forEach(function(init) {
  15924. var tw = new TreeWalker(function(node) {
  15925. if (node instanceof AST_SymbolRef) {
  15926. push_uniq(in_use, node.definition());
  15927. }
  15928. });
  15929. init.walk(tw);
  15930. });
  15931. });
  15932. }
  15933. var tt = new TreeTransformer(function before(node, descend, in_list) {
  15934. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  15935. if (!compressor.option("keep_fargs")) {
  15936. for (var a = node.argnames, i = a.length; --i >= 0; ) {
  15937. var sym = a[i];
  15938. if (sym.unreferenced()) {
  15939. a.pop();
  15940. compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
  15941. name: sym.name,
  15942. file: sym.start.file,
  15943. line: sym.start.line,
  15944. col: sym.start.col
  15945. });
  15946. } else break;
  15947. }
  15948. }
  15949. }
  15950. if (node instanceof AST_Defun && node !== self) {
  15951. if (!member(node.name.definition(), in_use)) {
  15952. compressor.warn("Dropping unused function {name} [{file}:{line},{col}]", {
  15953. name: node.name.name,
  15954. file: node.name.start.file,
  15955. line: node.name.start.line,
  15956. col: node.name.start.col
  15957. });
  15958. return make_node(AST_EmptyStatement, node);
  15959. }
  15960. return node;
  15961. }
  15962. if (node instanceof AST_Definitions && !(tt.parent() instanceof AST_ForIn)) {
  15963. var def = node.definitions.filter(function(def) {
  15964. if (member(def.name.definition(), in_use)) return true;
  15965. var w = {
  15966. name: def.name.name,
  15967. file: def.name.start.file,
  15968. line: def.name.start.line,
  15969. col: def.name.start.col
  15970. };
  15971. if (def.value && def.value.has_side_effects(compressor)) {
  15972. def._unused_side_effects = true;
  15973. compressor.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", w);
  15974. return true;
  15975. }
  15976. compressor.warn("Dropping unused variable {name} [{file}:{line},{col}]", w);
  15977. return false;
  15978. });
  15979. def = mergeSort(def, function(a, b) {
  15980. if (!a.value && b.value) return -1;
  15981. if (!b.value && a.value) return 1;
  15982. return 0;
  15983. });
  15984. var side_effects = [];
  15985. for (var i = 0; i < def.length; ) {
  15986. var x = def[i];
  15987. if (x._unused_side_effects) {
  15988. side_effects.push(x.value);
  15989. def.splice(i, 1);
  15990. } else {
  15991. if (side_effects.length > 0) {
  15992. side_effects.push(x.value);
  15993. x.value = AST_Seq.from_array(side_effects);
  15994. side_effects = [];
  15995. }
  15996. ++i;
  15997. }
  15998. }
  15999. if (side_effects.length > 0) {
  16000. side_effects = make_node(AST_BlockStatement, node, {
  16001. body: [ make_node(AST_SimpleStatement, node, {
  16002. body: AST_Seq.from_array(side_effects)
  16003. }) ]
  16004. });
  16005. } else {
  16006. side_effects = null;
  16007. }
  16008. if (def.length == 0 && !side_effects) {
  16009. return make_node(AST_EmptyStatement, node);
  16010. }
  16011. if (def.length == 0) {
  16012. return side_effects;
  16013. }
  16014. node.definitions = def;
  16015. if (side_effects) {
  16016. side_effects.body.unshift(node);
  16017. node = side_effects;
  16018. }
  16019. return node;
  16020. }
  16021. if (node instanceof AST_For) {
  16022. descend(node, this);
  16023. if (node.init instanceof AST_BlockStatement) {
  16024. var body = node.init.body.slice(0, -1);
  16025. node.init = node.init.body.slice(-1)[0].body;
  16026. body.push(node);
  16027. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  16028. body: body
  16029. });
  16030. }
  16031. }
  16032. if (node instanceof AST_Scope && node !== self) return node;
  16033. });
  16034. self.transform(tt);
  16035. }
  16036. });
  16037. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  16038. var hoist_funs = compressor.option("hoist_funs");
  16039. var hoist_vars = compressor.option("hoist_vars");
  16040. var self = this;
  16041. if (hoist_funs || hoist_vars) {
  16042. var dirs = [];
  16043. var hoisted = [];
  16044. var vars = new Dictionary(), vars_found = 0, var_decl = 0;
  16045. self.walk(new TreeWalker(function(node) {
  16046. if (node instanceof AST_Scope && node !== self) return true;
  16047. if (node instanceof AST_Var) {
  16048. ++var_decl;
  16049. return true;
  16050. }
  16051. }));
  16052. hoist_vars = hoist_vars && var_decl > 1;
  16053. var tt = new TreeTransformer(function before(node) {
  16054. if (node !== self) {
  16055. if (node instanceof AST_Directive) {
  16056. dirs.push(node);
  16057. return make_node(AST_EmptyStatement, node);
  16058. }
  16059. if (node instanceof AST_Defun && hoist_funs) {
  16060. hoisted.push(node);
  16061. return make_node(AST_EmptyStatement, node);
  16062. }
  16063. if (node instanceof AST_Var && hoist_vars) {
  16064. node.definitions.forEach(function(def) {
  16065. vars.set(def.name.name, def);
  16066. ++vars_found;
  16067. });
  16068. var seq = node.to_assignments();
  16069. var p = tt.parent();
  16070. if (p instanceof AST_ForIn && p.init === node) {
  16071. if (seq == null) return node.definitions[0].name;
  16072. return seq;
  16073. }
  16074. if (p instanceof AST_For && p.init === node) {
  16075. return seq;
  16076. }
  16077. if (!seq) return make_node(AST_EmptyStatement, node);
  16078. return make_node(AST_SimpleStatement, node, {
  16079. body: seq
  16080. });
  16081. }
  16082. if (node instanceof AST_Scope) return node;
  16083. }
  16084. });
  16085. self = self.transform(tt);
  16086. if (vars_found > 0) {
  16087. var defs = [];
  16088. vars.each(function(def, name) {
  16089. if (self instanceof AST_Lambda && find_if(function(x) {
  16090. return x.name == def.name.name;
  16091. }, self.argnames)) {
  16092. vars.del(name);
  16093. } else {
  16094. def = def.clone();
  16095. def.value = null;
  16096. defs.push(def);
  16097. vars.set(name, def);
  16098. }
  16099. });
  16100. if (defs.length > 0) {
  16101. for (var i = 0; i < self.body.length; ) {
  16102. if (self.body[i] instanceof AST_SimpleStatement) {
  16103. var expr = self.body[i].body, sym, assign;
  16104. if (expr instanceof AST_Assign && expr.operator == "=" && (sym = expr.left) instanceof AST_Symbol && vars.has(sym.name)) {
  16105. var def = vars.get(sym.name);
  16106. if (def.value) break;
  16107. def.value = expr.right;
  16108. remove(defs, def);
  16109. defs.push(def);
  16110. self.body.splice(i, 1);
  16111. continue;
  16112. }
  16113. if (expr instanceof AST_Seq && (assign = expr.car) instanceof AST_Assign && assign.operator == "=" && (sym = assign.left) instanceof AST_Symbol && vars.has(sym.name)) {
  16114. var def = vars.get(sym.name);
  16115. if (def.value) break;
  16116. def.value = assign.right;
  16117. remove(defs, def);
  16118. defs.push(def);
  16119. self.body[i].body = expr.cdr;
  16120. continue;
  16121. }
  16122. }
  16123. if (self.body[i] instanceof AST_EmptyStatement) {
  16124. self.body.splice(i, 1);
  16125. continue;
  16126. }
  16127. if (self.body[i] instanceof AST_BlockStatement) {
  16128. var tmp = [ i, 1 ].concat(self.body[i].body);
  16129. self.body.splice.apply(self.body, tmp);
  16130. continue;
  16131. }
  16132. break;
  16133. }
  16134. defs = make_node(AST_Var, self, {
  16135. definitions: defs
  16136. });
  16137. hoisted.push(defs);
  16138. }
  16139. }
  16140. self.body = dirs.concat(hoisted, self.body);
  16141. }
  16142. return self;
  16143. });
  16144. OPT(AST_SimpleStatement, function(self, compressor) {
  16145. if (compressor.option("side_effects")) {
  16146. if (!self.body.has_side_effects(compressor)) {
  16147. compressor.warn("Dropping side-effect-free statement [{file}:{line},{col}]", self.start);
  16148. return make_node(AST_EmptyStatement, self);
  16149. }
  16150. }
  16151. return self;
  16152. });
  16153. OPT(AST_DWLoop, function(self, compressor) {
  16154. var cond = self.condition.evaluate(compressor);
  16155. self.condition = cond[0];
  16156. if (!compressor.option("loops")) return self;
  16157. if (cond.length > 1) {
  16158. if (cond[1]) {
  16159. return make_node(AST_For, self, {
  16160. body: self.body
  16161. });
  16162. } else if (self instanceof AST_While) {
  16163. if (compressor.option("dead_code")) {
  16164. var a = [];
  16165. extract_declarations_from_unreachable_code(compressor, self.body, a);
  16166. return make_node(AST_BlockStatement, self, {
  16167. body: a
  16168. });
  16169. }
  16170. }
  16171. }
  16172. return self;
  16173. });
  16174. function if_break_in_loop(self, compressor) {
  16175. function drop_it(rest) {
  16176. rest = as_statement_array(rest);
  16177. if (self.body instanceof AST_BlockStatement) {
  16178. self.body = self.body.clone();
  16179. self.body.body = rest.concat(self.body.body.slice(1));
  16180. self.body = self.body.transform(compressor);
  16181. } else {
  16182. self.body = make_node(AST_BlockStatement, self.body, {
  16183. body: rest
  16184. }).transform(compressor);
  16185. }
  16186. if_break_in_loop(self, compressor);
  16187. }
  16188. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  16189. if (first instanceof AST_If) {
  16190. if (first.body instanceof AST_Break && compressor.loopcontrol_target(first.body.label) === self) {
  16191. if (self.condition) {
  16192. self.condition = make_node(AST_Binary, self.condition, {
  16193. left: self.condition,
  16194. operator: "&&",
  16195. right: first.condition.negate(compressor)
  16196. });
  16197. } else {
  16198. self.condition = first.condition.negate(compressor);
  16199. }
  16200. drop_it(first.alternative);
  16201. } else if (first.alternative instanceof AST_Break && compressor.loopcontrol_target(first.alternative.label) === self) {
  16202. if (self.condition) {
  16203. self.condition = make_node(AST_Binary, self.condition, {
  16204. left: self.condition,
  16205. operator: "&&",
  16206. right: first.condition
  16207. });
  16208. } else {
  16209. self.condition = first.condition;
  16210. }
  16211. drop_it(first.body);
  16212. }
  16213. }
  16214. }
  16215. OPT(AST_While, function(self, compressor) {
  16216. if (!compressor.option("loops")) return self;
  16217. self = AST_DWLoop.prototype.optimize.call(self, compressor);
  16218. if (self instanceof AST_While) {
  16219. if_break_in_loop(self, compressor);
  16220. self = make_node(AST_For, self, self).transform(compressor);
  16221. }
  16222. return self;
  16223. });
  16224. OPT(AST_For, function(self, compressor) {
  16225. var cond = self.condition;
  16226. if (cond) {
  16227. cond = cond.evaluate(compressor);
  16228. self.condition = cond[0];
  16229. }
  16230. if (!compressor.option("loops")) return self;
  16231. if (cond) {
  16232. if (cond.length > 1 && !cond[1]) {
  16233. if (compressor.option("dead_code")) {
  16234. var a = [];
  16235. if (self.init instanceof AST_Statement) {
  16236. a.push(self.init);
  16237. } else if (self.init) {
  16238. a.push(make_node(AST_SimpleStatement, self.init, {
  16239. body: self.init
  16240. }));
  16241. }
  16242. extract_declarations_from_unreachable_code(compressor, self.body, a);
  16243. return make_node(AST_BlockStatement, self, {
  16244. body: a
  16245. });
  16246. }
  16247. }
  16248. }
  16249. if_break_in_loop(self, compressor);
  16250. return self;
  16251. });
  16252. OPT(AST_If, function(self, compressor) {
  16253. if (!compressor.option("conditionals")) return self;
  16254. var cond = self.condition.evaluate(compressor);
  16255. self.condition = cond[0];
  16256. if (cond.length > 1) {
  16257. if (cond[1]) {
  16258. compressor.warn("Condition always true [{file}:{line},{col}]", self.condition.start);
  16259. if (compressor.option("dead_code")) {
  16260. var a = [];
  16261. if (self.alternative) {
  16262. extract_declarations_from_unreachable_code(compressor, self.alternative, a);
  16263. }
  16264. a.push(self.body);
  16265. return make_node(AST_BlockStatement, self, {
  16266. body: a
  16267. }).transform(compressor);
  16268. }
  16269. } else {
  16270. compressor.warn("Condition always false [{file}:{line},{col}]", self.condition.start);
  16271. if (compressor.option("dead_code")) {
  16272. var a = [];
  16273. extract_declarations_from_unreachable_code(compressor, self.body, a);
  16274. if (self.alternative) a.push(self.alternative);
  16275. return make_node(AST_BlockStatement, self, {
  16276. body: a
  16277. }).transform(compressor);
  16278. }
  16279. }
  16280. }
  16281. if (is_empty(self.alternative)) self.alternative = null;
  16282. var negated = self.condition.negate(compressor);
  16283. var negated_is_best = best_of(self.condition, negated) === negated;
  16284. if (self.alternative && negated_is_best) {
  16285. negated_is_best = false;
  16286. self.condition = negated;
  16287. var tmp = self.body;
  16288. self.body = self.alternative || make_node(AST_EmptyStatement);
  16289. self.alternative = tmp;
  16290. }
  16291. if (is_empty(self.body) && is_empty(self.alternative)) {
  16292. return make_node(AST_SimpleStatement, self.condition, {
  16293. body: self.condition
  16294. }).transform(compressor);
  16295. }
  16296. if (self.body instanceof AST_SimpleStatement && self.alternative instanceof AST_SimpleStatement) {
  16297. return make_node(AST_SimpleStatement, self, {
  16298. body: make_node(AST_Conditional, self, {
  16299. condition: self.condition,
  16300. consequent: self.body.body,
  16301. alternative: self.alternative.body
  16302. })
  16303. }).transform(compressor);
  16304. }
  16305. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  16306. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  16307. body: make_node(AST_Binary, self, {
  16308. operator: "||",
  16309. left: negated,
  16310. right: self.body.body
  16311. })
  16312. }).transform(compressor);
  16313. return make_node(AST_SimpleStatement, self, {
  16314. body: make_node(AST_Binary, self, {
  16315. operator: "&&",
  16316. left: self.condition,
  16317. right: self.body.body
  16318. })
  16319. }).transform(compressor);
  16320. }
  16321. if (self.body instanceof AST_EmptyStatement && self.alternative && self.alternative instanceof AST_SimpleStatement) {
  16322. return make_node(AST_SimpleStatement, self, {
  16323. body: make_node(AST_Binary, self, {
  16324. operator: "||",
  16325. left: self.condition,
  16326. right: self.alternative.body
  16327. })
  16328. }).transform(compressor);
  16329. }
  16330. if (self.body instanceof AST_Exit && self.alternative instanceof AST_Exit && self.body.TYPE == self.alternative.TYPE) {
  16331. return make_node(self.body.CTOR, self, {
  16332. value: make_node(AST_Conditional, self, {
  16333. condition: self.condition,
  16334. consequent: self.body.value || make_node(AST_Undefined, self.body).optimize(compressor),
  16335. alternative: self.alternative.value || make_node(AST_Undefined, self.alternative).optimize(compressor)
  16336. })
  16337. }).transform(compressor);
  16338. }
  16339. if (self.body instanceof AST_If && !self.body.alternative && !self.alternative) {
  16340. self.condition = make_node(AST_Binary, self.condition, {
  16341. operator: "&&",
  16342. left: self.condition,
  16343. right: self.body.condition
  16344. }).transform(compressor);
  16345. self.body = self.body.body;
  16346. }
  16347. if (aborts(self.body)) {
  16348. if (self.alternative) {
  16349. var alt = self.alternative;
  16350. self.alternative = null;
  16351. return make_node(AST_BlockStatement, self, {
  16352. body: [ self, alt ]
  16353. }).transform(compressor);
  16354. }
  16355. }
  16356. if (aborts(self.alternative)) {
  16357. var body = self.body;
  16358. self.body = self.alternative;
  16359. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  16360. self.alternative = null;
  16361. return make_node(AST_BlockStatement, self, {
  16362. body: [ self, body ]
  16363. }).transform(compressor);
  16364. }
  16365. return self;
  16366. });
  16367. OPT(AST_Switch, function(self, compressor) {
  16368. if (self.body.length == 0 && compressor.option("conditionals")) {
  16369. return make_node(AST_SimpleStatement, self, {
  16370. body: self.expression
  16371. }).transform(compressor);
  16372. }
  16373. for (;;) {
  16374. var last_branch = self.body[self.body.length - 1];
  16375. if (last_branch) {
  16376. var stat = last_branch.body[last_branch.body.length - 1];
  16377. if (stat instanceof AST_Break && loop_body(compressor.loopcontrol_target(stat.label)) === self) last_branch.body.pop();
  16378. if (last_branch instanceof AST_Default && last_branch.body.length == 0) {
  16379. self.body.pop();
  16380. continue;
  16381. }
  16382. }
  16383. break;
  16384. }
  16385. var exp = self.expression.evaluate(compressor);
  16386. out: if (exp.length == 2) try {
  16387. self.expression = exp[0];
  16388. if (!compressor.option("dead_code")) break out;
  16389. var value = exp[1];
  16390. var in_if = false;
  16391. var in_block = false;
  16392. var started = false;
  16393. var stopped = false;
  16394. var ruined = false;
  16395. var tt = new TreeTransformer(function(node, descend, in_list) {
  16396. if (node instanceof AST_Lambda || node instanceof AST_SimpleStatement) {
  16397. return node;
  16398. } else if (node instanceof AST_Switch && node === self) {
  16399. node = node.clone();
  16400. descend(node, this);
  16401. return ruined ? node : make_node(AST_BlockStatement, node, {
  16402. body: node.body.reduce(function(a, branch) {
  16403. return a.concat(branch.body);
  16404. }, [])
  16405. }).transform(compressor);
  16406. } else if (node instanceof AST_If || node instanceof AST_Try) {
  16407. var save = in_if;
  16408. in_if = !in_block;
  16409. descend(node, this);
  16410. in_if = save;
  16411. return node;
  16412. } else if (node instanceof AST_StatementWithBody || node instanceof AST_Switch) {
  16413. var save = in_block;
  16414. in_block = true;
  16415. descend(node, this);
  16416. in_block = save;
  16417. return node;
  16418. } else if (node instanceof AST_Break && this.loopcontrol_target(node.label) === self) {
  16419. if (in_if) {
  16420. ruined = true;
  16421. return node;
  16422. }
  16423. if (in_block) return node;
  16424. stopped = true;
  16425. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  16426. } else if (node instanceof AST_SwitchBranch && this.parent() === self) {
  16427. if (stopped) return MAP.skip;
  16428. if (node instanceof AST_Case) {
  16429. var exp = node.expression.evaluate(compressor);
  16430. if (exp.length < 2) {
  16431. throw self;
  16432. }
  16433. if (exp[1] === value || started) {
  16434. started = true;
  16435. if (aborts(node)) stopped = true;
  16436. descend(node, this);
  16437. return node;
  16438. }
  16439. return MAP.skip;
  16440. }
  16441. descend(node, this);
  16442. return node;
  16443. }
  16444. });
  16445. tt.stack = compressor.stack.slice();
  16446. self = self.transform(tt);
  16447. } catch (ex) {
  16448. if (ex !== self) throw ex;
  16449. }
  16450. return self;
  16451. });
  16452. OPT(AST_Case, function(self, compressor) {
  16453. self.body = tighten_body(self.body, compressor);
  16454. return self;
  16455. });
  16456. OPT(AST_Try, function(self, compressor) {
  16457. self.body = tighten_body(self.body, compressor);
  16458. return self;
  16459. });
  16460. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  16461. this.definitions.forEach(function(def) {
  16462. def.value = null;
  16463. });
  16464. });
  16465. AST_Definitions.DEFMETHOD("to_assignments", function() {
  16466. var assignments = this.definitions.reduce(function(a, def) {
  16467. if (def.value) {
  16468. var name = make_node(AST_SymbolRef, def.name, def.name);
  16469. a.push(make_node(AST_Assign, def, {
  16470. operator: "=",
  16471. left: name,
  16472. right: def.value
  16473. }));
  16474. }
  16475. return a;
  16476. }, []);
  16477. if (assignments.length == 0) return null;
  16478. return AST_Seq.from_array(assignments);
  16479. });
  16480. OPT(AST_Definitions, function(self, compressor) {
  16481. if (self.definitions.length == 0) return make_node(AST_EmptyStatement, self);
  16482. return self;
  16483. });
  16484. OPT(AST_Function, function(self, compressor) {
  16485. self = AST_Lambda.prototype.optimize.call(self, compressor);
  16486. if (compressor.option("unused")) {
  16487. if (self.name && self.name.unreferenced()) {
  16488. self.name = null;
  16489. }
  16490. }
  16491. return self;
  16492. });
  16493. OPT(AST_Call, function(self, compressor) {
  16494. if (compressor.option("unsafe")) {
  16495. var exp = self.expression;
  16496. if (exp instanceof AST_SymbolRef && exp.undeclared()) {
  16497. switch (exp.name) {
  16498. case "Array":
  16499. if (self.args.length != 1) {
  16500. return make_node(AST_Array, self, {
  16501. elements: self.args
  16502. }).transform(compressor);
  16503. }
  16504. break;
  16505. case "Object":
  16506. if (self.args.length == 0) {
  16507. return make_node(AST_Object, self, {
  16508. properties: []
  16509. });
  16510. }
  16511. break;
  16512. case "String":
  16513. if (self.args.length == 0) return make_node(AST_String, self, {
  16514. value: ""
  16515. });
  16516. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  16517. left: self.args[0],
  16518. operator: "+",
  16519. right: make_node(AST_String, self, {
  16520. value: ""
  16521. })
  16522. }).transform(compressor);
  16523. break;
  16524. case "Number":
  16525. if (self.args.length == 0) return make_node(AST_Number, self, {
  16526. value: 0
  16527. });
  16528. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  16529. expression: self.args[0],
  16530. operator: "+"
  16531. }).transform(compressor);
  16532. case "Boolean":
  16533. if (self.args.length == 0) return make_node(AST_False, self);
  16534. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  16535. expression: make_node(AST_UnaryPrefix, null, {
  16536. expression: self.args[0],
  16537. operator: "!"
  16538. }),
  16539. operator: "!"
  16540. }).transform(compressor);
  16541. break;
  16542. case "Function":
  16543. if (all(self.args, function(x) {
  16544. return x instanceof AST_String;
  16545. })) {
  16546. try {
  16547. var code = "(function(" + self.args.slice(0, -1).map(function(arg) {
  16548. return arg.value;
  16549. }).join(",") + "){" + self.args[self.args.length - 1].value + "})()";
  16550. var ast = parse(code);
  16551. ast.figure_out_scope({
  16552. screw_ie8: compressor.option("screw_ie8")
  16553. });
  16554. var comp = new Compressor(compressor.options);
  16555. ast = ast.transform(comp);
  16556. ast.figure_out_scope({
  16557. screw_ie8: compressor.option("screw_ie8")
  16558. });
  16559. ast.mangle_names();
  16560. var fun;
  16561. try {
  16562. ast.walk(new TreeWalker(function(node) {
  16563. if (node instanceof AST_Lambda) {
  16564. fun = node;
  16565. throw ast;
  16566. }
  16567. }));
  16568. } catch (ex) {
  16569. if (ex !== ast) throw ex;
  16570. }
  16571. var args = fun.argnames.map(function(arg, i) {
  16572. return make_node(AST_String, self.args[i], {
  16573. value: arg.print_to_string()
  16574. });
  16575. });
  16576. var code = OutputStream();
  16577. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  16578. code = code.toString().replace(/^\{|\}$/g, "");
  16579. args.push(make_node(AST_String, self.args[self.args.length - 1], {
  16580. value: code
  16581. }));
  16582. self.args = args;
  16583. return self;
  16584. } catch (ex) {
  16585. if (ex instanceof JS_Parse_Error) {
  16586. compressor.warn("Error parsing code passed to new Function [{file}:{line},{col}]", self.args[self.args.length - 1].start);
  16587. compressor.warn(ex.toString());
  16588. } else {
  16589. console.log(ex);
  16590. throw ex;
  16591. }
  16592. }
  16593. }
  16594. break;
  16595. }
  16596. } else if (exp instanceof AST_Dot && exp.property == "toString" && self.args.length == 0) {
  16597. return make_node(AST_Binary, self, {
  16598. left: make_node(AST_String, self, {
  16599. value: ""
  16600. }),
  16601. operator: "+",
  16602. right: exp.expression
  16603. }).transform(compressor);
  16604. } else if (exp instanceof AST_Dot && exp.expression instanceof AST_Array && exp.property == "join") EXIT: {
  16605. var separator = self.args.length == 0 ? "," : self.args[0].evaluate(compressor)[1];
  16606. if (separator == null) break EXIT;
  16607. var elements = exp.expression.elements.reduce(function(a, el) {
  16608. el = el.evaluate(compressor);
  16609. if (a.length == 0 || el.length == 1) {
  16610. a.push(el);
  16611. } else {
  16612. var last = a[a.length - 1];
  16613. if (last.length == 2) {
  16614. var val = "" + last[1] + separator + el[1];
  16615. a[a.length - 1] = [ make_node_from_constant(compressor, val, last[0]), val ];
  16616. } else {
  16617. a.push(el);
  16618. }
  16619. }
  16620. return a;
  16621. }, []);
  16622. if (elements.length == 0) return make_node(AST_String, self, {
  16623. value: ""
  16624. });
  16625. if (elements.length == 1) return elements[0][0];
  16626. if (separator == "") {
  16627. var first;
  16628. if (elements[0][0] instanceof AST_String || elements[1][0] instanceof AST_String) {
  16629. first = elements.shift()[0];
  16630. } else {
  16631. first = make_node(AST_String, self, {
  16632. value: ""
  16633. });
  16634. }
  16635. return elements.reduce(function(prev, el) {
  16636. return make_node(AST_Binary, el[0], {
  16637. operator: "+",
  16638. left: prev,
  16639. right: el[0]
  16640. });
  16641. }, first).transform(compressor);
  16642. }
  16643. var node = self.clone();
  16644. node.expression = node.expression.clone();
  16645. node.expression.expression = node.expression.expression.clone();
  16646. node.expression.expression.elements = elements.map(function(el) {
  16647. return el[0];
  16648. });
  16649. return best_of(self, node);
  16650. }
  16651. }
  16652. if (compressor.option("side_effects")) {
  16653. if (self.expression instanceof AST_Function && self.args.length == 0 && !AST_Block.prototype.has_side_effects.call(self.expression, compressor)) {
  16654. return make_node(AST_Undefined, self).transform(compressor);
  16655. }
  16656. }
  16657. if (compressor.option("drop_console")) {
  16658. if (self.expression instanceof AST_PropAccess && self.expression.expression instanceof AST_SymbolRef && self.expression.expression.name == "console" && self.expression.expression.undeclared()) {
  16659. return make_node(AST_Undefined, self).transform(compressor);
  16660. }
  16661. }
  16662. return self.evaluate(compressor)[0];
  16663. });
  16664. OPT(AST_New, function(self, compressor) {
  16665. if (compressor.option("unsafe")) {
  16666. var exp = self.expression;
  16667. if (exp instanceof AST_SymbolRef && exp.undeclared()) {
  16668. switch (exp.name) {
  16669. case "Object":
  16670. case "RegExp":
  16671. case "Function":
  16672. case "Error":
  16673. case "Array":
  16674. return make_node(AST_Call, self, self).transform(compressor);
  16675. }
  16676. }
  16677. }
  16678. return self;
  16679. });
  16680. OPT(AST_Seq, function(self, compressor) {
  16681. if (!compressor.option("side_effects")) return self;
  16682. if (!self.car.has_side_effects(compressor)) {
  16683. var p;
  16684. if (!(self.cdr instanceof AST_SymbolRef && self.cdr.name == "eval" && self.cdr.undeclared() && (p = compressor.parent()) instanceof AST_Call && p.expression === self)) {
  16685. return self.cdr;
  16686. }
  16687. }
  16688. if (compressor.option("cascade")) {
  16689. if (self.car instanceof AST_Assign && !self.car.left.has_side_effects(compressor)) {
  16690. if (self.car.left.equivalent_to(self.cdr)) {
  16691. return self.car;
  16692. }
  16693. if (self.cdr instanceof AST_Call && self.cdr.expression.equivalent_to(self.car.left)) {
  16694. self.cdr.expression = self.car;
  16695. return self.cdr;
  16696. }
  16697. }
  16698. if (!self.car.has_side_effects(compressor) && !self.cdr.has_side_effects(compressor) && self.car.equivalent_to(self.cdr)) {
  16699. return self.car;
  16700. }
  16701. }
  16702. if (self.cdr instanceof AST_UnaryPrefix && self.cdr.operator == "void" && !self.cdr.expression.has_side_effects(compressor)) {
  16703. self.cdr.operator = self.car;
  16704. return self.cdr;
  16705. }
  16706. if (self.cdr instanceof AST_Undefined) {
  16707. return make_node(AST_UnaryPrefix, self, {
  16708. operator: "void",
  16709. expression: self.car
  16710. });
  16711. }
  16712. return self;
  16713. });
  16714. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  16715. if (compressor.option("sequences")) {
  16716. if (this.expression instanceof AST_Seq) {
  16717. var seq = this.expression;
  16718. var x = seq.to_array();
  16719. this.expression = x.pop();
  16720. x.push(this);
  16721. seq = AST_Seq.from_array(x).transform(compressor);
  16722. return seq;
  16723. }
  16724. }
  16725. return this;
  16726. });
  16727. OPT(AST_UnaryPostfix, function(self, compressor) {
  16728. return self.lift_sequences(compressor);
  16729. });
  16730. OPT(AST_UnaryPrefix, function(self, compressor) {
  16731. self = self.lift_sequences(compressor);
  16732. var e = self.expression;
  16733. if (compressor.option("booleans") && compressor.in_boolean_context()) {
  16734. switch (self.operator) {
  16735. case "!":
  16736. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  16737. return e.expression;
  16738. }
  16739. break;
  16740. case "typeof":
  16741. compressor.warn("Boolean expression always true [{file}:{line},{col}]", self.start);
  16742. return make_node(AST_True, self);
  16743. }
  16744. if (e instanceof AST_Binary && self.operator == "!") {
  16745. self = best_of(self, e.negate(compressor));
  16746. }
  16747. }
  16748. return self.evaluate(compressor)[0];
  16749. });
  16750. function has_side_effects_or_prop_access(node, compressor) {
  16751. var save_pure_getters = compressor.option("pure_getters");
  16752. compressor.options.pure_getters = false;
  16753. var ret = node.has_side_effects(compressor);
  16754. compressor.options.pure_getters = save_pure_getters;
  16755. return ret;
  16756. }
  16757. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  16758. if (compressor.option("sequences")) {
  16759. if (this.left instanceof AST_Seq) {
  16760. var seq = this.left;
  16761. var x = seq.to_array();
  16762. this.left = x.pop();
  16763. x.push(this);
  16764. seq = AST_Seq.from_array(x).transform(compressor);
  16765. return seq;
  16766. }
  16767. if (this.right instanceof AST_Seq && this instanceof AST_Assign && !has_side_effects_or_prop_access(this.left, compressor)) {
  16768. var seq = this.right;
  16769. var x = seq.to_array();
  16770. this.right = x.pop();
  16771. x.push(this);
  16772. seq = AST_Seq.from_array(x).transform(compressor);
  16773. return seq;
  16774. }
  16775. }
  16776. return this;
  16777. });
  16778. var commutativeOperators = makePredicate("== === != !== * & | ^");
  16779. OPT(AST_Binary, function(self, compressor) {
  16780. var reverse = compressor.has_directive("use asm") ? noop : function(op, force) {
  16781. if (force || !(self.left.has_side_effects(compressor) || self.right.has_side_effects(compressor))) {
  16782. if (op) self.operator = op;
  16783. var tmp = self.left;
  16784. self.left = self.right;
  16785. self.right = tmp;
  16786. }
  16787. };
  16788. if (commutativeOperators(self.operator)) {
  16789. if (self.right instanceof AST_Constant && !(self.left instanceof AST_Constant)) {
  16790. if (!(self.left instanceof AST_Binary && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  16791. reverse(null, true);
  16792. }
  16793. }
  16794. if (/^[!=]==?$/.test(self.operator)) {
  16795. if (self.left instanceof AST_SymbolRef && self.right instanceof AST_Conditional) {
  16796. if (self.right.consequent instanceof AST_SymbolRef && self.right.consequent.definition() === self.left.definition()) {
  16797. if (/^==/.test(self.operator)) return self.right.condition;
  16798. if (/^!=/.test(self.operator)) return self.right.condition.negate(compressor);
  16799. }
  16800. if (self.right.alternative instanceof AST_SymbolRef && self.right.alternative.definition() === self.left.definition()) {
  16801. if (/^==/.test(self.operator)) return self.right.condition.negate(compressor);
  16802. if (/^!=/.test(self.operator)) return self.right.condition;
  16803. }
  16804. }
  16805. if (self.right instanceof AST_SymbolRef && self.left instanceof AST_Conditional) {
  16806. if (self.left.consequent instanceof AST_SymbolRef && self.left.consequent.definition() === self.right.definition()) {
  16807. if (/^==/.test(self.operator)) return self.left.condition;
  16808. if (/^!=/.test(self.operator)) return self.left.condition.negate(compressor);
  16809. }
  16810. if (self.left.alternative instanceof AST_SymbolRef && self.left.alternative.definition() === self.right.definition()) {
  16811. if (/^==/.test(self.operator)) return self.left.condition.negate(compressor);
  16812. if (/^!=/.test(self.operator)) return self.left.condition;
  16813. }
  16814. }
  16815. }
  16816. }
  16817. self = self.lift_sequences(compressor);
  16818. if (compressor.option("comparisons")) switch (self.operator) {
  16819. case "===":
  16820. case "!==":
  16821. if (self.left.is_string(compressor) && self.right.is_string(compressor) || self.left.is_boolean() && self.right.is_boolean()) {
  16822. self.operator = self.operator.substr(0, 2);
  16823. }
  16824. case "==":
  16825. case "!=":
  16826. if (self.left instanceof AST_String && self.left.value == "undefined" && self.right instanceof AST_UnaryPrefix && self.right.operator == "typeof" && compressor.option("unsafe")) {
  16827. if (!(self.right.expression instanceof AST_SymbolRef) || !self.right.expression.undeclared()) {
  16828. self.right = self.right.expression;
  16829. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  16830. if (self.operator.length == 2) self.operator += "=";
  16831. }
  16832. }
  16833. break;
  16834. }
  16835. if (compressor.option("booleans") && compressor.in_boolean_context()) switch (self.operator) {
  16836. case "&&":
  16837. var ll = self.left.evaluate(compressor);
  16838. var rr = self.right.evaluate(compressor);
  16839. if (ll.length > 1 && !ll[1] || rr.length > 1 && !rr[1]) {
  16840. compressor.warn("Boolean && always false [{file}:{line},{col}]", self.start);
  16841. return make_node(AST_False, self);
  16842. }
  16843. if (ll.length > 1 && ll[1]) {
  16844. return rr[0];
  16845. }
  16846. if (rr.length > 1 && rr[1]) {
  16847. return ll[0];
  16848. }
  16849. break;
  16850. case "||":
  16851. var ll = self.left.evaluate(compressor);
  16852. var rr = self.right.evaluate(compressor);
  16853. if (ll.length > 1 && ll[1] || rr.length > 1 && rr[1]) {
  16854. compressor.warn("Boolean || always true [{file}:{line},{col}]", self.start);
  16855. return make_node(AST_True, self);
  16856. }
  16857. if (ll.length > 1 && !ll[1]) {
  16858. return rr[0];
  16859. }
  16860. if (rr.length > 1 && !rr[1]) {
  16861. return ll[0];
  16862. }
  16863. break;
  16864. case "+":
  16865. var ll = self.left.evaluate(compressor);
  16866. var rr = self.right.evaluate(compressor);
  16867. if (ll.length > 1 && ll[0] instanceof AST_String && ll[1] || rr.length > 1 && rr[0] instanceof AST_String && rr[1]) {
  16868. compressor.warn("+ in boolean context always true [{file}:{line},{col}]", self.start);
  16869. return make_node(AST_True, self);
  16870. }
  16871. break;
  16872. }
  16873. if (compressor.option("comparisons")) {
  16874. if (!(compressor.parent() instanceof AST_Binary) || compressor.parent() instanceof AST_Assign) {
  16875. var negated = make_node(AST_UnaryPrefix, self, {
  16876. operator: "!",
  16877. expression: self.negate(compressor)
  16878. });
  16879. self = best_of(self, negated);
  16880. }
  16881. switch (self.operator) {
  16882. case "<":
  16883. reverse(">");
  16884. break;
  16885. case "<=":
  16886. reverse(">=");
  16887. break;
  16888. }
  16889. }
  16890. if (self.operator == "+" && self.right instanceof AST_String && self.right.getValue() === "" && self.left instanceof AST_Binary && self.left.operator == "+" && self.left.is_string(compressor)) {
  16891. return self.left;
  16892. }
  16893. if (compressor.option("evaluate")) {
  16894. if (self.operator == "+") {
  16895. 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)) {
  16896. self = make_node(AST_Binary, self, {
  16897. operator: "+",
  16898. left: make_node(AST_String, null, {
  16899. value: "" + self.left.getValue() + self.right.left.getValue(),
  16900. start: self.left.start,
  16901. end: self.right.left.end
  16902. }),
  16903. right: self.right.right
  16904. });
  16905. }
  16906. 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)) {
  16907. self = make_node(AST_Binary, self, {
  16908. operator: "+",
  16909. left: self.left.left,
  16910. right: make_node(AST_String, null, {
  16911. value: "" + self.left.right.getValue() + self.right.getValue(),
  16912. start: self.left.right.start,
  16913. end: self.right.end
  16914. })
  16915. });
  16916. }
  16917. 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)) {
  16918. self = make_node(AST_Binary, self, {
  16919. operator: "+",
  16920. left: make_node(AST_Binary, self.left, {
  16921. operator: "+",
  16922. left: self.left.left,
  16923. right: make_node(AST_String, null, {
  16924. value: "" + self.left.right.getValue() + self.right.left.getValue(),
  16925. start: self.left.right.start,
  16926. end: self.right.left.end
  16927. })
  16928. }),
  16929. right: self.right.right
  16930. });
  16931. }
  16932. }
  16933. }
  16934. if (self.right instanceof AST_Binary && self.right.operator == self.operator && (self.operator == "*" || self.operator == "&&" || self.operator == "||")) {
  16935. self.left = make_node(AST_Binary, self.left, {
  16936. operator: self.operator,
  16937. left: self.left,
  16938. right: self.right.left
  16939. });
  16940. self.right = self.right.right;
  16941. return self.transform(compressor);
  16942. }
  16943. return self.evaluate(compressor)[0];
  16944. });
  16945. OPT(AST_SymbolRef, function(self, compressor) {
  16946. if (self.undeclared()) {
  16947. var defines = compressor.option("global_defs");
  16948. if (defines && defines.hasOwnProperty(self.name)) {
  16949. return make_node_from_constant(compressor, defines[self.name], self);
  16950. }
  16951. switch (self.name) {
  16952. case "undefined":
  16953. return make_node(AST_Undefined, self);
  16954. case "NaN":
  16955. return make_node(AST_NaN, self);
  16956. case "Infinity":
  16957. return make_node(AST_Infinity, self);
  16958. }
  16959. }
  16960. return self;
  16961. });
  16962. OPT(AST_Undefined, function(self, compressor) {
  16963. if (compressor.option("unsafe")) {
  16964. var scope = compressor.find_parent(AST_Scope);
  16965. var undef = scope.find_variable("undefined");
  16966. if (undef) {
  16967. var ref = make_node(AST_SymbolRef, self, {
  16968. name: "undefined",
  16969. scope: scope,
  16970. thedef: undef
  16971. });
  16972. ref.reference();
  16973. return ref;
  16974. }
  16975. }
  16976. return self;
  16977. });
  16978. var ASSIGN_OPS = [ "+", "-", "/", "*", "%", ">>", "<<", ">>>", "|", "^", "&" ];
  16979. OPT(AST_Assign, function(self, compressor) {
  16980. self = self.lift_sequences(compressor);
  16981. 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)) {
  16982. self.operator = self.right.operator + "=";
  16983. self.right = self.right.right;
  16984. }
  16985. return self;
  16986. });
  16987. OPT(AST_Conditional, function(self, compressor) {
  16988. if (!compressor.option("conditionals")) return self;
  16989. if (self.condition instanceof AST_Seq) {
  16990. var car = self.condition.car;
  16991. self.condition = self.condition.cdr;
  16992. return AST_Seq.cons(car, self);
  16993. }
  16994. var cond = self.condition.evaluate(compressor);
  16995. if (cond.length > 1) {
  16996. if (cond[1]) {
  16997. compressor.warn("Condition always true [{file}:{line},{col}]", self.start);
  16998. return self.consequent;
  16999. } else {
  17000. compressor.warn("Condition always false [{file}:{line},{col}]", self.start);
  17001. return self.alternative;
  17002. }
  17003. }
  17004. var negated = cond[0].negate(compressor);
  17005. if (best_of(cond[0], negated) === negated) {
  17006. self = make_node(AST_Conditional, self, {
  17007. condition: negated,
  17008. consequent: self.alternative,
  17009. alternative: self.consequent
  17010. });
  17011. }
  17012. var consequent = self.consequent;
  17013. var alternative = self.alternative;
  17014. if (consequent instanceof AST_Assign && alternative instanceof AST_Assign && consequent.operator == alternative.operator && consequent.left.equivalent_to(alternative.left)) {
  17015. return make_node(AST_Assign, self, {
  17016. operator: consequent.operator,
  17017. left: consequent.left,
  17018. right: make_node(AST_Conditional, self, {
  17019. condition: self.condition,
  17020. consequent: consequent.right,
  17021. alternative: alternative.right
  17022. })
  17023. });
  17024. }
  17025. if (consequent instanceof AST_Call && alternative.TYPE === consequent.TYPE && consequent.args.length == alternative.args.length && consequent.expression.equivalent_to(alternative.expression)) {
  17026. if (consequent.args.length == 0) {
  17027. return make_node(AST_Seq, self, {
  17028. car: self.condition,
  17029. cdr: consequent
  17030. });
  17031. }
  17032. if (consequent.args.length == 1) {
  17033. consequent.args[0] = make_node(AST_Conditional, self, {
  17034. condition: self.condition,
  17035. consequent: consequent.args[0],
  17036. alternative: alternative.args[0]
  17037. });
  17038. return consequent;
  17039. }
  17040. }
  17041. if (consequent instanceof AST_Conditional && consequent.alternative.equivalent_to(alternative)) {
  17042. return make_node(AST_Conditional, self, {
  17043. condition: make_node(AST_Binary, self, {
  17044. left: self.condition,
  17045. operator: "&&",
  17046. right: consequent.condition
  17047. }),
  17048. consequent: consequent.consequent,
  17049. alternative: alternative
  17050. });
  17051. }
  17052. return self;
  17053. });
  17054. OPT(AST_Boolean, function(self, compressor) {
  17055. if (compressor.option("booleans")) {
  17056. var p = compressor.parent();
  17057. if (p instanceof AST_Binary && (p.operator == "==" || p.operator == "!=")) {
  17058. compressor.warn("Non-strict equality against boolean: {operator} {value} [{file}:{line},{col}]", {
  17059. operator: p.operator,
  17060. value: self.value,
  17061. file: p.start.file,
  17062. line: p.start.line,
  17063. col: p.start.col
  17064. });
  17065. return make_node(AST_Number, self, {
  17066. value: +self.value
  17067. });
  17068. }
  17069. return make_node(AST_UnaryPrefix, self, {
  17070. operator: "!",
  17071. expression: make_node(AST_Number, self, {
  17072. value: 1 - self.value
  17073. })
  17074. });
  17075. }
  17076. return self;
  17077. });
  17078. OPT(AST_Sub, function(self, compressor) {
  17079. var prop = self.property;
  17080. if (prop instanceof AST_String && compressor.option("properties")) {
  17081. prop = prop.getValue();
  17082. if (RESERVED_WORDS(prop) ? compressor.option("screw_ie8") : is_identifier_string(prop)) {
  17083. return make_node(AST_Dot, self, {
  17084. expression: self.expression,
  17085. property: prop
  17086. }).optimize(compressor);
  17087. }
  17088. var v = parseFloat(prop);
  17089. if (!isNaN(v) && v.toString() == prop) {
  17090. self.property = make_node(AST_Number, self.property, {
  17091. value: v
  17092. });
  17093. }
  17094. }
  17095. return self;
  17096. });
  17097. OPT(AST_Dot, function(self, compressor) {
  17098. return self.evaluate(compressor)[0];
  17099. });
  17100. function literals_in_boolean_context(self, compressor) {
  17101. if (compressor.option("booleans") && compressor.in_boolean_context()) {
  17102. return make_node(AST_True, self);
  17103. }
  17104. return self;
  17105. }
  17106. OPT(AST_Array, literals_in_boolean_context);
  17107. OPT(AST_Object, literals_in_boolean_context);
  17108. OPT(AST_RegExp, literals_in_boolean_context);
  17109. })();
  17110. "use strict";
  17111. function SourceMap(options) {
  17112. options = defaults(options, {
  17113. file: null,
  17114. root: null,
  17115. orig: null,
  17116. orig_line_diff: 0,
  17117. dest_line_diff: 0
  17118. });
  17119. var generator = new MOZ_SourceMap.SourceMapGenerator({
  17120. file: options.file,
  17121. sourceRoot: options.root
  17122. });
  17123. var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
  17124. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  17125. if (orig_map) {
  17126. var info = orig_map.originalPositionFor({
  17127. line: orig_line,
  17128. column: orig_col
  17129. });
  17130. if (info.source === null) {
  17131. return;
  17132. }
  17133. source = info.source;
  17134. orig_line = info.line;
  17135. orig_col = info.column;
  17136. name = info.name;
  17137. }
  17138. generator.addMapping({
  17139. generated: {
  17140. line: gen_line + options.dest_line_diff,
  17141. column: gen_col
  17142. },
  17143. original: {
  17144. line: orig_line + options.orig_line_diff,
  17145. column: orig_col
  17146. },
  17147. source: source,
  17148. name: name
  17149. });
  17150. }
  17151. return {
  17152. add: add,
  17153. get: function() {
  17154. return generator;
  17155. },
  17156. toString: function() {
  17157. return generator.toString();
  17158. }
  17159. };
  17160. }
  17161. "use strict";
  17162. (function() {
  17163. var MOZ_TO_ME = {
  17164. ExpressionStatement: function(M) {
  17165. var expr = M.expression;
  17166. if (expr.type === "Literal" && typeof expr.value === "string") {
  17167. return new AST_Directive({
  17168. start: my_start_token(M),
  17169. end: my_end_token(M),
  17170. value: expr.value
  17171. });
  17172. }
  17173. return new AST_SimpleStatement({
  17174. start: my_start_token(M),
  17175. end: my_end_token(M),
  17176. body: from_moz(expr)
  17177. });
  17178. },
  17179. TryStatement: function(M) {
  17180. var handlers = M.handlers || [ M.handler ];
  17181. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  17182. throw new Error("Multiple catch clauses are not supported.");
  17183. }
  17184. return new AST_Try({
  17185. start: my_start_token(M),
  17186. end: my_end_token(M),
  17187. body: from_moz(M.block).body,
  17188. bcatch: from_moz(handlers[0]),
  17189. bfinally: M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  17190. });
  17191. },
  17192. Property: function(M) {
  17193. var key = M.key;
  17194. var name = key.type == "Identifier" ? key.name : key.value;
  17195. var args = {
  17196. start: my_start_token(key),
  17197. end: my_end_token(M.value),
  17198. key: name,
  17199. value: from_moz(M.value)
  17200. };
  17201. switch (M.kind) {
  17202. case "init":
  17203. return new AST_ObjectKeyVal(args);
  17204. case "set":
  17205. args.value.name = from_moz(key);
  17206. return new AST_ObjectSetter(args);
  17207. case "get":
  17208. args.value.name = from_moz(key);
  17209. return new AST_ObjectGetter(args);
  17210. }
  17211. },
  17212. ObjectExpression: function(M) {
  17213. return new AST_Object({
  17214. start: my_start_token(M),
  17215. end: my_end_token(M),
  17216. properties: M.properties.map(function(prop) {
  17217. prop.type = "Property";
  17218. return from_moz(prop);
  17219. })
  17220. });
  17221. },
  17222. SequenceExpression: function(M) {
  17223. return AST_Seq.from_array(M.expressions.map(from_moz));
  17224. },
  17225. MemberExpression: function(M) {
  17226. return new (M.computed ? AST_Sub : AST_Dot)({
  17227. start: my_start_token(M),
  17228. end: my_end_token(M),
  17229. property: M.computed ? from_moz(M.property) : M.property.name,
  17230. expression: from_moz(M.object)
  17231. });
  17232. },
  17233. SwitchCase: function(M) {
  17234. return new (M.test ? AST_Case : AST_Default)({
  17235. start: my_start_token(M),
  17236. end: my_end_token(M),
  17237. expression: from_moz(M.test),
  17238. body: M.consequent.map(from_moz)
  17239. });
  17240. },
  17241. VariableDeclaration: function(M) {
  17242. return new (M.kind === "const" ? AST_Const : AST_Var)({
  17243. start: my_start_token(M),
  17244. end: my_end_token(M),
  17245. definitions: M.declarations.map(from_moz)
  17246. });
  17247. },
  17248. Literal: function(M) {
  17249. var val = M.value, args = {
  17250. start: my_start_token(M),
  17251. end: my_end_token(M)
  17252. };
  17253. if (val === null) return new AST_Null(args);
  17254. switch (typeof val) {
  17255. case "string":
  17256. args.value = val;
  17257. return new AST_String(args);
  17258. case "number":
  17259. args.value = val;
  17260. return new AST_Number(args);
  17261. case "boolean":
  17262. return new (val ? AST_True : AST_False)(args);
  17263. default:
  17264. args.value = val;
  17265. return new AST_RegExp(args);
  17266. }
  17267. },
  17268. Identifier: function(M) {
  17269. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  17270. 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)({
  17271. start: my_start_token(M),
  17272. end: my_end_token(M),
  17273. name: M.name
  17274. });
  17275. }
  17276. };
  17277. MOZ_TO_ME.UpdateExpression = MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  17278. var prefix = "prefix" in M ? M.prefix : M.type == "UnaryExpression" ? true : false;
  17279. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  17280. start: my_start_token(M),
  17281. end: my_end_token(M),
  17282. operator: M.operator,
  17283. expression: from_moz(M.argument)
  17284. });
  17285. };
  17286. map("Program", AST_Toplevel, "body@body");
  17287. map("EmptyStatement", AST_EmptyStatement);
  17288. map("BlockStatement", AST_BlockStatement, "body@body");
  17289. map("IfStatement", AST_If, "test>condition, consequent>body, alternate>alternative");
  17290. map("LabeledStatement", AST_LabeledStatement, "label>label, body>body");
  17291. map("BreakStatement", AST_Break, "label>label");
  17292. map("ContinueStatement", AST_Continue, "label>label");
  17293. map("WithStatement", AST_With, "object>expression, body>body");
  17294. map("SwitchStatement", AST_Switch, "discriminant>expression, cases@body");
  17295. map("ReturnStatement", AST_Return, "argument>value");
  17296. map("ThrowStatement", AST_Throw, "argument>value");
  17297. map("WhileStatement", AST_While, "test>condition, body>body");
  17298. map("DoWhileStatement", AST_Do, "test>condition, body>body");
  17299. map("ForStatement", AST_For, "init>init, test>condition, update>step, body>body");
  17300. map("ForInStatement", AST_ForIn, "left>init, right>object, body>body");
  17301. map("DebuggerStatement", AST_Debugger);
  17302. map("FunctionDeclaration", AST_Defun, "id>name, params@argnames, body%body");
  17303. map("VariableDeclarator", AST_VarDef, "id>name, init>value");
  17304. map("CatchClause", AST_Catch, "param>argname, body%body");
  17305. map("ThisExpression", AST_This);
  17306. map("ArrayExpression", AST_Array, "elements@elements");
  17307. map("FunctionExpression", AST_Function, "id>name, params@argnames, body%body");
  17308. map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
  17309. map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
  17310. map("AssignmentExpression", AST_Assign, "operator=operator, left>left, right>right");
  17311. map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
  17312. map("NewExpression", AST_New, "callee>expression, arguments@args");
  17313. map("CallExpression", AST_Call, "callee>expression, arguments@args");
  17314. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  17315. return {
  17316. type: "ExpressionStatement",
  17317. expression: {
  17318. type: "Literal",
  17319. value: M.value
  17320. }
  17321. };
  17322. });
  17323. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  17324. return {
  17325. type: "ExpressionStatement",
  17326. expression: to_moz(M.body)
  17327. };
  17328. });
  17329. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  17330. return {
  17331. type: "SwitchCase",
  17332. test: to_moz(M.expression),
  17333. consequent: M.body.map(to_moz)
  17334. };
  17335. });
  17336. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  17337. return {
  17338. type: "TryStatement",
  17339. block: to_moz_block(M),
  17340. handler: to_moz(M.bcatch),
  17341. guardedHandlers: [],
  17342. finalizer: to_moz(M.bfinally)
  17343. };
  17344. });
  17345. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  17346. return {
  17347. type: "CatchClause",
  17348. param: to_moz(M.argname),
  17349. guard: null,
  17350. body: to_moz_block(M)
  17351. };
  17352. });
  17353. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  17354. return {
  17355. type: "VariableDeclaration",
  17356. kind: M instanceof AST_Const ? "const" : "var",
  17357. declarations: M.definitions.map(to_moz)
  17358. };
  17359. });
  17360. def_to_moz(AST_Seq, function To_Moz_SequenceExpression(M) {
  17361. return {
  17362. type: "SequenceExpression",
  17363. expressions: M.to_array().map(to_moz)
  17364. };
  17365. });
  17366. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  17367. var isComputed = M instanceof AST_Sub;
  17368. return {
  17369. type: "MemberExpression",
  17370. object: to_moz(M.expression),
  17371. computed: isComputed,
  17372. property: isComputed ? to_moz(M.property) : {
  17373. type: "Identifier",
  17374. name: M.property
  17375. }
  17376. };
  17377. });
  17378. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  17379. return {
  17380. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  17381. operator: M.operator,
  17382. prefix: M instanceof AST_UnaryPrefix,
  17383. argument: to_moz(M.expression)
  17384. };
  17385. });
  17386. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  17387. return {
  17388. type: M.operator == "&&" || M.operator == "||" ? "LogicalExpression" : "BinaryExpression",
  17389. left: to_moz(M.left),
  17390. operator: M.operator,
  17391. right: to_moz(M.right)
  17392. };
  17393. });
  17394. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  17395. return {
  17396. type: "ObjectExpression",
  17397. properties: M.properties.map(to_moz)
  17398. };
  17399. });
  17400. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M) {
  17401. var key = is_identifier(M.key) ? {
  17402. type: "Identifier",
  17403. name: M.key
  17404. } : {
  17405. type: "Literal",
  17406. value: M.key
  17407. };
  17408. var kind;
  17409. if (M instanceof AST_ObjectKeyVal) {
  17410. kind = "init";
  17411. } else if (M instanceof AST_ObjectGetter) {
  17412. kind = "get";
  17413. } else if (M instanceof AST_ObjectSetter) {
  17414. kind = "set";
  17415. }
  17416. return {
  17417. type: "Property",
  17418. kind: kind,
  17419. key: key,
  17420. value: to_moz(M.value)
  17421. };
  17422. });
  17423. def_to_moz(AST_Symbol, function To_Moz_Identifier(M) {
  17424. var def = M.definition();
  17425. return {
  17426. type: "Identifier",
  17427. name: def ? def.mangled_name || def.name : M.name
  17428. };
  17429. });
  17430. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  17431. var value = M.value;
  17432. if (typeof value === "number" && (value < 0 || value === 0 && 1 / value < 0)) {
  17433. return {
  17434. type: "UnaryExpression",
  17435. operator: "-",
  17436. prefix: true,
  17437. argument: {
  17438. type: "Literal",
  17439. value: -value
  17440. }
  17441. };
  17442. }
  17443. return {
  17444. type: "Literal",
  17445. value: value
  17446. };
  17447. });
  17448. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  17449. return {
  17450. type: "Identifier",
  17451. name: String(M.value)
  17452. };
  17453. });
  17454. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  17455. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  17456. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() {
  17457. return null;
  17458. });
  17459. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  17460. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  17461. function my_start_token(moznode) {
  17462. var loc = moznode.loc;
  17463. var range = moznode.range;
  17464. return new AST_Token({
  17465. file: loc && loc.source,
  17466. line: loc && loc.start.line,
  17467. col: loc && loc.start.column,
  17468. pos: range ? range[0] : moznode.start,
  17469. endpos: range ? range[0] : moznode.start
  17470. });
  17471. }
  17472. function my_end_token(moznode) {
  17473. var loc = moznode.loc;
  17474. var range = moznode.range;
  17475. return new AST_Token({
  17476. file: loc && loc.source,
  17477. line: loc && loc.end.line,
  17478. col: loc && loc.end.column,
  17479. pos: range ? range[1] : moznode.end,
  17480. endpos: range ? range[1] : moznode.end
  17481. });
  17482. }
  17483. function map(moztype, mytype, propmap) {
  17484. if (typeof UglifyJS_NoUnsafeEval !== "undefined") {
  17485. var prop_list = [];
  17486. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  17487. var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
  17488. if (!m) throw new Error("Can't understand property map: " + prop);
  17489. if ("=@>%".indexOf(m[2]) < 0) {
  17490. throw new Error("Can't understand operator in propmap: " + prop);
  17491. }
  17492. prop_list.push(m);
  17493. });
  17494. var moz_to_me = function(M) {
  17495. var props = {
  17496. start: my_start_token(M),
  17497. end: my_end_token(M)
  17498. };
  17499. for (var i = 0; i < prop_list.length; i++) {
  17500. var m = prop_list[i];
  17501. var moz = m[1], how = m[2], my = m[3];
  17502. var mozProp = M[moz];
  17503. var myProp;
  17504. switch (how) {
  17505. case "@":
  17506. myProp = mozProp.map(from_moz);
  17507. break;
  17508. case ">":
  17509. myProp = from_moz(mozProp);
  17510. break;
  17511. case "=":
  17512. myProp = mozProp;
  17513. break;
  17514. case "%":
  17515. myProp = from_moz(mozProp).body;
  17516. break;
  17517. }
  17518. props[my] = myProp;
  17519. }
  17520. return new mytype(props);
  17521. };
  17522. var me_to_moz = function(M) {
  17523. var props = {
  17524. type: moztype
  17525. };
  17526. for (var i = 0; i < prop_list.length; i++) {
  17527. var m = prop_list[i];
  17528. var moz = m[1], how = m[2], my = m[3];
  17529. var myProp = M[my];
  17530. var mozProp;
  17531. switch (how) {
  17532. case "@":
  17533. mozProp = myProp.map(to_moz);
  17534. break;
  17535. case ">":
  17536. mozProp = to_moz(myProp);
  17537. break;
  17538. case "=":
  17539. mozProp = myProp;
  17540. break;
  17541. case "%":
  17542. mozProp = to_moz_block(M);
  17543. break;
  17544. }
  17545. props[moz] = mozProp;
  17546. }
  17547. return props;
  17548. };
  17549. MOZ_TO_ME[moztype] = moz_to_me;
  17550. def_to_moz(mytype, me_to_moz);
  17551. return;
  17552. }
  17553. var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
  17554. moz_to_me += "return new " + mytype.name + "({\n" + "start: my_start_token(M),\n" + "end: my_end_token(M)";
  17555. var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
  17556. me_to_moz += "return {\n" + "type: " + JSON.stringify(moztype);
  17557. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  17558. var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
  17559. if (!m) throw new Error("Can't understand property map: " + prop);
  17560. var moz = m[1], how = m[2], my = m[3];
  17561. moz_to_me += ",\n" + my + ": ";
  17562. me_to_moz += ",\n" + moz + ": ";
  17563. switch (how) {
  17564. case "@":
  17565. moz_to_me += "M." + moz + ".map(from_moz)";
  17566. me_to_moz += "M." + my + ".map(to_moz)";
  17567. break;
  17568. case ">":
  17569. moz_to_me += "from_moz(M." + moz + ")";
  17570. me_to_moz += "to_moz(M." + my + ")";
  17571. break;
  17572. case "=":
  17573. moz_to_me += "M." + moz;
  17574. me_to_moz += "M." + my;
  17575. break;
  17576. case "%":
  17577. moz_to_me += "from_moz(M." + moz + ").body";
  17578. me_to_moz += "to_moz_block(M)";
  17579. break;
  17580. default:
  17581. throw new Error("Can't understand operator in propmap: " + prop);
  17582. }
  17583. });
  17584. moz_to_me += "\n})\n}";
  17585. me_to_moz += "\n}\n}";
  17586. 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);
  17587. me_to_moz = new Function("to_moz", "to_moz_block", "return(" + me_to_moz + ")")(to_moz, to_moz_block);
  17588. MOZ_TO_ME[moztype] = moz_to_me;
  17589. def_to_moz(mytype, me_to_moz);
  17590. }
  17591. var FROM_MOZ_STACK = null;
  17592. function from_moz(node) {
  17593. FROM_MOZ_STACK.push(node);
  17594. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  17595. FROM_MOZ_STACK.pop();
  17596. return ret;
  17597. }
  17598. AST_Node.from_mozilla_ast = function(node) {
  17599. var save_stack = FROM_MOZ_STACK;
  17600. FROM_MOZ_STACK = [];
  17601. var ast = from_moz(node);
  17602. FROM_MOZ_STACK = save_stack;
  17603. return ast;
  17604. };
  17605. function moz_sub_loc(token) {
  17606. return token.line ? {
  17607. line: token.line,
  17608. column: token.col
  17609. } : null;
  17610. }
  17611. function set_moz_loc(mynode, moznode) {
  17612. var start = mynode.start;
  17613. var end = mynode.end;
  17614. if (start.pos != null && end.pos != null) {
  17615. moznode.range = [ start.pos, end.pos ];
  17616. }
  17617. if (start.line) {
  17618. moznode.loc = {
  17619. start: moz_sub_loc(start),
  17620. end: moz_sub_loc(end)
  17621. };
  17622. if (start.file) {
  17623. moznode.loc.source = start.file;
  17624. }
  17625. }
  17626. return moznode;
  17627. }
  17628. function def_to_moz(mytype, handler) {
  17629. mytype.DEFMETHOD("to_mozilla_ast", function() {
  17630. return set_moz_loc(this, handler(this));
  17631. });
  17632. }
  17633. function to_moz(node) {
  17634. return node != null ? node.to_mozilla_ast() : null;
  17635. }
  17636. function to_moz_block(node) {
  17637. return {
  17638. type: "BlockStatement",
  17639. body: node.body.map(to_moz)
  17640. };
  17641. }
  17642. })();
  17643. exports["array_to_hash"] = array_to_hash;
  17644. exports["slice"] = slice;
  17645. exports["characters"] = characters;
  17646. exports["member"] = member;
  17647. exports["find_if"] = find_if;
  17648. exports["repeat_string"] = repeat_string;
  17649. exports["DefaultsError"] = DefaultsError;
  17650. exports["defaults"] = defaults;
  17651. exports["merge"] = merge;
  17652. exports["noop"] = noop;
  17653. exports["MAP"] = MAP;
  17654. exports["push_uniq"] = push_uniq;
  17655. exports["string_template"] = string_template;
  17656. exports["remove"] = remove;
  17657. exports["mergeSort"] = mergeSort;
  17658. exports["set_difference"] = set_difference;
  17659. exports["set_intersection"] = set_intersection;
  17660. exports["makePredicate"] = makePredicate;
  17661. exports["all"] = all;
  17662. exports["Dictionary"] = Dictionary;
  17663. exports["DEFNODE"] = DEFNODE;
  17664. exports["AST_Token"] = AST_Token;
  17665. exports["AST_Node"] = AST_Node;
  17666. exports["AST_Statement"] = AST_Statement;
  17667. exports["AST_Debugger"] = AST_Debugger;
  17668. exports["AST_Directive"] = AST_Directive;
  17669. exports["AST_SimpleStatement"] = AST_SimpleStatement;
  17670. exports["walk_body"] = walk_body;
  17671. exports["AST_Block"] = AST_Block;
  17672. exports["AST_BlockStatement"] = AST_BlockStatement;
  17673. exports["AST_EmptyStatement"] = AST_EmptyStatement;
  17674. exports["AST_StatementWithBody"] = AST_StatementWithBody;
  17675. exports["AST_LabeledStatement"] = AST_LabeledStatement;
  17676. exports["AST_IterationStatement"] = AST_IterationStatement;
  17677. exports["AST_DWLoop"] = AST_DWLoop;
  17678. exports["AST_Do"] = AST_Do;
  17679. exports["AST_While"] = AST_While;
  17680. exports["AST_For"] = AST_For;
  17681. exports["AST_ForIn"] = AST_ForIn;
  17682. exports["AST_With"] = AST_With;
  17683. exports["AST_Scope"] = AST_Scope;
  17684. exports["AST_Toplevel"] = AST_Toplevel;
  17685. exports["AST_Lambda"] = AST_Lambda;
  17686. exports["AST_Accessor"] = AST_Accessor;
  17687. exports["AST_Function"] = AST_Function;
  17688. exports["AST_Defun"] = AST_Defun;
  17689. exports["AST_Jump"] = AST_Jump;
  17690. exports["AST_Exit"] = AST_Exit;
  17691. exports["AST_Return"] = AST_Return;
  17692. exports["AST_Throw"] = AST_Throw;
  17693. exports["AST_LoopControl"] = AST_LoopControl;
  17694. exports["AST_Break"] = AST_Break;
  17695. exports["AST_Continue"] = AST_Continue;
  17696. exports["AST_If"] = AST_If;
  17697. exports["AST_Switch"] = AST_Switch;
  17698. exports["AST_SwitchBranch"] = AST_SwitchBranch;
  17699. exports["AST_Default"] = AST_Default;
  17700. exports["AST_Case"] = AST_Case;
  17701. exports["AST_Try"] = AST_Try;
  17702. exports["AST_Catch"] = AST_Catch;
  17703. exports["AST_Finally"] = AST_Finally;
  17704. exports["AST_Definitions"] = AST_Definitions;
  17705. exports["AST_Var"] = AST_Var;
  17706. exports["AST_Const"] = AST_Const;
  17707. exports["AST_VarDef"] = AST_VarDef;
  17708. exports["AST_Call"] = AST_Call;
  17709. exports["AST_New"] = AST_New;
  17710. exports["AST_Seq"] = AST_Seq;
  17711. exports["AST_PropAccess"] = AST_PropAccess;
  17712. exports["AST_Dot"] = AST_Dot;
  17713. exports["AST_Sub"] = AST_Sub;
  17714. exports["AST_Unary"] = AST_Unary;
  17715. exports["AST_UnaryPrefix"] = AST_UnaryPrefix;
  17716. exports["AST_UnaryPostfix"] = AST_UnaryPostfix;
  17717. exports["AST_Binary"] = AST_Binary;
  17718. exports["AST_Conditional"] = AST_Conditional;
  17719. exports["AST_Assign"] = AST_Assign;
  17720. exports["AST_Array"] = AST_Array;
  17721. exports["AST_Object"] = AST_Object;
  17722. exports["AST_ObjectProperty"] = AST_ObjectProperty;
  17723. exports["AST_ObjectKeyVal"] = AST_ObjectKeyVal;
  17724. exports["AST_ObjectSetter"] = AST_ObjectSetter;
  17725. exports["AST_ObjectGetter"] = AST_ObjectGetter;
  17726. exports["AST_Symbol"] = AST_Symbol;
  17727. exports["AST_SymbolAccessor"] = AST_SymbolAccessor;
  17728. exports["AST_SymbolDeclaration"] = AST_SymbolDeclaration;
  17729. exports["AST_SymbolVar"] = AST_SymbolVar;
  17730. exports["AST_SymbolConst"] = AST_SymbolConst;
  17731. exports["AST_SymbolFunarg"] = AST_SymbolFunarg;
  17732. exports["AST_SymbolDefun"] = AST_SymbolDefun;
  17733. exports["AST_SymbolLambda"] = AST_SymbolLambda;
  17734. exports["AST_SymbolCatch"] = AST_SymbolCatch;
  17735. exports["AST_Label"] = AST_Label;
  17736. exports["AST_SymbolRef"] = AST_SymbolRef;
  17737. exports["AST_LabelRef"] = AST_LabelRef;
  17738. exports["AST_This"] = AST_This;
  17739. exports["AST_Constant"] = AST_Constant;
  17740. exports["AST_String"] = AST_String;
  17741. exports["AST_Number"] = AST_Number;
  17742. exports["AST_RegExp"] = AST_RegExp;
  17743. exports["AST_Atom"] = AST_Atom;
  17744. exports["AST_Null"] = AST_Null;
  17745. exports["AST_NaN"] = AST_NaN;
  17746. exports["AST_Undefined"] = AST_Undefined;
  17747. exports["AST_Hole"] = AST_Hole;
  17748. exports["AST_Infinity"] = AST_Infinity;
  17749. exports["AST_Boolean"] = AST_Boolean;
  17750. exports["AST_False"] = AST_False;
  17751. exports["AST_True"] = AST_True;
  17752. exports["TreeWalker"] = TreeWalker;
  17753. exports["KEYWORDS"] = KEYWORDS;
  17754. exports["KEYWORDS_ATOM"] = KEYWORDS_ATOM;
  17755. exports["RESERVED_WORDS"] = RESERVED_WORDS;
  17756. exports["KEYWORDS_BEFORE_EXPRESSION"] = KEYWORDS_BEFORE_EXPRESSION;
  17757. exports["OPERATOR_CHARS"] = OPERATOR_CHARS;
  17758. exports["RE_HEX_NUMBER"] = RE_HEX_NUMBER;
  17759. exports["RE_OCT_NUMBER"] = RE_OCT_NUMBER;
  17760. exports["RE_DEC_NUMBER"] = RE_DEC_NUMBER;
  17761. exports["OPERATORS"] = OPERATORS;
  17762. exports["WHITESPACE_CHARS"] = WHITESPACE_CHARS;
  17763. exports["PUNC_BEFORE_EXPRESSION"] = PUNC_BEFORE_EXPRESSION;
  17764. exports["PUNC_CHARS"] = PUNC_CHARS;
  17765. exports["REGEXP_MODIFIERS"] = REGEXP_MODIFIERS;
  17766. exports["UNICODE"] = UNICODE;
  17767. exports["is_letter"] = is_letter;
  17768. exports["is_digit"] = is_digit;
  17769. exports["is_alphanumeric_char"] = is_alphanumeric_char;
  17770. exports["is_unicode_combining_mark"] = is_unicode_combining_mark;
  17771. exports["is_unicode_connector_punctuation"] = is_unicode_connector_punctuation;
  17772. exports["is_identifier"] = is_identifier;
  17773. exports["is_identifier_start"] = is_identifier_start;
  17774. exports["is_identifier_char"] = is_identifier_char;
  17775. exports["is_identifier_string"] = is_identifier_string;
  17776. exports["parse_js_number"] = parse_js_number;
  17777. exports["JS_Parse_Error"] = JS_Parse_Error;
  17778. exports["js_error"] = js_error;
  17779. exports["is_token"] = is_token;
  17780. exports["EX_EOF"] = EX_EOF;
  17781. exports["tokenizer"] = tokenizer;
  17782. exports["UNARY_PREFIX"] = UNARY_PREFIX;
  17783. exports["UNARY_POSTFIX"] = UNARY_POSTFIX;
  17784. exports["ASSIGNMENT"] = ASSIGNMENT;
  17785. exports["PRECEDENCE"] = PRECEDENCE;
  17786. exports["STATEMENTS_WITH_LABELS"] = STATEMENTS_WITH_LABELS;
  17787. exports["ATOMIC_START_TOKEN"] = ATOMIC_START_TOKEN;
  17788. exports["parse"] = parse;
  17789. exports["TreeTransformer"] = TreeTransformer;
  17790. exports["SymbolDef"] = SymbolDef;
  17791. exports["base54"] = base54;
  17792. exports["OutputStream"] = OutputStream;
  17793. exports["Compressor"] = Compressor;
  17794. exports["SourceMap"] = SourceMap;
  17795. })({}, function() {
  17796. return this;
  17797. }());
  17798. },{}],"OmegaPac":[function(require,module,exports){
  17799. var name, ref, value;
  17800. module.exports = {
  17801. Conditions: require('./src/conditions'),
  17802. PacGenerator: require('./src/pac_generator'),
  17803. Profiles: require('./src/profiles'),
  17804. RuleList: require('./src/rule_list'),
  17805. ShexpUtils: require('./src/shexp_utils')
  17806. };
  17807. ref = require('./src/utils.coffee');
  17808. for (name in ref) {
  17809. value = ref[name];
  17810. module.exports[name] = value;
  17811. }
  17812. },{"./src/conditions":61,"./src/pac_generator":62,"./src/profiles":63,"./src/rule_list":64,"./src/shexp_utils":65,"./src/utils.coffee":66}]},{},["OmegaPac"])("OmegaPac")
  17813. });
  17814. },{}]},{},[1]);