vue-test-utils.iife.js 428 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151
  1. var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
  2. 'use strict';
  3. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  4. var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
  5. //
  6. function createVNodes(vm, slotValue, name) {
  7. var el = vueTemplateCompiler.compileToFunctions(
  8. ("<div><template slot=" + name + ">" + slotValue + "</template></div>")
  9. );
  10. var _staticRenderFns = vm._renderProxy.$options.staticRenderFns;
  11. var _staticTrees = vm._renderProxy._staticTrees;
  12. vm._renderProxy._staticTrees = [];
  13. vm._renderProxy.$options.staticRenderFns = el.staticRenderFns;
  14. var vnode = el.render.call(vm._renderProxy, vm.$createElement);
  15. vm._renderProxy.$options.staticRenderFns = _staticRenderFns;
  16. vm._renderProxy._staticTrees = _staticTrees;
  17. return vnode.children[0]
  18. }
  19. function createVNodesForSlot(
  20. vm,
  21. slotValue,
  22. name
  23. ) {
  24. if (typeof slotValue === 'string') {
  25. return createVNodes(vm, slotValue, name)
  26. }
  27. var vnode = vm.$createElement(slotValue)
  28. ;(vnode.data || (vnode.data = {})).slot = name;
  29. return vnode
  30. }
  31. function createSlotVNodes(
  32. vm,
  33. slots
  34. ) {
  35. return Object.keys(slots).reduce(function (acc, key) {
  36. var content = slots[key];
  37. if (Array.isArray(content)) {
  38. var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); }
  39. );
  40. return acc.concat(nodes)
  41. }
  42. return acc.concat(createVNodesForSlot(vm, content, key))
  43. }, [])
  44. }
  45. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  46. function createCommonjsModule(fn, basedir, module) {
  47. return module = {
  48. path: basedir,
  49. exports: {},
  50. require: function (path, base) {
  51. return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
  52. }
  53. }, fn(module, module.exports), module.exports;
  54. }
  55. function getCjsExportFromNamespace (n) {
  56. return n && n['default'] || n;
  57. }
  58. function commonjsRequire () {
  59. throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
  60. }
  61. var semver = createCommonjsModule(function (module, exports) {
  62. exports = module.exports = SemVer;
  63. var debug;
  64. /* istanbul ignore next */
  65. if (typeof process === 'object' &&
  66. process.env &&
  67. process.env.NODE_DEBUG &&
  68. /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
  69. debug = function () {
  70. var args = Array.prototype.slice.call(arguments, 0);
  71. args.unshift('SEMVER');
  72. console.log.apply(console, args);
  73. };
  74. } else {
  75. debug = function () {};
  76. }
  77. // Note: this is the semver.org version of the spec that it implements
  78. // Not necessarily the package version of this code.
  79. exports.SEMVER_SPEC_VERSION = '2.0.0';
  80. var MAX_LENGTH = 256;
  81. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
  82. /* istanbul ignore next */ 9007199254740991;
  83. // Max safe segment length for coercion.
  84. var MAX_SAFE_COMPONENT_LENGTH = 16;
  85. // The actual regexps go on exports.re
  86. var re = exports.re = [];
  87. var src = exports.src = [];
  88. var t = exports.tokens = {};
  89. var R = 0;
  90. function tok (n) {
  91. t[n] = R++;
  92. }
  93. // The following Regular Expressions can be used for tokenizing,
  94. // validating, and parsing SemVer version strings.
  95. // ## Numeric Identifier
  96. // A single `0`, or a non-zero digit followed by zero or more digits.
  97. tok('NUMERICIDENTIFIER');
  98. src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  99. tok('NUMERICIDENTIFIERLOOSE');
  100. src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
  101. // ## Non-numeric Identifier
  102. // Zero or more digits, followed by a letter or hyphen, and then zero or
  103. // more letters, digits, or hyphens.
  104. tok('NONNUMERICIDENTIFIER');
  105. src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
  106. // ## Main Version
  107. // Three dot-separated numeric identifiers.
  108. tok('MAINVERSION');
  109. src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
  110. '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
  111. '(' + src[t.NUMERICIDENTIFIER] + ')';
  112. tok('MAINVERSIONLOOSE');
  113. src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
  114. '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
  115. '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
  116. // ## Pre-release Version Identifier
  117. // A numeric identifier, or a non-numeric identifier.
  118. tok('PRERELEASEIDENTIFIER');
  119. src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
  120. '|' + src[t.NONNUMERICIDENTIFIER] + ')';
  121. tok('PRERELEASEIDENTIFIERLOOSE');
  122. src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
  123. '|' + src[t.NONNUMERICIDENTIFIER] + ')';
  124. // ## Pre-release Version
  125. // Hyphen, followed by one or more dot-separated pre-release version
  126. // identifiers.
  127. tok('PRERELEASE');
  128. src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
  129. '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
  130. tok('PRERELEASELOOSE');
  131. src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
  132. '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
  133. // ## Build Metadata Identifier
  134. // Any combination of digits, letters, or hyphens.
  135. tok('BUILDIDENTIFIER');
  136. src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
  137. // ## Build Metadata
  138. // Plus sign, followed by one or more period-separated build metadata
  139. // identifiers.
  140. tok('BUILD');
  141. src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
  142. '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
  143. // ## Full Version String
  144. // A main version, followed optionally by a pre-release version and
  145. // build metadata.
  146. // Note that the only major, minor, patch, and pre-release sections of
  147. // the version string are capturing groups. The build metadata is not a
  148. // capturing group, because it should not ever be used in version
  149. // comparison.
  150. tok('FULL');
  151. tok('FULLPLAIN');
  152. src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
  153. src[t.PRERELEASE] + '?' +
  154. src[t.BUILD] + '?';
  155. src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
  156. // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  157. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  158. // common in the npm registry.
  159. tok('LOOSEPLAIN');
  160. src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
  161. src[t.PRERELEASELOOSE] + '?' +
  162. src[t.BUILD] + '?';
  163. tok('LOOSE');
  164. src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
  165. tok('GTLT');
  166. src[t.GTLT] = '((?:<|>)?=?)';
  167. // Something like "2.*" or "1.2.x".
  168. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  169. // Only the first item is strictly required.
  170. tok('XRANGEIDENTIFIERLOOSE');
  171. src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  172. tok('XRANGEIDENTIFIER');
  173. src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
  174. tok('XRANGEPLAIN');
  175. src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
  176. '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
  177. '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
  178. '(?:' + src[t.PRERELEASE] + ')?' +
  179. src[t.BUILD] + '?' +
  180. ')?)?';
  181. tok('XRANGEPLAINLOOSE');
  182. src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  183. '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  184. '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  185. '(?:' + src[t.PRERELEASELOOSE] + ')?' +
  186. src[t.BUILD] + '?' +
  187. ')?)?';
  188. tok('XRANGE');
  189. src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
  190. tok('XRANGELOOSE');
  191. src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
  192. // Coercion.
  193. // Extract anything that could conceivably be a part of a valid semver
  194. tok('COERCE');
  195. src[t.COERCE] = '(^|[^\\d])' +
  196. '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
  197. '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
  198. '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
  199. '(?:$|[^\\d])';
  200. tok('COERCERTL');
  201. re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
  202. // Tilde ranges.
  203. // Meaning is "reasonably at or greater than"
  204. tok('LONETILDE');
  205. src[t.LONETILDE] = '(?:~>?)';
  206. tok('TILDETRIM');
  207. src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
  208. re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
  209. var tildeTrimReplace = '$1~';
  210. tok('TILDE');
  211. src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
  212. tok('TILDELOOSE');
  213. src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
  214. // Caret ranges.
  215. // Meaning is "at least and backwards compatible with"
  216. tok('LONECARET');
  217. src[t.LONECARET] = '(?:\\^)';
  218. tok('CARETTRIM');
  219. src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
  220. re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
  221. var caretTrimReplace = '$1^';
  222. tok('CARET');
  223. src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
  224. tok('CARETLOOSE');
  225. src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
  226. // A simple gt/lt/eq thing, or just "" to indicate "any version"
  227. tok('COMPARATORLOOSE');
  228. src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
  229. tok('COMPARATOR');
  230. src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
  231. // An expression to strip any whitespace between the gtlt and the thing
  232. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  233. tok('COMPARATORTRIM');
  234. src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
  235. '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
  236. // this one has to use the /g flag
  237. re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
  238. var comparatorTrimReplace = '$1$2$3';
  239. // Something like `1.2.3 - 1.2.4`
  240. // Note that these all use the loose form, because they'll be
  241. // checked against either the strict or loose comparator form
  242. // later.
  243. tok('HYPHENRANGE');
  244. src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
  245. '\\s+-\\s+' +
  246. '(' + src[t.XRANGEPLAIN] + ')' +
  247. '\\s*$';
  248. tok('HYPHENRANGELOOSE');
  249. src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
  250. '\\s+-\\s+' +
  251. '(' + src[t.XRANGEPLAINLOOSE] + ')' +
  252. '\\s*$';
  253. // Star ranges basically just allow anything at all.
  254. tok('STAR');
  255. src[t.STAR] = '(<|>)?=?\\s*\\*';
  256. // Compile to actual regexp objects.
  257. // All are flag-free, unless they were created above with a flag.
  258. for (var i = 0; i < R; i++) {
  259. debug(i, src[i]);
  260. if (!re[i]) {
  261. re[i] = new RegExp(src[i]);
  262. }
  263. }
  264. exports.parse = parse;
  265. function parse (version, options) {
  266. if (!options || typeof options !== 'object') {
  267. options = {
  268. loose: !!options,
  269. includePrerelease: false
  270. };
  271. }
  272. if (version instanceof SemVer) {
  273. return version
  274. }
  275. if (typeof version !== 'string') {
  276. return null
  277. }
  278. if (version.length > MAX_LENGTH) {
  279. return null
  280. }
  281. var r = options.loose ? re[t.LOOSE] : re[t.FULL];
  282. if (!r.test(version)) {
  283. return null
  284. }
  285. try {
  286. return new SemVer(version, options)
  287. } catch (er) {
  288. return null
  289. }
  290. }
  291. exports.valid = valid;
  292. function valid (version, options) {
  293. var v = parse(version, options);
  294. return v ? v.version : null
  295. }
  296. exports.clean = clean;
  297. function clean (version, options) {
  298. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  299. return s ? s.version : null
  300. }
  301. exports.SemVer = SemVer;
  302. function SemVer (version, options) {
  303. if (!options || typeof options !== 'object') {
  304. options = {
  305. loose: !!options,
  306. includePrerelease: false
  307. };
  308. }
  309. if (version instanceof SemVer) {
  310. if (version.loose === options.loose) {
  311. return version
  312. } else {
  313. version = version.version;
  314. }
  315. } else if (typeof version !== 'string') {
  316. throw new TypeError('Invalid Version: ' + version)
  317. }
  318. if (version.length > MAX_LENGTH) {
  319. throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
  320. }
  321. if (!(this instanceof SemVer)) {
  322. return new SemVer(version, options)
  323. }
  324. debug('SemVer', version, options);
  325. this.options = options;
  326. this.loose = !!options.loose;
  327. var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
  328. if (!m) {
  329. throw new TypeError('Invalid Version: ' + version)
  330. }
  331. this.raw = version;
  332. // these are actually numbers
  333. this.major = +m[1];
  334. this.minor = +m[2];
  335. this.patch = +m[3];
  336. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  337. throw new TypeError('Invalid major version')
  338. }
  339. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  340. throw new TypeError('Invalid minor version')
  341. }
  342. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  343. throw new TypeError('Invalid patch version')
  344. }
  345. // numberify any prerelease numeric ids
  346. if (!m[4]) {
  347. this.prerelease = [];
  348. } else {
  349. this.prerelease = m[4].split('.').map(function (id) {
  350. if (/^[0-9]+$/.test(id)) {
  351. var num = +id;
  352. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  353. return num
  354. }
  355. }
  356. return id
  357. });
  358. }
  359. this.build = m[5] ? m[5].split('.') : [];
  360. this.format();
  361. }
  362. SemVer.prototype.format = function () {
  363. this.version = this.major + '.' + this.minor + '.' + this.patch;
  364. if (this.prerelease.length) {
  365. this.version += '-' + this.prerelease.join('.');
  366. }
  367. return this.version
  368. };
  369. SemVer.prototype.toString = function () {
  370. return this.version
  371. };
  372. SemVer.prototype.compare = function (other) {
  373. debug('SemVer.compare', this.version, this.options, other);
  374. if (!(other instanceof SemVer)) {
  375. other = new SemVer(other, this.options);
  376. }
  377. return this.compareMain(other) || this.comparePre(other)
  378. };
  379. SemVer.prototype.compareMain = function (other) {
  380. if (!(other instanceof SemVer)) {
  381. other = new SemVer(other, this.options);
  382. }
  383. return compareIdentifiers(this.major, other.major) ||
  384. compareIdentifiers(this.minor, other.minor) ||
  385. compareIdentifiers(this.patch, other.patch)
  386. };
  387. SemVer.prototype.comparePre = function (other) {
  388. if (!(other instanceof SemVer)) {
  389. other = new SemVer(other, this.options);
  390. }
  391. // NOT having a prerelease is > having one
  392. if (this.prerelease.length && !other.prerelease.length) {
  393. return -1
  394. } else if (!this.prerelease.length && other.prerelease.length) {
  395. return 1
  396. } else if (!this.prerelease.length && !other.prerelease.length) {
  397. return 0
  398. }
  399. var i = 0;
  400. do {
  401. var a = this.prerelease[i];
  402. var b = other.prerelease[i];
  403. debug('prerelease compare', i, a, b);
  404. if (a === undefined && b === undefined) {
  405. return 0
  406. } else if (b === undefined) {
  407. return 1
  408. } else if (a === undefined) {
  409. return -1
  410. } else if (a === b) {
  411. continue
  412. } else {
  413. return compareIdentifiers(a, b)
  414. }
  415. } while (++i)
  416. };
  417. SemVer.prototype.compareBuild = function (other) {
  418. if (!(other instanceof SemVer)) {
  419. other = new SemVer(other, this.options);
  420. }
  421. var i = 0;
  422. do {
  423. var a = this.build[i];
  424. var b = other.build[i];
  425. debug('prerelease compare', i, a, b);
  426. if (a === undefined && b === undefined) {
  427. return 0
  428. } else if (b === undefined) {
  429. return 1
  430. } else if (a === undefined) {
  431. return -1
  432. } else if (a === b) {
  433. continue
  434. } else {
  435. return compareIdentifiers(a, b)
  436. }
  437. } while (++i)
  438. };
  439. // preminor will bump the version up to the next minor release, and immediately
  440. // down to pre-release. premajor and prepatch work the same way.
  441. SemVer.prototype.inc = function (release, identifier) {
  442. switch (release) {
  443. case 'premajor':
  444. this.prerelease.length = 0;
  445. this.patch = 0;
  446. this.minor = 0;
  447. this.major++;
  448. this.inc('pre', identifier);
  449. break
  450. case 'preminor':
  451. this.prerelease.length = 0;
  452. this.patch = 0;
  453. this.minor++;
  454. this.inc('pre', identifier);
  455. break
  456. case 'prepatch':
  457. // If this is already a prerelease, it will bump to the next version
  458. // drop any prereleases that might already exist, since they are not
  459. // relevant at this point.
  460. this.prerelease.length = 0;
  461. this.inc('patch', identifier);
  462. this.inc('pre', identifier);
  463. break
  464. // If the input is a non-prerelease version, this acts the same as
  465. // prepatch.
  466. case 'prerelease':
  467. if (this.prerelease.length === 0) {
  468. this.inc('patch', identifier);
  469. }
  470. this.inc('pre', identifier);
  471. break
  472. case 'major':
  473. // If this is a pre-major version, bump up to the same major version.
  474. // Otherwise increment major.
  475. // 1.0.0-5 bumps to 1.0.0
  476. // 1.1.0 bumps to 2.0.0
  477. if (this.minor !== 0 ||
  478. this.patch !== 0 ||
  479. this.prerelease.length === 0) {
  480. this.major++;
  481. }
  482. this.minor = 0;
  483. this.patch = 0;
  484. this.prerelease = [];
  485. break
  486. case 'minor':
  487. // If this is a pre-minor version, bump up to the same minor version.
  488. // Otherwise increment minor.
  489. // 1.2.0-5 bumps to 1.2.0
  490. // 1.2.1 bumps to 1.3.0
  491. if (this.patch !== 0 || this.prerelease.length === 0) {
  492. this.minor++;
  493. }
  494. this.patch = 0;
  495. this.prerelease = [];
  496. break
  497. case 'patch':
  498. // If this is not a pre-release version, it will increment the patch.
  499. // If it is a pre-release it will bump up to the same patch version.
  500. // 1.2.0-5 patches to 1.2.0
  501. // 1.2.0 patches to 1.2.1
  502. if (this.prerelease.length === 0) {
  503. this.patch++;
  504. }
  505. this.prerelease = [];
  506. break
  507. // This probably shouldn't be used publicly.
  508. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  509. case 'pre':
  510. if (this.prerelease.length === 0) {
  511. this.prerelease = [0];
  512. } else {
  513. var i = this.prerelease.length;
  514. while (--i >= 0) {
  515. if (typeof this.prerelease[i] === 'number') {
  516. this.prerelease[i]++;
  517. i = -2;
  518. }
  519. }
  520. if (i === -1) {
  521. // didn't increment anything
  522. this.prerelease.push(0);
  523. }
  524. }
  525. if (identifier) {
  526. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  527. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  528. if (this.prerelease[0] === identifier) {
  529. if (isNaN(this.prerelease[1])) {
  530. this.prerelease = [identifier, 0];
  531. }
  532. } else {
  533. this.prerelease = [identifier, 0];
  534. }
  535. }
  536. break
  537. default:
  538. throw new Error('invalid increment argument: ' + release)
  539. }
  540. this.format();
  541. this.raw = this.version;
  542. return this
  543. };
  544. exports.inc = inc;
  545. function inc (version, release, loose, identifier) {
  546. if (typeof (loose) === 'string') {
  547. identifier = loose;
  548. loose = undefined;
  549. }
  550. try {
  551. return new SemVer(version, loose).inc(release, identifier).version
  552. } catch (er) {
  553. return null
  554. }
  555. }
  556. exports.diff = diff;
  557. function diff (version1, version2) {
  558. if (eq(version1, version2)) {
  559. return null
  560. } else {
  561. var v1 = parse(version1);
  562. var v2 = parse(version2);
  563. var prefix = '';
  564. if (v1.prerelease.length || v2.prerelease.length) {
  565. prefix = 'pre';
  566. var defaultResult = 'prerelease';
  567. }
  568. for (var key in v1) {
  569. if (key === 'major' || key === 'minor' || key === 'patch') {
  570. if (v1[key] !== v2[key]) {
  571. return prefix + key
  572. }
  573. }
  574. }
  575. return defaultResult // may be undefined
  576. }
  577. }
  578. exports.compareIdentifiers = compareIdentifiers;
  579. var numeric = /^[0-9]+$/;
  580. function compareIdentifiers (a, b) {
  581. var anum = numeric.test(a);
  582. var bnum = numeric.test(b);
  583. if (anum && bnum) {
  584. a = +a;
  585. b = +b;
  586. }
  587. return a === b ? 0
  588. : (anum && !bnum) ? -1
  589. : (bnum && !anum) ? 1
  590. : a < b ? -1
  591. : 1
  592. }
  593. exports.rcompareIdentifiers = rcompareIdentifiers;
  594. function rcompareIdentifiers (a, b) {
  595. return compareIdentifiers(b, a)
  596. }
  597. exports.major = major;
  598. function major (a, loose) {
  599. return new SemVer(a, loose).major
  600. }
  601. exports.minor = minor;
  602. function minor (a, loose) {
  603. return new SemVer(a, loose).minor
  604. }
  605. exports.patch = patch;
  606. function patch (a, loose) {
  607. return new SemVer(a, loose).patch
  608. }
  609. exports.compare = compare;
  610. function compare (a, b, loose) {
  611. return new SemVer(a, loose).compare(new SemVer(b, loose))
  612. }
  613. exports.compareLoose = compareLoose;
  614. function compareLoose (a, b) {
  615. return compare(a, b, true)
  616. }
  617. exports.compareBuild = compareBuild;
  618. function compareBuild (a, b, loose) {
  619. var versionA = new SemVer(a, loose);
  620. var versionB = new SemVer(b, loose);
  621. return versionA.compare(versionB) || versionA.compareBuild(versionB)
  622. }
  623. exports.rcompare = rcompare;
  624. function rcompare (a, b, loose) {
  625. return compare(b, a, loose)
  626. }
  627. exports.sort = sort;
  628. function sort (list, loose) {
  629. return list.sort(function (a, b) {
  630. return exports.compareBuild(a, b, loose)
  631. })
  632. }
  633. exports.rsort = rsort;
  634. function rsort (list, loose) {
  635. return list.sort(function (a, b) {
  636. return exports.compareBuild(b, a, loose)
  637. })
  638. }
  639. exports.gt = gt;
  640. function gt (a, b, loose) {
  641. return compare(a, b, loose) > 0
  642. }
  643. exports.lt = lt;
  644. function lt (a, b, loose) {
  645. return compare(a, b, loose) < 0
  646. }
  647. exports.eq = eq;
  648. function eq (a, b, loose) {
  649. return compare(a, b, loose) === 0
  650. }
  651. exports.neq = neq;
  652. function neq (a, b, loose) {
  653. return compare(a, b, loose) !== 0
  654. }
  655. exports.gte = gte;
  656. function gte (a, b, loose) {
  657. return compare(a, b, loose) >= 0
  658. }
  659. exports.lte = lte;
  660. function lte (a, b, loose) {
  661. return compare(a, b, loose) <= 0
  662. }
  663. exports.cmp = cmp;
  664. function cmp (a, op, b, loose) {
  665. switch (op) {
  666. case '===':
  667. if (typeof a === 'object')
  668. { a = a.version; }
  669. if (typeof b === 'object')
  670. { b = b.version; }
  671. return a === b
  672. case '!==':
  673. if (typeof a === 'object')
  674. { a = a.version; }
  675. if (typeof b === 'object')
  676. { b = b.version; }
  677. return a !== b
  678. case '':
  679. case '=':
  680. case '==':
  681. return eq(a, b, loose)
  682. case '!=':
  683. return neq(a, b, loose)
  684. case '>':
  685. return gt(a, b, loose)
  686. case '>=':
  687. return gte(a, b, loose)
  688. case '<':
  689. return lt(a, b, loose)
  690. case '<=':
  691. return lte(a, b, loose)
  692. default:
  693. throw new TypeError('Invalid operator: ' + op)
  694. }
  695. }
  696. exports.Comparator = Comparator;
  697. function Comparator (comp, options) {
  698. if (!options || typeof options !== 'object') {
  699. options = {
  700. loose: !!options,
  701. includePrerelease: false
  702. };
  703. }
  704. if (comp instanceof Comparator) {
  705. if (comp.loose === !!options.loose) {
  706. return comp
  707. } else {
  708. comp = comp.value;
  709. }
  710. }
  711. if (!(this instanceof Comparator)) {
  712. return new Comparator(comp, options)
  713. }
  714. debug('comparator', comp, options);
  715. this.options = options;
  716. this.loose = !!options.loose;
  717. this.parse(comp);
  718. if (this.semver === ANY) {
  719. this.value = '';
  720. } else {
  721. this.value = this.operator + this.semver.version;
  722. }
  723. debug('comp', this);
  724. }
  725. var ANY = {};
  726. Comparator.prototype.parse = function (comp) {
  727. var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
  728. var m = comp.match(r);
  729. if (!m) {
  730. throw new TypeError('Invalid comparator: ' + comp)
  731. }
  732. this.operator = m[1] !== undefined ? m[1] : '';
  733. if (this.operator === '=') {
  734. this.operator = '';
  735. }
  736. // if it literally is just '>' or '' then allow anything.
  737. if (!m[2]) {
  738. this.semver = ANY;
  739. } else {
  740. this.semver = new SemVer(m[2], this.options.loose);
  741. }
  742. };
  743. Comparator.prototype.toString = function () {
  744. return this.value
  745. };
  746. Comparator.prototype.test = function (version) {
  747. debug('Comparator.test', version, this.options.loose);
  748. if (this.semver === ANY || version === ANY) {
  749. return true
  750. }
  751. if (typeof version === 'string') {
  752. try {
  753. version = new SemVer(version, this.options);
  754. } catch (er) {
  755. return false
  756. }
  757. }
  758. return cmp(version, this.operator, this.semver, this.options)
  759. };
  760. Comparator.prototype.intersects = function (comp, options) {
  761. if (!(comp instanceof Comparator)) {
  762. throw new TypeError('a Comparator is required')
  763. }
  764. if (!options || typeof options !== 'object') {
  765. options = {
  766. loose: !!options,
  767. includePrerelease: false
  768. };
  769. }
  770. var rangeTmp;
  771. if (this.operator === '') {
  772. if (this.value === '') {
  773. return true
  774. }
  775. rangeTmp = new Range(comp.value, options);
  776. return satisfies(this.value, rangeTmp, options)
  777. } else if (comp.operator === '') {
  778. if (comp.value === '') {
  779. return true
  780. }
  781. rangeTmp = new Range(this.value, options);
  782. return satisfies(comp.semver, rangeTmp, options)
  783. }
  784. var sameDirectionIncreasing =
  785. (this.operator === '>=' || this.operator === '>') &&
  786. (comp.operator === '>=' || comp.operator === '>');
  787. var sameDirectionDecreasing =
  788. (this.operator === '<=' || this.operator === '<') &&
  789. (comp.operator === '<=' || comp.operator === '<');
  790. var sameSemVer = this.semver.version === comp.semver.version;
  791. var differentDirectionsInclusive =
  792. (this.operator === '>=' || this.operator === '<=') &&
  793. (comp.operator === '>=' || comp.operator === '<=');
  794. var oppositeDirectionsLessThan =
  795. cmp(this.semver, '<', comp.semver, options) &&
  796. ((this.operator === '>=' || this.operator === '>') &&
  797. (comp.operator === '<=' || comp.operator === '<'));
  798. var oppositeDirectionsGreaterThan =
  799. cmp(this.semver, '>', comp.semver, options) &&
  800. ((this.operator === '<=' || this.operator === '<') &&
  801. (comp.operator === '>=' || comp.operator === '>'));
  802. return sameDirectionIncreasing || sameDirectionDecreasing ||
  803. (sameSemVer && differentDirectionsInclusive) ||
  804. oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
  805. };
  806. exports.Range = Range;
  807. function Range (range, options) {
  808. if (!options || typeof options !== 'object') {
  809. options = {
  810. loose: !!options,
  811. includePrerelease: false
  812. };
  813. }
  814. if (range instanceof Range) {
  815. if (range.loose === !!options.loose &&
  816. range.includePrerelease === !!options.includePrerelease) {
  817. return range
  818. } else {
  819. return new Range(range.raw, options)
  820. }
  821. }
  822. if (range instanceof Comparator) {
  823. return new Range(range.value, options)
  824. }
  825. if (!(this instanceof Range)) {
  826. return new Range(range, options)
  827. }
  828. this.options = options;
  829. this.loose = !!options.loose;
  830. this.includePrerelease = !!options.includePrerelease;
  831. // First, split based on boolean or ||
  832. this.raw = range;
  833. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  834. return this.parseRange(range.trim())
  835. }, this).filter(function (c) {
  836. // throw out any that are not relevant for whatever reason
  837. return c.length
  838. });
  839. if (!this.set.length) {
  840. throw new TypeError('Invalid SemVer Range: ' + range)
  841. }
  842. this.format();
  843. }
  844. Range.prototype.format = function () {
  845. this.range = this.set.map(function (comps) {
  846. return comps.join(' ').trim()
  847. }).join('||').trim();
  848. return this.range
  849. };
  850. Range.prototype.toString = function () {
  851. return this.range
  852. };
  853. Range.prototype.parseRange = function (range) {
  854. var loose = this.options.loose;
  855. range = range.trim();
  856. // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  857. var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
  858. range = range.replace(hr, hyphenReplace);
  859. debug('hyphen replace', range);
  860. // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  861. range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
  862. debug('comparator trim', range, re[t.COMPARATORTRIM]);
  863. // `~ 1.2.3` => `~1.2.3`
  864. range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
  865. // `^ 1.2.3` => `^1.2.3`
  866. range = range.replace(re[t.CARETTRIM], caretTrimReplace);
  867. // normalize spaces
  868. range = range.split(/\s+/).join(' ');
  869. // At this point, the range is completely trimmed and
  870. // ready to be split into comparators.
  871. var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
  872. var set = range.split(' ').map(function (comp) {
  873. return parseComparator(comp, this.options)
  874. }, this).join(' ').split(/\s+/);
  875. if (this.options.loose) {
  876. // in loose mode, throw out any that are not valid comparators
  877. set = set.filter(function (comp) {
  878. return !!comp.match(compRe)
  879. });
  880. }
  881. set = set.map(function (comp) {
  882. return new Comparator(comp, this.options)
  883. }, this);
  884. return set
  885. };
  886. Range.prototype.intersects = function (range, options) {
  887. if (!(range instanceof Range)) {
  888. throw new TypeError('a Range is required')
  889. }
  890. return this.set.some(function (thisComparators) {
  891. return (
  892. isSatisfiable(thisComparators, options) &&
  893. range.set.some(function (rangeComparators) {
  894. return (
  895. isSatisfiable(rangeComparators, options) &&
  896. thisComparators.every(function (thisComparator) {
  897. return rangeComparators.every(function (rangeComparator) {
  898. return thisComparator.intersects(rangeComparator, options)
  899. })
  900. })
  901. )
  902. })
  903. )
  904. })
  905. };
  906. // take a set of comparators and determine whether there
  907. // exists a version which can satisfy it
  908. function isSatisfiable (comparators, options) {
  909. var result = true;
  910. var remainingComparators = comparators.slice();
  911. var testComparator = remainingComparators.pop();
  912. while (result && remainingComparators.length) {
  913. result = remainingComparators.every(function (otherComparator) {
  914. return testComparator.intersects(otherComparator, options)
  915. });
  916. testComparator = remainingComparators.pop();
  917. }
  918. return result
  919. }
  920. // Mostly just for testing and legacy API reasons
  921. exports.toComparators = toComparators;
  922. function toComparators (range, options) {
  923. return new Range(range, options).set.map(function (comp) {
  924. return comp.map(function (c) {
  925. return c.value
  926. }).join(' ').trim().split(' ')
  927. })
  928. }
  929. // comprised of xranges, tildes, stars, and gtlt's at this point.
  930. // already replaced the hyphen ranges
  931. // turn into a set of JUST comparators.
  932. function parseComparator (comp, options) {
  933. debug('comp', comp, options);
  934. comp = replaceCarets(comp, options);
  935. debug('caret', comp);
  936. comp = replaceTildes(comp, options);
  937. debug('tildes', comp);
  938. comp = replaceXRanges(comp, options);
  939. debug('xrange', comp);
  940. comp = replaceStars(comp, options);
  941. debug('stars', comp);
  942. return comp
  943. }
  944. function isX (id) {
  945. return !id || id.toLowerCase() === 'x' || id === '*'
  946. }
  947. // ~, ~> --> * (any, kinda silly)
  948. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  949. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  950. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  951. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  952. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  953. function replaceTildes (comp, options) {
  954. return comp.trim().split(/\s+/).map(function (comp) {
  955. return replaceTilde(comp, options)
  956. }).join(' ')
  957. }
  958. function replaceTilde (comp, options) {
  959. var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
  960. return comp.replace(r, function (_, M, m, p, pr) {
  961. debug('tilde', comp, _, M, m, p, pr);
  962. var ret;
  963. if (isX(M)) {
  964. ret = '';
  965. } else if (isX(m)) {
  966. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  967. } else if (isX(p)) {
  968. // ~1.2 == >=1.2.0 <1.3.0
  969. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  970. } else if (pr) {
  971. debug('replaceTilde pr', pr);
  972. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  973. ' <' + M + '.' + (+m + 1) + '.0';
  974. } else {
  975. // ~1.2.3 == >=1.2.3 <1.3.0
  976. ret = '>=' + M + '.' + m + '.' + p +
  977. ' <' + M + '.' + (+m + 1) + '.0';
  978. }
  979. debug('tilde return', ret);
  980. return ret
  981. })
  982. }
  983. // ^ --> * (any, kinda silly)
  984. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  985. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  986. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  987. // ^1.2.3 --> >=1.2.3 <2.0.0
  988. // ^1.2.0 --> >=1.2.0 <2.0.0
  989. function replaceCarets (comp, options) {
  990. return comp.trim().split(/\s+/).map(function (comp) {
  991. return replaceCaret(comp, options)
  992. }).join(' ')
  993. }
  994. function replaceCaret (comp, options) {
  995. debug('caret', comp, options);
  996. var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
  997. return comp.replace(r, function (_, M, m, p, pr) {
  998. debug('caret', comp, _, M, m, p, pr);
  999. var ret;
  1000. if (isX(M)) {
  1001. ret = '';
  1002. } else if (isX(m)) {
  1003. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  1004. } else if (isX(p)) {
  1005. if (M === '0') {
  1006. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  1007. } else {
  1008. ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  1009. }
  1010. } else if (pr) {
  1011. debug('replaceCaret pr', pr);
  1012. if (M === '0') {
  1013. if (m === '0') {
  1014. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1015. ' <' + M + '.' + m + '.' + (+p + 1);
  1016. } else {
  1017. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1018. ' <' + M + '.' + (+m + 1) + '.0';
  1019. }
  1020. } else {
  1021. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1022. ' <' + (+M + 1) + '.0.0';
  1023. }
  1024. } else {
  1025. debug('no pr');
  1026. if (M === '0') {
  1027. if (m === '0') {
  1028. ret = '>=' + M + '.' + m + '.' + p +
  1029. ' <' + M + '.' + m + '.' + (+p + 1);
  1030. } else {
  1031. ret = '>=' + M + '.' + m + '.' + p +
  1032. ' <' + M + '.' + (+m + 1) + '.0';
  1033. }
  1034. } else {
  1035. ret = '>=' + M + '.' + m + '.' + p +
  1036. ' <' + (+M + 1) + '.0.0';
  1037. }
  1038. }
  1039. debug('caret return', ret);
  1040. return ret
  1041. })
  1042. }
  1043. function replaceXRanges (comp, options) {
  1044. debug('replaceXRanges', comp, options);
  1045. return comp.split(/\s+/).map(function (comp) {
  1046. return replaceXRange(comp, options)
  1047. }).join(' ')
  1048. }
  1049. function replaceXRange (comp, options) {
  1050. comp = comp.trim();
  1051. var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
  1052. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  1053. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  1054. var xM = isX(M);
  1055. var xm = xM || isX(m);
  1056. var xp = xm || isX(p);
  1057. var anyX = xp;
  1058. if (gtlt === '=' && anyX) {
  1059. gtlt = '';
  1060. }
  1061. // if we're including prereleases in the match, then we need
  1062. // to fix this to -0, the lowest possible prerelease value
  1063. pr = options.includePrerelease ? '-0' : '';
  1064. if (xM) {
  1065. if (gtlt === '>' || gtlt === '<') {
  1066. // nothing is allowed
  1067. ret = '<0.0.0-0';
  1068. } else {
  1069. // nothing is forbidden
  1070. ret = '*';
  1071. }
  1072. } else if (gtlt && anyX) {
  1073. // we know patch is an x, because we have any x at all.
  1074. // replace X with 0
  1075. if (xm) {
  1076. m = 0;
  1077. }
  1078. p = 0;
  1079. if (gtlt === '>') {
  1080. // >1 => >=2.0.0
  1081. // >1.2 => >=1.3.0
  1082. // >1.2.3 => >= 1.2.4
  1083. gtlt = '>=';
  1084. if (xm) {
  1085. M = +M + 1;
  1086. m = 0;
  1087. p = 0;
  1088. } else {
  1089. m = +m + 1;
  1090. p = 0;
  1091. }
  1092. } else if (gtlt === '<=') {
  1093. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  1094. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  1095. gtlt = '<';
  1096. if (xm) {
  1097. M = +M + 1;
  1098. } else {
  1099. m = +m + 1;
  1100. }
  1101. }
  1102. ret = gtlt + M + '.' + m + '.' + p + pr;
  1103. } else if (xm) {
  1104. ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
  1105. } else if (xp) {
  1106. ret = '>=' + M + '.' + m + '.0' + pr +
  1107. ' <' + M + '.' + (+m + 1) + '.0' + pr;
  1108. }
  1109. debug('xRange return', ret);
  1110. return ret
  1111. })
  1112. }
  1113. // Because * is AND-ed with everything else in the comparator,
  1114. // and '' means "any version", just remove the *s entirely.
  1115. function replaceStars (comp, options) {
  1116. debug('replaceStars', comp, options);
  1117. // Looseness is ignored here. star is always as loose as it gets!
  1118. return comp.trim().replace(re[t.STAR], '')
  1119. }
  1120. // This function is passed to string.replace(re[t.HYPHENRANGE])
  1121. // M, m, patch, prerelease, build
  1122. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  1123. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  1124. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  1125. function hyphenReplace ($0,
  1126. from, fM, fm, fp, fpr, fb,
  1127. to, tM, tm, tp, tpr, tb) {
  1128. if (isX(fM)) {
  1129. from = '';
  1130. } else if (isX(fm)) {
  1131. from = '>=' + fM + '.0.0';
  1132. } else if (isX(fp)) {
  1133. from = '>=' + fM + '.' + fm + '.0';
  1134. } else {
  1135. from = '>=' + from;
  1136. }
  1137. if (isX(tM)) {
  1138. to = '';
  1139. } else if (isX(tm)) {
  1140. to = '<' + (+tM + 1) + '.0.0';
  1141. } else if (isX(tp)) {
  1142. to = '<' + tM + '.' + (+tm + 1) + '.0';
  1143. } else if (tpr) {
  1144. to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
  1145. } else {
  1146. to = '<=' + to;
  1147. }
  1148. return (from + ' ' + to).trim()
  1149. }
  1150. // if ANY of the sets match ALL of its comparators, then pass
  1151. Range.prototype.test = function (version) {
  1152. if (!version) {
  1153. return false
  1154. }
  1155. if (typeof version === 'string') {
  1156. try {
  1157. version = new SemVer(version, this.options);
  1158. } catch (er) {
  1159. return false
  1160. }
  1161. }
  1162. for (var i = 0; i < this.set.length; i++) {
  1163. if (testSet(this.set[i], version, this.options)) {
  1164. return true
  1165. }
  1166. }
  1167. return false
  1168. };
  1169. function testSet (set, version, options) {
  1170. for (var i = 0; i < set.length; i++) {
  1171. if (!set[i].test(version)) {
  1172. return false
  1173. }
  1174. }
  1175. if (version.prerelease.length && !options.includePrerelease) {
  1176. // Find the set of versions that are allowed to have prereleases
  1177. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  1178. // That should allow `1.2.3-pr.2` to pass.
  1179. // However, `1.2.4-alpha.notready` should NOT be allowed,
  1180. // even though it's within the range set by the comparators.
  1181. for (i = 0; i < set.length; i++) {
  1182. debug(set[i].semver);
  1183. if (set[i].semver === ANY) {
  1184. continue
  1185. }
  1186. if (set[i].semver.prerelease.length > 0) {
  1187. var allowed = set[i].semver;
  1188. if (allowed.major === version.major &&
  1189. allowed.minor === version.minor &&
  1190. allowed.patch === version.patch) {
  1191. return true
  1192. }
  1193. }
  1194. }
  1195. // Version has a -pre, but it's not one of the ones we like.
  1196. return false
  1197. }
  1198. return true
  1199. }
  1200. exports.satisfies = satisfies;
  1201. function satisfies (version, range, options) {
  1202. try {
  1203. range = new Range(range, options);
  1204. } catch (er) {
  1205. return false
  1206. }
  1207. return range.test(version)
  1208. }
  1209. exports.maxSatisfying = maxSatisfying;
  1210. function maxSatisfying (versions, range, options) {
  1211. var max = null;
  1212. var maxSV = null;
  1213. try {
  1214. var rangeObj = new Range(range, options);
  1215. } catch (er) {
  1216. return null
  1217. }
  1218. versions.forEach(function (v) {
  1219. if (rangeObj.test(v)) {
  1220. // satisfies(v, range, options)
  1221. if (!max || maxSV.compare(v) === -1) {
  1222. // compare(max, v, true)
  1223. max = v;
  1224. maxSV = new SemVer(max, options);
  1225. }
  1226. }
  1227. });
  1228. return max
  1229. }
  1230. exports.minSatisfying = minSatisfying;
  1231. function minSatisfying (versions, range, options) {
  1232. var min = null;
  1233. var minSV = null;
  1234. try {
  1235. var rangeObj = new Range(range, options);
  1236. } catch (er) {
  1237. return null
  1238. }
  1239. versions.forEach(function (v) {
  1240. if (rangeObj.test(v)) {
  1241. // satisfies(v, range, options)
  1242. if (!min || minSV.compare(v) === 1) {
  1243. // compare(min, v, true)
  1244. min = v;
  1245. minSV = new SemVer(min, options);
  1246. }
  1247. }
  1248. });
  1249. return min
  1250. }
  1251. exports.minVersion = minVersion;
  1252. function minVersion (range, loose) {
  1253. range = new Range(range, loose);
  1254. var minver = new SemVer('0.0.0');
  1255. if (range.test(minver)) {
  1256. return minver
  1257. }
  1258. minver = new SemVer('0.0.0-0');
  1259. if (range.test(minver)) {
  1260. return minver
  1261. }
  1262. minver = null;
  1263. for (var i = 0; i < range.set.length; ++i) {
  1264. var comparators = range.set[i];
  1265. comparators.forEach(function (comparator) {
  1266. // Clone to avoid manipulating the comparator's semver object.
  1267. var compver = new SemVer(comparator.semver.version);
  1268. switch (comparator.operator) {
  1269. case '>':
  1270. if (compver.prerelease.length === 0) {
  1271. compver.patch++;
  1272. } else {
  1273. compver.prerelease.push(0);
  1274. }
  1275. compver.raw = compver.format();
  1276. /* fallthrough */
  1277. case '':
  1278. case '>=':
  1279. if (!minver || gt(minver, compver)) {
  1280. minver = compver;
  1281. }
  1282. break
  1283. case '<':
  1284. case '<=':
  1285. /* Ignore maximum versions */
  1286. break
  1287. /* istanbul ignore next */
  1288. default:
  1289. throw new Error('Unexpected operation: ' + comparator.operator)
  1290. }
  1291. });
  1292. }
  1293. if (minver && range.test(minver)) {
  1294. return minver
  1295. }
  1296. return null
  1297. }
  1298. exports.validRange = validRange;
  1299. function validRange (range, options) {
  1300. try {
  1301. // Return '*' instead of '' so that truthiness works.
  1302. // This will throw if it's invalid anyway
  1303. return new Range(range, options).range || '*'
  1304. } catch (er) {
  1305. return null
  1306. }
  1307. }
  1308. // Determine if version is less than all the versions possible in the range
  1309. exports.ltr = ltr;
  1310. function ltr (version, range, options) {
  1311. return outside(version, range, '<', options)
  1312. }
  1313. // Determine if version is greater than all the versions possible in the range.
  1314. exports.gtr = gtr;
  1315. function gtr (version, range, options) {
  1316. return outside(version, range, '>', options)
  1317. }
  1318. exports.outside = outside;
  1319. function outside (version, range, hilo, options) {
  1320. version = new SemVer(version, options);
  1321. range = new Range(range, options);
  1322. var gtfn, ltefn, ltfn, comp, ecomp;
  1323. switch (hilo) {
  1324. case '>':
  1325. gtfn = gt;
  1326. ltefn = lte;
  1327. ltfn = lt;
  1328. comp = '>';
  1329. ecomp = '>=';
  1330. break
  1331. case '<':
  1332. gtfn = lt;
  1333. ltefn = gte;
  1334. ltfn = gt;
  1335. comp = '<';
  1336. ecomp = '<=';
  1337. break
  1338. default:
  1339. throw new TypeError('Must provide a hilo val of "<" or ">"')
  1340. }
  1341. // If it satisifes the range it is not outside
  1342. if (satisfies(version, range, options)) {
  1343. return false
  1344. }
  1345. // From now on, variable terms are as if we're in "gtr" mode.
  1346. // but note that everything is flipped for the "ltr" function.
  1347. for (var i = 0; i < range.set.length; ++i) {
  1348. var comparators = range.set[i];
  1349. var high = null;
  1350. var low = null;
  1351. comparators.forEach(function (comparator) {
  1352. if (comparator.semver === ANY) {
  1353. comparator = new Comparator('>=0.0.0');
  1354. }
  1355. high = high || comparator;
  1356. low = low || comparator;
  1357. if (gtfn(comparator.semver, high.semver, options)) {
  1358. high = comparator;
  1359. } else if (ltfn(comparator.semver, low.semver, options)) {
  1360. low = comparator;
  1361. }
  1362. });
  1363. // If the edge version comparator has a operator then our version
  1364. // isn't outside it
  1365. if (high.operator === comp || high.operator === ecomp) {
  1366. return false
  1367. }
  1368. // If the lowest version comparator has an operator and our version
  1369. // is less than it then it isn't higher than the range
  1370. if ((!low.operator || low.operator === comp) &&
  1371. ltefn(version, low.semver)) {
  1372. return false
  1373. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  1374. return false
  1375. }
  1376. }
  1377. return true
  1378. }
  1379. exports.prerelease = prerelease;
  1380. function prerelease (version, options) {
  1381. var parsed = parse(version, options);
  1382. return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
  1383. }
  1384. exports.intersects = intersects;
  1385. function intersects (r1, r2, options) {
  1386. r1 = new Range(r1, options);
  1387. r2 = new Range(r2, options);
  1388. return r1.intersects(r2)
  1389. }
  1390. exports.coerce = coerce;
  1391. function coerce (version, options) {
  1392. if (version instanceof SemVer) {
  1393. return version
  1394. }
  1395. if (typeof version === 'number') {
  1396. version = String(version);
  1397. }
  1398. if (typeof version !== 'string') {
  1399. return null
  1400. }
  1401. options = options || {};
  1402. var match = null;
  1403. if (!options.rtl) {
  1404. match = version.match(re[t.COERCE]);
  1405. } else {
  1406. // Find the right-most coercible string that does not share
  1407. // a terminus with a more left-ward coercible string.
  1408. // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
  1409. //
  1410. // Walk through the string checking with a /g regexp
  1411. // Manually set the index so as to pick up overlapping matches.
  1412. // Stop when we get a match that ends at the string end, since no
  1413. // coercible string can be more right-ward without the same terminus.
  1414. var next;
  1415. while ((next = re[t.COERCERTL].exec(version)) &&
  1416. (!match || match.index + match[0].length !== version.length)
  1417. ) {
  1418. if (!match ||
  1419. next.index + next[0].length !== match.index + match[0].length) {
  1420. match = next;
  1421. }
  1422. re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
  1423. }
  1424. // leave it in a clean state
  1425. re[t.COERCERTL].lastIndex = -1;
  1426. }
  1427. if (match === null) {
  1428. return null
  1429. }
  1430. return parse(match[2] +
  1431. '.' + (match[3] || '0') +
  1432. '.' + (match[4] || '0'), options)
  1433. }
  1434. });
  1435. var NAME_SELECTOR = 'NAME_SELECTOR';
  1436. var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
  1437. var REF_SELECTOR = 'REF_SELECTOR';
  1438. var DOM_SELECTOR = 'DOM_SELECTOR';
  1439. var INVALID_SELECTOR = 'INVALID_SELECTOR';
  1440. var VUE_VERSION = Number(
  1441. ((Vue__default['default'].version.split('.')[0]) + "." + (Vue__default['default'].version.split('.')[1]))
  1442. );
  1443. var FUNCTIONAL_OPTIONS =
  1444. VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
  1445. var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue__default['default'].version, '2.1.8')
  1446. ? 'beforeCreate'
  1447. : 'beforeMount';
  1448. var CREATE_ELEMENT_ALIAS = semver.gt(Vue__default['default'].version, '2.1.5')
  1449. ? '_c'
  1450. : '_h';
  1451. //
  1452. function throwError(msg) {
  1453. throw new Error(("[vue-test-utils]: " + msg))
  1454. }
  1455. function warn(msg) {
  1456. console.error(("[vue-test-utils]: " + msg));
  1457. }
  1458. var camelizeRE = /-(\w)/g;
  1459. var camelize = function (str) {
  1460. var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }
  1461. );
  1462. return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
  1463. };
  1464. /**
  1465. * Capitalize a string.
  1466. */
  1467. var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
  1468. /**
  1469. * Hyphenate a camelCase string.
  1470. */
  1471. var hyphenateRE = /\B([A-Z])/g;
  1472. var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
  1473. function hasOwnProperty(obj, prop) {
  1474. return Object.prototype.hasOwnProperty.call(obj, prop)
  1475. }
  1476. function keys(obj) {
  1477. // $FlowIgnore
  1478. return Object.keys(obj)
  1479. }
  1480. function resolveComponent(id, components) {
  1481. if (typeof id !== 'string') {
  1482. return
  1483. }
  1484. // check local registration variations first
  1485. if (hasOwnProperty(components, id)) {
  1486. return components[id]
  1487. }
  1488. var camelizedId = camelize(id);
  1489. if (hasOwnProperty(components, camelizedId)) {
  1490. return components[camelizedId]
  1491. }
  1492. var PascalCaseId = capitalize(camelizedId);
  1493. if (hasOwnProperty(components, PascalCaseId)) {
  1494. return components[PascalCaseId]
  1495. }
  1496. // fallback to prototype chain
  1497. return components[id] || components[camelizedId] || components[PascalCaseId]
  1498. }
  1499. var UA =
  1500. typeof window !== 'undefined' &&
  1501. 'navigator' in window &&
  1502. navigator.userAgent.toLowerCase();
  1503. var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
  1504. var isEdge = UA && UA.indexOf('edge/') > 0;
  1505. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  1506. // get the event used to trigger v-model handler that updates bound data
  1507. function getCheckedEvent() {
  1508. var version = Vue__default['default'].version;
  1509. if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
  1510. return 'click'
  1511. }
  1512. if (semver.satisfies(version, '2.2 - 2.4')) {
  1513. return isChrome ? 'click' : 'change'
  1514. }
  1515. // change is handler for version 2.0 - 2.1.8, and 2.5+
  1516. return 'change'
  1517. }
  1518. /**
  1519. * Normalize nextTick to return a promise for all Vue 2 versions.
  1520. * Vue < 2.1 does not return a Promise from nextTick
  1521. * @return {Promise<R>}
  1522. */
  1523. function nextTick() {
  1524. if (VUE_VERSION > 2) { return Vue__default['default'].nextTick() }
  1525. return new Promise(function (resolve) {
  1526. Vue__default['default'].nextTick(resolve);
  1527. })
  1528. }
  1529. function warnDeprecated(method, fallback) {
  1530. if ( fallback === void 0 ) fallback = '';
  1531. if (!config.showDeprecationWarnings) { return }
  1532. var msg = method + " is deprecated and will be removed in the next major version.";
  1533. if (fallback) { msg += " " + fallback + "."; }
  1534. if (config.deprecationWarningHandler) {
  1535. config.deprecationWarningHandler(method, msg);
  1536. } else {
  1537. warn(msg);
  1538. }
  1539. }
  1540. function isVueWrapper(wrapper) {
  1541. return wrapper.vm || wrapper.isFunctionalComponent
  1542. }
  1543. //
  1544. function addMocks(
  1545. _Vue,
  1546. mockedProperties
  1547. ) {
  1548. if ( mockedProperties === void 0 ) mockedProperties = {};
  1549. if (mockedProperties === false) {
  1550. return
  1551. }
  1552. Object.keys(mockedProperties).forEach(function (key) {
  1553. try {
  1554. // $FlowIgnore
  1555. _Vue.prototype[key] = mockedProperties[key];
  1556. } catch (e) {
  1557. warn(
  1558. "could not overwrite property " + key + ", this is " +
  1559. "usually caused by a plugin that has added " +
  1560. "the property as a read-only value"
  1561. );
  1562. }
  1563. // $FlowIgnore
  1564. Vue__default['default'].util.defineReactive(_Vue, key, mockedProperties[key]);
  1565. });
  1566. }
  1567. //
  1568. function logEvents(
  1569. vm,
  1570. emitted,
  1571. emittedByOrder
  1572. ) {
  1573. var emit = vm.$emit;
  1574. vm.$emit = function (name) {
  1575. var args = [], len = arguments.length - 1;
  1576. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  1577. (emitted[name] || (emitted[name] = [])).push(args);
  1578. emittedByOrder.push({ name: name, args: args });
  1579. return emit.call.apply(emit, [ vm, name ].concat( args ))
  1580. };
  1581. }
  1582. function addEventLogger(_Vue) {
  1583. _Vue.mixin({
  1584. beforeCreate: function() {
  1585. this.__emitted = Object.create(null);
  1586. this.__emittedByOrder = [];
  1587. logEvents(this, this.__emitted, this.__emittedByOrder);
  1588. }
  1589. });
  1590. }
  1591. function addStubs(_Vue, stubComponents) {
  1592. var obj;
  1593. function addStubComponentsMixin() {
  1594. Object.assign(this.$options.components, stubComponents);
  1595. }
  1596. _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = addStubComponentsMixin, obj ));
  1597. }
  1598. //
  1599. function isDomSelector(selector) {
  1600. if (typeof selector !== 'string') {
  1601. return false
  1602. }
  1603. try {
  1604. if (typeof document === 'undefined') {
  1605. throwError(
  1606. "mount must be run in a browser environment like " +
  1607. "PhantomJS, jsdom or chrome"
  1608. );
  1609. }
  1610. } catch (error) {
  1611. throwError(
  1612. "mount must be run in a browser environment like " +
  1613. "PhantomJS, jsdom or chrome"
  1614. );
  1615. }
  1616. try {
  1617. document.querySelector(selector);
  1618. return true
  1619. } catch (error$1) {
  1620. return false
  1621. }
  1622. }
  1623. function isVueComponent(c) {
  1624. if (isConstructor(c)) {
  1625. return true
  1626. }
  1627. if (c === null || typeof c !== 'object') {
  1628. return false
  1629. }
  1630. if (c.extends || c._Ctor) {
  1631. return true
  1632. }
  1633. if (typeof c.template === 'string') {
  1634. return true
  1635. }
  1636. if (typeof c.setup === 'function' && !c.render) {
  1637. return true
  1638. }
  1639. return typeof c.render === 'function'
  1640. }
  1641. function componentNeedsCompiling(component) {
  1642. return (
  1643. component &&
  1644. !component.render &&
  1645. (component.template || component.extends || component.extendOptions) &&
  1646. !component.functional
  1647. )
  1648. }
  1649. function isRefSelector(refOptionsObject) {
  1650. if (
  1651. typeof refOptionsObject !== 'object' ||
  1652. Object.keys(refOptionsObject || {}).length !== 1
  1653. ) {
  1654. return false
  1655. }
  1656. return typeof refOptionsObject.ref === 'string'
  1657. }
  1658. function isNameSelector(nameOptionsObject) {
  1659. if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
  1660. return false
  1661. }
  1662. return !!nameOptionsObject.name
  1663. }
  1664. function isConstructor(c) {
  1665. return typeof c === 'function' && c.cid
  1666. }
  1667. function isDynamicComponent(c) {
  1668. return typeof c === 'function' && !c.cid
  1669. }
  1670. function isComponentOptions(c) {
  1671. return c !== null && typeof c === 'object' && (c.template || c.render)
  1672. }
  1673. function isFunctionalComponent(c) {
  1674. if (!isVueComponent(c)) {
  1675. return false
  1676. }
  1677. if (isConstructor(c)) {
  1678. return c.options.functional
  1679. }
  1680. return c.functional
  1681. }
  1682. function templateContainsComponent(
  1683. template,
  1684. name
  1685. ) {
  1686. return [capitalize, camelize, hyphenate].some(function (format) {
  1687. var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
  1688. return re.test(template)
  1689. })
  1690. }
  1691. function isPlainObject(c) {
  1692. return Object.prototype.toString.call(c) === '[object Object]'
  1693. }
  1694. function isHTMLElement(c) {
  1695. if (typeof HTMLElement === 'undefined') {
  1696. return false
  1697. }
  1698. // eslint-disable-next-line no-undef
  1699. return c instanceof HTMLElement
  1700. }
  1701. function makeMap(str, expectsLowerCase) {
  1702. var map = Object.create(null);
  1703. var list = str.split(',');
  1704. for (var i = 0; i < list.length; i++) {
  1705. map[list[i]] = true;
  1706. }
  1707. return expectsLowerCase
  1708. ? function(val) {
  1709. return map[val.toLowerCase()]
  1710. }
  1711. : function(val) {
  1712. return map[val]
  1713. }
  1714. }
  1715. var isHTMLTag = makeMap(
  1716. 'html,body,base,head,link,meta,style,title,' +
  1717. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1718. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1719. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1720. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,' +
  1721. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1722. 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' +
  1723. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1724. 'output,progress,select,textarea,' +
  1725. 'details,dialog,menu,menuitem,summary,' +
  1726. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1727. );
  1728. // this map is intentionally selective, only covering SVG elements that may
  1729. // contain child elements.
  1730. var isSVG = makeMap(
  1731. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1732. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1733. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1734. true
  1735. );
  1736. var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };
  1737. //
  1738. function compileTemplate(component) {
  1739. if (component.template) {
  1740. if (!vueTemplateCompiler.compileToFunctions) {
  1741. throwError(
  1742. "vueTemplateCompiler is undefined, you must pass " +
  1743. "precompiled components if vue-template-compiler is " +
  1744. "undefined"
  1745. );
  1746. }
  1747. if (component.template.charAt('#') === '#') {
  1748. var el = document.querySelector(component.template);
  1749. if (!el) {
  1750. throwError('Cannot find element' + component.template);
  1751. el = document.createElement('div');
  1752. }
  1753. component.template = el.innerHTML;
  1754. }
  1755. Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
  1756. {name: component.name}));
  1757. }
  1758. if (component.components) {
  1759. Object.keys(component.components).forEach(function (c) {
  1760. var cmp = component.components[c];
  1761. if (!cmp.render) {
  1762. compileTemplate(cmp);
  1763. }
  1764. });
  1765. }
  1766. if (component.extends) {
  1767. compileTemplate(component.extends);
  1768. }
  1769. if (component.extendOptions && !component.options.render) {
  1770. compileTemplate(component.options);
  1771. }
  1772. }
  1773. function compileTemplateForSlots(slots) {
  1774. Object.keys(slots).forEach(function (key) {
  1775. var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
  1776. slot.forEach(function (slotValue) {
  1777. if (componentNeedsCompiling(slotValue)) {
  1778. compileTemplate(slotValue);
  1779. }
  1780. });
  1781. });
  1782. }
  1783. //
  1784. var MOUNTING_OPTIONS = [
  1785. 'attachToDocument',
  1786. 'mocks',
  1787. 'slots',
  1788. 'localVue',
  1789. 'stubs',
  1790. 'context',
  1791. 'clone',
  1792. 'attrs',
  1793. 'listeners',
  1794. 'propsData',
  1795. 'shouldProxy'
  1796. ];
  1797. function extractInstanceOptions(options) {
  1798. var instanceOptions = Object.assign({}, options);
  1799. MOUNTING_OPTIONS.forEach(function (mountingOption) {
  1800. delete instanceOptions[mountingOption];
  1801. });
  1802. return instanceOptions
  1803. }
  1804. //
  1805. function isDestructuringSlotScope(slotScope) {
  1806. return /^{.*}$/.test(slotScope)
  1807. }
  1808. function getVueTemplateCompilerHelpers(
  1809. _Vue
  1810. ) {
  1811. // $FlowIgnore
  1812. var vue = new _Vue();
  1813. var helpers = {};
  1814. var names = [
  1815. '_c',
  1816. '_o',
  1817. '_n',
  1818. '_s',
  1819. '_l',
  1820. '_t',
  1821. '_q',
  1822. '_i',
  1823. '_m',
  1824. '_f',
  1825. '_k',
  1826. '_b',
  1827. '_v',
  1828. '_e',
  1829. '_u',
  1830. '_g'
  1831. ];
  1832. names.forEach(function (name) {
  1833. helpers[name] = vue._renderProxy[name];
  1834. });
  1835. helpers.$createElement = vue._renderProxy.$createElement;
  1836. helpers.$set = vue._renderProxy.$set;
  1837. return helpers
  1838. }
  1839. function validateEnvironment() {
  1840. if (VUE_VERSION < 2.1) {
  1841. throwError("the scopedSlots option is only supported in vue@2.1+.");
  1842. }
  1843. }
  1844. function isScopedSlot(slot) {
  1845. if (typeof slot === 'function') { return { match: null, slot: slot } }
  1846. var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
  1847. var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
  1848. var shortVSlotRe = /<template #.*="(.+)"/;
  1849. var hasOldSlotScope = slot.match(slotScopeRe);
  1850. var hasVSlotScopeAttr = slot.match(vSlotRe);
  1851. var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);
  1852. if (hasOldSlotScope) {
  1853. return { slot: slot, match: hasOldSlotScope }
  1854. } else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
  1855. // Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
  1856. var sanitizedSlot = slot.replace(
  1857. /(<template)([^>]+)(>.+<\/template>)/,
  1858. '$1$3'
  1859. );
  1860. return {
  1861. slot: sanitizedSlot,
  1862. match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
  1863. }
  1864. }
  1865. // we have no matches, so we just return
  1866. return {
  1867. slot: slot,
  1868. match: null
  1869. }
  1870. }
  1871. // Hide warning about <template> disallowed as root element
  1872. function customWarn(msg) {
  1873. if (msg.indexOf('Cannot use <template> as component root element') === -1) {
  1874. console.error(msg);
  1875. }
  1876. }
  1877. function createScopedSlots(
  1878. scopedSlotsOption,
  1879. _Vue
  1880. ) {
  1881. var scopedSlots = {};
  1882. if (!scopedSlotsOption) {
  1883. return scopedSlots
  1884. }
  1885. validateEnvironment();
  1886. var helpers = getVueTemplateCompilerHelpers(_Vue);
  1887. var loop = function ( scopedSlotName ) {
  1888. var slot = scopedSlotsOption[scopedSlotName];
  1889. var isFn = typeof slot === 'function';
  1890. var scopedSlotMatches = isScopedSlot(slot);
  1891. // Type check to silence flow (can't use isFn)
  1892. var renderFn =
  1893. typeof slot === 'function'
  1894. ? slot
  1895. : vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
  1896. .render;
  1897. var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
  1898. scopedSlots[scopedSlotName] = function(props) {
  1899. var obj;
  1900. var res;
  1901. if (isFn) {
  1902. res = renderFn.call(Object.assign({}, helpers), props);
  1903. } else if (slotScope && !isDestructuringSlotScope(slotScope)) {
  1904. res = renderFn.call(Object.assign({}, helpers, ( obj = {}, obj[slotScope] = props, obj )));
  1905. } else if (slotScope && isDestructuringSlotScope(slotScope)) {
  1906. res = renderFn.call(Object.assign({}, helpers, props));
  1907. } else {
  1908. res = renderFn.call(Object.assign({}, helpers, {props: props}));
  1909. }
  1910. // res is Array if <template> is a root element
  1911. return Array.isArray(res) ? res[0] : res
  1912. };
  1913. };
  1914. for (var scopedSlotName in scopedSlotsOption) loop( scopedSlotName );
  1915. return scopedSlots
  1916. }
  1917. //
  1918. var FUNCTION_PLACEHOLDER = '[Function]';
  1919. function isVueComponentStub(comp) {
  1920. return (comp && comp.template) || isVueComponent(comp)
  1921. }
  1922. function isValidStub(stub) {
  1923. return (
  1924. typeof stub === 'boolean' ||
  1925. (!!stub && typeof stub === 'string') ||
  1926. isVueComponentStub(stub)
  1927. )
  1928. }
  1929. function resolveComponent$1(obj, component) {
  1930. return (
  1931. obj[component] ||
  1932. obj[hyphenate(component)] ||
  1933. obj[camelize(component)] ||
  1934. obj[capitalize(camelize(component))] ||
  1935. obj[capitalize(component)] ||
  1936. {}
  1937. )
  1938. }
  1939. function getCoreProperties(componentOptions) {
  1940. return {
  1941. attrs: componentOptions.attrs,
  1942. name: componentOptions.name,
  1943. model: componentOptions.model,
  1944. props: componentOptions.props,
  1945. on: componentOptions.on,
  1946. key: componentOptions.key,
  1947. domProps: componentOptions.domProps,
  1948. class: componentOptions.class,
  1949. staticClass: componentOptions.staticClass,
  1950. staticStyle: componentOptions.staticStyle,
  1951. style: componentOptions.style,
  1952. normalizedStyle: componentOptions.normalizedStyle,
  1953. nativeOn: componentOptions.nativeOn,
  1954. functional: componentOptions.functional,
  1955. abstract: componentOptions.abstract
  1956. }
  1957. }
  1958. function resolveOptions(component, _Vue) {
  1959. if (isDynamicComponent(component)) {
  1960. return {}
  1961. }
  1962. return isConstructor(component)
  1963. ? component.options
  1964. : _Vue.extend(component).options
  1965. }
  1966. function getScopedSlotRenderFunctions(ctx) {
  1967. // In Vue 2.6+ a new v-slot syntax was introduced
  1968. // scopedSlots are now saved in parent._vnode.data.scopedSlots
  1969. // We filter out _normalized, $stable and $key keys
  1970. if (
  1971. ctx &&
  1972. ctx.$options &&
  1973. ctx.$options.parent &&
  1974. ctx.$options.parent._vnode &&
  1975. ctx.$options.parent._vnode.data &&
  1976. ctx.$options.parent._vnode.data.scopedSlots
  1977. ) {
  1978. var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
  1979. return keys(slotKeys).filter(
  1980. function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
  1981. )
  1982. }
  1983. return []
  1984. }
  1985. function createStubFromComponent(
  1986. originalComponent,
  1987. name,
  1988. _Vue
  1989. ) {
  1990. var componentOptions = resolveOptions(originalComponent, _Vue);
  1991. var tagName = (name || 'anonymous') + "-stub";
  1992. // ignoreElements does not exist in Vue 2.0.x
  1993. if (Vue__default['default'].config.ignoredElements) {
  1994. Vue__default['default'].config.ignoredElements.push(tagName);
  1995. }
  1996. return Object.assign({}, getCoreProperties(componentOptions),
  1997. {$_vueTestUtils_original: originalComponent,
  1998. $_doNotStubChildren: true,
  1999. render: function render(h, context) {
  2000. var this$1 = this;
  2001. return h(
  2002. tagName,
  2003. componentOptions.functional
  2004. ? Object.assign({}, context.data,
  2005. {attrs: Object.assign({}, shapeStubProps(context.props),
  2006. context.data.attrs)})
  2007. : {
  2008. attrs: Object.assign({}, shapeStubProps(this.$props))
  2009. },
  2010. context
  2011. ? context.children
  2012. : this.$options._renderChildren ||
  2013. getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
  2014. )
  2015. )
  2016. }})
  2017. }
  2018. function shapeStubProps(props) {
  2019. var shapedProps = {};
  2020. for (var propName in props) {
  2021. if (typeof props[propName] === 'function') {
  2022. shapedProps[propName] = FUNCTION_PLACEHOLDER;
  2023. continue
  2024. }
  2025. if (Array.isArray(props[propName])) {
  2026. shapedProps[propName] = props[propName].map(function (value) {
  2027. return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
  2028. });
  2029. continue
  2030. }
  2031. shapedProps[propName] = props[propName];
  2032. }
  2033. return shapedProps
  2034. }
  2035. // DEPRECATED: converts string stub to template stub.
  2036. function createStubFromString(templateString, name) {
  2037. warnDeprecated('Using a string for stubs');
  2038. if (templateContainsComponent(templateString, name)) {
  2039. throwError('options.stub cannot contain a circular reference');
  2040. }
  2041. return {
  2042. template: templateString,
  2043. $_doNotStubChildren: true
  2044. }
  2045. }
  2046. function setStubComponentName(
  2047. stub,
  2048. originalComponent,
  2049. _Vue
  2050. ) {
  2051. if ( originalComponent === void 0 ) originalComponent = {};
  2052. if (stub.name) { return }
  2053. var componentOptions = resolveOptions(originalComponent, _Vue);
  2054. stub.name = getCoreProperties(componentOptions).name;
  2055. }
  2056. function validateStub(stub) {
  2057. if (!isValidStub(stub)) {
  2058. throwError("options.stub values must be passed a string or " + "component");
  2059. }
  2060. }
  2061. function createStubsFromStubsObject(
  2062. originalComponents,
  2063. stubs,
  2064. _Vue
  2065. ) {
  2066. if ( originalComponents === void 0 ) originalComponents = {};
  2067. return Object.keys(stubs || {}).reduce(function (acc, stubName) {
  2068. var stub = stubs[stubName];
  2069. validateStub(stub);
  2070. if (stub === false) {
  2071. return acc
  2072. }
  2073. var component = resolveComponent$1(originalComponents, stubName);
  2074. if (stub === true) {
  2075. acc[stubName] = createStubFromComponent(component, stubName, _Vue);
  2076. return acc
  2077. }
  2078. if (typeof stub === 'string') {
  2079. stub = createStubFromString(stub, stubName);
  2080. stubs[stubName];
  2081. }
  2082. setStubComponentName(stub, component, _Vue);
  2083. if (componentNeedsCompiling(stub)) {
  2084. compileTemplate(stub);
  2085. }
  2086. acc[stubName] = stub;
  2087. stub._Ctor = {};
  2088. return acc
  2089. }, {})
  2090. }
  2091. var isAllowlisted = function (el, allowlist) { return resolveComponent(el, allowlist); };
  2092. var isAlreadyStubbed = function (el, stubs) { return stubs.has(el); };
  2093. function shouldExtend(component, _Vue) {
  2094. return isConstructor(component) || (component && component.extends)
  2095. }
  2096. function extend(component, _Vue) {
  2097. var componentOptions = component.options ? component.options : component;
  2098. var stub = _Vue.extend(componentOptions);
  2099. stub.options.$_vueTestUtils_original = component;
  2100. stub.options._base = _Vue;
  2101. return stub
  2102. }
  2103. function createStubIfNeeded(shouldStub, component, _Vue, el) {
  2104. if (shouldStub) {
  2105. return createStubFromComponent(component || {}, el, _Vue)
  2106. }
  2107. if (shouldExtend(component)) {
  2108. return extend(component, _Vue)
  2109. }
  2110. }
  2111. function shouldNotBeStubbed(el, allowlist, modifiedComponents) {
  2112. return (
  2113. (typeof el === 'string' && isReservedTag(el)) ||
  2114. isAllowlisted(el, allowlist) ||
  2115. isAlreadyStubbed(el, modifiedComponents)
  2116. )
  2117. }
  2118. function patchCreateElement(_Vue, stubs, stubAllComponents) {
  2119. var obj;
  2120. // This mixin patches vm.$createElement so that we can stub all components
  2121. // before they are rendered in shallow mode. We also need to ensure that
  2122. // component constructors were created from the _Vue constructor. If not,
  2123. // we must replace them with components created from the _Vue constructor
  2124. // before calling the original $createElement. This ensures that components
  2125. // have the correct instance properties and stubs when they are rendered.
  2126. function patchCreateElementMixin() {
  2127. var vm = this;
  2128. if (vm.$options.$_doNotStubChildren || vm.$options._isFunctionalContainer) {
  2129. return
  2130. }
  2131. var modifiedComponents = new Set();
  2132. var originalCreateElement = vm.$createElement;
  2133. var originalComponents = vm.$options.components;
  2134. var createElement = function (el) {
  2135. var obj;
  2136. var args = [], len = arguments.length - 1;
  2137. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  2138. if (shouldNotBeStubbed(el, stubs, modifiedComponents)) {
  2139. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2140. }
  2141. if (isConstructor(el) || isComponentOptions(el)) {
  2142. if (stubAllComponents) {
  2143. var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
  2144. return originalCreateElement.apply(void 0, [ stub ].concat( args ))
  2145. }
  2146. var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
  2147. return originalCreateElement.apply(void 0, [ Constructor ].concat( args ))
  2148. }
  2149. if (typeof el === 'string') {
  2150. var original = resolveComponent(el, originalComponents);
  2151. if (!original) {
  2152. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2153. }
  2154. if (isDynamicComponent(original)) {
  2155. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2156. }
  2157. var stub$1 = createStubIfNeeded(stubAllComponents, original, _Vue, el);
  2158. if (stub$1) {
  2159. Object.assign(vm.$options.components, ( obj = {}, obj[el] = stub$1, obj ));
  2160. modifiedComponents.add(el);
  2161. }
  2162. }
  2163. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2164. };
  2165. vm[CREATE_ELEMENT_ALIAS] = createElement;
  2166. vm.$createElement = createElement;
  2167. }
  2168. _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = patchCreateElementMixin, obj ));
  2169. }
  2170. //
  2171. function objectWithoutProperties (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; }
  2172. function createContext(options, scopedSlots, currentProps) {
  2173. var on = Object.assign({}, (options.context && options.context.on),
  2174. options.listeners);
  2175. return Object.assign({}, {attrs: Object.assign({}, options.attrs,
  2176. // pass as attrs so that inheritAttrs works correctly
  2177. // props should take precedence over attrs
  2178. currentProps)},
  2179. (options.context || {}),
  2180. {on: on,
  2181. scopedSlots: scopedSlots})
  2182. }
  2183. function createChildren(vm, h, ref) {
  2184. var slots = ref.slots;
  2185. var context = ref.context;
  2186. var slotVNodes = slots ? createSlotVNodes(vm, slots) : undefined;
  2187. return (
  2188. (context &&
  2189. context.children &&
  2190. context.children.map(function (x) { return (typeof x === 'function' ? x(h) : x); })) ||
  2191. slotVNodes
  2192. )
  2193. }
  2194. function getValuesFromCallableOption(optionValue) {
  2195. if (typeof optionValue === 'function') {
  2196. return optionValue.call(this)
  2197. }
  2198. return optionValue
  2199. }
  2200. function createInstance(
  2201. component,
  2202. options,
  2203. _Vue
  2204. ) {
  2205. var componentOptions = isConstructor(component)
  2206. ? component.options
  2207. : component;
  2208. // instance options are options that are passed to the
  2209. // root instance when it's instantiated
  2210. var instanceOptions = extractInstanceOptions(options);
  2211. var globalComponents = _Vue.options.components || {};
  2212. var componentsToStub = Object.assign(
  2213. Object.create(globalComponents),
  2214. componentOptions.components
  2215. );
  2216. var stubComponentsObject = createStubsFromStubsObject(
  2217. componentsToStub,
  2218. // $FlowIgnore
  2219. options.stubs,
  2220. _Vue
  2221. );
  2222. addEventLogger(_Vue);
  2223. addMocks(_Vue, options.mocks);
  2224. addStubs(_Vue, stubComponentsObject);
  2225. patchCreateElement(_Vue, stubComponentsObject, options.shouldProxy);
  2226. if (componentNeedsCompiling(componentOptions)) {
  2227. compileTemplate(componentOptions);
  2228. }
  2229. // used to identify extended component using constructor
  2230. componentOptions.$_vueTestUtils_original = component;
  2231. // watchers provided in mounting options should override preexisting ones
  2232. if (componentOptions.watch && instanceOptions.watch) {
  2233. var componentWatchers = Object.keys(componentOptions.watch);
  2234. var instanceWatchers = Object.keys(instanceOptions.watch);
  2235. for (var i = 0; i < instanceWatchers.length; i++) {
  2236. var k = instanceWatchers[i];
  2237. // override the componentOptions with the one provided in mounting options
  2238. if (componentWatchers.includes(k)) {
  2239. componentOptions.watch[k] = instanceOptions.watch[k];
  2240. }
  2241. }
  2242. }
  2243. // make sure all extends are based on this instance
  2244. var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
  2245. Constructor.options._base = _Vue;
  2246. var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);
  2247. var parentComponentOptions = options.parentComponent || {};
  2248. var originalParentComponentProvide = parentComponentOptions.provide;
  2249. parentComponentOptions.provide = function() {
  2250. return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
  2251. // $FlowIgnore
  2252. getValuesFromCallableOption.call(this, options.provide))
  2253. };
  2254. var originalParentComponentData = parentComponentOptions.data;
  2255. parentComponentOptions.data = function() {
  2256. return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentData),
  2257. {vueTestUtils_childProps: Object.assign({}, options.propsData)})
  2258. };
  2259. parentComponentOptions.$_doNotStubChildren = true;
  2260. parentComponentOptions.$_isWrapperParent = true;
  2261. parentComponentOptions._isFunctionalContainer = componentOptions.functional;
  2262. parentComponentOptions.render = function(h) {
  2263. return h(
  2264. Constructor,
  2265. createContext(options, scopedSlots, this.vueTestUtils_childProps),
  2266. createChildren(this, h, options)
  2267. )
  2268. };
  2269. // options "propsData" can only be used during instance creation with the `new` keyword
  2270. // "data" should be set only on component under test to avoid reactivity issues
  2271. var propsData = options.propsData;
  2272. var data = options.data;
  2273. var rest$1 = objectWithoutProperties( options, ["propsData", "data"] );
  2274. var rest = rest$1; // eslint-disable-line
  2275. var Parent = _Vue.extend(Object.assign({}, rest,
  2276. parentComponentOptions));
  2277. return new Parent()
  2278. }
  2279. //
  2280. function createElement() {
  2281. if (document) {
  2282. var elem = document.createElement('div');
  2283. if (document.body) {
  2284. document.body.appendChild(elem);
  2285. }
  2286. return elem
  2287. }
  2288. }
  2289. //
  2290. function findDOMNodes(
  2291. element,
  2292. selector
  2293. ) {
  2294. var nodes = [];
  2295. if (!element || !element.querySelectorAll || !element.matches) {
  2296. return nodes
  2297. }
  2298. if (element.matches(selector)) {
  2299. nodes.push(element);
  2300. }
  2301. // $FlowIgnore
  2302. return nodes.concat([].slice.call(element.querySelectorAll(selector)))
  2303. }
  2304. function vmMatchesName(vm, name) {
  2305. // We want to mirror how Vue resolves component names in SFCs:
  2306. // For example, <test-component />, <TestComponent /> and `<testComponent />
  2307. // all resolve to the same component
  2308. var componentName = isFunctionalComponent(vm)
  2309. ? vm.name
  2310. : vm.$options && vm.$options.name;
  2311. return (
  2312. !!name &&
  2313. !!componentName &&
  2314. (componentName === name ||
  2315. // testComponent -> TestComponent
  2316. componentName === capitalize(name) ||
  2317. // test-component -> TestComponent
  2318. componentName === capitalize(camelize(name)) ||
  2319. // same match as above, but the component name vs query
  2320. capitalize(camelize(componentName)) === name)
  2321. )
  2322. }
  2323. function vmCtorMatches(vm, component) {
  2324. if (
  2325. (vm.$options && vm.$options.$_vueTestUtils_original === component) ||
  2326. vm.$_vueTestUtils_original === component
  2327. ) {
  2328. return true
  2329. }
  2330. var Ctor = isConstructor(component)
  2331. ? component.options._Ctor
  2332. : component._Ctor;
  2333. if (!Ctor) {
  2334. return false
  2335. }
  2336. if (vm.constructor.extendOptions === component) {
  2337. return true
  2338. }
  2339. if (component.functional) {
  2340. return Object.keys(vm._Ctor || {}).some(function (c) {
  2341. return component === vm._Ctor[c].extendOptions
  2342. })
  2343. }
  2344. }
  2345. function matches(node, selector) {
  2346. if (selector.type === DOM_SELECTOR) {
  2347. var element = node instanceof Element ? node : node.elm;
  2348. return element && element.matches && element.matches(selector.value)
  2349. }
  2350. var isFunctionalSelector = isConstructor(selector.value)
  2351. ? selector.value.options.functional
  2352. : selector.value.functional;
  2353. var componentInstance =
  2354. (isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
  2355. node[FUNCTIONAL_OPTIONS] ||
  2356. node.child;
  2357. if (!componentInstance) {
  2358. return false
  2359. }
  2360. if (selector.type === COMPONENT_SELECTOR) {
  2361. if (vmCtorMatches(componentInstance, selector.value)) {
  2362. return true
  2363. }
  2364. }
  2365. // Fallback to name selector for COMPONENT_SELECTOR for Vue < 2.1
  2366. var nameSelector = isConstructor(selector.value)
  2367. ? selector.value.extendOptions.name
  2368. : selector.value.name;
  2369. return vmMatchesName(componentInstance, nameSelector)
  2370. }
  2371. //
  2372. /**
  2373. * Traverses a vue instance for its parents and returns them in an array format
  2374. * @param {Component} vm
  2375. * @returns {Component[]} The component and its corresponding parents, in order from left to right
  2376. */
  2377. function findAllParentInstances(childVm) {
  2378. var instances = [childVm];
  2379. function getParent(_vm) {
  2380. if (_vm && _vm.$parent) {
  2381. instances.push(_vm.$parent);
  2382. return getParent(_vm.$parent)
  2383. }
  2384. return _vm
  2385. }
  2386. getParent(childVm);
  2387. return instances
  2388. }
  2389. function findAllInstances(rootVm) {
  2390. var instances = [rootVm];
  2391. var i = 0;
  2392. while (i < instances.length) {
  2393. var vm = instances[i]
  2394. ;(vm.$children || []).forEach(function (child) {
  2395. instances.push(child);
  2396. });
  2397. i++;
  2398. }
  2399. return instances
  2400. }
  2401. function findAllVNodes(vnode, selector) {
  2402. var matchingNodes = [];
  2403. var nodes = [vnode];
  2404. while (nodes.length) {
  2405. var node = nodes.shift();
  2406. if (node.children) {
  2407. var children = [].concat( node.children ).reverse();
  2408. children.forEach(function (n) {
  2409. nodes.unshift(n);
  2410. });
  2411. }
  2412. if (node.child) {
  2413. nodes.unshift(node.child._vnode);
  2414. }
  2415. if (matches(node, selector)) {
  2416. matchingNodes.push(node);
  2417. }
  2418. }
  2419. return matchingNodes
  2420. }
  2421. function removeDuplicateNodes(vNodes) {
  2422. var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
  2423. return vNodes.filter(function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); })
  2424. }
  2425. function find(
  2426. root,
  2427. vm,
  2428. selector
  2429. ) {
  2430. if (root instanceof Element && selector.type !== DOM_SELECTOR) {
  2431. throwError(
  2432. "cannot find a Vue instance on a DOM node. The node " +
  2433. "you are calling find on does not exist in the " +
  2434. "VDom. Are you adding the node as innerHTML?"
  2435. );
  2436. }
  2437. if (
  2438. selector.type === COMPONENT_SELECTOR &&
  2439. (selector.value.functional ||
  2440. (selector.value.options && selector.value.options.functional)) &&
  2441. VUE_VERSION < 2.3
  2442. ) {
  2443. throwError(
  2444. "find for functional components is not supported " + "in Vue < 2.3"
  2445. );
  2446. }
  2447. if (root instanceof Element) {
  2448. return findDOMNodes(root, selector.value)
  2449. }
  2450. if (!root && selector.type !== DOM_SELECTOR) {
  2451. throwError(
  2452. "cannot find a Vue instance on a DOM node. The node " +
  2453. "you are calling find on does not exist in the " +
  2454. "VDom. Are you adding the node as innerHTML?"
  2455. );
  2456. }
  2457. if (!vm && selector.type === REF_SELECTOR) {
  2458. throwError("$ref selectors can only be used on Vue component " + "wrappers");
  2459. }
  2460. if (vm && vm.$refs && selector.value.ref in vm.$refs) {
  2461. var refs = vm.$refs[selector.value.ref];
  2462. return Array.isArray(refs) ? refs : [refs]
  2463. }
  2464. var nodes = findAllVNodes(root, selector);
  2465. var dedupedNodes = removeDuplicateNodes(nodes);
  2466. if (nodes.length > 0 || selector.type !== DOM_SELECTOR) {
  2467. return dedupedNodes
  2468. }
  2469. // Fallback in case element exists in HTML, but not in vnode tree
  2470. // (e.g. if innerHTML is set as a domProp)
  2471. return findDOMNodes(root.elm, selector.value)
  2472. }
  2473. function errorHandler(errorOrString, vm, info) {
  2474. var error =
  2475. typeof errorOrString === 'object' ? errorOrString : new Error(errorOrString);
  2476. // If a user defined errorHandler was register via createLocalVue
  2477. // find and call the user defined errorHandler
  2478. var instancedErrorHandlers = findAllParentInstances(vm)
  2479. .filter(
  2480. function (_vm) { return _vm &&
  2481. _vm.$options &&
  2482. _vm.$options.localVue &&
  2483. _vm.$options.localVue.config &&
  2484. _vm.$options.localVue.config.errorHandler; }
  2485. )
  2486. .map(function (_vm) { return _vm.$options.localVue.config.errorHandler; });
  2487. if (vm) {
  2488. vm._error = error;
  2489. }
  2490. if (!instancedErrorHandlers.length) {
  2491. throw error
  2492. }
  2493. // should be one error handler, as only once can be registered with local vue
  2494. // regardless, if more exist (for whatever reason), invoke the other user defined error handlers
  2495. instancedErrorHandlers.forEach(function (instancedErrorHandler) {
  2496. instancedErrorHandler(error, vm, info);
  2497. });
  2498. }
  2499. function throwIfInstancesThrew(vm) {
  2500. var instancesWithError = findAllInstances(vm).filter(function (_vm) { return _vm._error; });
  2501. if (instancesWithError.length > 0) {
  2502. throw instancesWithError[0]._error
  2503. }
  2504. }
  2505. var hasWarned = false;
  2506. // Vue swallows errors thrown by instances, even if the global error handler
  2507. // throws. In order to throw in the test, we add an _error property to an
  2508. // instance when it throws. Then we loop through the instances with
  2509. // throwIfInstancesThrew and throw an error in the test context if any
  2510. // instances threw.
  2511. function addGlobalErrorHandler(_Vue) {
  2512. var existingErrorHandler = _Vue.config.errorHandler;
  2513. if (existingErrorHandler === errorHandler) {
  2514. return
  2515. }
  2516. if (_Vue.config.errorHandler && !hasWarned) {
  2517. warn(
  2518. "Global error handler detected (Vue.config.errorHandler). \n" +
  2519. "Vue Test Utils sets a custom error handler to throw errors " +
  2520. "thrown by instances. If you want this behavior in " +
  2521. "your tests, you must remove the global error handler."
  2522. );
  2523. hasWarned = true;
  2524. } else {
  2525. _Vue.config.errorHandler = errorHandler;
  2526. }
  2527. }
  2528. function normalizeStubs(stubs) {
  2529. if ( stubs === void 0 ) stubs = {};
  2530. if (stubs === false) {
  2531. return false
  2532. }
  2533. if (isPlainObject(stubs)) {
  2534. return stubs
  2535. }
  2536. if (Array.isArray(stubs)) {
  2537. return stubs.reduce(function (acc, stub) {
  2538. if (typeof stub !== 'string') {
  2539. throwError('each item in an options.stubs array must be a string');
  2540. }
  2541. acc[stub] = true;
  2542. return acc
  2543. }, {})
  2544. }
  2545. throwError('options.stubs must be an object or an Array');
  2546. }
  2547. function normalizeProvide(provide) {
  2548. // Objects are not resolved in extended components in Vue < 2.5
  2549. // https://github.com/vuejs/vue/issues/6436
  2550. if (typeof provide === 'object' && VUE_VERSION < 2.5) {
  2551. var obj = Object.assign({}, provide);
  2552. return function () { return obj; }
  2553. }
  2554. return provide
  2555. }
  2556. //
  2557. function getOption(option, config) {
  2558. if (option === false) {
  2559. return false
  2560. }
  2561. if (option || (config && Object.keys(config).length > 0)) {
  2562. if (option instanceof Function) {
  2563. return option
  2564. }
  2565. if (config instanceof Function) {
  2566. throw new Error("Config can't be a Function.")
  2567. }
  2568. return Object.assign({}, config,
  2569. option)
  2570. }
  2571. }
  2572. function getStubs(stubs, configStubs) {
  2573. var normalizedStubs = normalizeStubs(stubs);
  2574. var normalizedConfigStubs = normalizeStubs(configStubs);
  2575. return getOption(normalizedStubs, normalizedConfigStubs)
  2576. }
  2577. function mergeOptions(
  2578. options,
  2579. config
  2580. ) {
  2581. var mocks = (getOption(options.mocks, config.mocks));
  2582. var methods = (getOption(options.methods, config.methods));
  2583. if (methods && Object.keys(methods).length) {
  2584. warnDeprecated(
  2585. 'overwriting methods via the `methods` property',
  2586. 'There is no clear migration path for the `methods` property - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests'
  2587. );
  2588. }
  2589. var provide = (getOption(options.provide, config.provide));
  2590. var stubs = (getStubs(options.stubs, config.stubs));
  2591. // $FlowIgnore
  2592. return Object.assign({}, options,
  2593. {provide: normalizeProvide(provide),
  2594. stubs: stubs,
  2595. mocks: mocks,
  2596. methods: methods})
  2597. }
  2598. var config = {
  2599. stubs: {
  2600. transition: true,
  2601. 'transition-group': true
  2602. },
  2603. mocks: {},
  2604. methods: {},
  2605. provide: {},
  2606. showDeprecationWarnings:
  2607. true
  2608. };
  2609. //
  2610. function warnIfNoWindow() {
  2611. if (typeof window === 'undefined') {
  2612. throwError(
  2613. "window is undefined, vue-test-utils needs to be " +
  2614. "run in a browser environment. \n" +
  2615. "You can run the tests in node using jsdom \n" +
  2616. "See https://vue-test-utils.vuejs.org/guides/#browser-environment " +
  2617. "for more details."
  2618. );
  2619. }
  2620. }
  2621. function polyfill() {
  2622. // Polyfill `Element.matches()` for IE and older versions of Chrome:
  2623. // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
  2624. if (!Element.prototype.matches) {
  2625. Element.prototype.matches =
  2626. Element.prototype.msMatchesSelector ||
  2627. Element.prototype.webkitMatchesSelector;
  2628. }
  2629. }
  2630. /*jshint node:true */
  2631. function OutputLine(parent) {
  2632. this.__parent = parent;
  2633. this.__character_count = 0;
  2634. // use indent_count as a marker for this.__lines that have preserved indentation
  2635. this.__indent_count = -1;
  2636. this.__alignment_count = 0;
  2637. this.__wrap_point_index = 0;
  2638. this.__wrap_point_character_count = 0;
  2639. this.__wrap_point_indent_count = -1;
  2640. this.__wrap_point_alignment_count = 0;
  2641. this.__items = [];
  2642. }
  2643. OutputLine.prototype.clone_empty = function() {
  2644. var line = new OutputLine(this.__parent);
  2645. line.set_indent(this.__indent_count, this.__alignment_count);
  2646. return line;
  2647. };
  2648. OutputLine.prototype.item = function(index) {
  2649. if (index < 0) {
  2650. return this.__items[this.__items.length + index];
  2651. } else {
  2652. return this.__items[index];
  2653. }
  2654. };
  2655. OutputLine.prototype.has_match = function(pattern) {
  2656. for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
  2657. if (this.__items[lastCheckedOutput].match(pattern)) {
  2658. return true;
  2659. }
  2660. }
  2661. return false;
  2662. };
  2663. OutputLine.prototype.set_indent = function(indent, alignment) {
  2664. if (this.is_empty()) {
  2665. this.__indent_count = indent || 0;
  2666. this.__alignment_count = alignment || 0;
  2667. this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
  2668. }
  2669. };
  2670. OutputLine.prototype._set_wrap_point = function() {
  2671. if (this.__parent.wrap_line_length) {
  2672. this.__wrap_point_index = this.__items.length;
  2673. this.__wrap_point_character_count = this.__character_count;
  2674. this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
  2675. this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
  2676. }
  2677. };
  2678. OutputLine.prototype._should_wrap = function() {
  2679. return this.__wrap_point_index &&
  2680. this.__character_count > this.__parent.wrap_line_length &&
  2681. this.__wrap_point_character_count > this.__parent.next_line.__character_count;
  2682. };
  2683. OutputLine.prototype._allow_wrap = function() {
  2684. if (this._should_wrap()) {
  2685. this.__parent.add_new_line();
  2686. var next = this.__parent.current_line;
  2687. next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
  2688. next.__items = this.__items.slice(this.__wrap_point_index);
  2689. this.__items = this.__items.slice(0, this.__wrap_point_index);
  2690. next.__character_count += this.__character_count - this.__wrap_point_character_count;
  2691. this.__character_count = this.__wrap_point_character_count;
  2692. if (next.__items[0] === " ") {
  2693. next.__items.splice(0, 1);
  2694. next.__character_count -= 1;
  2695. }
  2696. return true;
  2697. }
  2698. return false;
  2699. };
  2700. OutputLine.prototype.is_empty = function() {
  2701. return this.__items.length === 0;
  2702. };
  2703. OutputLine.prototype.last = function() {
  2704. if (!this.is_empty()) {
  2705. return this.__items[this.__items.length - 1];
  2706. } else {
  2707. return null;
  2708. }
  2709. };
  2710. OutputLine.prototype.push = function(item) {
  2711. this.__items.push(item);
  2712. var last_newline_index = item.lastIndexOf('\n');
  2713. if (last_newline_index !== -1) {
  2714. this.__character_count = item.length - last_newline_index;
  2715. } else {
  2716. this.__character_count += item.length;
  2717. }
  2718. };
  2719. OutputLine.prototype.pop = function() {
  2720. var item = null;
  2721. if (!this.is_empty()) {
  2722. item = this.__items.pop();
  2723. this.__character_count -= item.length;
  2724. }
  2725. return item;
  2726. };
  2727. OutputLine.prototype._remove_indent = function() {
  2728. if (this.__indent_count > 0) {
  2729. this.__indent_count -= 1;
  2730. this.__character_count -= this.__parent.indent_size;
  2731. }
  2732. };
  2733. OutputLine.prototype._remove_wrap_indent = function() {
  2734. if (this.__wrap_point_indent_count > 0) {
  2735. this.__wrap_point_indent_count -= 1;
  2736. }
  2737. };
  2738. OutputLine.prototype.trim = function() {
  2739. while (this.last() === ' ') {
  2740. this.__items.pop();
  2741. this.__character_count -= 1;
  2742. }
  2743. };
  2744. OutputLine.prototype.toString = function() {
  2745. var result = '';
  2746. if (this.is_empty()) {
  2747. if (this.__parent.indent_empty_lines) {
  2748. result = this.__parent.get_indent_string(this.__indent_count);
  2749. }
  2750. } else {
  2751. result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
  2752. result += this.__items.join('');
  2753. }
  2754. return result;
  2755. };
  2756. function IndentStringCache(options, baseIndentString) {
  2757. this.__cache = [''];
  2758. this.__indent_size = options.indent_size;
  2759. this.__indent_string = options.indent_char;
  2760. if (!options.indent_with_tabs) {
  2761. this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
  2762. }
  2763. // Set to null to continue support for auto detection of base indent
  2764. baseIndentString = baseIndentString || '';
  2765. if (options.indent_level > 0) {
  2766. baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
  2767. }
  2768. this.__base_string = baseIndentString;
  2769. this.__base_string_length = baseIndentString.length;
  2770. }
  2771. IndentStringCache.prototype.get_indent_size = function(indent, column) {
  2772. var result = this.__base_string_length;
  2773. column = column || 0;
  2774. if (indent < 0) {
  2775. result = 0;
  2776. }
  2777. result += indent * this.__indent_size;
  2778. result += column;
  2779. return result;
  2780. };
  2781. IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
  2782. var result = this.__base_string;
  2783. column = column || 0;
  2784. if (indent_level < 0) {
  2785. indent_level = 0;
  2786. result = '';
  2787. }
  2788. column += indent_level * this.__indent_size;
  2789. this.__ensure_cache(column);
  2790. result += this.__cache[column];
  2791. return result;
  2792. };
  2793. IndentStringCache.prototype.__ensure_cache = function(column) {
  2794. while (column >= this.__cache.length) {
  2795. this.__add_column();
  2796. }
  2797. };
  2798. IndentStringCache.prototype.__add_column = function() {
  2799. var column = this.__cache.length;
  2800. var indent = 0;
  2801. var result = '';
  2802. if (this.__indent_size && column >= this.__indent_size) {
  2803. indent = Math.floor(column / this.__indent_size);
  2804. column -= indent * this.__indent_size;
  2805. result = new Array(indent + 1).join(this.__indent_string);
  2806. }
  2807. if (column) {
  2808. result += new Array(column + 1).join(' ');
  2809. }
  2810. this.__cache.push(result);
  2811. };
  2812. function Output(options, baseIndentString) {
  2813. this.__indent_cache = new IndentStringCache(options, baseIndentString);
  2814. this.raw = false;
  2815. this._end_with_newline = options.end_with_newline;
  2816. this.indent_size = options.indent_size;
  2817. this.wrap_line_length = options.wrap_line_length;
  2818. this.indent_empty_lines = options.indent_empty_lines;
  2819. this.__lines = [];
  2820. this.previous_line = null;
  2821. this.current_line = null;
  2822. this.next_line = new OutputLine(this);
  2823. this.space_before_token = false;
  2824. this.non_breaking_space = false;
  2825. this.previous_token_wrapped = false;
  2826. // initialize
  2827. this.__add_outputline();
  2828. }
  2829. Output.prototype.__add_outputline = function() {
  2830. this.previous_line = this.current_line;
  2831. this.current_line = this.next_line.clone_empty();
  2832. this.__lines.push(this.current_line);
  2833. };
  2834. Output.prototype.get_line_number = function() {
  2835. return this.__lines.length;
  2836. };
  2837. Output.prototype.get_indent_string = function(indent, column) {
  2838. return this.__indent_cache.get_indent_string(indent, column);
  2839. };
  2840. Output.prototype.get_indent_size = function(indent, column) {
  2841. return this.__indent_cache.get_indent_size(indent, column);
  2842. };
  2843. Output.prototype.is_empty = function() {
  2844. return !this.previous_line && this.current_line.is_empty();
  2845. };
  2846. Output.prototype.add_new_line = function(force_newline) {
  2847. // never newline at the start of file
  2848. // otherwise, newline only if we didn't just add one or we're forced
  2849. if (this.is_empty() ||
  2850. (!force_newline && this.just_added_newline())) {
  2851. return false;
  2852. }
  2853. // if raw output is enabled, don't print additional newlines,
  2854. // but still return True as though you had
  2855. if (!this.raw) {
  2856. this.__add_outputline();
  2857. }
  2858. return true;
  2859. };
  2860. Output.prototype.get_code = function(eol) {
  2861. this.trim(true);
  2862. // handle some edge cases where the last tokens
  2863. // has text that ends with newline(s)
  2864. var last_item = this.current_line.pop();
  2865. if (last_item) {
  2866. if (last_item[last_item.length - 1] === '\n') {
  2867. last_item = last_item.replace(/\n+$/g, '');
  2868. }
  2869. this.current_line.push(last_item);
  2870. }
  2871. if (this._end_with_newline) {
  2872. this.__add_outputline();
  2873. }
  2874. var sweet_code = this.__lines.join('\n');
  2875. if (eol !== '\n') {
  2876. sweet_code = sweet_code.replace(/[\n]/g, eol);
  2877. }
  2878. return sweet_code;
  2879. };
  2880. Output.prototype.set_wrap_point = function() {
  2881. this.current_line._set_wrap_point();
  2882. };
  2883. Output.prototype.set_indent = function(indent, alignment) {
  2884. indent = indent || 0;
  2885. alignment = alignment || 0;
  2886. // Next line stores alignment values
  2887. this.next_line.set_indent(indent, alignment);
  2888. // Never indent your first output indent at the start of the file
  2889. if (this.__lines.length > 1) {
  2890. this.current_line.set_indent(indent, alignment);
  2891. return true;
  2892. }
  2893. this.current_line.set_indent();
  2894. return false;
  2895. };
  2896. Output.prototype.add_raw_token = function(token) {
  2897. for (var x = 0; x < token.newlines; x++) {
  2898. this.__add_outputline();
  2899. }
  2900. this.current_line.set_indent(-1);
  2901. this.current_line.push(token.whitespace_before);
  2902. this.current_line.push(token.text);
  2903. this.space_before_token = false;
  2904. this.non_breaking_space = false;
  2905. this.previous_token_wrapped = false;
  2906. };
  2907. Output.prototype.add_token = function(printable_token) {
  2908. this.__add_space_before_token();
  2909. this.current_line.push(printable_token);
  2910. this.space_before_token = false;
  2911. this.non_breaking_space = false;
  2912. this.previous_token_wrapped = this.current_line._allow_wrap();
  2913. };
  2914. Output.prototype.__add_space_before_token = function() {
  2915. if (this.space_before_token && !this.just_added_newline()) {
  2916. if (!this.non_breaking_space) {
  2917. this.set_wrap_point();
  2918. }
  2919. this.current_line.push(' ');
  2920. }
  2921. };
  2922. Output.prototype.remove_indent = function(index) {
  2923. var output_length = this.__lines.length;
  2924. while (index < output_length) {
  2925. this.__lines[index]._remove_indent();
  2926. index++;
  2927. }
  2928. this.current_line._remove_wrap_indent();
  2929. };
  2930. Output.prototype.trim = function(eat_newlines) {
  2931. eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
  2932. this.current_line.trim();
  2933. while (eat_newlines && this.__lines.length > 1 &&
  2934. this.current_line.is_empty()) {
  2935. this.__lines.pop();
  2936. this.current_line = this.__lines[this.__lines.length - 1];
  2937. this.current_line.trim();
  2938. }
  2939. this.previous_line = this.__lines.length > 1 ?
  2940. this.__lines[this.__lines.length - 2] : null;
  2941. };
  2942. Output.prototype.just_added_newline = function() {
  2943. return this.current_line.is_empty();
  2944. };
  2945. Output.prototype.just_added_blankline = function() {
  2946. return this.is_empty() ||
  2947. (this.current_line.is_empty() && this.previous_line.is_empty());
  2948. };
  2949. Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
  2950. var index = this.__lines.length - 2;
  2951. while (index >= 0) {
  2952. var potentialEmptyLine = this.__lines[index];
  2953. if (potentialEmptyLine.is_empty()) {
  2954. break;
  2955. } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
  2956. potentialEmptyLine.item(-1) !== ends_with) {
  2957. this.__lines.splice(index + 1, 0, new OutputLine(this));
  2958. this.previous_line = this.__lines[this.__lines.length - 2];
  2959. break;
  2960. }
  2961. index--;
  2962. }
  2963. };
  2964. var Output_1 = Output;
  2965. var output = {
  2966. Output: Output_1
  2967. };
  2968. /*jshint node:true */
  2969. function Token(type, text, newlines, whitespace_before) {
  2970. this.type = type;
  2971. this.text = text;
  2972. // comments_before are
  2973. // comments that have a new line before them
  2974. // and may or may not have a newline after
  2975. // this is a set of comments before
  2976. this.comments_before = null; /* inline comment*/
  2977. // this.comments_after = new TokenStream(); // no new line before and newline after
  2978. this.newlines = newlines || 0;
  2979. this.whitespace_before = whitespace_before || '';
  2980. this.parent = null;
  2981. this.next = null;
  2982. this.previous = null;
  2983. this.opened = null;
  2984. this.closed = null;
  2985. this.directives = null;
  2986. }
  2987. var Token_1 = Token;
  2988. var token = {
  2989. Token: Token_1
  2990. };
  2991. var acorn = createCommonjsModule(function (module, exports) {
  2992. // acorn used char codes to squeeze the last bit of performance out
  2993. // Beautifier is okay without that, so we're using regex
  2994. // permit $ (36) and @ (64). @ is used in ES7 decorators.
  2995. // 65 through 91 are uppercase letters.
  2996. // permit _ (95).
  2997. // 97 through 123 are lowercase letters.
  2998. var baseASCIIidentifierStartChars = "\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
  2999. // inside an identifier @ is not allowed but 0-9 are.
  3000. var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
  3001. // Big ugly regular expressions that match characters in the
  3002. // whitespace, identifier, and identifier-start categories. These
  3003. // are only applied when a character is found to actually have a
  3004. // code point above 128.
  3005. var nonASCIIidentifierStartChars = "\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc";
  3006. var nonASCIIidentifierChars = "\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f";
  3007. //var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3008. //var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3009. var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
  3010. var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
  3011. exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
  3012. exports.identifierStart = new RegExp(identifierStart);
  3013. exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
  3014. // Whether a single character denotes a newline.
  3015. exports.newline = /[\n\r\u2028\u2029]/;
  3016. // Matches a whole line break (where CRLF is considered a single
  3017. // line break). Used to count lines.
  3018. // in javascript, these two differ
  3019. // in python they are the same, different methods are called on them
  3020. exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
  3021. exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
  3022. });
  3023. /*jshint node:true */
  3024. function Options(options, merge_child_field) {
  3025. this.raw_options = _mergeOpts(options, merge_child_field);
  3026. // Support passing the source text back with no change
  3027. this.disabled = this._get_boolean('disabled');
  3028. this.eol = this._get_characters('eol', 'auto');
  3029. this.end_with_newline = this._get_boolean('end_with_newline');
  3030. this.indent_size = this._get_number('indent_size', 4);
  3031. this.indent_char = this._get_characters('indent_char', ' ');
  3032. this.indent_level = this._get_number('indent_level');
  3033. this.preserve_newlines = this._get_boolean('preserve_newlines', true);
  3034. this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
  3035. if (!this.preserve_newlines) {
  3036. this.max_preserve_newlines = 0;
  3037. }
  3038. this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
  3039. if (this.indent_with_tabs) {
  3040. this.indent_char = '\t';
  3041. // indent_size behavior changed after 1.8.6
  3042. // It used to be that indent_size would be
  3043. // set to 1 for indent_with_tabs. That is no longer needed and
  3044. // actually doesn't make sense - why not use spaces? Further,
  3045. // that might produce unexpected behavior - tabs being used
  3046. // for single-column alignment. So, when indent_with_tabs is true
  3047. // and indent_size is 1, reset indent_size to 4.
  3048. if (this.indent_size === 1) {
  3049. this.indent_size = 4;
  3050. }
  3051. }
  3052. // Backwards compat with 1.3.x
  3053. this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
  3054. this.indent_empty_lines = this._get_boolean('indent_empty_lines');
  3055. // valid templating languages ['django', 'erb', 'handlebars', 'php']
  3056. // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
  3057. // other values ignored
  3058. this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
  3059. }
  3060. Options.prototype._get_array = function(name, default_value) {
  3061. var option_value = this.raw_options[name];
  3062. var result = default_value || [];
  3063. if (typeof option_value === 'object') {
  3064. if (option_value !== null && typeof option_value.concat === 'function') {
  3065. result = option_value.concat();
  3066. }
  3067. } else if (typeof option_value === 'string') {
  3068. result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
  3069. }
  3070. return result;
  3071. };
  3072. Options.prototype._get_boolean = function(name, default_value) {
  3073. var option_value = this.raw_options[name];
  3074. var result = option_value === undefined ? !!default_value : !!option_value;
  3075. return result;
  3076. };
  3077. Options.prototype._get_characters = function(name, default_value) {
  3078. var option_value = this.raw_options[name];
  3079. var result = default_value || '';
  3080. if (typeof option_value === 'string') {
  3081. result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
  3082. }
  3083. return result;
  3084. };
  3085. Options.prototype._get_number = function(name, default_value) {
  3086. var option_value = this.raw_options[name];
  3087. default_value = parseInt(default_value, 10);
  3088. if (isNaN(default_value)) {
  3089. default_value = 0;
  3090. }
  3091. var result = parseInt(option_value, 10);
  3092. if (isNaN(result)) {
  3093. result = default_value;
  3094. }
  3095. return result;
  3096. };
  3097. Options.prototype._get_selection = function(name, selection_list, default_value) {
  3098. var result = this._get_selection_list(name, selection_list, default_value);
  3099. if (result.length !== 1) {
  3100. throw new Error(
  3101. "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
  3102. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  3103. }
  3104. return result[0];
  3105. };
  3106. Options.prototype._get_selection_list = function(name, selection_list, default_value) {
  3107. if (!selection_list || selection_list.length === 0) {
  3108. throw new Error("Selection list cannot be empty.");
  3109. }
  3110. default_value = default_value || [selection_list[0]];
  3111. if (!this._is_valid_selection(default_value, selection_list)) {
  3112. throw new Error("Invalid Default Value!");
  3113. }
  3114. var result = this._get_array(name, default_value);
  3115. if (!this._is_valid_selection(result, selection_list)) {
  3116. throw new Error(
  3117. "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
  3118. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  3119. }
  3120. return result;
  3121. };
  3122. Options.prototype._is_valid_selection = function(result, selection_list) {
  3123. return result.length && selection_list.length &&
  3124. !result.some(function(item) { return selection_list.indexOf(item) === -1; });
  3125. };
  3126. // merges child options up with the parent options object
  3127. // Example: obj = {a: 1, b: {a: 2}}
  3128. // mergeOpts(obj, 'b')
  3129. //
  3130. // Returns: {a: 2}
  3131. function _mergeOpts(allOptions, childFieldName) {
  3132. var finalOpts = {};
  3133. allOptions = _normalizeOpts(allOptions);
  3134. var name;
  3135. for (name in allOptions) {
  3136. if (name !== childFieldName) {
  3137. finalOpts[name] = allOptions[name];
  3138. }
  3139. }
  3140. //merge in the per type settings for the childFieldName
  3141. if (childFieldName && allOptions[childFieldName]) {
  3142. for (name in allOptions[childFieldName]) {
  3143. finalOpts[name] = allOptions[childFieldName][name];
  3144. }
  3145. }
  3146. return finalOpts;
  3147. }
  3148. function _normalizeOpts(options) {
  3149. var convertedOpts = {};
  3150. var key;
  3151. for (key in options) {
  3152. var newKey = key.replace(/-/g, "_");
  3153. convertedOpts[newKey] = options[key];
  3154. }
  3155. return convertedOpts;
  3156. }
  3157. var Options_1 = Options;
  3158. var normalizeOpts = _normalizeOpts;
  3159. var mergeOpts = _mergeOpts;
  3160. var options = {
  3161. Options: Options_1,
  3162. normalizeOpts: normalizeOpts,
  3163. mergeOpts: mergeOpts
  3164. };
  3165. var BaseOptions = options.Options;
  3166. var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
  3167. function Options$1(options) {
  3168. BaseOptions.call(this, options, 'js');
  3169. // compatibility, re
  3170. var raw_brace_style = this.raw_options.brace_style || null;
  3171. if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
  3172. this.raw_options.brace_style = "expand";
  3173. } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
  3174. this.raw_options.brace_style = "collapse,preserve-inline";
  3175. } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
  3176. this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
  3177. // } else if (!raw_brace_style) { //Nothing exists to set it
  3178. // raw_brace_style = "collapse";
  3179. }
  3180. //preserve-inline in delimited string will trigger brace_preserve_inline, everything
  3181. //else is considered a brace_style and the last one only will have an effect
  3182. var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
  3183. this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
  3184. this.brace_style = "collapse";
  3185. for (var bs = 0; bs < brace_style_split.length; bs++) {
  3186. if (brace_style_split[bs] === "preserve-inline") {
  3187. this.brace_preserve_inline = true;
  3188. } else {
  3189. this.brace_style = brace_style_split[bs];
  3190. }
  3191. }
  3192. this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
  3193. this.break_chained_methods = this._get_boolean('break_chained_methods');
  3194. this.space_in_paren = this._get_boolean('space_in_paren');
  3195. this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
  3196. this.jslint_happy = this._get_boolean('jslint_happy');
  3197. this.space_after_anon_function = this._get_boolean('space_after_anon_function');
  3198. this.space_after_named_function = this._get_boolean('space_after_named_function');
  3199. this.keep_array_indentation = this._get_boolean('keep_array_indentation');
  3200. this.space_before_conditional = this._get_boolean('space_before_conditional', true);
  3201. this.unescape_strings = this._get_boolean('unescape_strings');
  3202. this.e4x = this._get_boolean('e4x');
  3203. this.comma_first = this._get_boolean('comma_first');
  3204. this.operator_position = this._get_selection('operator_position', validPositionValues);
  3205. // For testing of beautify preserve:start directive
  3206. this.test_output_raw = this._get_boolean('test_output_raw');
  3207. // force this._options.space_after_anon_function to true if this._options.jslint_happy
  3208. if (this.jslint_happy) {
  3209. this.space_after_anon_function = true;
  3210. }
  3211. }
  3212. Options$1.prototype = new BaseOptions();
  3213. var Options_1$1 = Options$1;
  3214. var options$1 = {
  3215. Options: Options_1$1
  3216. };
  3217. /*jshint node:true */
  3218. var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
  3219. function InputScanner(input_string) {
  3220. this.__input = input_string || '';
  3221. this.__input_length = this.__input.length;
  3222. this.__position = 0;
  3223. }
  3224. InputScanner.prototype.restart = function() {
  3225. this.__position = 0;
  3226. };
  3227. InputScanner.prototype.back = function() {
  3228. if (this.__position > 0) {
  3229. this.__position -= 1;
  3230. }
  3231. };
  3232. InputScanner.prototype.hasNext = function() {
  3233. return this.__position < this.__input_length;
  3234. };
  3235. InputScanner.prototype.next = function() {
  3236. var val = null;
  3237. if (this.hasNext()) {
  3238. val = this.__input.charAt(this.__position);
  3239. this.__position += 1;
  3240. }
  3241. return val;
  3242. };
  3243. InputScanner.prototype.peek = function(index) {
  3244. var val = null;
  3245. index = index || 0;
  3246. index += this.__position;
  3247. if (index >= 0 && index < this.__input_length) {
  3248. val = this.__input.charAt(index);
  3249. }
  3250. return val;
  3251. };
  3252. // This is a JavaScript only helper function (not in python)
  3253. // Javascript doesn't have a match method
  3254. // and not all implementation support "sticky" flag.
  3255. // If they do not support sticky then both this.match() and this.test() method
  3256. // must get the match and check the index of the match.
  3257. // If sticky is supported and set, this method will use it.
  3258. // Otherwise it will check that global is set, and fall back to the slower method.
  3259. InputScanner.prototype.__match = function(pattern, index) {
  3260. pattern.lastIndex = index;
  3261. var pattern_match = pattern.exec(this.__input);
  3262. if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
  3263. if (pattern_match.index !== index) {
  3264. pattern_match = null;
  3265. }
  3266. }
  3267. return pattern_match;
  3268. };
  3269. InputScanner.prototype.test = function(pattern, index) {
  3270. index = index || 0;
  3271. index += this.__position;
  3272. if (index >= 0 && index < this.__input_length) {
  3273. return !!this.__match(pattern, index);
  3274. } else {
  3275. return false;
  3276. }
  3277. };
  3278. InputScanner.prototype.testChar = function(pattern, index) {
  3279. // test one character regex match
  3280. var val = this.peek(index);
  3281. pattern.lastIndex = 0;
  3282. return val !== null && pattern.test(val);
  3283. };
  3284. InputScanner.prototype.match = function(pattern) {
  3285. var pattern_match = this.__match(pattern, this.__position);
  3286. if (pattern_match) {
  3287. this.__position += pattern_match[0].length;
  3288. } else {
  3289. pattern_match = null;
  3290. }
  3291. return pattern_match;
  3292. };
  3293. InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
  3294. var val = '';
  3295. var match;
  3296. if (starting_pattern) {
  3297. match = this.match(starting_pattern);
  3298. if (match) {
  3299. val += match[0];
  3300. }
  3301. }
  3302. if (until_pattern && (match || !starting_pattern)) {
  3303. val += this.readUntil(until_pattern, until_after);
  3304. }
  3305. return val;
  3306. };
  3307. InputScanner.prototype.readUntil = function(pattern, until_after) {
  3308. var val = '';
  3309. var match_index = this.__position;
  3310. pattern.lastIndex = this.__position;
  3311. var pattern_match = pattern.exec(this.__input);
  3312. if (pattern_match) {
  3313. match_index = pattern_match.index;
  3314. if (until_after) {
  3315. match_index += pattern_match[0].length;
  3316. }
  3317. } else {
  3318. match_index = this.__input_length;
  3319. }
  3320. val = this.__input.substring(this.__position, match_index);
  3321. this.__position = match_index;
  3322. return val;
  3323. };
  3324. InputScanner.prototype.readUntilAfter = function(pattern) {
  3325. return this.readUntil(pattern, true);
  3326. };
  3327. InputScanner.prototype.get_regexp = function(pattern, match_from) {
  3328. var result = null;
  3329. var flags = 'g';
  3330. if (match_from && regexp_has_sticky) {
  3331. flags = 'y';
  3332. }
  3333. // strings are converted to regexp
  3334. if (typeof pattern === "string" && pattern !== '') {
  3335. // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
  3336. result = new RegExp(pattern, flags);
  3337. } else if (pattern) {
  3338. result = new RegExp(pattern.source, flags);
  3339. }
  3340. return result;
  3341. };
  3342. InputScanner.prototype.get_literal_regexp = function(literal_string) {
  3343. return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
  3344. };
  3345. /* css beautifier legacy helpers */
  3346. InputScanner.prototype.peekUntilAfter = function(pattern) {
  3347. var start = this.__position;
  3348. var val = this.readUntilAfter(pattern);
  3349. this.__position = start;
  3350. return val;
  3351. };
  3352. InputScanner.prototype.lookBack = function(testVal) {
  3353. var start = this.__position - 1;
  3354. return start >= testVal.length && this.__input.substring(start - testVal.length, start)
  3355. .toLowerCase() === testVal;
  3356. };
  3357. var InputScanner_1 = InputScanner;
  3358. var inputscanner = {
  3359. InputScanner: InputScanner_1
  3360. };
  3361. /*jshint node:true */
  3362. function TokenStream(parent_token) {
  3363. // private
  3364. this.__tokens = [];
  3365. this.__tokens_length = this.__tokens.length;
  3366. this.__position = 0;
  3367. this.__parent_token = parent_token;
  3368. }
  3369. TokenStream.prototype.restart = function() {
  3370. this.__position = 0;
  3371. };
  3372. TokenStream.prototype.isEmpty = function() {
  3373. return this.__tokens_length === 0;
  3374. };
  3375. TokenStream.prototype.hasNext = function() {
  3376. return this.__position < this.__tokens_length;
  3377. };
  3378. TokenStream.prototype.next = function() {
  3379. var val = null;
  3380. if (this.hasNext()) {
  3381. val = this.__tokens[this.__position];
  3382. this.__position += 1;
  3383. }
  3384. return val;
  3385. };
  3386. TokenStream.prototype.peek = function(index) {
  3387. var val = null;
  3388. index = index || 0;
  3389. index += this.__position;
  3390. if (index >= 0 && index < this.__tokens_length) {
  3391. val = this.__tokens[index];
  3392. }
  3393. return val;
  3394. };
  3395. TokenStream.prototype.add = function(token) {
  3396. if (this.__parent_token) {
  3397. token.parent = this.__parent_token;
  3398. }
  3399. this.__tokens.push(token);
  3400. this.__tokens_length += 1;
  3401. };
  3402. var TokenStream_1 = TokenStream;
  3403. var tokenstream = {
  3404. TokenStream: TokenStream_1
  3405. };
  3406. /*jshint node:true */
  3407. function Pattern(input_scanner, parent) {
  3408. this._input = input_scanner;
  3409. this._starting_pattern = null;
  3410. this._match_pattern = null;
  3411. this._until_pattern = null;
  3412. this._until_after = false;
  3413. if (parent) {
  3414. this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
  3415. this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
  3416. this._until_pattern = this._input.get_regexp(parent._until_pattern);
  3417. this._until_after = parent._until_after;
  3418. }
  3419. }
  3420. Pattern.prototype.read = function() {
  3421. var result = this._input.read(this._starting_pattern);
  3422. if (!this._starting_pattern || result) {
  3423. result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
  3424. }
  3425. return result;
  3426. };
  3427. Pattern.prototype.read_match = function() {
  3428. return this._input.match(this._match_pattern);
  3429. };
  3430. Pattern.prototype.until_after = function(pattern) {
  3431. var result = this._create();
  3432. result._until_after = true;
  3433. result._until_pattern = this._input.get_regexp(pattern);
  3434. result._update();
  3435. return result;
  3436. };
  3437. Pattern.prototype.until = function(pattern) {
  3438. var result = this._create();
  3439. result._until_after = false;
  3440. result._until_pattern = this._input.get_regexp(pattern);
  3441. result._update();
  3442. return result;
  3443. };
  3444. Pattern.prototype.starting_with = function(pattern) {
  3445. var result = this._create();
  3446. result._starting_pattern = this._input.get_regexp(pattern, true);
  3447. result._update();
  3448. return result;
  3449. };
  3450. Pattern.prototype.matching = function(pattern) {
  3451. var result = this._create();
  3452. result._match_pattern = this._input.get_regexp(pattern, true);
  3453. result._update();
  3454. return result;
  3455. };
  3456. Pattern.prototype._create = function() {
  3457. return new Pattern(this._input, this);
  3458. };
  3459. Pattern.prototype._update = function() {};
  3460. var Pattern_1 = Pattern;
  3461. var pattern = {
  3462. Pattern: Pattern_1
  3463. };
  3464. var Pattern$1 = pattern.Pattern;
  3465. function WhitespacePattern(input_scanner, parent) {
  3466. Pattern$1.call(this, input_scanner, parent);
  3467. if (parent) {
  3468. this._line_regexp = this._input.get_regexp(parent._line_regexp);
  3469. } else {
  3470. this.__set_whitespace_patterns('', '');
  3471. }
  3472. this.newline_count = 0;
  3473. this.whitespace_before_token = '';
  3474. }
  3475. WhitespacePattern.prototype = new Pattern$1();
  3476. WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
  3477. whitespace_chars += '\\t ';
  3478. newline_chars += '\\n\\r';
  3479. this._match_pattern = this._input.get_regexp(
  3480. '[' + whitespace_chars + newline_chars + ']+', true);
  3481. this._newline_regexp = this._input.get_regexp(
  3482. '\\r\\n|[' + newline_chars + ']');
  3483. };
  3484. WhitespacePattern.prototype.read = function() {
  3485. this.newline_count = 0;
  3486. this.whitespace_before_token = '';
  3487. var resulting_string = this._input.read(this._match_pattern);
  3488. if (resulting_string === ' ') {
  3489. this.whitespace_before_token = ' ';
  3490. } else if (resulting_string) {
  3491. var matches = this.__split(this._newline_regexp, resulting_string);
  3492. this.newline_count = matches.length - 1;
  3493. this.whitespace_before_token = matches[this.newline_count];
  3494. }
  3495. return resulting_string;
  3496. };
  3497. WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
  3498. var result = this._create();
  3499. result.__set_whitespace_patterns(whitespace_chars, newline_chars);
  3500. result._update();
  3501. return result;
  3502. };
  3503. WhitespacePattern.prototype._create = function() {
  3504. return new WhitespacePattern(this._input, this);
  3505. };
  3506. WhitespacePattern.prototype.__split = function(regexp, input_string) {
  3507. regexp.lastIndex = 0;
  3508. var start_index = 0;
  3509. var result = [];
  3510. var next_match = regexp.exec(input_string);
  3511. while (next_match) {
  3512. result.push(input_string.substring(start_index, next_match.index));
  3513. start_index = next_match.index + next_match[0].length;
  3514. next_match = regexp.exec(input_string);
  3515. }
  3516. if (start_index < input_string.length) {
  3517. result.push(input_string.substring(start_index, input_string.length));
  3518. } else {
  3519. result.push('');
  3520. }
  3521. return result;
  3522. };
  3523. var WhitespacePattern_1 = WhitespacePattern;
  3524. var whitespacepattern = {
  3525. WhitespacePattern: WhitespacePattern_1
  3526. };
  3527. var InputScanner$1 = inputscanner.InputScanner;
  3528. var Token$1 = token.Token;
  3529. var TokenStream$1 = tokenstream.TokenStream;
  3530. var WhitespacePattern$1 = whitespacepattern.WhitespacePattern;
  3531. var TOKEN = {
  3532. START: 'TK_START',
  3533. RAW: 'TK_RAW',
  3534. EOF: 'TK_EOF'
  3535. };
  3536. var Tokenizer = function(input_string, options) {
  3537. this._input = new InputScanner$1(input_string);
  3538. this._options = options || {};
  3539. this.__tokens = null;
  3540. this._patterns = {};
  3541. this._patterns.whitespace = new WhitespacePattern$1(this._input);
  3542. };
  3543. Tokenizer.prototype.tokenize = function() {
  3544. this._input.restart();
  3545. this.__tokens = new TokenStream$1();
  3546. this._reset();
  3547. var current;
  3548. var previous = new Token$1(TOKEN.START, '');
  3549. var open_token = null;
  3550. var open_stack = [];
  3551. var comments = new TokenStream$1();
  3552. while (previous.type !== TOKEN.EOF) {
  3553. current = this._get_next_token(previous, open_token);
  3554. while (this._is_comment(current)) {
  3555. comments.add(current);
  3556. current = this._get_next_token(previous, open_token);
  3557. }
  3558. if (!comments.isEmpty()) {
  3559. current.comments_before = comments;
  3560. comments = new TokenStream$1();
  3561. }
  3562. current.parent = open_token;
  3563. if (this._is_opening(current)) {
  3564. open_stack.push(open_token);
  3565. open_token = current;
  3566. } else if (open_token && this._is_closing(current, open_token)) {
  3567. current.opened = open_token;
  3568. open_token.closed = current;
  3569. open_token = open_stack.pop();
  3570. current.parent = open_token;
  3571. }
  3572. current.previous = previous;
  3573. previous.next = current;
  3574. this.__tokens.add(current);
  3575. previous = current;
  3576. }
  3577. return this.__tokens;
  3578. };
  3579. Tokenizer.prototype._is_first_token = function() {
  3580. return this.__tokens.isEmpty();
  3581. };
  3582. Tokenizer.prototype._reset = function() {};
  3583. Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  3584. this._readWhitespace();
  3585. var resulting_string = this._input.read(/.+/g);
  3586. if (resulting_string) {
  3587. return this._create_token(TOKEN.RAW, resulting_string);
  3588. } else {
  3589. return this._create_token(TOKEN.EOF, '');
  3590. }
  3591. };
  3592. Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
  3593. return false;
  3594. };
  3595. Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
  3596. return false;
  3597. };
  3598. Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
  3599. return false;
  3600. };
  3601. Tokenizer.prototype._create_token = function(type, text) {
  3602. var token = new Token$1(type, text,
  3603. this._patterns.whitespace.newline_count,
  3604. this._patterns.whitespace.whitespace_before_token);
  3605. return token;
  3606. };
  3607. Tokenizer.prototype._readWhitespace = function() {
  3608. return this._patterns.whitespace.read();
  3609. };
  3610. var Tokenizer_1 = Tokenizer;
  3611. var TOKEN_1 = TOKEN;
  3612. var tokenizer = {
  3613. Tokenizer: Tokenizer_1,
  3614. TOKEN: TOKEN_1
  3615. };
  3616. /*jshint node:true */
  3617. function Directives(start_block_pattern, end_block_pattern) {
  3618. start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
  3619. end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
  3620. this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
  3621. this.__directive_pattern = / (\w+)[:](\w+)/g;
  3622. this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
  3623. }
  3624. Directives.prototype.get_directives = function(text) {
  3625. if (!text.match(this.__directives_block_pattern)) {
  3626. return null;
  3627. }
  3628. var directives = {};
  3629. this.__directive_pattern.lastIndex = 0;
  3630. var directive_match = this.__directive_pattern.exec(text);
  3631. while (directive_match) {
  3632. directives[directive_match[1]] = directive_match[2];
  3633. directive_match = this.__directive_pattern.exec(text);
  3634. }
  3635. return directives;
  3636. };
  3637. Directives.prototype.readIgnored = function(input) {
  3638. return input.readUntilAfter(this.__directives_end_ignore_pattern);
  3639. };
  3640. var Directives_1 = Directives;
  3641. var directives = {
  3642. Directives: Directives_1
  3643. };
  3644. var Pattern$2 = pattern.Pattern;
  3645. var template_names = {
  3646. django: false,
  3647. erb: false,
  3648. handlebars: false,
  3649. php: false
  3650. };
  3651. // This lets templates appear anywhere we would do a readUntil
  3652. // The cost is higher but it is pay to play.
  3653. function TemplatablePattern(input_scanner, parent) {
  3654. Pattern$2.call(this, input_scanner, parent);
  3655. this.__template_pattern = null;
  3656. this._disabled = Object.assign({}, template_names);
  3657. this._excluded = Object.assign({}, template_names);
  3658. if (parent) {
  3659. this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
  3660. this._excluded = Object.assign(this._excluded, parent._excluded);
  3661. this._disabled = Object.assign(this._disabled, parent._disabled);
  3662. }
  3663. var pattern = new Pattern$2(input_scanner);
  3664. this.__patterns = {
  3665. handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
  3666. handlebars: pattern.starting_with(/{{/).until_after(/}}/),
  3667. php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
  3668. erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
  3669. // django coflicts with handlebars a bit.
  3670. django: pattern.starting_with(/{%/).until_after(/%}/),
  3671. django_value: pattern.starting_with(/{{/).until_after(/}}/),
  3672. django_comment: pattern.starting_with(/{#/).until_after(/#}/)
  3673. };
  3674. }
  3675. TemplatablePattern.prototype = new Pattern$2();
  3676. TemplatablePattern.prototype._create = function() {
  3677. return new TemplatablePattern(this._input, this);
  3678. };
  3679. TemplatablePattern.prototype._update = function() {
  3680. this.__set_templated_pattern();
  3681. };
  3682. TemplatablePattern.prototype.disable = function(language) {
  3683. var result = this._create();
  3684. result._disabled[language] = true;
  3685. result._update();
  3686. return result;
  3687. };
  3688. TemplatablePattern.prototype.read_options = function(options) {
  3689. var result = this._create();
  3690. for (var language in template_names) {
  3691. result._disabled[language] = options.templating.indexOf(language) === -1;
  3692. }
  3693. result._update();
  3694. return result;
  3695. };
  3696. TemplatablePattern.prototype.exclude = function(language) {
  3697. var result = this._create();
  3698. result._excluded[language] = true;
  3699. result._update();
  3700. return result;
  3701. };
  3702. TemplatablePattern.prototype.read = function() {
  3703. var result = '';
  3704. if (this._match_pattern) {
  3705. result = this._input.read(this._starting_pattern);
  3706. } else {
  3707. result = this._input.read(this._starting_pattern, this.__template_pattern);
  3708. }
  3709. var next = this._read_template();
  3710. while (next) {
  3711. if (this._match_pattern) {
  3712. next += this._input.read(this._match_pattern);
  3713. } else {
  3714. next += this._input.readUntil(this.__template_pattern);
  3715. }
  3716. result += next;
  3717. next = this._read_template();
  3718. }
  3719. if (this._until_after) {
  3720. result += this._input.readUntilAfter(this._until_pattern);
  3721. }
  3722. return result;
  3723. };
  3724. TemplatablePattern.prototype.__set_templated_pattern = function() {
  3725. var items = [];
  3726. if (!this._disabled.php) {
  3727. items.push(this.__patterns.php._starting_pattern.source);
  3728. }
  3729. if (!this._disabled.handlebars) {
  3730. items.push(this.__patterns.handlebars._starting_pattern.source);
  3731. }
  3732. if (!this._disabled.erb) {
  3733. items.push(this.__patterns.erb._starting_pattern.source);
  3734. }
  3735. if (!this._disabled.django) {
  3736. items.push(this.__patterns.django._starting_pattern.source);
  3737. items.push(this.__patterns.django_value._starting_pattern.source);
  3738. items.push(this.__patterns.django_comment._starting_pattern.source);
  3739. }
  3740. if (this._until_pattern) {
  3741. items.push(this._until_pattern.source);
  3742. }
  3743. this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
  3744. };
  3745. TemplatablePattern.prototype._read_template = function() {
  3746. var resulting_string = '';
  3747. var c = this._input.peek();
  3748. if (c === '<') {
  3749. var peek1 = this._input.peek(1);
  3750. //if we're in a comment, do something special
  3751. // We treat all comments as literals, even more than preformatted tags
  3752. // we just look for the appropriate close tag
  3753. if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
  3754. resulting_string = resulting_string ||
  3755. this.__patterns.php.read();
  3756. }
  3757. if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
  3758. resulting_string = resulting_string ||
  3759. this.__patterns.erb.read();
  3760. }
  3761. } else if (c === '{') {
  3762. if (!this._disabled.handlebars && !this._excluded.handlebars) {
  3763. resulting_string = resulting_string ||
  3764. this.__patterns.handlebars_comment.read();
  3765. resulting_string = resulting_string ||
  3766. this.__patterns.handlebars.read();
  3767. }
  3768. if (!this._disabled.django) {
  3769. // django coflicts with handlebars a bit.
  3770. if (!this._excluded.django && !this._excluded.handlebars) {
  3771. resulting_string = resulting_string ||
  3772. this.__patterns.django_value.read();
  3773. }
  3774. if (!this._excluded.django) {
  3775. resulting_string = resulting_string ||
  3776. this.__patterns.django_comment.read();
  3777. resulting_string = resulting_string ||
  3778. this.__patterns.django.read();
  3779. }
  3780. }
  3781. }
  3782. return resulting_string;
  3783. };
  3784. var TemplatablePattern_1 = TemplatablePattern;
  3785. var templatablepattern = {
  3786. TemplatablePattern: TemplatablePattern_1
  3787. };
  3788. var InputScanner$2 = inputscanner.InputScanner;
  3789. var BaseTokenizer = tokenizer.Tokenizer;
  3790. var BASETOKEN = tokenizer.TOKEN;
  3791. var Directives$1 = directives.Directives;
  3792. var Pattern$3 = pattern.Pattern;
  3793. var TemplatablePattern$1 = templatablepattern.TemplatablePattern;
  3794. function in_array(what, arr) {
  3795. return arr.indexOf(what) !== -1;
  3796. }
  3797. var TOKEN$1 = {
  3798. START_EXPR: 'TK_START_EXPR',
  3799. END_EXPR: 'TK_END_EXPR',
  3800. START_BLOCK: 'TK_START_BLOCK',
  3801. END_BLOCK: 'TK_END_BLOCK',
  3802. WORD: 'TK_WORD',
  3803. RESERVED: 'TK_RESERVED',
  3804. SEMICOLON: 'TK_SEMICOLON',
  3805. STRING: 'TK_STRING',
  3806. EQUALS: 'TK_EQUALS',
  3807. OPERATOR: 'TK_OPERATOR',
  3808. COMMA: 'TK_COMMA',
  3809. BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
  3810. COMMENT: 'TK_COMMENT',
  3811. DOT: 'TK_DOT',
  3812. UNKNOWN: 'TK_UNKNOWN',
  3813. START: BASETOKEN.START,
  3814. RAW: BASETOKEN.RAW,
  3815. EOF: BASETOKEN.EOF
  3816. };
  3817. var directives_core = new Directives$1(/\/\*/, /\*\//);
  3818. var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/;
  3819. var digit = /[0-9]/;
  3820. // Dot "." must be distinguished from "..." and decimal
  3821. var dot_pattern = /[^\d\.]/;
  3822. var positionable_operators = (
  3823. ">>> === !== " +
  3824. "<< && >= ** != == <= >> || " +
  3825. "< / - + > : & % ? ^ | *").split(' ');
  3826. // IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
  3827. // Also, you must update possitionable operators separately from punct
  3828. var punct =
  3829. ">>>= " +
  3830. "... >>= <<= === >>> !== **= " +
  3831. "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
  3832. "= ! ? > < : / ^ - + * & % ~ |";
  3833. punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
  3834. punct = punct.replace(/ /g, '|');
  3835. var punct_pattern = new RegExp(punct);
  3836. // words which should always start on new line.
  3837. var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
  3838. var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']);
  3839. var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
  3840. // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
  3841. var in_html_comment;
  3842. var Tokenizer$1 = function(input_string, options) {
  3843. BaseTokenizer.call(this, input_string, options);
  3844. this._patterns.whitespace = this._patterns.whitespace.matching(
  3845. /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
  3846. /\u2028\u2029/.source);
  3847. var pattern_reader = new Pattern$3(this._input);
  3848. var templatable = new TemplatablePattern$1(this._input)
  3849. .read_options(this._options);
  3850. this.__patterns = {
  3851. template: templatable,
  3852. identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
  3853. number: pattern_reader.matching(number_pattern),
  3854. punct: pattern_reader.matching(punct_pattern),
  3855. // comment ends just before nearest linefeed or end of file
  3856. comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
  3857. // /* ... */ comment ends with nearest */ or end of file
  3858. block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
  3859. html_comment_start: pattern_reader.matching(/<!--/),
  3860. html_comment_end: pattern_reader.matching(/-->/),
  3861. include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
  3862. shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
  3863. xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/),
  3864. single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
  3865. double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
  3866. template_text: templatable.until(/[`\\$]/),
  3867. template_expression: templatable.until(/[`}\\]/)
  3868. };
  3869. };
  3870. Tokenizer$1.prototype = new BaseTokenizer();
  3871. Tokenizer$1.prototype._is_comment = function(current_token) {
  3872. return current_token.type === TOKEN$1.COMMENT || current_token.type === TOKEN$1.BLOCK_COMMENT || current_token.type === TOKEN$1.UNKNOWN;
  3873. };
  3874. Tokenizer$1.prototype._is_opening = function(current_token) {
  3875. return current_token.type === TOKEN$1.START_BLOCK || current_token.type === TOKEN$1.START_EXPR;
  3876. };
  3877. Tokenizer$1.prototype._is_closing = function(current_token, open_token) {
  3878. return (current_token.type === TOKEN$1.END_BLOCK || current_token.type === TOKEN$1.END_EXPR) &&
  3879. (open_token && (
  3880. (current_token.text === ']' && open_token.text === '[') ||
  3881. (current_token.text === ')' && open_token.text === '(') ||
  3882. (current_token.text === '}' && open_token.text === '{')));
  3883. };
  3884. Tokenizer$1.prototype._reset = function() {
  3885. in_html_comment = false;
  3886. };
  3887. Tokenizer$1.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  3888. var token = null;
  3889. this._readWhitespace();
  3890. var c = this._input.peek();
  3891. if (c === null) {
  3892. return this._create_token(TOKEN$1.EOF, '');
  3893. }
  3894. token = token || this._read_string(c);
  3895. token = token || this._read_word(previous_token);
  3896. token = token || this._read_singles(c);
  3897. token = token || this._read_comment(c);
  3898. token = token || this._read_regexp(c, previous_token);
  3899. token = token || this._read_xml(c, previous_token);
  3900. token = token || this._read_non_javascript(c);
  3901. token = token || this._read_punctuation();
  3902. token = token || this._create_token(TOKEN$1.UNKNOWN, this._input.next());
  3903. return token;
  3904. };
  3905. Tokenizer$1.prototype._read_word = function(previous_token) {
  3906. var resulting_string;
  3907. resulting_string = this.__patterns.identifier.read();
  3908. if (resulting_string !== '') {
  3909. resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
  3910. if (!(previous_token.type === TOKEN$1.DOT ||
  3911. (previous_token.type === TOKEN$1.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
  3912. reserved_word_pattern.test(resulting_string)) {
  3913. if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators
  3914. return this._create_token(TOKEN$1.OPERATOR, resulting_string);
  3915. }
  3916. return this._create_token(TOKEN$1.RESERVED, resulting_string);
  3917. }
  3918. return this._create_token(TOKEN$1.WORD, resulting_string);
  3919. }
  3920. resulting_string = this.__patterns.number.read();
  3921. if (resulting_string !== '') {
  3922. return this._create_token(TOKEN$1.WORD, resulting_string);
  3923. }
  3924. };
  3925. Tokenizer$1.prototype._read_singles = function(c) {
  3926. var token = null;
  3927. if (c === '(' || c === '[') {
  3928. token = this._create_token(TOKEN$1.START_EXPR, c);
  3929. } else if (c === ')' || c === ']') {
  3930. token = this._create_token(TOKEN$1.END_EXPR, c);
  3931. } else if (c === '{') {
  3932. token = this._create_token(TOKEN$1.START_BLOCK, c);
  3933. } else if (c === '}') {
  3934. token = this._create_token(TOKEN$1.END_BLOCK, c);
  3935. } else if (c === ';') {
  3936. token = this._create_token(TOKEN$1.SEMICOLON, c);
  3937. } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
  3938. token = this._create_token(TOKEN$1.DOT, c);
  3939. } else if (c === ',') {
  3940. token = this._create_token(TOKEN$1.COMMA, c);
  3941. }
  3942. if (token) {
  3943. this._input.next();
  3944. }
  3945. return token;
  3946. };
  3947. Tokenizer$1.prototype._read_punctuation = function() {
  3948. var resulting_string = this.__patterns.punct.read();
  3949. if (resulting_string !== '') {
  3950. if (resulting_string === '=') {
  3951. return this._create_token(TOKEN$1.EQUALS, resulting_string);
  3952. } else {
  3953. return this._create_token(TOKEN$1.OPERATOR, resulting_string);
  3954. }
  3955. }
  3956. };
  3957. Tokenizer$1.prototype._read_non_javascript = function(c) {
  3958. var resulting_string = '';
  3959. if (c === '#') {
  3960. if (this._is_first_token()) {
  3961. resulting_string = this.__patterns.shebang.read();
  3962. if (resulting_string) {
  3963. return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
  3964. }
  3965. }
  3966. // handles extendscript #includes
  3967. resulting_string = this.__patterns.include.read();
  3968. if (resulting_string) {
  3969. return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
  3970. }
  3971. c = this._input.next();
  3972. // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
  3973. var sharp = '#';
  3974. if (this._input.hasNext() && this._input.testChar(digit)) {
  3975. do {
  3976. c = this._input.next();
  3977. sharp += c;
  3978. } while (this._input.hasNext() && c !== '#' && c !== '=');
  3979. if (c === '#') ; else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
  3980. sharp += '[]';
  3981. this._input.next();
  3982. this._input.next();
  3983. } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
  3984. sharp += '{}';
  3985. this._input.next();
  3986. this._input.next();
  3987. }
  3988. return this._create_token(TOKEN$1.WORD, sharp);
  3989. }
  3990. this._input.back();
  3991. } else if (c === '<' && this._is_first_token()) {
  3992. resulting_string = this.__patterns.html_comment_start.read();
  3993. if (resulting_string) {
  3994. while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
  3995. resulting_string += this._input.next();
  3996. }
  3997. in_html_comment = true;
  3998. return this._create_token(TOKEN$1.COMMENT, resulting_string);
  3999. }
  4000. } else if (in_html_comment && c === '-') {
  4001. resulting_string = this.__patterns.html_comment_end.read();
  4002. if (resulting_string) {
  4003. in_html_comment = false;
  4004. return this._create_token(TOKEN$1.COMMENT, resulting_string);
  4005. }
  4006. }
  4007. return null;
  4008. };
  4009. Tokenizer$1.prototype._read_comment = function(c) {
  4010. var token = null;
  4011. if (c === '/') {
  4012. var comment = '';
  4013. if (this._input.peek(1) === '*') {
  4014. // peek for comment /* ... */
  4015. comment = this.__patterns.block_comment.read();
  4016. var directives = directives_core.get_directives(comment);
  4017. if (directives && directives.ignore === 'start') {
  4018. comment += directives_core.readIgnored(this._input);
  4019. }
  4020. comment = comment.replace(acorn.allLineBreaks, '\n');
  4021. token = this._create_token(TOKEN$1.BLOCK_COMMENT, comment);
  4022. token.directives = directives;
  4023. } else if (this._input.peek(1) === '/') {
  4024. // peek for comment // ...
  4025. comment = this.__patterns.comment.read();
  4026. token = this._create_token(TOKEN$1.COMMENT, comment);
  4027. }
  4028. }
  4029. return token;
  4030. };
  4031. Tokenizer$1.prototype._read_string = function(c) {
  4032. if (c === '`' || c === "'" || c === '"') {
  4033. var resulting_string = this._input.next();
  4034. this.has_char_escapes = false;
  4035. if (c === '`') {
  4036. resulting_string += this._read_string_recursive('`', true, '${');
  4037. } else {
  4038. resulting_string += this._read_string_recursive(c);
  4039. }
  4040. if (this.has_char_escapes && this._options.unescape_strings) {
  4041. resulting_string = unescape_string(resulting_string);
  4042. }
  4043. if (this._input.peek() === c) {
  4044. resulting_string += this._input.next();
  4045. }
  4046. resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
  4047. return this._create_token(TOKEN$1.STRING, resulting_string);
  4048. }
  4049. return null;
  4050. };
  4051. Tokenizer$1.prototype._allow_regexp_or_xml = function(previous_token) {
  4052. // regex and xml can only appear in specific locations during parsing
  4053. return (previous_token.type === TOKEN$1.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
  4054. (previous_token.type === TOKEN$1.END_EXPR && previous_token.text === ')' &&
  4055. previous_token.opened.previous.type === TOKEN$1.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
  4056. (in_array(previous_token.type, [TOKEN$1.COMMENT, TOKEN$1.START_EXPR, TOKEN$1.START_BLOCK, TOKEN$1.START,
  4057. TOKEN$1.END_BLOCK, TOKEN$1.OPERATOR, TOKEN$1.EQUALS, TOKEN$1.EOF, TOKEN$1.SEMICOLON, TOKEN$1.COMMA
  4058. ]));
  4059. };
  4060. Tokenizer$1.prototype._read_regexp = function(c, previous_token) {
  4061. if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
  4062. // handle regexp
  4063. //
  4064. var resulting_string = this._input.next();
  4065. var esc = false;
  4066. var in_char_class = false;
  4067. while (this._input.hasNext() &&
  4068. ((esc || in_char_class || this._input.peek() !== c) &&
  4069. !this._input.testChar(acorn.newline))) {
  4070. resulting_string += this._input.peek();
  4071. if (!esc) {
  4072. esc = this._input.peek() === '\\';
  4073. if (this._input.peek() === '[') {
  4074. in_char_class = true;
  4075. } else if (this._input.peek() === ']') {
  4076. in_char_class = false;
  4077. }
  4078. } else {
  4079. esc = false;
  4080. }
  4081. this._input.next();
  4082. }
  4083. if (this._input.peek() === c) {
  4084. resulting_string += this._input.next();
  4085. // regexps may have modifiers /regexp/MOD , so fetch those, too
  4086. // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
  4087. resulting_string += this._input.read(acorn.identifier);
  4088. }
  4089. return this._create_token(TOKEN$1.STRING, resulting_string);
  4090. }
  4091. return null;
  4092. };
  4093. Tokenizer$1.prototype._read_xml = function(c, previous_token) {
  4094. if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
  4095. var xmlStr = '';
  4096. var match = this.__patterns.xml.read_match();
  4097. // handle e4x xml literals
  4098. //
  4099. if (match) {
  4100. // Trim root tag to attempt to
  4101. var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
  4102. var isCurlyRoot = rootTag.indexOf('{') === 0;
  4103. var depth = 0;
  4104. while (match) {
  4105. var isEndTag = !!match[1];
  4106. var tagName = match[2];
  4107. var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
  4108. if (!isSingletonTag &&
  4109. (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
  4110. if (isEndTag) {
  4111. --depth;
  4112. } else {
  4113. ++depth;
  4114. }
  4115. }
  4116. xmlStr += match[0];
  4117. if (depth <= 0) {
  4118. break;
  4119. }
  4120. match = this.__patterns.xml.read_match();
  4121. }
  4122. // if we didn't close correctly, keep unformatted.
  4123. if (!match) {
  4124. xmlStr += this._input.match(/[\s\S]*/g)[0];
  4125. }
  4126. xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
  4127. return this._create_token(TOKEN$1.STRING, xmlStr);
  4128. }
  4129. }
  4130. return null;
  4131. };
  4132. function unescape_string(s) {
  4133. // You think that a regex would work for this
  4134. // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
  4135. // return String.fromCharCode(parseInt(val, 16));
  4136. // })
  4137. // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
  4138. var out = '',
  4139. escaped = 0;
  4140. var input_scan = new InputScanner$2(s);
  4141. var matched = null;
  4142. while (input_scan.hasNext()) {
  4143. // Keep any whitespace, non-slash characters
  4144. // also keep slash pairs.
  4145. matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
  4146. if (matched) {
  4147. out += matched[0];
  4148. }
  4149. if (input_scan.peek() === '\\') {
  4150. input_scan.next();
  4151. if (input_scan.peek() === 'x') {
  4152. matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
  4153. } else if (input_scan.peek() === 'u') {
  4154. matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
  4155. } else {
  4156. out += '\\';
  4157. if (input_scan.hasNext()) {
  4158. out += input_scan.next();
  4159. }
  4160. continue;
  4161. }
  4162. // If there's some error decoding, return the original string
  4163. if (!matched) {
  4164. return s;
  4165. }
  4166. escaped = parseInt(matched[1], 16);
  4167. if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
  4168. // we bail out on \x7f..\xff,
  4169. // leaving whole string escaped,
  4170. // as it's probably completely binary
  4171. return s;
  4172. } else if (escaped >= 0x00 && escaped < 0x20) {
  4173. // leave 0x00...0x1f escaped
  4174. out += '\\' + matched[0];
  4175. continue;
  4176. } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
  4177. // single-quote, apostrophe, backslash - escape these
  4178. out += '\\' + String.fromCharCode(escaped);
  4179. } else {
  4180. out += String.fromCharCode(escaped);
  4181. }
  4182. }
  4183. }
  4184. return out;
  4185. }
  4186. // handle string
  4187. //
  4188. Tokenizer$1.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
  4189. var current_char;
  4190. var pattern;
  4191. if (delimiter === '\'') {
  4192. pattern = this.__patterns.single_quote;
  4193. } else if (delimiter === '"') {
  4194. pattern = this.__patterns.double_quote;
  4195. } else if (delimiter === '`') {
  4196. pattern = this.__patterns.template_text;
  4197. } else if (delimiter === '}') {
  4198. pattern = this.__patterns.template_expression;
  4199. }
  4200. var resulting_string = pattern.read();
  4201. var next = '';
  4202. while (this._input.hasNext()) {
  4203. next = this._input.next();
  4204. if (next === delimiter ||
  4205. (!allow_unescaped_newlines && acorn.newline.test(next))) {
  4206. this._input.back();
  4207. break;
  4208. } else if (next === '\\' && this._input.hasNext()) {
  4209. current_char = this._input.peek();
  4210. if (current_char === 'x' || current_char === 'u') {
  4211. this.has_char_escapes = true;
  4212. } else if (current_char === '\r' && this._input.peek(1) === '\n') {
  4213. this._input.next();
  4214. }
  4215. next += this._input.next();
  4216. } else if (start_sub) {
  4217. if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
  4218. next += this._input.next();
  4219. }
  4220. if (start_sub === next) {
  4221. if (delimiter === '`') {
  4222. next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
  4223. } else {
  4224. next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
  4225. }
  4226. if (this._input.hasNext()) {
  4227. next += this._input.next();
  4228. }
  4229. }
  4230. }
  4231. next += pattern.read();
  4232. resulting_string += next;
  4233. }
  4234. return resulting_string;
  4235. };
  4236. var Tokenizer_1$1 = Tokenizer$1;
  4237. var TOKEN_1$1 = TOKEN$1;
  4238. var positionable_operators_1 = positionable_operators.slice();
  4239. var line_starters_1 = line_starters.slice();
  4240. var tokenizer$1 = {
  4241. Tokenizer: Tokenizer_1$1,
  4242. TOKEN: TOKEN_1$1,
  4243. positionable_operators: positionable_operators_1,
  4244. line_starters: line_starters_1
  4245. };
  4246. var Output$1 = output.Output;
  4247. var Token$2 = token.Token;
  4248. var Options$2 = options$1.Options;
  4249. var Tokenizer$2 = tokenizer$1.Tokenizer;
  4250. var line_starters$1 = tokenizer$1.line_starters;
  4251. var positionable_operators$1 = tokenizer$1.positionable_operators;
  4252. var TOKEN$2 = tokenizer$1.TOKEN;
  4253. function in_array$1(what, arr) {
  4254. return arr.indexOf(what) !== -1;
  4255. }
  4256. function ltrim(s) {
  4257. return s.replace(/^\s+/g, '');
  4258. }
  4259. function generateMapFromStrings(list) {
  4260. var result = {};
  4261. for (var x = 0; x < list.length; x++) {
  4262. // make the mapped names underscored instead of dash
  4263. result[list[x].replace(/-/g, '_')] = list[x];
  4264. }
  4265. return result;
  4266. }
  4267. function reserved_word(token, word) {
  4268. return token && token.type === TOKEN$2.RESERVED && token.text === word;
  4269. }
  4270. function reserved_array(token, words) {
  4271. return token && token.type === TOKEN$2.RESERVED && in_array$1(token.text, words);
  4272. }
  4273. // Unsure of what they mean, but they work. Worth cleaning up in future.
  4274. var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
  4275. var validPositionValues$1 = ['before-newline', 'after-newline', 'preserve-newline'];
  4276. // Generate map from array
  4277. var OPERATOR_POSITION = generateMapFromStrings(validPositionValues$1);
  4278. var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
  4279. var MODE = {
  4280. BlockStatement: 'BlockStatement', // 'BLOCK'
  4281. Statement: 'Statement', // 'STATEMENT'
  4282. ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
  4283. ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
  4284. ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
  4285. Conditional: 'Conditional', //'(COND-EXPRESSION)',
  4286. Expression: 'Expression' //'(EXPRESSION)'
  4287. };
  4288. function remove_redundant_indentation(output, frame) {
  4289. // This implementation is effective but has some issues:
  4290. // - can cause line wrap to happen too soon due to indent removal
  4291. // after wrap points are calculated
  4292. // These issues are minor compared to ugly indentation.
  4293. if (frame.multiline_frame ||
  4294. frame.mode === MODE.ForInitializer ||
  4295. frame.mode === MODE.Conditional) {
  4296. return;
  4297. }
  4298. // remove one indent from each line inside this section
  4299. output.remove_indent(frame.start_line_index);
  4300. }
  4301. // we could use just string.split, but
  4302. // IE doesn't like returning empty strings
  4303. function split_linebreaks(s) {
  4304. //return s.split(/\x0d\x0a|\x0a/);
  4305. s = s.replace(acorn.allLineBreaks, '\n');
  4306. var out = [],
  4307. idx = s.indexOf("\n");
  4308. while (idx !== -1) {
  4309. out.push(s.substring(0, idx));
  4310. s = s.substring(idx + 1);
  4311. idx = s.indexOf("\n");
  4312. }
  4313. if (s.length) {
  4314. out.push(s);
  4315. }
  4316. return out;
  4317. }
  4318. function is_array(mode) {
  4319. return mode === MODE.ArrayLiteral;
  4320. }
  4321. function is_expression(mode) {
  4322. return in_array$1(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
  4323. }
  4324. function all_lines_start_with(lines, c) {
  4325. for (var i = 0; i < lines.length; i++) {
  4326. var line = lines[i].trim();
  4327. if (line.charAt(0) !== c) {
  4328. return false;
  4329. }
  4330. }
  4331. return true;
  4332. }
  4333. function each_line_matches_indent(lines, indent) {
  4334. var i = 0,
  4335. len = lines.length,
  4336. line;
  4337. for (; i < len; i++) {
  4338. line = lines[i];
  4339. // allow empty lines to pass through
  4340. if (line && line.indexOf(indent) !== 0) {
  4341. return false;
  4342. }
  4343. }
  4344. return true;
  4345. }
  4346. function Beautifier(source_text, options) {
  4347. options = options || {};
  4348. this._source_text = source_text || '';
  4349. this._output = null;
  4350. this._tokens = null;
  4351. this._last_last_text = null;
  4352. this._flags = null;
  4353. this._previous_flags = null;
  4354. this._flag_store = null;
  4355. this._options = new Options$2(options);
  4356. }
  4357. Beautifier.prototype.create_flags = function(flags_base, mode) {
  4358. var next_indent_level = 0;
  4359. if (flags_base) {
  4360. next_indent_level = flags_base.indentation_level;
  4361. if (!this._output.just_added_newline() &&
  4362. flags_base.line_indent_level > next_indent_level) {
  4363. next_indent_level = flags_base.line_indent_level;
  4364. }
  4365. }
  4366. var next_flags = {
  4367. mode: mode,
  4368. parent: flags_base,
  4369. last_token: flags_base ? flags_base.last_token : new Token$2(TOKEN$2.START_BLOCK, ''), // last token text
  4370. last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
  4371. declaration_statement: false,
  4372. declaration_assignment: false,
  4373. multiline_frame: false,
  4374. inline_frame: false,
  4375. if_block: false,
  4376. else_block: false,
  4377. do_block: false,
  4378. do_while: false,
  4379. import_block: false,
  4380. in_case_statement: false, // switch(..){ INSIDE HERE }
  4381. in_case: false, // we're on the exact line with "case 0:"
  4382. case_body: false, // the indented case-action block
  4383. indentation_level: next_indent_level,
  4384. alignment: 0,
  4385. line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
  4386. start_line_index: this._output.get_line_number(),
  4387. ternary_depth: 0
  4388. };
  4389. return next_flags;
  4390. };
  4391. Beautifier.prototype._reset = function(source_text) {
  4392. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  4393. this._last_last_text = ''; // pre-last token text
  4394. this._output = new Output$1(this._options, baseIndentString);
  4395. // If testing the ignore directive, start with output disable set to true
  4396. this._output.raw = this._options.test_output_raw;
  4397. // Stack of parsing/formatting states, including MODE.
  4398. // We tokenize, parse, and output in an almost purely a forward-only stream of token input
  4399. // and formatted output. This makes the beautifier less accurate than full parsers
  4400. // but also far more tolerant of syntax errors.
  4401. //
  4402. // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
  4403. // MODE.BlockStatement on the the stack, even though it could be object literal. If we later
  4404. // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
  4405. // most full parsers would die, but the beautifier gracefully falls back to
  4406. // MODE.BlockStatement and continues on.
  4407. this._flag_store = [];
  4408. this.set_mode(MODE.BlockStatement);
  4409. var tokenizer = new Tokenizer$2(source_text, this._options);
  4410. this._tokens = tokenizer.tokenize();
  4411. return source_text;
  4412. };
  4413. Beautifier.prototype.beautify = function() {
  4414. // if disabled, return the input unchanged.
  4415. if (this._options.disabled) {
  4416. return this._source_text;
  4417. }
  4418. var sweet_code;
  4419. var source_text = this._reset(this._source_text);
  4420. var eol = this._options.eol;
  4421. if (this._options.eol === 'auto') {
  4422. eol = '\n';
  4423. if (source_text && acorn.lineBreak.test(source_text || '')) {
  4424. eol = source_text.match(acorn.lineBreak)[0];
  4425. }
  4426. }
  4427. var current_token = this._tokens.next();
  4428. while (current_token) {
  4429. this.handle_token(current_token);
  4430. this._last_last_text = this._flags.last_token.text;
  4431. this._flags.last_token = current_token;
  4432. current_token = this._tokens.next();
  4433. }
  4434. sweet_code = this._output.get_code(eol);
  4435. return sweet_code;
  4436. };
  4437. Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
  4438. if (current_token.type === TOKEN$2.START_EXPR) {
  4439. this.handle_start_expr(current_token);
  4440. } else if (current_token.type === TOKEN$2.END_EXPR) {
  4441. this.handle_end_expr(current_token);
  4442. } else if (current_token.type === TOKEN$2.START_BLOCK) {
  4443. this.handle_start_block(current_token);
  4444. } else if (current_token.type === TOKEN$2.END_BLOCK) {
  4445. this.handle_end_block(current_token);
  4446. } else if (current_token.type === TOKEN$2.WORD) {
  4447. this.handle_word(current_token);
  4448. } else if (current_token.type === TOKEN$2.RESERVED) {
  4449. this.handle_word(current_token);
  4450. } else if (current_token.type === TOKEN$2.SEMICOLON) {
  4451. this.handle_semicolon(current_token);
  4452. } else if (current_token.type === TOKEN$2.STRING) {
  4453. this.handle_string(current_token);
  4454. } else if (current_token.type === TOKEN$2.EQUALS) {
  4455. this.handle_equals(current_token);
  4456. } else if (current_token.type === TOKEN$2.OPERATOR) {
  4457. this.handle_operator(current_token);
  4458. } else if (current_token.type === TOKEN$2.COMMA) {
  4459. this.handle_comma(current_token);
  4460. } else if (current_token.type === TOKEN$2.BLOCK_COMMENT) {
  4461. this.handle_block_comment(current_token, preserve_statement_flags);
  4462. } else if (current_token.type === TOKEN$2.COMMENT) {
  4463. this.handle_comment(current_token, preserve_statement_flags);
  4464. } else if (current_token.type === TOKEN$2.DOT) {
  4465. this.handle_dot(current_token);
  4466. } else if (current_token.type === TOKEN$2.EOF) {
  4467. this.handle_eof(current_token);
  4468. } else if (current_token.type === TOKEN$2.UNKNOWN) {
  4469. this.handle_unknown(current_token, preserve_statement_flags);
  4470. } else {
  4471. this.handle_unknown(current_token, preserve_statement_flags);
  4472. }
  4473. };
  4474. Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
  4475. var newlines = current_token.newlines;
  4476. var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
  4477. if (current_token.comments_before) {
  4478. var comment_token = current_token.comments_before.next();
  4479. while (comment_token) {
  4480. // The cleanest handling of inline comments is to treat them as though they aren't there.
  4481. // Just continue formatting and the behavior should be logical.
  4482. // Also ignore unknown tokens. Again, this should result in better behavior.
  4483. this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
  4484. this.handle_token(comment_token, preserve_statement_flags);
  4485. comment_token = current_token.comments_before.next();
  4486. }
  4487. }
  4488. if (keep_whitespace) {
  4489. for (var i = 0; i < newlines; i += 1) {
  4490. this.print_newline(i > 0, preserve_statement_flags);
  4491. }
  4492. } else {
  4493. if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
  4494. newlines = this._options.max_preserve_newlines;
  4495. }
  4496. if (this._options.preserve_newlines) {
  4497. if (newlines > 1) {
  4498. this.print_newline(false, preserve_statement_flags);
  4499. for (var j = 1; j < newlines; j += 1) {
  4500. this.print_newline(true, preserve_statement_flags);
  4501. }
  4502. }
  4503. }
  4504. }
  4505. };
  4506. var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
  4507. Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
  4508. force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
  4509. // Never wrap the first token on a line
  4510. if (this._output.just_added_newline()) {
  4511. return;
  4512. }
  4513. var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
  4514. var operatorLogicApplies = in_array$1(this._flags.last_token.text, positionable_operators$1) ||
  4515. in_array$1(current_token.text, positionable_operators$1);
  4516. if (operatorLogicApplies) {
  4517. var shouldPrintOperatorNewline = (
  4518. in_array$1(this._flags.last_token.text, positionable_operators$1) &&
  4519. in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
  4520. ) ||
  4521. in_array$1(current_token.text, positionable_operators$1);
  4522. shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
  4523. }
  4524. if (shouldPreserveOrForce) {
  4525. this.print_newline(false, true);
  4526. } else if (this._options.wrap_line_length) {
  4527. if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
  4528. // These tokens should never have a newline inserted
  4529. // between them and the following expression.
  4530. return;
  4531. }
  4532. this._output.set_wrap_point();
  4533. }
  4534. };
  4535. Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
  4536. if (!preserve_statement_flags) {
  4537. if (this._flags.last_token.text !== ';' && this._flags.last_token.text !== ',' && this._flags.last_token.text !== '=' && (this._flags.last_token.type !== TOKEN$2.OPERATOR || this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) {
  4538. var next_token = this._tokens.peek();
  4539. while (this._flags.mode === MODE.Statement &&
  4540. !(this._flags.if_block && reserved_word(next_token, 'else')) &&
  4541. !this._flags.do_block) {
  4542. this.restore_mode();
  4543. }
  4544. }
  4545. }
  4546. if (this._output.add_new_line(force_newline)) {
  4547. this._flags.multiline_frame = true;
  4548. }
  4549. };
  4550. Beautifier.prototype.print_token_line_indentation = function(current_token) {
  4551. if (this._output.just_added_newline()) {
  4552. if (this._options.keep_array_indentation &&
  4553. current_token.newlines &&
  4554. (current_token.text === '[' || is_array(this._flags.mode))) {
  4555. this._output.current_line.set_indent(-1);
  4556. this._output.current_line.push(current_token.whitespace_before);
  4557. this._output.space_before_token = false;
  4558. } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
  4559. this._flags.line_indent_level = this._flags.indentation_level;
  4560. }
  4561. }
  4562. };
  4563. Beautifier.prototype.print_token = function(current_token) {
  4564. if (this._output.raw) {
  4565. this._output.add_raw_token(current_token);
  4566. return;
  4567. }
  4568. if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN$2.COMMA &&
  4569. this._output.just_added_newline()) {
  4570. if (this._output.previous_line.last() === ',') {
  4571. var popped = this._output.previous_line.pop();
  4572. // if the comma was already at the start of the line,
  4573. // pull back onto that line and reprint the indentation
  4574. if (this._output.previous_line.is_empty()) {
  4575. this._output.previous_line.push(popped);
  4576. this._output.trim(true);
  4577. this._output.current_line.pop();
  4578. this._output.trim();
  4579. }
  4580. // add the comma in front of the next token
  4581. this.print_token_line_indentation(current_token);
  4582. this._output.add_token(',');
  4583. this._output.space_before_token = true;
  4584. }
  4585. }
  4586. this.print_token_line_indentation(current_token);
  4587. this._output.non_breaking_space = true;
  4588. this._output.add_token(current_token.text);
  4589. if (this._output.previous_token_wrapped) {
  4590. this._flags.multiline_frame = true;
  4591. }
  4592. };
  4593. Beautifier.prototype.indent = function() {
  4594. this._flags.indentation_level += 1;
  4595. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4596. };
  4597. Beautifier.prototype.deindent = function() {
  4598. if (this._flags.indentation_level > 0 &&
  4599. ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
  4600. this._flags.indentation_level -= 1;
  4601. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4602. }
  4603. };
  4604. Beautifier.prototype.set_mode = function(mode) {
  4605. if (this._flags) {
  4606. this._flag_store.push(this._flags);
  4607. this._previous_flags = this._flags;
  4608. } else {
  4609. this._previous_flags = this.create_flags(null, mode);
  4610. }
  4611. this._flags = this.create_flags(this._previous_flags, mode);
  4612. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4613. };
  4614. Beautifier.prototype.restore_mode = function() {
  4615. if (this._flag_store.length > 0) {
  4616. this._previous_flags = this._flags;
  4617. this._flags = this._flag_store.pop();
  4618. if (this._previous_flags.mode === MODE.Statement) {
  4619. remove_redundant_indentation(this._output, this._previous_flags);
  4620. }
  4621. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4622. }
  4623. };
  4624. Beautifier.prototype.start_of_object_property = function() {
  4625. return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
  4626. (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
  4627. };
  4628. Beautifier.prototype.start_of_statement = function(current_token) {
  4629. var start = false;
  4630. start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD;
  4631. start = start || reserved_word(this._flags.last_token, 'do');
  4632. start = start || (!(this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement)) && reserved_array(this._flags.last_token, newline_restricted_tokens) && !current_token.newlines;
  4633. start = start || reserved_word(this._flags.last_token, 'else') &&
  4634. !(reserved_word(current_token, 'if') && !current_token.comments_before);
  4635. start = start || (this._flags.last_token.type === TOKEN$2.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
  4636. start = start || (this._flags.last_token.type === TOKEN$2.WORD && this._flags.mode === MODE.BlockStatement &&
  4637. !this._flags.in_case &&
  4638. !(current_token.text === '--' || current_token.text === '++') &&
  4639. this._last_last_text !== 'function' &&
  4640. current_token.type !== TOKEN$2.WORD && current_token.type !== TOKEN$2.RESERVED);
  4641. start = start || (this._flags.mode === MODE.ObjectLiteral && (
  4642. (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
  4643. if (start) {
  4644. this.set_mode(MODE.Statement);
  4645. this.indent();
  4646. this.handle_whitespace_and_comments(current_token, true);
  4647. // Issue #276:
  4648. // If starting a new statement with [if, for, while, do], push to a new line.
  4649. // if (a) if (b) if(c) d(); else e(); else f();
  4650. if (!this.start_of_object_property()) {
  4651. this.allow_wrap_or_preserved_newline(current_token,
  4652. reserved_array(current_token, ['do', 'for', 'if', 'while']));
  4653. }
  4654. return true;
  4655. }
  4656. return false;
  4657. };
  4658. Beautifier.prototype.handle_start_expr = function(current_token) {
  4659. // The conditional starts the statement if appropriate.
  4660. if (!this.start_of_statement(current_token)) {
  4661. this.handle_whitespace_and_comments(current_token);
  4662. }
  4663. var next_mode = MODE.Expression;
  4664. if (current_token.text === '[') {
  4665. if (this._flags.last_token.type === TOKEN$2.WORD || this._flags.last_token.text === ')') {
  4666. // this is array index specifier, break immediately
  4667. // a[x], fn()[x]
  4668. if (reserved_array(this._flags.last_token, line_starters$1)) {
  4669. this._output.space_before_token = true;
  4670. }
  4671. this.print_token(current_token);
  4672. this.set_mode(next_mode);
  4673. this.indent();
  4674. if (this._options.space_in_paren) {
  4675. this._output.space_before_token = true;
  4676. }
  4677. return;
  4678. }
  4679. next_mode = MODE.ArrayLiteral;
  4680. if (is_array(this._flags.mode)) {
  4681. if (this._flags.last_token.text === '[' ||
  4682. (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
  4683. // ], [ goes to new line
  4684. // }, [ goes to new line
  4685. if (!this._options.keep_array_indentation) {
  4686. this.print_newline();
  4687. }
  4688. }
  4689. }
  4690. if (!in_array$1(this._flags.last_token.type, [TOKEN$2.START_EXPR, TOKEN$2.END_EXPR, TOKEN$2.WORD, TOKEN$2.OPERATOR])) {
  4691. this._output.space_before_token = true;
  4692. }
  4693. } else {
  4694. if (this._flags.last_token.type === TOKEN$2.RESERVED) {
  4695. if (this._flags.last_token.text === 'for') {
  4696. this._output.space_before_token = this._options.space_before_conditional;
  4697. next_mode = MODE.ForInitializer;
  4698. } else if (in_array$1(this._flags.last_token.text, ['if', 'while'])) {
  4699. this._output.space_before_token = this._options.space_before_conditional;
  4700. next_mode = MODE.Conditional;
  4701. } else if (in_array$1(this._flags.last_word, ['await', 'async'])) {
  4702. // Should be a space between await and an IIFE, or async and an arrow function
  4703. this._output.space_before_token = true;
  4704. } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
  4705. this._output.space_before_token = false;
  4706. } else if (in_array$1(this._flags.last_token.text, line_starters$1) || this._flags.last_token.text === 'catch') {
  4707. this._output.space_before_token = true;
  4708. }
  4709. } else if (this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
  4710. // Support of this kind of newline preservation.
  4711. // a = (b &&
  4712. // (c || d));
  4713. if (!this.start_of_object_property()) {
  4714. this.allow_wrap_or_preserved_newline(current_token);
  4715. }
  4716. } else if (this._flags.last_token.type === TOKEN$2.WORD) {
  4717. this._output.space_before_token = false;
  4718. // function name() vs function name ()
  4719. // function* name() vs function* name ()
  4720. // async name() vs async name ()
  4721. // In ES6, you can also define the method properties of an object
  4722. // var obj = {a: function() {}}
  4723. // It can be abbreviated
  4724. // var obj = {a() {}}
  4725. // var obj = { a() {}} vs var obj = { a () {}}
  4726. // var obj = { * a() {}} vs var obj = { * a () {}}
  4727. var peek_back_two = this._tokens.peek(-3);
  4728. if (this._options.space_after_named_function && peek_back_two) {
  4729. // peek starts at next character so -1 is current token
  4730. var peek_back_three = this._tokens.peek(-4);
  4731. if (reserved_array(peek_back_two, ['async', 'function']) ||
  4732. (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
  4733. this._output.space_before_token = true;
  4734. } else if (this._flags.mode === MODE.ObjectLiteral) {
  4735. if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
  4736. (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
  4737. this._output.space_before_token = true;
  4738. }
  4739. }
  4740. }
  4741. } else {
  4742. // Support preserving wrapped arrow function expressions
  4743. // a.b('c',
  4744. // () => d.e
  4745. // )
  4746. this.allow_wrap_or_preserved_newline(current_token);
  4747. }
  4748. // function() vs function ()
  4749. // yield*() vs yield* ()
  4750. // function*() vs function* ()
  4751. if ((this._flags.last_token.type === TOKEN$2.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
  4752. (this._flags.last_token.text === '*' &&
  4753. (in_array$1(this._last_last_text, ['function', 'yield']) ||
  4754. (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
  4755. this._output.space_before_token = this._options.space_after_anon_function;
  4756. }
  4757. }
  4758. if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN$2.START_BLOCK) {
  4759. this.print_newline();
  4760. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.END_BLOCK || this._flags.last_token.text === '.' || this._flags.last_token.type === TOKEN$2.COMMA) {
  4761. // do nothing on (( and )( and ][ and ]( and .(
  4762. // TODO: Consider whether forcing this is required. Review failing tests when removed.
  4763. this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
  4764. }
  4765. this.print_token(current_token);
  4766. this.set_mode(next_mode);
  4767. if (this._options.space_in_paren) {
  4768. this._output.space_before_token = true;
  4769. }
  4770. // In all cases, if we newline while inside an expression it should be indented.
  4771. this.indent();
  4772. };
  4773. Beautifier.prototype.handle_end_expr = function(current_token) {
  4774. // statements inside expressions are not valid syntax, but...
  4775. // statements must all be closed when their container closes
  4776. while (this._flags.mode === MODE.Statement) {
  4777. this.restore_mode();
  4778. }
  4779. this.handle_whitespace_and_comments(current_token);
  4780. if (this._flags.multiline_frame) {
  4781. this.allow_wrap_or_preserved_newline(current_token,
  4782. current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
  4783. }
  4784. if (this._options.space_in_paren) {
  4785. if (this._flags.last_token.type === TOKEN$2.START_EXPR && !this._options.space_in_empty_paren) {
  4786. // () [] no inner space in empty parens like these, ever, ref #320
  4787. this._output.trim();
  4788. this._output.space_before_token = false;
  4789. } else {
  4790. this._output.space_before_token = true;
  4791. }
  4792. }
  4793. this.deindent();
  4794. this.print_token(current_token);
  4795. this.restore_mode();
  4796. remove_redundant_indentation(this._output, this._previous_flags);
  4797. // do {} while () // no statement required after
  4798. if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
  4799. this._previous_flags.mode = MODE.Expression;
  4800. this._flags.do_block = false;
  4801. this._flags.do_while = false;
  4802. }
  4803. };
  4804. Beautifier.prototype.handle_start_block = function(current_token) {
  4805. this.handle_whitespace_and_comments(current_token);
  4806. // Check if this is should be treated as a ObjectLiteral
  4807. var next_token = this._tokens.peek();
  4808. var second_token = this._tokens.peek(1);
  4809. if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN$2.END_EXPR) {
  4810. this.set_mode(MODE.BlockStatement);
  4811. this._flags.in_case_statement = true;
  4812. } else if (this._flags.case_body) {
  4813. this.set_mode(MODE.BlockStatement);
  4814. } else if (second_token && (
  4815. (in_array$1(second_token.text, [':', ',']) && in_array$1(next_token.type, [TOKEN$2.STRING, TOKEN$2.WORD, TOKEN$2.RESERVED])) ||
  4816. (in_array$1(next_token.text, ['get', 'set', '...']) && in_array$1(second_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]))
  4817. )) {
  4818. // We don't support TypeScript,but we didn't break it for a very long time.
  4819. // We'll try to keep not breaking it.
  4820. if (!in_array$1(this._last_last_text, ['class', 'interface'])) {
  4821. this.set_mode(MODE.ObjectLiteral);
  4822. } else {
  4823. this.set_mode(MODE.BlockStatement);
  4824. }
  4825. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR && this._flags.last_token.text === '=>') {
  4826. // arrow function: (param1, paramN) => { statements }
  4827. this.set_mode(MODE.BlockStatement);
  4828. } else if (in_array$1(this._flags.last_token.type, [TOKEN$2.EQUALS, TOKEN$2.START_EXPR, TOKEN$2.COMMA, TOKEN$2.OPERATOR]) ||
  4829. reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
  4830. ) {
  4831. // Detecting shorthand function syntax is difficult by scanning forward,
  4832. // so check the surrounding context.
  4833. // If the block is being returned, imported, export default, passed as arg,
  4834. // assigned with = or assigned in a nested object, treat as an ObjectLiteral.
  4835. this.set_mode(MODE.ObjectLiteral);
  4836. } else {
  4837. this.set_mode(MODE.BlockStatement);
  4838. }
  4839. var empty_braces = !next_token.comments_before && next_token.text === '}';
  4840. var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
  4841. this._flags.last_token.type === TOKEN$2.END_EXPR;
  4842. if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
  4843. {
  4844. // search forward for a newline wanted inside this block
  4845. var index = 0;
  4846. var check_token = null;
  4847. this._flags.inline_frame = true;
  4848. do {
  4849. index += 1;
  4850. check_token = this._tokens.peek(index - 1);
  4851. if (check_token.newlines) {
  4852. this._flags.inline_frame = false;
  4853. break;
  4854. }
  4855. } while (check_token.type !== TOKEN$2.EOF &&
  4856. !(check_token.type === TOKEN$2.END_BLOCK && check_token.opened === current_token));
  4857. }
  4858. if ((this._options.brace_style === "expand" ||
  4859. (this._options.brace_style === "none" && current_token.newlines)) &&
  4860. !this._flags.inline_frame) {
  4861. if (this._flags.last_token.type !== TOKEN$2.OPERATOR &&
  4862. (empty_anonymous_function ||
  4863. this._flags.last_token.type === TOKEN$2.EQUALS ||
  4864. (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
  4865. this._output.space_before_token = true;
  4866. } else {
  4867. this.print_newline(false, true);
  4868. }
  4869. } else { // collapse || inline_frame
  4870. if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.COMMA)) {
  4871. if (this._flags.last_token.type === TOKEN$2.COMMA || this._options.space_in_paren) {
  4872. this._output.space_before_token = true;
  4873. }
  4874. if (this._flags.last_token.type === TOKEN$2.COMMA || (this._flags.last_token.type === TOKEN$2.START_EXPR && this._flags.inline_frame)) {
  4875. this.allow_wrap_or_preserved_newline(current_token);
  4876. this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
  4877. this._flags.multiline_frame = false;
  4878. }
  4879. }
  4880. if (this._flags.last_token.type !== TOKEN$2.OPERATOR && this._flags.last_token.type !== TOKEN$2.START_EXPR) {
  4881. if (this._flags.last_token.type === TOKEN$2.START_BLOCK && !this._flags.inline_frame) {
  4882. this.print_newline();
  4883. } else {
  4884. this._output.space_before_token = true;
  4885. }
  4886. }
  4887. }
  4888. this.print_token(current_token);
  4889. this.indent();
  4890. // Except for specific cases, open braces are followed by a new line.
  4891. if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
  4892. this.print_newline();
  4893. }
  4894. };
  4895. Beautifier.prototype.handle_end_block = function(current_token) {
  4896. // statements must all be closed when their container closes
  4897. this.handle_whitespace_and_comments(current_token);
  4898. while (this._flags.mode === MODE.Statement) {
  4899. this.restore_mode();
  4900. }
  4901. var empty_braces = this._flags.last_token.type === TOKEN$2.START_BLOCK;
  4902. if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
  4903. this._output.space_before_token = true;
  4904. } else if (this._options.brace_style === "expand") {
  4905. if (!empty_braces) {
  4906. this.print_newline();
  4907. }
  4908. } else {
  4909. // skip {}
  4910. if (!empty_braces) {
  4911. if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
  4912. // we REALLY need a newline here, but newliner would skip that
  4913. this._options.keep_array_indentation = false;
  4914. this.print_newline();
  4915. this._options.keep_array_indentation = true;
  4916. } else {
  4917. this.print_newline();
  4918. }
  4919. }
  4920. }
  4921. this.restore_mode();
  4922. this.print_token(current_token);
  4923. };
  4924. Beautifier.prototype.handle_word = function(current_token) {
  4925. if (current_token.type === TOKEN$2.RESERVED) {
  4926. if (in_array$1(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
  4927. current_token.type = TOKEN$2.WORD;
  4928. } else if (current_token.text === 'import' && this._tokens.peek().text === '(') {
  4929. current_token.type = TOKEN$2.WORD;
  4930. } else if (in_array$1(current_token.text, ['as', 'from']) && !this._flags.import_block) {
  4931. current_token.type = TOKEN$2.WORD;
  4932. } else if (this._flags.mode === MODE.ObjectLiteral) {
  4933. var next_token = this._tokens.peek();
  4934. if (next_token.text === ':') {
  4935. current_token.type = TOKEN$2.WORD;
  4936. }
  4937. }
  4938. }
  4939. if (this.start_of_statement(current_token)) {
  4940. // The conditional starts the statement if appropriate.
  4941. if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD) {
  4942. this._flags.declaration_statement = true;
  4943. }
  4944. } else if (current_token.newlines && !is_expression(this._flags.mode) &&
  4945. (this._flags.last_token.type !== TOKEN$2.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
  4946. this._flags.last_token.type !== TOKEN$2.EQUALS &&
  4947. (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
  4948. this.handle_whitespace_and_comments(current_token);
  4949. this.print_newline();
  4950. } else {
  4951. this.handle_whitespace_and_comments(current_token);
  4952. }
  4953. if (this._flags.do_block && !this._flags.do_while) {
  4954. if (reserved_word(current_token, 'while')) {
  4955. // do {} ## while ()
  4956. this._output.space_before_token = true;
  4957. this.print_token(current_token);
  4958. this._output.space_before_token = true;
  4959. this._flags.do_while = true;
  4960. return;
  4961. } else {
  4962. // do {} should always have while as the next word.
  4963. // if we don't see the expected while, recover
  4964. this.print_newline();
  4965. this._flags.do_block = false;
  4966. }
  4967. }
  4968. // if may be followed by else, or not
  4969. // Bare/inline ifs are tricky
  4970. // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
  4971. if (this._flags.if_block) {
  4972. if (!this._flags.else_block && reserved_word(current_token, 'else')) {
  4973. this._flags.else_block = true;
  4974. } else {
  4975. while (this._flags.mode === MODE.Statement) {
  4976. this.restore_mode();
  4977. }
  4978. this._flags.if_block = false;
  4979. this._flags.else_block = false;
  4980. }
  4981. }
  4982. if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
  4983. this.print_newline();
  4984. if (this._flags.last_token.type !== TOKEN$2.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) {
  4985. // switch cases following one another
  4986. this.deindent();
  4987. }
  4988. this._flags.case_body = false;
  4989. this.print_token(current_token);
  4990. this._flags.in_case = true;
  4991. return;
  4992. }
  4993. if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
  4994. if (!this.start_of_object_property()) {
  4995. this.allow_wrap_or_preserved_newline(current_token);
  4996. }
  4997. }
  4998. if (reserved_word(current_token, 'function')) {
  4999. if (in_array$1(this._flags.last_token.text, ['}', ';']) ||
  5000. (this._output.just_added_newline() && !(in_array$1(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN$2.OPERATOR))) {
  5001. // make sure there is a nice clean space of at least one blank line
  5002. // before a new function definition
  5003. if (!this._output.just_added_blankline() && !current_token.comments_before) {
  5004. this.print_newline();
  5005. this.print_newline(true);
  5006. }
  5007. }
  5008. if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD) {
  5009. if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
  5010. reserved_array(this._flags.last_token, newline_restricted_tokens)) {
  5011. this._output.space_before_token = true;
  5012. } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
  5013. this._output.space_before_token = true;
  5014. } else if (this._flags.last_token.text === 'declare') {
  5015. // accomodates Typescript declare function formatting
  5016. this._output.space_before_token = true;
  5017. } else {
  5018. this.print_newline();
  5019. }
  5020. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR || this._flags.last_token.text === '=') {
  5021. // foo = function
  5022. this._output.space_before_token = true;
  5023. } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
  5024. this.print_newline();
  5025. }
  5026. this.print_token(current_token);
  5027. this._flags.last_word = current_token.text;
  5028. return;
  5029. }
  5030. var prefix = 'NONE';
  5031. if (this._flags.last_token.type === TOKEN$2.END_BLOCK) {
  5032. if (this._previous_flags.inline_frame) {
  5033. prefix = 'SPACE';
  5034. } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
  5035. prefix = 'NEWLINE';
  5036. } else {
  5037. if (this._options.brace_style === "expand" ||
  5038. this._options.brace_style === "end-expand" ||
  5039. (this._options.brace_style === "none" && current_token.newlines)) {
  5040. prefix = 'NEWLINE';
  5041. } else {
  5042. prefix = 'SPACE';
  5043. this._output.space_before_token = true;
  5044. }
  5045. }
  5046. } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
  5047. // TODO: Should this be for STATEMENT as well?
  5048. prefix = 'NEWLINE';
  5049. } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && is_expression(this._flags.mode)) {
  5050. prefix = 'SPACE';
  5051. } else if (this._flags.last_token.type === TOKEN$2.STRING) {
  5052. prefix = 'NEWLINE';
  5053. } else if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD ||
  5054. (this._flags.last_token.text === '*' &&
  5055. (in_array$1(this._last_last_text, ['function', 'yield']) ||
  5056. (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
  5057. prefix = 'SPACE';
  5058. } else if (this._flags.last_token.type === TOKEN$2.START_BLOCK) {
  5059. if (this._flags.inline_frame) {
  5060. prefix = 'SPACE';
  5061. } else {
  5062. prefix = 'NEWLINE';
  5063. }
  5064. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
  5065. this._output.space_before_token = true;
  5066. prefix = 'NEWLINE';
  5067. }
  5068. if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
  5069. if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
  5070. prefix = 'SPACE';
  5071. } else {
  5072. prefix = 'NEWLINE';
  5073. }
  5074. }
  5075. if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
  5076. if ((!(this._flags.last_token.type === TOKEN$2.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
  5077. this._options.brace_style === "expand" ||
  5078. this._options.brace_style === "end-expand" ||
  5079. (this._options.brace_style === "none" && current_token.newlines)) &&
  5080. !this._flags.inline_frame) {
  5081. this.print_newline();
  5082. } else {
  5083. this._output.trim(true);
  5084. var line = this._output.current_line;
  5085. // If we trimmed and there's something other than a close block before us
  5086. // put a newline back in. Handles '} // comment' scenario.
  5087. if (line.last() !== '}') {
  5088. this.print_newline();
  5089. }
  5090. this._output.space_before_token = true;
  5091. }
  5092. } else if (prefix === 'NEWLINE') {
  5093. if (reserved_array(this._flags.last_token, special_words)) {
  5094. // no newline between 'return nnn'
  5095. this._output.space_before_token = true;
  5096. } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
  5097. // accomodates Typescript declare formatting
  5098. this._output.space_before_token = true;
  5099. } else if (this._flags.last_token.type !== TOKEN$2.END_EXPR) {
  5100. if ((this._flags.last_token.type !== TOKEN$2.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
  5101. // no need to force newline on 'var': for (var x = 0...)
  5102. if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
  5103. // no newline for } else if {
  5104. this._output.space_before_token = true;
  5105. } else {
  5106. this.print_newline();
  5107. }
  5108. }
  5109. } else if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
  5110. this.print_newline();
  5111. }
  5112. } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
  5113. this.print_newline(); // }, in lists get a newline treatment
  5114. } else if (prefix === 'SPACE') {
  5115. this._output.space_before_token = true;
  5116. }
  5117. if (current_token.previous && (current_token.previous.type === TOKEN$2.WORD || current_token.previous.type === TOKEN$2.RESERVED)) {
  5118. this._output.space_before_token = true;
  5119. }
  5120. this.print_token(current_token);
  5121. this._flags.last_word = current_token.text;
  5122. if (current_token.type === TOKEN$2.RESERVED) {
  5123. if (current_token.text === 'do') {
  5124. this._flags.do_block = true;
  5125. } else if (current_token.text === 'if') {
  5126. this._flags.if_block = true;
  5127. } else if (current_token.text === 'import') {
  5128. this._flags.import_block = true;
  5129. } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
  5130. this._flags.import_block = false;
  5131. }
  5132. }
  5133. };
  5134. Beautifier.prototype.handle_semicolon = function(current_token) {
  5135. if (this.start_of_statement(current_token)) {
  5136. // The conditional starts the statement if appropriate.
  5137. // Semicolon can be the start (and end) of a statement
  5138. this._output.space_before_token = false;
  5139. } else {
  5140. this.handle_whitespace_and_comments(current_token);
  5141. }
  5142. var next_token = this._tokens.peek();
  5143. while (this._flags.mode === MODE.Statement &&
  5144. !(this._flags.if_block && reserved_word(next_token, 'else')) &&
  5145. !this._flags.do_block) {
  5146. this.restore_mode();
  5147. }
  5148. // hacky but effective for the moment
  5149. if (this._flags.import_block) {
  5150. this._flags.import_block = false;
  5151. }
  5152. this.print_token(current_token);
  5153. };
  5154. Beautifier.prototype.handle_string = function(current_token) {
  5155. if (this.start_of_statement(current_token)) {
  5156. // The conditional starts the statement if appropriate.
  5157. // One difference - strings want at least a space before
  5158. this._output.space_before_token = true;
  5159. } else {
  5160. this.handle_whitespace_and_comments(current_token);
  5161. if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD || this._flags.inline_frame) {
  5162. this._output.space_before_token = true;
  5163. } else if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
  5164. if (!this.start_of_object_property()) {
  5165. this.allow_wrap_or_preserved_newline(current_token);
  5166. }
  5167. } else {
  5168. this.print_newline();
  5169. }
  5170. }
  5171. this.print_token(current_token);
  5172. };
  5173. Beautifier.prototype.handle_equals = function(current_token) {
  5174. if (this.start_of_statement(current_token)) ; else {
  5175. this.handle_whitespace_and_comments(current_token);
  5176. }
  5177. if (this._flags.declaration_statement) {
  5178. // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
  5179. this._flags.declaration_assignment = true;
  5180. }
  5181. this._output.space_before_token = true;
  5182. this.print_token(current_token);
  5183. this._output.space_before_token = true;
  5184. };
  5185. Beautifier.prototype.handle_comma = function(current_token) {
  5186. this.handle_whitespace_and_comments(current_token, true);
  5187. this.print_token(current_token);
  5188. this._output.space_before_token = true;
  5189. if (this._flags.declaration_statement) {
  5190. if (is_expression(this._flags.parent.mode)) {
  5191. // do not break on comma, for(var a = 1, b = 2)
  5192. this._flags.declaration_assignment = false;
  5193. }
  5194. if (this._flags.declaration_assignment) {
  5195. this._flags.declaration_assignment = false;
  5196. this.print_newline(false, true);
  5197. } else if (this._options.comma_first) {
  5198. // for comma-first, we want to allow a newline before the comma
  5199. // to turn into a newline after the comma, which we will fixup later
  5200. this.allow_wrap_or_preserved_newline(current_token);
  5201. }
  5202. } else if (this._flags.mode === MODE.ObjectLiteral ||
  5203. (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
  5204. if (this._flags.mode === MODE.Statement) {
  5205. this.restore_mode();
  5206. }
  5207. if (!this._flags.inline_frame) {
  5208. this.print_newline();
  5209. }
  5210. } else if (this._options.comma_first) {
  5211. // EXPR or DO_BLOCK
  5212. // for comma-first, we want to allow a newline before the comma
  5213. // to turn into a newline after the comma, which we will fixup later
  5214. this.allow_wrap_or_preserved_newline(current_token);
  5215. }
  5216. };
  5217. Beautifier.prototype.handle_operator = function(current_token) {
  5218. var isGeneratorAsterisk = current_token.text === '*' &&
  5219. (reserved_array(this._flags.last_token, ['function', 'yield']) ||
  5220. (in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.COMMA, TOKEN$2.END_BLOCK, TOKEN$2.SEMICOLON]))
  5221. );
  5222. var isUnary = in_array$1(current_token.text, ['-', '+']) && (
  5223. in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.START_EXPR, TOKEN$2.EQUALS, TOKEN$2.OPERATOR]) ||
  5224. in_array$1(this._flags.last_token.text, line_starters$1) ||
  5225. this._flags.last_token.text === ','
  5226. );
  5227. if (this.start_of_statement(current_token)) ; else {
  5228. var preserve_statement_flags = !isGeneratorAsterisk;
  5229. this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
  5230. }
  5231. if (reserved_array(this._flags.last_token, special_words)) {
  5232. // "return" had a special handling in TK_WORD. Now we need to return the favor
  5233. this._output.space_before_token = true;
  5234. this.print_token(current_token);
  5235. return;
  5236. }
  5237. // hack for actionscript's import .*;
  5238. if (current_token.text === '*' && this._flags.last_token.type === TOKEN$2.DOT) {
  5239. this.print_token(current_token);
  5240. return;
  5241. }
  5242. if (current_token.text === '::') {
  5243. // no spaces around exotic namespacing syntax operator
  5244. this.print_token(current_token);
  5245. return;
  5246. }
  5247. // Allow line wrapping between operators when operator_position is
  5248. // set to before or preserve
  5249. if (this._flags.last_token.type === TOKEN$2.OPERATOR && in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
  5250. this.allow_wrap_or_preserved_newline(current_token);
  5251. }
  5252. if (current_token.text === ':' && this._flags.in_case) {
  5253. this.print_token(current_token);
  5254. this._flags.in_case = false;
  5255. this._flags.case_body = true;
  5256. if (this._tokens.peek().type !== TOKEN$2.START_BLOCK) {
  5257. this.indent();
  5258. this.print_newline();
  5259. } else {
  5260. this._output.space_before_token = true;
  5261. }
  5262. return;
  5263. }
  5264. var space_before = true;
  5265. var space_after = true;
  5266. var in_ternary = false;
  5267. if (current_token.text === ':') {
  5268. if (this._flags.ternary_depth === 0) {
  5269. // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
  5270. space_before = false;
  5271. } else {
  5272. this._flags.ternary_depth -= 1;
  5273. in_ternary = true;
  5274. }
  5275. } else if (current_token.text === '?') {
  5276. this._flags.ternary_depth += 1;
  5277. }
  5278. // let's handle the operator_position option prior to any conflicting logic
  5279. if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array$1(current_token.text, positionable_operators$1)) {
  5280. var isColon = current_token.text === ':';
  5281. var isTernaryColon = (isColon && in_ternary);
  5282. var isOtherColon = (isColon && !in_ternary);
  5283. switch (this._options.operator_position) {
  5284. case OPERATOR_POSITION.before_newline:
  5285. // if the current token is : and it's not a ternary statement then we set space_before to false
  5286. this._output.space_before_token = !isOtherColon;
  5287. this.print_token(current_token);
  5288. if (!isColon || isTernaryColon) {
  5289. this.allow_wrap_or_preserved_newline(current_token);
  5290. }
  5291. this._output.space_before_token = true;
  5292. return;
  5293. case OPERATOR_POSITION.after_newline:
  5294. // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
  5295. // then print a newline.
  5296. this._output.space_before_token = true;
  5297. if (!isColon || isTernaryColon) {
  5298. if (this._tokens.peek().newlines) {
  5299. this.print_newline(false, true);
  5300. } else {
  5301. this.allow_wrap_or_preserved_newline(current_token);
  5302. }
  5303. } else {
  5304. this._output.space_before_token = false;
  5305. }
  5306. this.print_token(current_token);
  5307. this._output.space_before_token = true;
  5308. return;
  5309. case OPERATOR_POSITION.preserve_newline:
  5310. if (!isOtherColon) {
  5311. this.allow_wrap_or_preserved_newline(current_token);
  5312. }
  5313. // if we just added a newline, or the current token is : and it's not a ternary statement,
  5314. // then we set space_before to false
  5315. space_before = !(this._output.just_added_newline() || isOtherColon);
  5316. this._output.space_before_token = space_before;
  5317. this.print_token(current_token);
  5318. this._output.space_before_token = true;
  5319. return;
  5320. }
  5321. }
  5322. if (isGeneratorAsterisk) {
  5323. this.allow_wrap_or_preserved_newline(current_token);
  5324. space_before = false;
  5325. var next_token = this._tokens.peek();
  5326. space_after = next_token && in_array$1(next_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]);
  5327. } else if (current_token.text === '...') {
  5328. this.allow_wrap_or_preserved_newline(current_token);
  5329. space_before = this._flags.last_token.type === TOKEN$2.START_BLOCK;
  5330. space_after = false;
  5331. } else if (in_array$1(current_token.text, ['--', '++', '!', '~']) || isUnary) {
  5332. // unary operators (and binary +/- pretending to be unary) special cases
  5333. if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR) {
  5334. this.allow_wrap_or_preserved_newline(current_token);
  5335. }
  5336. space_before = false;
  5337. space_after = false;
  5338. // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
  5339. // if there is a newline between -- or ++ and anything else we should preserve it.
  5340. if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
  5341. this.print_newline(false, true);
  5342. }
  5343. if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
  5344. // for (;; ++i)
  5345. // ^^^
  5346. space_before = true;
  5347. }
  5348. if (this._flags.last_token.type === TOKEN$2.RESERVED) {
  5349. space_before = true;
  5350. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
  5351. space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
  5352. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR) {
  5353. // a++ + ++b;
  5354. // a - -b
  5355. space_before = in_array$1(current_token.text, ['--', '-', '++', '+']) && in_array$1(this._flags.last_token.text, ['--', '-', '++', '+']);
  5356. // + and - are not unary when preceeded by -- or ++ operator
  5357. // a-- + b
  5358. // a * +b
  5359. // a - -b
  5360. if (in_array$1(current_token.text, ['+', '-']) && in_array$1(this._flags.last_token.text, ['--', '++'])) {
  5361. space_after = true;
  5362. }
  5363. }
  5364. if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
  5365. (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
  5366. // { foo; --i }
  5367. // foo(); --bar;
  5368. this.print_newline();
  5369. }
  5370. }
  5371. this._output.space_before_token = this._output.space_before_token || space_before;
  5372. this.print_token(current_token);
  5373. this._output.space_before_token = space_after;
  5374. };
  5375. Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
  5376. if (this._output.raw) {
  5377. this._output.add_raw_token(current_token);
  5378. if (current_token.directives && current_token.directives.preserve === 'end') {
  5379. // If we're testing the raw output behavior, do not allow a directive to turn it off.
  5380. this._output.raw = this._options.test_output_raw;
  5381. }
  5382. return;
  5383. }
  5384. if (current_token.directives) {
  5385. this.print_newline(false, preserve_statement_flags);
  5386. this.print_token(current_token);
  5387. if (current_token.directives.preserve === 'start') {
  5388. this._output.raw = true;
  5389. }
  5390. this.print_newline(false, true);
  5391. return;
  5392. }
  5393. // inline block
  5394. if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
  5395. this._output.space_before_token = true;
  5396. this.print_token(current_token);
  5397. this._output.space_before_token = true;
  5398. return;
  5399. } else {
  5400. this.print_block_commment(current_token, preserve_statement_flags);
  5401. }
  5402. };
  5403. Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
  5404. var lines = split_linebreaks(current_token.text);
  5405. var j; // iterator for this case
  5406. var javadoc = false;
  5407. var starless = false;
  5408. var lastIndent = current_token.whitespace_before;
  5409. var lastIndentLength = lastIndent.length;
  5410. // block comment starts with a new line
  5411. this.print_newline(false, preserve_statement_flags);
  5412. // first line always indented
  5413. this.print_token_line_indentation(current_token);
  5414. this._output.add_token(lines[0]);
  5415. this.print_newline(false, preserve_statement_flags);
  5416. if (lines.length > 1) {
  5417. lines = lines.slice(1);
  5418. javadoc = all_lines_start_with(lines, '*');
  5419. starless = each_line_matches_indent(lines, lastIndent);
  5420. if (javadoc) {
  5421. this._flags.alignment = 1;
  5422. }
  5423. for (j = 0; j < lines.length; j++) {
  5424. if (javadoc) {
  5425. // javadoc: reformat and re-indent
  5426. this.print_token_line_indentation(current_token);
  5427. this._output.add_token(ltrim(lines[j]));
  5428. } else if (starless && lines[j]) {
  5429. // starless: re-indent non-empty content, avoiding trim
  5430. this.print_token_line_indentation(current_token);
  5431. this._output.add_token(lines[j].substring(lastIndentLength));
  5432. } else {
  5433. // normal comments output raw
  5434. this._output.current_line.set_indent(-1);
  5435. this._output.add_token(lines[j]);
  5436. }
  5437. // for comments on their own line or more than one line, make sure there's a new line after
  5438. this.print_newline(false, preserve_statement_flags);
  5439. }
  5440. this._flags.alignment = 0;
  5441. }
  5442. };
  5443. Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
  5444. if (current_token.newlines) {
  5445. this.print_newline(false, preserve_statement_flags);
  5446. } else {
  5447. this._output.trim(true);
  5448. }
  5449. this._output.space_before_token = true;
  5450. this.print_token(current_token);
  5451. this.print_newline(false, preserve_statement_flags);
  5452. };
  5453. Beautifier.prototype.handle_dot = function(current_token) {
  5454. if (this.start_of_statement(current_token)) ; else {
  5455. this.handle_whitespace_and_comments(current_token, true);
  5456. }
  5457. if (reserved_array(this._flags.last_token, special_words)) {
  5458. this._output.space_before_token = false;
  5459. } else {
  5460. // allow preserved newlines before dots in general
  5461. // force newlines on dots after close paren when break_chained - for bar().baz()
  5462. this.allow_wrap_or_preserved_newline(current_token,
  5463. this._flags.last_token.text === ')' && this._options.break_chained_methods);
  5464. }
  5465. // Only unindent chained method dot if this dot starts a new line.
  5466. // Otherwise the automatic extra indentation removal will handle the over indent
  5467. if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
  5468. this.deindent();
  5469. }
  5470. this.print_token(current_token);
  5471. };
  5472. Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
  5473. this.print_token(current_token);
  5474. if (current_token.text[current_token.text.length - 1] === '\n') {
  5475. this.print_newline(false, preserve_statement_flags);
  5476. }
  5477. };
  5478. Beautifier.prototype.handle_eof = function(current_token) {
  5479. // Unwind any open statements
  5480. while (this._flags.mode === MODE.Statement) {
  5481. this.restore_mode();
  5482. }
  5483. this.handle_whitespace_and_comments(current_token);
  5484. };
  5485. var Beautifier_1 = Beautifier;
  5486. var beautifier = {
  5487. Beautifier: Beautifier_1
  5488. };
  5489. var Beautifier$1 = beautifier.Beautifier,
  5490. Options$3 = options$1.Options;
  5491. function js_beautify(js_source_text, options) {
  5492. var beautifier = new Beautifier$1(js_source_text, options);
  5493. return beautifier.beautify();
  5494. }
  5495. var javascript = js_beautify;
  5496. var defaultOptions = function() {
  5497. return new Options$3();
  5498. };
  5499. javascript.defaultOptions = defaultOptions;
  5500. var BaseOptions$1 = options.Options;
  5501. function Options$4(options) {
  5502. BaseOptions$1.call(this, options, 'css');
  5503. this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
  5504. this.newline_between_rules = this._get_boolean('newline_between_rules', true);
  5505. var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
  5506. this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
  5507. }
  5508. Options$4.prototype = new BaseOptions$1();
  5509. var Options_1$2 = Options$4;
  5510. var options$2 = {
  5511. Options: Options_1$2
  5512. };
  5513. var Options$5 = options$2.Options;
  5514. var Output$2 = output.Output;
  5515. var InputScanner$3 = inputscanner.InputScanner;
  5516. var Directives$2 = directives.Directives;
  5517. var directives_core$1 = new Directives$2(/\/\*/, /\*\//);
  5518. var lineBreak = /\r\n|[\r\n]/;
  5519. var allLineBreaks = /\r\n|[\r\n]/g;
  5520. // tokenizer
  5521. var whitespaceChar = /\s/;
  5522. var whitespacePattern = /(?:\s|\n)+/g;
  5523. var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
  5524. var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
  5525. function Beautifier$2(source_text, options) {
  5526. this._source_text = source_text || '';
  5527. // Allow the setting of language/file-type specific options
  5528. // with inheritance of overall settings
  5529. this._options = new Options$5(options);
  5530. this._ch = null;
  5531. this._input = null;
  5532. // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
  5533. this.NESTED_AT_RULE = {
  5534. "@page": true,
  5535. "@font-face": true,
  5536. "@keyframes": true,
  5537. // also in CONDITIONAL_GROUP_RULE below
  5538. "@media": true,
  5539. "@supports": true,
  5540. "@document": true
  5541. };
  5542. this.CONDITIONAL_GROUP_RULE = {
  5543. "@media": true,
  5544. "@supports": true,
  5545. "@document": true
  5546. };
  5547. }
  5548. Beautifier$2.prototype.eatString = function(endChars) {
  5549. var result = '';
  5550. this._ch = this._input.next();
  5551. while (this._ch) {
  5552. result += this._ch;
  5553. if (this._ch === "\\") {
  5554. result += this._input.next();
  5555. } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
  5556. break;
  5557. }
  5558. this._ch = this._input.next();
  5559. }
  5560. return result;
  5561. };
  5562. // Skips any white space in the source text from the current position.
  5563. // When allowAtLeastOneNewLine is true, will output new lines for each
  5564. // newline character found; if the user has preserve_newlines off, only
  5565. // the first newline will be output
  5566. Beautifier$2.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
  5567. var result = whitespaceChar.test(this._input.peek());
  5568. var isFirstNewLine = true;
  5569. while (whitespaceChar.test(this._input.peek())) {
  5570. this._ch = this._input.next();
  5571. if (allowAtLeastOneNewLine && this._ch === '\n') {
  5572. if (this._options.preserve_newlines || isFirstNewLine) {
  5573. isFirstNewLine = false;
  5574. this._output.add_new_line(true);
  5575. }
  5576. }
  5577. }
  5578. return result;
  5579. };
  5580. // Nested pseudo-class if we are insideRule
  5581. // and the next special character found opens
  5582. // a new block
  5583. Beautifier$2.prototype.foundNestedPseudoClass = function() {
  5584. var openParen = 0;
  5585. var i = 1;
  5586. var ch = this._input.peek(i);
  5587. while (ch) {
  5588. if (ch === "{") {
  5589. return true;
  5590. } else if (ch === '(') {
  5591. // pseudoclasses can contain ()
  5592. openParen += 1;
  5593. } else if (ch === ')') {
  5594. if (openParen === 0) {
  5595. return false;
  5596. }
  5597. openParen -= 1;
  5598. } else if (ch === ";" || ch === "}") {
  5599. return false;
  5600. }
  5601. i++;
  5602. ch = this._input.peek(i);
  5603. }
  5604. return false;
  5605. };
  5606. Beautifier$2.prototype.print_string = function(output_string) {
  5607. this._output.set_indent(this._indentLevel);
  5608. this._output.non_breaking_space = true;
  5609. this._output.add_token(output_string);
  5610. };
  5611. Beautifier$2.prototype.preserveSingleSpace = function(isAfterSpace) {
  5612. if (isAfterSpace) {
  5613. this._output.space_before_token = true;
  5614. }
  5615. };
  5616. Beautifier$2.prototype.indent = function() {
  5617. this._indentLevel++;
  5618. };
  5619. Beautifier$2.prototype.outdent = function() {
  5620. if (this._indentLevel > 0) {
  5621. this._indentLevel--;
  5622. }
  5623. };
  5624. /*_____________________--------------------_____________________*/
  5625. Beautifier$2.prototype.beautify = function() {
  5626. if (this._options.disabled) {
  5627. return this._source_text;
  5628. }
  5629. var source_text = this._source_text;
  5630. var eol = this._options.eol;
  5631. if (eol === 'auto') {
  5632. eol = '\n';
  5633. if (source_text && lineBreak.test(source_text || '')) {
  5634. eol = source_text.match(lineBreak)[0];
  5635. }
  5636. }
  5637. // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
  5638. source_text = source_text.replace(allLineBreaks, '\n');
  5639. // reset
  5640. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  5641. this._output = new Output$2(this._options, baseIndentString);
  5642. this._input = new InputScanner$3(source_text);
  5643. this._indentLevel = 0;
  5644. this._nestedLevel = 0;
  5645. this._ch = null;
  5646. var parenLevel = 0;
  5647. var insideRule = false;
  5648. // This is the value side of a property value pair (blue in the following ex)
  5649. // label { content: blue }
  5650. var insidePropertyValue = false;
  5651. var enteringConditionalGroup = false;
  5652. var insideAtExtend = false;
  5653. var insideAtImport = false;
  5654. var topCharacter = this._ch;
  5655. var whitespace;
  5656. var isAfterSpace;
  5657. var previous_ch;
  5658. while (true) {
  5659. whitespace = this._input.read(whitespacePattern);
  5660. isAfterSpace = whitespace !== '';
  5661. previous_ch = topCharacter;
  5662. this._ch = this._input.next();
  5663. if (this._ch === '\\' && this._input.hasNext()) {
  5664. this._ch += this._input.next();
  5665. }
  5666. topCharacter = this._ch;
  5667. if (!this._ch) {
  5668. break;
  5669. } else if (this._ch === '/' && this._input.peek() === '*') {
  5670. // /* css comment */
  5671. // Always start block comments on a new line.
  5672. // This handles scenarios where a block comment immediately
  5673. // follows a property definition on the same line or where
  5674. // minified code is being beautified.
  5675. this._output.add_new_line();
  5676. this._input.back();
  5677. var comment = this._input.read(block_comment_pattern);
  5678. // Handle ignore directive
  5679. var directives = directives_core$1.get_directives(comment);
  5680. if (directives && directives.ignore === 'start') {
  5681. comment += directives_core$1.readIgnored(this._input);
  5682. }
  5683. this.print_string(comment);
  5684. // Ensures any new lines following the comment are preserved
  5685. this.eatWhitespace(true);
  5686. // Block comments are followed by a new line so they don't
  5687. // share a line with other properties
  5688. this._output.add_new_line();
  5689. } else if (this._ch === '/' && this._input.peek() === '/') {
  5690. // // single line comment
  5691. // Preserves the space before a comment
  5692. // on the same line as a rule
  5693. this._output.space_before_token = true;
  5694. this._input.back();
  5695. this.print_string(this._input.read(comment_pattern));
  5696. // Ensures any new lines following the comment are preserved
  5697. this.eatWhitespace(true);
  5698. } else if (this._ch === '@') {
  5699. this.preserveSingleSpace(isAfterSpace);
  5700. // deal with less propery mixins @{...}
  5701. if (this._input.peek() === '{') {
  5702. this.print_string(this._ch + this.eatString('}'));
  5703. } else {
  5704. this.print_string(this._ch);
  5705. // strip trailing space, if present, for hash property checks
  5706. var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
  5707. if (variableOrRule.match(/[ :]$/)) {
  5708. // we have a variable or pseudo-class, add it and insert one space before continuing
  5709. variableOrRule = this.eatString(": ").replace(/\s$/, '');
  5710. this.print_string(variableOrRule);
  5711. this._output.space_before_token = true;
  5712. }
  5713. variableOrRule = variableOrRule.replace(/\s$/, '');
  5714. if (variableOrRule === 'extend') {
  5715. insideAtExtend = true;
  5716. } else if (variableOrRule === 'import') {
  5717. insideAtImport = true;
  5718. }
  5719. // might be a nesting at-rule
  5720. if (variableOrRule in this.NESTED_AT_RULE) {
  5721. this._nestedLevel += 1;
  5722. if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
  5723. enteringConditionalGroup = true;
  5724. }
  5725. // might be less variable
  5726. } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
  5727. insidePropertyValue = true;
  5728. this.indent();
  5729. }
  5730. }
  5731. } else if (this._ch === '#' && this._input.peek() === '{') {
  5732. this.preserveSingleSpace(isAfterSpace);
  5733. this.print_string(this._ch + this.eatString('}'));
  5734. } else if (this._ch === '{') {
  5735. if (insidePropertyValue) {
  5736. insidePropertyValue = false;
  5737. this.outdent();
  5738. }
  5739. this.indent();
  5740. this._output.space_before_token = true;
  5741. this.print_string(this._ch);
  5742. // when entering conditional groups, only rulesets are allowed
  5743. if (enteringConditionalGroup) {
  5744. enteringConditionalGroup = false;
  5745. insideRule = (this._indentLevel > this._nestedLevel);
  5746. } else {
  5747. // otherwise, declarations are also allowed
  5748. insideRule = (this._indentLevel >= this._nestedLevel);
  5749. }
  5750. if (this._options.newline_between_rules && insideRule) {
  5751. if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
  5752. this._output.ensure_empty_line_above('/', ',');
  5753. }
  5754. }
  5755. this.eatWhitespace(true);
  5756. this._output.add_new_line();
  5757. } else if (this._ch === '}') {
  5758. this.outdent();
  5759. this._output.add_new_line();
  5760. if (previous_ch === '{') {
  5761. this._output.trim(true);
  5762. }
  5763. insideAtImport = false;
  5764. insideAtExtend = false;
  5765. if (insidePropertyValue) {
  5766. this.outdent();
  5767. insidePropertyValue = false;
  5768. }
  5769. this.print_string(this._ch);
  5770. insideRule = false;
  5771. if (this._nestedLevel) {
  5772. this._nestedLevel--;
  5773. }
  5774. this.eatWhitespace(true);
  5775. this._output.add_new_line();
  5776. if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
  5777. if (this._input.peek() !== '}') {
  5778. this._output.add_new_line(true);
  5779. }
  5780. }
  5781. } else if (this._ch === ":") {
  5782. if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
  5783. // 'property: value' delimiter
  5784. // which could be in a conditional group query
  5785. this.print_string(':');
  5786. if (!insidePropertyValue) {
  5787. insidePropertyValue = true;
  5788. this._output.space_before_token = true;
  5789. this.eatWhitespace(true);
  5790. this.indent();
  5791. }
  5792. } else {
  5793. // sass/less parent reference don't use a space
  5794. // sass nested pseudo-class don't use a space
  5795. // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
  5796. if (this._input.lookBack(" ")) {
  5797. this._output.space_before_token = true;
  5798. }
  5799. if (this._input.peek() === ":") {
  5800. // pseudo-element
  5801. this._ch = this._input.next();
  5802. this.print_string("::");
  5803. } else {
  5804. // pseudo-class
  5805. this.print_string(':');
  5806. }
  5807. }
  5808. } else if (this._ch === '"' || this._ch === '\'') {
  5809. this.preserveSingleSpace(isAfterSpace);
  5810. this.print_string(this._ch + this.eatString(this._ch));
  5811. this.eatWhitespace(true);
  5812. } else if (this._ch === ';') {
  5813. if (parenLevel === 0) {
  5814. if (insidePropertyValue) {
  5815. this.outdent();
  5816. insidePropertyValue = false;
  5817. }
  5818. insideAtExtend = false;
  5819. insideAtImport = false;
  5820. this.print_string(this._ch);
  5821. this.eatWhitespace(true);
  5822. // This maintains single line comments on the same
  5823. // line. Block comments are also affected, but
  5824. // a new line is always output before one inside
  5825. // that section
  5826. if (this._input.peek() !== '/') {
  5827. this._output.add_new_line();
  5828. }
  5829. } else {
  5830. this.print_string(this._ch);
  5831. this.eatWhitespace(true);
  5832. this._output.space_before_token = true;
  5833. }
  5834. } else if (this._ch === '(') { // may be a url
  5835. if (this._input.lookBack("url")) {
  5836. this.print_string(this._ch);
  5837. this.eatWhitespace();
  5838. parenLevel++;
  5839. this.indent();
  5840. this._ch = this._input.next();
  5841. if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
  5842. this._input.back();
  5843. } else if (this._ch) {
  5844. this.print_string(this._ch + this.eatString(')'));
  5845. if (parenLevel) {
  5846. parenLevel--;
  5847. this.outdent();
  5848. }
  5849. }
  5850. } else {
  5851. this.preserveSingleSpace(isAfterSpace);
  5852. this.print_string(this._ch);
  5853. this.eatWhitespace();
  5854. parenLevel++;
  5855. this.indent();
  5856. }
  5857. } else if (this._ch === ')') {
  5858. if (parenLevel) {
  5859. parenLevel--;
  5860. this.outdent();
  5861. }
  5862. this.print_string(this._ch);
  5863. } else if (this._ch === ',') {
  5864. this.print_string(this._ch);
  5865. this.eatWhitespace(true);
  5866. if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport) {
  5867. this._output.add_new_line();
  5868. } else {
  5869. this._output.space_before_token = true;
  5870. }
  5871. } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
  5872. //handle combinator spacing
  5873. if (this._options.space_around_combinator) {
  5874. this._output.space_before_token = true;
  5875. this.print_string(this._ch);
  5876. this._output.space_before_token = true;
  5877. } else {
  5878. this.print_string(this._ch);
  5879. this.eatWhitespace();
  5880. // squash extra whitespace
  5881. if (this._ch && whitespaceChar.test(this._ch)) {
  5882. this._ch = '';
  5883. }
  5884. }
  5885. } else if (this._ch === ']') {
  5886. this.print_string(this._ch);
  5887. } else if (this._ch === '[') {
  5888. this.preserveSingleSpace(isAfterSpace);
  5889. this.print_string(this._ch);
  5890. } else if (this._ch === '=') { // no whitespace before or after
  5891. this.eatWhitespace();
  5892. this.print_string('=');
  5893. if (whitespaceChar.test(this._ch)) {
  5894. this._ch = '';
  5895. }
  5896. } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
  5897. this.print_string(' ');
  5898. this.print_string(this._ch);
  5899. } else {
  5900. this.preserveSingleSpace(isAfterSpace);
  5901. this.print_string(this._ch);
  5902. }
  5903. }
  5904. var sweetCode = this._output.get_code(eol);
  5905. return sweetCode;
  5906. };
  5907. var Beautifier_1$1 = Beautifier$2;
  5908. var beautifier$1 = {
  5909. Beautifier: Beautifier_1$1
  5910. };
  5911. var Beautifier$3 = beautifier$1.Beautifier,
  5912. Options$6 = options$2.Options;
  5913. function css_beautify(source_text, options) {
  5914. var beautifier = new Beautifier$3(source_text, options);
  5915. return beautifier.beautify();
  5916. }
  5917. var css = css_beautify;
  5918. var defaultOptions$1 = function() {
  5919. return new Options$6();
  5920. };
  5921. css.defaultOptions = defaultOptions$1;
  5922. var BaseOptions$2 = options.Options;
  5923. function Options$7(options) {
  5924. BaseOptions$2.call(this, options, 'html');
  5925. if (this.templating.length === 1 && this.templating[0] === 'auto') {
  5926. this.templating = ['django', 'erb', 'handlebars', 'php'];
  5927. }
  5928. this.indent_inner_html = this._get_boolean('indent_inner_html');
  5929. this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
  5930. this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
  5931. this.indent_handlebars = this._get_boolean('indent_handlebars', true);
  5932. this.wrap_attributes = this._get_selection('wrap_attributes',
  5933. ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
  5934. this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
  5935. this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
  5936. // Block vs inline elements
  5937. // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
  5938. // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
  5939. // https://www.w3.org/TR/html5/dom.html#phrasing-content
  5940. this.inline = this._get_array('inline', [
  5941. 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
  5942. 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
  5943. 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
  5944. 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
  5945. 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
  5946. 'video', 'wbr', 'text',
  5947. // obsolete inline tags
  5948. 'acronym', 'big', 'strike', 'tt'
  5949. ]);
  5950. this.void_elements = this._get_array('void_elements', [
  5951. // HTLM void elements - aka self-closing tags - aka singletons
  5952. // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
  5953. 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
  5954. 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
  5955. // NOTE: Optional tags are too complex for a simple list
  5956. // they are hard coded in _do_optional_end_element
  5957. // Doctype and xml elements
  5958. '!doctype', '?xml',
  5959. // obsolete tags
  5960. // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
  5961. // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
  5962. 'basefont', 'isindex'
  5963. ]);
  5964. this.unformatted = this._get_array('unformatted', []);
  5965. this.content_unformatted = this._get_array('content_unformatted', [
  5966. 'pre', 'textarea'
  5967. ]);
  5968. this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
  5969. this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
  5970. }
  5971. Options$7.prototype = new BaseOptions$2();
  5972. var Options_1$3 = Options$7;
  5973. var options$3 = {
  5974. Options: Options_1$3
  5975. };
  5976. var BaseTokenizer$1 = tokenizer.Tokenizer;
  5977. var BASETOKEN$1 = tokenizer.TOKEN;
  5978. var Directives$3 = directives.Directives;
  5979. var TemplatablePattern$2 = templatablepattern.TemplatablePattern;
  5980. var Pattern$4 = pattern.Pattern;
  5981. var TOKEN$3 = {
  5982. TAG_OPEN: 'TK_TAG_OPEN',
  5983. TAG_CLOSE: 'TK_TAG_CLOSE',
  5984. ATTRIBUTE: 'TK_ATTRIBUTE',
  5985. EQUALS: 'TK_EQUALS',
  5986. VALUE: 'TK_VALUE',
  5987. COMMENT: 'TK_COMMENT',
  5988. TEXT: 'TK_TEXT',
  5989. UNKNOWN: 'TK_UNKNOWN',
  5990. START: BASETOKEN$1.START,
  5991. RAW: BASETOKEN$1.RAW,
  5992. EOF: BASETOKEN$1.EOF
  5993. };
  5994. var directives_core$2 = new Directives$3(/<\!--/, /-->/);
  5995. var Tokenizer$3 = function(input_string, options) {
  5996. BaseTokenizer$1.call(this, input_string, options);
  5997. this._current_tag_name = '';
  5998. // Words end at whitespace or when a tag starts
  5999. // if we are indenting handlebars, they are considered tags
  6000. var templatable_reader = new TemplatablePattern$2(this._input).read_options(this._options);
  6001. var pattern_reader = new Pattern$4(this._input);
  6002. this.__patterns = {
  6003. word: templatable_reader.until(/[\n\r\t <]/),
  6004. single_quote: templatable_reader.until_after(/'/),
  6005. double_quote: templatable_reader.until_after(/"/),
  6006. attribute: templatable_reader.until(/[\n\r\t =\/>]/),
  6007. element_name: templatable_reader.until(/[\n\r\t >\/]/),
  6008. handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
  6009. handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
  6010. handlebars_open: pattern_reader.until(/[\n\r\t }]/),
  6011. handlebars_raw_close: pattern_reader.until(/}}/),
  6012. comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
  6013. cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
  6014. // https://en.wikipedia.org/wiki/Conditional_comment
  6015. conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
  6016. processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
  6017. };
  6018. if (this._options.indent_handlebars) {
  6019. this.__patterns.word = this.__patterns.word.exclude('handlebars');
  6020. }
  6021. this._unformatted_content_delimiter = null;
  6022. if (this._options.unformatted_content_delimiter) {
  6023. var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
  6024. this.__patterns.unformatted_content_delimiter =
  6025. pattern_reader.matching(literal_regexp)
  6026. .until_after(literal_regexp);
  6027. }
  6028. };
  6029. Tokenizer$3.prototype = new BaseTokenizer$1();
  6030. Tokenizer$3.prototype._is_comment = function(current_token) { // jshint unused:false
  6031. return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
  6032. };
  6033. Tokenizer$3.prototype._is_opening = function(current_token) {
  6034. return current_token.type === TOKEN$3.TAG_OPEN;
  6035. };
  6036. Tokenizer$3.prototype._is_closing = function(current_token, open_token) {
  6037. return current_token.type === TOKEN$3.TAG_CLOSE &&
  6038. (open_token && (
  6039. ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
  6040. (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')));
  6041. };
  6042. Tokenizer$3.prototype._reset = function() {
  6043. this._current_tag_name = '';
  6044. };
  6045. Tokenizer$3.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  6046. var token = null;
  6047. this._readWhitespace();
  6048. var c = this._input.peek();
  6049. if (c === null) {
  6050. return this._create_token(TOKEN$3.EOF, '');
  6051. }
  6052. token = token || this._read_open_handlebars(c, open_token);
  6053. token = token || this._read_attribute(c, previous_token, open_token);
  6054. token = token || this._read_raw_content(c, previous_token, open_token);
  6055. token = token || this._read_close(c, open_token);
  6056. token = token || this._read_content_word(c);
  6057. token = token || this._read_comment(c);
  6058. token = token || this._read_open(c, open_token);
  6059. token = token || this._create_token(TOKEN$3.UNKNOWN, this._input.next());
  6060. return token;
  6061. };
  6062. Tokenizer$3.prototype._read_comment = function(c) { // jshint unused:false
  6063. var token = null;
  6064. var resulting_string = null;
  6065. var directives = null;
  6066. if (c === '<') {
  6067. var peek1 = this._input.peek(1);
  6068. //if we're in a comment, do something special
  6069. // We treat all comments as literals, even more than preformatted tags
  6070. // we just look for the appropriate close tag
  6071. if (c === '<' && (peek1 === '!' || peek1 === '?')) {
  6072. resulting_string = this.__patterns.comment.read();
  6073. // only process directive on html comments
  6074. if (resulting_string) {
  6075. directives = directives_core$2.get_directives(resulting_string);
  6076. if (directives && directives.ignore === 'start') {
  6077. resulting_string += directives_core$2.readIgnored(this._input);
  6078. }
  6079. } else {
  6080. resulting_string = this.__patterns.cdata.read();
  6081. resulting_string = resulting_string || this.__patterns.conditional_comment.read();
  6082. resulting_string = resulting_string || this.__patterns.processing.read();
  6083. }
  6084. }
  6085. if (resulting_string) {
  6086. token = this._create_token(TOKEN$3.COMMENT, resulting_string);
  6087. token.directives = directives;
  6088. }
  6089. }
  6090. return token;
  6091. };
  6092. Tokenizer$3.prototype._read_open = function(c, open_token) {
  6093. var resulting_string = null;
  6094. var token = null;
  6095. if (!open_token) {
  6096. if (c === '<') {
  6097. resulting_string = this._input.next();
  6098. if (this._input.peek() === '/') {
  6099. resulting_string += this._input.next();
  6100. }
  6101. resulting_string += this.__patterns.element_name.read();
  6102. token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
  6103. }
  6104. }
  6105. return token;
  6106. };
  6107. Tokenizer$3.prototype._read_open_handlebars = function(c, open_token) {
  6108. var resulting_string = null;
  6109. var token = null;
  6110. if (!open_token) {
  6111. if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
  6112. if (this._input.peek(2) === '!') {
  6113. resulting_string = this.__patterns.handlebars_comment.read();
  6114. resulting_string = resulting_string || this.__patterns.handlebars.read();
  6115. token = this._create_token(TOKEN$3.COMMENT, resulting_string);
  6116. } else {
  6117. resulting_string = this.__patterns.handlebars_open.read();
  6118. token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
  6119. }
  6120. }
  6121. }
  6122. return token;
  6123. };
  6124. Tokenizer$3.prototype._read_close = function(c, open_token) {
  6125. var resulting_string = null;
  6126. var token = null;
  6127. if (open_token) {
  6128. if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
  6129. resulting_string = this._input.next();
  6130. if (c === '/') { // for close tag "/>"
  6131. resulting_string += this._input.next();
  6132. }
  6133. token = this._create_token(TOKEN$3.TAG_CLOSE, resulting_string);
  6134. } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
  6135. this._input.next();
  6136. this._input.next();
  6137. token = this._create_token(TOKEN$3.TAG_CLOSE, '}}');
  6138. }
  6139. }
  6140. return token;
  6141. };
  6142. Tokenizer$3.prototype._read_attribute = function(c, previous_token, open_token) {
  6143. var token = null;
  6144. var resulting_string = '';
  6145. if (open_token && open_token.text[0] === '<') {
  6146. if (c === '=') {
  6147. token = this._create_token(TOKEN$3.EQUALS, this._input.next());
  6148. } else if (c === '"' || c === "'") {
  6149. var content = this._input.next();
  6150. if (c === '"') {
  6151. content += this.__patterns.double_quote.read();
  6152. } else {
  6153. content += this.__patterns.single_quote.read();
  6154. }
  6155. token = this._create_token(TOKEN$3.VALUE, content);
  6156. } else {
  6157. resulting_string = this.__patterns.attribute.read();
  6158. if (resulting_string) {
  6159. if (previous_token.type === TOKEN$3.EQUALS) {
  6160. token = this._create_token(TOKEN$3.VALUE, resulting_string);
  6161. } else {
  6162. token = this._create_token(TOKEN$3.ATTRIBUTE, resulting_string);
  6163. }
  6164. }
  6165. }
  6166. }
  6167. return token;
  6168. };
  6169. Tokenizer$3.prototype._is_content_unformatted = function(tag_name) {
  6170. // void_elements have no content and so cannot have unformatted content
  6171. // script and style tags should always be read as unformatted content
  6172. // finally content_unformatted and unformatted element contents are unformatted
  6173. return this._options.void_elements.indexOf(tag_name) === -1 &&
  6174. (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
  6175. this._options.unformatted.indexOf(tag_name) !== -1);
  6176. };
  6177. Tokenizer$3.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
  6178. var resulting_string = '';
  6179. if (open_token && open_token.text[0] === '{') {
  6180. resulting_string = this.__patterns.handlebars_raw_close.read();
  6181. } else if (previous_token.type === TOKEN$3.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
  6182. var tag_name = previous_token.opened.text.substr(1).toLowerCase();
  6183. if (tag_name === 'script' || tag_name === 'style') {
  6184. // Script and style tags are allowed to have comments wrapping their content
  6185. // or just have regular content.
  6186. var token = this._read_comment(c);
  6187. if (token) {
  6188. token.type = TOKEN$3.TEXT;
  6189. return token;
  6190. }
  6191. resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
  6192. } else if (this._is_content_unformatted(tag_name)) {
  6193. resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
  6194. }
  6195. }
  6196. if (resulting_string) {
  6197. return this._create_token(TOKEN$3.TEXT, resulting_string);
  6198. }
  6199. return null;
  6200. };
  6201. Tokenizer$3.prototype._read_content_word = function(c) {
  6202. var resulting_string = '';
  6203. if (this._options.unformatted_content_delimiter) {
  6204. if (c === this._options.unformatted_content_delimiter[0]) {
  6205. resulting_string = this.__patterns.unformatted_content_delimiter.read();
  6206. }
  6207. }
  6208. if (!resulting_string) {
  6209. resulting_string = this.__patterns.word.read();
  6210. }
  6211. if (resulting_string) {
  6212. return this._create_token(TOKEN$3.TEXT, resulting_string);
  6213. }
  6214. };
  6215. var Tokenizer_1$2 = Tokenizer$3;
  6216. var TOKEN_1$2 = TOKEN$3;
  6217. var tokenizer$2 = {
  6218. Tokenizer: Tokenizer_1$2,
  6219. TOKEN: TOKEN_1$2
  6220. };
  6221. var Options$8 = options$3.Options;
  6222. var Output$3 = output.Output;
  6223. var Tokenizer$4 = tokenizer$2.Tokenizer;
  6224. var TOKEN$4 = tokenizer$2.TOKEN;
  6225. var lineBreak$1 = /\r\n|[\r\n]/;
  6226. var allLineBreaks$1 = /\r\n|[\r\n]/g;
  6227. var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
  6228. this.indent_level = 0;
  6229. this.alignment_size = 0;
  6230. this.max_preserve_newlines = options.max_preserve_newlines;
  6231. this.preserve_newlines = options.preserve_newlines;
  6232. this._output = new Output$3(options, base_indent_string);
  6233. };
  6234. Printer.prototype.current_line_has_match = function(pattern) {
  6235. return this._output.current_line.has_match(pattern);
  6236. };
  6237. Printer.prototype.set_space_before_token = function(value, non_breaking) {
  6238. this._output.space_before_token = value;
  6239. this._output.non_breaking_space = non_breaking;
  6240. };
  6241. Printer.prototype.set_wrap_point = function() {
  6242. this._output.set_indent(this.indent_level, this.alignment_size);
  6243. this._output.set_wrap_point();
  6244. };
  6245. Printer.prototype.add_raw_token = function(token) {
  6246. this._output.add_raw_token(token);
  6247. };
  6248. Printer.prototype.print_preserved_newlines = function(raw_token) {
  6249. var newlines = 0;
  6250. if (raw_token.type !== TOKEN$4.TEXT && raw_token.previous.type !== TOKEN$4.TEXT) {
  6251. newlines = raw_token.newlines ? 1 : 0;
  6252. }
  6253. if (this.preserve_newlines) {
  6254. newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
  6255. }
  6256. for (var n = 0; n < newlines; n++) {
  6257. this.print_newline(n > 0);
  6258. }
  6259. return newlines !== 0;
  6260. };
  6261. Printer.prototype.traverse_whitespace = function(raw_token) {
  6262. if (raw_token.whitespace_before || raw_token.newlines) {
  6263. if (!this.print_preserved_newlines(raw_token)) {
  6264. this._output.space_before_token = true;
  6265. }
  6266. return true;
  6267. }
  6268. return false;
  6269. };
  6270. Printer.prototype.previous_token_wrapped = function() {
  6271. return this._output.previous_token_wrapped;
  6272. };
  6273. Printer.prototype.print_newline = function(force) {
  6274. this._output.add_new_line(force);
  6275. };
  6276. Printer.prototype.print_token = function(token) {
  6277. if (token.text) {
  6278. this._output.set_indent(this.indent_level, this.alignment_size);
  6279. this._output.add_token(token.text);
  6280. }
  6281. };
  6282. Printer.prototype.indent = function() {
  6283. this.indent_level++;
  6284. };
  6285. Printer.prototype.get_full_indent = function(level) {
  6286. level = this.indent_level + (level || 0);
  6287. if (level < 1) {
  6288. return '';
  6289. }
  6290. return this._output.get_indent_string(level);
  6291. };
  6292. var get_type_attribute = function(start_token) {
  6293. var result = null;
  6294. var raw_token = start_token.next;
  6295. // Search attributes for a type attribute
  6296. while (raw_token.type !== TOKEN$4.EOF && start_token.closed !== raw_token) {
  6297. if (raw_token.type === TOKEN$4.ATTRIBUTE && raw_token.text === 'type') {
  6298. if (raw_token.next && raw_token.next.type === TOKEN$4.EQUALS &&
  6299. raw_token.next.next && raw_token.next.next.type === TOKEN$4.VALUE) {
  6300. result = raw_token.next.next.text;
  6301. }
  6302. break;
  6303. }
  6304. raw_token = raw_token.next;
  6305. }
  6306. return result;
  6307. };
  6308. var get_custom_beautifier_name = function(tag_check, raw_token) {
  6309. var typeAttribute = null;
  6310. var result = null;
  6311. if (!raw_token.closed) {
  6312. return null;
  6313. }
  6314. if (tag_check === 'script') {
  6315. typeAttribute = 'text/javascript';
  6316. } else if (tag_check === 'style') {
  6317. typeAttribute = 'text/css';
  6318. }
  6319. typeAttribute = get_type_attribute(raw_token) || typeAttribute;
  6320. // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
  6321. // For those without a type attribute use default;
  6322. if (typeAttribute.search('text/css') > -1) {
  6323. result = 'css';
  6324. } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
  6325. result = 'javascript';
  6326. } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
  6327. result = 'html';
  6328. } else if (typeAttribute.search(/test\/null/) > -1) {
  6329. // Test only mime-type for testing the beautifier when null is passed as beautifing function
  6330. result = 'null';
  6331. }
  6332. return result;
  6333. };
  6334. function in_array$2(what, arr) {
  6335. return arr.indexOf(what) !== -1;
  6336. }
  6337. function TagFrame(parent, parser_token, indent_level) {
  6338. this.parent = parent || null;
  6339. this.tag = parser_token ? parser_token.tag_name : '';
  6340. this.indent_level = indent_level || 0;
  6341. this.parser_token = parser_token || null;
  6342. }
  6343. function TagStack(printer) {
  6344. this._printer = printer;
  6345. this._current_frame = null;
  6346. }
  6347. TagStack.prototype.get_parser_token = function() {
  6348. return this._current_frame ? this._current_frame.parser_token : null;
  6349. };
  6350. TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
  6351. var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
  6352. this._current_frame = new_frame;
  6353. };
  6354. TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
  6355. var parser_token = null;
  6356. if (frame) {
  6357. parser_token = frame.parser_token;
  6358. this._printer.indent_level = frame.indent_level;
  6359. this._current_frame = frame.parent;
  6360. }
  6361. return parser_token;
  6362. };
  6363. TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
  6364. var frame = this._current_frame;
  6365. while (frame) { //till we reach '' (the initial value);
  6366. if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
  6367. break;
  6368. } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
  6369. frame = null;
  6370. break;
  6371. }
  6372. frame = frame.parent;
  6373. }
  6374. return frame;
  6375. };
  6376. TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
  6377. var frame = this._get_frame([tag], stop_list);
  6378. return this._try_pop_frame(frame);
  6379. };
  6380. TagStack.prototype.indent_to_tag = function(tag_list) {
  6381. var frame = this._get_frame(tag_list);
  6382. if (frame) {
  6383. this._printer.indent_level = frame.indent_level;
  6384. }
  6385. };
  6386. function Beautifier$4(source_text, options, js_beautify, css_beautify) {
  6387. //Wrapper function to invoke all the necessary constructors and deal with the output.
  6388. this._source_text = source_text || '';
  6389. options = options || {};
  6390. this._js_beautify = js_beautify;
  6391. this._css_beautify = css_beautify;
  6392. this._tag_stack = null;
  6393. // Allow the setting of language/file-type specific options
  6394. // with inheritance of overall settings
  6395. var optionHtml = new Options$8(options, 'html');
  6396. this._options = optionHtml;
  6397. this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
  6398. this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
  6399. this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
  6400. this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
  6401. this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
  6402. this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
  6403. }
  6404. Beautifier$4.prototype.beautify = function() {
  6405. // if disabled, return the input unchanged.
  6406. if (this._options.disabled) {
  6407. return this._source_text;
  6408. }
  6409. var source_text = this._source_text;
  6410. var eol = this._options.eol;
  6411. if (this._options.eol === 'auto') {
  6412. eol = '\n';
  6413. if (source_text && lineBreak$1.test(source_text)) {
  6414. eol = source_text.match(lineBreak$1)[0];
  6415. }
  6416. }
  6417. // HACK: newline parsing inconsistent. This brute force normalizes the input.
  6418. source_text = source_text.replace(allLineBreaks$1, '\n');
  6419. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  6420. var last_token = {
  6421. text: '',
  6422. type: ''
  6423. };
  6424. var last_tag_token = new TagOpenParserToken();
  6425. var printer = new Printer(this._options, baseIndentString);
  6426. var tokens = new Tokenizer$4(source_text, this._options).tokenize();
  6427. this._tag_stack = new TagStack(printer);
  6428. var parser_token = null;
  6429. var raw_token = tokens.next();
  6430. while (raw_token.type !== TOKEN$4.EOF) {
  6431. if (raw_token.type === TOKEN$4.TAG_OPEN || raw_token.type === TOKEN$4.COMMENT) {
  6432. parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
  6433. last_tag_token = parser_token;
  6434. } else if ((raw_token.type === TOKEN$4.ATTRIBUTE || raw_token.type === TOKEN$4.EQUALS || raw_token.type === TOKEN$4.VALUE) ||
  6435. (raw_token.type === TOKEN$4.TEXT && !last_tag_token.tag_complete)) {
  6436. parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
  6437. } else if (raw_token.type === TOKEN$4.TAG_CLOSE) {
  6438. parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
  6439. } else if (raw_token.type === TOKEN$4.TEXT) {
  6440. parser_token = this._handle_text(printer, raw_token, last_tag_token);
  6441. } else {
  6442. // This should never happen, but if it does. Print the raw token
  6443. printer.add_raw_token(raw_token);
  6444. }
  6445. last_token = parser_token;
  6446. raw_token = tokens.next();
  6447. }
  6448. var sweet_code = printer._output.get_code(eol);
  6449. return sweet_code;
  6450. };
  6451. Beautifier$4.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
  6452. var parser_token = {
  6453. text: raw_token.text,
  6454. type: raw_token.type
  6455. };
  6456. printer.alignment_size = 0;
  6457. last_tag_token.tag_complete = true;
  6458. printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
  6459. if (last_tag_token.is_unformatted) {
  6460. printer.add_raw_token(raw_token);
  6461. } else {
  6462. if (last_tag_token.tag_start_char === '<') {
  6463. printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
  6464. if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
  6465. printer.print_newline(false);
  6466. }
  6467. }
  6468. printer.print_token(raw_token);
  6469. }
  6470. if (last_tag_token.indent_content &&
  6471. !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
  6472. printer.indent();
  6473. // only indent once per opened tag
  6474. last_tag_token.indent_content = false;
  6475. }
  6476. if (!last_tag_token.is_inline_element &&
  6477. !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
  6478. printer.set_wrap_point();
  6479. }
  6480. return parser_token;
  6481. };
  6482. Beautifier$4.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
  6483. var wrapped = last_tag_token.has_wrapped_attrs;
  6484. var parser_token = {
  6485. text: raw_token.text,
  6486. type: raw_token.type
  6487. };
  6488. printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
  6489. if (last_tag_token.is_unformatted) {
  6490. printer.add_raw_token(raw_token);
  6491. } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN$4.TEXT) {
  6492. // For the insides of handlebars allow newlines or a single space between open and contents
  6493. if (printer.print_preserved_newlines(raw_token)) {
  6494. raw_token.newlines = 0;
  6495. printer.add_raw_token(raw_token);
  6496. } else {
  6497. printer.print_token(raw_token);
  6498. }
  6499. } else {
  6500. if (raw_token.type === TOKEN$4.ATTRIBUTE) {
  6501. printer.set_space_before_token(true);
  6502. last_tag_token.attr_count += 1;
  6503. } else if (raw_token.type === TOKEN$4.EQUALS) { //no space before =
  6504. printer.set_space_before_token(false);
  6505. } else if (raw_token.type === TOKEN$4.VALUE && raw_token.previous.type === TOKEN$4.EQUALS) { //no space before value
  6506. printer.set_space_before_token(false);
  6507. }
  6508. if (raw_token.type === TOKEN$4.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
  6509. if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
  6510. printer.traverse_whitespace(raw_token);
  6511. wrapped = wrapped || raw_token.newlines !== 0;
  6512. }
  6513. if (this._is_wrap_attributes_force) {
  6514. var force_attr_wrap = last_tag_token.attr_count > 1;
  6515. if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
  6516. var is_only_attribute = true;
  6517. var peek_index = 0;
  6518. var peek_token;
  6519. do {
  6520. peek_token = tokens.peek(peek_index);
  6521. if (peek_token.type === TOKEN$4.ATTRIBUTE) {
  6522. is_only_attribute = false;
  6523. break;
  6524. }
  6525. peek_index += 1;
  6526. } while (peek_index < 4 && peek_token.type !== TOKEN$4.EOF && peek_token.type !== TOKEN$4.TAG_CLOSE);
  6527. force_attr_wrap = !is_only_attribute;
  6528. }
  6529. if (force_attr_wrap) {
  6530. printer.print_newline(false);
  6531. wrapped = true;
  6532. }
  6533. }
  6534. }
  6535. printer.print_token(raw_token);
  6536. wrapped = wrapped || printer.previous_token_wrapped();
  6537. last_tag_token.has_wrapped_attrs = wrapped;
  6538. }
  6539. return parser_token;
  6540. };
  6541. Beautifier$4.prototype._handle_text = function(printer, raw_token, last_tag_token) {
  6542. var parser_token = {
  6543. text: raw_token.text,
  6544. type: 'TK_CONTENT'
  6545. };
  6546. if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
  6547. this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
  6548. } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
  6549. printer.add_raw_token(raw_token);
  6550. } else {
  6551. printer.traverse_whitespace(raw_token);
  6552. printer.print_token(raw_token);
  6553. }
  6554. return parser_token;
  6555. };
  6556. Beautifier$4.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
  6557. var local = this;
  6558. if (raw_token.text !== '') {
  6559. var text = raw_token.text,
  6560. _beautifier,
  6561. script_indent_level = 1,
  6562. pre = '',
  6563. post = '';
  6564. if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
  6565. _beautifier = this._js_beautify;
  6566. } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
  6567. _beautifier = this._css_beautify;
  6568. } else if (last_tag_token.custom_beautifier_name === 'html') {
  6569. _beautifier = function(html_source, options) {
  6570. var beautifier = new Beautifier$4(html_source, options, local._js_beautify, local._css_beautify);
  6571. return beautifier.beautify();
  6572. };
  6573. }
  6574. if (this._options.indent_scripts === "keep") {
  6575. script_indent_level = 0;
  6576. } else if (this._options.indent_scripts === "separate") {
  6577. script_indent_level = -printer.indent_level;
  6578. }
  6579. var indentation = printer.get_full_indent(script_indent_level);
  6580. // if there is at least one empty line at the end of this text, strip it
  6581. // we'll be adding one back after the text but before the containing tag.
  6582. text = text.replace(/\n[ \t]*$/, '');
  6583. // Handle the case where content is wrapped in a comment or cdata.
  6584. if (last_tag_token.custom_beautifier_name !== 'html' &&
  6585. text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
  6586. var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
  6587. // if we start to wrap but don't finish, print raw
  6588. if (!matched) {
  6589. printer.add_raw_token(raw_token);
  6590. return;
  6591. }
  6592. pre = indentation + matched[1] + '\n';
  6593. text = matched[4];
  6594. if (matched[5]) {
  6595. post = indentation + matched[5];
  6596. }
  6597. // if there is at least one empty line at the end of this text, strip it
  6598. // we'll be adding one back after the text but before the containing tag.
  6599. text = text.replace(/\n[ \t]*$/, '');
  6600. if (matched[2] || matched[3].indexOf('\n') !== -1) {
  6601. // if the first line of the non-comment text has spaces
  6602. // use that as the basis for indenting in null case.
  6603. matched = matched[3].match(/[ \t]+$/);
  6604. if (matched) {
  6605. raw_token.whitespace_before = matched[0];
  6606. }
  6607. }
  6608. }
  6609. if (text) {
  6610. if (_beautifier) {
  6611. // call the Beautifier if avaliable
  6612. var Child_options = function() {
  6613. this.eol = '\n';
  6614. };
  6615. Child_options.prototype = this._options.raw_options;
  6616. var child_options = new Child_options();
  6617. text = _beautifier(indentation + text, child_options);
  6618. } else {
  6619. // simply indent the string otherwise
  6620. var white = raw_token.whitespace_before;
  6621. if (white) {
  6622. text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
  6623. }
  6624. text = indentation + text.replace(/\n/g, '\n' + indentation);
  6625. }
  6626. }
  6627. if (pre) {
  6628. if (!text) {
  6629. text = pre + post;
  6630. } else {
  6631. text = pre + text + '\n' + post;
  6632. }
  6633. }
  6634. printer.print_newline(false);
  6635. if (text) {
  6636. raw_token.text = text;
  6637. raw_token.whitespace_before = '';
  6638. raw_token.newlines = 0;
  6639. printer.add_raw_token(raw_token);
  6640. printer.print_newline(true);
  6641. }
  6642. }
  6643. };
  6644. Beautifier$4.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
  6645. var parser_token = this._get_tag_open_token(raw_token);
  6646. if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
  6647. raw_token.type === TOKEN$4.TAG_OPEN && raw_token.text.indexOf('</') === 0) {
  6648. // End element tags for unformatted or content_unformatted elements
  6649. // are printed raw to keep any newlines inside them exactly the same.
  6650. printer.add_raw_token(raw_token);
  6651. } else {
  6652. printer.traverse_whitespace(raw_token);
  6653. this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
  6654. if (!parser_token.is_inline_element) {
  6655. printer.set_wrap_point();
  6656. }
  6657. printer.print_token(raw_token);
  6658. }
  6659. //indent attributes an auto, forced, aligned or forced-align line-wrap
  6660. if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
  6661. parser_token.alignment_size = raw_token.text.length + 1;
  6662. }
  6663. if (!parser_token.tag_complete && !parser_token.is_unformatted) {
  6664. printer.alignment_size = parser_token.alignment_size;
  6665. }
  6666. return parser_token;
  6667. };
  6668. var TagOpenParserToken = function(parent, raw_token) {
  6669. this.parent = parent || null;
  6670. this.text = '';
  6671. this.type = 'TK_TAG_OPEN';
  6672. this.tag_name = '';
  6673. this.is_inline_element = false;
  6674. this.is_unformatted = false;
  6675. this.is_content_unformatted = false;
  6676. this.is_empty_element = false;
  6677. this.is_start_tag = false;
  6678. this.is_end_tag = false;
  6679. this.indent_content = false;
  6680. this.multiline_content = false;
  6681. this.custom_beautifier_name = null;
  6682. this.start_tag_token = null;
  6683. this.attr_count = 0;
  6684. this.has_wrapped_attrs = false;
  6685. this.alignment_size = 0;
  6686. this.tag_complete = false;
  6687. this.tag_start_char = '';
  6688. this.tag_check = '';
  6689. if (!raw_token) {
  6690. this.tag_complete = true;
  6691. } else {
  6692. var tag_check_match;
  6693. this.tag_start_char = raw_token.text[0];
  6694. this.text = raw_token.text;
  6695. if (this.tag_start_char === '<') {
  6696. tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
  6697. this.tag_check = tag_check_match ? tag_check_match[1] : '';
  6698. } else {
  6699. tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
  6700. this.tag_check = tag_check_match ? tag_check_match[1] : '';
  6701. }
  6702. this.tag_check = this.tag_check.toLowerCase();
  6703. if (raw_token.type === TOKEN$4.COMMENT) {
  6704. this.tag_complete = true;
  6705. }
  6706. this.is_start_tag = this.tag_check.charAt(0) !== '/';
  6707. this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
  6708. this.is_end_tag = !this.is_start_tag ||
  6709. (raw_token.closed && raw_token.closed.text === '/>');
  6710. // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
  6711. this.is_end_tag = this.is_end_tag ||
  6712. (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2)))));
  6713. }
  6714. };
  6715. Beautifier$4.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
  6716. var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
  6717. parser_token.alignment_size = this._options.wrap_attributes_indent_size;
  6718. parser_token.is_end_tag = parser_token.is_end_tag ||
  6719. in_array$2(parser_token.tag_check, this._options.void_elements);
  6720. parser_token.is_empty_element = parser_token.tag_complete ||
  6721. (parser_token.is_start_tag && parser_token.is_end_tag);
  6722. parser_token.is_unformatted = !parser_token.tag_complete && in_array$2(parser_token.tag_check, this._options.unformatted);
  6723. parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array$2(parser_token.tag_check, this._options.content_unformatted);
  6724. parser_token.is_inline_element = in_array$2(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{';
  6725. return parser_token;
  6726. };
  6727. Beautifier$4.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
  6728. if (!parser_token.is_empty_element) {
  6729. if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
  6730. parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
  6731. } else { // it's a start-tag
  6732. // check if this tag is starting an element that has optional end element
  6733. // and do an ending needed
  6734. if (this._do_optional_end_element(parser_token)) {
  6735. if (!parser_token.is_inline_element) {
  6736. if (parser_token.parent) {
  6737. parser_token.parent.multiline_content = true;
  6738. }
  6739. printer.print_newline(false);
  6740. }
  6741. }
  6742. this._tag_stack.record_tag(parser_token); //push it on the tag stack
  6743. if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
  6744. !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
  6745. parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
  6746. }
  6747. }
  6748. }
  6749. if (in_array$2(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
  6750. printer.print_newline(false);
  6751. if (!printer._output.just_added_blankline()) {
  6752. printer.print_newline(true);
  6753. }
  6754. }
  6755. if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
  6756. // if you hit an else case, reset the indent level if you are inside an:
  6757. // 'if', 'unless', or 'each' block.
  6758. if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
  6759. this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
  6760. parser_token.indent_content = true;
  6761. // Don't add a newline if opening {{#if}} tag is on the current line
  6762. var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
  6763. if (!foundIfOnCurrentLine) {
  6764. printer.print_newline(false);
  6765. }
  6766. }
  6767. // Don't add a newline before elements that should remain where they are.
  6768. if (parser_token.tag_name === '!--' && last_token.type === TOKEN$4.TAG_CLOSE &&
  6769. last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) ; else if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
  6770. printer.print_newline(false);
  6771. }
  6772. } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) {
  6773. if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
  6774. printer.print_newline(false);
  6775. }
  6776. } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
  6777. if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) ||
  6778. !(parser_token.is_inline_element ||
  6779. (last_tag_token.is_inline_element) ||
  6780. (last_token.type === TOKEN$4.TAG_CLOSE &&
  6781. parser_token.start_tag_token === last_tag_token) ||
  6782. (last_token.type === 'TK_CONTENT')
  6783. )) {
  6784. printer.print_newline(false);
  6785. }
  6786. } else { // it's a start-tag
  6787. parser_token.indent_content = !parser_token.custom_beautifier_name;
  6788. if (parser_token.tag_start_char === '<') {
  6789. if (parser_token.tag_name === 'html') {
  6790. parser_token.indent_content = this._options.indent_inner_html;
  6791. } else if (parser_token.tag_name === 'head') {
  6792. parser_token.indent_content = this._options.indent_head_inner_html;
  6793. } else if (parser_token.tag_name === 'body') {
  6794. parser_token.indent_content = this._options.indent_body_inner_html;
  6795. }
  6796. }
  6797. if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') {
  6798. if (parser_token.parent) {
  6799. parser_token.parent.multiline_content = true;
  6800. }
  6801. printer.print_newline(false);
  6802. }
  6803. }
  6804. };
  6805. //To be used for <p> tag special case:
  6806. //var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
  6807. Beautifier$4.prototype._do_optional_end_element = function(parser_token) {
  6808. var result = null;
  6809. // NOTE: cases of "if there is no more content in the parent element"
  6810. // are handled automatically by the beautifier.
  6811. // It assumes parent or ancestor close tag closes all children.
  6812. // https://www.w3.org/TR/html5/syntax.html#optional-tags
  6813. if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
  6814. return;
  6815. } else if (parser_token.tag_name === 'body') {
  6816. // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
  6817. result = result || this._tag_stack.try_pop('head');
  6818. //} else if (parser_token.tag_name === 'body') {
  6819. // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
  6820. } else if (parser_token.tag_name === 'li') {
  6821. // An li element’s end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
  6822. result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
  6823. } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
  6824. // A dd element’s end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
  6825. // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
  6826. result = result || this._tag_stack.try_pop('dt', ['dl']);
  6827. result = result || this._tag_stack.try_pop('dd', ['dl']);
  6828. //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
  6829. //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
  6830. //A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
  6831. //result = result || this._tag_stack.try_pop('p', ['body']);
  6832. } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
  6833. // An rt element’s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
  6834. // An rp element’s end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
  6835. result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
  6836. result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
  6837. } else if (parser_token.tag_name === 'optgroup') {
  6838. // An optgroup element’s end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
  6839. // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
  6840. result = result || this._tag_stack.try_pop('optgroup', ['select']);
  6841. //result = result || this._tag_stack.try_pop('option', ['select']);
  6842. } else if (parser_token.tag_name === 'option') {
  6843. // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
  6844. result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
  6845. } else if (parser_token.tag_name === 'colgroup') {
  6846. // DONE: A colgroup element’s end tag may be omitted if the colgroup element is not immediately followed by a space character or a comment.
  6847. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6848. result = result || this._tag_stack.try_pop('caption', ['table']);
  6849. } else if (parser_token.tag_name === 'thead') {
  6850. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6851. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6852. result = result || this._tag_stack.try_pop('caption', ['table']);
  6853. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6854. //} else if (parser_token.tag_name === 'caption') {
  6855. // DONE: A caption element’s end tag may be omitted if the caption element is not immediately followed by a space character or a comment.
  6856. } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
  6857. // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
  6858. // A tbody element’s end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
  6859. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6860. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6861. result = result || this._tag_stack.try_pop('caption', ['table']);
  6862. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6863. result = result || this._tag_stack.try_pop('thead', ['table']);
  6864. result = result || this._tag_stack.try_pop('tbody', ['table']);
  6865. //} else if (parser_token.tag_name === 'tfoot') {
  6866. // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
  6867. } else if (parser_token.tag_name === 'tr') {
  6868. // A tr element’s end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
  6869. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6870. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6871. result = result || this._tag_stack.try_pop('caption', ['table']);
  6872. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6873. result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
  6874. } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
  6875. // A td element’s end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
  6876. // A th element’s end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
  6877. result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
  6878. result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
  6879. }
  6880. // Start element omission not handled currently
  6881. // A head element’s start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.
  6882. // A tbody element’s start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can’t be omitted if the element is empty.)
  6883. // A colgroup element’s start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can’t be omitted if the element is empty.)
  6884. // Fix up the parent of the parser token
  6885. parser_token.parent = this._tag_stack.get_parser_token();
  6886. return result;
  6887. };
  6888. var Beautifier_1$2 = Beautifier$4;
  6889. var beautifier$2 = {
  6890. Beautifier: Beautifier_1$2
  6891. };
  6892. var Beautifier$5 = beautifier$2.Beautifier,
  6893. Options$9 = options$3.Options;
  6894. function style_html(html_source, options, js_beautify, css_beautify) {
  6895. var beautifier = new Beautifier$5(html_source, options, js_beautify, css_beautify);
  6896. return beautifier.beautify();
  6897. }
  6898. var html = style_html;
  6899. var defaultOptions$2 = function() {
  6900. return new Options$9();
  6901. };
  6902. html.defaultOptions = defaultOptions$2;
  6903. function style_html$1(html_source, options, js, css$1) {
  6904. js = js || javascript;
  6905. css$1 = css$1 || css;
  6906. return html(html_source, options, js, css$1);
  6907. }
  6908. style_html$1.defaultOptions = html.defaultOptions;
  6909. var js = javascript;
  6910. var css$1 = css;
  6911. var html$1 = style_html$1;
  6912. var src = {
  6913. js: js,
  6914. css: css$1,
  6915. html: html$1
  6916. };
  6917. var js$1 = createCommonjsModule(function (module) {
  6918. /**
  6919. The following batches are equivalent:
  6920. var beautify_js = require('js-beautify');
  6921. var beautify_js = require('js-beautify').js;
  6922. var beautify_js = require('js-beautify').js_beautify;
  6923. var beautify_css = require('js-beautify').css;
  6924. var beautify_css = require('js-beautify').css_beautify;
  6925. var beautify_html = require('js-beautify').html;
  6926. var beautify_html = require('js-beautify').html_beautify;
  6927. All methods returned accept two arguments, the source string and an options object.
  6928. **/
  6929. function get_beautify(js_beautify, css_beautify, html_beautify) {
  6930. // the default is js
  6931. var beautify = function(src, config) {
  6932. return js_beautify.js_beautify(src, config);
  6933. };
  6934. // short aliases
  6935. beautify.js = js_beautify.js_beautify;
  6936. beautify.css = css_beautify.css_beautify;
  6937. beautify.html = html_beautify.html_beautify;
  6938. // legacy aliases
  6939. beautify.js_beautify = js_beautify.js_beautify;
  6940. beautify.css_beautify = css_beautify.css_beautify;
  6941. beautify.html_beautify = html_beautify.html_beautify;
  6942. return beautify;
  6943. }
  6944. {
  6945. (function(mod) {
  6946. var beautifier = src;
  6947. beautifier.js_beautify = beautifier.js;
  6948. beautifier.css_beautify = beautifier.css;
  6949. beautifier.html_beautify = beautifier.html;
  6950. mod.exports = get_beautify(beautifier, beautifier, beautifier);
  6951. })(module);
  6952. }
  6953. });
  6954. /*!
  6955. * is-whitespace <https://github.com/jonschlinkert/is-whitespace>
  6956. *
  6957. * Copyright (c) 2014-2015, Jon Schlinkert.
  6958. * Licensed under the MIT License.
  6959. */
  6960. var cache;
  6961. var isWhitespace = function isWhitespace(str) {
  6962. return (typeof str === 'string') && regex().test(str);
  6963. };
  6964. function regex() {
  6965. // ensure that runtime compilation only happens once
  6966. return cache || (cache = new RegExp('^[\\s\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"]+$'));
  6967. }
  6968. /*!
  6969. * is-extendable <https://github.com/jonschlinkert/is-extendable>
  6970. *
  6971. * Copyright (c) 2015, Jon Schlinkert.
  6972. * Licensed under the MIT License.
  6973. */
  6974. var isExtendable = function isExtendable(val) {
  6975. return typeof val !== 'undefined' && val !== null
  6976. && (typeof val === 'object' || typeof val === 'function');
  6977. };
  6978. var extendShallow = function extend(o/*, objects*/) {
  6979. var arguments$1 = arguments;
  6980. if (!isExtendable(o)) { o = {}; }
  6981. var len = arguments.length;
  6982. for (var i = 1; i < len; i++) {
  6983. var obj = arguments$1[i];
  6984. if (isExtendable(obj)) {
  6985. assign(o, obj);
  6986. }
  6987. }
  6988. return o;
  6989. };
  6990. function assign(a, b) {
  6991. for (var key in b) {
  6992. if (hasOwn(b, key)) {
  6993. a[key] = b[key];
  6994. }
  6995. }
  6996. }
  6997. /**
  6998. * Returns true if the given `key` is an own property of `obj`.
  6999. */
  7000. function hasOwn(obj, key) {
  7001. return Object.prototype.hasOwnProperty.call(obj, key);
  7002. }
  7003. /*!
  7004. * Determine if an object is a Buffer
  7005. *
  7006. * @author Feross Aboukhadijeh <https://feross.org>
  7007. * @license MIT
  7008. */
  7009. // The _isBuffer check is for Safari 5-7 support, because it's missing
  7010. // Object.prototype.constructor. Remove this eventually
  7011. var isBuffer_1 = function (obj) {
  7012. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  7013. };
  7014. function isBuffer (obj) {
  7015. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  7016. }
  7017. // For Node v0.10 support. Remove this eventually.
  7018. function isSlowBuffer (obj) {
  7019. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  7020. }
  7021. var toString = Object.prototype.toString;
  7022. /**
  7023. * Get the native `typeof` a value.
  7024. *
  7025. * @param {*} `val`
  7026. * @return {*} Native javascript type
  7027. */
  7028. var kindOf = function kindOf(val) {
  7029. // primitivies
  7030. if (typeof val === 'undefined') {
  7031. return 'undefined';
  7032. }
  7033. if (val === null) {
  7034. return 'null';
  7035. }
  7036. if (val === true || val === false || val instanceof Boolean) {
  7037. return 'boolean';
  7038. }
  7039. if (typeof val === 'string' || val instanceof String) {
  7040. return 'string';
  7041. }
  7042. if (typeof val === 'number' || val instanceof Number) {
  7043. return 'number';
  7044. }
  7045. // functions
  7046. if (typeof val === 'function' || val instanceof Function) {
  7047. return 'function';
  7048. }
  7049. // array
  7050. if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
  7051. return 'array';
  7052. }
  7053. // check for instances of RegExp and Date before calling `toString`
  7054. if (val instanceof RegExp) {
  7055. return 'regexp';
  7056. }
  7057. if (val instanceof Date) {
  7058. return 'date';
  7059. }
  7060. // other objects
  7061. var type = toString.call(val);
  7062. if (type === '[object RegExp]') {
  7063. return 'regexp';
  7064. }
  7065. if (type === '[object Date]') {
  7066. return 'date';
  7067. }
  7068. if (type === '[object Arguments]') {
  7069. return 'arguments';
  7070. }
  7071. if (type === '[object Error]') {
  7072. return 'error';
  7073. }
  7074. // buffer
  7075. if (isBuffer_1(val)) {
  7076. return 'buffer';
  7077. }
  7078. // es6: Map, WeakMap, Set, WeakSet
  7079. if (type === '[object Set]') {
  7080. return 'set';
  7081. }
  7082. if (type === '[object WeakSet]') {
  7083. return 'weakset';
  7084. }
  7085. if (type === '[object Map]') {
  7086. return 'map';
  7087. }
  7088. if (type === '[object WeakMap]') {
  7089. return 'weakmap';
  7090. }
  7091. if (type === '[object Symbol]') {
  7092. return 'symbol';
  7093. }
  7094. // typed arrays
  7095. if (type === '[object Int8Array]') {
  7096. return 'int8array';
  7097. }
  7098. if (type === '[object Uint8Array]') {
  7099. return 'uint8array';
  7100. }
  7101. if (type === '[object Uint8ClampedArray]') {
  7102. return 'uint8clampedarray';
  7103. }
  7104. if (type === '[object Int16Array]') {
  7105. return 'int16array';
  7106. }
  7107. if (type === '[object Uint16Array]') {
  7108. return 'uint16array';
  7109. }
  7110. if (type === '[object Int32Array]') {
  7111. return 'int32array';
  7112. }
  7113. if (type === '[object Uint32Array]') {
  7114. return 'uint32array';
  7115. }
  7116. if (type === '[object Float32Array]') {
  7117. return 'float32array';
  7118. }
  7119. if (type === '[object Float64Array]') {
  7120. return 'float64array';
  7121. }
  7122. // must be a plain object
  7123. return 'object';
  7124. };
  7125. var condenseNewlines = function(str, options) {
  7126. var opts = extendShallow({}, options);
  7127. var sep = opts.sep || '\n\n';
  7128. var min = opts.min;
  7129. var re;
  7130. if (typeof min === 'number' && min !== 2) {
  7131. re = new RegExp('(\\r\\n|\\n|\\u2424) {' + min + ',}');
  7132. }
  7133. if (typeof re === 'undefined') {
  7134. re = opts.regex || /(\r\n|\n|\u2424){2,}/g;
  7135. }
  7136. // if a line is 100% whitespace it will be trimmed, so that
  7137. // later we can condense newlines correctly
  7138. if (opts.keepWhitespace !== true) {
  7139. str = str.split('\n').map(function(line) {
  7140. return isWhitespace(line) ? line.trim() : line;
  7141. }).join('\n');
  7142. }
  7143. str = trailingNewline(str, opts);
  7144. return str.replace(re, sep);
  7145. };
  7146. function trailingNewline(str, options) {
  7147. var val = options.trailingNewline;
  7148. if (val === false) {
  7149. return str;
  7150. }
  7151. switch (kindOf(val)) {
  7152. case 'string':
  7153. str = str.replace(/\s+$/, options.trailingNewline);
  7154. break;
  7155. case 'function':
  7156. str = options.trailingNewline(str);
  7157. break;
  7158. case 'undefined':
  7159. case 'boolean':
  7160. default: {
  7161. str = str.replace(/\s+$/, '\n');
  7162. break;
  7163. }
  7164. }
  7165. return str;
  7166. }
  7167. var defaults = {
  7168. unformatted: ['code', 'pre', 'em', 'strong', 'span'],
  7169. indent_inner_html: true,
  7170. indent_char: ' ',
  7171. indent_size: 2,
  7172. sep: '\n'
  7173. };
  7174. var pretty = function pretty(str, options) {
  7175. var opts = extendShallow({}, defaults, options);
  7176. str = js$1.html(str, opts);
  7177. if (opts.ocd === true) {
  7178. if (opts.newlines) { opts.sep = opts.newlines; }
  7179. return ocd(str, opts);
  7180. }
  7181. return str;
  7182. };
  7183. function ocd(str, options) {
  7184. // Normalize and condense all newlines
  7185. return condenseNewlines(str, options)
  7186. // Remove empty whitespace the top of a file.
  7187. .replace(/^\s+/g, '')
  7188. // Remove extra whitespace from eof
  7189. .replace(/\s+$/g, '\n')
  7190. // Add a space above each comment
  7191. .replace(/(\s*<!--)/g, '\n$1')
  7192. // Bring closing comments up to the same line as closing tag.
  7193. .replace(/>(\s*)(?=<!--\s*\/)/g, '> ');
  7194. }
  7195. //
  7196. function getSelectorType(selector) {
  7197. if (isDomSelector(selector)) { return DOM_SELECTOR }
  7198. if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
  7199. if (isNameSelector(selector)) { return NAME_SELECTOR }
  7200. if (isRefSelector(selector)) { return REF_SELECTOR }
  7201. return INVALID_SELECTOR
  7202. }
  7203. function getSelector(
  7204. selector,
  7205. methodName
  7206. ) {
  7207. var type = getSelectorType(selector);
  7208. if (type === INVALID_SELECTOR) {
  7209. throwError(
  7210. "wrapper." + methodName + "() must be passed a valid CSS selector, Vue " +
  7211. "constructor, or valid find option object"
  7212. );
  7213. }
  7214. return {
  7215. type: type,
  7216. value: selector
  7217. }
  7218. }
  7219. //
  7220. var WrapperArray = function WrapperArray(wrappers) {
  7221. var length = wrappers.length;
  7222. // $FlowIgnore
  7223. Object.defineProperty(this, 'wrappers', {
  7224. get: function () { return wrappers; },
  7225. set: function () { return throwError('wrapperArray.wrappers is read-only'); }
  7226. });
  7227. // $FlowIgnore
  7228. Object.defineProperty(this, 'length', {
  7229. get: function () { return length; },
  7230. set: function () { return throwError('wrapperArray.length is read-only'); }
  7231. });
  7232. };
  7233. WrapperArray.prototype.at = function at (index) {
  7234. var normalizedIndex = index < 0 ? this.length + index : index;
  7235. if (normalizedIndex > this.length - 1 || normalizedIndex < 0) {
  7236. var error = "no item exists at " + index;
  7237. error += index < 0 ? (" (normalized to " + normalizedIndex + ")") : '';
  7238. throwError(error);
  7239. }
  7240. return this.wrappers[normalizedIndex]
  7241. };
  7242. WrapperArray.prototype.attributes = function attributes () {
  7243. this.throwErrorIfWrappersIsEmpty('attributes');
  7244. throwError(
  7245. "attributes must be called on a single wrapper, use " +
  7246. "at(i) to access a wrapper"
  7247. );
  7248. };
  7249. WrapperArray.prototype.classes = function classes () {
  7250. this.throwErrorIfWrappersIsEmpty('classes');
  7251. throwError(
  7252. "classes must be called on a single wrapper, use " +
  7253. "at(i) to access a wrapper"
  7254. );
  7255. };
  7256. WrapperArray.prototype.contains = function contains (selector) {
  7257. this.throwErrorIfWrappersIsEmpty('contains');
  7258. return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
  7259. };
  7260. WrapperArray.prototype.exists = function exists () {
  7261. return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
  7262. };
  7263. WrapperArray.prototype.filter = function filter (predicate) {
  7264. return new WrapperArray(this.wrappers.filter(predicate))
  7265. };
  7266. WrapperArray.prototype.emitted = function emitted () {
  7267. this.throwErrorIfWrappersIsEmpty('emitted');
  7268. throwError(
  7269. "emitted must be called on a single wrapper, use " +
  7270. "at(i) to access a wrapper"
  7271. );
  7272. };
  7273. WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
  7274. this.throwErrorIfWrappersIsEmpty('emittedByOrder');
  7275. throwError(
  7276. "emittedByOrder must be called on a single wrapper, " +
  7277. "use at(i) to access a wrapper"
  7278. );
  7279. };
  7280. WrapperArray.prototype.findAll = function findAll () {
  7281. this.throwErrorIfWrappersIsEmpty('findAll');
  7282. throwError(
  7283. "findAll must be called on a single wrapper, use " +
  7284. "at(i) to access a wrapper"
  7285. );
  7286. };
  7287. WrapperArray.prototype.find = function find () {
  7288. this.throwErrorIfWrappersIsEmpty('find');
  7289. throwError(
  7290. "find must be called on a single wrapper, use at(i) " +
  7291. "to access a wrapper"
  7292. );
  7293. };
  7294. WrapperArray.prototype.html = function html () {
  7295. this.throwErrorIfWrappersIsEmpty('html');
  7296. throwError(
  7297. "html must be called on a single wrapper, use at(i) " +
  7298. "to access a wrapper"
  7299. );
  7300. };
  7301. WrapperArray.prototype.is = function is (selector) {
  7302. this.throwErrorIfWrappersIsEmpty('is');
  7303. return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
  7304. };
  7305. WrapperArray.prototype.isEmpty = function isEmpty () {
  7306. this.throwErrorIfWrappersIsEmpty('isEmpty');
  7307. return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
  7308. };
  7309. WrapperArray.prototype.isVisible = function isVisible () {
  7310. this.throwErrorIfWrappersIsEmpty('isVisible');
  7311. return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
  7312. };
  7313. WrapperArray.prototype.isVueInstance = function isVueInstance () {
  7314. this.throwErrorIfWrappersIsEmpty('isVueInstance');
  7315. return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
  7316. };
  7317. WrapperArray.prototype.name = function name () {
  7318. this.throwErrorIfWrappersIsEmpty('name');
  7319. throwError(
  7320. "name must be called on a single wrapper, use at(i) " +
  7321. "to access a wrapper"
  7322. );
  7323. };
  7324. WrapperArray.prototype.overview = function overview () {
  7325. this.throwErrorIfWrappersIsEmpty('overview()');
  7326. throwError(
  7327. "overview() must be called on a single wrapper, use at(i) " +
  7328. "to access a wrapper"
  7329. );
  7330. };
  7331. WrapperArray.prototype.props = function props () {
  7332. this.throwErrorIfWrappersIsEmpty('props');
  7333. throwError(
  7334. "props must be called on a single wrapper, use " +
  7335. "at(i) to access a wrapper"
  7336. );
  7337. };
  7338. WrapperArray.prototype.text = function text () {
  7339. this.throwErrorIfWrappersIsEmpty('text');
  7340. throwError(
  7341. "text must be called on a single wrapper, use at(i) " +
  7342. "to access a wrapper"
  7343. );
  7344. };
  7345. WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
  7346. if (this.wrappers.length === 0) {
  7347. throwError((method + " cannot be called on 0 items"));
  7348. }
  7349. };
  7350. WrapperArray.prototype.setData = function setData (data) {
  7351. this.throwErrorIfWrappersIsEmpty('setData');
  7352. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setData(data); }))
  7353. };
  7354. WrapperArray.prototype.setMethods = function setMethods (props) {
  7355. this.throwErrorIfWrappersIsEmpty('setMethods');
  7356. this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
  7357. };
  7358. WrapperArray.prototype.setProps = function setProps (props) {
  7359. this.throwErrorIfWrappersIsEmpty('setProps');
  7360. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setProps(props); }))
  7361. };
  7362. WrapperArray.prototype.setValue = function setValue (value) {
  7363. this.throwErrorIfWrappersIsEmpty('setValue');
  7364. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setValue(value); }))
  7365. };
  7366. WrapperArray.prototype.setChecked = function setChecked (checked) {
  7367. if ( checked === void 0 ) checked = true;
  7368. this.throwErrorIfWrappersIsEmpty('setChecked');
  7369. return Promise.all(
  7370. this.wrappers.map(function (wrapper) { return wrapper.setChecked(checked); })
  7371. )
  7372. };
  7373. WrapperArray.prototype.setSelected = function setSelected () {
  7374. this.throwErrorIfWrappersIsEmpty('setSelected');
  7375. throwError(
  7376. "setSelected must be called on a single wrapper, " +
  7377. "use at(i) to access a wrapper"
  7378. );
  7379. };
  7380. WrapperArray.prototype.trigger = function trigger (event, options) {
  7381. this.throwErrorIfWrappersIsEmpty('trigger');
  7382. return Promise.all(
  7383. this.wrappers.map(function (wrapper) { return wrapper.trigger(event, options); })
  7384. )
  7385. };
  7386. WrapperArray.prototype.destroy = function destroy () {
  7387. this.throwErrorIfWrappersIsEmpty('destroy');
  7388. this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
  7389. };
  7390. //
  7391. var buildSelectorString = function (selector) {
  7392. if (getSelectorType(selector) === REF_SELECTOR) {
  7393. return ("ref=\"" + (selector.value.ref) + "\"")
  7394. }
  7395. if (typeof selector === 'string') {
  7396. return selector
  7397. }
  7398. return 'Component'
  7399. };
  7400. var ErrorWrapper = function ErrorWrapper(selector) {
  7401. this.selector = selector;
  7402. };
  7403. ErrorWrapper.prototype.at = function at () {
  7404. throwError(
  7405. ("find did not return " + (buildSelectorString(
  7406. this.selector
  7407. )) + ", cannot call at() on empty Wrapper")
  7408. );
  7409. };
  7410. ErrorWrapper.prototype.attributes = function attributes () {
  7411. throwError(
  7412. ("find did not return " + (buildSelectorString(
  7413. this.selector
  7414. )) + ", cannot call attributes() on empty Wrapper")
  7415. );
  7416. };
  7417. ErrorWrapper.prototype.classes = function classes () {
  7418. throwError(
  7419. ("find did not return " + (buildSelectorString(
  7420. this.selector
  7421. )) + ", cannot call classes() on empty Wrapper")
  7422. );
  7423. };
  7424. ErrorWrapper.prototype.contains = function contains () {
  7425. throwError(
  7426. ("find did not return " + (buildSelectorString(
  7427. this.selector
  7428. )) + ", cannot call contains() on empty Wrapper")
  7429. );
  7430. };
  7431. ErrorWrapper.prototype.emitted = function emitted () {
  7432. throwError(
  7433. ("find did not return " + (buildSelectorString(
  7434. this.selector
  7435. )) + ", cannot call emitted() on empty Wrapper")
  7436. );
  7437. };
  7438. ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
  7439. throwError(
  7440. ("find did not return " + (buildSelectorString(
  7441. this.selector
  7442. )) + ", cannot call emittedByOrder() on empty Wrapper")
  7443. );
  7444. };
  7445. ErrorWrapper.prototype.exists = function exists () {
  7446. return false
  7447. };
  7448. ErrorWrapper.prototype.filter = function filter () {
  7449. throwError(
  7450. ("find did not return " + (buildSelectorString(
  7451. this.selector
  7452. )) + ", cannot call filter() on empty Wrapper")
  7453. );
  7454. };
  7455. ErrorWrapper.prototype.visible = function visible () {
  7456. throwError(
  7457. ("find did not return " + (buildSelectorString(
  7458. this.selector
  7459. )) + ", cannot call visible() on empty Wrapper")
  7460. );
  7461. };
  7462. ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
  7463. throwError(
  7464. ("find did not return " + (buildSelectorString(
  7465. this.selector
  7466. )) + ", cannot call hasAttribute() on empty Wrapper")
  7467. );
  7468. };
  7469. ErrorWrapper.prototype.hasClass = function hasClass () {
  7470. throwError(
  7471. ("find did not return " + (buildSelectorString(
  7472. this.selector
  7473. )) + ", cannot call hasClass() on empty Wrapper")
  7474. );
  7475. };
  7476. ErrorWrapper.prototype.hasProp = function hasProp () {
  7477. throwError(
  7478. ("find did not return " + (buildSelectorString(
  7479. this.selector
  7480. )) + ", cannot call hasProp() on empty Wrapper")
  7481. );
  7482. };
  7483. ErrorWrapper.prototype.hasStyle = function hasStyle () {
  7484. throwError(
  7485. ("find did not return " + (buildSelectorString(
  7486. this.selector
  7487. )) + ", cannot call hasStyle() on empty Wrapper")
  7488. );
  7489. };
  7490. ErrorWrapper.prototype.findAll = function findAll () {
  7491. throwError(
  7492. ("find did not return " + (buildSelectorString(
  7493. this.selector
  7494. )) + ", cannot call findAll() on empty Wrapper")
  7495. );
  7496. };
  7497. ErrorWrapper.prototype.find = function find () {
  7498. throwError(
  7499. ("find did not return " + (buildSelectorString(
  7500. this.selector
  7501. )) + ", cannot call find() on empty Wrapper")
  7502. );
  7503. };
  7504. ErrorWrapper.prototype.html = function html () {
  7505. throwError(
  7506. ("find did not return " + (buildSelectorString(
  7507. this.selector
  7508. )) + ", cannot call html() on empty Wrapper")
  7509. );
  7510. };
  7511. ErrorWrapper.prototype.is = function is () {
  7512. throwError(
  7513. ("find did not return " + (buildSelectorString(
  7514. this.selector
  7515. )) + ", cannot call is() on empty Wrapper")
  7516. );
  7517. };
  7518. ErrorWrapper.prototype.isEmpty = function isEmpty () {
  7519. throwError(
  7520. ("find did not return " + (buildSelectorString(
  7521. this.selector
  7522. )) + ", cannot call isEmpty() on empty Wrapper")
  7523. );
  7524. };
  7525. ErrorWrapper.prototype.isVisible = function isVisible () {
  7526. throwError(
  7527. ("find did not return " + (buildSelectorString(
  7528. this.selector
  7529. )) + ", cannot call isVisible() on empty Wrapper")
  7530. );
  7531. };
  7532. ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
  7533. throwError(
  7534. ("find did not return " + (buildSelectorString(
  7535. this.selector
  7536. )) + ", cannot call isVueInstance() on empty Wrapper")
  7537. );
  7538. };
  7539. ErrorWrapper.prototype.name = function name () {
  7540. throwError(
  7541. ("find did not return " + (buildSelectorString(
  7542. this.selector
  7543. )) + ", cannot call name() on empty Wrapper")
  7544. );
  7545. };
  7546. ErrorWrapper.prototype.overview = function overview () {
  7547. throwError(
  7548. ("find did not return " + (buildSelectorString(
  7549. this.selector
  7550. )) + ", cannot call overview() on empty Wrapper")
  7551. );
  7552. };
  7553. ErrorWrapper.prototype.props = function props () {
  7554. throwError(
  7555. ("find did not return " + (buildSelectorString(
  7556. this.selector
  7557. )) + ", cannot call props() on empty Wrapper")
  7558. );
  7559. };
  7560. ErrorWrapper.prototype.text = function text () {
  7561. throwError(
  7562. ("find did not return " + (buildSelectorString(
  7563. this.selector
  7564. )) + ", cannot call text() on empty Wrapper")
  7565. );
  7566. };
  7567. ErrorWrapper.prototype.setComputed = function setComputed () {
  7568. throwError(
  7569. ("find did not return " + (buildSelectorString(
  7570. this.selector
  7571. )) + ", cannot call setComputed() on empty Wrapper")
  7572. );
  7573. };
  7574. ErrorWrapper.prototype.setData = function setData () {
  7575. throwError(
  7576. ("find did not return " + (buildSelectorString(
  7577. this.selector
  7578. )) + ", cannot call setData() on empty Wrapper")
  7579. );
  7580. };
  7581. ErrorWrapper.prototype.setMethods = function setMethods () {
  7582. throwError(
  7583. ("find did not return " + (buildSelectorString(
  7584. this.selector
  7585. )) + ", cannot call setMethods() on empty Wrapper")
  7586. );
  7587. };
  7588. ErrorWrapper.prototype.setProps = function setProps () {
  7589. throwError(
  7590. ("find did not return " + (buildSelectorString(
  7591. this.selector
  7592. )) + ", cannot call setProps() on empty Wrapper")
  7593. );
  7594. };
  7595. ErrorWrapper.prototype.setValue = function setValue () {
  7596. throwError(
  7597. ("find did not return " + (buildSelectorString(
  7598. this.selector
  7599. )) + ", cannot call setValue() on empty Wrapper")
  7600. );
  7601. };
  7602. ErrorWrapper.prototype.setChecked = function setChecked () {
  7603. throwError(
  7604. ("find did not return " + (buildSelectorString(
  7605. this.selector
  7606. )) + ", cannot call setChecked() on empty Wrapper")
  7607. );
  7608. };
  7609. ErrorWrapper.prototype.setSelected = function setSelected () {
  7610. throwError(
  7611. ("find did not return " + (buildSelectorString(
  7612. this.selector
  7613. )) + ", cannot call setSelected() on empty Wrapper")
  7614. );
  7615. };
  7616. ErrorWrapper.prototype.trigger = function trigger () {
  7617. throwError(
  7618. ("find did not return " + (buildSelectorString(
  7619. this.selector
  7620. )) + ", cannot call trigger() on empty Wrapper")
  7621. );
  7622. };
  7623. ErrorWrapper.prototype.destroy = function destroy () {
  7624. throwError(
  7625. ("find did not return " + (buildSelectorString(
  7626. this.selector
  7627. )) + ", cannot call destroy() on empty Wrapper")
  7628. );
  7629. };
  7630. /*!
  7631. * isElementVisible
  7632. * Ported from https://github.com/testing-library/jest-dom
  7633. * Licensed under the MIT License.
  7634. */
  7635. function isStyleVisible(element) {
  7636. var ref = element.style;
  7637. var display = ref.display;
  7638. var visibility = ref.visibility;
  7639. var opacity = ref.opacity;
  7640. return (
  7641. display !== 'none' &&
  7642. visibility !== 'hidden' &&
  7643. visibility !== 'collapse' &&
  7644. opacity !== '0' &&
  7645. opacity !== 0
  7646. )
  7647. }
  7648. function isAttributeVisible(element, previousElement) {
  7649. return (
  7650. !element.hasAttribute('hidden') &&
  7651. (element.nodeName === 'DETAILS' && previousElement.nodeName !== 'SUMMARY'
  7652. ? element.hasAttribute('open')
  7653. : true)
  7654. )
  7655. }
  7656. function isElementVisible(element, previousElement) {
  7657. return (
  7658. element.nodeName !== '#comment' &&
  7659. isStyleVisible(element) &&
  7660. isAttributeVisible(element, previousElement) &&
  7661. (!element.parentElement || isElementVisible(element.parentElement, element))
  7662. )
  7663. }
  7664. function recursivelySetData(vm, target, data) {
  7665. Object.keys(data).forEach(function (key) {
  7666. var val = data[key];
  7667. var targetVal = target[key];
  7668. if (
  7669. isPlainObject(val) &&
  7670. isPlainObject(targetVal) &&
  7671. Object.keys(val).length > 0
  7672. ) {
  7673. recursivelySetData(vm, targetVal, val);
  7674. } else {
  7675. vm.$set(target, key, val);
  7676. }
  7677. });
  7678. }
  7679. var abort = {
  7680. eventInterface: "Event",
  7681. bubbles: false,
  7682. cancelable: false
  7683. };
  7684. var afterprint = {
  7685. eventInterface: "Event",
  7686. bubbles: false,
  7687. cancelable: false
  7688. };
  7689. var animationend = {
  7690. eventInterface: "AnimationEvent",
  7691. bubbles: true,
  7692. cancelable: false
  7693. };
  7694. var animationiteration = {
  7695. eventInterface: "AnimationEvent",
  7696. bubbles: true,
  7697. cancelable: false
  7698. };
  7699. var animationstart = {
  7700. eventInterface: "AnimationEvent",
  7701. bubbles: true,
  7702. cancelable: false
  7703. };
  7704. var appinstalled = {
  7705. eventInterface: "Event",
  7706. bubbles: false,
  7707. cancelable: false
  7708. };
  7709. var audioprocess = {
  7710. eventInterface: "AudioProcessingEvent"
  7711. };
  7712. var audioend = {
  7713. eventInterface: "Event",
  7714. bubbles: false,
  7715. cancelable: false
  7716. };
  7717. var audiostart = {
  7718. eventInterface: "Event",
  7719. bubbles: false,
  7720. cancelable: false
  7721. };
  7722. var beforeprint = {
  7723. eventInterface: "Event",
  7724. bubbles: false,
  7725. cancelable: false
  7726. };
  7727. var beforeunload = {
  7728. eventInterface: "BeforeUnloadEvent",
  7729. bubbles: false,
  7730. cancelable: true
  7731. };
  7732. var beginEvent = {
  7733. eventInterface: "TimeEvent",
  7734. bubbles: false,
  7735. cancelable: false
  7736. };
  7737. var blur = {
  7738. eventInterface: "FocusEvent",
  7739. bubbles: false,
  7740. cancelable: false
  7741. };
  7742. var boundary = {
  7743. eventInterface: "SpeechSynthesisEvent",
  7744. bubbles: false,
  7745. cancelable: false
  7746. };
  7747. var cached = {
  7748. eventInterface: "Event",
  7749. bubbles: false,
  7750. cancelable: false
  7751. };
  7752. var canplay = {
  7753. eventInterface: "Event",
  7754. bubbles: false,
  7755. cancelable: false
  7756. };
  7757. var canplaythrough = {
  7758. eventInterface: "Event",
  7759. bubbles: false,
  7760. cancelable: false
  7761. };
  7762. var change = {
  7763. eventInterface: "Event",
  7764. bubbles: true,
  7765. cancelable: false
  7766. };
  7767. var chargingchange = {
  7768. eventInterface: "Event",
  7769. bubbles: false,
  7770. cancelable: false
  7771. };
  7772. var chargingtimechange = {
  7773. eventInterface: "Event",
  7774. bubbles: false,
  7775. cancelable: false
  7776. };
  7777. var checking = {
  7778. eventInterface: "Event",
  7779. bubbles: false,
  7780. cancelable: false
  7781. };
  7782. var click = {
  7783. eventInterface: "MouseEvent",
  7784. bubbles: true,
  7785. cancelable: true
  7786. };
  7787. var close = {
  7788. eventInterface: "Event",
  7789. bubbles: false,
  7790. cancelable: false
  7791. };
  7792. var complete = {
  7793. eventInterface: "OfflineAudioCompletionEvent"
  7794. };
  7795. var compositionend = {
  7796. eventInterface: "CompositionEvent",
  7797. bubbles: true,
  7798. cancelable: true
  7799. };
  7800. var compositionstart = {
  7801. eventInterface: "CompositionEvent",
  7802. bubbles: true,
  7803. cancelable: true
  7804. };
  7805. var compositionupdate = {
  7806. eventInterface: "CompositionEvent",
  7807. bubbles: true,
  7808. cancelable: false
  7809. };
  7810. var contextmenu = {
  7811. eventInterface: "MouseEvent",
  7812. bubbles: true,
  7813. cancelable: true
  7814. };
  7815. var copy = {
  7816. eventInterface: "ClipboardEvent"
  7817. };
  7818. var cut = {
  7819. eventInterface: "ClipboardEvent",
  7820. bubbles: true,
  7821. cancelable: true
  7822. };
  7823. var dblclick = {
  7824. eventInterface: "MouseEvent",
  7825. bubbles: true,
  7826. cancelable: true
  7827. };
  7828. var devicechange = {
  7829. eventInterface: "Event",
  7830. bubbles: false,
  7831. cancelable: false
  7832. };
  7833. var devicelight = {
  7834. eventInterface: "DeviceLightEvent",
  7835. bubbles: false,
  7836. cancelable: false
  7837. };
  7838. var devicemotion = {
  7839. eventInterface: "DeviceMotionEvent",
  7840. bubbles: false,
  7841. cancelable: false
  7842. };
  7843. var deviceorientation = {
  7844. eventInterface: "DeviceOrientationEvent",
  7845. bubbles: false,
  7846. cancelable: false
  7847. };
  7848. var deviceproximity = {
  7849. eventInterface: "DeviceProximityEvent",
  7850. bubbles: false,
  7851. cancelable: false
  7852. };
  7853. var dischargingtimechange = {
  7854. eventInterface: "Event",
  7855. bubbles: false,
  7856. cancelable: false
  7857. };
  7858. var DOMActivate = {
  7859. eventInterface: "UIEvent",
  7860. bubbles: true,
  7861. cancelable: true
  7862. };
  7863. var DOMAttributeNameChanged = {
  7864. eventInterface: "MutationNameEvent",
  7865. bubbles: true,
  7866. cancelable: true
  7867. };
  7868. var DOMAttrModified = {
  7869. eventInterface: "MutationEvent",
  7870. bubbles: true,
  7871. cancelable: true
  7872. };
  7873. var DOMCharacterDataModified = {
  7874. eventInterface: "MutationEvent",
  7875. bubbles: true,
  7876. cancelable: true
  7877. };
  7878. var DOMContentLoaded = {
  7879. eventInterface: "Event",
  7880. bubbles: true,
  7881. cancelable: true
  7882. };
  7883. var DOMElementNameChanged = {
  7884. eventInterface: "MutationNameEvent",
  7885. bubbles: true,
  7886. cancelable: true
  7887. };
  7888. var DOMFocusIn = {
  7889. eventInterface: "FocusEvent",
  7890. bubbles: true,
  7891. cancelable: true
  7892. };
  7893. var DOMFocusOut = {
  7894. eventInterface: "FocusEvent",
  7895. bubbles: true,
  7896. cancelable: true
  7897. };
  7898. var DOMNodeInserted = {
  7899. eventInterface: "MutationEvent",
  7900. bubbles: true,
  7901. cancelable: true
  7902. };
  7903. var DOMNodeInsertedIntoDocument = {
  7904. eventInterface: "MutationEvent",
  7905. bubbles: true,
  7906. cancelable: true
  7907. };
  7908. var DOMNodeRemoved = {
  7909. eventInterface: "MutationEvent",
  7910. bubbles: true,
  7911. cancelable: true
  7912. };
  7913. var DOMNodeRemovedFromDocument = {
  7914. eventInterface: "MutationEvent",
  7915. bubbles: true,
  7916. cancelable: true
  7917. };
  7918. var DOMSubtreeModified = {
  7919. eventInterface: "MutationEvent"
  7920. };
  7921. var downloading = {
  7922. eventInterface: "Event",
  7923. bubbles: false,
  7924. cancelable: false
  7925. };
  7926. var drag = {
  7927. eventInterface: "DragEvent",
  7928. bubbles: true,
  7929. cancelable: true
  7930. };
  7931. var dragend = {
  7932. eventInterface: "DragEvent",
  7933. bubbles: true,
  7934. cancelable: false
  7935. };
  7936. var dragenter = {
  7937. eventInterface: "DragEvent",
  7938. bubbles: true,
  7939. cancelable: true
  7940. };
  7941. var dragleave = {
  7942. eventInterface: "DragEvent",
  7943. bubbles: true,
  7944. cancelable: false
  7945. };
  7946. var dragover = {
  7947. eventInterface: "DragEvent",
  7948. bubbles: true,
  7949. cancelable: true
  7950. };
  7951. var dragstart = {
  7952. eventInterface: "DragEvent",
  7953. bubbles: true,
  7954. cancelable: true
  7955. };
  7956. var drop = {
  7957. eventInterface: "DragEvent",
  7958. bubbles: true,
  7959. cancelable: true
  7960. };
  7961. var durationchange = {
  7962. eventInterface: "Event",
  7963. bubbles: false,
  7964. cancelable: false
  7965. };
  7966. var emptied = {
  7967. eventInterface: "Event",
  7968. bubbles: false,
  7969. cancelable: false
  7970. };
  7971. var end = {
  7972. eventInterface: "Event",
  7973. bubbles: false,
  7974. cancelable: false
  7975. };
  7976. var ended = {
  7977. eventInterface: "Event",
  7978. bubbles: false,
  7979. cancelable: false
  7980. };
  7981. var endEvent = {
  7982. eventInterface: "TimeEvent",
  7983. bubbles: false,
  7984. cancelable: false
  7985. };
  7986. var error = {
  7987. eventInterface: "Event",
  7988. bubbles: false,
  7989. cancelable: false
  7990. };
  7991. var focus = {
  7992. eventInterface: "FocusEvent",
  7993. bubbles: false,
  7994. cancelable: false
  7995. };
  7996. var focusin = {
  7997. eventInterface: "FocusEvent",
  7998. bubbles: true,
  7999. cancelable: false
  8000. };
  8001. var focusout = {
  8002. eventInterface: "FocusEvent",
  8003. bubbles: true,
  8004. cancelable: false
  8005. };
  8006. var fullscreenchange = {
  8007. eventInterface: "Event",
  8008. bubbles: true,
  8009. cancelable: false
  8010. };
  8011. var fullscreenerror = {
  8012. eventInterface: "Event",
  8013. bubbles: true,
  8014. cancelable: false
  8015. };
  8016. var gamepadconnected = {
  8017. eventInterface: "GamepadEvent",
  8018. bubbles: false,
  8019. cancelable: false
  8020. };
  8021. var gamepaddisconnected = {
  8022. eventInterface: "GamepadEvent",
  8023. bubbles: false,
  8024. cancelable: false
  8025. };
  8026. var gotpointercapture = {
  8027. eventInterface: "PointerEvent",
  8028. bubbles: false,
  8029. cancelable: false
  8030. };
  8031. var hashchange = {
  8032. eventInterface: "HashChangeEvent",
  8033. bubbles: true,
  8034. cancelable: false
  8035. };
  8036. var lostpointercapture = {
  8037. eventInterface: "PointerEvent",
  8038. bubbles: false,
  8039. cancelable: false
  8040. };
  8041. var input = {
  8042. eventInterface: "Event",
  8043. bubbles: true,
  8044. cancelable: false
  8045. };
  8046. var invalid = {
  8047. eventInterface: "Event",
  8048. cancelable: true,
  8049. bubbles: false
  8050. };
  8051. var keydown = {
  8052. eventInterface: "KeyboardEvent",
  8053. bubbles: true,
  8054. cancelable: true
  8055. };
  8056. var keypress = {
  8057. eventInterface: "KeyboardEvent",
  8058. bubbles: true,
  8059. cancelable: true
  8060. };
  8061. var keyup = {
  8062. eventInterface: "KeyboardEvent",
  8063. bubbles: true,
  8064. cancelable: true
  8065. };
  8066. var languagechange = {
  8067. eventInterface: "Event",
  8068. bubbles: false,
  8069. cancelable: false
  8070. };
  8071. var levelchange = {
  8072. eventInterface: "Event",
  8073. bubbles: false,
  8074. cancelable: false
  8075. };
  8076. var load = {
  8077. eventInterface: "UIEvent",
  8078. bubbles: false,
  8079. cancelable: false
  8080. };
  8081. var loadeddata = {
  8082. eventInterface: "Event",
  8083. bubbles: false,
  8084. cancelable: false
  8085. };
  8086. var loadedmetadata = {
  8087. eventInterface: "Event",
  8088. bubbles: false,
  8089. cancelable: false
  8090. };
  8091. var loadend = {
  8092. eventInterface: "ProgressEvent",
  8093. bubbles: false,
  8094. cancelable: false
  8095. };
  8096. var loadstart = {
  8097. eventInterface: "ProgressEvent",
  8098. bubbles: false,
  8099. cancelable: false
  8100. };
  8101. var mark = {
  8102. eventInterface: "SpeechSynthesisEvent",
  8103. bubbles: false,
  8104. cancelable: false
  8105. };
  8106. var message = {
  8107. eventInterface: "MessageEvent",
  8108. bubbles: false,
  8109. cancelable: false
  8110. };
  8111. var messageerror = {
  8112. eventInterface: "MessageEvent",
  8113. bubbles: false,
  8114. cancelable: false
  8115. };
  8116. var mousedown = {
  8117. eventInterface: "MouseEvent",
  8118. bubbles: true,
  8119. cancelable: true
  8120. };
  8121. var mouseenter = {
  8122. eventInterface: "MouseEvent",
  8123. bubbles: false,
  8124. cancelable: false
  8125. };
  8126. var mouseleave = {
  8127. eventInterface: "MouseEvent",
  8128. bubbles: false,
  8129. cancelable: false
  8130. };
  8131. var mousemove = {
  8132. eventInterface: "MouseEvent",
  8133. bubbles: true,
  8134. cancelable: true
  8135. };
  8136. var mouseout = {
  8137. eventInterface: "MouseEvent",
  8138. bubbles: true,
  8139. cancelable: true
  8140. };
  8141. var mouseover = {
  8142. eventInterface: "MouseEvent",
  8143. bubbles: true,
  8144. cancelable: true
  8145. };
  8146. var mouseup = {
  8147. eventInterface: "MouseEvent",
  8148. bubbles: true,
  8149. cancelable: true
  8150. };
  8151. var nomatch = {
  8152. eventInterface: "SpeechRecognitionEvent",
  8153. bubbles: false,
  8154. cancelable: false
  8155. };
  8156. var notificationclick = {
  8157. eventInterface: "NotificationEvent",
  8158. bubbles: false,
  8159. cancelable: false
  8160. };
  8161. var noupdate = {
  8162. eventInterface: "Event",
  8163. bubbles: false,
  8164. cancelable: false
  8165. };
  8166. var obsolete = {
  8167. eventInterface: "Event",
  8168. bubbles: false,
  8169. cancelable: false
  8170. };
  8171. var offline = {
  8172. eventInterface: "Event",
  8173. bubbles: false,
  8174. cancelable: false
  8175. };
  8176. var online = {
  8177. eventInterface: "Event",
  8178. bubbles: false,
  8179. cancelable: false
  8180. };
  8181. var open = {
  8182. eventInterface: "Event",
  8183. bubbles: false,
  8184. cancelable: false
  8185. };
  8186. var orientationchange = {
  8187. eventInterface: "Event",
  8188. bubbles: false,
  8189. cancelable: false
  8190. };
  8191. var pagehide = {
  8192. eventInterface: "PageTransitionEvent",
  8193. bubbles: false,
  8194. cancelable: false
  8195. };
  8196. var pageshow = {
  8197. eventInterface: "PageTransitionEvent",
  8198. bubbles: false,
  8199. cancelable: false
  8200. };
  8201. var paste = {
  8202. eventInterface: "ClipboardEvent",
  8203. bubbles: true,
  8204. cancelable: true
  8205. };
  8206. var pause = {
  8207. eventInterface: "SpeechSynthesisEvent",
  8208. bubbles: false,
  8209. cancelable: false
  8210. };
  8211. var pointercancel = {
  8212. eventInterface: "PointerEvent",
  8213. bubbles: true,
  8214. cancelable: false
  8215. };
  8216. var pointerdown = {
  8217. eventInterface: "PointerEvent",
  8218. bubbles: true,
  8219. cancelable: true
  8220. };
  8221. var pointerenter = {
  8222. eventInterface: "PointerEvent",
  8223. bubbles: false,
  8224. cancelable: false
  8225. };
  8226. var pointerleave = {
  8227. eventInterface: "PointerEvent",
  8228. bubbles: false,
  8229. cancelable: false
  8230. };
  8231. var pointerlockchange = {
  8232. eventInterface: "Event",
  8233. bubbles: true,
  8234. cancelable: false
  8235. };
  8236. var pointerlockerror = {
  8237. eventInterface: "Event",
  8238. bubbles: true,
  8239. cancelable: false
  8240. };
  8241. var pointermove = {
  8242. eventInterface: "PointerEvent",
  8243. bubbles: true,
  8244. cancelable: true
  8245. };
  8246. var pointerout = {
  8247. eventInterface: "PointerEvent",
  8248. bubbles: true,
  8249. cancelable: true
  8250. };
  8251. var pointerover = {
  8252. eventInterface: "PointerEvent",
  8253. bubbles: true,
  8254. cancelable: true
  8255. };
  8256. var pointerup = {
  8257. eventInterface: "PointerEvent",
  8258. bubbles: true,
  8259. cancelable: true
  8260. };
  8261. var play = {
  8262. eventInterface: "Event",
  8263. bubbles: false,
  8264. cancelable: false
  8265. };
  8266. var playing = {
  8267. eventInterface: "Event",
  8268. bubbles: false,
  8269. cancelable: false
  8270. };
  8271. var popstate = {
  8272. eventInterface: "PopStateEvent",
  8273. bubbles: true,
  8274. cancelable: false
  8275. };
  8276. var progress = {
  8277. eventInterface: "ProgressEvent",
  8278. bubbles: false,
  8279. cancelable: false
  8280. };
  8281. var push = {
  8282. eventInterface: "PushEvent",
  8283. bubbles: false,
  8284. cancelable: false
  8285. };
  8286. var pushsubscriptionchange = {
  8287. eventInterface: "PushEvent",
  8288. bubbles: false,
  8289. cancelable: false
  8290. };
  8291. var ratechange = {
  8292. eventInterface: "Event",
  8293. bubbles: false,
  8294. cancelable: false
  8295. };
  8296. var readystatechange = {
  8297. eventInterface: "Event",
  8298. bubbles: false,
  8299. cancelable: false
  8300. };
  8301. var repeatEvent = {
  8302. eventInterface: "TimeEvent",
  8303. bubbles: false,
  8304. cancelable: false
  8305. };
  8306. var reset = {
  8307. eventInterface: "Event",
  8308. bubbles: true,
  8309. cancelable: true
  8310. };
  8311. var resize = {
  8312. eventInterface: "UIEvent",
  8313. bubbles: false,
  8314. cancelable: false
  8315. };
  8316. var resourcetimingbufferfull = {
  8317. eventInterface: "Performance",
  8318. bubbles: true,
  8319. cancelable: true
  8320. };
  8321. var result = {
  8322. eventInterface: "SpeechRecognitionEvent",
  8323. bubbles: false,
  8324. cancelable: false
  8325. };
  8326. var resume = {
  8327. eventInterface: "SpeechSynthesisEvent",
  8328. bubbles: false,
  8329. cancelable: false
  8330. };
  8331. var scroll = {
  8332. eventInterface: "UIEvent",
  8333. bubbles: false,
  8334. cancelable: false
  8335. };
  8336. var seeked = {
  8337. eventInterface: "Event",
  8338. bubbles: false,
  8339. cancelable: false
  8340. };
  8341. var seeking = {
  8342. eventInterface: "Event",
  8343. bubbles: false,
  8344. cancelable: false
  8345. };
  8346. var select = {
  8347. eventInterface: "UIEvent",
  8348. bubbles: true,
  8349. cancelable: false
  8350. };
  8351. var selectstart = {
  8352. eventInterface: "Event",
  8353. bubbles: true,
  8354. cancelable: true
  8355. };
  8356. var selectionchange = {
  8357. eventInterface: "Event",
  8358. bubbles: false,
  8359. cancelable: false
  8360. };
  8361. var show = {
  8362. eventInterface: "MouseEvent",
  8363. bubbles: false,
  8364. cancelable: false
  8365. };
  8366. var slotchange = {
  8367. eventInterface: "Event",
  8368. bubbles: true,
  8369. cancelable: false
  8370. };
  8371. var soundend = {
  8372. eventInterface: "Event",
  8373. bubbles: false,
  8374. cancelable: false
  8375. };
  8376. var soundstart = {
  8377. eventInterface: "Event",
  8378. bubbles: false,
  8379. cancelable: false
  8380. };
  8381. var speechend = {
  8382. eventInterface: "Event",
  8383. bubbles: false,
  8384. cancelable: false
  8385. };
  8386. var speechstart = {
  8387. eventInterface: "Event",
  8388. bubbles: false,
  8389. cancelable: false
  8390. };
  8391. var stalled = {
  8392. eventInterface: "Event",
  8393. bubbles: false,
  8394. cancelable: false
  8395. };
  8396. var start = {
  8397. eventInterface: "SpeechSynthesisEvent",
  8398. bubbles: false,
  8399. cancelable: false
  8400. };
  8401. var storage = {
  8402. eventInterface: "StorageEvent",
  8403. bubbles: false,
  8404. cancelable: false
  8405. };
  8406. var submit = {
  8407. eventInterface: "Event",
  8408. bubbles: true,
  8409. cancelable: true
  8410. };
  8411. var success = {
  8412. eventInterface: "Event",
  8413. bubbles: false,
  8414. cancelable: false
  8415. };
  8416. var suspend = {
  8417. eventInterface: "Event",
  8418. bubbles: false,
  8419. cancelable: false
  8420. };
  8421. var SVGAbort = {
  8422. eventInterface: "SVGEvent",
  8423. bubbles: true,
  8424. cancelable: false
  8425. };
  8426. var SVGError = {
  8427. eventInterface: "SVGEvent",
  8428. bubbles: true,
  8429. cancelable: false
  8430. };
  8431. var SVGLoad = {
  8432. eventInterface: "SVGEvent",
  8433. bubbles: false,
  8434. cancelable: false
  8435. };
  8436. var SVGResize = {
  8437. eventInterface: "SVGEvent",
  8438. bubbles: true,
  8439. cancelable: false
  8440. };
  8441. var SVGScroll = {
  8442. eventInterface: "SVGEvent",
  8443. bubbles: true,
  8444. cancelable: false
  8445. };
  8446. var SVGUnload = {
  8447. eventInterface: "SVGEvent",
  8448. bubbles: false,
  8449. cancelable: false
  8450. };
  8451. var SVGZoom = {
  8452. eventInterface: "SVGZoomEvent",
  8453. bubbles: true,
  8454. cancelable: false
  8455. };
  8456. var timeout = {
  8457. eventInterface: "ProgressEvent",
  8458. bubbles: false,
  8459. cancelable: false
  8460. };
  8461. var timeupdate = {
  8462. eventInterface: "Event",
  8463. bubbles: false,
  8464. cancelable: false
  8465. };
  8466. var touchcancel = {
  8467. eventInterface: "TouchEvent",
  8468. bubbles: true,
  8469. cancelable: false
  8470. };
  8471. var touchend = {
  8472. eventInterface: "TouchEvent",
  8473. bubbles: true,
  8474. cancelable: true
  8475. };
  8476. var touchmove = {
  8477. eventInterface: "TouchEvent",
  8478. bubbles: true,
  8479. cancelable: true
  8480. };
  8481. var touchstart = {
  8482. eventInterface: "TouchEvent",
  8483. bubbles: true,
  8484. cancelable: true
  8485. };
  8486. var transitionend = {
  8487. eventInterface: "TransitionEvent",
  8488. bubbles: true,
  8489. cancelable: true
  8490. };
  8491. var unload = {
  8492. eventInterface: "UIEvent",
  8493. bubbles: false
  8494. };
  8495. var updateready = {
  8496. eventInterface: "Event",
  8497. bubbles: false,
  8498. cancelable: false
  8499. };
  8500. var userproximity = {
  8501. eventInterface: "UserProximityEvent",
  8502. bubbles: false,
  8503. cancelable: false
  8504. };
  8505. var voiceschanged = {
  8506. eventInterface: "Event",
  8507. bubbles: false,
  8508. cancelable: false
  8509. };
  8510. var visibilitychange = {
  8511. eventInterface: "Event",
  8512. bubbles: true,
  8513. cancelable: false
  8514. };
  8515. var volumechange = {
  8516. eventInterface: "Event",
  8517. bubbles: false,
  8518. cancelable: false
  8519. };
  8520. var waiting = {
  8521. eventInterface: "Event",
  8522. bubbles: false,
  8523. cancelable: false
  8524. };
  8525. var wheel = {
  8526. eventInterface: "WheelEvent",
  8527. bubbles: true,
  8528. cancelable: true
  8529. };
  8530. var domEventTypes = {
  8531. abort: abort,
  8532. afterprint: afterprint,
  8533. animationend: animationend,
  8534. animationiteration: animationiteration,
  8535. animationstart: animationstart,
  8536. appinstalled: appinstalled,
  8537. audioprocess: audioprocess,
  8538. audioend: audioend,
  8539. audiostart: audiostart,
  8540. beforeprint: beforeprint,
  8541. beforeunload: beforeunload,
  8542. beginEvent: beginEvent,
  8543. blur: blur,
  8544. boundary: boundary,
  8545. cached: cached,
  8546. canplay: canplay,
  8547. canplaythrough: canplaythrough,
  8548. change: change,
  8549. chargingchange: chargingchange,
  8550. chargingtimechange: chargingtimechange,
  8551. checking: checking,
  8552. click: click,
  8553. close: close,
  8554. complete: complete,
  8555. compositionend: compositionend,
  8556. compositionstart: compositionstart,
  8557. compositionupdate: compositionupdate,
  8558. contextmenu: contextmenu,
  8559. copy: copy,
  8560. cut: cut,
  8561. dblclick: dblclick,
  8562. devicechange: devicechange,
  8563. devicelight: devicelight,
  8564. devicemotion: devicemotion,
  8565. deviceorientation: deviceorientation,
  8566. deviceproximity: deviceproximity,
  8567. dischargingtimechange: dischargingtimechange,
  8568. DOMActivate: DOMActivate,
  8569. DOMAttributeNameChanged: DOMAttributeNameChanged,
  8570. DOMAttrModified: DOMAttrModified,
  8571. DOMCharacterDataModified: DOMCharacterDataModified,
  8572. DOMContentLoaded: DOMContentLoaded,
  8573. DOMElementNameChanged: DOMElementNameChanged,
  8574. DOMFocusIn: DOMFocusIn,
  8575. DOMFocusOut: DOMFocusOut,
  8576. DOMNodeInserted: DOMNodeInserted,
  8577. DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
  8578. DOMNodeRemoved: DOMNodeRemoved,
  8579. DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
  8580. DOMSubtreeModified: DOMSubtreeModified,
  8581. downloading: downloading,
  8582. drag: drag,
  8583. dragend: dragend,
  8584. dragenter: dragenter,
  8585. dragleave: dragleave,
  8586. dragover: dragover,
  8587. dragstart: dragstart,
  8588. drop: drop,
  8589. durationchange: durationchange,
  8590. emptied: emptied,
  8591. end: end,
  8592. ended: ended,
  8593. endEvent: endEvent,
  8594. error: error,
  8595. focus: focus,
  8596. focusin: focusin,
  8597. focusout: focusout,
  8598. fullscreenchange: fullscreenchange,
  8599. fullscreenerror: fullscreenerror,
  8600. gamepadconnected: gamepadconnected,
  8601. gamepaddisconnected: gamepaddisconnected,
  8602. gotpointercapture: gotpointercapture,
  8603. hashchange: hashchange,
  8604. lostpointercapture: lostpointercapture,
  8605. input: input,
  8606. invalid: invalid,
  8607. keydown: keydown,
  8608. keypress: keypress,
  8609. keyup: keyup,
  8610. languagechange: languagechange,
  8611. levelchange: levelchange,
  8612. load: load,
  8613. loadeddata: loadeddata,
  8614. loadedmetadata: loadedmetadata,
  8615. loadend: loadend,
  8616. loadstart: loadstart,
  8617. mark: mark,
  8618. message: message,
  8619. messageerror: messageerror,
  8620. mousedown: mousedown,
  8621. mouseenter: mouseenter,
  8622. mouseleave: mouseleave,
  8623. mousemove: mousemove,
  8624. mouseout: mouseout,
  8625. mouseover: mouseover,
  8626. mouseup: mouseup,
  8627. nomatch: nomatch,
  8628. notificationclick: notificationclick,
  8629. noupdate: noupdate,
  8630. obsolete: obsolete,
  8631. offline: offline,
  8632. online: online,
  8633. open: open,
  8634. orientationchange: orientationchange,
  8635. pagehide: pagehide,
  8636. pageshow: pageshow,
  8637. paste: paste,
  8638. pause: pause,
  8639. pointercancel: pointercancel,
  8640. pointerdown: pointerdown,
  8641. pointerenter: pointerenter,
  8642. pointerleave: pointerleave,
  8643. pointerlockchange: pointerlockchange,
  8644. pointerlockerror: pointerlockerror,
  8645. pointermove: pointermove,
  8646. pointerout: pointerout,
  8647. pointerover: pointerover,
  8648. pointerup: pointerup,
  8649. play: play,
  8650. playing: playing,
  8651. popstate: popstate,
  8652. progress: progress,
  8653. push: push,
  8654. pushsubscriptionchange: pushsubscriptionchange,
  8655. ratechange: ratechange,
  8656. readystatechange: readystatechange,
  8657. repeatEvent: repeatEvent,
  8658. reset: reset,
  8659. resize: resize,
  8660. resourcetimingbufferfull: resourcetimingbufferfull,
  8661. result: result,
  8662. resume: resume,
  8663. scroll: scroll,
  8664. seeked: seeked,
  8665. seeking: seeking,
  8666. select: select,
  8667. selectstart: selectstart,
  8668. selectionchange: selectionchange,
  8669. show: show,
  8670. slotchange: slotchange,
  8671. soundend: soundend,
  8672. soundstart: soundstart,
  8673. speechend: speechend,
  8674. speechstart: speechstart,
  8675. stalled: stalled,
  8676. start: start,
  8677. storage: storage,
  8678. submit: submit,
  8679. success: success,
  8680. suspend: suspend,
  8681. SVGAbort: SVGAbort,
  8682. SVGError: SVGError,
  8683. SVGLoad: SVGLoad,
  8684. SVGResize: SVGResize,
  8685. SVGScroll: SVGScroll,
  8686. SVGUnload: SVGUnload,
  8687. SVGZoom: SVGZoom,
  8688. timeout: timeout,
  8689. timeupdate: timeupdate,
  8690. touchcancel: touchcancel,
  8691. touchend: touchend,
  8692. touchmove: touchmove,
  8693. touchstart: touchstart,
  8694. transitionend: transitionend,
  8695. unload: unload,
  8696. updateready: updateready,
  8697. userproximity: userproximity,
  8698. voiceschanged: voiceschanged,
  8699. visibilitychange: visibilitychange,
  8700. volumechange: volumechange,
  8701. waiting: waiting,
  8702. wheel: wheel
  8703. };
  8704. var domEventTypes$1 = /*#__PURE__*/Object.freeze({
  8705. __proto__: null,
  8706. abort: abort,
  8707. afterprint: afterprint,
  8708. animationend: animationend,
  8709. animationiteration: animationiteration,
  8710. animationstart: animationstart,
  8711. appinstalled: appinstalled,
  8712. audioprocess: audioprocess,
  8713. audioend: audioend,
  8714. audiostart: audiostart,
  8715. beforeprint: beforeprint,
  8716. beforeunload: beforeunload,
  8717. beginEvent: beginEvent,
  8718. blur: blur,
  8719. boundary: boundary,
  8720. cached: cached,
  8721. canplay: canplay,
  8722. canplaythrough: canplaythrough,
  8723. change: change,
  8724. chargingchange: chargingchange,
  8725. chargingtimechange: chargingtimechange,
  8726. checking: checking,
  8727. click: click,
  8728. close: close,
  8729. complete: complete,
  8730. compositionend: compositionend,
  8731. compositionstart: compositionstart,
  8732. compositionupdate: compositionupdate,
  8733. contextmenu: contextmenu,
  8734. copy: copy,
  8735. cut: cut,
  8736. dblclick: dblclick,
  8737. devicechange: devicechange,
  8738. devicelight: devicelight,
  8739. devicemotion: devicemotion,
  8740. deviceorientation: deviceorientation,
  8741. deviceproximity: deviceproximity,
  8742. dischargingtimechange: dischargingtimechange,
  8743. DOMActivate: DOMActivate,
  8744. DOMAttributeNameChanged: DOMAttributeNameChanged,
  8745. DOMAttrModified: DOMAttrModified,
  8746. DOMCharacterDataModified: DOMCharacterDataModified,
  8747. DOMContentLoaded: DOMContentLoaded,
  8748. DOMElementNameChanged: DOMElementNameChanged,
  8749. DOMFocusIn: DOMFocusIn,
  8750. DOMFocusOut: DOMFocusOut,
  8751. DOMNodeInserted: DOMNodeInserted,
  8752. DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
  8753. DOMNodeRemoved: DOMNodeRemoved,
  8754. DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
  8755. DOMSubtreeModified: DOMSubtreeModified,
  8756. downloading: downloading,
  8757. drag: drag,
  8758. dragend: dragend,
  8759. dragenter: dragenter,
  8760. dragleave: dragleave,
  8761. dragover: dragover,
  8762. dragstart: dragstart,
  8763. drop: drop,
  8764. durationchange: durationchange,
  8765. emptied: emptied,
  8766. end: end,
  8767. ended: ended,
  8768. endEvent: endEvent,
  8769. error: error,
  8770. focus: focus,
  8771. focusin: focusin,
  8772. focusout: focusout,
  8773. fullscreenchange: fullscreenchange,
  8774. fullscreenerror: fullscreenerror,
  8775. gamepadconnected: gamepadconnected,
  8776. gamepaddisconnected: gamepaddisconnected,
  8777. gotpointercapture: gotpointercapture,
  8778. hashchange: hashchange,
  8779. lostpointercapture: lostpointercapture,
  8780. input: input,
  8781. invalid: invalid,
  8782. keydown: keydown,
  8783. keypress: keypress,
  8784. keyup: keyup,
  8785. languagechange: languagechange,
  8786. levelchange: levelchange,
  8787. load: load,
  8788. loadeddata: loadeddata,
  8789. loadedmetadata: loadedmetadata,
  8790. loadend: loadend,
  8791. loadstart: loadstart,
  8792. mark: mark,
  8793. message: message,
  8794. messageerror: messageerror,
  8795. mousedown: mousedown,
  8796. mouseenter: mouseenter,
  8797. mouseleave: mouseleave,
  8798. mousemove: mousemove,
  8799. mouseout: mouseout,
  8800. mouseover: mouseover,
  8801. mouseup: mouseup,
  8802. nomatch: nomatch,
  8803. notificationclick: notificationclick,
  8804. noupdate: noupdate,
  8805. obsolete: obsolete,
  8806. offline: offline,
  8807. online: online,
  8808. open: open,
  8809. orientationchange: orientationchange,
  8810. pagehide: pagehide,
  8811. pageshow: pageshow,
  8812. paste: paste,
  8813. pause: pause,
  8814. pointercancel: pointercancel,
  8815. pointerdown: pointerdown,
  8816. pointerenter: pointerenter,
  8817. pointerleave: pointerleave,
  8818. pointerlockchange: pointerlockchange,
  8819. pointerlockerror: pointerlockerror,
  8820. pointermove: pointermove,
  8821. pointerout: pointerout,
  8822. pointerover: pointerover,
  8823. pointerup: pointerup,
  8824. play: play,
  8825. playing: playing,
  8826. popstate: popstate,
  8827. progress: progress,
  8828. push: push,
  8829. pushsubscriptionchange: pushsubscriptionchange,
  8830. ratechange: ratechange,
  8831. readystatechange: readystatechange,
  8832. repeatEvent: repeatEvent,
  8833. reset: reset,
  8834. resize: resize,
  8835. resourcetimingbufferfull: resourcetimingbufferfull,
  8836. result: result,
  8837. resume: resume,
  8838. scroll: scroll,
  8839. seeked: seeked,
  8840. seeking: seeking,
  8841. select: select,
  8842. selectstart: selectstart,
  8843. selectionchange: selectionchange,
  8844. show: show,
  8845. slotchange: slotchange,
  8846. soundend: soundend,
  8847. soundstart: soundstart,
  8848. speechend: speechend,
  8849. speechstart: speechstart,
  8850. stalled: stalled,
  8851. start: start,
  8852. storage: storage,
  8853. submit: submit,
  8854. success: success,
  8855. suspend: suspend,
  8856. SVGAbort: SVGAbort,
  8857. SVGError: SVGError,
  8858. SVGLoad: SVGLoad,
  8859. SVGResize: SVGResize,
  8860. SVGScroll: SVGScroll,
  8861. SVGUnload: SVGUnload,
  8862. SVGZoom: SVGZoom,
  8863. timeout: timeout,
  8864. timeupdate: timeupdate,
  8865. touchcancel: touchcancel,
  8866. touchend: touchend,
  8867. touchmove: touchmove,
  8868. touchstart: touchstart,
  8869. transitionend: transitionend,
  8870. unload: unload,
  8871. updateready: updateready,
  8872. userproximity: userproximity,
  8873. voiceschanged: voiceschanged,
  8874. visibilitychange: visibilitychange,
  8875. volumechange: volumechange,
  8876. waiting: waiting,
  8877. wheel: wheel,
  8878. 'default': domEventTypes
  8879. });
  8880. var require$$0 = getCjsExportFromNamespace(domEventTypes$1);
  8881. var domEventTypes$2 = require$$0;
  8882. var defaultEventType = {
  8883. eventInterface: 'Event',
  8884. cancelable: true,
  8885. bubbles: true
  8886. };
  8887. var modifiers = {
  8888. enter: 13,
  8889. tab: 9,
  8890. delete: 46,
  8891. esc: 27,
  8892. space: 32,
  8893. up: 38,
  8894. down: 40,
  8895. left: 37,
  8896. right: 39,
  8897. end: 35,
  8898. home: 36,
  8899. backspace: 8,
  8900. insert: 45,
  8901. pageup: 33,
  8902. pagedown: 34
  8903. };
  8904. // get from https://github.com/ashubham/w3c-keys/blob/master/index.ts
  8905. var w3cKeys = {
  8906. enter: 'Enter',
  8907. tab: 'Tab',
  8908. delete: 'Delete',
  8909. esc: 'Esc',
  8910. escape: 'Escape',
  8911. space: ' ',
  8912. up: 'Up',
  8913. left: 'Left',
  8914. right: 'Right',
  8915. down: 'Down',
  8916. end: 'End',
  8917. home: 'Home',
  8918. backspace: 'Backspace',
  8919. insert: 'Insert',
  8920. pageup: 'PageUp',
  8921. pagedown: 'PageDown'
  8922. };
  8923. var codeToKeyNameMap = Object.entries(modifiers).reduce(
  8924. function (acc, ref) {
  8925. var obj;
  8926. var key = ref[0];
  8927. var value = ref[1];
  8928. return Object.assign(acc, ( obj = {}, obj[value] = w3cKeys[key], obj ));
  8929. },
  8930. {}
  8931. );
  8932. function getOptions(eventParams) {
  8933. var modifier = eventParams.modifier;
  8934. var meta = eventParams.meta;
  8935. var options = eventParams.options;
  8936. var keyCode = modifiers[modifier] || options.keyCode || options.code;
  8937. var key = codeToKeyNameMap[keyCode];
  8938. return Object.assign({}, options, // What the user passed in as the second argument to #trigger
  8939. {bubbles: meta.bubbles,
  8940. cancelable: meta.cancelable,
  8941. // Any derived options should go here
  8942. keyCode: keyCode,
  8943. code: keyCode,
  8944. key: key || options.key})
  8945. }
  8946. function createEvent(eventParams) {
  8947. var eventType = eventParams.eventType;
  8948. var meta = eventParams.meta; if ( meta === void 0 ) meta = {};
  8949. var SupportedEventInterface =
  8950. typeof window[meta.eventInterface] === 'function'
  8951. ? window[meta.eventInterface]
  8952. : window.Event;
  8953. var event = new SupportedEventInterface(
  8954. eventType,
  8955. // event properties can only be added when the event is instantiated
  8956. // custom properties must be added after the event has been instantiated
  8957. getOptions(eventParams)
  8958. );
  8959. return event
  8960. }
  8961. function createOldEvent(eventParams) {
  8962. var eventType = eventParams.eventType;
  8963. var modifier = eventParams.modifier;
  8964. var meta = eventParams.meta;
  8965. var bubbles = meta.bubbles;
  8966. var cancelable = meta.cancelable;
  8967. var event = document.createEvent('Event');
  8968. event.initEvent(eventType, bubbles, cancelable);
  8969. event.keyCode = modifiers[modifier];
  8970. return event
  8971. }
  8972. function createDOMEvent(type, options) {
  8973. var ref = type.split('.');
  8974. var eventType = ref[0];
  8975. var modifier = ref[1];
  8976. var meta = domEventTypes$2[eventType] || defaultEventType;
  8977. var eventParams = { eventType: eventType, modifier: modifier, meta: meta, options: options };
  8978. // Fallback for IE10,11 - https://stackoverflow.com/questions/26596123
  8979. var event =
  8980. typeof window.Event === 'function'
  8981. ? createEvent(eventParams)
  8982. : createOldEvent(eventParams);
  8983. var eventPrototype = Object.getPrototypeOf(event);
  8984. Object.keys(options || {}).forEach(function (key) {
  8985. var propertyDescriptor = Object.getOwnPropertyDescriptor(
  8986. eventPrototype,
  8987. key
  8988. );
  8989. var canSetProperty = !(
  8990. propertyDescriptor && propertyDescriptor.setter === undefined
  8991. );
  8992. if (canSetProperty) {
  8993. event[key] = options[key];
  8994. }
  8995. });
  8996. return event
  8997. }
  8998. //
  8999. var Wrapper = function Wrapper(
  9000. node,
  9001. options,
  9002. isVueWrapper
  9003. ) {
  9004. var vnode = node instanceof Element ? null : node;
  9005. var element = node instanceof Element ? node : node.elm;
  9006. // Prevent redefine by VueWrapper
  9007. if (!isVueWrapper) {
  9008. // $FlowIgnore : issue with defineProperty
  9009. Object.defineProperty(this, 'rootNode', {
  9010. get: function () { return vnode || element; },
  9011. set: function () { return throwError('wrapper.rootNode is read-only'); }
  9012. });
  9013. // $FlowIgnore
  9014. Object.defineProperty(this, 'vnode', {
  9015. get: function () { return vnode; },
  9016. set: function () { return throwError('wrapper.vnode is read-only'); }
  9017. });
  9018. // $FlowIgnore
  9019. Object.defineProperty(this, 'element', {
  9020. get: function () { return element; },
  9021. set: function () { return throwError('wrapper.element is read-only'); }
  9022. });
  9023. // $FlowIgnore
  9024. Object.defineProperty(this, 'vm', {
  9025. get: function () { return undefined; },
  9026. set: function () { return throwError('wrapper.vm is read-only'); }
  9027. });
  9028. }
  9029. var frozenOptions = Object.freeze(options);
  9030. // $FlowIgnore
  9031. Object.defineProperty(this, 'options', {
  9032. get: function () { return frozenOptions; },
  9033. set: function () { return throwError('wrapper.options is read-only'); }
  9034. });
  9035. if (
  9036. this.vnode &&
  9037. (this.vnode[FUNCTIONAL_OPTIONS] || this.vnode.functionalContext)
  9038. ) {
  9039. this.isFunctionalComponent = true;
  9040. }
  9041. };
  9042. /**
  9043. * Prints warning if component is destroyed
  9044. */
  9045. Wrapper.prototype.__warnIfDestroyed = function __warnIfDestroyed () {
  9046. if (!this.exists()) {
  9047. warn('Operations on destroyed component are discouraged');
  9048. }
  9049. };
  9050. Wrapper.prototype.at = function at () {
  9051. this.__warnIfDestroyed();
  9052. throwError('at() must be called on a WrapperArray');
  9053. };
  9054. /**
  9055. * Returns an Object containing all the attribute/value pairs on the element.
  9056. */
  9057. Wrapper.prototype.attributes = function attributes (key) {
  9058. this.__warnIfDestroyed();
  9059. var attributes = this.element.attributes;
  9060. var attributeMap = {};
  9061. for (var i = 0; i < attributes.length; i++) {
  9062. var att = attributes.item(i);
  9063. attributeMap[att.localName] = att.value;
  9064. }
  9065. return key ? attributeMap[key] : attributeMap
  9066. };
  9067. /**
  9068. * Returns an Array containing all the classes on the element
  9069. */
  9070. Wrapper.prototype.classes = function classes (className) {
  9071. var this$1 = this;
  9072. this.__warnIfDestroyed();
  9073. var classAttribute = this.element.getAttribute('class');
  9074. var classes = classAttribute ? classAttribute.split(' ') : [];
  9075. // Handle converting cssmodules identifiers back to the original class name
  9076. if (this.vm && this.vm.$style) {
  9077. var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
  9078. function (acc, key) {
  9079. // $FlowIgnore
  9080. var moduleIdent = this$1.vm.$style[key];
  9081. if (moduleIdent) {
  9082. acc[moduleIdent.split(' ')[0]] = key;
  9083. }
  9084. return acc
  9085. },
  9086. {}
  9087. );
  9088. classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
  9089. }
  9090. return className ? !!(classes.indexOf(className) > -1) : classes
  9091. };
  9092. /**
  9093. * Checks if wrapper contains provided selector.
  9094. * @deprecated
  9095. */
  9096. Wrapper.prototype.contains = function contains (rawSelector) {
  9097. warnDeprecated(
  9098. 'contains',
  9099. 'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
  9100. );
  9101. this.__warnIfDestroyed();
  9102. var selector = getSelector(rawSelector, 'contains');
  9103. var nodes = find(this.rootNode, this.vm, selector);
  9104. return nodes.length > 0
  9105. };
  9106. /**
  9107. * Calls destroy on vm
  9108. */
  9109. Wrapper.prototype.destroy = function destroy () {
  9110. if (!this.vm && !this.isFunctionalComponent) {
  9111. throwError(
  9112. "wrapper.destroy() can only be called on a Vue instance or " +
  9113. "functional component."
  9114. );
  9115. }
  9116. if (this.element.parentNode) {
  9117. this.element.parentNode.removeChild(this.element);
  9118. }
  9119. if (this.vm) {
  9120. // $FlowIgnore
  9121. this.vm.$destroy();
  9122. throwIfInstancesThrew(this.vm);
  9123. }
  9124. };
  9125. /**
  9126. * Returns an object containing custom events emitted by the Wrapper vm
  9127. */
  9128. Wrapper.prototype.emitted = function emitted (
  9129. event
  9130. ) {
  9131. if (!this._emitted && !this.vm) {
  9132. throwError("wrapper.emitted() can only be called on a Vue instance");
  9133. }
  9134. if (event) {
  9135. return this._emitted[event]
  9136. }
  9137. return this._emitted
  9138. };
  9139. /**
  9140. * Returns an Array containing custom events emitted by the Wrapper vm
  9141. * @deprecated
  9142. */
  9143. Wrapper.prototype.emittedByOrder = function emittedByOrder () {
  9144. warnDeprecated('emittedByOrder', 'Use `wrapper.emitted` instead');
  9145. if (!this._emittedByOrder && !this.vm) {
  9146. throwError(
  9147. "wrapper.emittedByOrder() can only be called on a Vue instance"
  9148. );
  9149. }
  9150. return this._emittedByOrder
  9151. };
  9152. /**
  9153. * Utility to check wrapper exists.
  9154. */
  9155. Wrapper.prototype.exists = function exists () {
  9156. if (this.vm) {
  9157. return !!this.vm && !this.vm._isDestroyed
  9158. }
  9159. return true
  9160. };
  9161. Wrapper.prototype.filter = function filter () {
  9162. throwError('filter() must be called on a WrapperArray');
  9163. };
  9164. /**
  9165. * Gets first node in tree of the current wrapper that
  9166. * matches the provided selector.
  9167. */
  9168. Wrapper.prototype.get = function get (rawSelector) {
  9169. this.__warnIfDestroyed();
  9170. var found = this.find(rawSelector);
  9171. if (found instanceof ErrorWrapper) {
  9172. throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
  9173. }
  9174. return found
  9175. };
  9176. /**
  9177. * Gets first node in tree of the current wrapper that
  9178. * matches the provided selector.
  9179. */
  9180. Wrapper.prototype.getComponent = function getComponent (rawSelector) {
  9181. this.__warnIfDestroyed();
  9182. var found = this.findComponent(rawSelector);
  9183. if (found instanceof ErrorWrapper) {
  9184. throw new Error(("Unable to get " + rawSelector + " within: " + (this.html())))
  9185. }
  9186. return found
  9187. };
  9188. /**
  9189. * Finds first DOM node in tree of the current wrapper that
  9190. * matches the provided selector.
  9191. */
  9192. Wrapper.prototype.find = function find (rawSelector) {
  9193. this.__warnIfDestroyed();
  9194. var selector = getSelector(rawSelector, 'find');
  9195. if (selector.type !== DOM_SELECTOR) {
  9196. warnDeprecated(
  9197. 'finding components with `find` or `get`',
  9198. 'Use `findComponent` and `getComponent` instead'
  9199. );
  9200. }
  9201. return this.__find(rawSelector, selector)
  9202. };
  9203. /**
  9204. * Finds first component in tree of the current wrapper that
  9205. * matches the provided selector.
  9206. */
  9207. Wrapper.prototype.findComponent = function findComponent (rawSelector) {
  9208. this.__warnIfDestroyed();
  9209. var selector = getSelector(rawSelector, 'findComponent');
  9210. return this.__find(rawSelector, selector)
  9211. };
  9212. Wrapper.prototype.__find = function __find (rawSelector, selector) {
  9213. var node = find(this.rootNode, this.vm, selector)[0];
  9214. if (!node) {
  9215. return new ErrorWrapper(rawSelector)
  9216. }
  9217. var wrapper = createWrapper(node, this.options);
  9218. wrapper.selector = rawSelector;
  9219. return wrapper
  9220. };
  9221. /**
  9222. * Finds DOM elements in tree of the current wrapper that matches
  9223. * the provided selector.
  9224. */
  9225. Wrapper.prototype.findAll = function findAll (rawSelector) {
  9226. this.__warnIfDestroyed();
  9227. var selector = getSelector(rawSelector, 'findAll');
  9228. if (selector.type !== DOM_SELECTOR) {
  9229. warnDeprecated(
  9230. 'finding components with `findAll`',
  9231. 'Use `findAllComponents` instead'
  9232. );
  9233. }
  9234. return this.__findAll(rawSelector, selector)
  9235. };
  9236. /**
  9237. * Finds components in tree of the current wrapper that matches
  9238. * the provided selector.
  9239. */
  9240. Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
  9241. this.__warnIfDestroyed();
  9242. var selector = getSelector(rawSelector, 'findAll');
  9243. return this.__findAll(rawSelector, selector, isVueWrapper)
  9244. };
  9245. Wrapper.prototype.__findAll = function __findAll (
  9246. rawSelector,
  9247. selector,
  9248. filterFn
  9249. ) {
  9250. var this$1 = this;
  9251. if ( filterFn === void 0 ) filterFn = function () { return true; };
  9252. var nodes = find(this.rootNode, this.vm, selector);
  9253. var wrappers = nodes
  9254. .map(function (node) {
  9255. // Using CSS Selector, returns a VueWrapper instance if the root element
  9256. // binds a Vue instance.
  9257. var wrapper = createWrapper(node, this$1.options);
  9258. wrapper.selector = rawSelector;
  9259. return wrapper
  9260. })
  9261. .filter(filterFn);
  9262. var wrapperArray = new WrapperArray(wrappers);
  9263. wrapperArray.selector = rawSelector;
  9264. return wrapperArray
  9265. };
  9266. /**
  9267. * Returns HTML of element as a string
  9268. */
  9269. Wrapper.prototype.html = function html () {
  9270. this.__warnIfDestroyed();
  9271. return pretty(this.element.outerHTML)
  9272. };
  9273. /**
  9274. * Checks if node matches selector or component definition
  9275. */
  9276. Wrapper.prototype.is = function is (rawSelector) {
  9277. this.__warnIfDestroyed();
  9278. var selector = getSelector(rawSelector, 'is');
  9279. if (selector.type === DOM_SELECTOR) {
  9280. warnDeprecated(
  9281. 'checking tag name with `is`',
  9282. 'Use `element.tagName` instead'
  9283. );
  9284. }
  9285. if (selector.type === REF_SELECTOR) {
  9286. throwError('$ref selectors can not be used with wrapper.is()');
  9287. }
  9288. return matches(this.rootNode, selector)
  9289. };
  9290. /**
  9291. * Checks if node is empty
  9292. * @deprecated
  9293. */
  9294. Wrapper.prototype.isEmpty = function isEmpty () {
  9295. warnDeprecated(
  9296. 'isEmpty',
  9297. 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
  9298. 'When using with findComponent, access the DOM element with findComponent(Comp).element'
  9299. );
  9300. this.__warnIfDestroyed();
  9301. if (!this.vnode) {
  9302. return this.element.innerHTML === ''
  9303. }
  9304. var nodes = [];
  9305. var node = this.vnode;
  9306. var i = 0;
  9307. while (node) {
  9308. if (node.child) {
  9309. nodes.push(node.child._vnode);
  9310. }
  9311. node.children &&
  9312. node.children.forEach(function (n) {
  9313. nodes.push(n);
  9314. });
  9315. node = nodes[i++];
  9316. }
  9317. return nodes.every(function (n) { return n.isComment || n.child; })
  9318. };
  9319. /**
  9320. * Checks if node is visible
  9321. */
  9322. Wrapper.prototype.isVisible = function isVisible () {
  9323. this.__warnIfDestroyed();
  9324. return isElementVisible(this.element)
  9325. };
  9326. /**
  9327. * Checks if wrapper is a vue instance
  9328. * @deprecated
  9329. */
  9330. Wrapper.prototype.isVueInstance = function isVueInstance () {
  9331. warnDeprecated("isVueInstance");
  9332. this.__warnIfDestroyed();
  9333. return !!this.vm
  9334. };
  9335. /**
  9336. * Returns name of component, or tag name if node is not a Vue component
  9337. * @deprecated
  9338. */
  9339. Wrapper.prototype.name = function name () {
  9340. warnDeprecated("name");
  9341. this.__warnIfDestroyed();
  9342. if (this.vm) {
  9343. return (
  9344. this.vm.$options.name ||
  9345. // compat for Vue < 2.3
  9346. (this.vm.$options.extendOptions && this.vm.$options.extendOptions.name)
  9347. )
  9348. }
  9349. if (!this.vnode) {
  9350. return this.element.tagName
  9351. }
  9352. return this.vnode.tag
  9353. };
  9354. /**
  9355. * Prints a simple overview of the wrapper current state
  9356. * with useful information for debugging
  9357. * @deprecated
  9358. */
  9359. Wrapper.prototype.overview = function overview () {
  9360. var this$1 = this;
  9361. warnDeprecated("overview");
  9362. this.__warnIfDestroyed();
  9363. if (!this.vm) {
  9364. throwError("wrapper.overview() can only be called on a Vue instance");
  9365. }
  9366. var identation = 4;
  9367. var formatJSON = function (json, replacer) {
  9368. if ( replacer === void 0 ) replacer = null;
  9369. return JSON.stringify(json, replacer, identation).replace(/"/g, '');
  9370. };
  9371. var visibility = this.isVisible() ? 'Visible' : 'Not visible';
  9372. var html = this.html()
  9373. ? this.html().replace(/^(?!\s*$)/gm, ' '.repeat(identation)) + '\n'
  9374. : '';
  9375. // $FlowIgnore
  9376. var data = formatJSON(this.vm.$data);
  9377. /* eslint-disable operator-linebreak */
  9378. // $FlowIgnore
  9379. var computed = this.vm._computedWatchers
  9380. ? formatJSON.apply(
  9381. // $FlowIgnore
  9382. void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
  9383. var obj;
  9384. return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
  9385. })
  9386. )
  9387. : // $FlowIgnore
  9388. this.vm.$options.computed
  9389. ? formatJSON.apply(
  9390. // $FlowIgnore
  9391. void 0, Object.entries(this.vm.$options.computed).map(function (ref) {
  9392. var obj;
  9393. var key = ref[0];
  9394. var value = ref[1];
  9395. return (( obj = {}, obj[key] = value(), obj ));
  9396. })
  9397. )
  9398. : '{}';
  9399. /* eslint-enable operator-linebreak */
  9400. var emittedJSONReplacer = function (key, value) { return value instanceof Array
  9401. ? value.map(function (calledWith, index) {
  9402. var callParams = calledWith.map(function (param) { return typeof param === 'object'
  9403. ? JSON.stringify(param)
  9404. .replace(/"/g, '')
  9405. .replace(/,/g, ', ')
  9406. : param; }
  9407. );
  9408. return (index + ": [ " + (callParams.join(', ')) + " ]")
  9409. })
  9410. : value; };
  9411. var emitted = formatJSON(this.emitted(), emittedJSONReplacer);
  9412. console.log(
  9413. '\n' +
  9414. "Wrapper (" + visibility + "):\n\n" +
  9415. "Html:\n" + html + "\n" +
  9416. "Data: " + data + "\n\n" +
  9417. "Computed: " + computed + "\n\n" +
  9418. "Emitted: " + emitted + "\n"
  9419. );
  9420. };
  9421. /**
  9422. * Returns an Object containing the prop name/value pairs on the element
  9423. */
  9424. Wrapper.prototype.props = function props (key) {
  9425. var this$1 = this;
  9426. if (this.isFunctionalComponent) {
  9427. throwError(
  9428. "wrapper.props() cannot be called on a mounted functional component."
  9429. );
  9430. }
  9431. if (!this.vm) {
  9432. throwError('wrapper.props() must be called on a Vue instance');
  9433. }
  9434. this.__warnIfDestroyed();
  9435. var props = {};
  9436. var keys = this.vm && this.vm.$options._propKeys;
  9437. if (keys) {
  9438. (keys || {}).forEach(function (key) {
  9439. if (this$1.vm) {
  9440. props[key] = this$1.vm[key];
  9441. }
  9442. });
  9443. }
  9444. if (key) {
  9445. return props[key]
  9446. }
  9447. return props
  9448. };
  9449. /**
  9450. * Checks radio button or checkbox element
  9451. * @deprecated
  9452. */
  9453. Wrapper.prototype.setChecked = function setChecked (checked) {
  9454. if ( checked === void 0 ) checked = true;
  9455. this.__warnIfDestroyed();
  9456. if (typeof checked !== 'boolean') {
  9457. throwError('wrapper.setChecked() must be passed a boolean');
  9458. }
  9459. var tagName = this.element.tagName;
  9460. // $FlowIgnore
  9461. var type = this.attributes().type;
  9462. var event = getCheckedEvent();
  9463. if (tagName === 'INPUT' && type === 'checkbox') {
  9464. // $FlowIgnore
  9465. if (this.element.checked === checked) {
  9466. return nextTick()
  9467. }
  9468. if (event !== 'click' || isPhantomJS) {
  9469. // $FlowIgnore
  9470. this.element.checked = checked;
  9471. }
  9472. return this.trigger(event)
  9473. }
  9474. if (tagName === 'INPUT' && type === 'radio') {
  9475. if (!checked) {
  9476. throwError(
  9477. "wrapper.setChecked() cannot be called with parameter false on a " +
  9478. "<input type=\"radio\" /> element."
  9479. );
  9480. }
  9481. // $FlowIgnore
  9482. if (this.element.checked === checked) {
  9483. return nextTick()
  9484. }
  9485. if (event !== 'click' || isPhantomJS) {
  9486. // $FlowIgnore
  9487. this.element.selected = true;
  9488. }
  9489. return this.trigger(event)
  9490. }
  9491. throwError("wrapper.setChecked() cannot be called on this element");
  9492. return nextTick()
  9493. };
  9494. /**
  9495. * Selects <option></option> element
  9496. * @deprecated
  9497. */
  9498. Wrapper.prototype.setSelected = function setSelected () {
  9499. this.__warnIfDestroyed();
  9500. var tagName = this.element.tagName;
  9501. if (tagName === 'SELECT') {
  9502. throwError(
  9503. "wrapper.setSelected() cannot be called on select. Call it on one of " +
  9504. "its options"
  9505. );
  9506. }
  9507. if (tagName !== 'OPTION') {
  9508. throwError("wrapper.setSelected() cannot be called on this element");
  9509. }
  9510. // $FlowIgnore
  9511. if (this.element.selected) {
  9512. return nextTick()
  9513. }
  9514. // $FlowIgnore
  9515. this.element.selected = true;
  9516. // $FlowIgnore
  9517. var parentElement = this.element.parentElement;
  9518. // $FlowIgnore
  9519. if (parentElement.tagName === 'OPTGROUP') {
  9520. // $FlowIgnore
  9521. parentElement = parentElement.parentElement;
  9522. }
  9523. // $FlowIgnore
  9524. return createWrapper(parentElement, this.options).trigger('change')
  9525. };
  9526. /**
  9527. * Sets vm data
  9528. */
  9529. Wrapper.prototype.setData = function setData (data) {
  9530. if (this.isFunctionalComponent) {
  9531. throwError("wrapper.setData() cannot be called on a functional component");
  9532. }
  9533. if (!this.vm) {
  9534. throwError("wrapper.setData() can only be called on a Vue instance");
  9535. }
  9536. this.__warnIfDestroyed();
  9537. recursivelySetData(this.vm, this.vm, data);
  9538. return nextTick()
  9539. };
  9540. /**
  9541. * Sets vm methods
  9542. * @deprecated
  9543. */
  9544. Wrapper.prototype.setMethods = function setMethods (methods) {
  9545. var this$1 = this;
  9546. warnDeprecated(
  9547. "setMethods",
  9548. "There is no clear migration path for setMethods - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests"
  9549. );
  9550. if (!this.vm) {
  9551. throwError("wrapper.setMethods() can only be called on a Vue instance");
  9552. }
  9553. this.__warnIfDestroyed();
  9554. Object.keys(methods).forEach(function (key) {
  9555. // $FlowIgnore : Problem with possibly null this.vm
  9556. this$1.vm[key] = methods[key];
  9557. // $FlowIgnore : Problem with possibly null this.vm
  9558. this$1.vm.$options.methods[key] = methods[key];
  9559. });
  9560. if (this.vnode) {
  9561. var context = this.vnode.context;
  9562. if (context.$options.render) { context._update(context._render()); }
  9563. }
  9564. };
  9565. /**
  9566. * Sets vm props
  9567. */
  9568. Wrapper.prototype.setProps = function setProps (data) {
  9569. var this$1 = this;
  9570. // Validate the setProps method call
  9571. if (this.isFunctionalComponent) {
  9572. throwError(
  9573. "wrapper.setProps() cannot be called on a functional component"
  9574. );
  9575. }
  9576. if (!this.vm) {
  9577. throwError("wrapper.setProps() can only be called on a Vue instance");
  9578. }
  9579. // $FlowIgnore : Problem with possibly null this.vm
  9580. if (!this.vm.$parent.$options.$_isWrapperParent) {
  9581. throwError(
  9582. "wrapper.setProps() can only be called for top-level component"
  9583. );
  9584. }
  9585. this.__warnIfDestroyed();
  9586. Object.keys(data).forEach(function (key) {
  9587. // Don't let people set entire objects, because reactivity won't work
  9588. if (
  9589. typeof data[key] === 'object' &&
  9590. data[key] !== null &&
  9591. // $FlowIgnore : Problem with possibly null this.vm
  9592. data[key] === this$1.vm[key]
  9593. ) {
  9594. throwError(
  9595. "wrapper.setProps() called with the same object of the existing " +
  9596. key + " property. You must call wrapper.setProps() with a new " +
  9597. "object to trigger reactivity"
  9598. );
  9599. }
  9600. if (
  9601. VUE_VERSION <= 2.3 &&
  9602. (!this$1.vm ||
  9603. !this$1.vm.$options._propKeys ||
  9604. !this$1.vm.$options._propKeys.some(function (prop) { return prop === key; }))
  9605. ) {
  9606. throwError(
  9607. "wrapper.setProps() called with " + key + " property which " +
  9608. "is not defined on the component"
  9609. );
  9610. }
  9611. // $FlowIgnore : Problem with possibly null this.vm
  9612. var parent = this$1.vm.$parent;
  9613. parent.$set(parent.vueTestUtils_childProps, key, data[key]);
  9614. });
  9615. return nextTick()
  9616. };
  9617. /**
  9618. * Sets element value and triggers input event
  9619. */
  9620. Wrapper.prototype.setValue = function setValue (value) {
  9621. var tagName = this.element.tagName;
  9622. // $FlowIgnore
  9623. var type = this.attributes().type;
  9624. this.__warnIfDestroyed();
  9625. if (tagName === 'OPTION') {
  9626. throwError(
  9627. "wrapper.setValue() cannot be called on an <option> element. Use " +
  9628. "wrapper.setSelected() instead"
  9629. );
  9630. } else if (tagName === 'INPUT' && type === 'checkbox') {
  9631. throwError(
  9632. "wrapper.setValue() cannot be called on a <input type=\"checkbox\" /> " +
  9633. "element. Use wrapper.setChecked() instead"
  9634. );
  9635. } else if (tagName === 'INPUT' && type === 'radio') {
  9636. throwError(
  9637. "wrapper.setValue() cannot be called on a <input type=\"radio\" /> " +
  9638. "element. Use wrapper.setChecked() instead"
  9639. );
  9640. } else if (tagName === 'SELECT') {
  9641. if (Array.isArray(value)) {
  9642. // $FlowIgnore
  9643. var options = this.element.options;
  9644. for (var i = 0; i < options.length; i++) {
  9645. var option = options[i];
  9646. option.selected = value.indexOf(option.value) >= 0;
  9647. }
  9648. } else {
  9649. // $FlowIgnore
  9650. this.element.value = value;
  9651. }
  9652. this.trigger('change');
  9653. return nextTick()
  9654. } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
  9655. // $FlowIgnore
  9656. this.element.value = value;
  9657. this.trigger('input');
  9658. // for v-model.lazy, we need to trigger a change event, too.
  9659. // $FlowIgnore
  9660. if (this.element._vModifiers && this.element._vModifiers.lazy) {
  9661. this.trigger('change');
  9662. }
  9663. return nextTick()
  9664. }
  9665. throwError("wrapper.setValue() cannot be called on this element");
  9666. return nextTick()
  9667. };
  9668. /**
  9669. * Return text of wrapper element
  9670. */
  9671. Wrapper.prototype.text = function text () {
  9672. this.__warnIfDestroyed();
  9673. return this.element.textContent.trim()
  9674. };
  9675. /**
  9676. * Simulates event triggering
  9677. */
  9678. Wrapper.prototype.__simulateTrigger = function __simulateTrigger (type, options) {
  9679. var this$1 = this;
  9680. var regularEventTrigger = function (type, options) {
  9681. var event = createDOMEvent(type, options);
  9682. return this$1.element.dispatchEvent(event)
  9683. };
  9684. var focusEventTrigger = function (type, options) {
  9685. if (this$1.element instanceof HTMLElement) {
  9686. return this$1.element.focus()
  9687. }
  9688. regularEventTrigger(type, options);
  9689. };
  9690. var triggerProcedureMap = {
  9691. focus: focusEventTrigger,
  9692. __default: regularEventTrigger
  9693. };
  9694. var triggerFn = triggerProcedureMap[type] || triggerProcedureMap.__default;
  9695. return triggerFn(type, options)
  9696. };
  9697. /**
  9698. * Dispatches a DOM event on wrapper
  9699. */
  9700. Wrapper.prototype.trigger = function trigger (type, options) {
  9701. if ( options === void 0 ) options = {};
  9702. this.__warnIfDestroyed();
  9703. if (typeof type !== 'string') {
  9704. throwError('wrapper.trigger() must be passed a string');
  9705. }
  9706. if (options.target) {
  9707. throwError(
  9708. "you cannot set the target value of an event. See the notes section " +
  9709. "of the docs for more details—" +
  9710. "https://vue-test-utils.vuejs.org/api/wrapper/trigger.html"
  9711. );
  9712. }
  9713. /**
  9714. * Avoids firing events on specific disabled elements
  9715. * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
  9716. */
  9717. var supportedTags = [
  9718. 'BUTTON',
  9719. 'COMMAND',
  9720. 'FIELDSET',
  9721. 'KEYGEN',
  9722. 'OPTGROUP',
  9723. 'OPTION',
  9724. 'SELECT',
  9725. 'TEXTAREA',
  9726. 'INPUT'
  9727. ];
  9728. var tagName = this.element.tagName;
  9729. if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
  9730. return nextTick()
  9731. }
  9732. this.__simulateTrigger(type, options);
  9733. return nextTick()
  9734. };
  9735. //
  9736. var VueWrapper = /*@__PURE__*/(function (Wrapper) {
  9737. function VueWrapper(vm, options) {
  9738. var this$1 = this;
  9739. Wrapper.call(this, vm._vnode, options, true);
  9740. // $FlowIgnore : issue with defineProperty
  9741. Object.defineProperty(this, 'rootNode', {
  9742. get: function () { return vm.$vnode || { child: this$1.vm }; },
  9743. set: function () { return throwError('wrapper.vnode is read-only'); }
  9744. });
  9745. // $FlowIgnore : issue with defineProperty
  9746. Object.defineProperty(this, 'vnode', {
  9747. get: function () { return vm._vnode; },
  9748. set: function () { return throwError('wrapper.vnode is read-only'); }
  9749. });
  9750. // $FlowIgnore
  9751. Object.defineProperty(this, 'element', {
  9752. get: function () { return vm.$el; },
  9753. set: function () { return throwError('wrapper.element is read-only'); }
  9754. });
  9755. // $FlowIgnore
  9756. Object.defineProperty(this, 'vm', {
  9757. get: function () { return vm; },
  9758. set: function () { return throwError('wrapper.vm is read-only'); }
  9759. });
  9760. this.isFunctionalComponent = vm.$options._isFunctionalContainer;
  9761. this._emitted = vm.__emitted;
  9762. this._emittedByOrder = vm.__emittedByOrder;
  9763. }
  9764. if ( Wrapper ) VueWrapper.__proto__ = Wrapper;
  9765. VueWrapper.prototype = Object.create( Wrapper && Wrapper.prototype );
  9766. VueWrapper.prototype.constructor = VueWrapper;
  9767. return VueWrapper;
  9768. }(Wrapper));
  9769. //
  9770. var isEnabled = false;
  9771. var wrapperInstances = [];
  9772. function resetAutoDestroyState() {
  9773. isEnabled = false;
  9774. wrapperInstances.length = 0;
  9775. }
  9776. function enableAutoDestroy(hook) {
  9777. if (isEnabled) {
  9778. throwError('enableAutoDestroy cannot be called more than once');
  9779. }
  9780. isEnabled = true;
  9781. hook(function () {
  9782. wrapperInstances.forEach(function (wrapper) {
  9783. // skip child wrappers created by wrapper.find()
  9784. if (wrapper.vm || wrapper.isFunctionalComponent) {
  9785. wrapper.destroy();
  9786. }
  9787. });
  9788. wrapperInstances.length = 0;
  9789. });
  9790. }
  9791. function trackInstance(wrapper) {
  9792. if (!isEnabled) { return }
  9793. wrapperInstances.push(wrapper);
  9794. }
  9795. //
  9796. function createWrapper(
  9797. node,
  9798. options
  9799. ) {
  9800. if ( options === void 0 ) options = {};
  9801. var componentInstance = node.child;
  9802. if (componentInstance) {
  9803. var wrapper$1 = new VueWrapper(componentInstance, options);
  9804. trackInstance(wrapper$1);
  9805. return wrapper$1
  9806. }
  9807. var wrapper =
  9808. node instanceof Vue__default['default']
  9809. ? new VueWrapper(node, options)
  9810. : new Wrapper(node, options);
  9811. trackInstance(wrapper);
  9812. return wrapper
  9813. }
  9814. /**
  9815. * Removes all key-value entries from the list cache.
  9816. *
  9817. * @private
  9818. * @name clear
  9819. * @memberOf ListCache
  9820. */
  9821. function listCacheClear() {
  9822. this.__data__ = [];
  9823. this.size = 0;
  9824. }
  9825. var _listCacheClear = listCacheClear;
  9826. /**
  9827. * Performs a
  9828. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9829. * comparison between two values to determine if they are equivalent.
  9830. *
  9831. * @static
  9832. * @memberOf _
  9833. * @since 4.0.0
  9834. * @category Lang
  9835. * @param {*} value The value to compare.
  9836. * @param {*} other The other value to compare.
  9837. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  9838. * @example
  9839. *
  9840. * var object = { 'a': 1 };
  9841. * var other = { 'a': 1 };
  9842. *
  9843. * _.eq(object, object);
  9844. * // => true
  9845. *
  9846. * _.eq(object, other);
  9847. * // => false
  9848. *
  9849. * _.eq('a', 'a');
  9850. * // => true
  9851. *
  9852. * _.eq('a', Object('a'));
  9853. * // => false
  9854. *
  9855. * _.eq(NaN, NaN);
  9856. * // => true
  9857. */
  9858. function eq(value, other) {
  9859. return value === other || (value !== value && other !== other);
  9860. }
  9861. var eq_1 = eq;
  9862. /**
  9863. * Gets the index at which the `key` is found in `array` of key-value pairs.
  9864. *
  9865. * @private
  9866. * @param {Array} array The array to inspect.
  9867. * @param {*} key The key to search for.
  9868. * @returns {number} Returns the index of the matched value, else `-1`.
  9869. */
  9870. function assocIndexOf(array, key) {
  9871. var length = array.length;
  9872. while (length--) {
  9873. if (eq_1(array[length][0], key)) {
  9874. return length;
  9875. }
  9876. }
  9877. return -1;
  9878. }
  9879. var _assocIndexOf = assocIndexOf;
  9880. /** Used for built-in method references. */
  9881. var arrayProto = Array.prototype;
  9882. /** Built-in value references. */
  9883. var splice = arrayProto.splice;
  9884. /**
  9885. * Removes `key` and its value from the list cache.
  9886. *
  9887. * @private
  9888. * @name delete
  9889. * @memberOf ListCache
  9890. * @param {string} key The key of the value to remove.
  9891. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  9892. */
  9893. function listCacheDelete(key) {
  9894. var data = this.__data__,
  9895. index = _assocIndexOf(data, key);
  9896. if (index < 0) {
  9897. return false;
  9898. }
  9899. var lastIndex = data.length - 1;
  9900. if (index == lastIndex) {
  9901. data.pop();
  9902. } else {
  9903. splice.call(data, index, 1);
  9904. }
  9905. --this.size;
  9906. return true;
  9907. }
  9908. var _listCacheDelete = listCacheDelete;
  9909. /**
  9910. * Gets the list cache value for `key`.
  9911. *
  9912. * @private
  9913. * @name get
  9914. * @memberOf ListCache
  9915. * @param {string} key The key of the value to get.
  9916. * @returns {*} Returns the entry value.
  9917. */
  9918. function listCacheGet(key) {
  9919. var data = this.__data__,
  9920. index = _assocIndexOf(data, key);
  9921. return index < 0 ? undefined : data[index][1];
  9922. }
  9923. var _listCacheGet = listCacheGet;
  9924. /**
  9925. * Checks if a list cache value for `key` exists.
  9926. *
  9927. * @private
  9928. * @name has
  9929. * @memberOf ListCache
  9930. * @param {string} key The key of the entry to check.
  9931. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  9932. */
  9933. function listCacheHas(key) {
  9934. return _assocIndexOf(this.__data__, key) > -1;
  9935. }
  9936. var _listCacheHas = listCacheHas;
  9937. /**
  9938. * Sets the list cache `key` to `value`.
  9939. *
  9940. * @private
  9941. * @name set
  9942. * @memberOf ListCache
  9943. * @param {string} key The key of the value to set.
  9944. * @param {*} value The value to set.
  9945. * @returns {Object} Returns the list cache instance.
  9946. */
  9947. function listCacheSet(key, value) {
  9948. var data = this.__data__,
  9949. index = _assocIndexOf(data, key);
  9950. if (index < 0) {
  9951. ++this.size;
  9952. data.push([key, value]);
  9953. } else {
  9954. data[index][1] = value;
  9955. }
  9956. return this;
  9957. }
  9958. var _listCacheSet = listCacheSet;
  9959. /**
  9960. * Creates an list cache object.
  9961. *
  9962. * @private
  9963. * @constructor
  9964. * @param {Array} [entries] The key-value pairs to cache.
  9965. */
  9966. function ListCache(entries) {
  9967. var index = -1,
  9968. length = entries == null ? 0 : entries.length;
  9969. this.clear();
  9970. while (++index < length) {
  9971. var entry = entries[index];
  9972. this.set(entry[0], entry[1]);
  9973. }
  9974. }
  9975. // Add methods to `ListCache`.
  9976. ListCache.prototype.clear = _listCacheClear;
  9977. ListCache.prototype['delete'] = _listCacheDelete;
  9978. ListCache.prototype.get = _listCacheGet;
  9979. ListCache.prototype.has = _listCacheHas;
  9980. ListCache.prototype.set = _listCacheSet;
  9981. var _ListCache = ListCache;
  9982. /**
  9983. * Removes all key-value entries from the stack.
  9984. *
  9985. * @private
  9986. * @name clear
  9987. * @memberOf Stack
  9988. */
  9989. function stackClear() {
  9990. this.__data__ = new _ListCache;
  9991. this.size = 0;
  9992. }
  9993. var _stackClear = stackClear;
  9994. /**
  9995. * Removes `key` and its value from the stack.
  9996. *
  9997. * @private
  9998. * @name delete
  9999. * @memberOf Stack
  10000. * @param {string} key The key of the value to remove.
  10001. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10002. */
  10003. function stackDelete(key) {
  10004. var data = this.__data__,
  10005. result = data['delete'](key);
  10006. this.size = data.size;
  10007. return result;
  10008. }
  10009. var _stackDelete = stackDelete;
  10010. /**
  10011. * Gets the stack value for `key`.
  10012. *
  10013. * @private
  10014. * @name get
  10015. * @memberOf Stack
  10016. * @param {string} key The key of the value to get.
  10017. * @returns {*} Returns the entry value.
  10018. */
  10019. function stackGet(key) {
  10020. return this.__data__.get(key);
  10021. }
  10022. var _stackGet = stackGet;
  10023. /**
  10024. * Checks if a stack value for `key` exists.
  10025. *
  10026. * @private
  10027. * @name has
  10028. * @memberOf Stack
  10029. * @param {string} key The key of the entry to check.
  10030. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10031. */
  10032. function stackHas(key) {
  10033. return this.__data__.has(key);
  10034. }
  10035. var _stackHas = stackHas;
  10036. /** Detect free variable `global` from Node.js. */
  10037. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  10038. var _freeGlobal = freeGlobal;
  10039. /** Detect free variable `self`. */
  10040. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  10041. /** Used as a reference to the global object. */
  10042. var root = _freeGlobal || freeSelf || Function('return this')();
  10043. var _root = root;
  10044. /** Built-in value references. */
  10045. var Symbol = _root.Symbol;
  10046. var _Symbol = Symbol;
  10047. /** Used for built-in method references. */
  10048. var objectProto = Object.prototype;
  10049. /** Used to check objects for own properties. */
  10050. var hasOwnProperty$1 = objectProto.hasOwnProperty;
  10051. /**
  10052. * Used to resolve the
  10053. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  10054. * of values.
  10055. */
  10056. var nativeObjectToString = objectProto.toString;
  10057. /** Built-in value references. */
  10058. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  10059. /**
  10060. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  10061. *
  10062. * @private
  10063. * @param {*} value The value to query.
  10064. * @returns {string} Returns the raw `toStringTag`.
  10065. */
  10066. function getRawTag(value) {
  10067. var isOwn = hasOwnProperty$1.call(value, symToStringTag),
  10068. tag = value[symToStringTag];
  10069. try {
  10070. value[symToStringTag] = undefined;
  10071. var unmasked = true;
  10072. } catch (e) {}
  10073. var result = nativeObjectToString.call(value);
  10074. if (unmasked) {
  10075. if (isOwn) {
  10076. value[symToStringTag] = tag;
  10077. } else {
  10078. delete value[symToStringTag];
  10079. }
  10080. }
  10081. return result;
  10082. }
  10083. var _getRawTag = getRawTag;
  10084. /** Used for built-in method references. */
  10085. var objectProto$1 = Object.prototype;
  10086. /**
  10087. * Used to resolve the
  10088. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  10089. * of values.
  10090. */
  10091. var nativeObjectToString$1 = objectProto$1.toString;
  10092. /**
  10093. * Converts `value` to a string using `Object.prototype.toString`.
  10094. *
  10095. * @private
  10096. * @param {*} value The value to convert.
  10097. * @returns {string} Returns the converted string.
  10098. */
  10099. function objectToString(value) {
  10100. return nativeObjectToString$1.call(value);
  10101. }
  10102. var _objectToString = objectToString;
  10103. /** `Object#toString` result references. */
  10104. var nullTag = '[object Null]',
  10105. undefinedTag = '[object Undefined]';
  10106. /** Built-in value references. */
  10107. var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
  10108. /**
  10109. * The base implementation of `getTag` without fallbacks for buggy environments.
  10110. *
  10111. * @private
  10112. * @param {*} value The value to query.
  10113. * @returns {string} Returns the `toStringTag`.
  10114. */
  10115. function baseGetTag(value) {
  10116. if (value == null) {
  10117. return value === undefined ? undefinedTag : nullTag;
  10118. }
  10119. return (symToStringTag$1 && symToStringTag$1 in Object(value))
  10120. ? _getRawTag(value)
  10121. : _objectToString(value);
  10122. }
  10123. var _baseGetTag = baseGetTag;
  10124. /**
  10125. * Checks if `value` is the
  10126. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  10127. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  10128. *
  10129. * @static
  10130. * @memberOf _
  10131. * @since 0.1.0
  10132. * @category Lang
  10133. * @param {*} value The value to check.
  10134. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  10135. * @example
  10136. *
  10137. * _.isObject({});
  10138. * // => true
  10139. *
  10140. * _.isObject([1, 2, 3]);
  10141. * // => true
  10142. *
  10143. * _.isObject(_.noop);
  10144. * // => true
  10145. *
  10146. * _.isObject(null);
  10147. * // => false
  10148. */
  10149. function isObject(value) {
  10150. var type = typeof value;
  10151. return value != null && (type == 'object' || type == 'function');
  10152. }
  10153. var isObject_1 = isObject;
  10154. /** `Object#toString` result references. */
  10155. var asyncTag = '[object AsyncFunction]',
  10156. funcTag = '[object Function]',
  10157. genTag = '[object GeneratorFunction]',
  10158. proxyTag = '[object Proxy]';
  10159. /**
  10160. * Checks if `value` is classified as a `Function` object.
  10161. *
  10162. * @static
  10163. * @memberOf _
  10164. * @since 0.1.0
  10165. * @category Lang
  10166. * @param {*} value The value to check.
  10167. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  10168. * @example
  10169. *
  10170. * _.isFunction(_);
  10171. * // => true
  10172. *
  10173. * _.isFunction(/abc/);
  10174. * // => false
  10175. */
  10176. function isFunction(value) {
  10177. if (!isObject_1(value)) {
  10178. return false;
  10179. }
  10180. // The use of `Object#toString` avoids issues with the `typeof` operator
  10181. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  10182. var tag = _baseGetTag(value);
  10183. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  10184. }
  10185. var isFunction_1 = isFunction;
  10186. /** Used to detect overreaching core-js shims. */
  10187. var coreJsData = _root['__core-js_shared__'];
  10188. var _coreJsData = coreJsData;
  10189. /** Used to detect methods masquerading as native. */
  10190. var maskSrcKey = (function() {
  10191. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  10192. return uid ? ('Symbol(src)_1.' + uid) : '';
  10193. }());
  10194. /**
  10195. * Checks if `func` has its source masked.
  10196. *
  10197. * @private
  10198. * @param {Function} func The function to check.
  10199. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  10200. */
  10201. function isMasked(func) {
  10202. return !!maskSrcKey && (maskSrcKey in func);
  10203. }
  10204. var _isMasked = isMasked;
  10205. /** Used for built-in method references. */
  10206. var funcProto = Function.prototype;
  10207. /** Used to resolve the decompiled source of functions. */
  10208. var funcToString = funcProto.toString;
  10209. /**
  10210. * Converts `func` to its source code.
  10211. *
  10212. * @private
  10213. * @param {Function} func The function to convert.
  10214. * @returns {string} Returns the source code.
  10215. */
  10216. function toSource(func) {
  10217. if (func != null) {
  10218. try {
  10219. return funcToString.call(func);
  10220. } catch (e) {}
  10221. try {
  10222. return (func + '');
  10223. } catch (e$1) {}
  10224. }
  10225. return '';
  10226. }
  10227. var _toSource = toSource;
  10228. /**
  10229. * Used to match `RegExp`
  10230. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  10231. */
  10232. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  10233. /** Used to detect host constructors (Safari). */
  10234. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  10235. /** Used for built-in method references. */
  10236. var funcProto$1 = Function.prototype,
  10237. objectProto$2 = Object.prototype;
  10238. /** Used to resolve the decompiled source of functions. */
  10239. var funcToString$1 = funcProto$1.toString;
  10240. /** Used to check objects for own properties. */
  10241. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  10242. /** Used to detect if a method is native. */
  10243. var reIsNative = RegExp('^' +
  10244. funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  10245. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  10246. );
  10247. /**
  10248. * The base implementation of `_.isNative` without bad shim checks.
  10249. *
  10250. * @private
  10251. * @param {*} value The value to check.
  10252. * @returns {boolean} Returns `true` if `value` is a native function,
  10253. * else `false`.
  10254. */
  10255. function baseIsNative(value) {
  10256. if (!isObject_1(value) || _isMasked(value)) {
  10257. return false;
  10258. }
  10259. var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
  10260. return pattern.test(_toSource(value));
  10261. }
  10262. var _baseIsNative = baseIsNative;
  10263. /**
  10264. * Gets the value at `key` of `object`.
  10265. *
  10266. * @private
  10267. * @param {Object} [object] The object to query.
  10268. * @param {string} key The key of the property to get.
  10269. * @returns {*} Returns the property value.
  10270. */
  10271. function getValue(object, key) {
  10272. return object == null ? undefined : object[key];
  10273. }
  10274. var _getValue = getValue;
  10275. /**
  10276. * Gets the native function at `key` of `object`.
  10277. *
  10278. * @private
  10279. * @param {Object} object The object to query.
  10280. * @param {string} key The key of the method to get.
  10281. * @returns {*} Returns the function if it's native, else `undefined`.
  10282. */
  10283. function getNative(object, key) {
  10284. var value = _getValue(object, key);
  10285. return _baseIsNative(value) ? value : undefined;
  10286. }
  10287. var _getNative = getNative;
  10288. /* Built-in method references that are verified to be native. */
  10289. var Map = _getNative(_root, 'Map');
  10290. var _Map = Map;
  10291. /* Built-in method references that are verified to be native. */
  10292. var nativeCreate = _getNative(Object, 'create');
  10293. var _nativeCreate = nativeCreate;
  10294. /**
  10295. * Removes all key-value entries from the hash.
  10296. *
  10297. * @private
  10298. * @name clear
  10299. * @memberOf Hash
  10300. */
  10301. function hashClear() {
  10302. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  10303. this.size = 0;
  10304. }
  10305. var _hashClear = hashClear;
  10306. /**
  10307. * Removes `key` and its value from the hash.
  10308. *
  10309. * @private
  10310. * @name delete
  10311. * @memberOf Hash
  10312. * @param {Object} hash The hash to modify.
  10313. * @param {string} key The key of the value to remove.
  10314. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10315. */
  10316. function hashDelete(key) {
  10317. var result = this.has(key) && delete this.__data__[key];
  10318. this.size -= result ? 1 : 0;
  10319. return result;
  10320. }
  10321. var _hashDelete = hashDelete;
  10322. /** Used to stand-in for `undefined` hash values. */
  10323. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  10324. /** Used for built-in method references. */
  10325. var objectProto$3 = Object.prototype;
  10326. /** Used to check objects for own properties. */
  10327. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  10328. /**
  10329. * Gets the hash value for `key`.
  10330. *
  10331. * @private
  10332. * @name get
  10333. * @memberOf Hash
  10334. * @param {string} key The key of the value to get.
  10335. * @returns {*} Returns the entry value.
  10336. */
  10337. function hashGet(key) {
  10338. var data = this.__data__;
  10339. if (_nativeCreate) {
  10340. var result = data[key];
  10341. return result === HASH_UNDEFINED ? undefined : result;
  10342. }
  10343. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  10344. }
  10345. var _hashGet = hashGet;
  10346. /** Used for built-in method references. */
  10347. var objectProto$4 = Object.prototype;
  10348. /** Used to check objects for own properties. */
  10349. var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  10350. /**
  10351. * Checks if a hash value for `key` exists.
  10352. *
  10353. * @private
  10354. * @name has
  10355. * @memberOf Hash
  10356. * @param {string} key The key of the entry to check.
  10357. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10358. */
  10359. function hashHas(key) {
  10360. var data = this.__data__;
  10361. return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
  10362. }
  10363. var _hashHas = hashHas;
  10364. /** Used to stand-in for `undefined` hash values. */
  10365. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  10366. /**
  10367. * Sets the hash `key` to `value`.
  10368. *
  10369. * @private
  10370. * @name set
  10371. * @memberOf Hash
  10372. * @param {string} key The key of the value to set.
  10373. * @param {*} value The value to set.
  10374. * @returns {Object} Returns the hash instance.
  10375. */
  10376. function hashSet(key, value) {
  10377. var data = this.__data__;
  10378. this.size += this.has(key) ? 0 : 1;
  10379. data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  10380. return this;
  10381. }
  10382. var _hashSet = hashSet;
  10383. /**
  10384. * Creates a hash object.
  10385. *
  10386. * @private
  10387. * @constructor
  10388. * @param {Array} [entries] The key-value pairs to cache.
  10389. */
  10390. function Hash(entries) {
  10391. var index = -1,
  10392. length = entries == null ? 0 : entries.length;
  10393. this.clear();
  10394. while (++index < length) {
  10395. var entry = entries[index];
  10396. this.set(entry[0], entry[1]);
  10397. }
  10398. }
  10399. // Add methods to `Hash`.
  10400. Hash.prototype.clear = _hashClear;
  10401. Hash.prototype['delete'] = _hashDelete;
  10402. Hash.prototype.get = _hashGet;
  10403. Hash.prototype.has = _hashHas;
  10404. Hash.prototype.set = _hashSet;
  10405. var _Hash = Hash;
  10406. /**
  10407. * Removes all key-value entries from the map.
  10408. *
  10409. * @private
  10410. * @name clear
  10411. * @memberOf MapCache
  10412. */
  10413. function mapCacheClear() {
  10414. this.size = 0;
  10415. this.__data__ = {
  10416. 'hash': new _Hash,
  10417. 'map': new (_Map || _ListCache),
  10418. 'string': new _Hash
  10419. };
  10420. }
  10421. var _mapCacheClear = mapCacheClear;
  10422. /**
  10423. * Checks if `value` is suitable for use as unique object key.
  10424. *
  10425. * @private
  10426. * @param {*} value The value to check.
  10427. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10428. */
  10429. function isKeyable(value) {
  10430. var type = typeof value;
  10431. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  10432. ? (value !== '__proto__')
  10433. : (value === null);
  10434. }
  10435. var _isKeyable = isKeyable;
  10436. /**
  10437. * Gets the data for `map`.
  10438. *
  10439. * @private
  10440. * @param {Object} map The map to query.
  10441. * @param {string} key The reference key.
  10442. * @returns {*} Returns the map data.
  10443. */
  10444. function getMapData(map, key) {
  10445. var data = map.__data__;
  10446. return _isKeyable(key)
  10447. ? data[typeof key == 'string' ? 'string' : 'hash']
  10448. : data.map;
  10449. }
  10450. var _getMapData = getMapData;
  10451. /**
  10452. * Removes `key` and its value from the map.
  10453. *
  10454. * @private
  10455. * @name delete
  10456. * @memberOf MapCache
  10457. * @param {string} key The key of the value to remove.
  10458. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10459. */
  10460. function mapCacheDelete(key) {
  10461. var result = _getMapData(this, key)['delete'](key);
  10462. this.size -= result ? 1 : 0;
  10463. return result;
  10464. }
  10465. var _mapCacheDelete = mapCacheDelete;
  10466. /**
  10467. * Gets the map value for `key`.
  10468. *
  10469. * @private
  10470. * @name get
  10471. * @memberOf MapCache
  10472. * @param {string} key The key of the value to get.
  10473. * @returns {*} Returns the entry value.
  10474. */
  10475. function mapCacheGet(key) {
  10476. return _getMapData(this, key).get(key);
  10477. }
  10478. var _mapCacheGet = mapCacheGet;
  10479. /**
  10480. * Checks if a map value for `key` exists.
  10481. *
  10482. * @private
  10483. * @name has
  10484. * @memberOf MapCache
  10485. * @param {string} key The key of the entry to check.
  10486. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10487. */
  10488. function mapCacheHas(key) {
  10489. return _getMapData(this, key).has(key);
  10490. }
  10491. var _mapCacheHas = mapCacheHas;
  10492. /**
  10493. * Sets the map `key` to `value`.
  10494. *
  10495. * @private
  10496. * @name set
  10497. * @memberOf MapCache
  10498. * @param {string} key The key of the value to set.
  10499. * @param {*} value The value to set.
  10500. * @returns {Object} Returns the map cache instance.
  10501. */
  10502. function mapCacheSet(key, value) {
  10503. var data = _getMapData(this, key),
  10504. size = data.size;
  10505. data.set(key, value);
  10506. this.size += data.size == size ? 0 : 1;
  10507. return this;
  10508. }
  10509. var _mapCacheSet = mapCacheSet;
  10510. /**
  10511. * Creates a map cache object to store key-value pairs.
  10512. *
  10513. * @private
  10514. * @constructor
  10515. * @param {Array} [entries] The key-value pairs to cache.
  10516. */
  10517. function MapCache(entries) {
  10518. var index = -1,
  10519. length = entries == null ? 0 : entries.length;
  10520. this.clear();
  10521. while (++index < length) {
  10522. var entry = entries[index];
  10523. this.set(entry[0], entry[1]);
  10524. }
  10525. }
  10526. // Add methods to `MapCache`.
  10527. MapCache.prototype.clear = _mapCacheClear;
  10528. MapCache.prototype['delete'] = _mapCacheDelete;
  10529. MapCache.prototype.get = _mapCacheGet;
  10530. MapCache.prototype.has = _mapCacheHas;
  10531. MapCache.prototype.set = _mapCacheSet;
  10532. var _MapCache = MapCache;
  10533. /** Used as the size to enable large array optimizations. */
  10534. var LARGE_ARRAY_SIZE = 200;
  10535. /**
  10536. * Sets the stack `key` to `value`.
  10537. *
  10538. * @private
  10539. * @name set
  10540. * @memberOf Stack
  10541. * @param {string} key The key of the value to set.
  10542. * @param {*} value The value to set.
  10543. * @returns {Object} Returns the stack cache instance.
  10544. */
  10545. function stackSet(key, value) {
  10546. var data = this.__data__;
  10547. if (data instanceof _ListCache) {
  10548. var pairs = data.__data__;
  10549. if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  10550. pairs.push([key, value]);
  10551. this.size = ++data.size;
  10552. return this;
  10553. }
  10554. data = this.__data__ = new _MapCache(pairs);
  10555. }
  10556. data.set(key, value);
  10557. this.size = data.size;
  10558. return this;
  10559. }
  10560. var _stackSet = stackSet;
  10561. /**
  10562. * Creates a stack cache object to store key-value pairs.
  10563. *
  10564. * @private
  10565. * @constructor
  10566. * @param {Array} [entries] The key-value pairs to cache.
  10567. */
  10568. function Stack(entries) {
  10569. var data = this.__data__ = new _ListCache(entries);
  10570. this.size = data.size;
  10571. }
  10572. // Add methods to `Stack`.
  10573. Stack.prototype.clear = _stackClear;
  10574. Stack.prototype['delete'] = _stackDelete;
  10575. Stack.prototype.get = _stackGet;
  10576. Stack.prototype.has = _stackHas;
  10577. Stack.prototype.set = _stackSet;
  10578. var _Stack = Stack;
  10579. /**
  10580. * A specialized version of `_.forEach` for arrays without support for
  10581. * iteratee shorthands.
  10582. *
  10583. * @private
  10584. * @param {Array} [array] The array to iterate over.
  10585. * @param {Function} iteratee The function invoked per iteration.
  10586. * @returns {Array} Returns `array`.
  10587. */
  10588. function arrayEach(array, iteratee) {
  10589. var index = -1,
  10590. length = array == null ? 0 : array.length;
  10591. while (++index < length) {
  10592. if (iteratee(array[index], index, array) === false) {
  10593. break;
  10594. }
  10595. }
  10596. return array;
  10597. }
  10598. var _arrayEach = arrayEach;
  10599. var defineProperty = (function() {
  10600. try {
  10601. var func = _getNative(Object, 'defineProperty');
  10602. func({}, '', {});
  10603. return func;
  10604. } catch (e) {}
  10605. }());
  10606. var _defineProperty = defineProperty;
  10607. /**
  10608. * The base implementation of `assignValue` and `assignMergeValue` without
  10609. * value checks.
  10610. *
  10611. * @private
  10612. * @param {Object} object The object to modify.
  10613. * @param {string} key The key of the property to assign.
  10614. * @param {*} value The value to assign.
  10615. */
  10616. function baseAssignValue(object, key, value) {
  10617. if (key == '__proto__' && _defineProperty) {
  10618. _defineProperty(object, key, {
  10619. 'configurable': true,
  10620. 'enumerable': true,
  10621. 'value': value,
  10622. 'writable': true
  10623. });
  10624. } else {
  10625. object[key] = value;
  10626. }
  10627. }
  10628. var _baseAssignValue = baseAssignValue;
  10629. /** Used for built-in method references. */
  10630. var objectProto$5 = Object.prototype;
  10631. /** Used to check objects for own properties. */
  10632. var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
  10633. /**
  10634. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  10635. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10636. * for equality comparisons.
  10637. *
  10638. * @private
  10639. * @param {Object} object The object to modify.
  10640. * @param {string} key The key of the property to assign.
  10641. * @param {*} value The value to assign.
  10642. */
  10643. function assignValue(object, key, value) {
  10644. var objValue = object[key];
  10645. if (!(hasOwnProperty$5.call(object, key) && eq_1(objValue, value)) ||
  10646. (value === undefined && !(key in object))) {
  10647. _baseAssignValue(object, key, value);
  10648. }
  10649. }
  10650. var _assignValue = assignValue;
  10651. /**
  10652. * Copies properties of `source` to `object`.
  10653. *
  10654. * @private
  10655. * @param {Object} source The object to copy properties from.
  10656. * @param {Array} props The property identifiers to copy.
  10657. * @param {Object} [object={}] The object to copy properties to.
  10658. * @param {Function} [customizer] The function to customize copied values.
  10659. * @returns {Object} Returns `object`.
  10660. */
  10661. function copyObject(source, props, object, customizer) {
  10662. var isNew = !object;
  10663. object || (object = {});
  10664. var index = -1,
  10665. length = props.length;
  10666. while (++index < length) {
  10667. var key = props[index];
  10668. var newValue = customizer
  10669. ? customizer(object[key], source[key], key, object, source)
  10670. : undefined;
  10671. if (newValue === undefined) {
  10672. newValue = source[key];
  10673. }
  10674. if (isNew) {
  10675. _baseAssignValue(object, key, newValue);
  10676. } else {
  10677. _assignValue(object, key, newValue);
  10678. }
  10679. }
  10680. return object;
  10681. }
  10682. var _copyObject = copyObject;
  10683. /**
  10684. * The base implementation of `_.times` without support for iteratee shorthands
  10685. * or max array length checks.
  10686. *
  10687. * @private
  10688. * @param {number} n The number of times to invoke `iteratee`.
  10689. * @param {Function} iteratee The function invoked per iteration.
  10690. * @returns {Array} Returns the array of results.
  10691. */
  10692. function baseTimes(n, iteratee) {
  10693. var index = -1,
  10694. result = Array(n);
  10695. while (++index < n) {
  10696. result[index] = iteratee(index);
  10697. }
  10698. return result;
  10699. }
  10700. var _baseTimes = baseTimes;
  10701. /**
  10702. * Checks if `value` is object-like. A value is object-like if it's not `null`
  10703. * and has a `typeof` result of "object".
  10704. *
  10705. * @static
  10706. * @memberOf _
  10707. * @since 4.0.0
  10708. * @category Lang
  10709. * @param {*} value The value to check.
  10710. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  10711. * @example
  10712. *
  10713. * _.isObjectLike({});
  10714. * // => true
  10715. *
  10716. * _.isObjectLike([1, 2, 3]);
  10717. * // => true
  10718. *
  10719. * _.isObjectLike(_.noop);
  10720. * // => false
  10721. *
  10722. * _.isObjectLike(null);
  10723. * // => false
  10724. */
  10725. function isObjectLike(value) {
  10726. return value != null && typeof value == 'object';
  10727. }
  10728. var isObjectLike_1 = isObjectLike;
  10729. /** `Object#toString` result references. */
  10730. var argsTag = '[object Arguments]';
  10731. /**
  10732. * The base implementation of `_.isArguments`.
  10733. *
  10734. * @private
  10735. * @param {*} value The value to check.
  10736. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10737. */
  10738. function baseIsArguments(value) {
  10739. return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
  10740. }
  10741. var _baseIsArguments = baseIsArguments;
  10742. /** Used for built-in method references. */
  10743. var objectProto$6 = Object.prototype;
  10744. /** Used to check objects for own properties. */
  10745. var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
  10746. /** Built-in value references. */
  10747. var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
  10748. /**
  10749. * Checks if `value` is likely an `arguments` object.
  10750. *
  10751. * @static
  10752. * @memberOf _
  10753. * @since 0.1.0
  10754. * @category Lang
  10755. * @param {*} value The value to check.
  10756. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10757. * else `false`.
  10758. * @example
  10759. *
  10760. * _.isArguments(function() { return arguments; }());
  10761. * // => true
  10762. *
  10763. * _.isArguments([1, 2, 3]);
  10764. * // => false
  10765. */
  10766. var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
  10767. return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') &&
  10768. !propertyIsEnumerable.call(value, 'callee');
  10769. };
  10770. var isArguments_1 = isArguments;
  10771. /**
  10772. * Checks if `value` is classified as an `Array` object.
  10773. *
  10774. * @static
  10775. * @memberOf _
  10776. * @since 0.1.0
  10777. * @category Lang
  10778. * @param {*} value The value to check.
  10779. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  10780. * @example
  10781. *
  10782. * _.isArray([1, 2, 3]);
  10783. * // => true
  10784. *
  10785. * _.isArray(document.body.children);
  10786. * // => false
  10787. *
  10788. * _.isArray('abc');
  10789. * // => false
  10790. *
  10791. * _.isArray(_.noop);
  10792. * // => false
  10793. */
  10794. var isArray = Array.isArray;
  10795. var isArray_1 = isArray;
  10796. /**
  10797. * This method returns `false`.
  10798. *
  10799. * @static
  10800. * @memberOf _
  10801. * @since 4.13.0
  10802. * @category Util
  10803. * @returns {boolean} Returns `false`.
  10804. * @example
  10805. *
  10806. * _.times(2, _.stubFalse);
  10807. * // => [false, false]
  10808. */
  10809. function stubFalse() {
  10810. return false;
  10811. }
  10812. var stubFalse_1 = stubFalse;
  10813. var isBuffer_1$1 = createCommonjsModule(function (module, exports) {
  10814. /** Detect free variable `exports`. */
  10815. var freeExports = exports && !exports.nodeType && exports;
  10816. /** Detect free variable `module`. */
  10817. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  10818. /** Detect the popular CommonJS extension `module.exports`. */
  10819. var moduleExports = freeModule && freeModule.exports === freeExports;
  10820. /** Built-in value references. */
  10821. var Buffer = moduleExports ? _root.Buffer : undefined;
  10822. /* Built-in method references for those with the same name as other `lodash` methods. */
  10823. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  10824. /**
  10825. * Checks if `value` is a buffer.
  10826. *
  10827. * @static
  10828. * @memberOf _
  10829. * @since 4.3.0
  10830. * @category Lang
  10831. * @param {*} value The value to check.
  10832. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  10833. * @example
  10834. *
  10835. * _.isBuffer(new Buffer(2));
  10836. * // => true
  10837. *
  10838. * _.isBuffer(new Uint8Array(2));
  10839. * // => false
  10840. */
  10841. var isBuffer = nativeIsBuffer || stubFalse_1;
  10842. module.exports = isBuffer;
  10843. });
  10844. /** Used as references for various `Number` constants. */
  10845. var MAX_SAFE_INTEGER = 9007199254740991;
  10846. /** Used to detect unsigned integer values. */
  10847. var reIsUint = /^(?:0|[1-9]\d*)$/;
  10848. /**
  10849. * Checks if `value` is a valid array-like index.
  10850. *
  10851. * @private
  10852. * @param {*} value The value to check.
  10853. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  10854. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  10855. */
  10856. function isIndex(value, length) {
  10857. var type = typeof value;
  10858. length = length == null ? MAX_SAFE_INTEGER : length;
  10859. return !!length &&
  10860. (type == 'number' ||
  10861. (type != 'symbol' && reIsUint.test(value))) &&
  10862. (value > -1 && value % 1 == 0 && value < length);
  10863. }
  10864. var _isIndex = isIndex;
  10865. /** Used as references for various `Number` constants. */
  10866. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  10867. /**
  10868. * Checks if `value` is a valid array-like length.
  10869. *
  10870. * **Note:** This method is loosely based on
  10871. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  10872. *
  10873. * @static
  10874. * @memberOf _
  10875. * @since 4.0.0
  10876. * @category Lang
  10877. * @param {*} value The value to check.
  10878. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  10879. * @example
  10880. *
  10881. * _.isLength(3);
  10882. * // => true
  10883. *
  10884. * _.isLength(Number.MIN_VALUE);
  10885. * // => false
  10886. *
  10887. * _.isLength(Infinity);
  10888. * // => false
  10889. *
  10890. * _.isLength('3');
  10891. * // => false
  10892. */
  10893. function isLength(value) {
  10894. return typeof value == 'number' &&
  10895. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
  10896. }
  10897. var isLength_1 = isLength;
  10898. /** `Object#toString` result references. */
  10899. var argsTag$1 = '[object Arguments]',
  10900. arrayTag = '[object Array]',
  10901. boolTag = '[object Boolean]',
  10902. dateTag = '[object Date]',
  10903. errorTag = '[object Error]',
  10904. funcTag$1 = '[object Function]',
  10905. mapTag = '[object Map]',
  10906. numberTag = '[object Number]',
  10907. objectTag = '[object Object]',
  10908. regexpTag = '[object RegExp]',
  10909. setTag = '[object Set]',
  10910. stringTag = '[object String]',
  10911. weakMapTag = '[object WeakMap]';
  10912. var arrayBufferTag = '[object ArrayBuffer]',
  10913. dataViewTag = '[object DataView]',
  10914. float32Tag = '[object Float32Array]',
  10915. float64Tag = '[object Float64Array]',
  10916. int8Tag = '[object Int8Array]',
  10917. int16Tag = '[object Int16Array]',
  10918. int32Tag = '[object Int32Array]',
  10919. uint8Tag = '[object Uint8Array]',
  10920. uint8ClampedTag = '[object Uint8ClampedArray]',
  10921. uint16Tag = '[object Uint16Array]',
  10922. uint32Tag = '[object Uint32Array]';
  10923. /** Used to identify `toStringTag` values of typed arrays. */
  10924. var typedArrayTags = {};
  10925. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  10926. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  10927. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  10928. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  10929. typedArrayTags[uint32Tag] = true;
  10930. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
  10931. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  10932. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  10933. typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
  10934. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  10935. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  10936. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  10937. typedArrayTags[weakMapTag] = false;
  10938. /**
  10939. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  10940. *
  10941. * @private
  10942. * @param {*} value The value to check.
  10943. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10944. */
  10945. function baseIsTypedArray(value) {
  10946. return isObjectLike_1(value) &&
  10947. isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
  10948. }
  10949. var _baseIsTypedArray = baseIsTypedArray;
  10950. /**
  10951. * The base implementation of `_.unary` without support for storing metadata.
  10952. *
  10953. * @private
  10954. * @param {Function} func The function to cap arguments for.
  10955. * @returns {Function} Returns the new capped function.
  10956. */
  10957. function baseUnary(func) {
  10958. return function(value) {
  10959. return func(value);
  10960. };
  10961. }
  10962. var _baseUnary = baseUnary;
  10963. var _nodeUtil = createCommonjsModule(function (module, exports) {
  10964. /** Detect free variable `exports`. */
  10965. var freeExports = exports && !exports.nodeType && exports;
  10966. /** Detect free variable `module`. */
  10967. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  10968. /** Detect the popular CommonJS extension `module.exports`. */
  10969. var moduleExports = freeModule && freeModule.exports === freeExports;
  10970. /** Detect free variable `process` from Node.js. */
  10971. var freeProcess = moduleExports && _freeGlobal.process;
  10972. /** Used to access faster Node.js helpers. */
  10973. var nodeUtil = (function() {
  10974. try {
  10975. // Use `util.types` for Node.js 10+.
  10976. var types = freeModule && freeModule.require && freeModule.require('util').types;
  10977. if (types) {
  10978. return types;
  10979. }
  10980. // Legacy `process.binding('util')` for Node.js < 10.
  10981. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  10982. } catch (e) {}
  10983. }());
  10984. module.exports = nodeUtil;
  10985. });
  10986. /* Node.js helper references. */
  10987. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  10988. /**
  10989. * Checks if `value` is classified as a typed array.
  10990. *
  10991. * @static
  10992. * @memberOf _
  10993. * @since 3.0.0
  10994. * @category Lang
  10995. * @param {*} value The value to check.
  10996. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10997. * @example
  10998. *
  10999. * _.isTypedArray(new Uint8Array);
  11000. * // => true
  11001. *
  11002. * _.isTypedArray([]);
  11003. * // => false
  11004. */
  11005. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  11006. var isTypedArray_1 = isTypedArray;
  11007. /** Used for built-in method references. */
  11008. var objectProto$7 = Object.prototype;
  11009. /** Used to check objects for own properties. */
  11010. var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
  11011. /**
  11012. * Creates an array of the enumerable property names of the array-like `value`.
  11013. *
  11014. * @private
  11015. * @param {*} value The value to query.
  11016. * @param {boolean} inherited Specify returning inherited property names.
  11017. * @returns {Array} Returns the array of property names.
  11018. */
  11019. function arrayLikeKeys(value, inherited) {
  11020. var isArr = isArray_1(value),
  11021. isArg = !isArr && isArguments_1(value),
  11022. isBuff = !isArr && !isArg && isBuffer_1$1(value),
  11023. isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
  11024. skipIndexes = isArr || isArg || isBuff || isType,
  11025. result = skipIndexes ? _baseTimes(value.length, String) : [],
  11026. length = result.length;
  11027. for (var key in value) {
  11028. if ((inherited || hasOwnProperty$7.call(value, key)) &&
  11029. !(skipIndexes && (
  11030. // Safari 9 has enumerable `arguments.length` in strict mode.
  11031. key == 'length' ||
  11032. // Node.js 0.10 has enumerable non-index properties on buffers.
  11033. (isBuff && (key == 'offset' || key == 'parent')) ||
  11034. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  11035. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  11036. // Skip index properties.
  11037. _isIndex(key, length)
  11038. ))) {
  11039. result.push(key);
  11040. }
  11041. }
  11042. return result;
  11043. }
  11044. var _arrayLikeKeys = arrayLikeKeys;
  11045. /** Used for built-in method references. */
  11046. var objectProto$8 = Object.prototype;
  11047. /**
  11048. * Checks if `value` is likely a prototype object.
  11049. *
  11050. * @private
  11051. * @param {*} value The value to check.
  11052. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  11053. */
  11054. function isPrototype(value) {
  11055. var Ctor = value && value.constructor,
  11056. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
  11057. return value === proto;
  11058. }
  11059. var _isPrototype = isPrototype;
  11060. /**
  11061. * Creates a unary function that invokes `func` with its argument transformed.
  11062. *
  11063. * @private
  11064. * @param {Function} func The function to wrap.
  11065. * @param {Function} transform The argument transform.
  11066. * @returns {Function} Returns the new function.
  11067. */
  11068. function overArg(func, transform) {
  11069. return function(arg) {
  11070. return func(transform(arg));
  11071. };
  11072. }
  11073. var _overArg = overArg;
  11074. /* Built-in method references for those with the same name as other `lodash` methods. */
  11075. var nativeKeys = _overArg(Object.keys, Object);
  11076. var _nativeKeys = nativeKeys;
  11077. /** Used for built-in method references. */
  11078. var objectProto$9 = Object.prototype;
  11079. /** Used to check objects for own properties. */
  11080. var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
  11081. /**
  11082. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  11083. *
  11084. * @private
  11085. * @param {Object} object The object to query.
  11086. * @returns {Array} Returns the array of property names.
  11087. */
  11088. function baseKeys(object) {
  11089. if (!_isPrototype(object)) {
  11090. return _nativeKeys(object);
  11091. }
  11092. var result = [];
  11093. for (var key in Object(object)) {
  11094. if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
  11095. result.push(key);
  11096. }
  11097. }
  11098. return result;
  11099. }
  11100. var _baseKeys = baseKeys;
  11101. /**
  11102. * Checks if `value` is array-like. A value is considered array-like if it's
  11103. * not a function and has a `value.length` that's an integer greater than or
  11104. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11105. *
  11106. * @static
  11107. * @memberOf _
  11108. * @since 4.0.0
  11109. * @category Lang
  11110. * @param {*} value The value to check.
  11111. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11112. * @example
  11113. *
  11114. * _.isArrayLike([1, 2, 3]);
  11115. * // => true
  11116. *
  11117. * _.isArrayLike(document.body.children);
  11118. * // => true
  11119. *
  11120. * _.isArrayLike('abc');
  11121. * // => true
  11122. *
  11123. * _.isArrayLike(_.noop);
  11124. * // => false
  11125. */
  11126. function isArrayLike(value) {
  11127. return value != null && isLength_1(value.length) && !isFunction_1(value);
  11128. }
  11129. var isArrayLike_1 = isArrayLike;
  11130. /**
  11131. * Creates an array of the own enumerable property names of `object`.
  11132. *
  11133. * **Note:** Non-object values are coerced to objects. See the
  11134. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11135. * for more details.
  11136. *
  11137. * @static
  11138. * @since 0.1.0
  11139. * @memberOf _
  11140. * @category Object
  11141. * @param {Object} object The object to query.
  11142. * @returns {Array} Returns the array of property names.
  11143. * @example
  11144. *
  11145. * function Foo() {
  11146. * this.a = 1;
  11147. * this.b = 2;
  11148. * }
  11149. *
  11150. * Foo.prototype.c = 3;
  11151. *
  11152. * _.keys(new Foo);
  11153. * // => ['a', 'b'] (iteration order is not guaranteed)
  11154. *
  11155. * _.keys('hi');
  11156. * // => ['0', '1']
  11157. */
  11158. function keys$1(object) {
  11159. return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  11160. }
  11161. var keys_1 = keys$1;
  11162. /**
  11163. * The base implementation of `_.assign` without support for multiple sources
  11164. * or `customizer` functions.
  11165. *
  11166. * @private
  11167. * @param {Object} object The destination object.
  11168. * @param {Object} source The source object.
  11169. * @returns {Object} Returns `object`.
  11170. */
  11171. function baseAssign(object, source) {
  11172. return object && _copyObject(source, keys_1(source), object);
  11173. }
  11174. var _baseAssign = baseAssign;
  11175. /**
  11176. * This function is like
  11177. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11178. * except that it includes inherited enumerable properties.
  11179. *
  11180. * @private
  11181. * @param {Object} object The object to query.
  11182. * @returns {Array} Returns the array of property names.
  11183. */
  11184. function nativeKeysIn(object) {
  11185. var result = [];
  11186. if (object != null) {
  11187. for (var key in Object(object)) {
  11188. result.push(key);
  11189. }
  11190. }
  11191. return result;
  11192. }
  11193. var _nativeKeysIn = nativeKeysIn;
  11194. /** Used for built-in method references. */
  11195. var objectProto$a = Object.prototype;
  11196. /** Used to check objects for own properties. */
  11197. var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
  11198. /**
  11199. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  11200. *
  11201. * @private
  11202. * @param {Object} object The object to query.
  11203. * @returns {Array} Returns the array of property names.
  11204. */
  11205. function baseKeysIn(object) {
  11206. if (!isObject_1(object)) {
  11207. return _nativeKeysIn(object);
  11208. }
  11209. var isProto = _isPrototype(object),
  11210. result = [];
  11211. for (var key in object) {
  11212. if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
  11213. result.push(key);
  11214. }
  11215. }
  11216. return result;
  11217. }
  11218. var _baseKeysIn = baseKeysIn;
  11219. /**
  11220. * Creates an array of the own and inherited enumerable property names of `object`.
  11221. *
  11222. * **Note:** Non-object values are coerced to objects.
  11223. *
  11224. * @static
  11225. * @memberOf _
  11226. * @since 3.0.0
  11227. * @category Object
  11228. * @param {Object} object The object to query.
  11229. * @returns {Array} Returns the array of property names.
  11230. * @example
  11231. *
  11232. * function Foo() {
  11233. * this.a = 1;
  11234. * this.b = 2;
  11235. * }
  11236. *
  11237. * Foo.prototype.c = 3;
  11238. *
  11239. * _.keysIn(new Foo);
  11240. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  11241. */
  11242. function keysIn(object) {
  11243. return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
  11244. }
  11245. var keysIn_1 = keysIn;
  11246. /**
  11247. * The base implementation of `_.assignIn` without support for multiple sources
  11248. * or `customizer` functions.
  11249. *
  11250. * @private
  11251. * @param {Object} object The destination object.
  11252. * @param {Object} source The source object.
  11253. * @returns {Object} Returns `object`.
  11254. */
  11255. function baseAssignIn(object, source) {
  11256. return object && _copyObject(source, keysIn_1(source), object);
  11257. }
  11258. var _baseAssignIn = baseAssignIn;
  11259. var _cloneBuffer = createCommonjsModule(function (module, exports) {
  11260. /** Detect free variable `exports`. */
  11261. var freeExports = exports && !exports.nodeType && exports;
  11262. /** Detect free variable `module`. */
  11263. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  11264. /** Detect the popular CommonJS extension `module.exports`. */
  11265. var moduleExports = freeModule && freeModule.exports === freeExports;
  11266. /** Built-in value references. */
  11267. var Buffer = moduleExports ? _root.Buffer : undefined,
  11268. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  11269. /**
  11270. * Creates a clone of `buffer`.
  11271. *
  11272. * @private
  11273. * @param {Buffer} buffer The buffer to clone.
  11274. * @param {boolean} [isDeep] Specify a deep clone.
  11275. * @returns {Buffer} Returns the cloned buffer.
  11276. */
  11277. function cloneBuffer(buffer, isDeep) {
  11278. if (isDeep) {
  11279. return buffer.slice();
  11280. }
  11281. var length = buffer.length,
  11282. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  11283. buffer.copy(result);
  11284. return result;
  11285. }
  11286. module.exports = cloneBuffer;
  11287. });
  11288. /**
  11289. * Copies the values of `source` to `array`.
  11290. *
  11291. * @private
  11292. * @param {Array} source The array to copy values from.
  11293. * @param {Array} [array=[]] The array to copy values to.
  11294. * @returns {Array} Returns `array`.
  11295. */
  11296. function copyArray(source, array) {
  11297. var index = -1,
  11298. length = source.length;
  11299. array || (array = Array(length));
  11300. while (++index < length) {
  11301. array[index] = source[index];
  11302. }
  11303. return array;
  11304. }
  11305. var _copyArray = copyArray;
  11306. /**
  11307. * A specialized version of `_.filter` for arrays without support for
  11308. * iteratee shorthands.
  11309. *
  11310. * @private
  11311. * @param {Array} [array] The array to iterate over.
  11312. * @param {Function} predicate The function invoked per iteration.
  11313. * @returns {Array} Returns the new filtered array.
  11314. */
  11315. function arrayFilter(array, predicate) {
  11316. var index = -1,
  11317. length = array == null ? 0 : array.length,
  11318. resIndex = 0,
  11319. result = [];
  11320. while (++index < length) {
  11321. var value = array[index];
  11322. if (predicate(value, index, array)) {
  11323. result[resIndex++] = value;
  11324. }
  11325. }
  11326. return result;
  11327. }
  11328. var _arrayFilter = arrayFilter;
  11329. /**
  11330. * This method returns a new empty array.
  11331. *
  11332. * @static
  11333. * @memberOf _
  11334. * @since 4.13.0
  11335. * @category Util
  11336. * @returns {Array} Returns the new empty array.
  11337. * @example
  11338. *
  11339. * var arrays = _.times(2, _.stubArray);
  11340. *
  11341. * console.log(arrays);
  11342. * // => [[], []]
  11343. *
  11344. * console.log(arrays[0] === arrays[1]);
  11345. * // => false
  11346. */
  11347. function stubArray() {
  11348. return [];
  11349. }
  11350. var stubArray_1 = stubArray;
  11351. /** Used for built-in method references. */
  11352. var objectProto$b = Object.prototype;
  11353. /** Built-in value references. */
  11354. var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
  11355. /* Built-in method references for those with the same name as other `lodash` methods. */
  11356. var nativeGetSymbols = Object.getOwnPropertySymbols;
  11357. /**
  11358. * Creates an array of the own enumerable symbols of `object`.
  11359. *
  11360. * @private
  11361. * @param {Object} object The object to query.
  11362. * @returns {Array} Returns the array of symbols.
  11363. */
  11364. var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
  11365. if (object == null) {
  11366. return [];
  11367. }
  11368. object = Object(object);
  11369. return _arrayFilter(nativeGetSymbols(object), function(symbol) {
  11370. return propertyIsEnumerable$1.call(object, symbol);
  11371. });
  11372. };
  11373. var _getSymbols = getSymbols;
  11374. /**
  11375. * Copies own symbols of `source` to `object`.
  11376. *
  11377. * @private
  11378. * @param {Object} source The object to copy symbols from.
  11379. * @param {Object} [object={}] The object to copy symbols to.
  11380. * @returns {Object} Returns `object`.
  11381. */
  11382. function copySymbols(source, object) {
  11383. return _copyObject(source, _getSymbols(source), object);
  11384. }
  11385. var _copySymbols = copySymbols;
  11386. /**
  11387. * Appends the elements of `values` to `array`.
  11388. *
  11389. * @private
  11390. * @param {Array} array The array to modify.
  11391. * @param {Array} values The values to append.
  11392. * @returns {Array} Returns `array`.
  11393. */
  11394. function arrayPush(array, values) {
  11395. var index = -1,
  11396. length = values.length,
  11397. offset = array.length;
  11398. while (++index < length) {
  11399. array[offset + index] = values[index];
  11400. }
  11401. return array;
  11402. }
  11403. var _arrayPush = arrayPush;
  11404. /** Built-in value references. */
  11405. var getPrototype = _overArg(Object.getPrototypeOf, Object);
  11406. var _getPrototype = getPrototype;
  11407. /* Built-in method references for those with the same name as other `lodash` methods. */
  11408. var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
  11409. /**
  11410. * Creates an array of the own and inherited enumerable symbols of `object`.
  11411. *
  11412. * @private
  11413. * @param {Object} object The object to query.
  11414. * @returns {Array} Returns the array of symbols.
  11415. */
  11416. var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
  11417. var result = [];
  11418. while (object) {
  11419. _arrayPush(result, _getSymbols(object));
  11420. object = _getPrototype(object);
  11421. }
  11422. return result;
  11423. };
  11424. var _getSymbolsIn = getSymbolsIn;
  11425. /**
  11426. * Copies own and inherited symbols of `source` to `object`.
  11427. *
  11428. * @private
  11429. * @param {Object} source The object to copy symbols from.
  11430. * @param {Object} [object={}] The object to copy symbols to.
  11431. * @returns {Object} Returns `object`.
  11432. */
  11433. function copySymbolsIn(source, object) {
  11434. return _copyObject(source, _getSymbolsIn(source), object);
  11435. }
  11436. var _copySymbolsIn = copySymbolsIn;
  11437. /**
  11438. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  11439. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  11440. * symbols of `object`.
  11441. *
  11442. * @private
  11443. * @param {Object} object The object to query.
  11444. * @param {Function} keysFunc The function to get the keys of `object`.
  11445. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  11446. * @returns {Array} Returns the array of property names and symbols.
  11447. */
  11448. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  11449. var result = keysFunc(object);
  11450. return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
  11451. }
  11452. var _baseGetAllKeys = baseGetAllKeys;
  11453. /**
  11454. * Creates an array of own enumerable property names and symbols of `object`.
  11455. *
  11456. * @private
  11457. * @param {Object} object The object to query.
  11458. * @returns {Array} Returns the array of property names and symbols.
  11459. */
  11460. function getAllKeys(object) {
  11461. return _baseGetAllKeys(object, keys_1, _getSymbols);
  11462. }
  11463. var _getAllKeys = getAllKeys;
  11464. /**
  11465. * Creates an array of own and inherited enumerable property names and
  11466. * symbols of `object`.
  11467. *
  11468. * @private
  11469. * @param {Object} object The object to query.
  11470. * @returns {Array} Returns the array of property names and symbols.
  11471. */
  11472. function getAllKeysIn(object) {
  11473. return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
  11474. }
  11475. var _getAllKeysIn = getAllKeysIn;
  11476. /* Built-in method references that are verified to be native. */
  11477. var DataView = _getNative(_root, 'DataView');
  11478. var _DataView = DataView;
  11479. /* Built-in method references that are verified to be native. */
  11480. var Promise$1 = _getNative(_root, 'Promise');
  11481. var _Promise = Promise$1;
  11482. /* Built-in method references that are verified to be native. */
  11483. var Set$1 = _getNative(_root, 'Set');
  11484. var _Set = Set$1;
  11485. /* Built-in method references that are verified to be native. */
  11486. var WeakMap = _getNative(_root, 'WeakMap');
  11487. var _WeakMap = WeakMap;
  11488. /** `Object#toString` result references. */
  11489. var mapTag$1 = '[object Map]',
  11490. objectTag$1 = '[object Object]',
  11491. promiseTag = '[object Promise]',
  11492. setTag$1 = '[object Set]',
  11493. weakMapTag$1 = '[object WeakMap]';
  11494. var dataViewTag$1 = '[object DataView]';
  11495. /** Used to detect maps, sets, and weakmaps. */
  11496. var dataViewCtorString = _toSource(_DataView),
  11497. mapCtorString = _toSource(_Map),
  11498. promiseCtorString = _toSource(_Promise),
  11499. setCtorString = _toSource(_Set),
  11500. weakMapCtorString = _toSource(_WeakMap);
  11501. /**
  11502. * Gets the `toStringTag` of `value`.
  11503. *
  11504. * @private
  11505. * @param {*} value The value to query.
  11506. * @returns {string} Returns the `toStringTag`.
  11507. */
  11508. var getTag = _baseGetTag;
  11509. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  11510. if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
  11511. (_Map && getTag(new _Map) != mapTag$1) ||
  11512. (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
  11513. (_Set && getTag(new _Set) != setTag$1) ||
  11514. (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
  11515. getTag = function(value) {
  11516. var result = _baseGetTag(value),
  11517. Ctor = result == objectTag$1 ? value.constructor : undefined,
  11518. ctorString = Ctor ? _toSource(Ctor) : '';
  11519. if (ctorString) {
  11520. switch (ctorString) {
  11521. case dataViewCtorString: return dataViewTag$1;
  11522. case mapCtorString: return mapTag$1;
  11523. case promiseCtorString: return promiseTag;
  11524. case setCtorString: return setTag$1;
  11525. case weakMapCtorString: return weakMapTag$1;
  11526. }
  11527. }
  11528. return result;
  11529. };
  11530. }
  11531. var _getTag = getTag;
  11532. /** Used for built-in method references. */
  11533. var objectProto$c = Object.prototype;
  11534. /** Used to check objects for own properties. */
  11535. var hasOwnProperty$a = objectProto$c.hasOwnProperty;
  11536. /**
  11537. * Initializes an array clone.
  11538. *
  11539. * @private
  11540. * @param {Array} array The array to clone.
  11541. * @returns {Array} Returns the initialized clone.
  11542. */
  11543. function initCloneArray(array) {
  11544. var length = array.length,
  11545. result = new array.constructor(length);
  11546. // Add properties assigned by `RegExp#exec`.
  11547. if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
  11548. result.index = array.index;
  11549. result.input = array.input;
  11550. }
  11551. return result;
  11552. }
  11553. var _initCloneArray = initCloneArray;
  11554. /** Built-in value references. */
  11555. var Uint8Array = _root.Uint8Array;
  11556. var _Uint8Array = Uint8Array;
  11557. /**
  11558. * Creates a clone of `arrayBuffer`.
  11559. *
  11560. * @private
  11561. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  11562. * @returns {ArrayBuffer} Returns the cloned array buffer.
  11563. */
  11564. function cloneArrayBuffer(arrayBuffer) {
  11565. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  11566. new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  11567. return result;
  11568. }
  11569. var _cloneArrayBuffer = cloneArrayBuffer;
  11570. /**
  11571. * Creates a clone of `dataView`.
  11572. *
  11573. * @private
  11574. * @param {Object} dataView The data view to clone.
  11575. * @param {boolean} [isDeep] Specify a deep clone.
  11576. * @returns {Object} Returns the cloned data view.
  11577. */
  11578. function cloneDataView(dataView, isDeep) {
  11579. var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  11580. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  11581. }
  11582. var _cloneDataView = cloneDataView;
  11583. /** Used to match `RegExp` flags from their coerced string values. */
  11584. var reFlags = /\w*$/;
  11585. /**
  11586. * Creates a clone of `regexp`.
  11587. *
  11588. * @private
  11589. * @param {Object} regexp The regexp to clone.
  11590. * @returns {Object} Returns the cloned regexp.
  11591. */
  11592. function cloneRegExp(regexp) {
  11593. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  11594. result.lastIndex = regexp.lastIndex;
  11595. return result;
  11596. }
  11597. var _cloneRegExp = cloneRegExp;
  11598. /** Used to convert symbols to primitives and strings. */
  11599. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  11600. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  11601. /**
  11602. * Creates a clone of the `symbol` object.
  11603. *
  11604. * @private
  11605. * @param {Object} symbol The symbol object to clone.
  11606. * @returns {Object} Returns the cloned symbol object.
  11607. */
  11608. function cloneSymbol(symbol) {
  11609. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  11610. }
  11611. var _cloneSymbol = cloneSymbol;
  11612. /**
  11613. * Creates a clone of `typedArray`.
  11614. *
  11615. * @private
  11616. * @param {Object} typedArray The typed array to clone.
  11617. * @param {boolean} [isDeep] Specify a deep clone.
  11618. * @returns {Object} Returns the cloned typed array.
  11619. */
  11620. function cloneTypedArray(typedArray, isDeep) {
  11621. var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  11622. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  11623. }
  11624. var _cloneTypedArray = cloneTypedArray;
  11625. /** `Object#toString` result references. */
  11626. var boolTag$1 = '[object Boolean]',
  11627. dateTag$1 = '[object Date]',
  11628. mapTag$2 = '[object Map]',
  11629. numberTag$1 = '[object Number]',
  11630. regexpTag$1 = '[object RegExp]',
  11631. setTag$2 = '[object Set]',
  11632. stringTag$1 = '[object String]',
  11633. symbolTag = '[object Symbol]';
  11634. var arrayBufferTag$1 = '[object ArrayBuffer]',
  11635. dataViewTag$2 = '[object DataView]',
  11636. float32Tag$1 = '[object Float32Array]',
  11637. float64Tag$1 = '[object Float64Array]',
  11638. int8Tag$1 = '[object Int8Array]',
  11639. int16Tag$1 = '[object Int16Array]',
  11640. int32Tag$1 = '[object Int32Array]',
  11641. uint8Tag$1 = '[object Uint8Array]',
  11642. uint8ClampedTag$1 = '[object Uint8ClampedArray]',
  11643. uint16Tag$1 = '[object Uint16Array]',
  11644. uint32Tag$1 = '[object Uint32Array]';
  11645. /**
  11646. * Initializes an object clone based on its `toStringTag`.
  11647. *
  11648. * **Note:** This function only supports cloning values with tags of
  11649. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  11650. *
  11651. * @private
  11652. * @param {Object} object The object to clone.
  11653. * @param {string} tag The `toStringTag` of the object to clone.
  11654. * @param {boolean} [isDeep] Specify a deep clone.
  11655. * @returns {Object} Returns the initialized clone.
  11656. */
  11657. function initCloneByTag(object, tag, isDeep) {
  11658. var Ctor = object.constructor;
  11659. switch (tag) {
  11660. case arrayBufferTag$1:
  11661. return _cloneArrayBuffer(object);
  11662. case boolTag$1:
  11663. case dateTag$1:
  11664. return new Ctor(+object);
  11665. case dataViewTag$2:
  11666. return _cloneDataView(object, isDeep);
  11667. case float32Tag$1: case float64Tag$1:
  11668. case int8Tag$1: case int16Tag$1: case int32Tag$1:
  11669. case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
  11670. return _cloneTypedArray(object, isDeep);
  11671. case mapTag$2:
  11672. return new Ctor;
  11673. case numberTag$1:
  11674. case stringTag$1:
  11675. return new Ctor(object);
  11676. case regexpTag$1:
  11677. return _cloneRegExp(object);
  11678. case setTag$2:
  11679. return new Ctor;
  11680. case symbolTag:
  11681. return _cloneSymbol(object);
  11682. }
  11683. }
  11684. var _initCloneByTag = initCloneByTag;
  11685. /** Built-in value references. */
  11686. var objectCreate = Object.create;
  11687. /**
  11688. * The base implementation of `_.create` without support for assigning
  11689. * properties to the created object.
  11690. *
  11691. * @private
  11692. * @param {Object} proto The object to inherit from.
  11693. * @returns {Object} Returns the new object.
  11694. */
  11695. var baseCreate = (function() {
  11696. function object() {}
  11697. return function(proto) {
  11698. if (!isObject_1(proto)) {
  11699. return {};
  11700. }
  11701. if (objectCreate) {
  11702. return objectCreate(proto);
  11703. }
  11704. object.prototype = proto;
  11705. var result = new object;
  11706. object.prototype = undefined;
  11707. return result;
  11708. };
  11709. }());
  11710. var _baseCreate = baseCreate;
  11711. /**
  11712. * Initializes an object clone.
  11713. *
  11714. * @private
  11715. * @param {Object} object The object to clone.
  11716. * @returns {Object} Returns the initialized clone.
  11717. */
  11718. function initCloneObject(object) {
  11719. return (typeof object.constructor == 'function' && !_isPrototype(object))
  11720. ? _baseCreate(_getPrototype(object))
  11721. : {};
  11722. }
  11723. var _initCloneObject = initCloneObject;
  11724. /** `Object#toString` result references. */
  11725. var mapTag$3 = '[object Map]';
  11726. /**
  11727. * The base implementation of `_.isMap` without Node.js optimizations.
  11728. *
  11729. * @private
  11730. * @param {*} value The value to check.
  11731. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11732. */
  11733. function baseIsMap(value) {
  11734. return isObjectLike_1(value) && _getTag(value) == mapTag$3;
  11735. }
  11736. var _baseIsMap = baseIsMap;
  11737. /* Node.js helper references. */
  11738. var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
  11739. /**
  11740. * Checks if `value` is classified as a `Map` object.
  11741. *
  11742. * @static
  11743. * @memberOf _
  11744. * @since 4.3.0
  11745. * @category Lang
  11746. * @param {*} value The value to check.
  11747. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11748. * @example
  11749. *
  11750. * _.isMap(new Map);
  11751. * // => true
  11752. *
  11753. * _.isMap(new WeakMap);
  11754. * // => false
  11755. */
  11756. var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
  11757. var isMap_1 = isMap;
  11758. /** `Object#toString` result references. */
  11759. var setTag$3 = '[object Set]';
  11760. /**
  11761. * The base implementation of `_.isSet` without Node.js optimizations.
  11762. *
  11763. * @private
  11764. * @param {*} value The value to check.
  11765. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  11766. */
  11767. function baseIsSet(value) {
  11768. return isObjectLike_1(value) && _getTag(value) == setTag$3;
  11769. }
  11770. var _baseIsSet = baseIsSet;
  11771. /* Node.js helper references. */
  11772. var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
  11773. /**
  11774. * Checks if `value` is classified as a `Set` object.
  11775. *
  11776. * @static
  11777. * @memberOf _
  11778. * @since 4.3.0
  11779. * @category Lang
  11780. * @param {*} value The value to check.
  11781. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  11782. * @example
  11783. *
  11784. * _.isSet(new Set);
  11785. * // => true
  11786. *
  11787. * _.isSet(new WeakSet);
  11788. * // => false
  11789. */
  11790. var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
  11791. var isSet_1 = isSet;
  11792. /** Used to compose bitmasks for cloning. */
  11793. var CLONE_DEEP_FLAG = 1,
  11794. CLONE_FLAT_FLAG = 2,
  11795. CLONE_SYMBOLS_FLAG = 4;
  11796. /** `Object#toString` result references. */
  11797. var argsTag$2 = '[object Arguments]',
  11798. arrayTag$1 = '[object Array]',
  11799. boolTag$2 = '[object Boolean]',
  11800. dateTag$2 = '[object Date]',
  11801. errorTag$1 = '[object Error]',
  11802. funcTag$2 = '[object Function]',
  11803. genTag$1 = '[object GeneratorFunction]',
  11804. mapTag$4 = '[object Map]',
  11805. numberTag$2 = '[object Number]',
  11806. objectTag$2 = '[object Object]',
  11807. regexpTag$2 = '[object RegExp]',
  11808. setTag$4 = '[object Set]',
  11809. stringTag$2 = '[object String]',
  11810. symbolTag$1 = '[object Symbol]',
  11811. weakMapTag$2 = '[object WeakMap]';
  11812. var arrayBufferTag$2 = '[object ArrayBuffer]',
  11813. dataViewTag$3 = '[object DataView]',
  11814. float32Tag$2 = '[object Float32Array]',
  11815. float64Tag$2 = '[object Float64Array]',
  11816. int8Tag$2 = '[object Int8Array]',
  11817. int16Tag$2 = '[object Int16Array]',
  11818. int32Tag$2 = '[object Int32Array]',
  11819. uint8Tag$2 = '[object Uint8Array]',
  11820. uint8ClampedTag$2 = '[object Uint8ClampedArray]',
  11821. uint16Tag$2 = '[object Uint16Array]',
  11822. uint32Tag$2 = '[object Uint32Array]';
  11823. /** Used to identify `toStringTag` values supported by `_.clone`. */
  11824. var cloneableTags = {};
  11825. cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
  11826. cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
  11827. cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
  11828. cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
  11829. cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
  11830. cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
  11831. cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
  11832. cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
  11833. cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
  11834. cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
  11835. cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
  11836. cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
  11837. cloneableTags[weakMapTag$2] = false;
  11838. /**
  11839. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  11840. * traversed objects.
  11841. *
  11842. * @private
  11843. * @param {*} value The value to clone.
  11844. * @param {boolean} bitmask The bitmask flags.
  11845. * 1 - Deep clone
  11846. * 2 - Flatten inherited properties
  11847. * 4 - Clone symbols
  11848. * @param {Function} [customizer] The function to customize cloning.
  11849. * @param {string} [key] The key of `value`.
  11850. * @param {Object} [object] The parent object of `value`.
  11851. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  11852. * @returns {*} Returns the cloned value.
  11853. */
  11854. function baseClone(value, bitmask, customizer, key, object, stack) {
  11855. var result,
  11856. isDeep = bitmask & CLONE_DEEP_FLAG,
  11857. isFlat = bitmask & CLONE_FLAT_FLAG,
  11858. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  11859. if (customizer) {
  11860. result = object ? customizer(value, key, object, stack) : customizer(value);
  11861. }
  11862. if (result !== undefined) {
  11863. return result;
  11864. }
  11865. if (!isObject_1(value)) {
  11866. return value;
  11867. }
  11868. var isArr = isArray_1(value);
  11869. if (isArr) {
  11870. result = _initCloneArray(value);
  11871. if (!isDeep) {
  11872. return _copyArray(value, result);
  11873. }
  11874. } else {
  11875. var tag = _getTag(value),
  11876. isFunc = tag == funcTag$2 || tag == genTag$1;
  11877. if (isBuffer_1$1(value)) {
  11878. return _cloneBuffer(value, isDeep);
  11879. }
  11880. if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
  11881. result = (isFlat || isFunc) ? {} : _initCloneObject(value);
  11882. if (!isDeep) {
  11883. return isFlat
  11884. ? _copySymbolsIn(value, _baseAssignIn(result, value))
  11885. : _copySymbols(value, _baseAssign(result, value));
  11886. }
  11887. } else {
  11888. if (!cloneableTags[tag]) {
  11889. return object ? value : {};
  11890. }
  11891. result = _initCloneByTag(value, tag, isDeep);
  11892. }
  11893. }
  11894. // Check for circular references and return its corresponding clone.
  11895. stack || (stack = new _Stack);
  11896. var stacked = stack.get(value);
  11897. if (stacked) {
  11898. return stacked;
  11899. }
  11900. stack.set(value, result);
  11901. if (isSet_1(value)) {
  11902. value.forEach(function(subValue) {
  11903. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  11904. });
  11905. } else if (isMap_1(value)) {
  11906. value.forEach(function(subValue, key) {
  11907. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  11908. });
  11909. }
  11910. var keysFunc = isFull
  11911. ? (isFlat ? _getAllKeysIn : _getAllKeys)
  11912. : (isFlat ? keysIn_1 : keys_1);
  11913. var props = isArr ? undefined : keysFunc(value);
  11914. _arrayEach(props || value, function(subValue, key) {
  11915. if (props) {
  11916. key = subValue;
  11917. subValue = value[key];
  11918. }
  11919. // Recursively populate clone (susceptible to call stack limits).
  11920. _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  11921. });
  11922. return result;
  11923. }
  11924. var _baseClone = baseClone;
  11925. /** Used to compose bitmasks for cloning. */
  11926. var CLONE_DEEP_FLAG$1 = 1,
  11927. CLONE_SYMBOLS_FLAG$1 = 4;
  11928. /**
  11929. * This method is like `_.clone` except that it recursively clones `value`.
  11930. *
  11931. * @static
  11932. * @memberOf _
  11933. * @since 1.0.0
  11934. * @category Lang
  11935. * @param {*} value The value to recursively clone.
  11936. * @returns {*} Returns the deep cloned value.
  11937. * @see _.clone
  11938. * @example
  11939. *
  11940. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11941. *
  11942. * var deep = _.cloneDeep(objects);
  11943. * console.log(deep[0] === objects[0]);
  11944. * // => false
  11945. */
  11946. function cloneDeep(value) {
  11947. return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
  11948. }
  11949. var cloneDeep_1 = cloneDeep;
  11950. //
  11951. /**
  11952. * Used internally by vue-server-test-utils and test-utils to propagate/create vue instances.
  11953. * This method is wrapped by createLocalVue in test-utils to provide a different public API signature
  11954. * @param {Component} _Vue
  11955. * @param {VueConfig} config
  11956. * @returns {Component}
  11957. */
  11958. function _createLocalVue(
  11959. _Vue,
  11960. config
  11961. ) {
  11962. if ( _Vue === void 0 ) _Vue = Vue__default['default'];
  11963. if ( config === void 0 ) config = {};
  11964. var instance = _Vue.extend();
  11965. // clone global APIs
  11966. Object.keys(_Vue).forEach(function (key) {
  11967. if (!instance.hasOwnProperty(key)) {
  11968. var original = _Vue[key];
  11969. // cloneDeep can fail when cloning Vue instances
  11970. // cloneDeep checks that the instance has a Symbol
  11971. // which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
  11972. try {
  11973. instance[key] =
  11974. typeof original === 'object' ? cloneDeep_1(original) : original;
  11975. } catch (e) {
  11976. instance[key] = original;
  11977. }
  11978. }
  11979. });
  11980. // config is not enumerable
  11981. instance.config = cloneDeep_1(Vue__default['default'].config);
  11982. // if a user defined errorHandler is defined by a localVue instance via createLocalVue, register it
  11983. instance.config.errorHandler = config.errorHandler;
  11984. // option merge strategies need to be exposed by reference
  11985. // so that merge strats registered by plugins can work properly
  11986. instance.config.optionMergeStrategies = Vue__default['default'].config.optionMergeStrategies;
  11987. // make sure all extends are based on this instance.
  11988. // this is important so that global components registered by plugins,
  11989. // e.g. router-link are created using the correct base constructor
  11990. instance.options._base = instance;
  11991. // compat for vue-router < 2.7.1 where it does not allow multiple installs
  11992. if (instance._installedPlugins && instance._installedPlugins.length) {
  11993. instance._installedPlugins.length = 0;
  11994. }
  11995. var use = instance.use;
  11996. instance.use = function (plugin) {
  11997. var rest = [], len = arguments.length - 1;
  11998. while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
  11999. if (plugin.installed === true) {
  12000. plugin.installed = false;
  12001. }
  12002. if (plugin.install && plugin.install.installed === true) {
  12003. plugin.install.installed = false;
  12004. }
  12005. use.call.apply(use, [ instance, plugin ].concat( rest ));
  12006. };
  12007. return instance
  12008. }
  12009. //
  12010. function isValidSlot(slot) {
  12011. return isVueComponent(slot) || typeof slot === 'string'
  12012. }
  12013. function requiresTemplateCompiler(slot) {
  12014. if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) {
  12015. throwError(
  12016. "vueTemplateCompiler is undefined, you must pass " +
  12017. "precompiled components if vue-template-compiler is " +
  12018. "undefined"
  12019. );
  12020. }
  12021. }
  12022. function validateSlots(slots) {
  12023. Object.keys(slots).forEach(function (key) {
  12024. var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
  12025. slot.forEach(function (slotValue) {
  12026. if (!isValidSlot(slotValue)) {
  12027. throwError(
  12028. "slots[key] must be a Component, string or an array " +
  12029. "of Components"
  12030. );
  12031. }
  12032. requiresTemplateCompiler(slotValue);
  12033. });
  12034. });
  12035. }
  12036. function vueExtendUnsupportedOption(option) {
  12037. return (
  12038. "options." + option + " is not supported for " +
  12039. "components created with Vue.extend in Vue < 2.3. " +
  12040. "You can set " + option + " to false to mount the component."
  12041. )
  12042. }
  12043. // these options aren't supported if Vue is version < 2.3
  12044. // for components using Vue.extend. This is due to a bug
  12045. // that means the mixins we use to add properties are not applied
  12046. // correctly
  12047. var UNSUPPORTED_VERSION_OPTIONS = ['mocks', 'stubs', 'localVue'];
  12048. function validateOptions(options, component) {
  12049. if (
  12050. options.attachTo &&
  12051. !isHTMLElement(options.attachTo) &&
  12052. !isDomSelector(options.attachTo)
  12053. ) {
  12054. throwError(
  12055. "options.attachTo should be a valid HTMLElement or CSS selector string"
  12056. );
  12057. }
  12058. if ('attachToDocument' in options) {
  12059. warnDeprecated(
  12060. "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
  12061. );
  12062. }
  12063. if (options.parentComponent && !isPlainObject(options.parentComponent)) {
  12064. throwError(
  12065. "options.parentComponent should be a valid Vue component options object"
  12066. );
  12067. }
  12068. if (!isFunctionalComponent(component) && options.context) {
  12069. throwError(
  12070. "mount.context can only be used when mounting a functional component"
  12071. );
  12072. }
  12073. if (options.context && !isPlainObject(options.context)) {
  12074. throwError('mount.context must be an object');
  12075. }
  12076. if (VUE_VERSION < 2.3 && isConstructor(component)) {
  12077. UNSUPPORTED_VERSION_OPTIONS.forEach(function (option) {
  12078. if (options[option]) {
  12079. throwError(vueExtendUnsupportedOption(option));
  12080. }
  12081. });
  12082. }
  12083. if (options.slots) {
  12084. compileTemplateForSlots(options.slots);
  12085. // validate slots outside of the createSlots function so
  12086. // that we can throw an error without it being caught by
  12087. // the Vue error handler
  12088. // $FlowIgnore
  12089. validateSlots(options.slots);
  12090. }
  12091. }
  12092. Vue__default['default'].config.productionTip = false;
  12093. Vue__default['default'].config.devtools = false;
  12094. function mount(component, options) {
  12095. if ( options === void 0 ) options = {};
  12096. warnIfNoWindow();
  12097. polyfill();
  12098. addGlobalErrorHandler(Vue__default['default']);
  12099. var _Vue = _createLocalVue(
  12100. options.localVue,
  12101. options.localVue ? options.localVue.config : undefined
  12102. );
  12103. var mergedOptions = mergeOptions(options, config);
  12104. validateOptions(mergedOptions, component);
  12105. var parentVm = createInstance(component, mergedOptions, _Vue);
  12106. var el =
  12107. options.attachToDocument || options.attachTo instanceof HTMLBodyElement
  12108. ? createElement()
  12109. : options.attachTo;
  12110. var vm = parentVm.$mount(el);
  12111. component._Ctor = {};
  12112. throwIfInstancesThrew(vm);
  12113. var wrapperOptions = {
  12114. attachedToDocument: !!el
  12115. };
  12116. var root = parentVm.$options._isFunctionalContainer
  12117. ? vm._vnode
  12118. : vm.$children[0];
  12119. return createWrapper(root, wrapperOptions)
  12120. }
  12121. //
  12122. function shallowMount(
  12123. component,
  12124. options
  12125. ) {
  12126. if ( options === void 0 ) options = {};
  12127. return mount(component, Object.assign({}, options,
  12128. {shouldProxy: true}))
  12129. }
  12130. //
  12131. /**
  12132. * Returns a local vue instance to add components, mixins and install plugins without polluting the global Vue class
  12133. * @param {VueConfig} config
  12134. * @returns {Component}
  12135. */
  12136. function createLocalVue(config) {
  12137. if ( config === void 0 ) config = {};
  12138. return _createLocalVue(undefined, config)
  12139. }
  12140. //
  12141. var toTypes = [String, Object];
  12142. var eventTypes = [String, Array];
  12143. var RouterLinkStub = {
  12144. name: 'RouterLinkStub',
  12145. props: {
  12146. to: {
  12147. type: toTypes,
  12148. required: true
  12149. },
  12150. tag: {
  12151. type: String,
  12152. default: 'a'
  12153. },
  12154. exact: Boolean,
  12155. exactPath: Boolean,
  12156. append: Boolean,
  12157. replace: Boolean,
  12158. activeClass: String,
  12159. exactActiveClass: String,
  12160. exactPathActiveClass: String,
  12161. event: {
  12162. type: eventTypes,
  12163. default: 'click'
  12164. }
  12165. },
  12166. render: function render(h) {
  12167. return h(this.tag, undefined, this.$slots.default)
  12168. }
  12169. };
  12170. function shallow(component, options) {
  12171. warn(
  12172. "shallow has been renamed to shallowMount. shallow " +
  12173. "will be removed in 1.0.0, use shallowMount instead"
  12174. );
  12175. return shallowMount(component, options)
  12176. }
  12177. exports.ErrorWrapper = ErrorWrapper;
  12178. exports.RouterLinkStub = RouterLinkStub;
  12179. exports.Wrapper = Wrapper;
  12180. exports.WrapperArray = WrapperArray;
  12181. exports.config = config;
  12182. exports.createLocalVue = createLocalVue;
  12183. exports.createWrapper = createWrapper;
  12184. exports.enableAutoDestroy = enableAutoDestroy;
  12185. exports.mount = mount;
  12186. exports.resetAutoDestroyState = resetAutoDestroyState;
  12187. exports.shallow = shallow;
  12188. exports.shallowMount = shallowMount;
  12189. return exports;
  12190. }({}, Vue, VueTemplateCompiler));