vue-test-utils.umd.js 429 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('vue-template-compiler')) :
  3. typeof define === 'function' && define.amd ? define(['exports', 'vue', 'vue-template-compiler'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueTestUtils = {}, global.Vue, global.VueTemplateCompiler));
  5. }(this, (function (exports, Vue, vueTemplateCompiler) { 'use strict';
  6. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  7. var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
  8. //
  9. function createVNodes(vm, slotValue, name) {
  10. var el = vueTemplateCompiler.compileToFunctions(
  11. ("<div><template slot=" + name + ">" + slotValue + "</template></div>")
  12. );
  13. var _staticRenderFns = vm._renderProxy.$options.staticRenderFns;
  14. var _staticTrees = vm._renderProxy._staticTrees;
  15. vm._renderProxy._staticTrees = [];
  16. vm._renderProxy.$options.staticRenderFns = el.staticRenderFns;
  17. var vnode = el.render.call(vm._renderProxy, vm.$createElement);
  18. vm._renderProxy.$options.staticRenderFns = _staticRenderFns;
  19. vm._renderProxy._staticTrees = _staticTrees;
  20. return vnode.children[0]
  21. }
  22. function createVNodesForSlot(
  23. vm,
  24. slotValue,
  25. name
  26. ) {
  27. if (typeof slotValue === 'string') {
  28. return createVNodes(vm, slotValue, name)
  29. }
  30. var vnode = vm.$createElement(slotValue)
  31. ;(vnode.data || (vnode.data = {})).slot = name;
  32. return vnode
  33. }
  34. function createSlotVNodes(
  35. vm,
  36. slots
  37. ) {
  38. return Object.keys(slots).reduce(function (acc, key) {
  39. var content = slots[key];
  40. if (Array.isArray(content)) {
  41. var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); }
  42. );
  43. return acc.concat(nodes)
  44. }
  45. return acc.concat(createVNodesForSlot(vm, content, key))
  46. }, [])
  47. }
  48. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  49. function createCommonjsModule(fn, basedir, module) {
  50. return module = {
  51. path: basedir,
  52. exports: {},
  53. require: function (path, base) {
  54. return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
  55. }
  56. }, fn(module, module.exports), module.exports;
  57. }
  58. function getCjsExportFromNamespace (n) {
  59. return n && n['default'] || n;
  60. }
  61. function commonjsRequire () {
  62. throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
  63. }
  64. var semver = createCommonjsModule(function (module, exports) {
  65. exports = module.exports = SemVer;
  66. var debug;
  67. /* istanbul ignore next */
  68. if (typeof process === 'object' &&
  69. process.env &&
  70. process.env.NODE_DEBUG &&
  71. /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
  72. debug = function () {
  73. var args = Array.prototype.slice.call(arguments, 0);
  74. args.unshift('SEMVER');
  75. console.log.apply(console, args);
  76. };
  77. } else {
  78. debug = function () {};
  79. }
  80. // Note: this is the semver.org version of the spec that it implements
  81. // Not necessarily the package version of this code.
  82. exports.SEMVER_SPEC_VERSION = '2.0.0';
  83. var MAX_LENGTH = 256;
  84. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
  85. /* istanbul ignore next */ 9007199254740991;
  86. // Max safe segment length for coercion.
  87. var MAX_SAFE_COMPONENT_LENGTH = 16;
  88. // The actual regexps go on exports.re
  89. var re = exports.re = [];
  90. var src = exports.src = [];
  91. var t = exports.tokens = {};
  92. var R = 0;
  93. function tok (n) {
  94. t[n] = R++;
  95. }
  96. // The following Regular Expressions can be used for tokenizing,
  97. // validating, and parsing SemVer version strings.
  98. // ## Numeric Identifier
  99. // A single `0`, or a non-zero digit followed by zero or more digits.
  100. tok('NUMERICIDENTIFIER');
  101. src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  102. tok('NUMERICIDENTIFIERLOOSE');
  103. src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
  104. // ## Non-numeric Identifier
  105. // Zero or more digits, followed by a letter or hyphen, and then zero or
  106. // more letters, digits, or hyphens.
  107. tok('NONNUMERICIDENTIFIER');
  108. src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
  109. // ## Main Version
  110. // Three dot-separated numeric identifiers.
  111. tok('MAINVERSION');
  112. src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
  113. '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
  114. '(' + src[t.NUMERICIDENTIFIER] + ')';
  115. tok('MAINVERSIONLOOSE');
  116. src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
  117. '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
  118. '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
  119. // ## Pre-release Version Identifier
  120. // A numeric identifier, or a non-numeric identifier.
  121. tok('PRERELEASEIDENTIFIER');
  122. src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
  123. '|' + src[t.NONNUMERICIDENTIFIER] + ')';
  124. tok('PRERELEASEIDENTIFIERLOOSE');
  125. src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
  126. '|' + src[t.NONNUMERICIDENTIFIER] + ')';
  127. // ## Pre-release Version
  128. // Hyphen, followed by one or more dot-separated pre-release version
  129. // identifiers.
  130. tok('PRERELEASE');
  131. src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
  132. '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
  133. tok('PRERELEASELOOSE');
  134. src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
  135. '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
  136. // ## Build Metadata Identifier
  137. // Any combination of digits, letters, or hyphens.
  138. tok('BUILDIDENTIFIER');
  139. src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
  140. // ## Build Metadata
  141. // Plus sign, followed by one or more period-separated build metadata
  142. // identifiers.
  143. tok('BUILD');
  144. src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
  145. '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
  146. // ## Full Version String
  147. // A main version, followed optionally by a pre-release version and
  148. // build metadata.
  149. // Note that the only major, minor, patch, and pre-release sections of
  150. // the version string are capturing groups. The build metadata is not a
  151. // capturing group, because it should not ever be used in version
  152. // comparison.
  153. tok('FULL');
  154. tok('FULLPLAIN');
  155. src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
  156. src[t.PRERELEASE] + '?' +
  157. src[t.BUILD] + '?';
  158. src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
  159. // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  160. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  161. // common in the npm registry.
  162. tok('LOOSEPLAIN');
  163. src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
  164. src[t.PRERELEASELOOSE] + '?' +
  165. src[t.BUILD] + '?';
  166. tok('LOOSE');
  167. src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
  168. tok('GTLT');
  169. src[t.GTLT] = '((?:<|>)?=?)';
  170. // Something like "2.*" or "1.2.x".
  171. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  172. // Only the first item is strictly required.
  173. tok('XRANGEIDENTIFIERLOOSE');
  174. src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  175. tok('XRANGEIDENTIFIER');
  176. src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
  177. tok('XRANGEPLAIN');
  178. src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
  179. '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
  180. '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
  181. '(?:' + src[t.PRERELEASE] + ')?' +
  182. src[t.BUILD] + '?' +
  183. ')?)?';
  184. tok('XRANGEPLAINLOOSE');
  185. src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  186. '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  187. '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  188. '(?:' + src[t.PRERELEASELOOSE] + ')?' +
  189. src[t.BUILD] + '?' +
  190. ')?)?';
  191. tok('XRANGE');
  192. src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
  193. tok('XRANGELOOSE');
  194. src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
  195. // Coercion.
  196. // Extract anything that could conceivably be a part of a valid semver
  197. tok('COERCE');
  198. src[t.COERCE] = '(^|[^\\d])' +
  199. '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
  200. '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
  201. '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
  202. '(?:$|[^\\d])';
  203. tok('COERCERTL');
  204. re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
  205. // Tilde ranges.
  206. // Meaning is "reasonably at or greater than"
  207. tok('LONETILDE');
  208. src[t.LONETILDE] = '(?:~>?)';
  209. tok('TILDETRIM');
  210. src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
  211. re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
  212. var tildeTrimReplace = '$1~';
  213. tok('TILDE');
  214. src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
  215. tok('TILDELOOSE');
  216. src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
  217. // Caret ranges.
  218. // Meaning is "at least and backwards compatible with"
  219. tok('LONECARET');
  220. src[t.LONECARET] = '(?:\\^)';
  221. tok('CARETTRIM');
  222. src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
  223. re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
  224. var caretTrimReplace = '$1^';
  225. tok('CARET');
  226. src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
  227. tok('CARETLOOSE');
  228. src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
  229. // A simple gt/lt/eq thing, or just "" to indicate "any version"
  230. tok('COMPARATORLOOSE');
  231. src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
  232. tok('COMPARATOR');
  233. src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
  234. // An expression to strip any whitespace between the gtlt and the thing
  235. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  236. tok('COMPARATORTRIM');
  237. src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
  238. '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
  239. // this one has to use the /g flag
  240. re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
  241. var comparatorTrimReplace = '$1$2$3';
  242. // Something like `1.2.3 - 1.2.4`
  243. // Note that these all use the loose form, because they'll be
  244. // checked against either the strict or loose comparator form
  245. // later.
  246. tok('HYPHENRANGE');
  247. src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
  248. '\\s+-\\s+' +
  249. '(' + src[t.XRANGEPLAIN] + ')' +
  250. '\\s*$';
  251. tok('HYPHENRANGELOOSE');
  252. src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
  253. '\\s+-\\s+' +
  254. '(' + src[t.XRANGEPLAINLOOSE] + ')' +
  255. '\\s*$';
  256. // Star ranges basically just allow anything at all.
  257. tok('STAR');
  258. src[t.STAR] = '(<|>)?=?\\s*\\*';
  259. // Compile to actual regexp objects.
  260. // All are flag-free, unless they were created above with a flag.
  261. for (var i = 0; i < R; i++) {
  262. debug(i, src[i]);
  263. if (!re[i]) {
  264. re[i] = new RegExp(src[i]);
  265. }
  266. }
  267. exports.parse = parse;
  268. function parse (version, options) {
  269. if (!options || typeof options !== 'object') {
  270. options = {
  271. loose: !!options,
  272. includePrerelease: false
  273. };
  274. }
  275. if (version instanceof SemVer) {
  276. return version
  277. }
  278. if (typeof version !== 'string') {
  279. return null
  280. }
  281. if (version.length > MAX_LENGTH) {
  282. return null
  283. }
  284. var r = options.loose ? re[t.LOOSE] : re[t.FULL];
  285. if (!r.test(version)) {
  286. return null
  287. }
  288. try {
  289. return new SemVer(version, options)
  290. } catch (er) {
  291. return null
  292. }
  293. }
  294. exports.valid = valid;
  295. function valid (version, options) {
  296. var v = parse(version, options);
  297. return v ? v.version : null
  298. }
  299. exports.clean = clean;
  300. function clean (version, options) {
  301. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  302. return s ? s.version : null
  303. }
  304. exports.SemVer = SemVer;
  305. function SemVer (version, options) {
  306. if (!options || typeof options !== 'object') {
  307. options = {
  308. loose: !!options,
  309. includePrerelease: false
  310. };
  311. }
  312. if (version instanceof SemVer) {
  313. if (version.loose === options.loose) {
  314. return version
  315. } else {
  316. version = version.version;
  317. }
  318. } else if (typeof version !== 'string') {
  319. throw new TypeError('Invalid Version: ' + version)
  320. }
  321. if (version.length > MAX_LENGTH) {
  322. throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
  323. }
  324. if (!(this instanceof SemVer)) {
  325. return new SemVer(version, options)
  326. }
  327. debug('SemVer', version, options);
  328. this.options = options;
  329. this.loose = !!options.loose;
  330. var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
  331. if (!m) {
  332. throw new TypeError('Invalid Version: ' + version)
  333. }
  334. this.raw = version;
  335. // these are actually numbers
  336. this.major = +m[1];
  337. this.minor = +m[2];
  338. this.patch = +m[3];
  339. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  340. throw new TypeError('Invalid major version')
  341. }
  342. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  343. throw new TypeError('Invalid minor version')
  344. }
  345. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  346. throw new TypeError('Invalid patch version')
  347. }
  348. // numberify any prerelease numeric ids
  349. if (!m[4]) {
  350. this.prerelease = [];
  351. } else {
  352. this.prerelease = m[4].split('.').map(function (id) {
  353. if (/^[0-9]+$/.test(id)) {
  354. var num = +id;
  355. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  356. return num
  357. }
  358. }
  359. return id
  360. });
  361. }
  362. this.build = m[5] ? m[5].split('.') : [];
  363. this.format();
  364. }
  365. SemVer.prototype.format = function () {
  366. this.version = this.major + '.' + this.minor + '.' + this.patch;
  367. if (this.prerelease.length) {
  368. this.version += '-' + this.prerelease.join('.');
  369. }
  370. return this.version
  371. };
  372. SemVer.prototype.toString = function () {
  373. return this.version
  374. };
  375. SemVer.prototype.compare = function (other) {
  376. debug('SemVer.compare', this.version, this.options, other);
  377. if (!(other instanceof SemVer)) {
  378. other = new SemVer(other, this.options);
  379. }
  380. return this.compareMain(other) || this.comparePre(other)
  381. };
  382. SemVer.prototype.compareMain = function (other) {
  383. if (!(other instanceof SemVer)) {
  384. other = new SemVer(other, this.options);
  385. }
  386. return compareIdentifiers(this.major, other.major) ||
  387. compareIdentifiers(this.minor, other.minor) ||
  388. compareIdentifiers(this.patch, other.patch)
  389. };
  390. SemVer.prototype.comparePre = function (other) {
  391. if (!(other instanceof SemVer)) {
  392. other = new SemVer(other, this.options);
  393. }
  394. // NOT having a prerelease is > having one
  395. if (this.prerelease.length && !other.prerelease.length) {
  396. return -1
  397. } else if (!this.prerelease.length && other.prerelease.length) {
  398. return 1
  399. } else if (!this.prerelease.length && !other.prerelease.length) {
  400. return 0
  401. }
  402. var i = 0;
  403. do {
  404. var a = this.prerelease[i];
  405. var b = other.prerelease[i];
  406. debug('prerelease compare', i, a, b);
  407. if (a === undefined && b === undefined) {
  408. return 0
  409. } else if (b === undefined) {
  410. return 1
  411. } else if (a === undefined) {
  412. return -1
  413. } else if (a === b) {
  414. continue
  415. } else {
  416. return compareIdentifiers(a, b)
  417. }
  418. } while (++i)
  419. };
  420. SemVer.prototype.compareBuild = function (other) {
  421. if (!(other instanceof SemVer)) {
  422. other = new SemVer(other, this.options);
  423. }
  424. var i = 0;
  425. do {
  426. var a = this.build[i];
  427. var b = other.build[i];
  428. debug('prerelease compare', i, a, b);
  429. if (a === undefined && b === undefined) {
  430. return 0
  431. } else if (b === undefined) {
  432. return 1
  433. } else if (a === undefined) {
  434. return -1
  435. } else if (a === b) {
  436. continue
  437. } else {
  438. return compareIdentifiers(a, b)
  439. }
  440. } while (++i)
  441. };
  442. // preminor will bump the version up to the next minor release, and immediately
  443. // down to pre-release. premajor and prepatch work the same way.
  444. SemVer.prototype.inc = function (release, identifier) {
  445. switch (release) {
  446. case 'premajor':
  447. this.prerelease.length = 0;
  448. this.patch = 0;
  449. this.minor = 0;
  450. this.major++;
  451. this.inc('pre', identifier);
  452. break
  453. case 'preminor':
  454. this.prerelease.length = 0;
  455. this.patch = 0;
  456. this.minor++;
  457. this.inc('pre', identifier);
  458. break
  459. case 'prepatch':
  460. // If this is already a prerelease, it will bump to the next version
  461. // drop any prereleases that might already exist, since they are not
  462. // relevant at this point.
  463. this.prerelease.length = 0;
  464. this.inc('patch', identifier);
  465. this.inc('pre', identifier);
  466. break
  467. // If the input is a non-prerelease version, this acts the same as
  468. // prepatch.
  469. case 'prerelease':
  470. if (this.prerelease.length === 0) {
  471. this.inc('patch', identifier);
  472. }
  473. this.inc('pre', identifier);
  474. break
  475. case 'major':
  476. // If this is a pre-major version, bump up to the same major version.
  477. // Otherwise increment major.
  478. // 1.0.0-5 bumps to 1.0.0
  479. // 1.1.0 bumps to 2.0.0
  480. if (this.minor !== 0 ||
  481. this.patch !== 0 ||
  482. this.prerelease.length === 0) {
  483. this.major++;
  484. }
  485. this.minor = 0;
  486. this.patch = 0;
  487. this.prerelease = [];
  488. break
  489. case 'minor':
  490. // If this is a pre-minor version, bump up to the same minor version.
  491. // Otherwise increment minor.
  492. // 1.2.0-5 bumps to 1.2.0
  493. // 1.2.1 bumps to 1.3.0
  494. if (this.patch !== 0 || this.prerelease.length === 0) {
  495. this.minor++;
  496. }
  497. this.patch = 0;
  498. this.prerelease = [];
  499. break
  500. case 'patch':
  501. // If this is not a pre-release version, it will increment the patch.
  502. // If it is a pre-release it will bump up to the same patch version.
  503. // 1.2.0-5 patches to 1.2.0
  504. // 1.2.0 patches to 1.2.1
  505. if (this.prerelease.length === 0) {
  506. this.patch++;
  507. }
  508. this.prerelease = [];
  509. break
  510. // This probably shouldn't be used publicly.
  511. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  512. case 'pre':
  513. if (this.prerelease.length === 0) {
  514. this.prerelease = [0];
  515. } else {
  516. var i = this.prerelease.length;
  517. while (--i >= 0) {
  518. if (typeof this.prerelease[i] === 'number') {
  519. this.prerelease[i]++;
  520. i = -2;
  521. }
  522. }
  523. if (i === -1) {
  524. // didn't increment anything
  525. this.prerelease.push(0);
  526. }
  527. }
  528. if (identifier) {
  529. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  530. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  531. if (this.prerelease[0] === identifier) {
  532. if (isNaN(this.prerelease[1])) {
  533. this.prerelease = [identifier, 0];
  534. }
  535. } else {
  536. this.prerelease = [identifier, 0];
  537. }
  538. }
  539. break
  540. default:
  541. throw new Error('invalid increment argument: ' + release)
  542. }
  543. this.format();
  544. this.raw = this.version;
  545. return this
  546. };
  547. exports.inc = inc;
  548. function inc (version, release, loose, identifier) {
  549. if (typeof (loose) === 'string') {
  550. identifier = loose;
  551. loose = undefined;
  552. }
  553. try {
  554. return new SemVer(version, loose).inc(release, identifier).version
  555. } catch (er) {
  556. return null
  557. }
  558. }
  559. exports.diff = diff;
  560. function diff (version1, version2) {
  561. if (eq(version1, version2)) {
  562. return null
  563. } else {
  564. var v1 = parse(version1);
  565. var v2 = parse(version2);
  566. var prefix = '';
  567. if (v1.prerelease.length || v2.prerelease.length) {
  568. prefix = 'pre';
  569. var defaultResult = 'prerelease';
  570. }
  571. for (var key in v1) {
  572. if (key === 'major' || key === 'minor' || key === 'patch') {
  573. if (v1[key] !== v2[key]) {
  574. return prefix + key
  575. }
  576. }
  577. }
  578. return defaultResult // may be undefined
  579. }
  580. }
  581. exports.compareIdentifiers = compareIdentifiers;
  582. var numeric = /^[0-9]+$/;
  583. function compareIdentifiers (a, b) {
  584. var anum = numeric.test(a);
  585. var bnum = numeric.test(b);
  586. if (anum && bnum) {
  587. a = +a;
  588. b = +b;
  589. }
  590. return a === b ? 0
  591. : (anum && !bnum) ? -1
  592. : (bnum && !anum) ? 1
  593. : a < b ? -1
  594. : 1
  595. }
  596. exports.rcompareIdentifiers = rcompareIdentifiers;
  597. function rcompareIdentifiers (a, b) {
  598. return compareIdentifiers(b, a)
  599. }
  600. exports.major = major;
  601. function major (a, loose) {
  602. return new SemVer(a, loose).major
  603. }
  604. exports.minor = minor;
  605. function minor (a, loose) {
  606. return new SemVer(a, loose).minor
  607. }
  608. exports.patch = patch;
  609. function patch (a, loose) {
  610. return new SemVer(a, loose).patch
  611. }
  612. exports.compare = compare;
  613. function compare (a, b, loose) {
  614. return new SemVer(a, loose).compare(new SemVer(b, loose))
  615. }
  616. exports.compareLoose = compareLoose;
  617. function compareLoose (a, b) {
  618. return compare(a, b, true)
  619. }
  620. exports.compareBuild = compareBuild;
  621. function compareBuild (a, b, loose) {
  622. var versionA = new SemVer(a, loose);
  623. var versionB = new SemVer(b, loose);
  624. return versionA.compare(versionB) || versionA.compareBuild(versionB)
  625. }
  626. exports.rcompare = rcompare;
  627. function rcompare (a, b, loose) {
  628. return compare(b, a, loose)
  629. }
  630. exports.sort = sort;
  631. function sort (list, loose) {
  632. return list.sort(function (a, b) {
  633. return exports.compareBuild(a, b, loose)
  634. })
  635. }
  636. exports.rsort = rsort;
  637. function rsort (list, loose) {
  638. return list.sort(function (a, b) {
  639. return exports.compareBuild(b, a, loose)
  640. })
  641. }
  642. exports.gt = gt;
  643. function gt (a, b, loose) {
  644. return compare(a, b, loose) > 0
  645. }
  646. exports.lt = lt;
  647. function lt (a, b, loose) {
  648. return compare(a, b, loose) < 0
  649. }
  650. exports.eq = eq;
  651. function eq (a, b, loose) {
  652. return compare(a, b, loose) === 0
  653. }
  654. exports.neq = neq;
  655. function neq (a, b, loose) {
  656. return compare(a, b, loose) !== 0
  657. }
  658. exports.gte = gte;
  659. function gte (a, b, loose) {
  660. return compare(a, b, loose) >= 0
  661. }
  662. exports.lte = lte;
  663. function lte (a, b, loose) {
  664. return compare(a, b, loose) <= 0
  665. }
  666. exports.cmp = cmp;
  667. function cmp (a, op, b, loose) {
  668. switch (op) {
  669. case '===':
  670. if (typeof a === 'object')
  671. { a = a.version; }
  672. if (typeof b === 'object')
  673. { b = b.version; }
  674. return a === b
  675. case '!==':
  676. if (typeof a === 'object')
  677. { a = a.version; }
  678. if (typeof b === 'object')
  679. { b = b.version; }
  680. return a !== b
  681. case '':
  682. case '=':
  683. case '==':
  684. return eq(a, b, loose)
  685. case '!=':
  686. return neq(a, b, loose)
  687. case '>':
  688. return gt(a, b, loose)
  689. case '>=':
  690. return gte(a, b, loose)
  691. case '<':
  692. return lt(a, b, loose)
  693. case '<=':
  694. return lte(a, b, loose)
  695. default:
  696. throw new TypeError('Invalid operator: ' + op)
  697. }
  698. }
  699. exports.Comparator = Comparator;
  700. function Comparator (comp, options) {
  701. if (!options || typeof options !== 'object') {
  702. options = {
  703. loose: !!options,
  704. includePrerelease: false
  705. };
  706. }
  707. if (comp instanceof Comparator) {
  708. if (comp.loose === !!options.loose) {
  709. return comp
  710. } else {
  711. comp = comp.value;
  712. }
  713. }
  714. if (!(this instanceof Comparator)) {
  715. return new Comparator(comp, options)
  716. }
  717. debug('comparator', comp, options);
  718. this.options = options;
  719. this.loose = !!options.loose;
  720. this.parse(comp);
  721. if (this.semver === ANY) {
  722. this.value = '';
  723. } else {
  724. this.value = this.operator + this.semver.version;
  725. }
  726. debug('comp', this);
  727. }
  728. var ANY = {};
  729. Comparator.prototype.parse = function (comp) {
  730. var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
  731. var m = comp.match(r);
  732. if (!m) {
  733. throw new TypeError('Invalid comparator: ' + comp)
  734. }
  735. this.operator = m[1] !== undefined ? m[1] : '';
  736. if (this.operator === '=') {
  737. this.operator = '';
  738. }
  739. // if it literally is just '>' or '' then allow anything.
  740. if (!m[2]) {
  741. this.semver = ANY;
  742. } else {
  743. this.semver = new SemVer(m[2], this.options.loose);
  744. }
  745. };
  746. Comparator.prototype.toString = function () {
  747. return this.value
  748. };
  749. Comparator.prototype.test = function (version) {
  750. debug('Comparator.test', version, this.options.loose);
  751. if (this.semver === ANY || version === ANY) {
  752. return true
  753. }
  754. if (typeof version === 'string') {
  755. try {
  756. version = new SemVer(version, this.options);
  757. } catch (er) {
  758. return false
  759. }
  760. }
  761. return cmp(version, this.operator, this.semver, this.options)
  762. };
  763. Comparator.prototype.intersects = function (comp, options) {
  764. if (!(comp instanceof Comparator)) {
  765. throw new TypeError('a Comparator is required')
  766. }
  767. if (!options || typeof options !== 'object') {
  768. options = {
  769. loose: !!options,
  770. includePrerelease: false
  771. };
  772. }
  773. var rangeTmp;
  774. if (this.operator === '') {
  775. if (this.value === '') {
  776. return true
  777. }
  778. rangeTmp = new Range(comp.value, options);
  779. return satisfies(this.value, rangeTmp, options)
  780. } else if (comp.operator === '') {
  781. if (comp.value === '') {
  782. return true
  783. }
  784. rangeTmp = new Range(this.value, options);
  785. return satisfies(comp.semver, rangeTmp, options)
  786. }
  787. var sameDirectionIncreasing =
  788. (this.operator === '>=' || this.operator === '>') &&
  789. (comp.operator === '>=' || comp.operator === '>');
  790. var sameDirectionDecreasing =
  791. (this.operator === '<=' || this.operator === '<') &&
  792. (comp.operator === '<=' || comp.operator === '<');
  793. var sameSemVer = this.semver.version === comp.semver.version;
  794. var differentDirectionsInclusive =
  795. (this.operator === '>=' || this.operator === '<=') &&
  796. (comp.operator === '>=' || comp.operator === '<=');
  797. var oppositeDirectionsLessThan =
  798. cmp(this.semver, '<', comp.semver, options) &&
  799. ((this.operator === '>=' || this.operator === '>') &&
  800. (comp.operator === '<=' || comp.operator === '<'));
  801. var oppositeDirectionsGreaterThan =
  802. cmp(this.semver, '>', comp.semver, options) &&
  803. ((this.operator === '<=' || this.operator === '<') &&
  804. (comp.operator === '>=' || comp.operator === '>'));
  805. return sameDirectionIncreasing || sameDirectionDecreasing ||
  806. (sameSemVer && differentDirectionsInclusive) ||
  807. oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
  808. };
  809. exports.Range = Range;
  810. function Range (range, options) {
  811. if (!options || typeof options !== 'object') {
  812. options = {
  813. loose: !!options,
  814. includePrerelease: false
  815. };
  816. }
  817. if (range instanceof Range) {
  818. if (range.loose === !!options.loose &&
  819. range.includePrerelease === !!options.includePrerelease) {
  820. return range
  821. } else {
  822. return new Range(range.raw, options)
  823. }
  824. }
  825. if (range instanceof Comparator) {
  826. return new Range(range.value, options)
  827. }
  828. if (!(this instanceof Range)) {
  829. return new Range(range, options)
  830. }
  831. this.options = options;
  832. this.loose = !!options.loose;
  833. this.includePrerelease = !!options.includePrerelease;
  834. // First, split based on boolean or ||
  835. this.raw = range;
  836. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  837. return this.parseRange(range.trim())
  838. }, this).filter(function (c) {
  839. // throw out any that are not relevant for whatever reason
  840. return c.length
  841. });
  842. if (!this.set.length) {
  843. throw new TypeError('Invalid SemVer Range: ' + range)
  844. }
  845. this.format();
  846. }
  847. Range.prototype.format = function () {
  848. this.range = this.set.map(function (comps) {
  849. return comps.join(' ').trim()
  850. }).join('||').trim();
  851. return this.range
  852. };
  853. Range.prototype.toString = function () {
  854. return this.range
  855. };
  856. Range.prototype.parseRange = function (range) {
  857. var loose = this.options.loose;
  858. range = range.trim();
  859. // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  860. var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
  861. range = range.replace(hr, hyphenReplace);
  862. debug('hyphen replace', range);
  863. // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  864. range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
  865. debug('comparator trim', range, re[t.COMPARATORTRIM]);
  866. // `~ 1.2.3` => `~1.2.3`
  867. range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
  868. // `^ 1.2.3` => `^1.2.3`
  869. range = range.replace(re[t.CARETTRIM], caretTrimReplace);
  870. // normalize spaces
  871. range = range.split(/\s+/).join(' ');
  872. // At this point, the range is completely trimmed and
  873. // ready to be split into comparators.
  874. var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
  875. var set = range.split(' ').map(function (comp) {
  876. return parseComparator(comp, this.options)
  877. }, this).join(' ').split(/\s+/);
  878. if (this.options.loose) {
  879. // in loose mode, throw out any that are not valid comparators
  880. set = set.filter(function (comp) {
  881. return !!comp.match(compRe)
  882. });
  883. }
  884. set = set.map(function (comp) {
  885. return new Comparator(comp, this.options)
  886. }, this);
  887. return set
  888. };
  889. Range.prototype.intersects = function (range, options) {
  890. if (!(range instanceof Range)) {
  891. throw new TypeError('a Range is required')
  892. }
  893. return this.set.some(function (thisComparators) {
  894. return (
  895. isSatisfiable(thisComparators, options) &&
  896. range.set.some(function (rangeComparators) {
  897. return (
  898. isSatisfiable(rangeComparators, options) &&
  899. thisComparators.every(function (thisComparator) {
  900. return rangeComparators.every(function (rangeComparator) {
  901. return thisComparator.intersects(rangeComparator, options)
  902. })
  903. })
  904. )
  905. })
  906. )
  907. })
  908. };
  909. // take a set of comparators and determine whether there
  910. // exists a version which can satisfy it
  911. function isSatisfiable (comparators, options) {
  912. var result = true;
  913. var remainingComparators = comparators.slice();
  914. var testComparator = remainingComparators.pop();
  915. while (result && remainingComparators.length) {
  916. result = remainingComparators.every(function (otherComparator) {
  917. return testComparator.intersects(otherComparator, options)
  918. });
  919. testComparator = remainingComparators.pop();
  920. }
  921. return result
  922. }
  923. // Mostly just for testing and legacy API reasons
  924. exports.toComparators = toComparators;
  925. function toComparators (range, options) {
  926. return new Range(range, options).set.map(function (comp) {
  927. return comp.map(function (c) {
  928. return c.value
  929. }).join(' ').trim().split(' ')
  930. })
  931. }
  932. // comprised of xranges, tildes, stars, and gtlt's at this point.
  933. // already replaced the hyphen ranges
  934. // turn into a set of JUST comparators.
  935. function parseComparator (comp, options) {
  936. debug('comp', comp, options);
  937. comp = replaceCarets(comp, options);
  938. debug('caret', comp);
  939. comp = replaceTildes(comp, options);
  940. debug('tildes', comp);
  941. comp = replaceXRanges(comp, options);
  942. debug('xrange', comp);
  943. comp = replaceStars(comp, options);
  944. debug('stars', comp);
  945. return comp
  946. }
  947. function isX (id) {
  948. return !id || id.toLowerCase() === 'x' || id === '*'
  949. }
  950. // ~, ~> --> * (any, kinda silly)
  951. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  952. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  953. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  954. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  955. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  956. function replaceTildes (comp, options) {
  957. return comp.trim().split(/\s+/).map(function (comp) {
  958. return replaceTilde(comp, options)
  959. }).join(' ')
  960. }
  961. function replaceTilde (comp, options) {
  962. var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
  963. return comp.replace(r, function (_, M, m, p, pr) {
  964. debug('tilde', comp, _, M, m, p, pr);
  965. var ret;
  966. if (isX(M)) {
  967. ret = '';
  968. } else if (isX(m)) {
  969. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  970. } else if (isX(p)) {
  971. // ~1.2 == >=1.2.0 <1.3.0
  972. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  973. } else if (pr) {
  974. debug('replaceTilde pr', pr);
  975. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  976. ' <' + M + '.' + (+m + 1) + '.0';
  977. } else {
  978. // ~1.2.3 == >=1.2.3 <1.3.0
  979. ret = '>=' + M + '.' + m + '.' + p +
  980. ' <' + M + '.' + (+m + 1) + '.0';
  981. }
  982. debug('tilde return', ret);
  983. return ret
  984. })
  985. }
  986. // ^ --> * (any, kinda silly)
  987. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  988. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  989. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  990. // ^1.2.3 --> >=1.2.3 <2.0.0
  991. // ^1.2.0 --> >=1.2.0 <2.0.0
  992. function replaceCarets (comp, options) {
  993. return comp.trim().split(/\s+/).map(function (comp) {
  994. return replaceCaret(comp, options)
  995. }).join(' ')
  996. }
  997. function replaceCaret (comp, options) {
  998. debug('caret', comp, options);
  999. var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
  1000. return comp.replace(r, function (_, M, m, p, pr) {
  1001. debug('caret', comp, _, M, m, p, pr);
  1002. var ret;
  1003. if (isX(M)) {
  1004. ret = '';
  1005. } else if (isX(m)) {
  1006. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  1007. } else if (isX(p)) {
  1008. if (M === '0') {
  1009. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  1010. } else {
  1011. ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  1012. }
  1013. } else if (pr) {
  1014. debug('replaceCaret pr', pr);
  1015. if (M === '0') {
  1016. if (m === '0') {
  1017. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1018. ' <' + M + '.' + m + '.' + (+p + 1);
  1019. } else {
  1020. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1021. ' <' + M + '.' + (+m + 1) + '.0';
  1022. }
  1023. } else {
  1024. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1025. ' <' + (+M + 1) + '.0.0';
  1026. }
  1027. } else {
  1028. debug('no pr');
  1029. if (M === '0') {
  1030. if (m === '0') {
  1031. ret = '>=' + M + '.' + m + '.' + p +
  1032. ' <' + M + '.' + m + '.' + (+p + 1);
  1033. } else {
  1034. ret = '>=' + M + '.' + m + '.' + p +
  1035. ' <' + M + '.' + (+m + 1) + '.0';
  1036. }
  1037. } else {
  1038. ret = '>=' + M + '.' + m + '.' + p +
  1039. ' <' + (+M + 1) + '.0.0';
  1040. }
  1041. }
  1042. debug('caret return', ret);
  1043. return ret
  1044. })
  1045. }
  1046. function replaceXRanges (comp, options) {
  1047. debug('replaceXRanges', comp, options);
  1048. return comp.split(/\s+/).map(function (comp) {
  1049. return replaceXRange(comp, options)
  1050. }).join(' ')
  1051. }
  1052. function replaceXRange (comp, options) {
  1053. comp = comp.trim();
  1054. var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
  1055. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  1056. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  1057. var xM = isX(M);
  1058. var xm = xM || isX(m);
  1059. var xp = xm || isX(p);
  1060. var anyX = xp;
  1061. if (gtlt === '=' && anyX) {
  1062. gtlt = '';
  1063. }
  1064. // if we're including prereleases in the match, then we need
  1065. // to fix this to -0, the lowest possible prerelease value
  1066. pr = options.includePrerelease ? '-0' : '';
  1067. if (xM) {
  1068. if (gtlt === '>' || gtlt === '<') {
  1069. // nothing is allowed
  1070. ret = '<0.0.0-0';
  1071. } else {
  1072. // nothing is forbidden
  1073. ret = '*';
  1074. }
  1075. } else if (gtlt && anyX) {
  1076. // we know patch is an x, because we have any x at all.
  1077. // replace X with 0
  1078. if (xm) {
  1079. m = 0;
  1080. }
  1081. p = 0;
  1082. if (gtlt === '>') {
  1083. // >1 => >=2.0.0
  1084. // >1.2 => >=1.3.0
  1085. // >1.2.3 => >= 1.2.4
  1086. gtlt = '>=';
  1087. if (xm) {
  1088. M = +M + 1;
  1089. m = 0;
  1090. p = 0;
  1091. } else {
  1092. m = +m + 1;
  1093. p = 0;
  1094. }
  1095. } else if (gtlt === '<=') {
  1096. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  1097. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  1098. gtlt = '<';
  1099. if (xm) {
  1100. M = +M + 1;
  1101. } else {
  1102. m = +m + 1;
  1103. }
  1104. }
  1105. ret = gtlt + M + '.' + m + '.' + p + pr;
  1106. } else if (xm) {
  1107. ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
  1108. } else if (xp) {
  1109. ret = '>=' + M + '.' + m + '.0' + pr +
  1110. ' <' + M + '.' + (+m + 1) + '.0' + pr;
  1111. }
  1112. debug('xRange return', ret);
  1113. return ret
  1114. })
  1115. }
  1116. // Because * is AND-ed with everything else in the comparator,
  1117. // and '' means "any version", just remove the *s entirely.
  1118. function replaceStars (comp, options) {
  1119. debug('replaceStars', comp, options);
  1120. // Looseness is ignored here. star is always as loose as it gets!
  1121. return comp.trim().replace(re[t.STAR], '')
  1122. }
  1123. // This function is passed to string.replace(re[t.HYPHENRANGE])
  1124. // M, m, patch, prerelease, build
  1125. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  1126. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  1127. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  1128. function hyphenReplace ($0,
  1129. from, fM, fm, fp, fpr, fb,
  1130. to, tM, tm, tp, tpr, tb) {
  1131. if (isX(fM)) {
  1132. from = '';
  1133. } else if (isX(fm)) {
  1134. from = '>=' + fM + '.0.0';
  1135. } else if (isX(fp)) {
  1136. from = '>=' + fM + '.' + fm + '.0';
  1137. } else {
  1138. from = '>=' + from;
  1139. }
  1140. if (isX(tM)) {
  1141. to = '';
  1142. } else if (isX(tm)) {
  1143. to = '<' + (+tM + 1) + '.0.0';
  1144. } else if (isX(tp)) {
  1145. to = '<' + tM + '.' + (+tm + 1) + '.0';
  1146. } else if (tpr) {
  1147. to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
  1148. } else {
  1149. to = '<=' + to;
  1150. }
  1151. return (from + ' ' + to).trim()
  1152. }
  1153. // if ANY of the sets match ALL of its comparators, then pass
  1154. Range.prototype.test = function (version) {
  1155. if (!version) {
  1156. return false
  1157. }
  1158. if (typeof version === 'string') {
  1159. try {
  1160. version = new SemVer(version, this.options);
  1161. } catch (er) {
  1162. return false
  1163. }
  1164. }
  1165. for (var i = 0; i < this.set.length; i++) {
  1166. if (testSet(this.set[i], version, this.options)) {
  1167. return true
  1168. }
  1169. }
  1170. return false
  1171. };
  1172. function testSet (set, version, options) {
  1173. for (var i = 0; i < set.length; i++) {
  1174. if (!set[i].test(version)) {
  1175. return false
  1176. }
  1177. }
  1178. if (version.prerelease.length && !options.includePrerelease) {
  1179. // Find the set of versions that are allowed to have prereleases
  1180. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  1181. // That should allow `1.2.3-pr.2` to pass.
  1182. // However, `1.2.4-alpha.notready` should NOT be allowed,
  1183. // even though it's within the range set by the comparators.
  1184. for (i = 0; i < set.length; i++) {
  1185. debug(set[i].semver);
  1186. if (set[i].semver === ANY) {
  1187. continue
  1188. }
  1189. if (set[i].semver.prerelease.length > 0) {
  1190. var allowed = set[i].semver;
  1191. if (allowed.major === version.major &&
  1192. allowed.minor === version.minor &&
  1193. allowed.patch === version.patch) {
  1194. return true
  1195. }
  1196. }
  1197. }
  1198. // Version has a -pre, but it's not one of the ones we like.
  1199. return false
  1200. }
  1201. return true
  1202. }
  1203. exports.satisfies = satisfies;
  1204. function satisfies (version, range, options) {
  1205. try {
  1206. range = new Range(range, options);
  1207. } catch (er) {
  1208. return false
  1209. }
  1210. return range.test(version)
  1211. }
  1212. exports.maxSatisfying = maxSatisfying;
  1213. function maxSatisfying (versions, range, options) {
  1214. var max = null;
  1215. var maxSV = null;
  1216. try {
  1217. var rangeObj = new Range(range, options);
  1218. } catch (er) {
  1219. return null
  1220. }
  1221. versions.forEach(function (v) {
  1222. if (rangeObj.test(v)) {
  1223. // satisfies(v, range, options)
  1224. if (!max || maxSV.compare(v) === -1) {
  1225. // compare(max, v, true)
  1226. max = v;
  1227. maxSV = new SemVer(max, options);
  1228. }
  1229. }
  1230. });
  1231. return max
  1232. }
  1233. exports.minSatisfying = minSatisfying;
  1234. function minSatisfying (versions, range, options) {
  1235. var min = null;
  1236. var minSV = null;
  1237. try {
  1238. var rangeObj = new Range(range, options);
  1239. } catch (er) {
  1240. return null
  1241. }
  1242. versions.forEach(function (v) {
  1243. if (rangeObj.test(v)) {
  1244. // satisfies(v, range, options)
  1245. if (!min || minSV.compare(v) === 1) {
  1246. // compare(min, v, true)
  1247. min = v;
  1248. minSV = new SemVer(min, options);
  1249. }
  1250. }
  1251. });
  1252. return min
  1253. }
  1254. exports.minVersion = minVersion;
  1255. function minVersion (range, loose) {
  1256. range = new Range(range, loose);
  1257. var minver = new SemVer('0.0.0');
  1258. if (range.test(minver)) {
  1259. return minver
  1260. }
  1261. minver = new SemVer('0.0.0-0');
  1262. if (range.test(minver)) {
  1263. return minver
  1264. }
  1265. minver = null;
  1266. for (var i = 0; i < range.set.length; ++i) {
  1267. var comparators = range.set[i];
  1268. comparators.forEach(function (comparator) {
  1269. // Clone to avoid manipulating the comparator's semver object.
  1270. var compver = new SemVer(comparator.semver.version);
  1271. switch (comparator.operator) {
  1272. case '>':
  1273. if (compver.prerelease.length === 0) {
  1274. compver.patch++;
  1275. } else {
  1276. compver.prerelease.push(0);
  1277. }
  1278. compver.raw = compver.format();
  1279. /* fallthrough */
  1280. case '':
  1281. case '>=':
  1282. if (!minver || gt(minver, compver)) {
  1283. minver = compver;
  1284. }
  1285. break
  1286. case '<':
  1287. case '<=':
  1288. /* Ignore maximum versions */
  1289. break
  1290. /* istanbul ignore next */
  1291. default:
  1292. throw new Error('Unexpected operation: ' + comparator.operator)
  1293. }
  1294. });
  1295. }
  1296. if (minver && range.test(minver)) {
  1297. return minver
  1298. }
  1299. return null
  1300. }
  1301. exports.validRange = validRange;
  1302. function validRange (range, options) {
  1303. try {
  1304. // Return '*' instead of '' so that truthiness works.
  1305. // This will throw if it's invalid anyway
  1306. return new Range(range, options).range || '*'
  1307. } catch (er) {
  1308. return null
  1309. }
  1310. }
  1311. // Determine if version is less than all the versions possible in the range
  1312. exports.ltr = ltr;
  1313. function ltr (version, range, options) {
  1314. return outside(version, range, '<', options)
  1315. }
  1316. // Determine if version is greater than all the versions possible in the range.
  1317. exports.gtr = gtr;
  1318. function gtr (version, range, options) {
  1319. return outside(version, range, '>', options)
  1320. }
  1321. exports.outside = outside;
  1322. function outside (version, range, hilo, options) {
  1323. version = new SemVer(version, options);
  1324. range = new Range(range, options);
  1325. var gtfn, ltefn, ltfn, comp, ecomp;
  1326. switch (hilo) {
  1327. case '>':
  1328. gtfn = gt;
  1329. ltefn = lte;
  1330. ltfn = lt;
  1331. comp = '>';
  1332. ecomp = '>=';
  1333. break
  1334. case '<':
  1335. gtfn = lt;
  1336. ltefn = gte;
  1337. ltfn = gt;
  1338. comp = '<';
  1339. ecomp = '<=';
  1340. break
  1341. default:
  1342. throw new TypeError('Must provide a hilo val of "<" or ">"')
  1343. }
  1344. // If it satisifes the range it is not outside
  1345. if (satisfies(version, range, options)) {
  1346. return false
  1347. }
  1348. // From now on, variable terms are as if we're in "gtr" mode.
  1349. // but note that everything is flipped for the "ltr" function.
  1350. for (var i = 0; i < range.set.length; ++i) {
  1351. var comparators = range.set[i];
  1352. var high = null;
  1353. var low = null;
  1354. comparators.forEach(function (comparator) {
  1355. if (comparator.semver === ANY) {
  1356. comparator = new Comparator('>=0.0.0');
  1357. }
  1358. high = high || comparator;
  1359. low = low || comparator;
  1360. if (gtfn(comparator.semver, high.semver, options)) {
  1361. high = comparator;
  1362. } else if (ltfn(comparator.semver, low.semver, options)) {
  1363. low = comparator;
  1364. }
  1365. });
  1366. // If the edge version comparator has a operator then our version
  1367. // isn't outside it
  1368. if (high.operator === comp || high.operator === ecomp) {
  1369. return false
  1370. }
  1371. // If the lowest version comparator has an operator and our version
  1372. // is less than it then it isn't higher than the range
  1373. if ((!low.operator || low.operator === comp) &&
  1374. ltefn(version, low.semver)) {
  1375. return false
  1376. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  1377. return false
  1378. }
  1379. }
  1380. return true
  1381. }
  1382. exports.prerelease = prerelease;
  1383. function prerelease (version, options) {
  1384. var parsed = parse(version, options);
  1385. return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
  1386. }
  1387. exports.intersects = intersects;
  1388. function intersects (r1, r2, options) {
  1389. r1 = new Range(r1, options);
  1390. r2 = new Range(r2, options);
  1391. return r1.intersects(r2)
  1392. }
  1393. exports.coerce = coerce;
  1394. function coerce (version, options) {
  1395. if (version instanceof SemVer) {
  1396. return version
  1397. }
  1398. if (typeof version === 'number') {
  1399. version = String(version);
  1400. }
  1401. if (typeof version !== 'string') {
  1402. return null
  1403. }
  1404. options = options || {};
  1405. var match = null;
  1406. if (!options.rtl) {
  1407. match = version.match(re[t.COERCE]);
  1408. } else {
  1409. // Find the right-most coercible string that does not share
  1410. // a terminus with a more left-ward coercible string.
  1411. // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
  1412. //
  1413. // Walk through the string checking with a /g regexp
  1414. // Manually set the index so as to pick up overlapping matches.
  1415. // Stop when we get a match that ends at the string end, since no
  1416. // coercible string can be more right-ward without the same terminus.
  1417. var next;
  1418. while ((next = re[t.COERCERTL].exec(version)) &&
  1419. (!match || match.index + match[0].length !== version.length)
  1420. ) {
  1421. if (!match ||
  1422. next.index + next[0].length !== match.index + match[0].length) {
  1423. match = next;
  1424. }
  1425. re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
  1426. }
  1427. // leave it in a clean state
  1428. re[t.COERCERTL].lastIndex = -1;
  1429. }
  1430. if (match === null) {
  1431. return null
  1432. }
  1433. return parse(match[2] +
  1434. '.' + (match[3] || '0') +
  1435. '.' + (match[4] || '0'), options)
  1436. }
  1437. });
  1438. var NAME_SELECTOR = 'NAME_SELECTOR';
  1439. var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
  1440. var REF_SELECTOR = 'REF_SELECTOR';
  1441. var DOM_SELECTOR = 'DOM_SELECTOR';
  1442. var INVALID_SELECTOR = 'INVALID_SELECTOR';
  1443. var VUE_VERSION = Number(
  1444. ((Vue__default['default'].version.split('.')[0]) + "." + (Vue__default['default'].version.split('.')[1]))
  1445. );
  1446. var FUNCTIONAL_OPTIONS =
  1447. VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
  1448. var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue__default['default'].version, '2.1.8')
  1449. ? 'beforeCreate'
  1450. : 'beforeMount';
  1451. var CREATE_ELEMENT_ALIAS = semver.gt(Vue__default['default'].version, '2.1.5')
  1452. ? '_c'
  1453. : '_h';
  1454. //
  1455. function throwError(msg) {
  1456. throw new Error(("[vue-test-utils]: " + msg))
  1457. }
  1458. function warn(msg) {
  1459. console.error(("[vue-test-utils]: " + msg));
  1460. }
  1461. var camelizeRE = /-(\w)/g;
  1462. var camelize = function (str) {
  1463. var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }
  1464. );
  1465. return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
  1466. };
  1467. /**
  1468. * Capitalize a string.
  1469. */
  1470. var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
  1471. /**
  1472. * Hyphenate a camelCase string.
  1473. */
  1474. var hyphenateRE = /\B([A-Z])/g;
  1475. var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
  1476. function hasOwnProperty(obj, prop) {
  1477. return Object.prototype.hasOwnProperty.call(obj, prop)
  1478. }
  1479. function keys(obj) {
  1480. // $FlowIgnore
  1481. return Object.keys(obj)
  1482. }
  1483. function resolveComponent(id, components) {
  1484. if (typeof id !== 'string') {
  1485. return
  1486. }
  1487. // check local registration variations first
  1488. if (hasOwnProperty(components, id)) {
  1489. return components[id]
  1490. }
  1491. var camelizedId = camelize(id);
  1492. if (hasOwnProperty(components, camelizedId)) {
  1493. return components[camelizedId]
  1494. }
  1495. var PascalCaseId = capitalize(camelizedId);
  1496. if (hasOwnProperty(components, PascalCaseId)) {
  1497. return components[PascalCaseId]
  1498. }
  1499. // fallback to prototype chain
  1500. return components[id] || components[camelizedId] || components[PascalCaseId]
  1501. }
  1502. var UA =
  1503. typeof window !== 'undefined' &&
  1504. 'navigator' in window &&
  1505. navigator.userAgent.toLowerCase();
  1506. var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
  1507. var isEdge = UA && UA.indexOf('edge/') > 0;
  1508. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  1509. // get the event used to trigger v-model handler that updates bound data
  1510. function getCheckedEvent() {
  1511. var version = Vue__default['default'].version;
  1512. if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
  1513. return 'click'
  1514. }
  1515. if (semver.satisfies(version, '2.2 - 2.4')) {
  1516. return isChrome ? 'click' : 'change'
  1517. }
  1518. // change is handler for version 2.0 - 2.1.8, and 2.5+
  1519. return 'change'
  1520. }
  1521. /**
  1522. * Normalize nextTick to return a promise for all Vue 2 versions.
  1523. * Vue < 2.1 does not return a Promise from nextTick
  1524. * @return {Promise<R>}
  1525. */
  1526. function nextTick() {
  1527. if (VUE_VERSION > 2) { return Vue__default['default'].nextTick() }
  1528. return new Promise(function (resolve) {
  1529. Vue__default['default'].nextTick(resolve);
  1530. })
  1531. }
  1532. function warnDeprecated(method, fallback) {
  1533. if ( fallback === void 0 ) fallback = '';
  1534. if (!config.showDeprecationWarnings) { return }
  1535. var msg = method + " is deprecated and will be removed in the next major version.";
  1536. if (fallback) { msg += " " + fallback + "."; }
  1537. if (config.deprecationWarningHandler) {
  1538. config.deprecationWarningHandler(method, msg);
  1539. } else {
  1540. warn(msg);
  1541. }
  1542. }
  1543. function isVueWrapper(wrapper) {
  1544. return wrapper.vm || wrapper.isFunctionalComponent
  1545. }
  1546. //
  1547. function addMocks(
  1548. _Vue,
  1549. mockedProperties
  1550. ) {
  1551. if ( mockedProperties === void 0 ) mockedProperties = {};
  1552. if (mockedProperties === false) {
  1553. return
  1554. }
  1555. Object.keys(mockedProperties).forEach(function (key) {
  1556. try {
  1557. // $FlowIgnore
  1558. _Vue.prototype[key] = mockedProperties[key];
  1559. } catch (e) {
  1560. warn(
  1561. "could not overwrite property " + key + ", this is " +
  1562. "usually caused by a plugin that has added " +
  1563. "the property as a read-only value"
  1564. );
  1565. }
  1566. // $FlowIgnore
  1567. Vue__default['default'].util.defineReactive(_Vue, key, mockedProperties[key]);
  1568. });
  1569. }
  1570. //
  1571. function logEvents(
  1572. vm,
  1573. emitted,
  1574. emittedByOrder
  1575. ) {
  1576. var emit = vm.$emit;
  1577. vm.$emit = function (name) {
  1578. var args = [], len = arguments.length - 1;
  1579. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  1580. (emitted[name] || (emitted[name] = [])).push(args);
  1581. emittedByOrder.push({ name: name, args: args });
  1582. return emit.call.apply(emit, [ vm, name ].concat( args ))
  1583. };
  1584. }
  1585. function addEventLogger(_Vue) {
  1586. _Vue.mixin({
  1587. beforeCreate: function() {
  1588. this.__emitted = Object.create(null);
  1589. this.__emittedByOrder = [];
  1590. logEvents(this, this.__emitted, this.__emittedByOrder);
  1591. }
  1592. });
  1593. }
  1594. function addStubs(_Vue, stubComponents) {
  1595. var obj;
  1596. function addStubComponentsMixin() {
  1597. Object.assign(this.$options.components, stubComponents);
  1598. }
  1599. _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = addStubComponentsMixin, obj ));
  1600. }
  1601. //
  1602. function isDomSelector(selector) {
  1603. if (typeof selector !== 'string') {
  1604. return false
  1605. }
  1606. try {
  1607. if (typeof document === 'undefined') {
  1608. throwError(
  1609. "mount must be run in a browser environment like " +
  1610. "PhantomJS, jsdom or chrome"
  1611. );
  1612. }
  1613. } catch (error) {
  1614. throwError(
  1615. "mount must be run in a browser environment like " +
  1616. "PhantomJS, jsdom or chrome"
  1617. );
  1618. }
  1619. try {
  1620. document.querySelector(selector);
  1621. return true
  1622. } catch (error$1) {
  1623. return false
  1624. }
  1625. }
  1626. function isVueComponent(c) {
  1627. if (isConstructor(c)) {
  1628. return true
  1629. }
  1630. if (c === null || typeof c !== 'object') {
  1631. return false
  1632. }
  1633. if (c.extends || c._Ctor) {
  1634. return true
  1635. }
  1636. if (typeof c.template === 'string') {
  1637. return true
  1638. }
  1639. if (typeof c.setup === 'function' && !c.render) {
  1640. return true
  1641. }
  1642. return typeof c.render === 'function'
  1643. }
  1644. function componentNeedsCompiling(component) {
  1645. return (
  1646. component &&
  1647. !component.render &&
  1648. (component.template || component.extends || component.extendOptions) &&
  1649. !component.functional
  1650. )
  1651. }
  1652. function isRefSelector(refOptionsObject) {
  1653. if (
  1654. typeof refOptionsObject !== 'object' ||
  1655. Object.keys(refOptionsObject || {}).length !== 1
  1656. ) {
  1657. return false
  1658. }
  1659. return typeof refOptionsObject.ref === 'string'
  1660. }
  1661. function isNameSelector(nameOptionsObject) {
  1662. if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
  1663. return false
  1664. }
  1665. return !!nameOptionsObject.name
  1666. }
  1667. function isConstructor(c) {
  1668. return typeof c === 'function' && c.cid
  1669. }
  1670. function isDynamicComponent(c) {
  1671. return typeof c === 'function' && !c.cid
  1672. }
  1673. function isComponentOptions(c) {
  1674. return c !== null && typeof c === 'object' && (c.template || c.render)
  1675. }
  1676. function isFunctionalComponent(c) {
  1677. if (!isVueComponent(c)) {
  1678. return false
  1679. }
  1680. if (isConstructor(c)) {
  1681. return c.options.functional
  1682. }
  1683. return c.functional
  1684. }
  1685. function templateContainsComponent(
  1686. template,
  1687. name
  1688. ) {
  1689. return [capitalize, camelize, hyphenate].some(function (format) {
  1690. var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
  1691. return re.test(template)
  1692. })
  1693. }
  1694. function isPlainObject(c) {
  1695. return Object.prototype.toString.call(c) === '[object Object]'
  1696. }
  1697. function isHTMLElement(c) {
  1698. if (typeof HTMLElement === 'undefined') {
  1699. return false
  1700. }
  1701. // eslint-disable-next-line no-undef
  1702. return c instanceof HTMLElement
  1703. }
  1704. function makeMap(str, expectsLowerCase) {
  1705. var map = Object.create(null);
  1706. var list = str.split(',');
  1707. for (var i = 0; i < list.length; i++) {
  1708. map[list[i]] = true;
  1709. }
  1710. return expectsLowerCase
  1711. ? function(val) {
  1712. return map[val.toLowerCase()]
  1713. }
  1714. : function(val) {
  1715. return map[val]
  1716. }
  1717. }
  1718. var isHTMLTag = makeMap(
  1719. 'html,body,base,head,link,meta,style,title,' +
  1720. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1721. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1722. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1723. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,' +
  1724. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1725. 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' +
  1726. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1727. 'output,progress,select,textarea,' +
  1728. 'details,dialog,menu,menuitem,summary,' +
  1729. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1730. );
  1731. // this map is intentionally selective, only covering SVG elements that may
  1732. // contain child elements.
  1733. var isSVG = makeMap(
  1734. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1735. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1736. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1737. true
  1738. );
  1739. var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };
  1740. //
  1741. function compileTemplate(component) {
  1742. if (component.template) {
  1743. if (!vueTemplateCompiler.compileToFunctions) {
  1744. throwError(
  1745. "vueTemplateCompiler is undefined, you must pass " +
  1746. "precompiled components if vue-template-compiler is " +
  1747. "undefined"
  1748. );
  1749. }
  1750. if (component.template.charAt('#') === '#') {
  1751. var el = document.querySelector(component.template);
  1752. if (!el) {
  1753. throwError('Cannot find element' + component.template);
  1754. el = document.createElement('div');
  1755. }
  1756. component.template = el.innerHTML;
  1757. }
  1758. Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
  1759. {name: component.name}));
  1760. }
  1761. if (component.components) {
  1762. Object.keys(component.components).forEach(function (c) {
  1763. var cmp = component.components[c];
  1764. if (!cmp.render) {
  1765. compileTemplate(cmp);
  1766. }
  1767. });
  1768. }
  1769. if (component.extends) {
  1770. compileTemplate(component.extends);
  1771. }
  1772. if (component.extendOptions && !component.options.render) {
  1773. compileTemplate(component.options);
  1774. }
  1775. }
  1776. function compileTemplateForSlots(slots) {
  1777. Object.keys(slots).forEach(function (key) {
  1778. var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
  1779. slot.forEach(function (slotValue) {
  1780. if (componentNeedsCompiling(slotValue)) {
  1781. compileTemplate(slotValue);
  1782. }
  1783. });
  1784. });
  1785. }
  1786. //
  1787. var MOUNTING_OPTIONS = [
  1788. 'attachToDocument',
  1789. 'mocks',
  1790. 'slots',
  1791. 'localVue',
  1792. 'stubs',
  1793. 'context',
  1794. 'clone',
  1795. 'attrs',
  1796. 'listeners',
  1797. 'propsData',
  1798. 'shouldProxy'
  1799. ];
  1800. function extractInstanceOptions(options) {
  1801. var instanceOptions = Object.assign({}, options);
  1802. MOUNTING_OPTIONS.forEach(function (mountingOption) {
  1803. delete instanceOptions[mountingOption];
  1804. });
  1805. return instanceOptions
  1806. }
  1807. //
  1808. function isDestructuringSlotScope(slotScope) {
  1809. return /^{.*}$/.test(slotScope)
  1810. }
  1811. function getVueTemplateCompilerHelpers(
  1812. _Vue
  1813. ) {
  1814. // $FlowIgnore
  1815. var vue = new _Vue();
  1816. var helpers = {};
  1817. var names = [
  1818. '_c',
  1819. '_o',
  1820. '_n',
  1821. '_s',
  1822. '_l',
  1823. '_t',
  1824. '_q',
  1825. '_i',
  1826. '_m',
  1827. '_f',
  1828. '_k',
  1829. '_b',
  1830. '_v',
  1831. '_e',
  1832. '_u',
  1833. '_g'
  1834. ];
  1835. names.forEach(function (name) {
  1836. helpers[name] = vue._renderProxy[name];
  1837. });
  1838. helpers.$createElement = vue._renderProxy.$createElement;
  1839. helpers.$set = vue._renderProxy.$set;
  1840. return helpers
  1841. }
  1842. function validateEnvironment() {
  1843. if (VUE_VERSION < 2.1) {
  1844. throwError("the scopedSlots option is only supported in vue@2.1+.");
  1845. }
  1846. }
  1847. function isScopedSlot(slot) {
  1848. if (typeof slot === 'function') { return { match: null, slot: slot } }
  1849. var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
  1850. var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
  1851. var shortVSlotRe = /<template #.*="(.+)"/;
  1852. var hasOldSlotScope = slot.match(slotScopeRe);
  1853. var hasVSlotScopeAttr = slot.match(vSlotRe);
  1854. var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);
  1855. if (hasOldSlotScope) {
  1856. return { slot: slot, match: hasOldSlotScope }
  1857. } else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
  1858. // Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
  1859. var sanitizedSlot = slot.replace(
  1860. /(<template)([^>]+)(>.+<\/template>)/,
  1861. '$1$3'
  1862. );
  1863. return {
  1864. slot: sanitizedSlot,
  1865. match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
  1866. }
  1867. }
  1868. // we have no matches, so we just return
  1869. return {
  1870. slot: slot,
  1871. match: null
  1872. }
  1873. }
  1874. // Hide warning about <template> disallowed as root element
  1875. function customWarn(msg) {
  1876. if (msg.indexOf('Cannot use <template> as component root element') === -1) {
  1877. console.error(msg);
  1878. }
  1879. }
  1880. function createScopedSlots(
  1881. scopedSlotsOption,
  1882. _Vue
  1883. ) {
  1884. var scopedSlots = {};
  1885. if (!scopedSlotsOption) {
  1886. return scopedSlots
  1887. }
  1888. validateEnvironment();
  1889. var helpers = getVueTemplateCompilerHelpers(_Vue);
  1890. var loop = function ( scopedSlotName ) {
  1891. var slot = scopedSlotsOption[scopedSlotName];
  1892. var isFn = typeof slot === 'function';
  1893. var scopedSlotMatches = isScopedSlot(slot);
  1894. // Type check to silence flow (can't use isFn)
  1895. var renderFn =
  1896. typeof slot === 'function'
  1897. ? slot
  1898. : vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
  1899. .render;
  1900. var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
  1901. scopedSlots[scopedSlotName] = function(props) {
  1902. var obj;
  1903. var res;
  1904. if (isFn) {
  1905. res = renderFn.call(Object.assign({}, helpers), props);
  1906. } else if (slotScope && !isDestructuringSlotScope(slotScope)) {
  1907. res = renderFn.call(Object.assign({}, helpers, ( obj = {}, obj[slotScope] = props, obj )));
  1908. } else if (slotScope && isDestructuringSlotScope(slotScope)) {
  1909. res = renderFn.call(Object.assign({}, helpers, props));
  1910. } else {
  1911. res = renderFn.call(Object.assign({}, helpers, {props: props}));
  1912. }
  1913. // res is Array if <template> is a root element
  1914. return Array.isArray(res) ? res[0] : res
  1915. };
  1916. };
  1917. for (var scopedSlotName in scopedSlotsOption) loop( scopedSlotName );
  1918. return scopedSlots
  1919. }
  1920. //
  1921. var FUNCTION_PLACEHOLDER = '[Function]';
  1922. function isVueComponentStub(comp) {
  1923. return (comp && comp.template) || isVueComponent(comp)
  1924. }
  1925. function isValidStub(stub) {
  1926. return (
  1927. typeof stub === 'boolean' ||
  1928. (!!stub && typeof stub === 'string') ||
  1929. isVueComponentStub(stub)
  1930. )
  1931. }
  1932. function resolveComponent$1(obj, component) {
  1933. return (
  1934. obj[component] ||
  1935. obj[hyphenate(component)] ||
  1936. obj[camelize(component)] ||
  1937. obj[capitalize(camelize(component))] ||
  1938. obj[capitalize(component)] ||
  1939. {}
  1940. )
  1941. }
  1942. function getCoreProperties(componentOptions) {
  1943. return {
  1944. attrs: componentOptions.attrs,
  1945. name: componentOptions.name,
  1946. model: componentOptions.model,
  1947. props: componentOptions.props,
  1948. on: componentOptions.on,
  1949. key: componentOptions.key,
  1950. domProps: componentOptions.domProps,
  1951. class: componentOptions.class,
  1952. staticClass: componentOptions.staticClass,
  1953. staticStyle: componentOptions.staticStyle,
  1954. style: componentOptions.style,
  1955. normalizedStyle: componentOptions.normalizedStyle,
  1956. nativeOn: componentOptions.nativeOn,
  1957. functional: componentOptions.functional,
  1958. abstract: componentOptions.abstract
  1959. }
  1960. }
  1961. function resolveOptions(component, _Vue) {
  1962. if (isDynamicComponent(component)) {
  1963. return {}
  1964. }
  1965. return isConstructor(component)
  1966. ? component.options
  1967. : _Vue.extend(component).options
  1968. }
  1969. function getScopedSlotRenderFunctions(ctx) {
  1970. // In Vue 2.6+ a new v-slot syntax was introduced
  1971. // scopedSlots are now saved in parent._vnode.data.scopedSlots
  1972. // We filter out _normalized, $stable and $key keys
  1973. if (
  1974. ctx &&
  1975. ctx.$options &&
  1976. ctx.$options.parent &&
  1977. ctx.$options.parent._vnode &&
  1978. ctx.$options.parent._vnode.data &&
  1979. ctx.$options.parent._vnode.data.scopedSlots
  1980. ) {
  1981. var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
  1982. return keys(slotKeys).filter(
  1983. function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
  1984. )
  1985. }
  1986. return []
  1987. }
  1988. function createStubFromComponent(
  1989. originalComponent,
  1990. name,
  1991. _Vue
  1992. ) {
  1993. var componentOptions = resolveOptions(originalComponent, _Vue);
  1994. var tagName = (name || 'anonymous') + "-stub";
  1995. // ignoreElements does not exist in Vue 2.0.x
  1996. if (Vue__default['default'].config.ignoredElements) {
  1997. Vue__default['default'].config.ignoredElements.push(tagName);
  1998. }
  1999. return Object.assign({}, getCoreProperties(componentOptions),
  2000. {$_vueTestUtils_original: originalComponent,
  2001. $_doNotStubChildren: true,
  2002. render: function render(h, context) {
  2003. var this$1 = this;
  2004. return h(
  2005. tagName,
  2006. componentOptions.functional
  2007. ? Object.assign({}, context.data,
  2008. {attrs: Object.assign({}, shapeStubProps(context.props),
  2009. context.data.attrs)})
  2010. : {
  2011. attrs: Object.assign({}, shapeStubProps(this.$props))
  2012. },
  2013. context
  2014. ? context.children
  2015. : this.$options._renderChildren ||
  2016. getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
  2017. )
  2018. )
  2019. }})
  2020. }
  2021. function shapeStubProps(props) {
  2022. var shapedProps = {};
  2023. for (var propName in props) {
  2024. if (typeof props[propName] === 'function') {
  2025. shapedProps[propName] = FUNCTION_PLACEHOLDER;
  2026. continue
  2027. }
  2028. if (Array.isArray(props[propName])) {
  2029. shapedProps[propName] = props[propName].map(function (value) {
  2030. return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
  2031. });
  2032. continue
  2033. }
  2034. shapedProps[propName] = props[propName];
  2035. }
  2036. return shapedProps
  2037. }
  2038. // DEPRECATED: converts string stub to template stub.
  2039. function createStubFromString(templateString, name) {
  2040. warnDeprecated('Using a string for stubs');
  2041. if (templateContainsComponent(templateString, name)) {
  2042. throwError('options.stub cannot contain a circular reference');
  2043. }
  2044. return {
  2045. template: templateString,
  2046. $_doNotStubChildren: true
  2047. }
  2048. }
  2049. function setStubComponentName(
  2050. stub,
  2051. originalComponent,
  2052. _Vue
  2053. ) {
  2054. if ( originalComponent === void 0 ) originalComponent = {};
  2055. if (stub.name) { return }
  2056. var componentOptions = resolveOptions(originalComponent, _Vue);
  2057. stub.name = getCoreProperties(componentOptions).name;
  2058. }
  2059. function validateStub(stub) {
  2060. if (!isValidStub(stub)) {
  2061. throwError("options.stub values must be passed a string or " + "component");
  2062. }
  2063. }
  2064. function createStubsFromStubsObject(
  2065. originalComponents,
  2066. stubs,
  2067. _Vue
  2068. ) {
  2069. if ( originalComponents === void 0 ) originalComponents = {};
  2070. return Object.keys(stubs || {}).reduce(function (acc, stubName) {
  2071. var stub = stubs[stubName];
  2072. validateStub(stub);
  2073. if (stub === false) {
  2074. return acc
  2075. }
  2076. var component = resolveComponent$1(originalComponents, stubName);
  2077. if (stub === true) {
  2078. acc[stubName] = createStubFromComponent(component, stubName, _Vue);
  2079. return acc
  2080. }
  2081. if (typeof stub === 'string') {
  2082. stub = createStubFromString(stub, stubName);
  2083. stubs[stubName];
  2084. }
  2085. setStubComponentName(stub, component, _Vue);
  2086. if (componentNeedsCompiling(stub)) {
  2087. compileTemplate(stub);
  2088. }
  2089. acc[stubName] = stub;
  2090. stub._Ctor = {};
  2091. return acc
  2092. }, {})
  2093. }
  2094. var isAllowlisted = function (el, allowlist) { return resolveComponent(el, allowlist); };
  2095. var isAlreadyStubbed = function (el, stubs) { return stubs.has(el); };
  2096. function shouldExtend(component, _Vue) {
  2097. return isConstructor(component) || (component && component.extends)
  2098. }
  2099. function extend(component, _Vue) {
  2100. var componentOptions = component.options ? component.options : component;
  2101. var stub = _Vue.extend(componentOptions);
  2102. stub.options.$_vueTestUtils_original = component;
  2103. stub.options._base = _Vue;
  2104. return stub
  2105. }
  2106. function createStubIfNeeded(shouldStub, component, _Vue, el) {
  2107. if (shouldStub) {
  2108. return createStubFromComponent(component || {}, el, _Vue)
  2109. }
  2110. if (shouldExtend(component)) {
  2111. return extend(component, _Vue)
  2112. }
  2113. }
  2114. function shouldNotBeStubbed(el, allowlist, modifiedComponents) {
  2115. return (
  2116. (typeof el === 'string' && isReservedTag(el)) ||
  2117. isAllowlisted(el, allowlist) ||
  2118. isAlreadyStubbed(el, modifiedComponents)
  2119. )
  2120. }
  2121. function patchCreateElement(_Vue, stubs, stubAllComponents) {
  2122. var obj;
  2123. // This mixin patches vm.$createElement so that we can stub all components
  2124. // before they are rendered in shallow mode. We also need to ensure that
  2125. // component constructors were created from the _Vue constructor. If not,
  2126. // we must replace them with components created from the _Vue constructor
  2127. // before calling the original $createElement. This ensures that components
  2128. // have the correct instance properties and stubs when they are rendered.
  2129. function patchCreateElementMixin() {
  2130. var vm = this;
  2131. if (vm.$options.$_doNotStubChildren || vm.$options._isFunctionalContainer) {
  2132. return
  2133. }
  2134. var modifiedComponents = new Set();
  2135. var originalCreateElement = vm.$createElement;
  2136. var originalComponents = vm.$options.components;
  2137. var createElement = function (el) {
  2138. var obj;
  2139. var args = [], len = arguments.length - 1;
  2140. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  2141. if (shouldNotBeStubbed(el, stubs, modifiedComponents)) {
  2142. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2143. }
  2144. if (isConstructor(el) || isComponentOptions(el)) {
  2145. if (stubAllComponents) {
  2146. var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
  2147. return originalCreateElement.apply(void 0, [ stub ].concat( args ))
  2148. }
  2149. var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
  2150. return originalCreateElement.apply(void 0, [ Constructor ].concat( args ))
  2151. }
  2152. if (typeof el === 'string') {
  2153. var original = resolveComponent(el, originalComponents);
  2154. if (!original) {
  2155. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2156. }
  2157. if (isDynamicComponent(original)) {
  2158. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2159. }
  2160. var stub$1 = createStubIfNeeded(stubAllComponents, original, _Vue, el);
  2161. if (stub$1) {
  2162. Object.assign(vm.$options.components, ( obj = {}, obj[el] = stub$1, obj ));
  2163. modifiedComponents.add(el);
  2164. }
  2165. }
  2166. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2167. };
  2168. vm[CREATE_ELEMENT_ALIAS] = createElement;
  2169. vm.$createElement = createElement;
  2170. }
  2171. _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = patchCreateElementMixin, obj ));
  2172. }
  2173. //
  2174. 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; }
  2175. function createContext(options, scopedSlots, currentProps) {
  2176. var on = Object.assign({}, (options.context && options.context.on),
  2177. options.listeners);
  2178. return Object.assign({}, {attrs: Object.assign({}, options.attrs,
  2179. // pass as attrs so that inheritAttrs works correctly
  2180. // props should take precedence over attrs
  2181. currentProps)},
  2182. (options.context || {}),
  2183. {on: on,
  2184. scopedSlots: scopedSlots})
  2185. }
  2186. function createChildren(vm, h, ref) {
  2187. var slots = ref.slots;
  2188. var context = ref.context;
  2189. var slotVNodes = slots ? createSlotVNodes(vm, slots) : undefined;
  2190. return (
  2191. (context &&
  2192. context.children &&
  2193. context.children.map(function (x) { return (typeof x === 'function' ? x(h) : x); })) ||
  2194. slotVNodes
  2195. )
  2196. }
  2197. function getValuesFromCallableOption(optionValue) {
  2198. if (typeof optionValue === 'function') {
  2199. return optionValue.call(this)
  2200. }
  2201. return optionValue
  2202. }
  2203. function createInstance(
  2204. component,
  2205. options,
  2206. _Vue
  2207. ) {
  2208. var componentOptions = isConstructor(component)
  2209. ? component.options
  2210. : component;
  2211. // instance options are options that are passed to the
  2212. // root instance when it's instantiated
  2213. var instanceOptions = extractInstanceOptions(options);
  2214. var globalComponents = _Vue.options.components || {};
  2215. var componentsToStub = Object.assign(
  2216. Object.create(globalComponents),
  2217. componentOptions.components
  2218. );
  2219. var stubComponentsObject = createStubsFromStubsObject(
  2220. componentsToStub,
  2221. // $FlowIgnore
  2222. options.stubs,
  2223. _Vue
  2224. );
  2225. addEventLogger(_Vue);
  2226. addMocks(_Vue, options.mocks);
  2227. addStubs(_Vue, stubComponentsObject);
  2228. patchCreateElement(_Vue, stubComponentsObject, options.shouldProxy);
  2229. if (componentNeedsCompiling(componentOptions)) {
  2230. compileTemplate(componentOptions);
  2231. }
  2232. // used to identify extended component using constructor
  2233. componentOptions.$_vueTestUtils_original = component;
  2234. // watchers provided in mounting options should override preexisting ones
  2235. if (componentOptions.watch && instanceOptions.watch) {
  2236. var componentWatchers = Object.keys(componentOptions.watch);
  2237. var instanceWatchers = Object.keys(instanceOptions.watch);
  2238. for (var i = 0; i < instanceWatchers.length; i++) {
  2239. var k = instanceWatchers[i];
  2240. // override the componentOptions with the one provided in mounting options
  2241. if (componentWatchers.includes(k)) {
  2242. componentOptions.watch[k] = instanceOptions.watch[k];
  2243. }
  2244. }
  2245. }
  2246. // make sure all extends are based on this instance
  2247. var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
  2248. Constructor.options._base = _Vue;
  2249. var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);
  2250. var parentComponentOptions = options.parentComponent || {};
  2251. var originalParentComponentProvide = parentComponentOptions.provide;
  2252. parentComponentOptions.provide = function() {
  2253. return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
  2254. // $FlowIgnore
  2255. getValuesFromCallableOption.call(this, options.provide))
  2256. };
  2257. var originalParentComponentData = parentComponentOptions.data;
  2258. parentComponentOptions.data = function() {
  2259. return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentData),
  2260. {vueTestUtils_childProps: Object.assign({}, options.propsData)})
  2261. };
  2262. parentComponentOptions.$_doNotStubChildren = true;
  2263. parentComponentOptions.$_isWrapperParent = true;
  2264. parentComponentOptions._isFunctionalContainer = componentOptions.functional;
  2265. parentComponentOptions.render = function(h) {
  2266. return h(
  2267. Constructor,
  2268. createContext(options, scopedSlots, this.vueTestUtils_childProps),
  2269. createChildren(this, h, options)
  2270. )
  2271. };
  2272. // options "propsData" can only be used during instance creation with the `new` keyword
  2273. // "data" should be set only on component under test to avoid reactivity issues
  2274. var propsData = options.propsData;
  2275. var data = options.data;
  2276. var rest$1 = objectWithoutProperties( options, ["propsData", "data"] );
  2277. var rest = rest$1; // eslint-disable-line
  2278. var Parent = _Vue.extend(Object.assign({}, rest,
  2279. parentComponentOptions));
  2280. return new Parent()
  2281. }
  2282. //
  2283. function createElement() {
  2284. if (document) {
  2285. var elem = document.createElement('div');
  2286. if (document.body) {
  2287. document.body.appendChild(elem);
  2288. }
  2289. return elem
  2290. }
  2291. }
  2292. //
  2293. function findDOMNodes(
  2294. element,
  2295. selector
  2296. ) {
  2297. var nodes = [];
  2298. if (!element || !element.querySelectorAll || !element.matches) {
  2299. return nodes
  2300. }
  2301. if (element.matches(selector)) {
  2302. nodes.push(element);
  2303. }
  2304. // $FlowIgnore
  2305. return nodes.concat([].slice.call(element.querySelectorAll(selector)))
  2306. }
  2307. function vmMatchesName(vm, name) {
  2308. // We want to mirror how Vue resolves component names in SFCs:
  2309. // For example, <test-component />, <TestComponent /> and `<testComponent />
  2310. // all resolve to the same component
  2311. var componentName = isFunctionalComponent(vm)
  2312. ? vm.name
  2313. : vm.$options && vm.$options.name;
  2314. return (
  2315. !!name &&
  2316. !!componentName &&
  2317. (componentName === name ||
  2318. // testComponent -> TestComponent
  2319. componentName === capitalize(name) ||
  2320. // test-component -> TestComponent
  2321. componentName === capitalize(camelize(name)) ||
  2322. // same match as above, but the component name vs query
  2323. capitalize(camelize(componentName)) === name)
  2324. )
  2325. }
  2326. function vmCtorMatches(vm, component) {
  2327. if (
  2328. (vm.$options && vm.$options.$_vueTestUtils_original === component) ||
  2329. vm.$_vueTestUtils_original === component
  2330. ) {
  2331. return true
  2332. }
  2333. var Ctor = isConstructor(component)
  2334. ? component.options._Ctor
  2335. : component._Ctor;
  2336. if (!Ctor) {
  2337. return false
  2338. }
  2339. if (vm.constructor.extendOptions === component) {
  2340. return true
  2341. }
  2342. if (component.functional) {
  2343. return Object.keys(vm._Ctor || {}).some(function (c) {
  2344. return component === vm._Ctor[c].extendOptions
  2345. })
  2346. }
  2347. }
  2348. function matches(node, selector) {
  2349. if (selector.type === DOM_SELECTOR) {
  2350. var element = node instanceof Element ? node : node.elm;
  2351. return element && element.matches && element.matches(selector.value)
  2352. }
  2353. var isFunctionalSelector = isConstructor(selector.value)
  2354. ? selector.value.options.functional
  2355. : selector.value.functional;
  2356. var componentInstance =
  2357. (isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
  2358. node[FUNCTIONAL_OPTIONS] ||
  2359. node.child;
  2360. if (!componentInstance) {
  2361. return false
  2362. }
  2363. if (selector.type === COMPONENT_SELECTOR) {
  2364. if (vmCtorMatches(componentInstance, selector.value)) {
  2365. return true
  2366. }
  2367. }
  2368. // Fallback to name selector for COMPONENT_SELECTOR for Vue < 2.1
  2369. var nameSelector = isConstructor(selector.value)
  2370. ? selector.value.extendOptions.name
  2371. : selector.value.name;
  2372. return vmMatchesName(componentInstance, nameSelector)
  2373. }
  2374. //
  2375. /**
  2376. * Traverses a vue instance for its parents and returns them in an array format
  2377. * @param {Component} vm
  2378. * @returns {Component[]} The component and its corresponding parents, in order from left to right
  2379. */
  2380. function findAllParentInstances(childVm) {
  2381. var instances = [childVm];
  2382. function getParent(_vm) {
  2383. if (_vm && _vm.$parent) {
  2384. instances.push(_vm.$parent);
  2385. return getParent(_vm.$parent)
  2386. }
  2387. return _vm
  2388. }
  2389. getParent(childVm);
  2390. return instances
  2391. }
  2392. function findAllInstances(rootVm) {
  2393. var instances = [rootVm];
  2394. var i = 0;
  2395. while (i < instances.length) {
  2396. var vm = instances[i]
  2397. ;(vm.$children || []).forEach(function (child) {
  2398. instances.push(child);
  2399. });
  2400. i++;
  2401. }
  2402. return instances
  2403. }
  2404. function findAllVNodes(vnode, selector) {
  2405. var matchingNodes = [];
  2406. var nodes = [vnode];
  2407. while (nodes.length) {
  2408. var node = nodes.shift();
  2409. if (node.children) {
  2410. var children = [].concat( node.children ).reverse();
  2411. children.forEach(function (n) {
  2412. nodes.unshift(n);
  2413. });
  2414. }
  2415. if (node.child) {
  2416. nodes.unshift(node.child._vnode);
  2417. }
  2418. if (matches(node, selector)) {
  2419. matchingNodes.push(node);
  2420. }
  2421. }
  2422. return matchingNodes
  2423. }
  2424. function removeDuplicateNodes(vNodes) {
  2425. var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
  2426. return vNodes.filter(function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); })
  2427. }
  2428. function find(
  2429. root,
  2430. vm,
  2431. selector
  2432. ) {
  2433. if (root instanceof Element && selector.type !== DOM_SELECTOR) {
  2434. throwError(
  2435. "cannot find a Vue instance on a DOM node. The node " +
  2436. "you are calling find on does not exist in the " +
  2437. "VDom. Are you adding the node as innerHTML?"
  2438. );
  2439. }
  2440. if (
  2441. selector.type === COMPONENT_SELECTOR &&
  2442. (selector.value.functional ||
  2443. (selector.value.options && selector.value.options.functional)) &&
  2444. VUE_VERSION < 2.3
  2445. ) {
  2446. throwError(
  2447. "find for functional components is not supported " + "in Vue < 2.3"
  2448. );
  2449. }
  2450. if (root instanceof Element) {
  2451. return findDOMNodes(root, selector.value)
  2452. }
  2453. if (!root && selector.type !== DOM_SELECTOR) {
  2454. throwError(
  2455. "cannot find a Vue instance on a DOM node. The node " +
  2456. "you are calling find on does not exist in the " +
  2457. "VDom. Are you adding the node as innerHTML?"
  2458. );
  2459. }
  2460. if (!vm && selector.type === REF_SELECTOR) {
  2461. throwError("$ref selectors can only be used on Vue component " + "wrappers");
  2462. }
  2463. if (vm && vm.$refs && selector.value.ref in vm.$refs) {
  2464. var refs = vm.$refs[selector.value.ref];
  2465. return Array.isArray(refs) ? refs : [refs]
  2466. }
  2467. var nodes = findAllVNodes(root, selector);
  2468. var dedupedNodes = removeDuplicateNodes(nodes);
  2469. if (nodes.length > 0 || selector.type !== DOM_SELECTOR) {
  2470. return dedupedNodes
  2471. }
  2472. // Fallback in case element exists in HTML, but not in vnode tree
  2473. // (e.g. if innerHTML is set as a domProp)
  2474. return findDOMNodes(root.elm, selector.value)
  2475. }
  2476. function errorHandler(errorOrString, vm, info) {
  2477. var error =
  2478. typeof errorOrString === 'object' ? errorOrString : new Error(errorOrString);
  2479. // If a user defined errorHandler was register via createLocalVue
  2480. // find and call the user defined errorHandler
  2481. var instancedErrorHandlers = findAllParentInstances(vm)
  2482. .filter(
  2483. function (_vm) { return _vm &&
  2484. _vm.$options &&
  2485. _vm.$options.localVue &&
  2486. _vm.$options.localVue.config &&
  2487. _vm.$options.localVue.config.errorHandler; }
  2488. )
  2489. .map(function (_vm) { return _vm.$options.localVue.config.errorHandler; });
  2490. if (vm) {
  2491. vm._error = error;
  2492. }
  2493. if (!instancedErrorHandlers.length) {
  2494. throw error
  2495. }
  2496. // should be one error handler, as only once can be registered with local vue
  2497. // regardless, if more exist (for whatever reason), invoke the other user defined error handlers
  2498. instancedErrorHandlers.forEach(function (instancedErrorHandler) {
  2499. instancedErrorHandler(error, vm, info);
  2500. });
  2501. }
  2502. function throwIfInstancesThrew(vm) {
  2503. var instancesWithError = findAllInstances(vm).filter(function (_vm) { return _vm._error; });
  2504. if (instancesWithError.length > 0) {
  2505. throw instancesWithError[0]._error
  2506. }
  2507. }
  2508. var hasWarned = false;
  2509. // Vue swallows errors thrown by instances, even if the global error handler
  2510. // throws. In order to throw in the test, we add an _error property to an
  2511. // instance when it throws. Then we loop through the instances with
  2512. // throwIfInstancesThrew and throw an error in the test context if any
  2513. // instances threw.
  2514. function addGlobalErrorHandler(_Vue) {
  2515. var existingErrorHandler = _Vue.config.errorHandler;
  2516. if (existingErrorHandler === errorHandler) {
  2517. return
  2518. }
  2519. if (_Vue.config.errorHandler && !hasWarned) {
  2520. warn(
  2521. "Global error handler detected (Vue.config.errorHandler). \n" +
  2522. "Vue Test Utils sets a custom error handler to throw errors " +
  2523. "thrown by instances. If you want this behavior in " +
  2524. "your tests, you must remove the global error handler."
  2525. );
  2526. hasWarned = true;
  2527. } else {
  2528. _Vue.config.errorHandler = errorHandler;
  2529. }
  2530. }
  2531. function normalizeStubs(stubs) {
  2532. if ( stubs === void 0 ) stubs = {};
  2533. if (stubs === false) {
  2534. return false
  2535. }
  2536. if (isPlainObject(stubs)) {
  2537. return stubs
  2538. }
  2539. if (Array.isArray(stubs)) {
  2540. return stubs.reduce(function (acc, stub) {
  2541. if (typeof stub !== 'string') {
  2542. throwError('each item in an options.stubs array must be a string');
  2543. }
  2544. acc[stub] = true;
  2545. return acc
  2546. }, {})
  2547. }
  2548. throwError('options.stubs must be an object or an Array');
  2549. }
  2550. function normalizeProvide(provide) {
  2551. // Objects are not resolved in extended components in Vue < 2.5
  2552. // https://github.com/vuejs/vue/issues/6436
  2553. if (typeof provide === 'object' && VUE_VERSION < 2.5) {
  2554. var obj = Object.assign({}, provide);
  2555. return function () { return obj; }
  2556. }
  2557. return provide
  2558. }
  2559. //
  2560. function getOption(option, config) {
  2561. if (option === false) {
  2562. return false
  2563. }
  2564. if (option || (config && Object.keys(config).length > 0)) {
  2565. if (option instanceof Function) {
  2566. return option
  2567. }
  2568. if (config instanceof Function) {
  2569. throw new Error("Config can't be a Function.")
  2570. }
  2571. return Object.assign({}, config,
  2572. option)
  2573. }
  2574. }
  2575. function getStubs(stubs, configStubs) {
  2576. var normalizedStubs = normalizeStubs(stubs);
  2577. var normalizedConfigStubs = normalizeStubs(configStubs);
  2578. return getOption(normalizedStubs, normalizedConfigStubs)
  2579. }
  2580. function mergeOptions(
  2581. options,
  2582. config
  2583. ) {
  2584. var mocks = (getOption(options.mocks, config.mocks));
  2585. var methods = (getOption(options.methods, config.methods));
  2586. if (methods && Object.keys(methods).length) {
  2587. warnDeprecated(
  2588. 'overwriting methods via the `methods` property',
  2589. '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'
  2590. );
  2591. }
  2592. var provide = (getOption(options.provide, config.provide));
  2593. var stubs = (getStubs(options.stubs, config.stubs));
  2594. // $FlowIgnore
  2595. return Object.assign({}, options,
  2596. {provide: normalizeProvide(provide),
  2597. stubs: stubs,
  2598. mocks: mocks,
  2599. methods: methods})
  2600. }
  2601. var config = {
  2602. stubs: {
  2603. transition: true,
  2604. 'transition-group': true
  2605. },
  2606. mocks: {},
  2607. methods: {},
  2608. provide: {},
  2609. showDeprecationWarnings:
  2610. true
  2611. };
  2612. //
  2613. function warnIfNoWindow() {
  2614. if (typeof window === 'undefined') {
  2615. throwError(
  2616. "window is undefined, vue-test-utils needs to be " +
  2617. "run in a browser environment. \n" +
  2618. "You can run the tests in node using jsdom \n" +
  2619. "See https://vue-test-utils.vuejs.org/guides/#browser-environment " +
  2620. "for more details."
  2621. );
  2622. }
  2623. }
  2624. function polyfill() {
  2625. // Polyfill `Element.matches()` for IE and older versions of Chrome:
  2626. // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
  2627. if (!Element.prototype.matches) {
  2628. Element.prototype.matches =
  2629. Element.prototype.msMatchesSelector ||
  2630. Element.prototype.webkitMatchesSelector;
  2631. }
  2632. }
  2633. /*jshint node:true */
  2634. function OutputLine(parent) {
  2635. this.__parent = parent;
  2636. this.__character_count = 0;
  2637. // use indent_count as a marker for this.__lines that have preserved indentation
  2638. this.__indent_count = -1;
  2639. this.__alignment_count = 0;
  2640. this.__wrap_point_index = 0;
  2641. this.__wrap_point_character_count = 0;
  2642. this.__wrap_point_indent_count = -1;
  2643. this.__wrap_point_alignment_count = 0;
  2644. this.__items = [];
  2645. }
  2646. OutputLine.prototype.clone_empty = function() {
  2647. var line = new OutputLine(this.__parent);
  2648. line.set_indent(this.__indent_count, this.__alignment_count);
  2649. return line;
  2650. };
  2651. OutputLine.prototype.item = function(index) {
  2652. if (index < 0) {
  2653. return this.__items[this.__items.length + index];
  2654. } else {
  2655. return this.__items[index];
  2656. }
  2657. };
  2658. OutputLine.prototype.has_match = function(pattern) {
  2659. for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
  2660. if (this.__items[lastCheckedOutput].match(pattern)) {
  2661. return true;
  2662. }
  2663. }
  2664. return false;
  2665. };
  2666. OutputLine.prototype.set_indent = function(indent, alignment) {
  2667. if (this.is_empty()) {
  2668. this.__indent_count = indent || 0;
  2669. this.__alignment_count = alignment || 0;
  2670. this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
  2671. }
  2672. };
  2673. OutputLine.prototype._set_wrap_point = function() {
  2674. if (this.__parent.wrap_line_length) {
  2675. this.__wrap_point_index = this.__items.length;
  2676. this.__wrap_point_character_count = this.__character_count;
  2677. this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
  2678. this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
  2679. }
  2680. };
  2681. OutputLine.prototype._should_wrap = function() {
  2682. return this.__wrap_point_index &&
  2683. this.__character_count > this.__parent.wrap_line_length &&
  2684. this.__wrap_point_character_count > this.__parent.next_line.__character_count;
  2685. };
  2686. OutputLine.prototype._allow_wrap = function() {
  2687. if (this._should_wrap()) {
  2688. this.__parent.add_new_line();
  2689. var next = this.__parent.current_line;
  2690. next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
  2691. next.__items = this.__items.slice(this.__wrap_point_index);
  2692. this.__items = this.__items.slice(0, this.__wrap_point_index);
  2693. next.__character_count += this.__character_count - this.__wrap_point_character_count;
  2694. this.__character_count = this.__wrap_point_character_count;
  2695. if (next.__items[0] === " ") {
  2696. next.__items.splice(0, 1);
  2697. next.__character_count -= 1;
  2698. }
  2699. return true;
  2700. }
  2701. return false;
  2702. };
  2703. OutputLine.prototype.is_empty = function() {
  2704. return this.__items.length === 0;
  2705. };
  2706. OutputLine.prototype.last = function() {
  2707. if (!this.is_empty()) {
  2708. return this.__items[this.__items.length - 1];
  2709. } else {
  2710. return null;
  2711. }
  2712. };
  2713. OutputLine.prototype.push = function(item) {
  2714. this.__items.push(item);
  2715. var last_newline_index = item.lastIndexOf('\n');
  2716. if (last_newline_index !== -1) {
  2717. this.__character_count = item.length - last_newline_index;
  2718. } else {
  2719. this.__character_count += item.length;
  2720. }
  2721. };
  2722. OutputLine.prototype.pop = function() {
  2723. var item = null;
  2724. if (!this.is_empty()) {
  2725. item = this.__items.pop();
  2726. this.__character_count -= item.length;
  2727. }
  2728. return item;
  2729. };
  2730. OutputLine.prototype._remove_indent = function() {
  2731. if (this.__indent_count > 0) {
  2732. this.__indent_count -= 1;
  2733. this.__character_count -= this.__parent.indent_size;
  2734. }
  2735. };
  2736. OutputLine.prototype._remove_wrap_indent = function() {
  2737. if (this.__wrap_point_indent_count > 0) {
  2738. this.__wrap_point_indent_count -= 1;
  2739. }
  2740. };
  2741. OutputLine.prototype.trim = function() {
  2742. while (this.last() === ' ') {
  2743. this.__items.pop();
  2744. this.__character_count -= 1;
  2745. }
  2746. };
  2747. OutputLine.prototype.toString = function() {
  2748. var result = '';
  2749. if (this.is_empty()) {
  2750. if (this.__parent.indent_empty_lines) {
  2751. result = this.__parent.get_indent_string(this.__indent_count);
  2752. }
  2753. } else {
  2754. result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
  2755. result += this.__items.join('');
  2756. }
  2757. return result;
  2758. };
  2759. function IndentStringCache(options, baseIndentString) {
  2760. this.__cache = [''];
  2761. this.__indent_size = options.indent_size;
  2762. this.__indent_string = options.indent_char;
  2763. if (!options.indent_with_tabs) {
  2764. this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
  2765. }
  2766. // Set to null to continue support for auto detection of base indent
  2767. baseIndentString = baseIndentString || '';
  2768. if (options.indent_level > 0) {
  2769. baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
  2770. }
  2771. this.__base_string = baseIndentString;
  2772. this.__base_string_length = baseIndentString.length;
  2773. }
  2774. IndentStringCache.prototype.get_indent_size = function(indent, column) {
  2775. var result = this.__base_string_length;
  2776. column = column || 0;
  2777. if (indent < 0) {
  2778. result = 0;
  2779. }
  2780. result += indent * this.__indent_size;
  2781. result += column;
  2782. return result;
  2783. };
  2784. IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
  2785. var result = this.__base_string;
  2786. column = column || 0;
  2787. if (indent_level < 0) {
  2788. indent_level = 0;
  2789. result = '';
  2790. }
  2791. column += indent_level * this.__indent_size;
  2792. this.__ensure_cache(column);
  2793. result += this.__cache[column];
  2794. return result;
  2795. };
  2796. IndentStringCache.prototype.__ensure_cache = function(column) {
  2797. while (column >= this.__cache.length) {
  2798. this.__add_column();
  2799. }
  2800. };
  2801. IndentStringCache.prototype.__add_column = function() {
  2802. var column = this.__cache.length;
  2803. var indent = 0;
  2804. var result = '';
  2805. if (this.__indent_size && column >= this.__indent_size) {
  2806. indent = Math.floor(column / this.__indent_size);
  2807. column -= indent * this.__indent_size;
  2808. result = new Array(indent + 1).join(this.__indent_string);
  2809. }
  2810. if (column) {
  2811. result += new Array(column + 1).join(' ');
  2812. }
  2813. this.__cache.push(result);
  2814. };
  2815. function Output(options, baseIndentString) {
  2816. this.__indent_cache = new IndentStringCache(options, baseIndentString);
  2817. this.raw = false;
  2818. this._end_with_newline = options.end_with_newline;
  2819. this.indent_size = options.indent_size;
  2820. this.wrap_line_length = options.wrap_line_length;
  2821. this.indent_empty_lines = options.indent_empty_lines;
  2822. this.__lines = [];
  2823. this.previous_line = null;
  2824. this.current_line = null;
  2825. this.next_line = new OutputLine(this);
  2826. this.space_before_token = false;
  2827. this.non_breaking_space = false;
  2828. this.previous_token_wrapped = false;
  2829. // initialize
  2830. this.__add_outputline();
  2831. }
  2832. Output.prototype.__add_outputline = function() {
  2833. this.previous_line = this.current_line;
  2834. this.current_line = this.next_line.clone_empty();
  2835. this.__lines.push(this.current_line);
  2836. };
  2837. Output.prototype.get_line_number = function() {
  2838. return this.__lines.length;
  2839. };
  2840. Output.prototype.get_indent_string = function(indent, column) {
  2841. return this.__indent_cache.get_indent_string(indent, column);
  2842. };
  2843. Output.prototype.get_indent_size = function(indent, column) {
  2844. return this.__indent_cache.get_indent_size(indent, column);
  2845. };
  2846. Output.prototype.is_empty = function() {
  2847. return !this.previous_line && this.current_line.is_empty();
  2848. };
  2849. Output.prototype.add_new_line = function(force_newline) {
  2850. // never newline at the start of file
  2851. // otherwise, newline only if we didn't just add one or we're forced
  2852. if (this.is_empty() ||
  2853. (!force_newline && this.just_added_newline())) {
  2854. return false;
  2855. }
  2856. // if raw output is enabled, don't print additional newlines,
  2857. // but still return True as though you had
  2858. if (!this.raw) {
  2859. this.__add_outputline();
  2860. }
  2861. return true;
  2862. };
  2863. Output.prototype.get_code = function(eol) {
  2864. this.trim(true);
  2865. // handle some edge cases where the last tokens
  2866. // has text that ends with newline(s)
  2867. var last_item = this.current_line.pop();
  2868. if (last_item) {
  2869. if (last_item[last_item.length - 1] === '\n') {
  2870. last_item = last_item.replace(/\n+$/g, '');
  2871. }
  2872. this.current_line.push(last_item);
  2873. }
  2874. if (this._end_with_newline) {
  2875. this.__add_outputline();
  2876. }
  2877. var sweet_code = this.__lines.join('\n');
  2878. if (eol !== '\n') {
  2879. sweet_code = sweet_code.replace(/[\n]/g, eol);
  2880. }
  2881. return sweet_code;
  2882. };
  2883. Output.prototype.set_wrap_point = function() {
  2884. this.current_line._set_wrap_point();
  2885. };
  2886. Output.prototype.set_indent = function(indent, alignment) {
  2887. indent = indent || 0;
  2888. alignment = alignment || 0;
  2889. // Next line stores alignment values
  2890. this.next_line.set_indent(indent, alignment);
  2891. // Never indent your first output indent at the start of the file
  2892. if (this.__lines.length > 1) {
  2893. this.current_line.set_indent(indent, alignment);
  2894. return true;
  2895. }
  2896. this.current_line.set_indent();
  2897. return false;
  2898. };
  2899. Output.prototype.add_raw_token = function(token) {
  2900. for (var x = 0; x < token.newlines; x++) {
  2901. this.__add_outputline();
  2902. }
  2903. this.current_line.set_indent(-1);
  2904. this.current_line.push(token.whitespace_before);
  2905. this.current_line.push(token.text);
  2906. this.space_before_token = false;
  2907. this.non_breaking_space = false;
  2908. this.previous_token_wrapped = false;
  2909. };
  2910. Output.prototype.add_token = function(printable_token) {
  2911. this.__add_space_before_token();
  2912. this.current_line.push(printable_token);
  2913. this.space_before_token = false;
  2914. this.non_breaking_space = false;
  2915. this.previous_token_wrapped = this.current_line._allow_wrap();
  2916. };
  2917. Output.prototype.__add_space_before_token = function() {
  2918. if (this.space_before_token && !this.just_added_newline()) {
  2919. if (!this.non_breaking_space) {
  2920. this.set_wrap_point();
  2921. }
  2922. this.current_line.push(' ');
  2923. }
  2924. };
  2925. Output.prototype.remove_indent = function(index) {
  2926. var output_length = this.__lines.length;
  2927. while (index < output_length) {
  2928. this.__lines[index]._remove_indent();
  2929. index++;
  2930. }
  2931. this.current_line._remove_wrap_indent();
  2932. };
  2933. Output.prototype.trim = function(eat_newlines) {
  2934. eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
  2935. this.current_line.trim();
  2936. while (eat_newlines && this.__lines.length > 1 &&
  2937. this.current_line.is_empty()) {
  2938. this.__lines.pop();
  2939. this.current_line = this.__lines[this.__lines.length - 1];
  2940. this.current_line.trim();
  2941. }
  2942. this.previous_line = this.__lines.length > 1 ?
  2943. this.__lines[this.__lines.length - 2] : null;
  2944. };
  2945. Output.prototype.just_added_newline = function() {
  2946. return this.current_line.is_empty();
  2947. };
  2948. Output.prototype.just_added_blankline = function() {
  2949. return this.is_empty() ||
  2950. (this.current_line.is_empty() && this.previous_line.is_empty());
  2951. };
  2952. Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
  2953. var index = this.__lines.length - 2;
  2954. while (index >= 0) {
  2955. var potentialEmptyLine = this.__lines[index];
  2956. if (potentialEmptyLine.is_empty()) {
  2957. break;
  2958. } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
  2959. potentialEmptyLine.item(-1) !== ends_with) {
  2960. this.__lines.splice(index + 1, 0, new OutputLine(this));
  2961. this.previous_line = this.__lines[this.__lines.length - 2];
  2962. break;
  2963. }
  2964. index--;
  2965. }
  2966. };
  2967. var Output_1 = Output;
  2968. var output = {
  2969. Output: Output_1
  2970. };
  2971. /*jshint node:true */
  2972. function Token(type, text, newlines, whitespace_before) {
  2973. this.type = type;
  2974. this.text = text;
  2975. // comments_before are
  2976. // comments that have a new line before them
  2977. // and may or may not have a newline after
  2978. // this is a set of comments before
  2979. this.comments_before = null; /* inline comment*/
  2980. // this.comments_after = new TokenStream(); // no new line before and newline after
  2981. this.newlines = newlines || 0;
  2982. this.whitespace_before = whitespace_before || '';
  2983. this.parent = null;
  2984. this.next = null;
  2985. this.previous = null;
  2986. this.opened = null;
  2987. this.closed = null;
  2988. this.directives = null;
  2989. }
  2990. var Token_1 = Token;
  2991. var token = {
  2992. Token: Token_1
  2993. };
  2994. var acorn = createCommonjsModule(function (module, exports) {
  2995. // acorn used char codes to squeeze the last bit of performance out
  2996. // Beautifier is okay without that, so we're using regex
  2997. // permit $ (36) and @ (64). @ is used in ES7 decorators.
  2998. // 65 through 91 are uppercase letters.
  2999. // permit _ (95).
  3000. // 97 through 123 are lowercase letters.
  3001. var baseASCIIidentifierStartChars = "\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
  3002. // inside an identifier @ is not allowed but 0-9 are.
  3003. var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
  3004. // Big ugly regular expressions that match characters in the
  3005. // whitespace, identifier, and identifier-start categories. These
  3006. // are only applied when a character is found to actually have a
  3007. // code point above 128.
  3008. 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";
  3009. 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";
  3010. //var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3011. //var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3012. var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
  3013. var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
  3014. exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
  3015. exports.identifierStart = new RegExp(identifierStart);
  3016. exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
  3017. // Whether a single character denotes a newline.
  3018. exports.newline = /[\n\r\u2028\u2029]/;
  3019. // Matches a whole line break (where CRLF is considered a single
  3020. // line break). Used to count lines.
  3021. // in javascript, these two differ
  3022. // in python they are the same, different methods are called on them
  3023. exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
  3024. exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
  3025. });
  3026. /*jshint node:true */
  3027. function Options(options, merge_child_field) {
  3028. this.raw_options = _mergeOpts(options, merge_child_field);
  3029. // Support passing the source text back with no change
  3030. this.disabled = this._get_boolean('disabled');
  3031. this.eol = this._get_characters('eol', 'auto');
  3032. this.end_with_newline = this._get_boolean('end_with_newline');
  3033. this.indent_size = this._get_number('indent_size', 4);
  3034. this.indent_char = this._get_characters('indent_char', ' ');
  3035. this.indent_level = this._get_number('indent_level');
  3036. this.preserve_newlines = this._get_boolean('preserve_newlines', true);
  3037. this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
  3038. if (!this.preserve_newlines) {
  3039. this.max_preserve_newlines = 0;
  3040. }
  3041. this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
  3042. if (this.indent_with_tabs) {
  3043. this.indent_char = '\t';
  3044. // indent_size behavior changed after 1.8.6
  3045. // It used to be that indent_size would be
  3046. // set to 1 for indent_with_tabs. That is no longer needed and
  3047. // actually doesn't make sense - why not use spaces? Further,
  3048. // that might produce unexpected behavior - tabs being used
  3049. // for single-column alignment. So, when indent_with_tabs is true
  3050. // and indent_size is 1, reset indent_size to 4.
  3051. if (this.indent_size === 1) {
  3052. this.indent_size = 4;
  3053. }
  3054. }
  3055. // Backwards compat with 1.3.x
  3056. this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
  3057. this.indent_empty_lines = this._get_boolean('indent_empty_lines');
  3058. // valid templating languages ['django', 'erb', 'handlebars', 'php']
  3059. // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
  3060. // other values ignored
  3061. this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
  3062. }
  3063. Options.prototype._get_array = function(name, default_value) {
  3064. var option_value = this.raw_options[name];
  3065. var result = default_value || [];
  3066. if (typeof option_value === 'object') {
  3067. if (option_value !== null && typeof option_value.concat === 'function') {
  3068. result = option_value.concat();
  3069. }
  3070. } else if (typeof option_value === 'string') {
  3071. result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
  3072. }
  3073. return result;
  3074. };
  3075. Options.prototype._get_boolean = function(name, default_value) {
  3076. var option_value = this.raw_options[name];
  3077. var result = option_value === undefined ? !!default_value : !!option_value;
  3078. return result;
  3079. };
  3080. Options.prototype._get_characters = function(name, default_value) {
  3081. var option_value = this.raw_options[name];
  3082. var result = default_value || '';
  3083. if (typeof option_value === 'string') {
  3084. result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
  3085. }
  3086. return result;
  3087. };
  3088. Options.prototype._get_number = function(name, default_value) {
  3089. var option_value = this.raw_options[name];
  3090. default_value = parseInt(default_value, 10);
  3091. if (isNaN(default_value)) {
  3092. default_value = 0;
  3093. }
  3094. var result = parseInt(option_value, 10);
  3095. if (isNaN(result)) {
  3096. result = default_value;
  3097. }
  3098. return result;
  3099. };
  3100. Options.prototype._get_selection = function(name, selection_list, default_value) {
  3101. var result = this._get_selection_list(name, selection_list, default_value);
  3102. if (result.length !== 1) {
  3103. throw new Error(
  3104. "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
  3105. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  3106. }
  3107. return result[0];
  3108. };
  3109. Options.prototype._get_selection_list = function(name, selection_list, default_value) {
  3110. if (!selection_list || selection_list.length === 0) {
  3111. throw new Error("Selection list cannot be empty.");
  3112. }
  3113. default_value = default_value || [selection_list[0]];
  3114. if (!this._is_valid_selection(default_value, selection_list)) {
  3115. throw new Error("Invalid Default Value!");
  3116. }
  3117. var result = this._get_array(name, default_value);
  3118. if (!this._is_valid_selection(result, selection_list)) {
  3119. throw new Error(
  3120. "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
  3121. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  3122. }
  3123. return result;
  3124. };
  3125. Options.prototype._is_valid_selection = function(result, selection_list) {
  3126. return result.length && selection_list.length &&
  3127. !result.some(function(item) { return selection_list.indexOf(item) === -1; });
  3128. };
  3129. // merges child options up with the parent options object
  3130. // Example: obj = {a: 1, b: {a: 2}}
  3131. // mergeOpts(obj, 'b')
  3132. //
  3133. // Returns: {a: 2}
  3134. function _mergeOpts(allOptions, childFieldName) {
  3135. var finalOpts = {};
  3136. allOptions = _normalizeOpts(allOptions);
  3137. var name;
  3138. for (name in allOptions) {
  3139. if (name !== childFieldName) {
  3140. finalOpts[name] = allOptions[name];
  3141. }
  3142. }
  3143. //merge in the per type settings for the childFieldName
  3144. if (childFieldName && allOptions[childFieldName]) {
  3145. for (name in allOptions[childFieldName]) {
  3146. finalOpts[name] = allOptions[childFieldName][name];
  3147. }
  3148. }
  3149. return finalOpts;
  3150. }
  3151. function _normalizeOpts(options) {
  3152. var convertedOpts = {};
  3153. var key;
  3154. for (key in options) {
  3155. var newKey = key.replace(/-/g, "_");
  3156. convertedOpts[newKey] = options[key];
  3157. }
  3158. return convertedOpts;
  3159. }
  3160. var Options_1 = Options;
  3161. var normalizeOpts = _normalizeOpts;
  3162. var mergeOpts = _mergeOpts;
  3163. var options = {
  3164. Options: Options_1,
  3165. normalizeOpts: normalizeOpts,
  3166. mergeOpts: mergeOpts
  3167. };
  3168. var BaseOptions = options.Options;
  3169. var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
  3170. function Options$1(options) {
  3171. BaseOptions.call(this, options, 'js');
  3172. // compatibility, re
  3173. var raw_brace_style = this.raw_options.brace_style || null;
  3174. if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
  3175. this.raw_options.brace_style = "expand";
  3176. } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
  3177. this.raw_options.brace_style = "collapse,preserve-inline";
  3178. } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
  3179. this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
  3180. // } else if (!raw_brace_style) { //Nothing exists to set it
  3181. // raw_brace_style = "collapse";
  3182. }
  3183. //preserve-inline in delimited string will trigger brace_preserve_inline, everything
  3184. //else is considered a brace_style and the last one only will have an effect
  3185. var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
  3186. this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
  3187. this.brace_style = "collapse";
  3188. for (var bs = 0; bs < brace_style_split.length; bs++) {
  3189. if (brace_style_split[bs] === "preserve-inline") {
  3190. this.brace_preserve_inline = true;
  3191. } else {
  3192. this.brace_style = brace_style_split[bs];
  3193. }
  3194. }
  3195. this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
  3196. this.break_chained_methods = this._get_boolean('break_chained_methods');
  3197. this.space_in_paren = this._get_boolean('space_in_paren');
  3198. this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
  3199. this.jslint_happy = this._get_boolean('jslint_happy');
  3200. this.space_after_anon_function = this._get_boolean('space_after_anon_function');
  3201. this.space_after_named_function = this._get_boolean('space_after_named_function');
  3202. this.keep_array_indentation = this._get_boolean('keep_array_indentation');
  3203. this.space_before_conditional = this._get_boolean('space_before_conditional', true);
  3204. this.unescape_strings = this._get_boolean('unescape_strings');
  3205. this.e4x = this._get_boolean('e4x');
  3206. this.comma_first = this._get_boolean('comma_first');
  3207. this.operator_position = this._get_selection('operator_position', validPositionValues);
  3208. // For testing of beautify preserve:start directive
  3209. this.test_output_raw = this._get_boolean('test_output_raw');
  3210. // force this._options.space_after_anon_function to true if this._options.jslint_happy
  3211. if (this.jslint_happy) {
  3212. this.space_after_anon_function = true;
  3213. }
  3214. }
  3215. Options$1.prototype = new BaseOptions();
  3216. var Options_1$1 = Options$1;
  3217. var options$1 = {
  3218. Options: Options_1$1
  3219. };
  3220. /*jshint node:true */
  3221. var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
  3222. function InputScanner(input_string) {
  3223. this.__input = input_string || '';
  3224. this.__input_length = this.__input.length;
  3225. this.__position = 0;
  3226. }
  3227. InputScanner.prototype.restart = function() {
  3228. this.__position = 0;
  3229. };
  3230. InputScanner.prototype.back = function() {
  3231. if (this.__position > 0) {
  3232. this.__position -= 1;
  3233. }
  3234. };
  3235. InputScanner.prototype.hasNext = function() {
  3236. return this.__position < this.__input_length;
  3237. };
  3238. InputScanner.prototype.next = function() {
  3239. var val = null;
  3240. if (this.hasNext()) {
  3241. val = this.__input.charAt(this.__position);
  3242. this.__position += 1;
  3243. }
  3244. return val;
  3245. };
  3246. InputScanner.prototype.peek = function(index) {
  3247. var val = null;
  3248. index = index || 0;
  3249. index += this.__position;
  3250. if (index >= 0 && index < this.__input_length) {
  3251. val = this.__input.charAt(index);
  3252. }
  3253. return val;
  3254. };
  3255. // This is a JavaScript only helper function (not in python)
  3256. // Javascript doesn't have a match method
  3257. // and not all implementation support "sticky" flag.
  3258. // If they do not support sticky then both this.match() and this.test() method
  3259. // must get the match and check the index of the match.
  3260. // If sticky is supported and set, this method will use it.
  3261. // Otherwise it will check that global is set, and fall back to the slower method.
  3262. InputScanner.prototype.__match = function(pattern, index) {
  3263. pattern.lastIndex = index;
  3264. var pattern_match = pattern.exec(this.__input);
  3265. if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
  3266. if (pattern_match.index !== index) {
  3267. pattern_match = null;
  3268. }
  3269. }
  3270. return pattern_match;
  3271. };
  3272. InputScanner.prototype.test = function(pattern, index) {
  3273. index = index || 0;
  3274. index += this.__position;
  3275. if (index >= 0 && index < this.__input_length) {
  3276. return !!this.__match(pattern, index);
  3277. } else {
  3278. return false;
  3279. }
  3280. };
  3281. InputScanner.prototype.testChar = function(pattern, index) {
  3282. // test one character regex match
  3283. var val = this.peek(index);
  3284. pattern.lastIndex = 0;
  3285. return val !== null && pattern.test(val);
  3286. };
  3287. InputScanner.prototype.match = function(pattern) {
  3288. var pattern_match = this.__match(pattern, this.__position);
  3289. if (pattern_match) {
  3290. this.__position += pattern_match[0].length;
  3291. } else {
  3292. pattern_match = null;
  3293. }
  3294. return pattern_match;
  3295. };
  3296. InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
  3297. var val = '';
  3298. var match;
  3299. if (starting_pattern) {
  3300. match = this.match(starting_pattern);
  3301. if (match) {
  3302. val += match[0];
  3303. }
  3304. }
  3305. if (until_pattern && (match || !starting_pattern)) {
  3306. val += this.readUntil(until_pattern, until_after);
  3307. }
  3308. return val;
  3309. };
  3310. InputScanner.prototype.readUntil = function(pattern, until_after) {
  3311. var val = '';
  3312. var match_index = this.__position;
  3313. pattern.lastIndex = this.__position;
  3314. var pattern_match = pattern.exec(this.__input);
  3315. if (pattern_match) {
  3316. match_index = pattern_match.index;
  3317. if (until_after) {
  3318. match_index += pattern_match[0].length;
  3319. }
  3320. } else {
  3321. match_index = this.__input_length;
  3322. }
  3323. val = this.__input.substring(this.__position, match_index);
  3324. this.__position = match_index;
  3325. return val;
  3326. };
  3327. InputScanner.prototype.readUntilAfter = function(pattern) {
  3328. return this.readUntil(pattern, true);
  3329. };
  3330. InputScanner.prototype.get_regexp = function(pattern, match_from) {
  3331. var result = null;
  3332. var flags = 'g';
  3333. if (match_from && regexp_has_sticky) {
  3334. flags = 'y';
  3335. }
  3336. // strings are converted to regexp
  3337. if (typeof pattern === "string" && pattern !== '') {
  3338. // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
  3339. result = new RegExp(pattern, flags);
  3340. } else if (pattern) {
  3341. result = new RegExp(pattern.source, flags);
  3342. }
  3343. return result;
  3344. };
  3345. InputScanner.prototype.get_literal_regexp = function(literal_string) {
  3346. return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
  3347. };
  3348. /* css beautifier legacy helpers */
  3349. InputScanner.prototype.peekUntilAfter = function(pattern) {
  3350. var start = this.__position;
  3351. var val = this.readUntilAfter(pattern);
  3352. this.__position = start;
  3353. return val;
  3354. };
  3355. InputScanner.prototype.lookBack = function(testVal) {
  3356. var start = this.__position - 1;
  3357. return start >= testVal.length && this.__input.substring(start - testVal.length, start)
  3358. .toLowerCase() === testVal;
  3359. };
  3360. var InputScanner_1 = InputScanner;
  3361. var inputscanner = {
  3362. InputScanner: InputScanner_1
  3363. };
  3364. /*jshint node:true */
  3365. function TokenStream(parent_token) {
  3366. // private
  3367. this.__tokens = [];
  3368. this.__tokens_length = this.__tokens.length;
  3369. this.__position = 0;
  3370. this.__parent_token = parent_token;
  3371. }
  3372. TokenStream.prototype.restart = function() {
  3373. this.__position = 0;
  3374. };
  3375. TokenStream.prototype.isEmpty = function() {
  3376. return this.__tokens_length === 0;
  3377. };
  3378. TokenStream.prototype.hasNext = function() {
  3379. return this.__position < this.__tokens_length;
  3380. };
  3381. TokenStream.prototype.next = function() {
  3382. var val = null;
  3383. if (this.hasNext()) {
  3384. val = this.__tokens[this.__position];
  3385. this.__position += 1;
  3386. }
  3387. return val;
  3388. };
  3389. TokenStream.prototype.peek = function(index) {
  3390. var val = null;
  3391. index = index || 0;
  3392. index += this.__position;
  3393. if (index >= 0 && index < this.__tokens_length) {
  3394. val = this.__tokens[index];
  3395. }
  3396. return val;
  3397. };
  3398. TokenStream.prototype.add = function(token) {
  3399. if (this.__parent_token) {
  3400. token.parent = this.__parent_token;
  3401. }
  3402. this.__tokens.push(token);
  3403. this.__tokens_length += 1;
  3404. };
  3405. var TokenStream_1 = TokenStream;
  3406. var tokenstream = {
  3407. TokenStream: TokenStream_1
  3408. };
  3409. /*jshint node:true */
  3410. function Pattern(input_scanner, parent) {
  3411. this._input = input_scanner;
  3412. this._starting_pattern = null;
  3413. this._match_pattern = null;
  3414. this._until_pattern = null;
  3415. this._until_after = false;
  3416. if (parent) {
  3417. this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
  3418. this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
  3419. this._until_pattern = this._input.get_regexp(parent._until_pattern);
  3420. this._until_after = parent._until_after;
  3421. }
  3422. }
  3423. Pattern.prototype.read = function() {
  3424. var result = this._input.read(this._starting_pattern);
  3425. if (!this._starting_pattern || result) {
  3426. result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
  3427. }
  3428. return result;
  3429. };
  3430. Pattern.prototype.read_match = function() {
  3431. return this._input.match(this._match_pattern);
  3432. };
  3433. Pattern.prototype.until_after = function(pattern) {
  3434. var result = this._create();
  3435. result._until_after = true;
  3436. result._until_pattern = this._input.get_regexp(pattern);
  3437. result._update();
  3438. return result;
  3439. };
  3440. Pattern.prototype.until = function(pattern) {
  3441. var result = this._create();
  3442. result._until_after = false;
  3443. result._until_pattern = this._input.get_regexp(pattern);
  3444. result._update();
  3445. return result;
  3446. };
  3447. Pattern.prototype.starting_with = function(pattern) {
  3448. var result = this._create();
  3449. result._starting_pattern = this._input.get_regexp(pattern, true);
  3450. result._update();
  3451. return result;
  3452. };
  3453. Pattern.prototype.matching = function(pattern) {
  3454. var result = this._create();
  3455. result._match_pattern = this._input.get_regexp(pattern, true);
  3456. result._update();
  3457. return result;
  3458. };
  3459. Pattern.prototype._create = function() {
  3460. return new Pattern(this._input, this);
  3461. };
  3462. Pattern.prototype._update = function() {};
  3463. var Pattern_1 = Pattern;
  3464. var pattern = {
  3465. Pattern: Pattern_1
  3466. };
  3467. var Pattern$1 = pattern.Pattern;
  3468. function WhitespacePattern(input_scanner, parent) {
  3469. Pattern$1.call(this, input_scanner, parent);
  3470. if (parent) {
  3471. this._line_regexp = this._input.get_regexp(parent._line_regexp);
  3472. } else {
  3473. this.__set_whitespace_patterns('', '');
  3474. }
  3475. this.newline_count = 0;
  3476. this.whitespace_before_token = '';
  3477. }
  3478. WhitespacePattern.prototype = new Pattern$1();
  3479. WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
  3480. whitespace_chars += '\\t ';
  3481. newline_chars += '\\n\\r';
  3482. this._match_pattern = this._input.get_regexp(
  3483. '[' + whitespace_chars + newline_chars + ']+', true);
  3484. this._newline_regexp = this._input.get_regexp(
  3485. '\\r\\n|[' + newline_chars + ']');
  3486. };
  3487. WhitespacePattern.prototype.read = function() {
  3488. this.newline_count = 0;
  3489. this.whitespace_before_token = '';
  3490. var resulting_string = this._input.read(this._match_pattern);
  3491. if (resulting_string === ' ') {
  3492. this.whitespace_before_token = ' ';
  3493. } else if (resulting_string) {
  3494. var matches = this.__split(this._newline_regexp, resulting_string);
  3495. this.newline_count = matches.length - 1;
  3496. this.whitespace_before_token = matches[this.newline_count];
  3497. }
  3498. return resulting_string;
  3499. };
  3500. WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
  3501. var result = this._create();
  3502. result.__set_whitespace_patterns(whitespace_chars, newline_chars);
  3503. result._update();
  3504. return result;
  3505. };
  3506. WhitespacePattern.prototype._create = function() {
  3507. return new WhitespacePattern(this._input, this);
  3508. };
  3509. WhitespacePattern.prototype.__split = function(regexp, input_string) {
  3510. regexp.lastIndex = 0;
  3511. var start_index = 0;
  3512. var result = [];
  3513. var next_match = regexp.exec(input_string);
  3514. while (next_match) {
  3515. result.push(input_string.substring(start_index, next_match.index));
  3516. start_index = next_match.index + next_match[0].length;
  3517. next_match = regexp.exec(input_string);
  3518. }
  3519. if (start_index < input_string.length) {
  3520. result.push(input_string.substring(start_index, input_string.length));
  3521. } else {
  3522. result.push('');
  3523. }
  3524. return result;
  3525. };
  3526. var WhitespacePattern_1 = WhitespacePattern;
  3527. var whitespacepattern = {
  3528. WhitespacePattern: WhitespacePattern_1
  3529. };
  3530. var InputScanner$1 = inputscanner.InputScanner;
  3531. var Token$1 = token.Token;
  3532. var TokenStream$1 = tokenstream.TokenStream;
  3533. var WhitespacePattern$1 = whitespacepattern.WhitespacePattern;
  3534. var TOKEN = {
  3535. START: 'TK_START',
  3536. RAW: 'TK_RAW',
  3537. EOF: 'TK_EOF'
  3538. };
  3539. var Tokenizer = function(input_string, options) {
  3540. this._input = new InputScanner$1(input_string);
  3541. this._options = options || {};
  3542. this.__tokens = null;
  3543. this._patterns = {};
  3544. this._patterns.whitespace = new WhitespacePattern$1(this._input);
  3545. };
  3546. Tokenizer.prototype.tokenize = function() {
  3547. this._input.restart();
  3548. this.__tokens = new TokenStream$1();
  3549. this._reset();
  3550. var current;
  3551. var previous = new Token$1(TOKEN.START, '');
  3552. var open_token = null;
  3553. var open_stack = [];
  3554. var comments = new TokenStream$1();
  3555. while (previous.type !== TOKEN.EOF) {
  3556. current = this._get_next_token(previous, open_token);
  3557. while (this._is_comment(current)) {
  3558. comments.add(current);
  3559. current = this._get_next_token(previous, open_token);
  3560. }
  3561. if (!comments.isEmpty()) {
  3562. current.comments_before = comments;
  3563. comments = new TokenStream$1();
  3564. }
  3565. current.parent = open_token;
  3566. if (this._is_opening(current)) {
  3567. open_stack.push(open_token);
  3568. open_token = current;
  3569. } else if (open_token && this._is_closing(current, open_token)) {
  3570. current.opened = open_token;
  3571. open_token.closed = current;
  3572. open_token = open_stack.pop();
  3573. current.parent = open_token;
  3574. }
  3575. current.previous = previous;
  3576. previous.next = current;
  3577. this.__tokens.add(current);
  3578. previous = current;
  3579. }
  3580. return this.__tokens;
  3581. };
  3582. Tokenizer.prototype._is_first_token = function() {
  3583. return this.__tokens.isEmpty();
  3584. };
  3585. Tokenizer.prototype._reset = function() {};
  3586. Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  3587. this._readWhitespace();
  3588. var resulting_string = this._input.read(/.+/g);
  3589. if (resulting_string) {
  3590. return this._create_token(TOKEN.RAW, resulting_string);
  3591. } else {
  3592. return this._create_token(TOKEN.EOF, '');
  3593. }
  3594. };
  3595. Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
  3596. return false;
  3597. };
  3598. Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
  3599. return false;
  3600. };
  3601. Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
  3602. return false;
  3603. };
  3604. Tokenizer.prototype._create_token = function(type, text) {
  3605. var token = new Token$1(type, text,
  3606. this._patterns.whitespace.newline_count,
  3607. this._patterns.whitespace.whitespace_before_token);
  3608. return token;
  3609. };
  3610. Tokenizer.prototype._readWhitespace = function() {
  3611. return this._patterns.whitespace.read();
  3612. };
  3613. var Tokenizer_1 = Tokenizer;
  3614. var TOKEN_1 = TOKEN;
  3615. var tokenizer = {
  3616. Tokenizer: Tokenizer_1,
  3617. TOKEN: TOKEN_1
  3618. };
  3619. /*jshint node:true */
  3620. function Directives(start_block_pattern, end_block_pattern) {
  3621. start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
  3622. end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
  3623. this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
  3624. this.__directive_pattern = / (\w+)[:](\w+)/g;
  3625. this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
  3626. }
  3627. Directives.prototype.get_directives = function(text) {
  3628. if (!text.match(this.__directives_block_pattern)) {
  3629. return null;
  3630. }
  3631. var directives = {};
  3632. this.__directive_pattern.lastIndex = 0;
  3633. var directive_match = this.__directive_pattern.exec(text);
  3634. while (directive_match) {
  3635. directives[directive_match[1]] = directive_match[2];
  3636. directive_match = this.__directive_pattern.exec(text);
  3637. }
  3638. return directives;
  3639. };
  3640. Directives.prototype.readIgnored = function(input) {
  3641. return input.readUntilAfter(this.__directives_end_ignore_pattern);
  3642. };
  3643. var Directives_1 = Directives;
  3644. var directives = {
  3645. Directives: Directives_1
  3646. };
  3647. var Pattern$2 = pattern.Pattern;
  3648. var template_names = {
  3649. django: false,
  3650. erb: false,
  3651. handlebars: false,
  3652. php: false
  3653. };
  3654. // This lets templates appear anywhere we would do a readUntil
  3655. // The cost is higher but it is pay to play.
  3656. function TemplatablePattern(input_scanner, parent) {
  3657. Pattern$2.call(this, input_scanner, parent);
  3658. this.__template_pattern = null;
  3659. this._disabled = Object.assign({}, template_names);
  3660. this._excluded = Object.assign({}, template_names);
  3661. if (parent) {
  3662. this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
  3663. this._excluded = Object.assign(this._excluded, parent._excluded);
  3664. this._disabled = Object.assign(this._disabled, parent._disabled);
  3665. }
  3666. var pattern = new Pattern$2(input_scanner);
  3667. this.__patterns = {
  3668. handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
  3669. handlebars: pattern.starting_with(/{{/).until_after(/}}/),
  3670. php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
  3671. erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
  3672. // django coflicts with handlebars a bit.
  3673. django: pattern.starting_with(/{%/).until_after(/%}/),
  3674. django_value: pattern.starting_with(/{{/).until_after(/}}/),
  3675. django_comment: pattern.starting_with(/{#/).until_after(/#}/)
  3676. };
  3677. }
  3678. TemplatablePattern.prototype = new Pattern$2();
  3679. TemplatablePattern.prototype._create = function() {
  3680. return new TemplatablePattern(this._input, this);
  3681. };
  3682. TemplatablePattern.prototype._update = function() {
  3683. this.__set_templated_pattern();
  3684. };
  3685. TemplatablePattern.prototype.disable = function(language) {
  3686. var result = this._create();
  3687. result._disabled[language] = true;
  3688. result._update();
  3689. return result;
  3690. };
  3691. TemplatablePattern.prototype.read_options = function(options) {
  3692. var result = this._create();
  3693. for (var language in template_names) {
  3694. result._disabled[language] = options.templating.indexOf(language) === -1;
  3695. }
  3696. result._update();
  3697. return result;
  3698. };
  3699. TemplatablePattern.prototype.exclude = function(language) {
  3700. var result = this._create();
  3701. result._excluded[language] = true;
  3702. result._update();
  3703. return result;
  3704. };
  3705. TemplatablePattern.prototype.read = function() {
  3706. var result = '';
  3707. if (this._match_pattern) {
  3708. result = this._input.read(this._starting_pattern);
  3709. } else {
  3710. result = this._input.read(this._starting_pattern, this.__template_pattern);
  3711. }
  3712. var next = this._read_template();
  3713. while (next) {
  3714. if (this._match_pattern) {
  3715. next += this._input.read(this._match_pattern);
  3716. } else {
  3717. next += this._input.readUntil(this.__template_pattern);
  3718. }
  3719. result += next;
  3720. next = this._read_template();
  3721. }
  3722. if (this._until_after) {
  3723. result += this._input.readUntilAfter(this._until_pattern);
  3724. }
  3725. return result;
  3726. };
  3727. TemplatablePattern.prototype.__set_templated_pattern = function() {
  3728. var items = [];
  3729. if (!this._disabled.php) {
  3730. items.push(this.__patterns.php._starting_pattern.source);
  3731. }
  3732. if (!this._disabled.handlebars) {
  3733. items.push(this.__patterns.handlebars._starting_pattern.source);
  3734. }
  3735. if (!this._disabled.erb) {
  3736. items.push(this.__patterns.erb._starting_pattern.source);
  3737. }
  3738. if (!this._disabled.django) {
  3739. items.push(this.__patterns.django._starting_pattern.source);
  3740. items.push(this.__patterns.django_value._starting_pattern.source);
  3741. items.push(this.__patterns.django_comment._starting_pattern.source);
  3742. }
  3743. if (this._until_pattern) {
  3744. items.push(this._until_pattern.source);
  3745. }
  3746. this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
  3747. };
  3748. TemplatablePattern.prototype._read_template = function() {
  3749. var resulting_string = '';
  3750. var c = this._input.peek();
  3751. if (c === '<') {
  3752. var peek1 = this._input.peek(1);
  3753. //if we're in a comment, do something special
  3754. // We treat all comments as literals, even more than preformatted tags
  3755. // we just look for the appropriate close tag
  3756. if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
  3757. resulting_string = resulting_string ||
  3758. this.__patterns.php.read();
  3759. }
  3760. if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
  3761. resulting_string = resulting_string ||
  3762. this.__patterns.erb.read();
  3763. }
  3764. } else if (c === '{') {
  3765. if (!this._disabled.handlebars && !this._excluded.handlebars) {
  3766. resulting_string = resulting_string ||
  3767. this.__patterns.handlebars_comment.read();
  3768. resulting_string = resulting_string ||
  3769. this.__patterns.handlebars.read();
  3770. }
  3771. if (!this._disabled.django) {
  3772. // django coflicts with handlebars a bit.
  3773. if (!this._excluded.django && !this._excluded.handlebars) {
  3774. resulting_string = resulting_string ||
  3775. this.__patterns.django_value.read();
  3776. }
  3777. if (!this._excluded.django) {
  3778. resulting_string = resulting_string ||
  3779. this.__patterns.django_comment.read();
  3780. resulting_string = resulting_string ||
  3781. this.__patterns.django.read();
  3782. }
  3783. }
  3784. }
  3785. return resulting_string;
  3786. };
  3787. var TemplatablePattern_1 = TemplatablePattern;
  3788. var templatablepattern = {
  3789. TemplatablePattern: TemplatablePattern_1
  3790. };
  3791. var InputScanner$2 = inputscanner.InputScanner;
  3792. var BaseTokenizer = tokenizer.Tokenizer;
  3793. var BASETOKEN = tokenizer.TOKEN;
  3794. var Directives$1 = directives.Directives;
  3795. var Pattern$3 = pattern.Pattern;
  3796. var TemplatablePattern$1 = templatablepattern.TemplatablePattern;
  3797. function in_array(what, arr) {
  3798. return arr.indexOf(what) !== -1;
  3799. }
  3800. var TOKEN$1 = {
  3801. START_EXPR: 'TK_START_EXPR',
  3802. END_EXPR: 'TK_END_EXPR',
  3803. START_BLOCK: 'TK_START_BLOCK',
  3804. END_BLOCK: 'TK_END_BLOCK',
  3805. WORD: 'TK_WORD',
  3806. RESERVED: 'TK_RESERVED',
  3807. SEMICOLON: 'TK_SEMICOLON',
  3808. STRING: 'TK_STRING',
  3809. EQUALS: 'TK_EQUALS',
  3810. OPERATOR: 'TK_OPERATOR',
  3811. COMMA: 'TK_COMMA',
  3812. BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
  3813. COMMENT: 'TK_COMMENT',
  3814. DOT: 'TK_DOT',
  3815. UNKNOWN: 'TK_UNKNOWN',
  3816. START: BASETOKEN.START,
  3817. RAW: BASETOKEN.RAW,
  3818. EOF: BASETOKEN.EOF
  3819. };
  3820. var directives_core = new Directives$1(/\/\*/, /\*\//);
  3821. var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/;
  3822. var digit = /[0-9]/;
  3823. // Dot "." must be distinguished from "..." and decimal
  3824. var dot_pattern = /[^\d\.]/;
  3825. var positionable_operators = (
  3826. ">>> === !== " +
  3827. "<< && >= ** != == <= >> || " +
  3828. "< / - + > : & % ? ^ | *").split(' ');
  3829. // IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
  3830. // Also, you must update possitionable operators separately from punct
  3831. var punct =
  3832. ">>>= " +
  3833. "... >>= <<= === >>> !== **= " +
  3834. "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
  3835. "= ! ? > < : / ^ - + * & % ~ |";
  3836. punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
  3837. punct = punct.replace(/ /g, '|');
  3838. var punct_pattern = new RegExp(punct);
  3839. // words which should always start on new line.
  3840. var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
  3841. var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']);
  3842. var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
  3843. // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
  3844. var in_html_comment;
  3845. var Tokenizer$1 = function(input_string, options) {
  3846. BaseTokenizer.call(this, input_string, options);
  3847. this._patterns.whitespace = this._patterns.whitespace.matching(
  3848. /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
  3849. /\u2028\u2029/.source);
  3850. var pattern_reader = new Pattern$3(this._input);
  3851. var templatable = new TemplatablePattern$1(this._input)
  3852. .read_options(this._options);
  3853. this.__patterns = {
  3854. template: templatable,
  3855. identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
  3856. number: pattern_reader.matching(number_pattern),
  3857. punct: pattern_reader.matching(punct_pattern),
  3858. // comment ends just before nearest linefeed or end of file
  3859. comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
  3860. // /* ... */ comment ends with nearest */ or end of file
  3861. block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
  3862. html_comment_start: pattern_reader.matching(/<!--/),
  3863. html_comment_end: pattern_reader.matching(/-->/),
  3864. include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
  3865. shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
  3866. 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*>/),
  3867. single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
  3868. double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
  3869. template_text: templatable.until(/[`\\$]/),
  3870. template_expression: templatable.until(/[`}\\]/)
  3871. };
  3872. };
  3873. Tokenizer$1.prototype = new BaseTokenizer();
  3874. Tokenizer$1.prototype._is_comment = function(current_token) {
  3875. return current_token.type === TOKEN$1.COMMENT || current_token.type === TOKEN$1.BLOCK_COMMENT || current_token.type === TOKEN$1.UNKNOWN;
  3876. };
  3877. Tokenizer$1.prototype._is_opening = function(current_token) {
  3878. return current_token.type === TOKEN$1.START_BLOCK || current_token.type === TOKEN$1.START_EXPR;
  3879. };
  3880. Tokenizer$1.prototype._is_closing = function(current_token, open_token) {
  3881. return (current_token.type === TOKEN$1.END_BLOCK || current_token.type === TOKEN$1.END_EXPR) &&
  3882. (open_token && (
  3883. (current_token.text === ']' && open_token.text === '[') ||
  3884. (current_token.text === ')' && open_token.text === '(') ||
  3885. (current_token.text === '}' && open_token.text === '{')));
  3886. };
  3887. Tokenizer$1.prototype._reset = function() {
  3888. in_html_comment = false;
  3889. };
  3890. Tokenizer$1.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  3891. var token = null;
  3892. this._readWhitespace();
  3893. var c = this._input.peek();
  3894. if (c === null) {
  3895. return this._create_token(TOKEN$1.EOF, '');
  3896. }
  3897. token = token || this._read_string(c);
  3898. token = token || this._read_word(previous_token);
  3899. token = token || this._read_singles(c);
  3900. token = token || this._read_comment(c);
  3901. token = token || this._read_regexp(c, previous_token);
  3902. token = token || this._read_xml(c, previous_token);
  3903. token = token || this._read_non_javascript(c);
  3904. token = token || this._read_punctuation();
  3905. token = token || this._create_token(TOKEN$1.UNKNOWN, this._input.next());
  3906. return token;
  3907. };
  3908. Tokenizer$1.prototype._read_word = function(previous_token) {
  3909. var resulting_string;
  3910. resulting_string = this.__patterns.identifier.read();
  3911. if (resulting_string !== '') {
  3912. resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
  3913. if (!(previous_token.type === TOKEN$1.DOT ||
  3914. (previous_token.type === TOKEN$1.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
  3915. reserved_word_pattern.test(resulting_string)) {
  3916. if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators
  3917. return this._create_token(TOKEN$1.OPERATOR, resulting_string);
  3918. }
  3919. return this._create_token(TOKEN$1.RESERVED, resulting_string);
  3920. }
  3921. return this._create_token(TOKEN$1.WORD, resulting_string);
  3922. }
  3923. resulting_string = this.__patterns.number.read();
  3924. if (resulting_string !== '') {
  3925. return this._create_token(TOKEN$1.WORD, resulting_string);
  3926. }
  3927. };
  3928. Tokenizer$1.prototype._read_singles = function(c) {
  3929. var token = null;
  3930. if (c === '(' || c === '[') {
  3931. token = this._create_token(TOKEN$1.START_EXPR, c);
  3932. } else if (c === ')' || c === ']') {
  3933. token = this._create_token(TOKEN$1.END_EXPR, c);
  3934. } else if (c === '{') {
  3935. token = this._create_token(TOKEN$1.START_BLOCK, c);
  3936. } else if (c === '}') {
  3937. token = this._create_token(TOKEN$1.END_BLOCK, c);
  3938. } else if (c === ';') {
  3939. token = this._create_token(TOKEN$1.SEMICOLON, c);
  3940. } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
  3941. token = this._create_token(TOKEN$1.DOT, c);
  3942. } else if (c === ',') {
  3943. token = this._create_token(TOKEN$1.COMMA, c);
  3944. }
  3945. if (token) {
  3946. this._input.next();
  3947. }
  3948. return token;
  3949. };
  3950. Tokenizer$1.prototype._read_punctuation = function() {
  3951. var resulting_string = this.__patterns.punct.read();
  3952. if (resulting_string !== '') {
  3953. if (resulting_string === '=') {
  3954. return this._create_token(TOKEN$1.EQUALS, resulting_string);
  3955. } else {
  3956. return this._create_token(TOKEN$1.OPERATOR, resulting_string);
  3957. }
  3958. }
  3959. };
  3960. Tokenizer$1.prototype._read_non_javascript = function(c) {
  3961. var resulting_string = '';
  3962. if (c === '#') {
  3963. if (this._is_first_token()) {
  3964. resulting_string = this.__patterns.shebang.read();
  3965. if (resulting_string) {
  3966. return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
  3967. }
  3968. }
  3969. // handles extendscript #includes
  3970. resulting_string = this.__patterns.include.read();
  3971. if (resulting_string) {
  3972. return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
  3973. }
  3974. c = this._input.next();
  3975. // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
  3976. var sharp = '#';
  3977. if (this._input.hasNext() && this._input.testChar(digit)) {
  3978. do {
  3979. c = this._input.next();
  3980. sharp += c;
  3981. } while (this._input.hasNext() && c !== '#' && c !== '=');
  3982. if (c === '#') ; else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
  3983. sharp += '[]';
  3984. this._input.next();
  3985. this._input.next();
  3986. } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
  3987. sharp += '{}';
  3988. this._input.next();
  3989. this._input.next();
  3990. }
  3991. return this._create_token(TOKEN$1.WORD, sharp);
  3992. }
  3993. this._input.back();
  3994. } else if (c === '<' && this._is_first_token()) {
  3995. resulting_string = this.__patterns.html_comment_start.read();
  3996. if (resulting_string) {
  3997. while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
  3998. resulting_string += this._input.next();
  3999. }
  4000. in_html_comment = true;
  4001. return this._create_token(TOKEN$1.COMMENT, resulting_string);
  4002. }
  4003. } else if (in_html_comment && c === '-') {
  4004. resulting_string = this.__patterns.html_comment_end.read();
  4005. if (resulting_string) {
  4006. in_html_comment = false;
  4007. return this._create_token(TOKEN$1.COMMENT, resulting_string);
  4008. }
  4009. }
  4010. return null;
  4011. };
  4012. Tokenizer$1.prototype._read_comment = function(c) {
  4013. var token = null;
  4014. if (c === '/') {
  4015. var comment = '';
  4016. if (this._input.peek(1) === '*') {
  4017. // peek for comment /* ... */
  4018. comment = this.__patterns.block_comment.read();
  4019. var directives = directives_core.get_directives(comment);
  4020. if (directives && directives.ignore === 'start') {
  4021. comment += directives_core.readIgnored(this._input);
  4022. }
  4023. comment = comment.replace(acorn.allLineBreaks, '\n');
  4024. token = this._create_token(TOKEN$1.BLOCK_COMMENT, comment);
  4025. token.directives = directives;
  4026. } else if (this._input.peek(1) === '/') {
  4027. // peek for comment // ...
  4028. comment = this.__patterns.comment.read();
  4029. token = this._create_token(TOKEN$1.COMMENT, comment);
  4030. }
  4031. }
  4032. return token;
  4033. };
  4034. Tokenizer$1.prototype._read_string = function(c) {
  4035. if (c === '`' || c === "'" || c === '"') {
  4036. var resulting_string = this._input.next();
  4037. this.has_char_escapes = false;
  4038. if (c === '`') {
  4039. resulting_string += this._read_string_recursive('`', true, '${');
  4040. } else {
  4041. resulting_string += this._read_string_recursive(c);
  4042. }
  4043. if (this.has_char_escapes && this._options.unescape_strings) {
  4044. resulting_string = unescape_string(resulting_string);
  4045. }
  4046. if (this._input.peek() === c) {
  4047. resulting_string += this._input.next();
  4048. }
  4049. resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
  4050. return this._create_token(TOKEN$1.STRING, resulting_string);
  4051. }
  4052. return null;
  4053. };
  4054. Tokenizer$1.prototype._allow_regexp_or_xml = function(previous_token) {
  4055. // regex and xml can only appear in specific locations during parsing
  4056. return (previous_token.type === TOKEN$1.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
  4057. (previous_token.type === TOKEN$1.END_EXPR && previous_token.text === ')' &&
  4058. previous_token.opened.previous.type === TOKEN$1.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
  4059. (in_array(previous_token.type, [TOKEN$1.COMMENT, TOKEN$1.START_EXPR, TOKEN$1.START_BLOCK, TOKEN$1.START,
  4060. TOKEN$1.END_BLOCK, TOKEN$1.OPERATOR, TOKEN$1.EQUALS, TOKEN$1.EOF, TOKEN$1.SEMICOLON, TOKEN$1.COMMA
  4061. ]));
  4062. };
  4063. Tokenizer$1.prototype._read_regexp = function(c, previous_token) {
  4064. if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
  4065. // handle regexp
  4066. //
  4067. var resulting_string = this._input.next();
  4068. var esc = false;
  4069. var in_char_class = false;
  4070. while (this._input.hasNext() &&
  4071. ((esc || in_char_class || this._input.peek() !== c) &&
  4072. !this._input.testChar(acorn.newline))) {
  4073. resulting_string += this._input.peek();
  4074. if (!esc) {
  4075. esc = this._input.peek() === '\\';
  4076. if (this._input.peek() === '[') {
  4077. in_char_class = true;
  4078. } else if (this._input.peek() === ']') {
  4079. in_char_class = false;
  4080. }
  4081. } else {
  4082. esc = false;
  4083. }
  4084. this._input.next();
  4085. }
  4086. if (this._input.peek() === c) {
  4087. resulting_string += this._input.next();
  4088. // regexps may have modifiers /regexp/MOD , so fetch those, too
  4089. // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
  4090. resulting_string += this._input.read(acorn.identifier);
  4091. }
  4092. return this._create_token(TOKEN$1.STRING, resulting_string);
  4093. }
  4094. return null;
  4095. };
  4096. Tokenizer$1.prototype._read_xml = function(c, previous_token) {
  4097. if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
  4098. var xmlStr = '';
  4099. var match = this.__patterns.xml.read_match();
  4100. // handle e4x xml literals
  4101. //
  4102. if (match) {
  4103. // Trim root tag to attempt to
  4104. var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
  4105. var isCurlyRoot = rootTag.indexOf('{') === 0;
  4106. var depth = 0;
  4107. while (match) {
  4108. var isEndTag = !!match[1];
  4109. var tagName = match[2];
  4110. var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
  4111. if (!isSingletonTag &&
  4112. (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
  4113. if (isEndTag) {
  4114. --depth;
  4115. } else {
  4116. ++depth;
  4117. }
  4118. }
  4119. xmlStr += match[0];
  4120. if (depth <= 0) {
  4121. break;
  4122. }
  4123. match = this.__patterns.xml.read_match();
  4124. }
  4125. // if we didn't close correctly, keep unformatted.
  4126. if (!match) {
  4127. xmlStr += this._input.match(/[\s\S]*/g)[0];
  4128. }
  4129. xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
  4130. return this._create_token(TOKEN$1.STRING, xmlStr);
  4131. }
  4132. }
  4133. return null;
  4134. };
  4135. function unescape_string(s) {
  4136. // You think that a regex would work for this
  4137. // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
  4138. // return String.fromCharCode(parseInt(val, 16));
  4139. // })
  4140. // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
  4141. var out = '',
  4142. escaped = 0;
  4143. var input_scan = new InputScanner$2(s);
  4144. var matched = null;
  4145. while (input_scan.hasNext()) {
  4146. // Keep any whitespace, non-slash characters
  4147. // also keep slash pairs.
  4148. matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
  4149. if (matched) {
  4150. out += matched[0];
  4151. }
  4152. if (input_scan.peek() === '\\') {
  4153. input_scan.next();
  4154. if (input_scan.peek() === 'x') {
  4155. matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
  4156. } else if (input_scan.peek() === 'u') {
  4157. matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
  4158. } else {
  4159. out += '\\';
  4160. if (input_scan.hasNext()) {
  4161. out += input_scan.next();
  4162. }
  4163. continue;
  4164. }
  4165. // If there's some error decoding, return the original string
  4166. if (!matched) {
  4167. return s;
  4168. }
  4169. escaped = parseInt(matched[1], 16);
  4170. if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
  4171. // we bail out on \x7f..\xff,
  4172. // leaving whole string escaped,
  4173. // as it's probably completely binary
  4174. return s;
  4175. } else if (escaped >= 0x00 && escaped < 0x20) {
  4176. // leave 0x00...0x1f escaped
  4177. out += '\\' + matched[0];
  4178. continue;
  4179. } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
  4180. // single-quote, apostrophe, backslash - escape these
  4181. out += '\\' + String.fromCharCode(escaped);
  4182. } else {
  4183. out += String.fromCharCode(escaped);
  4184. }
  4185. }
  4186. }
  4187. return out;
  4188. }
  4189. // handle string
  4190. //
  4191. Tokenizer$1.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
  4192. var current_char;
  4193. var pattern;
  4194. if (delimiter === '\'') {
  4195. pattern = this.__patterns.single_quote;
  4196. } else if (delimiter === '"') {
  4197. pattern = this.__patterns.double_quote;
  4198. } else if (delimiter === '`') {
  4199. pattern = this.__patterns.template_text;
  4200. } else if (delimiter === '}') {
  4201. pattern = this.__patterns.template_expression;
  4202. }
  4203. var resulting_string = pattern.read();
  4204. var next = '';
  4205. while (this._input.hasNext()) {
  4206. next = this._input.next();
  4207. if (next === delimiter ||
  4208. (!allow_unescaped_newlines && acorn.newline.test(next))) {
  4209. this._input.back();
  4210. break;
  4211. } else if (next === '\\' && this._input.hasNext()) {
  4212. current_char = this._input.peek();
  4213. if (current_char === 'x' || current_char === 'u') {
  4214. this.has_char_escapes = true;
  4215. } else if (current_char === '\r' && this._input.peek(1) === '\n') {
  4216. this._input.next();
  4217. }
  4218. next += this._input.next();
  4219. } else if (start_sub) {
  4220. if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
  4221. next += this._input.next();
  4222. }
  4223. if (start_sub === next) {
  4224. if (delimiter === '`') {
  4225. next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
  4226. } else {
  4227. next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
  4228. }
  4229. if (this._input.hasNext()) {
  4230. next += this._input.next();
  4231. }
  4232. }
  4233. }
  4234. next += pattern.read();
  4235. resulting_string += next;
  4236. }
  4237. return resulting_string;
  4238. };
  4239. var Tokenizer_1$1 = Tokenizer$1;
  4240. var TOKEN_1$1 = TOKEN$1;
  4241. var positionable_operators_1 = positionable_operators.slice();
  4242. var line_starters_1 = line_starters.slice();
  4243. var tokenizer$1 = {
  4244. Tokenizer: Tokenizer_1$1,
  4245. TOKEN: TOKEN_1$1,
  4246. positionable_operators: positionable_operators_1,
  4247. line_starters: line_starters_1
  4248. };
  4249. var Output$1 = output.Output;
  4250. var Token$2 = token.Token;
  4251. var Options$2 = options$1.Options;
  4252. var Tokenizer$2 = tokenizer$1.Tokenizer;
  4253. var line_starters$1 = tokenizer$1.line_starters;
  4254. var positionable_operators$1 = tokenizer$1.positionable_operators;
  4255. var TOKEN$2 = tokenizer$1.TOKEN;
  4256. function in_array$1(what, arr) {
  4257. return arr.indexOf(what) !== -1;
  4258. }
  4259. function ltrim(s) {
  4260. return s.replace(/^\s+/g, '');
  4261. }
  4262. function generateMapFromStrings(list) {
  4263. var result = {};
  4264. for (var x = 0; x < list.length; x++) {
  4265. // make the mapped names underscored instead of dash
  4266. result[list[x].replace(/-/g, '_')] = list[x];
  4267. }
  4268. return result;
  4269. }
  4270. function reserved_word(token, word) {
  4271. return token && token.type === TOKEN$2.RESERVED && token.text === word;
  4272. }
  4273. function reserved_array(token, words) {
  4274. return token && token.type === TOKEN$2.RESERVED && in_array$1(token.text, words);
  4275. }
  4276. // Unsure of what they mean, but they work. Worth cleaning up in future.
  4277. var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
  4278. var validPositionValues$1 = ['before-newline', 'after-newline', 'preserve-newline'];
  4279. // Generate map from array
  4280. var OPERATOR_POSITION = generateMapFromStrings(validPositionValues$1);
  4281. var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
  4282. var MODE = {
  4283. BlockStatement: 'BlockStatement', // 'BLOCK'
  4284. Statement: 'Statement', // 'STATEMENT'
  4285. ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
  4286. ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
  4287. ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
  4288. Conditional: 'Conditional', //'(COND-EXPRESSION)',
  4289. Expression: 'Expression' //'(EXPRESSION)'
  4290. };
  4291. function remove_redundant_indentation(output, frame) {
  4292. // This implementation is effective but has some issues:
  4293. // - can cause line wrap to happen too soon due to indent removal
  4294. // after wrap points are calculated
  4295. // These issues are minor compared to ugly indentation.
  4296. if (frame.multiline_frame ||
  4297. frame.mode === MODE.ForInitializer ||
  4298. frame.mode === MODE.Conditional) {
  4299. return;
  4300. }
  4301. // remove one indent from each line inside this section
  4302. output.remove_indent(frame.start_line_index);
  4303. }
  4304. // we could use just string.split, but
  4305. // IE doesn't like returning empty strings
  4306. function split_linebreaks(s) {
  4307. //return s.split(/\x0d\x0a|\x0a/);
  4308. s = s.replace(acorn.allLineBreaks, '\n');
  4309. var out = [],
  4310. idx = s.indexOf("\n");
  4311. while (idx !== -1) {
  4312. out.push(s.substring(0, idx));
  4313. s = s.substring(idx + 1);
  4314. idx = s.indexOf("\n");
  4315. }
  4316. if (s.length) {
  4317. out.push(s);
  4318. }
  4319. return out;
  4320. }
  4321. function is_array(mode) {
  4322. return mode === MODE.ArrayLiteral;
  4323. }
  4324. function is_expression(mode) {
  4325. return in_array$1(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
  4326. }
  4327. function all_lines_start_with(lines, c) {
  4328. for (var i = 0; i < lines.length; i++) {
  4329. var line = lines[i].trim();
  4330. if (line.charAt(0) !== c) {
  4331. return false;
  4332. }
  4333. }
  4334. return true;
  4335. }
  4336. function each_line_matches_indent(lines, indent) {
  4337. var i = 0,
  4338. len = lines.length,
  4339. line;
  4340. for (; i < len; i++) {
  4341. line = lines[i];
  4342. // allow empty lines to pass through
  4343. if (line && line.indexOf(indent) !== 0) {
  4344. return false;
  4345. }
  4346. }
  4347. return true;
  4348. }
  4349. function Beautifier(source_text, options) {
  4350. options = options || {};
  4351. this._source_text = source_text || '';
  4352. this._output = null;
  4353. this._tokens = null;
  4354. this._last_last_text = null;
  4355. this._flags = null;
  4356. this._previous_flags = null;
  4357. this._flag_store = null;
  4358. this._options = new Options$2(options);
  4359. }
  4360. Beautifier.prototype.create_flags = function(flags_base, mode) {
  4361. var next_indent_level = 0;
  4362. if (flags_base) {
  4363. next_indent_level = flags_base.indentation_level;
  4364. if (!this._output.just_added_newline() &&
  4365. flags_base.line_indent_level > next_indent_level) {
  4366. next_indent_level = flags_base.line_indent_level;
  4367. }
  4368. }
  4369. var next_flags = {
  4370. mode: mode,
  4371. parent: flags_base,
  4372. last_token: flags_base ? flags_base.last_token : new Token$2(TOKEN$2.START_BLOCK, ''), // last token text
  4373. last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
  4374. declaration_statement: false,
  4375. declaration_assignment: false,
  4376. multiline_frame: false,
  4377. inline_frame: false,
  4378. if_block: false,
  4379. else_block: false,
  4380. do_block: false,
  4381. do_while: false,
  4382. import_block: false,
  4383. in_case_statement: false, // switch(..){ INSIDE HERE }
  4384. in_case: false, // we're on the exact line with "case 0:"
  4385. case_body: false, // the indented case-action block
  4386. indentation_level: next_indent_level,
  4387. alignment: 0,
  4388. line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
  4389. start_line_index: this._output.get_line_number(),
  4390. ternary_depth: 0
  4391. };
  4392. return next_flags;
  4393. };
  4394. Beautifier.prototype._reset = function(source_text) {
  4395. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  4396. this._last_last_text = ''; // pre-last token text
  4397. this._output = new Output$1(this._options, baseIndentString);
  4398. // If testing the ignore directive, start with output disable set to true
  4399. this._output.raw = this._options.test_output_raw;
  4400. // Stack of parsing/formatting states, including MODE.
  4401. // We tokenize, parse, and output in an almost purely a forward-only stream of token input
  4402. // and formatted output. This makes the beautifier less accurate than full parsers
  4403. // but also far more tolerant of syntax errors.
  4404. //
  4405. // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
  4406. // MODE.BlockStatement on the the stack, even though it could be object literal. If we later
  4407. // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
  4408. // most full parsers would die, but the beautifier gracefully falls back to
  4409. // MODE.BlockStatement and continues on.
  4410. this._flag_store = [];
  4411. this.set_mode(MODE.BlockStatement);
  4412. var tokenizer = new Tokenizer$2(source_text, this._options);
  4413. this._tokens = tokenizer.tokenize();
  4414. return source_text;
  4415. };
  4416. Beautifier.prototype.beautify = function() {
  4417. // if disabled, return the input unchanged.
  4418. if (this._options.disabled) {
  4419. return this._source_text;
  4420. }
  4421. var sweet_code;
  4422. var source_text = this._reset(this._source_text);
  4423. var eol = this._options.eol;
  4424. if (this._options.eol === 'auto') {
  4425. eol = '\n';
  4426. if (source_text && acorn.lineBreak.test(source_text || '')) {
  4427. eol = source_text.match(acorn.lineBreak)[0];
  4428. }
  4429. }
  4430. var current_token = this._tokens.next();
  4431. while (current_token) {
  4432. this.handle_token(current_token);
  4433. this._last_last_text = this._flags.last_token.text;
  4434. this._flags.last_token = current_token;
  4435. current_token = this._tokens.next();
  4436. }
  4437. sweet_code = this._output.get_code(eol);
  4438. return sweet_code;
  4439. };
  4440. Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
  4441. if (current_token.type === TOKEN$2.START_EXPR) {
  4442. this.handle_start_expr(current_token);
  4443. } else if (current_token.type === TOKEN$2.END_EXPR) {
  4444. this.handle_end_expr(current_token);
  4445. } else if (current_token.type === TOKEN$2.START_BLOCK) {
  4446. this.handle_start_block(current_token);
  4447. } else if (current_token.type === TOKEN$2.END_BLOCK) {
  4448. this.handle_end_block(current_token);
  4449. } else if (current_token.type === TOKEN$2.WORD) {
  4450. this.handle_word(current_token);
  4451. } else if (current_token.type === TOKEN$2.RESERVED) {
  4452. this.handle_word(current_token);
  4453. } else if (current_token.type === TOKEN$2.SEMICOLON) {
  4454. this.handle_semicolon(current_token);
  4455. } else if (current_token.type === TOKEN$2.STRING) {
  4456. this.handle_string(current_token);
  4457. } else if (current_token.type === TOKEN$2.EQUALS) {
  4458. this.handle_equals(current_token);
  4459. } else if (current_token.type === TOKEN$2.OPERATOR) {
  4460. this.handle_operator(current_token);
  4461. } else if (current_token.type === TOKEN$2.COMMA) {
  4462. this.handle_comma(current_token);
  4463. } else if (current_token.type === TOKEN$2.BLOCK_COMMENT) {
  4464. this.handle_block_comment(current_token, preserve_statement_flags);
  4465. } else if (current_token.type === TOKEN$2.COMMENT) {
  4466. this.handle_comment(current_token, preserve_statement_flags);
  4467. } else if (current_token.type === TOKEN$2.DOT) {
  4468. this.handle_dot(current_token);
  4469. } else if (current_token.type === TOKEN$2.EOF) {
  4470. this.handle_eof(current_token);
  4471. } else if (current_token.type === TOKEN$2.UNKNOWN) {
  4472. this.handle_unknown(current_token, preserve_statement_flags);
  4473. } else {
  4474. this.handle_unknown(current_token, preserve_statement_flags);
  4475. }
  4476. };
  4477. Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
  4478. var newlines = current_token.newlines;
  4479. var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
  4480. if (current_token.comments_before) {
  4481. var comment_token = current_token.comments_before.next();
  4482. while (comment_token) {
  4483. // The cleanest handling of inline comments is to treat them as though they aren't there.
  4484. // Just continue formatting and the behavior should be logical.
  4485. // Also ignore unknown tokens. Again, this should result in better behavior.
  4486. this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
  4487. this.handle_token(comment_token, preserve_statement_flags);
  4488. comment_token = current_token.comments_before.next();
  4489. }
  4490. }
  4491. if (keep_whitespace) {
  4492. for (var i = 0; i < newlines; i += 1) {
  4493. this.print_newline(i > 0, preserve_statement_flags);
  4494. }
  4495. } else {
  4496. if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
  4497. newlines = this._options.max_preserve_newlines;
  4498. }
  4499. if (this._options.preserve_newlines) {
  4500. if (newlines > 1) {
  4501. this.print_newline(false, preserve_statement_flags);
  4502. for (var j = 1; j < newlines; j += 1) {
  4503. this.print_newline(true, preserve_statement_flags);
  4504. }
  4505. }
  4506. }
  4507. }
  4508. };
  4509. var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
  4510. Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
  4511. force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
  4512. // Never wrap the first token on a line
  4513. if (this._output.just_added_newline()) {
  4514. return;
  4515. }
  4516. var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
  4517. var operatorLogicApplies = in_array$1(this._flags.last_token.text, positionable_operators$1) ||
  4518. in_array$1(current_token.text, positionable_operators$1);
  4519. if (operatorLogicApplies) {
  4520. var shouldPrintOperatorNewline = (
  4521. in_array$1(this._flags.last_token.text, positionable_operators$1) &&
  4522. in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
  4523. ) ||
  4524. in_array$1(current_token.text, positionable_operators$1);
  4525. shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
  4526. }
  4527. if (shouldPreserveOrForce) {
  4528. this.print_newline(false, true);
  4529. } else if (this._options.wrap_line_length) {
  4530. if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
  4531. // These tokens should never have a newline inserted
  4532. // between them and the following expression.
  4533. return;
  4534. }
  4535. this._output.set_wrap_point();
  4536. }
  4537. };
  4538. Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
  4539. if (!preserve_statement_flags) {
  4540. 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 === '++')) {
  4541. var next_token = this._tokens.peek();
  4542. while (this._flags.mode === MODE.Statement &&
  4543. !(this._flags.if_block && reserved_word(next_token, 'else')) &&
  4544. !this._flags.do_block) {
  4545. this.restore_mode();
  4546. }
  4547. }
  4548. }
  4549. if (this._output.add_new_line(force_newline)) {
  4550. this._flags.multiline_frame = true;
  4551. }
  4552. };
  4553. Beautifier.prototype.print_token_line_indentation = function(current_token) {
  4554. if (this._output.just_added_newline()) {
  4555. if (this._options.keep_array_indentation &&
  4556. current_token.newlines &&
  4557. (current_token.text === '[' || is_array(this._flags.mode))) {
  4558. this._output.current_line.set_indent(-1);
  4559. this._output.current_line.push(current_token.whitespace_before);
  4560. this._output.space_before_token = false;
  4561. } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
  4562. this._flags.line_indent_level = this._flags.indentation_level;
  4563. }
  4564. }
  4565. };
  4566. Beautifier.prototype.print_token = function(current_token) {
  4567. if (this._output.raw) {
  4568. this._output.add_raw_token(current_token);
  4569. return;
  4570. }
  4571. if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN$2.COMMA &&
  4572. this._output.just_added_newline()) {
  4573. if (this._output.previous_line.last() === ',') {
  4574. var popped = this._output.previous_line.pop();
  4575. // if the comma was already at the start of the line,
  4576. // pull back onto that line and reprint the indentation
  4577. if (this._output.previous_line.is_empty()) {
  4578. this._output.previous_line.push(popped);
  4579. this._output.trim(true);
  4580. this._output.current_line.pop();
  4581. this._output.trim();
  4582. }
  4583. // add the comma in front of the next token
  4584. this.print_token_line_indentation(current_token);
  4585. this._output.add_token(',');
  4586. this._output.space_before_token = true;
  4587. }
  4588. }
  4589. this.print_token_line_indentation(current_token);
  4590. this._output.non_breaking_space = true;
  4591. this._output.add_token(current_token.text);
  4592. if (this._output.previous_token_wrapped) {
  4593. this._flags.multiline_frame = true;
  4594. }
  4595. };
  4596. Beautifier.prototype.indent = function() {
  4597. this._flags.indentation_level += 1;
  4598. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4599. };
  4600. Beautifier.prototype.deindent = function() {
  4601. if (this._flags.indentation_level > 0 &&
  4602. ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
  4603. this._flags.indentation_level -= 1;
  4604. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4605. }
  4606. };
  4607. Beautifier.prototype.set_mode = function(mode) {
  4608. if (this._flags) {
  4609. this._flag_store.push(this._flags);
  4610. this._previous_flags = this._flags;
  4611. } else {
  4612. this._previous_flags = this.create_flags(null, mode);
  4613. }
  4614. this._flags = this.create_flags(this._previous_flags, mode);
  4615. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4616. };
  4617. Beautifier.prototype.restore_mode = function() {
  4618. if (this._flag_store.length > 0) {
  4619. this._previous_flags = this._flags;
  4620. this._flags = this._flag_store.pop();
  4621. if (this._previous_flags.mode === MODE.Statement) {
  4622. remove_redundant_indentation(this._output, this._previous_flags);
  4623. }
  4624. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4625. }
  4626. };
  4627. Beautifier.prototype.start_of_object_property = function() {
  4628. return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
  4629. (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
  4630. };
  4631. Beautifier.prototype.start_of_statement = function(current_token) {
  4632. var start = false;
  4633. start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD;
  4634. start = start || reserved_word(this._flags.last_token, 'do');
  4635. 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;
  4636. start = start || reserved_word(this._flags.last_token, 'else') &&
  4637. !(reserved_word(current_token, 'if') && !current_token.comments_before);
  4638. start = start || (this._flags.last_token.type === TOKEN$2.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
  4639. start = start || (this._flags.last_token.type === TOKEN$2.WORD && this._flags.mode === MODE.BlockStatement &&
  4640. !this._flags.in_case &&
  4641. !(current_token.text === '--' || current_token.text === '++') &&
  4642. this._last_last_text !== 'function' &&
  4643. current_token.type !== TOKEN$2.WORD && current_token.type !== TOKEN$2.RESERVED);
  4644. start = start || (this._flags.mode === MODE.ObjectLiteral && (
  4645. (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
  4646. if (start) {
  4647. this.set_mode(MODE.Statement);
  4648. this.indent();
  4649. this.handle_whitespace_and_comments(current_token, true);
  4650. // Issue #276:
  4651. // If starting a new statement with [if, for, while, do], push to a new line.
  4652. // if (a) if (b) if(c) d(); else e(); else f();
  4653. if (!this.start_of_object_property()) {
  4654. this.allow_wrap_or_preserved_newline(current_token,
  4655. reserved_array(current_token, ['do', 'for', 'if', 'while']));
  4656. }
  4657. return true;
  4658. }
  4659. return false;
  4660. };
  4661. Beautifier.prototype.handle_start_expr = function(current_token) {
  4662. // The conditional starts the statement if appropriate.
  4663. if (!this.start_of_statement(current_token)) {
  4664. this.handle_whitespace_and_comments(current_token);
  4665. }
  4666. var next_mode = MODE.Expression;
  4667. if (current_token.text === '[') {
  4668. if (this._flags.last_token.type === TOKEN$2.WORD || this._flags.last_token.text === ')') {
  4669. // this is array index specifier, break immediately
  4670. // a[x], fn()[x]
  4671. if (reserved_array(this._flags.last_token, line_starters$1)) {
  4672. this._output.space_before_token = true;
  4673. }
  4674. this.print_token(current_token);
  4675. this.set_mode(next_mode);
  4676. this.indent();
  4677. if (this._options.space_in_paren) {
  4678. this._output.space_before_token = true;
  4679. }
  4680. return;
  4681. }
  4682. next_mode = MODE.ArrayLiteral;
  4683. if (is_array(this._flags.mode)) {
  4684. if (this._flags.last_token.text === '[' ||
  4685. (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
  4686. // ], [ goes to new line
  4687. // }, [ goes to new line
  4688. if (!this._options.keep_array_indentation) {
  4689. this.print_newline();
  4690. }
  4691. }
  4692. }
  4693. if (!in_array$1(this._flags.last_token.type, [TOKEN$2.START_EXPR, TOKEN$2.END_EXPR, TOKEN$2.WORD, TOKEN$2.OPERATOR])) {
  4694. this._output.space_before_token = true;
  4695. }
  4696. } else {
  4697. if (this._flags.last_token.type === TOKEN$2.RESERVED) {
  4698. if (this._flags.last_token.text === 'for') {
  4699. this._output.space_before_token = this._options.space_before_conditional;
  4700. next_mode = MODE.ForInitializer;
  4701. } else if (in_array$1(this._flags.last_token.text, ['if', 'while'])) {
  4702. this._output.space_before_token = this._options.space_before_conditional;
  4703. next_mode = MODE.Conditional;
  4704. } else if (in_array$1(this._flags.last_word, ['await', 'async'])) {
  4705. // Should be a space between await and an IIFE, or async and an arrow function
  4706. this._output.space_before_token = true;
  4707. } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
  4708. this._output.space_before_token = false;
  4709. } else if (in_array$1(this._flags.last_token.text, line_starters$1) || this._flags.last_token.text === 'catch') {
  4710. this._output.space_before_token = true;
  4711. }
  4712. } else if (this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
  4713. // Support of this kind of newline preservation.
  4714. // a = (b &&
  4715. // (c || d));
  4716. if (!this.start_of_object_property()) {
  4717. this.allow_wrap_or_preserved_newline(current_token);
  4718. }
  4719. } else if (this._flags.last_token.type === TOKEN$2.WORD) {
  4720. this._output.space_before_token = false;
  4721. // function name() vs function name ()
  4722. // function* name() vs function* name ()
  4723. // async name() vs async name ()
  4724. // In ES6, you can also define the method properties of an object
  4725. // var obj = {a: function() {}}
  4726. // It can be abbreviated
  4727. // var obj = {a() {}}
  4728. // var obj = { a() {}} vs var obj = { a () {}}
  4729. // var obj = { * a() {}} vs var obj = { * a () {}}
  4730. var peek_back_two = this._tokens.peek(-3);
  4731. if (this._options.space_after_named_function && peek_back_two) {
  4732. // peek starts at next character so -1 is current token
  4733. var peek_back_three = this._tokens.peek(-4);
  4734. if (reserved_array(peek_back_two, ['async', 'function']) ||
  4735. (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
  4736. this._output.space_before_token = true;
  4737. } else if (this._flags.mode === MODE.ObjectLiteral) {
  4738. if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
  4739. (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
  4740. this._output.space_before_token = true;
  4741. }
  4742. }
  4743. }
  4744. } else {
  4745. // Support preserving wrapped arrow function expressions
  4746. // a.b('c',
  4747. // () => d.e
  4748. // )
  4749. this.allow_wrap_or_preserved_newline(current_token);
  4750. }
  4751. // function() vs function ()
  4752. // yield*() vs yield* ()
  4753. // function*() vs function* ()
  4754. if ((this._flags.last_token.type === TOKEN$2.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
  4755. (this._flags.last_token.text === '*' &&
  4756. (in_array$1(this._last_last_text, ['function', 'yield']) ||
  4757. (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
  4758. this._output.space_before_token = this._options.space_after_anon_function;
  4759. }
  4760. }
  4761. if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN$2.START_BLOCK) {
  4762. this.print_newline();
  4763. } 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) {
  4764. // do nothing on (( and )( and ][ and ]( and .(
  4765. // TODO: Consider whether forcing this is required. Review failing tests when removed.
  4766. this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
  4767. }
  4768. this.print_token(current_token);
  4769. this.set_mode(next_mode);
  4770. if (this._options.space_in_paren) {
  4771. this._output.space_before_token = true;
  4772. }
  4773. // In all cases, if we newline while inside an expression it should be indented.
  4774. this.indent();
  4775. };
  4776. Beautifier.prototype.handle_end_expr = function(current_token) {
  4777. // statements inside expressions are not valid syntax, but...
  4778. // statements must all be closed when their container closes
  4779. while (this._flags.mode === MODE.Statement) {
  4780. this.restore_mode();
  4781. }
  4782. this.handle_whitespace_and_comments(current_token);
  4783. if (this._flags.multiline_frame) {
  4784. this.allow_wrap_or_preserved_newline(current_token,
  4785. current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
  4786. }
  4787. if (this._options.space_in_paren) {
  4788. if (this._flags.last_token.type === TOKEN$2.START_EXPR && !this._options.space_in_empty_paren) {
  4789. // () [] no inner space in empty parens like these, ever, ref #320
  4790. this._output.trim();
  4791. this._output.space_before_token = false;
  4792. } else {
  4793. this._output.space_before_token = true;
  4794. }
  4795. }
  4796. this.deindent();
  4797. this.print_token(current_token);
  4798. this.restore_mode();
  4799. remove_redundant_indentation(this._output, this._previous_flags);
  4800. // do {} while () // no statement required after
  4801. if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
  4802. this._previous_flags.mode = MODE.Expression;
  4803. this._flags.do_block = false;
  4804. this._flags.do_while = false;
  4805. }
  4806. };
  4807. Beautifier.prototype.handle_start_block = function(current_token) {
  4808. this.handle_whitespace_and_comments(current_token);
  4809. // Check if this is should be treated as a ObjectLiteral
  4810. var next_token = this._tokens.peek();
  4811. var second_token = this._tokens.peek(1);
  4812. if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN$2.END_EXPR) {
  4813. this.set_mode(MODE.BlockStatement);
  4814. this._flags.in_case_statement = true;
  4815. } else if (this._flags.case_body) {
  4816. this.set_mode(MODE.BlockStatement);
  4817. } else if (second_token && (
  4818. (in_array$1(second_token.text, [':', ',']) && in_array$1(next_token.type, [TOKEN$2.STRING, TOKEN$2.WORD, TOKEN$2.RESERVED])) ||
  4819. (in_array$1(next_token.text, ['get', 'set', '...']) && in_array$1(second_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]))
  4820. )) {
  4821. // We don't support TypeScript,but we didn't break it for a very long time.
  4822. // We'll try to keep not breaking it.
  4823. if (!in_array$1(this._last_last_text, ['class', 'interface'])) {
  4824. this.set_mode(MODE.ObjectLiteral);
  4825. } else {
  4826. this.set_mode(MODE.BlockStatement);
  4827. }
  4828. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR && this._flags.last_token.text === '=>') {
  4829. // arrow function: (param1, paramN) => { statements }
  4830. this.set_mode(MODE.BlockStatement);
  4831. } else if (in_array$1(this._flags.last_token.type, [TOKEN$2.EQUALS, TOKEN$2.START_EXPR, TOKEN$2.COMMA, TOKEN$2.OPERATOR]) ||
  4832. reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
  4833. ) {
  4834. // Detecting shorthand function syntax is difficult by scanning forward,
  4835. // so check the surrounding context.
  4836. // If the block is being returned, imported, export default, passed as arg,
  4837. // assigned with = or assigned in a nested object, treat as an ObjectLiteral.
  4838. this.set_mode(MODE.ObjectLiteral);
  4839. } else {
  4840. this.set_mode(MODE.BlockStatement);
  4841. }
  4842. var empty_braces = !next_token.comments_before && next_token.text === '}';
  4843. var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
  4844. this._flags.last_token.type === TOKEN$2.END_EXPR;
  4845. if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
  4846. {
  4847. // search forward for a newline wanted inside this block
  4848. var index = 0;
  4849. var check_token = null;
  4850. this._flags.inline_frame = true;
  4851. do {
  4852. index += 1;
  4853. check_token = this._tokens.peek(index - 1);
  4854. if (check_token.newlines) {
  4855. this._flags.inline_frame = false;
  4856. break;
  4857. }
  4858. } while (check_token.type !== TOKEN$2.EOF &&
  4859. !(check_token.type === TOKEN$2.END_BLOCK && check_token.opened === current_token));
  4860. }
  4861. if ((this._options.brace_style === "expand" ||
  4862. (this._options.brace_style === "none" && current_token.newlines)) &&
  4863. !this._flags.inline_frame) {
  4864. if (this._flags.last_token.type !== TOKEN$2.OPERATOR &&
  4865. (empty_anonymous_function ||
  4866. this._flags.last_token.type === TOKEN$2.EQUALS ||
  4867. (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
  4868. this._output.space_before_token = true;
  4869. } else {
  4870. this.print_newline(false, true);
  4871. }
  4872. } else { // collapse || inline_frame
  4873. if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.COMMA)) {
  4874. if (this._flags.last_token.type === TOKEN$2.COMMA || this._options.space_in_paren) {
  4875. this._output.space_before_token = true;
  4876. }
  4877. if (this._flags.last_token.type === TOKEN$2.COMMA || (this._flags.last_token.type === TOKEN$2.START_EXPR && this._flags.inline_frame)) {
  4878. this.allow_wrap_or_preserved_newline(current_token);
  4879. this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
  4880. this._flags.multiline_frame = false;
  4881. }
  4882. }
  4883. if (this._flags.last_token.type !== TOKEN$2.OPERATOR && this._flags.last_token.type !== TOKEN$2.START_EXPR) {
  4884. if (this._flags.last_token.type === TOKEN$2.START_BLOCK && !this._flags.inline_frame) {
  4885. this.print_newline();
  4886. } else {
  4887. this._output.space_before_token = true;
  4888. }
  4889. }
  4890. }
  4891. this.print_token(current_token);
  4892. this.indent();
  4893. // Except for specific cases, open braces are followed by a new line.
  4894. if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
  4895. this.print_newline();
  4896. }
  4897. };
  4898. Beautifier.prototype.handle_end_block = function(current_token) {
  4899. // statements must all be closed when their container closes
  4900. this.handle_whitespace_and_comments(current_token);
  4901. while (this._flags.mode === MODE.Statement) {
  4902. this.restore_mode();
  4903. }
  4904. var empty_braces = this._flags.last_token.type === TOKEN$2.START_BLOCK;
  4905. if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
  4906. this._output.space_before_token = true;
  4907. } else if (this._options.brace_style === "expand") {
  4908. if (!empty_braces) {
  4909. this.print_newline();
  4910. }
  4911. } else {
  4912. // skip {}
  4913. if (!empty_braces) {
  4914. if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
  4915. // we REALLY need a newline here, but newliner would skip that
  4916. this._options.keep_array_indentation = false;
  4917. this.print_newline();
  4918. this._options.keep_array_indentation = true;
  4919. } else {
  4920. this.print_newline();
  4921. }
  4922. }
  4923. }
  4924. this.restore_mode();
  4925. this.print_token(current_token);
  4926. };
  4927. Beautifier.prototype.handle_word = function(current_token) {
  4928. if (current_token.type === TOKEN$2.RESERVED) {
  4929. if (in_array$1(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
  4930. current_token.type = TOKEN$2.WORD;
  4931. } else if (current_token.text === 'import' && this._tokens.peek().text === '(') {
  4932. current_token.type = TOKEN$2.WORD;
  4933. } else if (in_array$1(current_token.text, ['as', 'from']) && !this._flags.import_block) {
  4934. current_token.type = TOKEN$2.WORD;
  4935. } else if (this._flags.mode === MODE.ObjectLiteral) {
  4936. var next_token = this._tokens.peek();
  4937. if (next_token.text === ':') {
  4938. current_token.type = TOKEN$2.WORD;
  4939. }
  4940. }
  4941. }
  4942. if (this.start_of_statement(current_token)) {
  4943. // The conditional starts the statement if appropriate.
  4944. if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD) {
  4945. this._flags.declaration_statement = true;
  4946. }
  4947. } else if (current_token.newlines && !is_expression(this._flags.mode) &&
  4948. (this._flags.last_token.type !== TOKEN$2.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
  4949. this._flags.last_token.type !== TOKEN$2.EQUALS &&
  4950. (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
  4951. this.handle_whitespace_and_comments(current_token);
  4952. this.print_newline();
  4953. } else {
  4954. this.handle_whitespace_and_comments(current_token);
  4955. }
  4956. if (this._flags.do_block && !this._flags.do_while) {
  4957. if (reserved_word(current_token, 'while')) {
  4958. // do {} ## while ()
  4959. this._output.space_before_token = true;
  4960. this.print_token(current_token);
  4961. this._output.space_before_token = true;
  4962. this._flags.do_while = true;
  4963. return;
  4964. } else {
  4965. // do {} should always have while as the next word.
  4966. // if we don't see the expected while, recover
  4967. this.print_newline();
  4968. this._flags.do_block = false;
  4969. }
  4970. }
  4971. // if may be followed by else, or not
  4972. // Bare/inline ifs are tricky
  4973. // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
  4974. if (this._flags.if_block) {
  4975. if (!this._flags.else_block && reserved_word(current_token, 'else')) {
  4976. this._flags.else_block = true;
  4977. } else {
  4978. while (this._flags.mode === MODE.Statement) {
  4979. this.restore_mode();
  4980. }
  4981. this._flags.if_block = false;
  4982. this._flags.else_block = false;
  4983. }
  4984. }
  4985. if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
  4986. this.print_newline();
  4987. if (this._flags.last_token.type !== TOKEN$2.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) {
  4988. // switch cases following one another
  4989. this.deindent();
  4990. }
  4991. this._flags.case_body = false;
  4992. this.print_token(current_token);
  4993. this._flags.in_case = true;
  4994. return;
  4995. }
  4996. 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) {
  4997. if (!this.start_of_object_property()) {
  4998. this.allow_wrap_or_preserved_newline(current_token);
  4999. }
  5000. }
  5001. if (reserved_word(current_token, 'function')) {
  5002. if (in_array$1(this._flags.last_token.text, ['}', ';']) ||
  5003. (this._output.just_added_newline() && !(in_array$1(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN$2.OPERATOR))) {
  5004. // make sure there is a nice clean space of at least one blank line
  5005. // before a new function definition
  5006. if (!this._output.just_added_blankline() && !current_token.comments_before) {
  5007. this.print_newline();
  5008. this.print_newline(true);
  5009. }
  5010. }
  5011. if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD) {
  5012. if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
  5013. reserved_array(this._flags.last_token, newline_restricted_tokens)) {
  5014. this._output.space_before_token = true;
  5015. } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
  5016. this._output.space_before_token = true;
  5017. } else if (this._flags.last_token.text === 'declare') {
  5018. // accomodates Typescript declare function formatting
  5019. this._output.space_before_token = true;
  5020. } else {
  5021. this.print_newline();
  5022. }
  5023. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR || this._flags.last_token.text === '=') {
  5024. // foo = function
  5025. this._output.space_before_token = true;
  5026. } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
  5027. this.print_newline();
  5028. }
  5029. this.print_token(current_token);
  5030. this._flags.last_word = current_token.text;
  5031. return;
  5032. }
  5033. var prefix = 'NONE';
  5034. if (this._flags.last_token.type === TOKEN$2.END_BLOCK) {
  5035. if (this._previous_flags.inline_frame) {
  5036. prefix = 'SPACE';
  5037. } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
  5038. prefix = 'NEWLINE';
  5039. } else {
  5040. if (this._options.brace_style === "expand" ||
  5041. this._options.brace_style === "end-expand" ||
  5042. (this._options.brace_style === "none" && current_token.newlines)) {
  5043. prefix = 'NEWLINE';
  5044. } else {
  5045. prefix = 'SPACE';
  5046. this._output.space_before_token = true;
  5047. }
  5048. }
  5049. } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
  5050. // TODO: Should this be for STATEMENT as well?
  5051. prefix = 'NEWLINE';
  5052. } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && is_expression(this._flags.mode)) {
  5053. prefix = 'SPACE';
  5054. } else if (this._flags.last_token.type === TOKEN$2.STRING) {
  5055. prefix = 'NEWLINE';
  5056. } else if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD ||
  5057. (this._flags.last_token.text === '*' &&
  5058. (in_array$1(this._last_last_text, ['function', 'yield']) ||
  5059. (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
  5060. prefix = 'SPACE';
  5061. } else if (this._flags.last_token.type === TOKEN$2.START_BLOCK) {
  5062. if (this._flags.inline_frame) {
  5063. prefix = 'SPACE';
  5064. } else {
  5065. prefix = 'NEWLINE';
  5066. }
  5067. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
  5068. this._output.space_before_token = true;
  5069. prefix = 'NEWLINE';
  5070. }
  5071. if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
  5072. if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
  5073. prefix = 'SPACE';
  5074. } else {
  5075. prefix = 'NEWLINE';
  5076. }
  5077. }
  5078. if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
  5079. if ((!(this._flags.last_token.type === TOKEN$2.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
  5080. this._options.brace_style === "expand" ||
  5081. this._options.brace_style === "end-expand" ||
  5082. (this._options.brace_style === "none" && current_token.newlines)) &&
  5083. !this._flags.inline_frame) {
  5084. this.print_newline();
  5085. } else {
  5086. this._output.trim(true);
  5087. var line = this._output.current_line;
  5088. // If we trimmed and there's something other than a close block before us
  5089. // put a newline back in. Handles '} // comment' scenario.
  5090. if (line.last() !== '}') {
  5091. this.print_newline();
  5092. }
  5093. this._output.space_before_token = true;
  5094. }
  5095. } else if (prefix === 'NEWLINE') {
  5096. if (reserved_array(this._flags.last_token, special_words)) {
  5097. // no newline between 'return nnn'
  5098. this._output.space_before_token = true;
  5099. } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
  5100. // accomodates Typescript declare formatting
  5101. this._output.space_before_token = true;
  5102. } else if (this._flags.last_token.type !== TOKEN$2.END_EXPR) {
  5103. if ((this._flags.last_token.type !== TOKEN$2.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
  5104. // no need to force newline on 'var': for (var x = 0...)
  5105. if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
  5106. // no newline for } else if {
  5107. this._output.space_before_token = true;
  5108. } else {
  5109. this.print_newline();
  5110. }
  5111. }
  5112. } else if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
  5113. this.print_newline();
  5114. }
  5115. } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
  5116. this.print_newline(); // }, in lists get a newline treatment
  5117. } else if (prefix === 'SPACE') {
  5118. this._output.space_before_token = true;
  5119. }
  5120. if (current_token.previous && (current_token.previous.type === TOKEN$2.WORD || current_token.previous.type === TOKEN$2.RESERVED)) {
  5121. this._output.space_before_token = true;
  5122. }
  5123. this.print_token(current_token);
  5124. this._flags.last_word = current_token.text;
  5125. if (current_token.type === TOKEN$2.RESERVED) {
  5126. if (current_token.text === 'do') {
  5127. this._flags.do_block = true;
  5128. } else if (current_token.text === 'if') {
  5129. this._flags.if_block = true;
  5130. } else if (current_token.text === 'import') {
  5131. this._flags.import_block = true;
  5132. } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
  5133. this._flags.import_block = false;
  5134. }
  5135. }
  5136. };
  5137. Beautifier.prototype.handle_semicolon = function(current_token) {
  5138. if (this.start_of_statement(current_token)) {
  5139. // The conditional starts the statement if appropriate.
  5140. // Semicolon can be the start (and end) of a statement
  5141. this._output.space_before_token = false;
  5142. } else {
  5143. this.handle_whitespace_and_comments(current_token);
  5144. }
  5145. var next_token = this._tokens.peek();
  5146. while (this._flags.mode === MODE.Statement &&
  5147. !(this._flags.if_block && reserved_word(next_token, 'else')) &&
  5148. !this._flags.do_block) {
  5149. this.restore_mode();
  5150. }
  5151. // hacky but effective for the moment
  5152. if (this._flags.import_block) {
  5153. this._flags.import_block = false;
  5154. }
  5155. this.print_token(current_token);
  5156. };
  5157. Beautifier.prototype.handle_string = function(current_token) {
  5158. if (this.start_of_statement(current_token)) {
  5159. // The conditional starts the statement if appropriate.
  5160. // One difference - strings want at least a space before
  5161. this._output.space_before_token = true;
  5162. } else {
  5163. this.handle_whitespace_and_comments(current_token);
  5164. if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD || this._flags.inline_frame) {
  5165. this._output.space_before_token = true;
  5166. } 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) {
  5167. if (!this.start_of_object_property()) {
  5168. this.allow_wrap_or_preserved_newline(current_token);
  5169. }
  5170. } else {
  5171. this.print_newline();
  5172. }
  5173. }
  5174. this.print_token(current_token);
  5175. };
  5176. Beautifier.prototype.handle_equals = function(current_token) {
  5177. if (this.start_of_statement(current_token)) ; else {
  5178. this.handle_whitespace_and_comments(current_token);
  5179. }
  5180. if (this._flags.declaration_statement) {
  5181. // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
  5182. this._flags.declaration_assignment = true;
  5183. }
  5184. this._output.space_before_token = true;
  5185. this.print_token(current_token);
  5186. this._output.space_before_token = true;
  5187. };
  5188. Beautifier.prototype.handle_comma = function(current_token) {
  5189. this.handle_whitespace_and_comments(current_token, true);
  5190. this.print_token(current_token);
  5191. this._output.space_before_token = true;
  5192. if (this._flags.declaration_statement) {
  5193. if (is_expression(this._flags.parent.mode)) {
  5194. // do not break on comma, for(var a = 1, b = 2)
  5195. this._flags.declaration_assignment = false;
  5196. }
  5197. if (this._flags.declaration_assignment) {
  5198. this._flags.declaration_assignment = false;
  5199. this.print_newline(false, true);
  5200. } else if (this._options.comma_first) {
  5201. // for comma-first, we want to allow a newline before the comma
  5202. // to turn into a newline after the comma, which we will fixup later
  5203. this.allow_wrap_or_preserved_newline(current_token);
  5204. }
  5205. } else if (this._flags.mode === MODE.ObjectLiteral ||
  5206. (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
  5207. if (this._flags.mode === MODE.Statement) {
  5208. this.restore_mode();
  5209. }
  5210. if (!this._flags.inline_frame) {
  5211. this.print_newline();
  5212. }
  5213. } else if (this._options.comma_first) {
  5214. // EXPR or DO_BLOCK
  5215. // for comma-first, we want to allow a newline before the comma
  5216. // to turn into a newline after the comma, which we will fixup later
  5217. this.allow_wrap_or_preserved_newline(current_token);
  5218. }
  5219. };
  5220. Beautifier.prototype.handle_operator = function(current_token) {
  5221. var isGeneratorAsterisk = current_token.text === '*' &&
  5222. (reserved_array(this._flags.last_token, ['function', 'yield']) ||
  5223. (in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.COMMA, TOKEN$2.END_BLOCK, TOKEN$2.SEMICOLON]))
  5224. );
  5225. var isUnary = in_array$1(current_token.text, ['-', '+']) && (
  5226. in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.START_EXPR, TOKEN$2.EQUALS, TOKEN$2.OPERATOR]) ||
  5227. in_array$1(this._flags.last_token.text, line_starters$1) ||
  5228. this._flags.last_token.text === ','
  5229. );
  5230. if (this.start_of_statement(current_token)) ; else {
  5231. var preserve_statement_flags = !isGeneratorAsterisk;
  5232. this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
  5233. }
  5234. if (reserved_array(this._flags.last_token, special_words)) {
  5235. // "return" had a special handling in TK_WORD. Now we need to return the favor
  5236. this._output.space_before_token = true;
  5237. this.print_token(current_token);
  5238. return;
  5239. }
  5240. // hack for actionscript's import .*;
  5241. if (current_token.text === '*' && this._flags.last_token.type === TOKEN$2.DOT) {
  5242. this.print_token(current_token);
  5243. return;
  5244. }
  5245. if (current_token.text === '::') {
  5246. // no spaces around exotic namespacing syntax operator
  5247. this.print_token(current_token);
  5248. return;
  5249. }
  5250. // Allow line wrapping between operators when operator_position is
  5251. // set to before or preserve
  5252. if (this._flags.last_token.type === TOKEN$2.OPERATOR && in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
  5253. this.allow_wrap_or_preserved_newline(current_token);
  5254. }
  5255. if (current_token.text === ':' && this._flags.in_case) {
  5256. this.print_token(current_token);
  5257. this._flags.in_case = false;
  5258. this._flags.case_body = true;
  5259. if (this._tokens.peek().type !== TOKEN$2.START_BLOCK) {
  5260. this.indent();
  5261. this.print_newline();
  5262. } else {
  5263. this._output.space_before_token = true;
  5264. }
  5265. return;
  5266. }
  5267. var space_before = true;
  5268. var space_after = true;
  5269. var in_ternary = false;
  5270. if (current_token.text === ':') {
  5271. if (this._flags.ternary_depth === 0) {
  5272. // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
  5273. space_before = false;
  5274. } else {
  5275. this._flags.ternary_depth -= 1;
  5276. in_ternary = true;
  5277. }
  5278. } else if (current_token.text === '?') {
  5279. this._flags.ternary_depth += 1;
  5280. }
  5281. // let's handle the operator_position option prior to any conflicting logic
  5282. if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array$1(current_token.text, positionable_operators$1)) {
  5283. var isColon = current_token.text === ':';
  5284. var isTernaryColon = (isColon && in_ternary);
  5285. var isOtherColon = (isColon && !in_ternary);
  5286. switch (this._options.operator_position) {
  5287. case OPERATOR_POSITION.before_newline:
  5288. // if the current token is : and it's not a ternary statement then we set space_before to false
  5289. this._output.space_before_token = !isOtherColon;
  5290. this.print_token(current_token);
  5291. if (!isColon || isTernaryColon) {
  5292. this.allow_wrap_or_preserved_newline(current_token);
  5293. }
  5294. this._output.space_before_token = true;
  5295. return;
  5296. case OPERATOR_POSITION.after_newline:
  5297. // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
  5298. // then print a newline.
  5299. this._output.space_before_token = true;
  5300. if (!isColon || isTernaryColon) {
  5301. if (this._tokens.peek().newlines) {
  5302. this.print_newline(false, true);
  5303. } else {
  5304. this.allow_wrap_or_preserved_newline(current_token);
  5305. }
  5306. } else {
  5307. this._output.space_before_token = false;
  5308. }
  5309. this.print_token(current_token);
  5310. this._output.space_before_token = true;
  5311. return;
  5312. case OPERATOR_POSITION.preserve_newline:
  5313. if (!isOtherColon) {
  5314. this.allow_wrap_or_preserved_newline(current_token);
  5315. }
  5316. // if we just added a newline, or the current token is : and it's not a ternary statement,
  5317. // then we set space_before to false
  5318. space_before = !(this._output.just_added_newline() || isOtherColon);
  5319. this._output.space_before_token = space_before;
  5320. this.print_token(current_token);
  5321. this._output.space_before_token = true;
  5322. return;
  5323. }
  5324. }
  5325. if (isGeneratorAsterisk) {
  5326. this.allow_wrap_or_preserved_newline(current_token);
  5327. space_before = false;
  5328. var next_token = this._tokens.peek();
  5329. space_after = next_token && in_array$1(next_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]);
  5330. } else if (current_token.text === '...') {
  5331. this.allow_wrap_or_preserved_newline(current_token);
  5332. space_before = this._flags.last_token.type === TOKEN$2.START_BLOCK;
  5333. space_after = false;
  5334. } else if (in_array$1(current_token.text, ['--', '++', '!', '~']) || isUnary) {
  5335. // unary operators (and binary +/- pretending to be unary) special cases
  5336. if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR) {
  5337. this.allow_wrap_or_preserved_newline(current_token);
  5338. }
  5339. space_before = false;
  5340. space_after = false;
  5341. // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
  5342. // if there is a newline between -- or ++ and anything else we should preserve it.
  5343. if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
  5344. this.print_newline(false, true);
  5345. }
  5346. if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
  5347. // for (;; ++i)
  5348. // ^^^
  5349. space_before = true;
  5350. }
  5351. if (this._flags.last_token.type === TOKEN$2.RESERVED) {
  5352. space_before = true;
  5353. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
  5354. space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
  5355. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR) {
  5356. // a++ + ++b;
  5357. // a - -b
  5358. space_before = in_array$1(current_token.text, ['--', '-', '++', '+']) && in_array$1(this._flags.last_token.text, ['--', '-', '++', '+']);
  5359. // + and - are not unary when preceeded by -- or ++ operator
  5360. // a-- + b
  5361. // a * +b
  5362. // a - -b
  5363. if (in_array$1(current_token.text, ['+', '-']) && in_array$1(this._flags.last_token.text, ['--', '++'])) {
  5364. space_after = true;
  5365. }
  5366. }
  5367. if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
  5368. (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
  5369. // { foo; --i }
  5370. // foo(); --bar;
  5371. this.print_newline();
  5372. }
  5373. }
  5374. this._output.space_before_token = this._output.space_before_token || space_before;
  5375. this.print_token(current_token);
  5376. this._output.space_before_token = space_after;
  5377. };
  5378. Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
  5379. if (this._output.raw) {
  5380. this._output.add_raw_token(current_token);
  5381. if (current_token.directives && current_token.directives.preserve === 'end') {
  5382. // If we're testing the raw output behavior, do not allow a directive to turn it off.
  5383. this._output.raw = this._options.test_output_raw;
  5384. }
  5385. return;
  5386. }
  5387. if (current_token.directives) {
  5388. this.print_newline(false, preserve_statement_flags);
  5389. this.print_token(current_token);
  5390. if (current_token.directives.preserve === 'start') {
  5391. this._output.raw = true;
  5392. }
  5393. this.print_newline(false, true);
  5394. return;
  5395. }
  5396. // inline block
  5397. if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
  5398. this._output.space_before_token = true;
  5399. this.print_token(current_token);
  5400. this._output.space_before_token = true;
  5401. return;
  5402. } else {
  5403. this.print_block_commment(current_token, preserve_statement_flags);
  5404. }
  5405. };
  5406. Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
  5407. var lines = split_linebreaks(current_token.text);
  5408. var j; // iterator for this case
  5409. var javadoc = false;
  5410. var starless = false;
  5411. var lastIndent = current_token.whitespace_before;
  5412. var lastIndentLength = lastIndent.length;
  5413. // block comment starts with a new line
  5414. this.print_newline(false, preserve_statement_flags);
  5415. // first line always indented
  5416. this.print_token_line_indentation(current_token);
  5417. this._output.add_token(lines[0]);
  5418. this.print_newline(false, preserve_statement_flags);
  5419. if (lines.length > 1) {
  5420. lines = lines.slice(1);
  5421. javadoc = all_lines_start_with(lines, '*');
  5422. starless = each_line_matches_indent(lines, lastIndent);
  5423. if (javadoc) {
  5424. this._flags.alignment = 1;
  5425. }
  5426. for (j = 0; j < lines.length; j++) {
  5427. if (javadoc) {
  5428. // javadoc: reformat and re-indent
  5429. this.print_token_line_indentation(current_token);
  5430. this._output.add_token(ltrim(lines[j]));
  5431. } else if (starless && lines[j]) {
  5432. // starless: re-indent non-empty content, avoiding trim
  5433. this.print_token_line_indentation(current_token);
  5434. this._output.add_token(lines[j].substring(lastIndentLength));
  5435. } else {
  5436. // normal comments output raw
  5437. this._output.current_line.set_indent(-1);
  5438. this._output.add_token(lines[j]);
  5439. }
  5440. // for comments on their own line or more than one line, make sure there's a new line after
  5441. this.print_newline(false, preserve_statement_flags);
  5442. }
  5443. this._flags.alignment = 0;
  5444. }
  5445. };
  5446. Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
  5447. if (current_token.newlines) {
  5448. this.print_newline(false, preserve_statement_flags);
  5449. } else {
  5450. this._output.trim(true);
  5451. }
  5452. this._output.space_before_token = true;
  5453. this.print_token(current_token);
  5454. this.print_newline(false, preserve_statement_flags);
  5455. };
  5456. Beautifier.prototype.handle_dot = function(current_token) {
  5457. if (this.start_of_statement(current_token)) ; else {
  5458. this.handle_whitespace_and_comments(current_token, true);
  5459. }
  5460. if (reserved_array(this._flags.last_token, special_words)) {
  5461. this._output.space_before_token = false;
  5462. } else {
  5463. // allow preserved newlines before dots in general
  5464. // force newlines on dots after close paren when break_chained - for bar().baz()
  5465. this.allow_wrap_or_preserved_newline(current_token,
  5466. this._flags.last_token.text === ')' && this._options.break_chained_methods);
  5467. }
  5468. // Only unindent chained method dot if this dot starts a new line.
  5469. // Otherwise the automatic extra indentation removal will handle the over indent
  5470. if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
  5471. this.deindent();
  5472. }
  5473. this.print_token(current_token);
  5474. };
  5475. Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
  5476. this.print_token(current_token);
  5477. if (current_token.text[current_token.text.length - 1] === '\n') {
  5478. this.print_newline(false, preserve_statement_flags);
  5479. }
  5480. };
  5481. Beautifier.prototype.handle_eof = function(current_token) {
  5482. // Unwind any open statements
  5483. while (this._flags.mode === MODE.Statement) {
  5484. this.restore_mode();
  5485. }
  5486. this.handle_whitespace_and_comments(current_token);
  5487. };
  5488. var Beautifier_1 = Beautifier;
  5489. var beautifier = {
  5490. Beautifier: Beautifier_1
  5491. };
  5492. var Beautifier$1 = beautifier.Beautifier,
  5493. Options$3 = options$1.Options;
  5494. function js_beautify(js_source_text, options) {
  5495. var beautifier = new Beautifier$1(js_source_text, options);
  5496. return beautifier.beautify();
  5497. }
  5498. var javascript = js_beautify;
  5499. var defaultOptions = function() {
  5500. return new Options$3();
  5501. };
  5502. javascript.defaultOptions = defaultOptions;
  5503. var BaseOptions$1 = options.Options;
  5504. function Options$4(options) {
  5505. BaseOptions$1.call(this, options, 'css');
  5506. this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
  5507. this.newline_between_rules = this._get_boolean('newline_between_rules', true);
  5508. var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
  5509. this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
  5510. }
  5511. Options$4.prototype = new BaseOptions$1();
  5512. var Options_1$2 = Options$4;
  5513. var options$2 = {
  5514. Options: Options_1$2
  5515. };
  5516. var Options$5 = options$2.Options;
  5517. var Output$2 = output.Output;
  5518. var InputScanner$3 = inputscanner.InputScanner;
  5519. var Directives$2 = directives.Directives;
  5520. var directives_core$1 = new Directives$2(/\/\*/, /\*\//);
  5521. var lineBreak = /\r\n|[\r\n]/;
  5522. var allLineBreaks = /\r\n|[\r\n]/g;
  5523. // tokenizer
  5524. var whitespaceChar = /\s/;
  5525. var whitespacePattern = /(?:\s|\n)+/g;
  5526. var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
  5527. var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
  5528. function Beautifier$2(source_text, options) {
  5529. this._source_text = source_text || '';
  5530. // Allow the setting of language/file-type specific options
  5531. // with inheritance of overall settings
  5532. this._options = new Options$5(options);
  5533. this._ch = null;
  5534. this._input = null;
  5535. // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
  5536. this.NESTED_AT_RULE = {
  5537. "@page": true,
  5538. "@font-face": true,
  5539. "@keyframes": true,
  5540. // also in CONDITIONAL_GROUP_RULE below
  5541. "@media": true,
  5542. "@supports": true,
  5543. "@document": true
  5544. };
  5545. this.CONDITIONAL_GROUP_RULE = {
  5546. "@media": true,
  5547. "@supports": true,
  5548. "@document": true
  5549. };
  5550. }
  5551. Beautifier$2.prototype.eatString = function(endChars) {
  5552. var result = '';
  5553. this._ch = this._input.next();
  5554. while (this._ch) {
  5555. result += this._ch;
  5556. if (this._ch === "\\") {
  5557. result += this._input.next();
  5558. } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
  5559. break;
  5560. }
  5561. this._ch = this._input.next();
  5562. }
  5563. return result;
  5564. };
  5565. // Skips any white space in the source text from the current position.
  5566. // When allowAtLeastOneNewLine is true, will output new lines for each
  5567. // newline character found; if the user has preserve_newlines off, only
  5568. // the first newline will be output
  5569. Beautifier$2.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
  5570. var result = whitespaceChar.test(this._input.peek());
  5571. var isFirstNewLine = true;
  5572. while (whitespaceChar.test(this._input.peek())) {
  5573. this._ch = this._input.next();
  5574. if (allowAtLeastOneNewLine && this._ch === '\n') {
  5575. if (this._options.preserve_newlines || isFirstNewLine) {
  5576. isFirstNewLine = false;
  5577. this._output.add_new_line(true);
  5578. }
  5579. }
  5580. }
  5581. return result;
  5582. };
  5583. // Nested pseudo-class if we are insideRule
  5584. // and the next special character found opens
  5585. // a new block
  5586. Beautifier$2.prototype.foundNestedPseudoClass = function() {
  5587. var openParen = 0;
  5588. var i = 1;
  5589. var ch = this._input.peek(i);
  5590. while (ch) {
  5591. if (ch === "{") {
  5592. return true;
  5593. } else if (ch === '(') {
  5594. // pseudoclasses can contain ()
  5595. openParen += 1;
  5596. } else if (ch === ')') {
  5597. if (openParen === 0) {
  5598. return false;
  5599. }
  5600. openParen -= 1;
  5601. } else if (ch === ";" || ch === "}") {
  5602. return false;
  5603. }
  5604. i++;
  5605. ch = this._input.peek(i);
  5606. }
  5607. return false;
  5608. };
  5609. Beautifier$2.prototype.print_string = function(output_string) {
  5610. this._output.set_indent(this._indentLevel);
  5611. this._output.non_breaking_space = true;
  5612. this._output.add_token(output_string);
  5613. };
  5614. Beautifier$2.prototype.preserveSingleSpace = function(isAfterSpace) {
  5615. if (isAfterSpace) {
  5616. this._output.space_before_token = true;
  5617. }
  5618. };
  5619. Beautifier$2.prototype.indent = function() {
  5620. this._indentLevel++;
  5621. };
  5622. Beautifier$2.prototype.outdent = function() {
  5623. if (this._indentLevel > 0) {
  5624. this._indentLevel--;
  5625. }
  5626. };
  5627. /*_____________________--------------------_____________________*/
  5628. Beautifier$2.prototype.beautify = function() {
  5629. if (this._options.disabled) {
  5630. return this._source_text;
  5631. }
  5632. var source_text = this._source_text;
  5633. var eol = this._options.eol;
  5634. if (eol === 'auto') {
  5635. eol = '\n';
  5636. if (source_text && lineBreak.test(source_text || '')) {
  5637. eol = source_text.match(lineBreak)[0];
  5638. }
  5639. }
  5640. // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
  5641. source_text = source_text.replace(allLineBreaks, '\n');
  5642. // reset
  5643. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  5644. this._output = new Output$2(this._options, baseIndentString);
  5645. this._input = new InputScanner$3(source_text);
  5646. this._indentLevel = 0;
  5647. this._nestedLevel = 0;
  5648. this._ch = null;
  5649. var parenLevel = 0;
  5650. var insideRule = false;
  5651. // This is the value side of a property value pair (blue in the following ex)
  5652. // label { content: blue }
  5653. var insidePropertyValue = false;
  5654. var enteringConditionalGroup = false;
  5655. var insideAtExtend = false;
  5656. var insideAtImport = false;
  5657. var topCharacter = this._ch;
  5658. var whitespace;
  5659. var isAfterSpace;
  5660. var previous_ch;
  5661. while (true) {
  5662. whitespace = this._input.read(whitespacePattern);
  5663. isAfterSpace = whitespace !== '';
  5664. previous_ch = topCharacter;
  5665. this._ch = this._input.next();
  5666. if (this._ch === '\\' && this._input.hasNext()) {
  5667. this._ch += this._input.next();
  5668. }
  5669. topCharacter = this._ch;
  5670. if (!this._ch) {
  5671. break;
  5672. } else if (this._ch === '/' && this._input.peek() === '*') {
  5673. // /* css comment */
  5674. // Always start block comments on a new line.
  5675. // This handles scenarios where a block comment immediately
  5676. // follows a property definition on the same line or where
  5677. // minified code is being beautified.
  5678. this._output.add_new_line();
  5679. this._input.back();
  5680. var comment = this._input.read(block_comment_pattern);
  5681. // Handle ignore directive
  5682. var directives = directives_core$1.get_directives(comment);
  5683. if (directives && directives.ignore === 'start') {
  5684. comment += directives_core$1.readIgnored(this._input);
  5685. }
  5686. this.print_string(comment);
  5687. // Ensures any new lines following the comment are preserved
  5688. this.eatWhitespace(true);
  5689. // Block comments are followed by a new line so they don't
  5690. // share a line with other properties
  5691. this._output.add_new_line();
  5692. } else if (this._ch === '/' && this._input.peek() === '/') {
  5693. // // single line comment
  5694. // Preserves the space before a comment
  5695. // on the same line as a rule
  5696. this._output.space_before_token = true;
  5697. this._input.back();
  5698. this.print_string(this._input.read(comment_pattern));
  5699. // Ensures any new lines following the comment are preserved
  5700. this.eatWhitespace(true);
  5701. } else if (this._ch === '@') {
  5702. this.preserveSingleSpace(isAfterSpace);
  5703. // deal with less propery mixins @{...}
  5704. if (this._input.peek() === '{') {
  5705. this.print_string(this._ch + this.eatString('}'));
  5706. } else {
  5707. this.print_string(this._ch);
  5708. // strip trailing space, if present, for hash property checks
  5709. var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
  5710. if (variableOrRule.match(/[ :]$/)) {
  5711. // we have a variable or pseudo-class, add it and insert one space before continuing
  5712. variableOrRule = this.eatString(": ").replace(/\s$/, '');
  5713. this.print_string(variableOrRule);
  5714. this._output.space_before_token = true;
  5715. }
  5716. variableOrRule = variableOrRule.replace(/\s$/, '');
  5717. if (variableOrRule === 'extend') {
  5718. insideAtExtend = true;
  5719. } else if (variableOrRule === 'import') {
  5720. insideAtImport = true;
  5721. }
  5722. // might be a nesting at-rule
  5723. if (variableOrRule in this.NESTED_AT_RULE) {
  5724. this._nestedLevel += 1;
  5725. if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
  5726. enteringConditionalGroup = true;
  5727. }
  5728. // might be less variable
  5729. } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
  5730. insidePropertyValue = true;
  5731. this.indent();
  5732. }
  5733. }
  5734. } else if (this._ch === '#' && this._input.peek() === '{') {
  5735. this.preserveSingleSpace(isAfterSpace);
  5736. this.print_string(this._ch + this.eatString('}'));
  5737. } else if (this._ch === '{') {
  5738. if (insidePropertyValue) {
  5739. insidePropertyValue = false;
  5740. this.outdent();
  5741. }
  5742. this.indent();
  5743. this._output.space_before_token = true;
  5744. this.print_string(this._ch);
  5745. // when entering conditional groups, only rulesets are allowed
  5746. if (enteringConditionalGroup) {
  5747. enteringConditionalGroup = false;
  5748. insideRule = (this._indentLevel > this._nestedLevel);
  5749. } else {
  5750. // otherwise, declarations are also allowed
  5751. insideRule = (this._indentLevel >= this._nestedLevel);
  5752. }
  5753. if (this._options.newline_between_rules && insideRule) {
  5754. if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
  5755. this._output.ensure_empty_line_above('/', ',');
  5756. }
  5757. }
  5758. this.eatWhitespace(true);
  5759. this._output.add_new_line();
  5760. } else if (this._ch === '}') {
  5761. this.outdent();
  5762. this._output.add_new_line();
  5763. if (previous_ch === '{') {
  5764. this._output.trim(true);
  5765. }
  5766. insideAtImport = false;
  5767. insideAtExtend = false;
  5768. if (insidePropertyValue) {
  5769. this.outdent();
  5770. insidePropertyValue = false;
  5771. }
  5772. this.print_string(this._ch);
  5773. insideRule = false;
  5774. if (this._nestedLevel) {
  5775. this._nestedLevel--;
  5776. }
  5777. this.eatWhitespace(true);
  5778. this._output.add_new_line();
  5779. if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
  5780. if (this._input.peek() !== '}') {
  5781. this._output.add_new_line(true);
  5782. }
  5783. }
  5784. } else if (this._ch === ":") {
  5785. if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
  5786. // 'property: value' delimiter
  5787. // which could be in a conditional group query
  5788. this.print_string(':');
  5789. if (!insidePropertyValue) {
  5790. insidePropertyValue = true;
  5791. this._output.space_before_token = true;
  5792. this.eatWhitespace(true);
  5793. this.indent();
  5794. }
  5795. } else {
  5796. // sass/less parent reference don't use a space
  5797. // sass nested pseudo-class don't use a space
  5798. // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
  5799. if (this._input.lookBack(" ")) {
  5800. this._output.space_before_token = true;
  5801. }
  5802. if (this._input.peek() === ":") {
  5803. // pseudo-element
  5804. this._ch = this._input.next();
  5805. this.print_string("::");
  5806. } else {
  5807. // pseudo-class
  5808. this.print_string(':');
  5809. }
  5810. }
  5811. } else if (this._ch === '"' || this._ch === '\'') {
  5812. this.preserveSingleSpace(isAfterSpace);
  5813. this.print_string(this._ch + this.eatString(this._ch));
  5814. this.eatWhitespace(true);
  5815. } else if (this._ch === ';') {
  5816. if (parenLevel === 0) {
  5817. if (insidePropertyValue) {
  5818. this.outdent();
  5819. insidePropertyValue = false;
  5820. }
  5821. insideAtExtend = false;
  5822. insideAtImport = false;
  5823. this.print_string(this._ch);
  5824. this.eatWhitespace(true);
  5825. // This maintains single line comments on the same
  5826. // line. Block comments are also affected, but
  5827. // a new line is always output before one inside
  5828. // that section
  5829. if (this._input.peek() !== '/') {
  5830. this._output.add_new_line();
  5831. }
  5832. } else {
  5833. this.print_string(this._ch);
  5834. this.eatWhitespace(true);
  5835. this._output.space_before_token = true;
  5836. }
  5837. } else if (this._ch === '(') { // may be a url
  5838. if (this._input.lookBack("url")) {
  5839. this.print_string(this._ch);
  5840. this.eatWhitespace();
  5841. parenLevel++;
  5842. this.indent();
  5843. this._ch = this._input.next();
  5844. if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
  5845. this._input.back();
  5846. } else if (this._ch) {
  5847. this.print_string(this._ch + this.eatString(')'));
  5848. if (parenLevel) {
  5849. parenLevel--;
  5850. this.outdent();
  5851. }
  5852. }
  5853. } else {
  5854. this.preserveSingleSpace(isAfterSpace);
  5855. this.print_string(this._ch);
  5856. this.eatWhitespace();
  5857. parenLevel++;
  5858. this.indent();
  5859. }
  5860. } else if (this._ch === ')') {
  5861. if (parenLevel) {
  5862. parenLevel--;
  5863. this.outdent();
  5864. }
  5865. this.print_string(this._ch);
  5866. } else if (this._ch === ',') {
  5867. this.print_string(this._ch);
  5868. this.eatWhitespace(true);
  5869. if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport) {
  5870. this._output.add_new_line();
  5871. } else {
  5872. this._output.space_before_token = true;
  5873. }
  5874. } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
  5875. //handle combinator spacing
  5876. if (this._options.space_around_combinator) {
  5877. this._output.space_before_token = true;
  5878. this.print_string(this._ch);
  5879. this._output.space_before_token = true;
  5880. } else {
  5881. this.print_string(this._ch);
  5882. this.eatWhitespace();
  5883. // squash extra whitespace
  5884. if (this._ch && whitespaceChar.test(this._ch)) {
  5885. this._ch = '';
  5886. }
  5887. }
  5888. } else if (this._ch === ']') {
  5889. this.print_string(this._ch);
  5890. } else if (this._ch === '[') {
  5891. this.preserveSingleSpace(isAfterSpace);
  5892. this.print_string(this._ch);
  5893. } else if (this._ch === '=') { // no whitespace before or after
  5894. this.eatWhitespace();
  5895. this.print_string('=');
  5896. if (whitespaceChar.test(this._ch)) {
  5897. this._ch = '';
  5898. }
  5899. } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
  5900. this.print_string(' ');
  5901. this.print_string(this._ch);
  5902. } else {
  5903. this.preserveSingleSpace(isAfterSpace);
  5904. this.print_string(this._ch);
  5905. }
  5906. }
  5907. var sweetCode = this._output.get_code(eol);
  5908. return sweetCode;
  5909. };
  5910. var Beautifier_1$1 = Beautifier$2;
  5911. var beautifier$1 = {
  5912. Beautifier: Beautifier_1$1
  5913. };
  5914. var Beautifier$3 = beautifier$1.Beautifier,
  5915. Options$6 = options$2.Options;
  5916. function css_beautify(source_text, options) {
  5917. var beautifier = new Beautifier$3(source_text, options);
  5918. return beautifier.beautify();
  5919. }
  5920. var css = css_beautify;
  5921. var defaultOptions$1 = function() {
  5922. return new Options$6();
  5923. };
  5924. css.defaultOptions = defaultOptions$1;
  5925. var BaseOptions$2 = options.Options;
  5926. function Options$7(options) {
  5927. BaseOptions$2.call(this, options, 'html');
  5928. if (this.templating.length === 1 && this.templating[0] === 'auto') {
  5929. this.templating = ['django', 'erb', 'handlebars', 'php'];
  5930. }
  5931. this.indent_inner_html = this._get_boolean('indent_inner_html');
  5932. this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
  5933. this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
  5934. this.indent_handlebars = this._get_boolean('indent_handlebars', true);
  5935. this.wrap_attributes = this._get_selection('wrap_attributes',
  5936. ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
  5937. this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
  5938. this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
  5939. // Block vs inline elements
  5940. // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
  5941. // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
  5942. // https://www.w3.org/TR/html5/dom.html#phrasing-content
  5943. this.inline = this._get_array('inline', [
  5944. 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
  5945. 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
  5946. 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
  5947. 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
  5948. 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
  5949. 'video', 'wbr', 'text',
  5950. // obsolete inline tags
  5951. 'acronym', 'big', 'strike', 'tt'
  5952. ]);
  5953. this.void_elements = this._get_array('void_elements', [
  5954. // HTLM void elements - aka self-closing tags - aka singletons
  5955. // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
  5956. 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
  5957. 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
  5958. // NOTE: Optional tags are too complex for a simple list
  5959. // they are hard coded in _do_optional_end_element
  5960. // Doctype and xml elements
  5961. '!doctype', '?xml',
  5962. // obsolete tags
  5963. // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
  5964. // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
  5965. 'basefont', 'isindex'
  5966. ]);
  5967. this.unformatted = this._get_array('unformatted', []);
  5968. this.content_unformatted = this._get_array('content_unformatted', [
  5969. 'pre', 'textarea'
  5970. ]);
  5971. this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
  5972. this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
  5973. }
  5974. Options$7.prototype = new BaseOptions$2();
  5975. var Options_1$3 = Options$7;
  5976. var options$3 = {
  5977. Options: Options_1$3
  5978. };
  5979. var BaseTokenizer$1 = tokenizer.Tokenizer;
  5980. var BASETOKEN$1 = tokenizer.TOKEN;
  5981. var Directives$3 = directives.Directives;
  5982. var TemplatablePattern$2 = templatablepattern.TemplatablePattern;
  5983. var Pattern$4 = pattern.Pattern;
  5984. var TOKEN$3 = {
  5985. TAG_OPEN: 'TK_TAG_OPEN',
  5986. TAG_CLOSE: 'TK_TAG_CLOSE',
  5987. ATTRIBUTE: 'TK_ATTRIBUTE',
  5988. EQUALS: 'TK_EQUALS',
  5989. VALUE: 'TK_VALUE',
  5990. COMMENT: 'TK_COMMENT',
  5991. TEXT: 'TK_TEXT',
  5992. UNKNOWN: 'TK_UNKNOWN',
  5993. START: BASETOKEN$1.START,
  5994. RAW: BASETOKEN$1.RAW,
  5995. EOF: BASETOKEN$1.EOF
  5996. };
  5997. var directives_core$2 = new Directives$3(/<\!--/, /-->/);
  5998. var Tokenizer$3 = function(input_string, options) {
  5999. BaseTokenizer$1.call(this, input_string, options);
  6000. this._current_tag_name = '';
  6001. // Words end at whitespace or when a tag starts
  6002. // if we are indenting handlebars, they are considered tags
  6003. var templatable_reader = new TemplatablePattern$2(this._input).read_options(this._options);
  6004. var pattern_reader = new Pattern$4(this._input);
  6005. this.__patterns = {
  6006. word: templatable_reader.until(/[\n\r\t <]/),
  6007. single_quote: templatable_reader.until_after(/'/),
  6008. double_quote: templatable_reader.until_after(/"/),
  6009. attribute: templatable_reader.until(/[\n\r\t =\/>]/),
  6010. element_name: templatable_reader.until(/[\n\r\t >\/]/),
  6011. handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
  6012. handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
  6013. handlebars_open: pattern_reader.until(/[\n\r\t }]/),
  6014. handlebars_raw_close: pattern_reader.until(/}}/),
  6015. comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
  6016. cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
  6017. // https://en.wikipedia.org/wiki/Conditional_comment
  6018. conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
  6019. processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
  6020. };
  6021. if (this._options.indent_handlebars) {
  6022. this.__patterns.word = this.__patterns.word.exclude('handlebars');
  6023. }
  6024. this._unformatted_content_delimiter = null;
  6025. if (this._options.unformatted_content_delimiter) {
  6026. var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
  6027. this.__patterns.unformatted_content_delimiter =
  6028. pattern_reader.matching(literal_regexp)
  6029. .until_after(literal_regexp);
  6030. }
  6031. };
  6032. Tokenizer$3.prototype = new BaseTokenizer$1();
  6033. Tokenizer$3.prototype._is_comment = function(current_token) { // jshint unused:false
  6034. return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
  6035. };
  6036. Tokenizer$3.prototype._is_opening = function(current_token) {
  6037. return current_token.type === TOKEN$3.TAG_OPEN;
  6038. };
  6039. Tokenizer$3.prototype._is_closing = function(current_token, open_token) {
  6040. return current_token.type === TOKEN$3.TAG_CLOSE &&
  6041. (open_token && (
  6042. ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
  6043. (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')));
  6044. };
  6045. Tokenizer$3.prototype._reset = function() {
  6046. this._current_tag_name = '';
  6047. };
  6048. Tokenizer$3.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  6049. var token = null;
  6050. this._readWhitespace();
  6051. var c = this._input.peek();
  6052. if (c === null) {
  6053. return this._create_token(TOKEN$3.EOF, '');
  6054. }
  6055. token = token || this._read_open_handlebars(c, open_token);
  6056. token = token || this._read_attribute(c, previous_token, open_token);
  6057. token = token || this._read_raw_content(c, previous_token, open_token);
  6058. token = token || this._read_close(c, open_token);
  6059. token = token || this._read_content_word(c);
  6060. token = token || this._read_comment(c);
  6061. token = token || this._read_open(c, open_token);
  6062. token = token || this._create_token(TOKEN$3.UNKNOWN, this._input.next());
  6063. return token;
  6064. };
  6065. Tokenizer$3.prototype._read_comment = function(c) { // jshint unused:false
  6066. var token = null;
  6067. var resulting_string = null;
  6068. var directives = null;
  6069. if (c === '<') {
  6070. var peek1 = this._input.peek(1);
  6071. //if we're in a comment, do something special
  6072. // We treat all comments as literals, even more than preformatted tags
  6073. // we just look for the appropriate close tag
  6074. if (c === '<' && (peek1 === '!' || peek1 === '?')) {
  6075. resulting_string = this.__patterns.comment.read();
  6076. // only process directive on html comments
  6077. if (resulting_string) {
  6078. directives = directives_core$2.get_directives(resulting_string);
  6079. if (directives && directives.ignore === 'start') {
  6080. resulting_string += directives_core$2.readIgnored(this._input);
  6081. }
  6082. } else {
  6083. resulting_string = this.__patterns.cdata.read();
  6084. resulting_string = resulting_string || this.__patterns.conditional_comment.read();
  6085. resulting_string = resulting_string || this.__patterns.processing.read();
  6086. }
  6087. }
  6088. if (resulting_string) {
  6089. token = this._create_token(TOKEN$3.COMMENT, resulting_string);
  6090. token.directives = directives;
  6091. }
  6092. }
  6093. return token;
  6094. };
  6095. Tokenizer$3.prototype._read_open = function(c, open_token) {
  6096. var resulting_string = null;
  6097. var token = null;
  6098. if (!open_token) {
  6099. if (c === '<') {
  6100. resulting_string = this._input.next();
  6101. if (this._input.peek() === '/') {
  6102. resulting_string += this._input.next();
  6103. }
  6104. resulting_string += this.__patterns.element_name.read();
  6105. token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
  6106. }
  6107. }
  6108. return token;
  6109. };
  6110. Tokenizer$3.prototype._read_open_handlebars = function(c, open_token) {
  6111. var resulting_string = null;
  6112. var token = null;
  6113. if (!open_token) {
  6114. if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
  6115. if (this._input.peek(2) === '!') {
  6116. resulting_string = this.__patterns.handlebars_comment.read();
  6117. resulting_string = resulting_string || this.__patterns.handlebars.read();
  6118. token = this._create_token(TOKEN$3.COMMENT, resulting_string);
  6119. } else {
  6120. resulting_string = this.__patterns.handlebars_open.read();
  6121. token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
  6122. }
  6123. }
  6124. }
  6125. return token;
  6126. };
  6127. Tokenizer$3.prototype._read_close = function(c, open_token) {
  6128. var resulting_string = null;
  6129. var token = null;
  6130. if (open_token) {
  6131. if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
  6132. resulting_string = this._input.next();
  6133. if (c === '/') { // for close tag "/>"
  6134. resulting_string += this._input.next();
  6135. }
  6136. token = this._create_token(TOKEN$3.TAG_CLOSE, resulting_string);
  6137. } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
  6138. this._input.next();
  6139. this._input.next();
  6140. token = this._create_token(TOKEN$3.TAG_CLOSE, '}}');
  6141. }
  6142. }
  6143. return token;
  6144. };
  6145. Tokenizer$3.prototype._read_attribute = function(c, previous_token, open_token) {
  6146. var token = null;
  6147. var resulting_string = '';
  6148. if (open_token && open_token.text[0] === '<') {
  6149. if (c === '=') {
  6150. token = this._create_token(TOKEN$3.EQUALS, this._input.next());
  6151. } else if (c === '"' || c === "'") {
  6152. var content = this._input.next();
  6153. if (c === '"') {
  6154. content += this.__patterns.double_quote.read();
  6155. } else {
  6156. content += this.__patterns.single_quote.read();
  6157. }
  6158. token = this._create_token(TOKEN$3.VALUE, content);
  6159. } else {
  6160. resulting_string = this.__patterns.attribute.read();
  6161. if (resulting_string) {
  6162. if (previous_token.type === TOKEN$3.EQUALS) {
  6163. token = this._create_token(TOKEN$3.VALUE, resulting_string);
  6164. } else {
  6165. token = this._create_token(TOKEN$3.ATTRIBUTE, resulting_string);
  6166. }
  6167. }
  6168. }
  6169. }
  6170. return token;
  6171. };
  6172. Tokenizer$3.prototype._is_content_unformatted = function(tag_name) {
  6173. // void_elements have no content and so cannot have unformatted content
  6174. // script and style tags should always be read as unformatted content
  6175. // finally content_unformatted and unformatted element contents are unformatted
  6176. return this._options.void_elements.indexOf(tag_name) === -1 &&
  6177. (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
  6178. this._options.unformatted.indexOf(tag_name) !== -1);
  6179. };
  6180. Tokenizer$3.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
  6181. var resulting_string = '';
  6182. if (open_token && open_token.text[0] === '{') {
  6183. resulting_string = this.__patterns.handlebars_raw_close.read();
  6184. } else if (previous_token.type === TOKEN$3.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
  6185. var tag_name = previous_token.opened.text.substr(1).toLowerCase();
  6186. if (tag_name === 'script' || tag_name === 'style') {
  6187. // Script and style tags are allowed to have comments wrapping their content
  6188. // or just have regular content.
  6189. var token = this._read_comment(c);
  6190. if (token) {
  6191. token.type = TOKEN$3.TEXT;
  6192. return token;
  6193. }
  6194. resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
  6195. } else if (this._is_content_unformatted(tag_name)) {
  6196. resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
  6197. }
  6198. }
  6199. if (resulting_string) {
  6200. return this._create_token(TOKEN$3.TEXT, resulting_string);
  6201. }
  6202. return null;
  6203. };
  6204. Tokenizer$3.prototype._read_content_word = function(c) {
  6205. var resulting_string = '';
  6206. if (this._options.unformatted_content_delimiter) {
  6207. if (c === this._options.unformatted_content_delimiter[0]) {
  6208. resulting_string = this.__patterns.unformatted_content_delimiter.read();
  6209. }
  6210. }
  6211. if (!resulting_string) {
  6212. resulting_string = this.__patterns.word.read();
  6213. }
  6214. if (resulting_string) {
  6215. return this._create_token(TOKEN$3.TEXT, resulting_string);
  6216. }
  6217. };
  6218. var Tokenizer_1$2 = Tokenizer$3;
  6219. var TOKEN_1$2 = TOKEN$3;
  6220. var tokenizer$2 = {
  6221. Tokenizer: Tokenizer_1$2,
  6222. TOKEN: TOKEN_1$2
  6223. };
  6224. var Options$8 = options$3.Options;
  6225. var Output$3 = output.Output;
  6226. var Tokenizer$4 = tokenizer$2.Tokenizer;
  6227. var TOKEN$4 = tokenizer$2.TOKEN;
  6228. var lineBreak$1 = /\r\n|[\r\n]/;
  6229. var allLineBreaks$1 = /\r\n|[\r\n]/g;
  6230. var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
  6231. this.indent_level = 0;
  6232. this.alignment_size = 0;
  6233. this.max_preserve_newlines = options.max_preserve_newlines;
  6234. this.preserve_newlines = options.preserve_newlines;
  6235. this._output = new Output$3(options, base_indent_string);
  6236. };
  6237. Printer.prototype.current_line_has_match = function(pattern) {
  6238. return this._output.current_line.has_match(pattern);
  6239. };
  6240. Printer.prototype.set_space_before_token = function(value, non_breaking) {
  6241. this._output.space_before_token = value;
  6242. this._output.non_breaking_space = non_breaking;
  6243. };
  6244. Printer.prototype.set_wrap_point = function() {
  6245. this._output.set_indent(this.indent_level, this.alignment_size);
  6246. this._output.set_wrap_point();
  6247. };
  6248. Printer.prototype.add_raw_token = function(token) {
  6249. this._output.add_raw_token(token);
  6250. };
  6251. Printer.prototype.print_preserved_newlines = function(raw_token) {
  6252. var newlines = 0;
  6253. if (raw_token.type !== TOKEN$4.TEXT && raw_token.previous.type !== TOKEN$4.TEXT) {
  6254. newlines = raw_token.newlines ? 1 : 0;
  6255. }
  6256. if (this.preserve_newlines) {
  6257. newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
  6258. }
  6259. for (var n = 0; n < newlines; n++) {
  6260. this.print_newline(n > 0);
  6261. }
  6262. return newlines !== 0;
  6263. };
  6264. Printer.prototype.traverse_whitespace = function(raw_token) {
  6265. if (raw_token.whitespace_before || raw_token.newlines) {
  6266. if (!this.print_preserved_newlines(raw_token)) {
  6267. this._output.space_before_token = true;
  6268. }
  6269. return true;
  6270. }
  6271. return false;
  6272. };
  6273. Printer.prototype.previous_token_wrapped = function() {
  6274. return this._output.previous_token_wrapped;
  6275. };
  6276. Printer.prototype.print_newline = function(force) {
  6277. this._output.add_new_line(force);
  6278. };
  6279. Printer.prototype.print_token = function(token) {
  6280. if (token.text) {
  6281. this._output.set_indent(this.indent_level, this.alignment_size);
  6282. this._output.add_token(token.text);
  6283. }
  6284. };
  6285. Printer.prototype.indent = function() {
  6286. this.indent_level++;
  6287. };
  6288. Printer.prototype.get_full_indent = function(level) {
  6289. level = this.indent_level + (level || 0);
  6290. if (level < 1) {
  6291. return '';
  6292. }
  6293. return this._output.get_indent_string(level);
  6294. };
  6295. var get_type_attribute = function(start_token) {
  6296. var result = null;
  6297. var raw_token = start_token.next;
  6298. // Search attributes for a type attribute
  6299. while (raw_token.type !== TOKEN$4.EOF && start_token.closed !== raw_token) {
  6300. if (raw_token.type === TOKEN$4.ATTRIBUTE && raw_token.text === 'type') {
  6301. if (raw_token.next && raw_token.next.type === TOKEN$4.EQUALS &&
  6302. raw_token.next.next && raw_token.next.next.type === TOKEN$4.VALUE) {
  6303. result = raw_token.next.next.text;
  6304. }
  6305. break;
  6306. }
  6307. raw_token = raw_token.next;
  6308. }
  6309. return result;
  6310. };
  6311. var get_custom_beautifier_name = function(tag_check, raw_token) {
  6312. var typeAttribute = null;
  6313. var result = null;
  6314. if (!raw_token.closed) {
  6315. return null;
  6316. }
  6317. if (tag_check === 'script') {
  6318. typeAttribute = 'text/javascript';
  6319. } else if (tag_check === 'style') {
  6320. typeAttribute = 'text/css';
  6321. }
  6322. typeAttribute = get_type_attribute(raw_token) || typeAttribute;
  6323. // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
  6324. // For those without a type attribute use default;
  6325. if (typeAttribute.search('text/css') > -1) {
  6326. result = 'css';
  6327. } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
  6328. result = 'javascript';
  6329. } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
  6330. result = 'html';
  6331. } else if (typeAttribute.search(/test\/null/) > -1) {
  6332. // Test only mime-type for testing the beautifier when null is passed as beautifing function
  6333. result = 'null';
  6334. }
  6335. return result;
  6336. };
  6337. function in_array$2(what, arr) {
  6338. return arr.indexOf(what) !== -1;
  6339. }
  6340. function TagFrame(parent, parser_token, indent_level) {
  6341. this.parent = parent || null;
  6342. this.tag = parser_token ? parser_token.tag_name : '';
  6343. this.indent_level = indent_level || 0;
  6344. this.parser_token = parser_token || null;
  6345. }
  6346. function TagStack(printer) {
  6347. this._printer = printer;
  6348. this._current_frame = null;
  6349. }
  6350. TagStack.prototype.get_parser_token = function() {
  6351. return this._current_frame ? this._current_frame.parser_token : null;
  6352. };
  6353. TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
  6354. var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
  6355. this._current_frame = new_frame;
  6356. };
  6357. TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
  6358. var parser_token = null;
  6359. if (frame) {
  6360. parser_token = frame.parser_token;
  6361. this._printer.indent_level = frame.indent_level;
  6362. this._current_frame = frame.parent;
  6363. }
  6364. return parser_token;
  6365. };
  6366. TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
  6367. var frame = this._current_frame;
  6368. while (frame) { //till we reach '' (the initial value);
  6369. if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
  6370. break;
  6371. } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
  6372. frame = null;
  6373. break;
  6374. }
  6375. frame = frame.parent;
  6376. }
  6377. return frame;
  6378. };
  6379. TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
  6380. var frame = this._get_frame([tag], stop_list);
  6381. return this._try_pop_frame(frame);
  6382. };
  6383. TagStack.prototype.indent_to_tag = function(tag_list) {
  6384. var frame = this._get_frame(tag_list);
  6385. if (frame) {
  6386. this._printer.indent_level = frame.indent_level;
  6387. }
  6388. };
  6389. function Beautifier$4(source_text, options, js_beautify, css_beautify) {
  6390. //Wrapper function to invoke all the necessary constructors and deal with the output.
  6391. this._source_text = source_text || '';
  6392. options = options || {};
  6393. this._js_beautify = js_beautify;
  6394. this._css_beautify = css_beautify;
  6395. this._tag_stack = null;
  6396. // Allow the setting of language/file-type specific options
  6397. // with inheritance of overall settings
  6398. var optionHtml = new Options$8(options, 'html');
  6399. this._options = optionHtml;
  6400. this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
  6401. this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
  6402. this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
  6403. this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
  6404. this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
  6405. this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
  6406. }
  6407. Beautifier$4.prototype.beautify = function() {
  6408. // if disabled, return the input unchanged.
  6409. if (this._options.disabled) {
  6410. return this._source_text;
  6411. }
  6412. var source_text = this._source_text;
  6413. var eol = this._options.eol;
  6414. if (this._options.eol === 'auto') {
  6415. eol = '\n';
  6416. if (source_text && lineBreak$1.test(source_text)) {
  6417. eol = source_text.match(lineBreak$1)[0];
  6418. }
  6419. }
  6420. // HACK: newline parsing inconsistent. This brute force normalizes the input.
  6421. source_text = source_text.replace(allLineBreaks$1, '\n');
  6422. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  6423. var last_token = {
  6424. text: '',
  6425. type: ''
  6426. };
  6427. var last_tag_token = new TagOpenParserToken();
  6428. var printer = new Printer(this._options, baseIndentString);
  6429. var tokens = new Tokenizer$4(source_text, this._options).tokenize();
  6430. this._tag_stack = new TagStack(printer);
  6431. var parser_token = null;
  6432. var raw_token = tokens.next();
  6433. while (raw_token.type !== TOKEN$4.EOF) {
  6434. if (raw_token.type === TOKEN$4.TAG_OPEN || raw_token.type === TOKEN$4.COMMENT) {
  6435. parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
  6436. last_tag_token = parser_token;
  6437. } else if ((raw_token.type === TOKEN$4.ATTRIBUTE || raw_token.type === TOKEN$4.EQUALS || raw_token.type === TOKEN$4.VALUE) ||
  6438. (raw_token.type === TOKEN$4.TEXT && !last_tag_token.tag_complete)) {
  6439. parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
  6440. } else if (raw_token.type === TOKEN$4.TAG_CLOSE) {
  6441. parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
  6442. } else if (raw_token.type === TOKEN$4.TEXT) {
  6443. parser_token = this._handle_text(printer, raw_token, last_tag_token);
  6444. } else {
  6445. // This should never happen, but if it does. Print the raw token
  6446. printer.add_raw_token(raw_token);
  6447. }
  6448. last_token = parser_token;
  6449. raw_token = tokens.next();
  6450. }
  6451. var sweet_code = printer._output.get_code(eol);
  6452. return sweet_code;
  6453. };
  6454. Beautifier$4.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
  6455. var parser_token = {
  6456. text: raw_token.text,
  6457. type: raw_token.type
  6458. };
  6459. printer.alignment_size = 0;
  6460. last_tag_token.tag_complete = true;
  6461. printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
  6462. if (last_tag_token.is_unformatted) {
  6463. printer.add_raw_token(raw_token);
  6464. } else {
  6465. if (last_tag_token.tag_start_char === '<') {
  6466. printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
  6467. if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
  6468. printer.print_newline(false);
  6469. }
  6470. }
  6471. printer.print_token(raw_token);
  6472. }
  6473. if (last_tag_token.indent_content &&
  6474. !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
  6475. printer.indent();
  6476. // only indent once per opened tag
  6477. last_tag_token.indent_content = false;
  6478. }
  6479. if (!last_tag_token.is_inline_element &&
  6480. !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
  6481. printer.set_wrap_point();
  6482. }
  6483. return parser_token;
  6484. };
  6485. Beautifier$4.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
  6486. var wrapped = last_tag_token.has_wrapped_attrs;
  6487. var parser_token = {
  6488. text: raw_token.text,
  6489. type: raw_token.type
  6490. };
  6491. printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
  6492. if (last_tag_token.is_unformatted) {
  6493. printer.add_raw_token(raw_token);
  6494. } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN$4.TEXT) {
  6495. // For the insides of handlebars allow newlines or a single space between open and contents
  6496. if (printer.print_preserved_newlines(raw_token)) {
  6497. raw_token.newlines = 0;
  6498. printer.add_raw_token(raw_token);
  6499. } else {
  6500. printer.print_token(raw_token);
  6501. }
  6502. } else {
  6503. if (raw_token.type === TOKEN$4.ATTRIBUTE) {
  6504. printer.set_space_before_token(true);
  6505. last_tag_token.attr_count += 1;
  6506. } else if (raw_token.type === TOKEN$4.EQUALS) { //no space before =
  6507. printer.set_space_before_token(false);
  6508. } else if (raw_token.type === TOKEN$4.VALUE && raw_token.previous.type === TOKEN$4.EQUALS) { //no space before value
  6509. printer.set_space_before_token(false);
  6510. }
  6511. if (raw_token.type === TOKEN$4.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
  6512. if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
  6513. printer.traverse_whitespace(raw_token);
  6514. wrapped = wrapped || raw_token.newlines !== 0;
  6515. }
  6516. if (this._is_wrap_attributes_force) {
  6517. var force_attr_wrap = last_tag_token.attr_count > 1;
  6518. if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
  6519. var is_only_attribute = true;
  6520. var peek_index = 0;
  6521. var peek_token;
  6522. do {
  6523. peek_token = tokens.peek(peek_index);
  6524. if (peek_token.type === TOKEN$4.ATTRIBUTE) {
  6525. is_only_attribute = false;
  6526. break;
  6527. }
  6528. peek_index += 1;
  6529. } while (peek_index < 4 && peek_token.type !== TOKEN$4.EOF && peek_token.type !== TOKEN$4.TAG_CLOSE);
  6530. force_attr_wrap = !is_only_attribute;
  6531. }
  6532. if (force_attr_wrap) {
  6533. printer.print_newline(false);
  6534. wrapped = true;
  6535. }
  6536. }
  6537. }
  6538. printer.print_token(raw_token);
  6539. wrapped = wrapped || printer.previous_token_wrapped();
  6540. last_tag_token.has_wrapped_attrs = wrapped;
  6541. }
  6542. return parser_token;
  6543. };
  6544. Beautifier$4.prototype._handle_text = function(printer, raw_token, last_tag_token) {
  6545. var parser_token = {
  6546. text: raw_token.text,
  6547. type: 'TK_CONTENT'
  6548. };
  6549. if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
  6550. this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
  6551. } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
  6552. printer.add_raw_token(raw_token);
  6553. } else {
  6554. printer.traverse_whitespace(raw_token);
  6555. printer.print_token(raw_token);
  6556. }
  6557. return parser_token;
  6558. };
  6559. Beautifier$4.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
  6560. var local = this;
  6561. if (raw_token.text !== '') {
  6562. var text = raw_token.text,
  6563. _beautifier,
  6564. script_indent_level = 1,
  6565. pre = '',
  6566. post = '';
  6567. if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
  6568. _beautifier = this._js_beautify;
  6569. } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
  6570. _beautifier = this._css_beautify;
  6571. } else if (last_tag_token.custom_beautifier_name === 'html') {
  6572. _beautifier = function(html_source, options) {
  6573. var beautifier = new Beautifier$4(html_source, options, local._js_beautify, local._css_beautify);
  6574. return beautifier.beautify();
  6575. };
  6576. }
  6577. if (this._options.indent_scripts === "keep") {
  6578. script_indent_level = 0;
  6579. } else if (this._options.indent_scripts === "separate") {
  6580. script_indent_level = -printer.indent_level;
  6581. }
  6582. var indentation = printer.get_full_indent(script_indent_level);
  6583. // if there is at least one empty line at the end of this text, strip it
  6584. // we'll be adding one back after the text but before the containing tag.
  6585. text = text.replace(/\n[ \t]*$/, '');
  6586. // Handle the case where content is wrapped in a comment or cdata.
  6587. if (last_tag_token.custom_beautifier_name !== 'html' &&
  6588. text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
  6589. var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
  6590. // if we start to wrap but don't finish, print raw
  6591. if (!matched) {
  6592. printer.add_raw_token(raw_token);
  6593. return;
  6594. }
  6595. pre = indentation + matched[1] + '\n';
  6596. text = matched[4];
  6597. if (matched[5]) {
  6598. post = indentation + matched[5];
  6599. }
  6600. // if there is at least one empty line at the end of this text, strip it
  6601. // we'll be adding one back after the text but before the containing tag.
  6602. text = text.replace(/\n[ \t]*$/, '');
  6603. if (matched[2] || matched[3].indexOf('\n') !== -1) {
  6604. // if the first line of the non-comment text has spaces
  6605. // use that as the basis for indenting in null case.
  6606. matched = matched[3].match(/[ \t]+$/);
  6607. if (matched) {
  6608. raw_token.whitespace_before = matched[0];
  6609. }
  6610. }
  6611. }
  6612. if (text) {
  6613. if (_beautifier) {
  6614. // call the Beautifier if avaliable
  6615. var Child_options = function() {
  6616. this.eol = '\n';
  6617. };
  6618. Child_options.prototype = this._options.raw_options;
  6619. var child_options = new Child_options();
  6620. text = _beautifier(indentation + text, child_options);
  6621. } else {
  6622. // simply indent the string otherwise
  6623. var white = raw_token.whitespace_before;
  6624. if (white) {
  6625. text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
  6626. }
  6627. text = indentation + text.replace(/\n/g, '\n' + indentation);
  6628. }
  6629. }
  6630. if (pre) {
  6631. if (!text) {
  6632. text = pre + post;
  6633. } else {
  6634. text = pre + text + '\n' + post;
  6635. }
  6636. }
  6637. printer.print_newline(false);
  6638. if (text) {
  6639. raw_token.text = text;
  6640. raw_token.whitespace_before = '';
  6641. raw_token.newlines = 0;
  6642. printer.add_raw_token(raw_token);
  6643. printer.print_newline(true);
  6644. }
  6645. }
  6646. };
  6647. Beautifier$4.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
  6648. var parser_token = this._get_tag_open_token(raw_token);
  6649. if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
  6650. raw_token.type === TOKEN$4.TAG_OPEN && raw_token.text.indexOf('</') === 0) {
  6651. // End element tags for unformatted or content_unformatted elements
  6652. // are printed raw to keep any newlines inside them exactly the same.
  6653. printer.add_raw_token(raw_token);
  6654. } else {
  6655. printer.traverse_whitespace(raw_token);
  6656. this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
  6657. if (!parser_token.is_inline_element) {
  6658. printer.set_wrap_point();
  6659. }
  6660. printer.print_token(raw_token);
  6661. }
  6662. //indent attributes an auto, forced, aligned or forced-align line-wrap
  6663. if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
  6664. parser_token.alignment_size = raw_token.text.length + 1;
  6665. }
  6666. if (!parser_token.tag_complete && !parser_token.is_unformatted) {
  6667. printer.alignment_size = parser_token.alignment_size;
  6668. }
  6669. return parser_token;
  6670. };
  6671. var TagOpenParserToken = function(parent, raw_token) {
  6672. this.parent = parent || null;
  6673. this.text = '';
  6674. this.type = 'TK_TAG_OPEN';
  6675. this.tag_name = '';
  6676. this.is_inline_element = false;
  6677. this.is_unformatted = false;
  6678. this.is_content_unformatted = false;
  6679. this.is_empty_element = false;
  6680. this.is_start_tag = false;
  6681. this.is_end_tag = false;
  6682. this.indent_content = false;
  6683. this.multiline_content = false;
  6684. this.custom_beautifier_name = null;
  6685. this.start_tag_token = null;
  6686. this.attr_count = 0;
  6687. this.has_wrapped_attrs = false;
  6688. this.alignment_size = 0;
  6689. this.tag_complete = false;
  6690. this.tag_start_char = '';
  6691. this.tag_check = '';
  6692. if (!raw_token) {
  6693. this.tag_complete = true;
  6694. } else {
  6695. var tag_check_match;
  6696. this.tag_start_char = raw_token.text[0];
  6697. this.text = raw_token.text;
  6698. if (this.tag_start_char === '<') {
  6699. tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
  6700. this.tag_check = tag_check_match ? tag_check_match[1] : '';
  6701. } else {
  6702. tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
  6703. this.tag_check = tag_check_match ? tag_check_match[1] : '';
  6704. }
  6705. this.tag_check = this.tag_check.toLowerCase();
  6706. if (raw_token.type === TOKEN$4.COMMENT) {
  6707. this.tag_complete = true;
  6708. }
  6709. this.is_start_tag = this.tag_check.charAt(0) !== '/';
  6710. this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
  6711. this.is_end_tag = !this.is_start_tag ||
  6712. (raw_token.closed && raw_token.closed.text === '/>');
  6713. // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
  6714. this.is_end_tag = this.is_end_tag ||
  6715. (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2)))));
  6716. }
  6717. };
  6718. Beautifier$4.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
  6719. var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
  6720. parser_token.alignment_size = this._options.wrap_attributes_indent_size;
  6721. parser_token.is_end_tag = parser_token.is_end_tag ||
  6722. in_array$2(parser_token.tag_check, this._options.void_elements);
  6723. parser_token.is_empty_element = parser_token.tag_complete ||
  6724. (parser_token.is_start_tag && parser_token.is_end_tag);
  6725. parser_token.is_unformatted = !parser_token.tag_complete && in_array$2(parser_token.tag_check, this._options.unformatted);
  6726. parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array$2(parser_token.tag_check, this._options.content_unformatted);
  6727. parser_token.is_inline_element = in_array$2(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{';
  6728. return parser_token;
  6729. };
  6730. Beautifier$4.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
  6731. if (!parser_token.is_empty_element) {
  6732. if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
  6733. parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
  6734. } else { // it's a start-tag
  6735. // check if this tag is starting an element that has optional end element
  6736. // and do an ending needed
  6737. if (this._do_optional_end_element(parser_token)) {
  6738. if (!parser_token.is_inline_element) {
  6739. if (parser_token.parent) {
  6740. parser_token.parent.multiline_content = true;
  6741. }
  6742. printer.print_newline(false);
  6743. }
  6744. }
  6745. this._tag_stack.record_tag(parser_token); //push it on the tag stack
  6746. if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
  6747. !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
  6748. parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
  6749. }
  6750. }
  6751. }
  6752. if (in_array$2(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
  6753. printer.print_newline(false);
  6754. if (!printer._output.just_added_blankline()) {
  6755. printer.print_newline(true);
  6756. }
  6757. }
  6758. if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
  6759. // if you hit an else case, reset the indent level if you are inside an:
  6760. // 'if', 'unless', or 'each' block.
  6761. if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
  6762. this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
  6763. parser_token.indent_content = true;
  6764. // Don't add a newline if opening {{#if}} tag is on the current line
  6765. var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
  6766. if (!foundIfOnCurrentLine) {
  6767. printer.print_newline(false);
  6768. }
  6769. }
  6770. // Don't add a newline before elements that should remain where they are.
  6771. if (parser_token.tag_name === '!--' && last_token.type === TOKEN$4.TAG_CLOSE &&
  6772. last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) ; else if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
  6773. printer.print_newline(false);
  6774. }
  6775. } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) {
  6776. if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
  6777. printer.print_newline(false);
  6778. }
  6779. } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
  6780. if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) ||
  6781. !(parser_token.is_inline_element ||
  6782. (last_tag_token.is_inline_element) ||
  6783. (last_token.type === TOKEN$4.TAG_CLOSE &&
  6784. parser_token.start_tag_token === last_tag_token) ||
  6785. (last_token.type === 'TK_CONTENT')
  6786. )) {
  6787. printer.print_newline(false);
  6788. }
  6789. } else { // it's a start-tag
  6790. parser_token.indent_content = !parser_token.custom_beautifier_name;
  6791. if (parser_token.tag_start_char === '<') {
  6792. if (parser_token.tag_name === 'html') {
  6793. parser_token.indent_content = this._options.indent_inner_html;
  6794. } else if (parser_token.tag_name === 'head') {
  6795. parser_token.indent_content = this._options.indent_head_inner_html;
  6796. } else if (parser_token.tag_name === 'body') {
  6797. parser_token.indent_content = this._options.indent_body_inner_html;
  6798. }
  6799. }
  6800. if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') {
  6801. if (parser_token.parent) {
  6802. parser_token.parent.multiline_content = true;
  6803. }
  6804. printer.print_newline(false);
  6805. }
  6806. }
  6807. };
  6808. //To be used for <p> tag special case:
  6809. //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'];
  6810. Beautifier$4.prototype._do_optional_end_element = function(parser_token) {
  6811. var result = null;
  6812. // NOTE: cases of "if there is no more content in the parent element"
  6813. // are handled automatically by the beautifier.
  6814. // It assumes parent or ancestor close tag closes all children.
  6815. // https://www.w3.org/TR/html5/syntax.html#optional-tags
  6816. if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
  6817. return;
  6818. } else if (parser_token.tag_name === 'body') {
  6819. // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
  6820. result = result || this._tag_stack.try_pop('head');
  6821. //} else if (parser_token.tag_name === 'body') {
  6822. // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
  6823. } else if (parser_token.tag_name === 'li') {
  6824. // 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.
  6825. result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
  6826. } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
  6827. // 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.
  6828. // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
  6829. result = result || this._tag_stack.try_pop('dt', ['dl']);
  6830. result = result || this._tag_stack.try_pop('dd', ['dl']);
  6831. //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
  6832. //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
  6833. //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.
  6834. //result = result || this._tag_stack.try_pop('p', ['body']);
  6835. } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
  6836. // 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.
  6837. // 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.
  6838. result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
  6839. result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
  6840. } else if (parser_token.tag_name === 'optgroup') {
  6841. // 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.
  6842. // 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.
  6843. result = result || this._tag_stack.try_pop('optgroup', ['select']);
  6844. //result = result || this._tag_stack.try_pop('option', ['select']);
  6845. } else if (parser_token.tag_name === 'option') {
  6846. // 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.
  6847. result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
  6848. } else if (parser_token.tag_name === 'colgroup') {
  6849. // 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.
  6850. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6851. result = result || this._tag_stack.try_pop('caption', ['table']);
  6852. } else if (parser_token.tag_name === 'thead') {
  6853. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6854. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6855. result = result || this._tag_stack.try_pop('caption', ['table']);
  6856. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6857. //} else if (parser_token.tag_name === 'caption') {
  6858. // 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.
  6859. } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
  6860. // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
  6861. // 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.
  6862. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6863. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6864. result = result || this._tag_stack.try_pop('caption', ['table']);
  6865. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6866. result = result || this._tag_stack.try_pop('thead', ['table']);
  6867. result = result || this._tag_stack.try_pop('tbody', ['table']);
  6868. //} else if (parser_token.tag_name === 'tfoot') {
  6869. // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
  6870. } else if (parser_token.tag_name === 'tr') {
  6871. // 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.
  6872. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6873. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6874. result = result || this._tag_stack.try_pop('caption', ['table']);
  6875. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6876. result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
  6877. } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
  6878. // 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.
  6879. // 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.
  6880. result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
  6881. result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
  6882. }
  6883. // Start element omission not handled currently
  6884. // 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.
  6885. // 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.)
  6886. // 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.)
  6887. // Fix up the parent of the parser token
  6888. parser_token.parent = this._tag_stack.get_parser_token();
  6889. return result;
  6890. };
  6891. var Beautifier_1$2 = Beautifier$4;
  6892. var beautifier$2 = {
  6893. Beautifier: Beautifier_1$2
  6894. };
  6895. var Beautifier$5 = beautifier$2.Beautifier,
  6896. Options$9 = options$3.Options;
  6897. function style_html(html_source, options, js_beautify, css_beautify) {
  6898. var beautifier = new Beautifier$5(html_source, options, js_beautify, css_beautify);
  6899. return beautifier.beautify();
  6900. }
  6901. var html = style_html;
  6902. var defaultOptions$2 = function() {
  6903. return new Options$9();
  6904. };
  6905. html.defaultOptions = defaultOptions$2;
  6906. function style_html$1(html_source, options, js, css$1) {
  6907. js = js || javascript;
  6908. css$1 = css$1 || css;
  6909. return html(html_source, options, js, css$1);
  6910. }
  6911. style_html$1.defaultOptions = html.defaultOptions;
  6912. var js = javascript;
  6913. var css$1 = css;
  6914. var html$1 = style_html$1;
  6915. var src = {
  6916. js: js,
  6917. css: css$1,
  6918. html: html$1
  6919. };
  6920. var js$1 = createCommonjsModule(function (module) {
  6921. /**
  6922. The following batches are equivalent:
  6923. var beautify_js = require('js-beautify');
  6924. var beautify_js = require('js-beautify').js;
  6925. var beautify_js = require('js-beautify').js_beautify;
  6926. var beautify_css = require('js-beautify').css;
  6927. var beautify_css = require('js-beautify').css_beautify;
  6928. var beautify_html = require('js-beautify').html;
  6929. var beautify_html = require('js-beautify').html_beautify;
  6930. All methods returned accept two arguments, the source string and an options object.
  6931. **/
  6932. function get_beautify(js_beautify, css_beautify, html_beautify) {
  6933. // the default is js
  6934. var beautify = function(src, config) {
  6935. return js_beautify.js_beautify(src, config);
  6936. };
  6937. // short aliases
  6938. beautify.js = js_beautify.js_beautify;
  6939. beautify.css = css_beautify.css_beautify;
  6940. beautify.html = html_beautify.html_beautify;
  6941. // legacy aliases
  6942. beautify.js_beautify = js_beautify.js_beautify;
  6943. beautify.css_beautify = css_beautify.css_beautify;
  6944. beautify.html_beautify = html_beautify.html_beautify;
  6945. return beautify;
  6946. }
  6947. {
  6948. (function(mod) {
  6949. var beautifier = src;
  6950. beautifier.js_beautify = beautifier.js;
  6951. beautifier.css_beautify = beautifier.css;
  6952. beautifier.html_beautify = beautifier.html;
  6953. mod.exports = get_beautify(beautifier, beautifier, beautifier);
  6954. })(module);
  6955. }
  6956. });
  6957. /*!
  6958. * is-whitespace <https://github.com/jonschlinkert/is-whitespace>
  6959. *
  6960. * Copyright (c) 2014-2015, Jon Schlinkert.
  6961. * Licensed under the MIT License.
  6962. */
  6963. var cache;
  6964. var isWhitespace = function isWhitespace(str) {
  6965. return (typeof str === 'string') && regex().test(str);
  6966. };
  6967. function regex() {
  6968. // ensure that runtime compilation only happens once
  6969. 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"]+$'));
  6970. }
  6971. /*!
  6972. * is-extendable <https://github.com/jonschlinkert/is-extendable>
  6973. *
  6974. * Copyright (c) 2015, Jon Schlinkert.
  6975. * Licensed under the MIT License.
  6976. */
  6977. var isExtendable = function isExtendable(val) {
  6978. return typeof val !== 'undefined' && val !== null
  6979. && (typeof val === 'object' || typeof val === 'function');
  6980. };
  6981. var extendShallow = function extend(o/*, objects*/) {
  6982. var arguments$1 = arguments;
  6983. if (!isExtendable(o)) { o = {}; }
  6984. var len = arguments.length;
  6985. for (var i = 1; i < len; i++) {
  6986. var obj = arguments$1[i];
  6987. if (isExtendable(obj)) {
  6988. assign(o, obj);
  6989. }
  6990. }
  6991. return o;
  6992. };
  6993. function assign(a, b) {
  6994. for (var key in b) {
  6995. if (hasOwn(b, key)) {
  6996. a[key] = b[key];
  6997. }
  6998. }
  6999. }
  7000. /**
  7001. * Returns true if the given `key` is an own property of `obj`.
  7002. */
  7003. function hasOwn(obj, key) {
  7004. return Object.prototype.hasOwnProperty.call(obj, key);
  7005. }
  7006. /*!
  7007. * Determine if an object is a Buffer
  7008. *
  7009. * @author Feross Aboukhadijeh <https://feross.org>
  7010. * @license MIT
  7011. */
  7012. // The _isBuffer check is for Safari 5-7 support, because it's missing
  7013. // Object.prototype.constructor. Remove this eventually
  7014. var isBuffer_1 = function (obj) {
  7015. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  7016. };
  7017. function isBuffer (obj) {
  7018. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  7019. }
  7020. // For Node v0.10 support. Remove this eventually.
  7021. function isSlowBuffer (obj) {
  7022. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  7023. }
  7024. var toString = Object.prototype.toString;
  7025. /**
  7026. * Get the native `typeof` a value.
  7027. *
  7028. * @param {*} `val`
  7029. * @return {*} Native javascript type
  7030. */
  7031. var kindOf = function kindOf(val) {
  7032. // primitivies
  7033. if (typeof val === 'undefined') {
  7034. return 'undefined';
  7035. }
  7036. if (val === null) {
  7037. return 'null';
  7038. }
  7039. if (val === true || val === false || val instanceof Boolean) {
  7040. return 'boolean';
  7041. }
  7042. if (typeof val === 'string' || val instanceof String) {
  7043. return 'string';
  7044. }
  7045. if (typeof val === 'number' || val instanceof Number) {
  7046. return 'number';
  7047. }
  7048. // functions
  7049. if (typeof val === 'function' || val instanceof Function) {
  7050. return 'function';
  7051. }
  7052. // array
  7053. if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
  7054. return 'array';
  7055. }
  7056. // check for instances of RegExp and Date before calling `toString`
  7057. if (val instanceof RegExp) {
  7058. return 'regexp';
  7059. }
  7060. if (val instanceof Date) {
  7061. return 'date';
  7062. }
  7063. // other objects
  7064. var type = toString.call(val);
  7065. if (type === '[object RegExp]') {
  7066. return 'regexp';
  7067. }
  7068. if (type === '[object Date]') {
  7069. return 'date';
  7070. }
  7071. if (type === '[object Arguments]') {
  7072. return 'arguments';
  7073. }
  7074. if (type === '[object Error]') {
  7075. return 'error';
  7076. }
  7077. // buffer
  7078. if (isBuffer_1(val)) {
  7079. return 'buffer';
  7080. }
  7081. // es6: Map, WeakMap, Set, WeakSet
  7082. if (type === '[object Set]') {
  7083. return 'set';
  7084. }
  7085. if (type === '[object WeakSet]') {
  7086. return 'weakset';
  7087. }
  7088. if (type === '[object Map]') {
  7089. return 'map';
  7090. }
  7091. if (type === '[object WeakMap]') {
  7092. return 'weakmap';
  7093. }
  7094. if (type === '[object Symbol]') {
  7095. return 'symbol';
  7096. }
  7097. // typed arrays
  7098. if (type === '[object Int8Array]') {
  7099. return 'int8array';
  7100. }
  7101. if (type === '[object Uint8Array]') {
  7102. return 'uint8array';
  7103. }
  7104. if (type === '[object Uint8ClampedArray]') {
  7105. return 'uint8clampedarray';
  7106. }
  7107. if (type === '[object Int16Array]') {
  7108. return 'int16array';
  7109. }
  7110. if (type === '[object Uint16Array]') {
  7111. return 'uint16array';
  7112. }
  7113. if (type === '[object Int32Array]') {
  7114. return 'int32array';
  7115. }
  7116. if (type === '[object Uint32Array]') {
  7117. return 'uint32array';
  7118. }
  7119. if (type === '[object Float32Array]') {
  7120. return 'float32array';
  7121. }
  7122. if (type === '[object Float64Array]') {
  7123. return 'float64array';
  7124. }
  7125. // must be a plain object
  7126. return 'object';
  7127. };
  7128. var condenseNewlines = function(str, options) {
  7129. var opts = extendShallow({}, options);
  7130. var sep = opts.sep || '\n\n';
  7131. var min = opts.min;
  7132. var re;
  7133. if (typeof min === 'number' && min !== 2) {
  7134. re = new RegExp('(\\r\\n|\\n|\\u2424) {' + min + ',}');
  7135. }
  7136. if (typeof re === 'undefined') {
  7137. re = opts.regex || /(\r\n|\n|\u2424){2,}/g;
  7138. }
  7139. // if a line is 100% whitespace it will be trimmed, so that
  7140. // later we can condense newlines correctly
  7141. if (opts.keepWhitespace !== true) {
  7142. str = str.split('\n').map(function(line) {
  7143. return isWhitespace(line) ? line.trim() : line;
  7144. }).join('\n');
  7145. }
  7146. str = trailingNewline(str, opts);
  7147. return str.replace(re, sep);
  7148. };
  7149. function trailingNewline(str, options) {
  7150. var val = options.trailingNewline;
  7151. if (val === false) {
  7152. return str;
  7153. }
  7154. switch (kindOf(val)) {
  7155. case 'string':
  7156. str = str.replace(/\s+$/, options.trailingNewline);
  7157. break;
  7158. case 'function':
  7159. str = options.trailingNewline(str);
  7160. break;
  7161. case 'undefined':
  7162. case 'boolean':
  7163. default: {
  7164. str = str.replace(/\s+$/, '\n');
  7165. break;
  7166. }
  7167. }
  7168. return str;
  7169. }
  7170. var defaults = {
  7171. unformatted: ['code', 'pre', 'em', 'strong', 'span'],
  7172. indent_inner_html: true,
  7173. indent_char: ' ',
  7174. indent_size: 2,
  7175. sep: '\n'
  7176. };
  7177. var pretty = function pretty(str, options) {
  7178. var opts = extendShallow({}, defaults, options);
  7179. str = js$1.html(str, opts);
  7180. if (opts.ocd === true) {
  7181. if (opts.newlines) { opts.sep = opts.newlines; }
  7182. return ocd(str, opts);
  7183. }
  7184. return str;
  7185. };
  7186. function ocd(str, options) {
  7187. // Normalize and condense all newlines
  7188. return condenseNewlines(str, options)
  7189. // Remove empty whitespace the top of a file.
  7190. .replace(/^\s+/g, '')
  7191. // Remove extra whitespace from eof
  7192. .replace(/\s+$/g, '\n')
  7193. // Add a space above each comment
  7194. .replace(/(\s*<!--)/g, '\n$1')
  7195. // Bring closing comments up to the same line as closing tag.
  7196. .replace(/>(\s*)(?=<!--\s*\/)/g, '> ');
  7197. }
  7198. //
  7199. function getSelectorType(selector) {
  7200. if (isDomSelector(selector)) { return DOM_SELECTOR }
  7201. if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
  7202. if (isNameSelector(selector)) { return NAME_SELECTOR }
  7203. if (isRefSelector(selector)) { return REF_SELECTOR }
  7204. return INVALID_SELECTOR
  7205. }
  7206. function getSelector(
  7207. selector,
  7208. methodName
  7209. ) {
  7210. var type = getSelectorType(selector);
  7211. if (type === INVALID_SELECTOR) {
  7212. throwError(
  7213. "wrapper." + methodName + "() must be passed a valid CSS selector, Vue " +
  7214. "constructor, or valid find option object"
  7215. );
  7216. }
  7217. return {
  7218. type: type,
  7219. value: selector
  7220. }
  7221. }
  7222. //
  7223. var WrapperArray = function WrapperArray(wrappers) {
  7224. var length = wrappers.length;
  7225. // $FlowIgnore
  7226. Object.defineProperty(this, 'wrappers', {
  7227. get: function () { return wrappers; },
  7228. set: function () { return throwError('wrapperArray.wrappers is read-only'); }
  7229. });
  7230. // $FlowIgnore
  7231. Object.defineProperty(this, 'length', {
  7232. get: function () { return length; },
  7233. set: function () { return throwError('wrapperArray.length is read-only'); }
  7234. });
  7235. };
  7236. WrapperArray.prototype.at = function at (index) {
  7237. var normalizedIndex = index < 0 ? this.length + index : index;
  7238. if (normalizedIndex > this.length - 1 || normalizedIndex < 0) {
  7239. var error = "no item exists at " + index;
  7240. error += index < 0 ? (" (normalized to " + normalizedIndex + ")") : '';
  7241. throwError(error);
  7242. }
  7243. return this.wrappers[normalizedIndex]
  7244. };
  7245. WrapperArray.prototype.attributes = function attributes () {
  7246. this.throwErrorIfWrappersIsEmpty('attributes');
  7247. throwError(
  7248. "attributes must be called on a single wrapper, use " +
  7249. "at(i) to access a wrapper"
  7250. );
  7251. };
  7252. WrapperArray.prototype.classes = function classes () {
  7253. this.throwErrorIfWrappersIsEmpty('classes');
  7254. throwError(
  7255. "classes must be called on a single wrapper, use " +
  7256. "at(i) to access a wrapper"
  7257. );
  7258. };
  7259. WrapperArray.prototype.contains = function contains (selector) {
  7260. this.throwErrorIfWrappersIsEmpty('contains');
  7261. return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
  7262. };
  7263. WrapperArray.prototype.exists = function exists () {
  7264. return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
  7265. };
  7266. WrapperArray.prototype.filter = function filter (predicate) {
  7267. return new WrapperArray(this.wrappers.filter(predicate))
  7268. };
  7269. WrapperArray.prototype.emitted = function emitted () {
  7270. this.throwErrorIfWrappersIsEmpty('emitted');
  7271. throwError(
  7272. "emitted must be called on a single wrapper, use " +
  7273. "at(i) to access a wrapper"
  7274. );
  7275. };
  7276. WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
  7277. this.throwErrorIfWrappersIsEmpty('emittedByOrder');
  7278. throwError(
  7279. "emittedByOrder must be called on a single wrapper, " +
  7280. "use at(i) to access a wrapper"
  7281. );
  7282. };
  7283. WrapperArray.prototype.findAll = function findAll () {
  7284. this.throwErrorIfWrappersIsEmpty('findAll');
  7285. throwError(
  7286. "findAll must be called on a single wrapper, use " +
  7287. "at(i) to access a wrapper"
  7288. );
  7289. };
  7290. WrapperArray.prototype.find = function find () {
  7291. this.throwErrorIfWrappersIsEmpty('find');
  7292. throwError(
  7293. "find must be called on a single wrapper, use at(i) " +
  7294. "to access a wrapper"
  7295. );
  7296. };
  7297. WrapperArray.prototype.html = function html () {
  7298. this.throwErrorIfWrappersIsEmpty('html');
  7299. throwError(
  7300. "html must be called on a single wrapper, use at(i) " +
  7301. "to access a wrapper"
  7302. );
  7303. };
  7304. WrapperArray.prototype.is = function is (selector) {
  7305. this.throwErrorIfWrappersIsEmpty('is');
  7306. return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
  7307. };
  7308. WrapperArray.prototype.isEmpty = function isEmpty () {
  7309. this.throwErrorIfWrappersIsEmpty('isEmpty');
  7310. return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
  7311. };
  7312. WrapperArray.prototype.isVisible = function isVisible () {
  7313. this.throwErrorIfWrappersIsEmpty('isVisible');
  7314. return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
  7315. };
  7316. WrapperArray.prototype.isVueInstance = function isVueInstance () {
  7317. this.throwErrorIfWrappersIsEmpty('isVueInstance');
  7318. return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
  7319. };
  7320. WrapperArray.prototype.name = function name () {
  7321. this.throwErrorIfWrappersIsEmpty('name');
  7322. throwError(
  7323. "name must be called on a single wrapper, use at(i) " +
  7324. "to access a wrapper"
  7325. );
  7326. };
  7327. WrapperArray.prototype.overview = function overview () {
  7328. this.throwErrorIfWrappersIsEmpty('overview()');
  7329. throwError(
  7330. "overview() must be called on a single wrapper, use at(i) " +
  7331. "to access a wrapper"
  7332. );
  7333. };
  7334. WrapperArray.prototype.props = function props () {
  7335. this.throwErrorIfWrappersIsEmpty('props');
  7336. throwError(
  7337. "props must be called on a single wrapper, use " +
  7338. "at(i) to access a wrapper"
  7339. );
  7340. };
  7341. WrapperArray.prototype.text = function text () {
  7342. this.throwErrorIfWrappersIsEmpty('text');
  7343. throwError(
  7344. "text must be called on a single wrapper, use at(i) " +
  7345. "to access a wrapper"
  7346. );
  7347. };
  7348. WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
  7349. if (this.wrappers.length === 0) {
  7350. throwError((method + " cannot be called on 0 items"));
  7351. }
  7352. };
  7353. WrapperArray.prototype.setData = function setData (data) {
  7354. this.throwErrorIfWrappersIsEmpty('setData');
  7355. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setData(data); }))
  7356. };
  7357. WrapperArray.prototype.setMethods = function setMethods (props) {
  7358. this.throwErrorIfWrappersIsEmpty('setMethods');
  7359. this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
  7360. };
  7361. WrapperArray.prototype.setProps = function setProps (props) {
  7362. this.throwErrorIfWrappersIsEmpty('setProps');
  7363. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setProps(props); }))
  7364. };
  7365. WrapperArray.prototype.setValue = function setValue (value) {
  7366. this.throwErrorIfWrappersIsEmpty('setValue');
  7367. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setValue(value); }))
  7368. };
  7369. WrapperArray.prototype.setChecked = function setChecked (checked) {
  7370. if ( checked === void 0 ) checked = true;
  7371. this.throwErrorIfWrappersIsEmpty('setChecked');
  7372. return Promise.all(
  7373. this.wrappers.map(function (wrapper) { return wrapper.setChecked(checked); })
  7374. )
  7375. };
  7376. WrapperArray.prototype.setSelected = function setSelected () {
  7377. this.throwErrorIfWrappersIsEmpty('setSelected');
  7378. throwError(
  7379. "setSelected must be called on a single wrapper, " +
  7380. "use at(i) to access a wrapper"
  7381. );
  7382. };
  7383. WrapperArray.prototype.trigger = function trigger (event, options) {
  7384. this.throwErrorIfWrappersIsEmpty('trigger');
  7385. return Promise.all(
  7386. this.wrappers.map(function (wrapper) { return wrapper.trigger(event, options); })
  7387. )
  7388. };
  7389. WrapperArray.prototype.destroy = function destroy () {
  7390. this.throwErrorIfWrappersIsEmpty('destroy');
  7391. this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
  7392. };
  7393. //
  7394. var buildSelectorString = function (selector) {
  7395. if (getSelectorType(selector) === REF_SELECTOR) {
  7396. return ("ref=\"" + (selector.value.ref) + "\"")
  7397. }
  7398. if (typeof selector === 'string') {
  7399. return selector
  7400. }
  7401. return 'Component'
  7402. };
  7403. var ErrorWrapper = function ErrorWrapper(selector) {
  7404. this.selector = selector;
  7405. };
  7406. ErrorWrapper.prototype.at = function at () {
  7407. throwError(
  7408. ("find did not return " + (buildSelectorString(
  7409. this.selector
  7410. )) + ", cannot call at() on empty Wrapper")
  7411. );
  7412. };
  7413. ErrorWrapper.prototype.attributes = function attributes () {
  7414. throwError(
  7415. ("find did not return " + (buildSelectorString(
  7416. this.selector
  7417. )) + ", cannot call attributes() on empty Wrapper")
  7418. );
  7419. };
  7420. ErrorWrapper.prototype.classes = function classes () {
  7421. throwError(
  7422. ("find did not return " + (buildSelectorString(
  7423. this.selector
  7424. )) + ", cannot call classes() on empty Wrapper")
  7425. );
  7426. };
  7427. ErrorWrapper.prototype.contains = function contains () {
  7428. throwError(
  7429. ("find did not return " + (buildSelectorString(
  7430. this.selector
  7431. )) + ", cannot call contains() on empty Wrapper")
  7432. );
  7433. };
  7434. ErrorWrapper.prototype.emitted = function emitted () {
  7435. throwError(
  7436. ("find did not return " + (buildSelectorString(
  7437. this.selector
  7438. )) + ", cannot call emitted() on empty Wrapper")
  7439. );
  7440. };
  7441. ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
  7442. throwError(
  7443. ("find did not return " + (buildSelectorString(
  7444. this.selector
  7445. )) + ", cannot call emittedByOrder() on empty Wrapper")
  7446. );
  7447. };
  7448. ErrorWrapper.prototype.exists = function exists () {
  7449. return false
  7450. };
  7451. ErrorWrapper.prototype.filter = function filter () {
  7452. throwError(
  7453. ("find did not return " + (buildSelectorString(
  7454. this.selector
  7455. )) + ", cannot call filter() on empty Wrapper")
  7456. );
  7457. };
  7458. ErrorWrapper.prototype.visible = function visible () {
  7459. throwError(
  7460. ("find did not return " + (buildSelectorString(
  7461. this.selector
  7462. )) + ", cannot call visible() on empty Wrapper")
  7463. );
  7464. };
  7465. ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
  7466. throwError(
  7467. ("find did not return " + (buildSelectorString(
  7468. this.selector
  7469. )) + ", cannot call hasAttribute() on empty Wrapper")
  7470. );
  7471. };
  7472. ErrorWrapper.prototype.hasClass = function hasClass () {
  7473. throwError(
  7474. ("find did not return " + (buildSelectorString(
  7475. this.selector
  7476. )) + ", cannot call hasClass() on empty Wrapper")
  7477. );
  7478. };
  7479. ErrorWrapper.prototype.hasProp = function hasProp () {
  7480. throwError(
  7481. ("find did not return " + (buildSelectorString(
  7482. this.selector
  7483. )) + ", cannot call hasProp() on empty Wrapper")
  7484. );
  7485. };
  7486. ErrorWrapper.prototype.hasStyle = function hasStyle () {
  7487. throwError(
  7488. ("find did not return " + (buildSelectorString(
  7489. this.selector
  7490. )) + ", cannot call hasStyle() on empty Wrapper")
  7491. );
  7492. };
  7493. ErrorWrapper.prototype.findAll = function findAll () {
  7494. throwError(
  7495. ("find did not return " + (buildSelectorString(
  7496. this.selector
  7497. )) + ", cannot call findAll() on empty Wrapper")
  7498. );
  7499. };
  7500. ErrorWrapper.prototype.find = function find () {
  7501. throwError(
  7502. ("find did not return " + (buildSelectorString(
  7503. this.selector
  7504. )) + ", cannot call find() on empty Wrapper")
  7505. );
  7506. };
  7507. ErrorWrapper.prototype.html = function html () {
  7508. throwError(
  7509. ("find did not return " + (buildSelectorString(
  7510. this.selector
  7511. )) + ", cannot call html() on empty Wrapper")
  7512. );
  7513. };
  7514. ErrorWrapper.prototype.is = function is () {
  7515. throwError(
  7516. ("find did not return " + (buildSelectorString(
  7517. this.selector
  7518. )) + ", cannot call is() on empty Wrapper")
  7519. );
  7520. };
  7521. ErrorWrapper.prototype.isEmpty = function isEmpty () {
  7522. throwError(
  7523. ("find did not return " + (buildSelectorString(
  7524. this.selector
  7525. )) + ", cannot call isEmpty() on empty Wrapper")
  7526. );
  7527. };
  7528. ErrorWrapper.prototype.isVisible = function isVisible () {
  7529. throwError(
  7530. ("find did not return " + (buildSelectorString(
  7531. this.selector
  7532. )) + ", cannot call isVisible() on empty Wrapper")
  7533. );
  7534. };
  7535. ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
  7536. throwError(
  7537. ("find did not return " + (buildSelectorString(
  7538. this.selector
  7539. )) + ", cannot call isVueInstance() on empty Wrapper")
  7540. );
  7541. };
  7542. ErrorWrapper.prototype.name = function name () {
  7543. throwError(
  7544. ("find did not return " + (buildSelectorString(
  7545. this.selector
  7546. )) + ", cannot call name() on empty Wrapper")
  7547. );
  7548. };
  7549. ErrorWrapper.prototype.overview = function overview () {
  7550. throwError(
  7551. ("find did not return " + (buildSelectorString(
  7552. this.selector
  7553. )) + ", cannot call overview() on empty Wrapper")
  7554. );
  7555. };
  7556. ErrorWrapper.prototype.props = function props () {
  7557. throwError(
  7558. ("find did not return " + (buildSelectorString(
  7559. this.selector
  7560. )) + ", cannot call props() on empty Wrapper")
  7561. );
  7562. };
  7563. ErrorWrapper.prototype.text = function text () {
  7564. throwError(
  7565. ("find did not return " + (buildSelectorString(
  7566. this.selector
  7567. )) + ", cannot call text() on empty Wrapper")
  7568. );
  7569. };
  7570. ErrorWrapper.prototype.setComputed = function setComputed () {
  7571. throwError(
  7572. ("find did not return " + (buildSelectorString(
  7573. this.selector
  7574. )) + ", cannot call setComputed() on empty Wrapper")
  7575. );
  7576. };
  7577. ErrorWrapper.prototype.setData = function setData () {
  7578. throwError(
  7579. ("find did not return " + (buildSelectorString(
  7580. this.selector
  7581. )) + ", cannot call setData() on empty Wrapper")
  7582. );
  7583. };
  7584. ErrorWrapper.prototype.setMethods = function setMethods () {
  7585. throwError(
  7586. ("find did not return " + (buildSelectorString(
  7587. this.selector
  7588. )) + ", cannot call setMethods() on empty Wrapper")
  7589. );
  7590. };
  7591. ErrorWrapper.prototype.setProps = function setProps () {
  7592. throwError(
  7593. ("find did not return " + (buildSelectorString(
  7594. this.selector
  7595. )) + ", cannot call setProps() on empty Wrapper")
  7596. );
  7597. };
  7598. ErrorWrapper.prototype.setValue = function setValue () {
  7599. throwError(
  7600. ("find did not return " + (buildSelectorString(
  7601. this.selector
  7602. )) + ", cannot call setValue() on empty Wrapper")
  7603. );
  7604. };
  7605. ErrorWrapper.prototype.setChecked = function setChecked () {
  7606. throwError(
  7607. ("find did not return " + (buildSelectorString(
  7608. this.selector
  7609. )) + ", cannot call setChecked() on empty Wrapper")
  7610. );
  7611. };
  7612. ErrorWrapper.prototype.setSelected = function setSelected () {
  7613. throwError(
  7614. ("find did not return " + (buildSelectorString(
  7615. this.selector
  7616. )) + ", cannot call setSelected() on empty Wrapper")
  7617. );
  7618. };
  7619. ErrorWrapper.prototype.trigger = function trigger () {
  7620. throwError(
  7621. ("find did not return " + (buildSelectorString(
  7622. this.selector
  7623. )) + ", cannot call trigger() on empty Wrapper")
  7624. );
  7625. };
  7626. ErrorWrapper.prototype.destroy = function destroy () {
  7627. throwError(
  7628. ("find did not return " + (buildSelectorString(
  7629. this.selector
  7630. )) + ", cannot call destroy() on empty Wrapper")
  7631. );
  7632. };
  7633. /*!
  7634. * isElementVisible
  7635. * Ported from https://github.com/testing-library/jest-dom
  7636. * Licensed under the MIT License.
  7637. */
  7638. function isStyleVisible(element) {
  7639. var ref = element.style;
  7640. var display = ref.display;
  7641. var visibility = ref.visibility;
  7642. var opacity = ref.opacity;
  7643. return (
  7644. display !== 'none' &&
  7645. visibility !== 'hidden' &&
  7646. visibility !== 'collapse' &&
  7647. opacity !== '0' &&
  7648. opacity !== 0
  7649. )
  7650. }
  7651. function isAttributeVisible(element, previousElement) {
  7652. return (
  7653. !element.hasAttribute('hidden') &&
  7654. (element.nodeName === 'DETAILS' && previousElement.nodeName !== 'SUMMARY'
  7655. ? element.hasAttribute('open')
  7656. : true)
  7657. )
  7658. }
  7659. function isElementVisible(element, previousElement) {
  7660. return (
  7661. element.nodeName !== '#comment' &&
  7662. isStyleVisible(element) &&
  7663. isAttributeVisible(element, previousElement) &&
  7664. (!element.parentElement || isElementVisible(element.parentElement, element))
  7665. )
  7666. }
  7667. function recursivelySetData(vm, target, data) {
  7668. Object.keys(data).forEach(function (key) {
  7669. var val = data[key];
  7670. var targetVal = target[key];
  7671. if (
  7672. isPlainObject(val) &&
  7673. isPlainObject(targetVal) &&
  7674. Object.keys(val).length > 0
  7675. ) {
  7676. recursivelySetData(vm, targetVal, val);
  7677. } else {
  7678. vm.$set(target, key, val);
  7679. }
  7680. });
  7681. }
  7682. var abort = {
  7683. eventInterface: "Event",
  7684. bubbles: false,
  7685. cancelable: false
  7686. };
  7687. var afterprint = {
  7688. eventInterface: "Event",
  7689. bubbles: false,
  7690. cancelable: false
  7691. };
  7692. var animationend = {
  7693. eventInterface: "AnimationEvent",
  7694. bubbles: true,
  7695. cancelable: false
  7696. };
  7697. var animationiteration = {
  7698. eventInterface: "AnimationEvent",
  7699. bubbles: true,
  7700. cancelable: false
  7701. };
  7702. var animationstart = {
  7703. eventInterface: "AnimationEvent",
  7704. bubbles: true,
  7705. cancelable: false
  7706. };
  7707. var appinstalled = {
  7708. eventInterface: "Event",
  7709. bubbles: false,
  7710. cancelable: false
  7711. };
  7712. var audioprocess = {
  7713. eventInterface: "AudioProcessingEvent"
  7714. };
  7715. var audioend = {
  7716. eventInterface: "Event",
  7717. bubbles: false,
  7718. cancelable: false
  7719. };
  7720. var audiostart = {
  7721. eventInterface: "Event",
  7722. bubbles: false,
  7723. cancelable: false
  7724. };
  7725. var beforeprint = {
  7726. eventInterface: "Event",
  7727. bubbles: false,
  7728. cancelable: false
  7729. };
  7730. var beforeunload = {
  7731. eventInterface: "BeforeUnloadEvent",
  7732. bubbles: false,
  7733. cancelable: true
  7734. };
  7735. var beginEvent = {
  7736. eventInterface: "TimeEvent",
  7737. bubbles: false,
  7738. cancelable: false
  7739. };
  7740. var blur = {
  7741. eventInterface: "FocusEvent",
  7742. bubbles: false,
  7743. cancelable: false
  7744. };
  7745. var boundary = {
  7746. eventInterface: "SpeechSynthesisEvent",
  7747. bubbles: false,
  7748. cancelable: false
  7749. };
  7750. var cached = {
  7751. eventInterface: "Event",
  7752. bubbles: false,
  7753. cancelable: false
  7754. };
  7755. var canplay = {
  7756. eventInterface: "Event",
  7757. bubbles: false,
  7758. cancelable: false
  7759. };
  7760. var canplaythrough = {
  7761. eventInterface: "Event",
  7762. bubbles: false,
  7763. cancelable: false
  7764. };
  7765. var change = {
  7766. eventInterface: "Event",
  7767. bubbles: true,
  7768. cancelable: false
  7769. };
  7770. var chargingchange = {
  7771. eventInterface: "Event",
  7772. bubbles: false,
  7773. cancelable: false
  7774. };
  7775. var chargingtimechange = {
  7776. eventInterface: "Event",
  7777. bubbles: false,
  7778. cancelable: false
  7779. };
  7780. var checking = {
  7781. eventInterface: "Event",
  7782. bubbles: false,
  7783. cancelable: false
  7784. };
  7785. var click = {
  7786. eventInterface: "MouseEvent",
  7787. bubbles: true,
  7788. cancelable: true
  7789. };
  7790. var close = {
  7791. eventInterface: "Event",
  7792. bubbles: false,
  7793. cancelable: false
  7794. };
  7795. var complete = {
  7796. eventInterface: "OfflineAudioCompletionEvent"
  7797. };
  7798. var compositionend = {
  7799. eventInterface: "CompositionEvent",
  7800. bubbles: true,
  7801. cancelable: true
  7802. };
  7803. var compositionstart = {
  7804. eventInterface: "CompositionEvent",
  7805. bubbles: true,
  7806. cancelable: true
  7807. };
  7808. var compositionupdate = {
  7809. eventInterface: "CompositionEvent",
  7810. bubbles: true,
  7811. cancelable: false
  7812. };
  7813. var contextmenu = {
  7814. eventInterface: "MouseEvent",
  7815. bubbles: true,
  7816. cancelable: true
  7817. };
  7818. var copy = {
  7819. eventInterface: "ClipboardEvent"
  7820. };
  7821. var cut = {
  7822. eventInterface: "ClipboardEvent",
  7823. bubbles: true,
  7824. cancelable: true
  7825. };
  7826. var dblclick = {
  7827. eventInterface: "MouseEvent",
  7828. bubbles: true,
  7829. cancelable: true
  7830. };
  7831. var devicechange = {
  7832. eventInterface: "Event",
  7833. bubbles: false,
  7834. cancelable: false
  7835. };
  7836. var devicelight = {
  7837. eventInterface: "DeviceLightEvent",
  7838. bubbles: false,
  7839. cancelable: false
  7840. };
  7841. var devicemotion = {
  7842. eventInterface: "DeviceMotionEvent",
  7843. bubbles: false,
  7844. cancelable: false
  7845. };
  7846. var deviceorientation = {
  7847. eventInterface: "DeviceOrientationEvent",
  7848. bubbles: false,
  7849. cancelable: false
  7850. };
  7851. var deviceproximity = {
  7852. eventInterface: "DeviceProximityEvent",
  7853. bubbles: false,
  7854. cancelable: false
  7855. };
  7856. var dischargingtimechange = {
  7857. eventInterface: "Event",
  7858. bubbles: false,
  7859. cancelable: false
  7860. };
  7861. var DOMActivate = {
  7862. eventInterface: "UIEvent",
  7863. bubbles: true,
  7864. cancelable: true
  7865. };
  7866. var DOMAttributeNameChanged = {
  7867. eventInterface: "MutationNameEvent",
  7868. bubbles: true,
  7869. cancelable: true
  7870. };
  7871. var DOMAttrModified = {
  7872. eventInterface: "MutationEvent",
  7873. bubbles: true,
  7874. cancelable: true
  7875. };
  7876. var DOMCharacterDataModified = {
  7877. eventInterface: "MutationEvent",
  7878. bubbles: true,
  7879. cancelable: true
  7880. };
  7881. var DOMContentLoaded = {
  7882. eventInterface: "Event",
  7883. bubbles: true,
  7884. cancelable: true
  7885. };
  7886. var DOMElementNameChanged = {
  7887. eventInterface: "MutationNameEvent",
  7888. bubbles: true,
  7889. cancelable: true
  7890. };
  7891. var DOMFocusIn = {
  7892. eventInterface: "FocusEvent",
  7893. bubbles: true,
  7894. cancelable: true
  7895. };
  7896. var DOMFocusOut = {
  7897. eventInterface: "FocusEvent",
  7898. bubbles: true,
  7899. cancelable: true
  7900. };
  7901. var DOMNodeInserted = {
  7902. eventInterface: "MutationEvent",
  7903. bubbles: true,
  7904. cancelable: true
  7905. };
  7906. var DOMNodeInsertedIntoDocument = {
  7907. eventInterface: "MutationEvent",
  7908. bubbles: true,
  7909. cancelable: true
  7910. };
  7911. var DOMNodeRemoved = {
  7912. eventInterface: "MutationEvent",
  7913. bubbles: true,
  7914. cancelable: true
  7915. };
  7916. var DOMNodeRemovedFromDocument = {
  7917. eventInterface: "MutationEvent",
  7918. bubbles: true,
  7919. cancelable: true
  7920. };
  7921. var DOMSubtreeModified = {
  7922. eventInterface: "MutationEvent"
  7923. };
  7924. var downloading = {
  7925. eventInterface: "Event",
  7926. bubbles: false,
  7927. cancelable: false
  7928. };
  7929. var drag = {
  7930. eventInterface: "DragEvent",
  7931. bubbles: true,
  7932. cancelable: true
  7933. };
  7934. var dragend = {
  7935. eventInterface: "DragEvent",
  7936. bubbles: true,
  7937. cancelable: false
  7938. };
  7939. var dragenter = {
  7940. eventInterface: "DragEvent",
  7941. bubbles: true,
  7942. cancelable: true
  7943. };
  7944. var dragleave = {
  7945. eventInterface: "DragEvent",
  7946. bubbles: true,
  7947. cancelable: false
  7948. };
  7949. var dragover = {
  7950. eventInterface: "DragEvent",
  7951. bubbles: true,
  7952. cancelable: true
  7953. };
  7954. var dragstart = {
  7955. eventInterface: "DragEvent",
  7956. bubbles: true,
  7957. cancelable: true
  7958. };
  7959. var drop = {
  7960. eventInterface: "DragEvent",
  7961. bubbles: true,
  7962. cancelable: true
  7963. };
  7964. var durationchange = {
  7965. eventInterface: "Event",
  7966. bubbles: false,
  7967. cancelable: false
  7968. };
  7969. var emptied = {
  7970. eventInterface: "Event",
  7971. bubbles: false,
  7972. cancelable: false
  7973. };
  7974. var end = {
  7975. eventInterface: "Event",
  7976. bubbles: false,
  7977. cancelable: false
  7978. };
  7979. var ended = {
  7980. eventInterface: "Event",
  7981. bubbles: false,
  7982. cancelable: false
  7983. };
  7984. var endEvent = {
  7985. eventInterface: "TimeEvent",
  7986. bubbles: false,
  7987. cancelable: false
  7988. };
  7989. var error = {
  7990. eventInterface: "Event",
  7991. bubbles: false,
  7992. cancelable: false
  7993. };
  7994. var focus = {
  7995. eventInterface: "FocusEvent",
  7996. bubbles: false,
  7997. cancelable: false
  7998. };
  7999. var focusin = {
  8000. eventInterface: "FocusEvent",
  8001. bubbles: true,
  8002. cancelable: false
  8003. };
  8004. var focusout = {
  8005. eventInterface: "FocusEvent",
  8006. bubbles: true,
  8007. cancelable: false
  8008. };
  8009. var fullscreenchange = {
  8010. eventInterface: "Event",
  8011. bubbles: true,
  8012. cancelable: false
  8013. };
  8014. var fullscreenerror = {
  8015. eventInterface: "Event",
  8016. bubbles: true,
  8017. cancelable: false
  8018. };
  8019. var gamepadconnected = {
  8020. eventInterface: "GamepadEvent",
  8021. bubbles: false,
  8022. cancelable: false
  8023. };
  8024. var gamepaddisconnected = {
  8025. eventInterface: "GamepadEvent",
  8026. bubbles: false,
  8027. cancelable: false
  8028. };
  8029. var gotpointercapture = {
  8030. eventInterface: "PointerEvent",
  8031. bubbles: false,
  8032. cancelable: false
  8033. };
  8034. var hashchange = {
  8035. eventInterface: "HashChangeEvent",
  8036. bubbles: true,
  8037. cancelable: false
  8038. };
  8039. var lostpointercapture = {
  8040. eventInterface: "PointerEvent",
  8041. bubbles: false,
  8042. cancelable: false
  8043. };
  8044. var input = {
  8045. eventInterface: "Event",
  8046. bubbles: true,
  8047. cancelable: false
  8048. };
  8049. var invalid = {
  8050. eventInterface: "Event",
  8051. cancelable: true,
  8052. bubbles: false
  8053. };
  8054. var keydown = {
  8055. eventInterface: "KeyboardEvent",
  8056. bubbles: true,
  8057. cancelable: true
  8058. };
  8059. var keypress = {
  8060. eventInterface: "KeyboardEvent",
  8061. bubbles: true,
  8062. cancelable: true
  8063. };
  8064. var keyup = {
  8065. eventInterface: "KeyboardEvent",
  8066. bubbles: true,
  8067. cancelable: true
  8068. };
  8069. var languagechange = {
  8070. eventInterface: "Event",
  8071. bubbles: false,
  8072. cancelable: false
  8073. };
  8074. var levelchange = {
  8075. eventInterface: "Event",
  8076. bubbles: false,
  8077. cancelable: false
  8078. };
  8079. var load = {
  8080. eventInterface: "UIEvent",
  8081. bubbles: false,
  8082. cancelable: false
  8083. };
  8084. var loadeddata = {
  8085. eventInterface: "Event",
  8086. bubbles: false,
  8087. cancelable: false
  8088. };
  8089. var loadedmetadata = {
  8090. eventInterface: "Event",
  8091. bubbles: false,
  8092. cancelable: false
  8093. };
  8094. var loadend = {
  8095. eventInterface: "ProgressEvent",
  8096. bubbles: false,
  8097. cancelable: false
  8098. };
  8099. var loadstart = {
  8100. eventInterface: "ProgressEvent",
  8101. bubbles: false,
  8102. cancelable: false
  8103. };
  8104. var mark = {
  8105. eventInterface: "SpeechSynthesisEvent",
  8106. bubbles: false,
  8107. cancelable: false
  8108. };
  8109. var message = {
  8110. eventInterface: "MessageEvent",
  8111. bubbles: false,
  8112. cancelable: false
  8113. };
  8114. var messageerror = {
  8115. eventInterface: "MessageEvent",
  8116. bubbles: false,
  8117. cancelable: false
  8118. };
  8119. var mousedown = {
  8120. eventInterface: "MouseEvent",
  8121. bubbles: true,
  8122. cancelable: true
  8123. };
  8124. var mouseenter = {
  8125. eventInterface: "MouseEvent",
  8126. bubbles: false,
  8127. cancelable: false
  8128. };
  8129. var mouseleave = {
  8130. eventInterface: "MouseEvent",
  8131. bubbles: false,
  8132. cancelable: false
  8133. };
  8134. var mousemove = {
  8135. eventInterface: "MouseEvent",
  8136. bubbles: true,
  8137. cancelable: true
  8138. };
  8139. var mouseout = {
  8140. eventInterface: "MouseEvent",
  8141. bubbles: true,
  8142. cancelable: true
  8143. };
  8144. var mouseover = {
  8145. eventInterface: "MouseEvent",
  8146. bubbles: true,
  8147. cancelable: true
  8148. };
  8149. var mouseup = {
  8150. eventInterface: "MouseEvent",
  8151. bubbles: true,
  8152. cancelable: true
  8153. };
  8154. var nomatch = {
  8155. eventInterface: "SpeechRecognitionEvent",
  8156. bubbles: false,
  8157. cancelable: false
  8158. };
  8159. var notificationclick = {
  8160. eventInterface: "NotificationEvent",
  8161. bubbles: false,
  8162. cancelable: false
  8163. };
  8164. var noupdate = {
  8165. eventInterface: "Event",
  8166. bubbles: false,
  8167. cancelable: false
  8168. };
  8169. var obsolete = {
  8170. eventInterface: "Event",
  8171. bubbles: false,
  8172. cancelable: false
  8173. };
  8174. var offline = {
  8175. eventInterface: "Event",
  8176. bubbles: false,
  8177. cancelable: false
  8178. };
  8179. var online = {
  8180. eventInterface: "Event",
  8181. bubbles: false,
  8182. cancelable: false
  8183. };
  8184. var open = {
  8185. eventInterface: "Event",
  8186. bubbles: false,
  8187. cancelable: false
  8188. };
  8189. var orientationchange = {
  8190. eventInterface: "Event",
  8191. bubbles: false,
  8192. cancelable: false
  8193. };
  8194. var pagehide = {
  8195. eventInterface: "PageTransitionEvent",
  8196. bubbles: false,
  8197. cancelable: false
  8198. };
  8199. var pageshow = {
  8200. eventInterface: "PageTransitionEvent",
  8201. bubbles: false,
  8202. cancelable: false
  8203. };
  8204. var paste = {
  8205. eventInterface: "ClipboardEvent",
  8206. bubbles: true,
  8207. cancelable: true
  8208. };
  8209. var pause = {
  8210. eventInterface: "SpeechSynthesisEvent",
  8211. bubbles: false,
  8212. cancelable: false
  8213. };
  8214. var pointercancel = {
  8215. eventInterface: "PointerEvent",
  8216. bubbles: true,
  8217. cancelable: false
  8218. };
  8219. var pointerdown = {
  8220. eventInterface: "PointerEvent",
  8221. bubbles: true,
  8222. cancelable: true
  8223. };
  8224. var pointerenter = {
  8225. eventInterface: "PointerEvent",
  8226. bubbles: false,
  8227. cancelable: false
  8228. };
  8229. var pointerleave = {
  8230. eventInterface: "PointerEvent",
  8231. bubbles: false,
  8232. cancelable: false
  8233. };
  8234. var pointerlockchange = {
  8235. eventInterface: "Event",
  8236. bubbles: true,
  8237. cancelable: false
  8238. };
  8239. var pointerlockerror = {
  8240. eventInterface: "Event",
  8241. bubbles: true,
  8242. cancelable: false
  8243. };
  8244. var pointermove = {
  8245. eventInterface: "PointerEvent",
  8246. bubbles: true,
  8247. cancelable: true
  8248. };
  8249. var pointerout = {
  8250. eventInterface: "PointerEvent",
  8251. bubbles: true,
  8252. cancelable: true
  8253. };
  8254. var pointerover = {
  8255. eventInterface: "PointerEvent",
  8256. bubbles: true,
  8257. cancelable: true
  8258. };
  8259. var pointerup = {
  8260. eventInterface: "PointerEvent",
  8261. bubbles: true,
  8262. cancelable: true
  8263. };
  8264. var play = {
  8265. eventInterface: "Event",
  8266. bubbles: false,
  8267. cancelable: false
  8268. };
  8269. var playing = {
  8270. eventInterface: "Event",
  8271. bubbles: false,
  8272. cancelable: false
  8273. };
  8274. var popstate = {
  8275. eventInterface: "PopStateEvent",
  8276. bubbles: true,
  8277. cancelable: false
  8278. };
  8279. var progress = {
  8280. eventInterface: "ProgressEvent",
  8281. bubbles: false,
  8282. cancelable: false
  8283. };
  8284. var push = {
  8285. eventInterface: "PushEvent",
  8286. bubbles: false,
  8287. cancelable: false
  8288. };
  8289. var pushsubscriptionchange = {
  8290. eventInterface: "PushEvent",
  8291. bubbles: false,
  8292. cancelable: false
  8293. };
  8294. var ratechange = {
  8295. eventInterface: "Event",
  8296. bubbles: false,
  8297. cancelable: false
  8298. };
  8299. var readystatechange = {
  8300. eventInterface: "Event",
  8301. bubbles: false,
  8302. cancelable: false
  8303. };
  8304. var repeatEvent = {
  8305. eventInterface: "TimeEvent",
  8306. bubbles: false,
  8307. cancelable: false
  8308. };
  8309. var reset = {
  8310. eventInterface: "Event",
  8311. bubbles: true,
  8312. cancelable: true
  8313. };
  8314. var resize = {
  8315. eventInterface: "UIEvent",
  8316. bubbles: false,
  8317. cancelable: false
  8318. };
  8319. var resourcetimingbufferfull = {
  8320. eventInterface: "Performance",
  8321. bubbles: true,
  8322. cancelable: true
  8323. };
  8324. var result = {
  8325. eventInterface: "SpeechRecognitionEvent",
  8326. bubbles: false,
  8327. cancelable: false
  8328. };
  8329. var resume = {
  8330. eventInterface: "SpeechSynthesisEvent",
  8331. bubbles: false,
  8332. cancelable: false
  8333. };
  8334. var scroll = {
  8335. eventInterface: "UIEvent",
  8336. bubbles: false,
  8337. cancelable: false
  8338. };
  8339. var seeked = {
  8340. eventInterface: "Event",
  8341. bubbles: false,
  8342. cancelable: false
  8343. };
  8344. var seeking = {
  8345. eventInterface: "Event",
  8346. bubbles: false,
  8347. cancelable: false
  8348. };
  8349. var select = {
  8350. eventInterface: "UIEvent",
  8351. bubbles: true,
  8352. cancelable: false
  8353. };
  8354. var selectstart = {
  8355. eventInterface: "Event",
  8356. bubbles: true,
  8357. cancelable: true
  8358. };
  8359. var selectionchange = {
  8360. eventInterface: "Event",
  8361. bubbles: false,
  8362. cancelable: false
  8363. };
  8364. var show = {
  8365. eventInterface: "MouseEvent",
  8366. bubbles: false,
  8367. cancelable: false
  8368. };
  8369. var slotchange = {
  8370. eventInterface: "Event",
  8371. bubbles: true,
  8372. cancelable: false
  8373. };
  8374. var soundend = {
  8375. eventInterface: "Event",
  8376. bubbles: false,
  8377. cancelable: false
  8378. };
  8379. var soundstart = {
  8380. eventInterface: "Event",
  8381. bubbles: false,
  8382. cancelable: false
  8383. };
  8384. var speechend = {
  8385. eventInterface: "Event",
  8386. bubbles: false,
  8387. cancelable: false
  8388. };
  8389. var speechstart = {
  8390. eventInterface: "Event",
  8391. bubbles: false,
  8392. cancelable: false
  8393. };
  8394. var stalled = {
  8395. eventInterface: "Event",
  8396. bubbles: false,
  8397. cancelable: false
  8398. };
  8399. var start = {
  8400. eventInterface: "SpeechSynthesisEvent",
  8401. bubbles: false,
  8402. cancelable: false
  8403. };
  8404. var storage = {
  8405. eventInterface: "StorageEvent",
  8406. bubbles: false,
  8407. cancelable: false
  8408. };
  8409. var submit = {
  8410. eventInterface: "Event",
  8411. bubbles: true,
  8412. cancelable: true
  8413. };
  8414. var success = {
  8415. eventInterface: "Event",
  8416. bubbles: false,
  8417. cancelable: false
  8418. };
  8419. var suspend = {
  8420. eventInterface: "Event",
  8421. bubbles: false,
  8422. cancelable: false
  8423. };
  8424. var SVGAbort = {
  8425. eventInterface: "SVGEvent",
  8426. bubbles: true,
  8427. cancelable: false
  8428. };
  8429. var SVGError = {
  8430. eventInterface: "SVGEvent",
  8431. bubbles: true,
  8432. cancelable: false
  8433. };
  8434. var SVGLoad = {
  8435. eventInterface: "SVGEvent",
  8436. bubbles: false,
  8437. cancelable: false
  8438. };
  8439. var SVGResize = {
  8440. eventInterface: "SVGEvent",
  8441. bubbles: true,
  8442. cancelable: false
  8443. };
  8444. var SVGScroll = {
  8445. eventInterface: "SVGEvent",
  8446. bubbles: true,
  8447. cancelable: false
  8448. };
  8449. var SVGUnload = {
  8450. eventInterface: "SVGEvent",
  8451. bubbles: false,
  8452. cancelable: false
  8453. };
  8454. var SVGZoom = {
  8455. eventInterface: "SVGZoomEvent",
  8456. bubbles: true,
  8457. cancelable: false
  8458. };
  8459. var timeout = {
  8460. eventInterface: "ProgressEvent",
  8461. bubbles: false,
  8462. cancelable: false
  8463. };
  8464. var timeupdate = {
  8465. eventInterface: "Event",
  8466. bubbles: false,
  8467. cancelable: false
  8468. };
  8469. var touchcancel = {
  8470. eventInterface: "TouchEvent",
  8471. bubbles: true,
  8472. cancelable: false
  8473. };
  8474. var touchend = {
  8475. eventInterface: "TouchEvent",
  8476. bubbles: true,
  8477. cancelable: true
  8478. };
  8479. var touchmove = {
  8480. eventInterface: "TouchEvent",
  8481. bubbles: true,
  8482. cancelable: true
  8483. };
  8484. var touchstart = {
  8485. eventInterface: "TouchEvent",
  8486. bubbles: true,
  8487. cancelable: true
  8488. };
  8489. var transitionend = {
  8490. eventInterface: "TransitionEvent",
  8491. bubbles: true,
  8492. cancelable: true
  8493. };
  8494. var unload = {
  8495. eventInterface: "UIEvent",
  8496. bubbles: false
  8497. };
  8498. var updateready = {
  8499. eventInterface: "Event",
  8500. bubbles: false,
  8501. cancelable: false
  8502. };
  8503. var userproximity = {
  8504. eventInterface: "UserProximityEvent",
  8505. bubbles: false,
  8506. cancelable: false
  8507. };
  8508. var voiceschanged = {
  8509. eventInterface: "Event",
  8510. bubbles: false,
  8511. cancelable: false
  8512. };
  8513. var visibilitychange = {
  8514. eventInterface: "Event",
  8515. bubbles: true,
  8516. cancelable: false
  8517. };
  8518. var volumechange = {
  8519. eventInterface: "Event",
  8520. bubbles: false,
  8521. cancelable: false
  8522. };
  8523. var waiting = {
  8524. eventInterface: "Event",
  8525. bubbles: false,
  8526. cancelable: false
  8527. };
  8528. var wheel = {
  8529. eventInterface: "WheelEvent",
  8530. bubbles: true,
  8531. cancelable: true
  8532. };
  8533. var domEventTypes = {
  8534. abort: abort,
  8535. afterprint: afterprint,
  8536. animationend: animationend,
  8537. animationiteration: animationiteration,
  8538. animationstart: animationstart,
  8539. appinstalled: appinstalled,
  8540. audioprocess: audioprocess,
  8541. audioend: audioend,
  8542. audiostart: audiostart,
  8543. beforeprint: beforeprint,
  8544. beforeunload: beforeunload,
  8545. beginEvent: beginEvent,
  8546. blur: blur,
  8547. boundary: boundary,
  8548. cached: cached,
  8549. canplay: canplay,
  8550. canplaythrough: canplaythrough,
  8551. change: change,
  8552. chargingchange: chargingchange,
  8553. chargingtimechange: chargingtimechange,
  8554. checking: checking,
  8555. click: click,
  8556. close: close,
  8557. complete: complete,
  8558. compositionend: compositionend,
  8559. compositionstart: compositionstart,
  8560. compositionupdate: compositionupdate,
  8561. contextmenu: contextmenu,
  8562. copy: copy,
  8563. cut: cut,
  8564. dblclick: dblclick,
  8565. devicechange: devicechange,
  8566. devicelight: devicelight,
  8567. devicemotion: devicemotion,
  8568. deviceorientation: deviceorientation,
  8569. deviceproximity: deviceproximity,
  8570. dischargingtimechange: dischargingtimechange,
  8571. DOMActivate: DOMActivate,
  8572. DOMAttributeNameChanged: DOMAttributeNameChanged,
  8573. DOMAttrModified: DOMAttrModified,
  8574. DOMCharacterDataModified: DOMCharacterDataModified,
  8575. DOMContentLoaded: DOMContentLoaded,
  8576. DOMElementNameChanged: DOMElementNameChanged,
  8577. DOMFocusIn: DOMFocusIn,
  8578. DOMFocusOut: DOMFocusOut,
  8579. DOMNodeInserted: DOMNodeInserted,
  8580. DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
  8581. DOMNodeRemoved: DOMNodeRemoved,
  8582. DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
  8583. DOMSubtreeModified: DOMSubtreeModified,
  8584. downloading: downloading,
  8585. drag: drag,
  8586. dragend: dragend,
  8587. dragenter: dragenter,
  8588. dragleave: dragleave,
  8589. dragover: dragover,
  8590. dragstart: dragstart,
  8591. drop: drop,
  8592. durationchange: durationchange,
  8593. emptied: emptied,
  8594. end: end,
  8595. ended: ended,
  8596. endEvent: endEvent,
  8597. error: error,
  8598. focus: focus,
  8599. focusin: focusin,
  8600. focusout: focusout,
  8601. fullscreenchange: fullscreenchange,
  8602. fullscreenerror: fullscreenerror,
  8603. gamepadconnected: gamepadconnected,
  8604. gamepaddisconnected: gamepaddisconnected,
  8605. gotpointercapture: gotpointercapture,
  8606. hashchange: hashchange,
  8607. lostpointercapture: lostpointercapture,
  8608. input: input,
  8609. invalid: invalid,
  8610. keydown: keydown,
  8611. keypress: keypress,
  8612. keyup: keyup,
  8613. languagechange: languagechange,
  8614. levelchange: levelchange,
  8615. load: load,
  8616. loadeddata: loadeddata,
  8617. loadedmetadata: loadedmetadata,
  8618. loadend: loadend,
  8619. loadstart: loadstart,
  8620. mark: mark,
  8621. message: message,
  8622. messageerror: messageerror,
  8623. mousedown: mousedown,
  8624. mouseenter: mouseenter,
  8625. mouseleave: mouseleave,
  8626. mousemove: mousemove,
  8627. mouseout: mouseout,
  8628. mouseover: mouseover,
  8629. mouseup: mouseup,
  8630. nomatch: nomatch,
  8631. notificationclick: notificationclick,
  8632. noupdate: noupdate,
  8633. obsolete: obsolete,
  8634. offline: offline,
  8635. online: online,
  8636. open: open,
  8637. orientationchange: orientationchange,
  8638. pagehide: pagehide,
  8639. pageshow: pageshow,
  8640. paste: paste,
  8641. pause: pause,
  8642. pointercancel: pointercancel,
  8643. pointerdown: pointerdown,
  8644. pointerenter: pointerenter,
  8645. pointerleave: pointerleave,
  8646. pointerlockchange: pointerlockchange,
  8647. pointerlockerror: pointerlockerror,
  8648. pointermove: pointermove,
  8649. pointerout: pointerout,
  8650. pointerover: pointerover,
  8651. pointerup: pointerup,
  8652. play: play,
  8653. playing: playing,
  8654. popstate: popstate,
  8655. progress: progress,
  8656. push: push,
  8657. pushsubscriptionchange: pushsubscriptionchange,
  8658. ratechange: ratechange,
  8659. readystatechange: readystatechange,
  8660. repeatEvent: repeatEvent,
  8661. reset: reset,
  8662. resize: resize,
  8663. resourcetimingbufferfull: resourcetimingbufferfull,
  8664. result: result,
  8665. resume: resume,
  8666. scroll: scroll,
  8667. seeked: seeked,
  8668. seeking: seeking,
  8669. select: select,
  8670. selectstart: selectstart,
  8671. selectionchange: selectionchange,
  8672. show: show,
  8673. slotchange: slotchange,
  8674. soundend: soundend,
  8675. soundstart: soundstart,
  8676. speechend: speechend,
  8677. speechstart: speechstart,
  8678. stalled: stalled,
  8679. start: start,
  8680. storage: storage,
  8681. submit: submit,
  8682. success: success,
  8683. suspend: suspend,
  8684. SVGAbort: SVGAbort,
  8685. SVGError: SVGError,
  8686. SVGLoad: SVGLoad,
  8687. SVGResize: SVGResize,
  8688. SVGScroll: SVGScroll,
  8689. SVGUnload: SVGUnload,
  8690. SVGZoom: SVGZoom,
  8691. timeout: timeout,
  8692. timeupdate: timeupdate,
  8693. touchcancel: touchcancel,
  8694. touchend: touchend,
  8695. touchmove: touchmove,
  8696. touchstart: touchstart,
  8697. transitionend: transitionend,
  8698. unload: unload,
  8699. updateready: updateready,
  8700. userproximity: userproximity,
  8701. voiceschanged: voiceschanged,
  8702. visibilitychange: visibilitychange,
  8703. volumechange: volumechange,
  8704. waiting: waiting,
  8705. wheel: wheel
  8706. };
  8707. var domEventTypes$1 = /*#__PURE__*/Object.freeze({
  8708. __proto__: null,
  8709. abort: abort,
  8710. afterprint: afterprint,
  8711. animationend: animationend,
  8712. animationiteration: animationiteration,
  8713. animationstart: animationstart,
  8714. appinstalled: appinstalled,
  8715. audioprocess: audioprocess,
  8716. audioend: audioend,
  8717. audiostart: audiostart,
  8718. beforeprint: beforeprint,
  8719. beforeunload: beforeunload,
  8720. beginEvent: beginEvent,
  8721. blur: blur,
  8722. boundary: boundary,
  8723. cached: cached,
  8724. canplay: canplay,
  8725. canplaythrough: canplaythrough,
  8726. change: change,
  8727. chargingchange: chargingchange,
  8728. chargingtimechange: chargingtimechange,
  8729. checking: checking,
  8730. click: click,
  8731. close: close,
  8732. complete: complete,
  8733. compositionend: compositionend,
  8734. compositionstart: compositionstart,
  8735. compositionupdate: compositionupdate,
  8736. contextmenu: contextmenu,
  8737. copy: copy,
  8738. cut: cut,
  8739. dblclick: dblclick,
  8740. devicechange: devicechange,
  8741. devicelight: devicelight,
  8742. devicemotion: devicemotion,
  8743. deviceorientation: deviceorientation,
  8744. deviceproximity: deviceproximity,
  8745. dischargingtimechange: dischargingtimechange,
  8746. DOMActivate: DOMActivate,
  8747. DOMAttributeNameChanged: DOMAttributeNameChanged,
  8748. DOMAttrModified: DOMAttrModified,
  8749. DOMCharacterDataModified: DOMCharacterDataModified,
  8750. DOMContentLoaded: DOMContentLoaded,
  8751. DOMElementNameChanged: DOMElementNameChanged,
  8752. DOMFocusIn: DOMFocusIn,
  8753. DOMFocusOut: DOMFocusOut,
  8754. DOMNodeInserted: DOMNodeInserted,
  8755. DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
  8756. DOMNodeRemoved: DOMNodeRemoved,
  8757. DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
  8758. DOMSubtreeModified: DOMSubtreeModified,
  8759. downloading: downloading,
  8760. drag: drag,
  8761. dragend: dragend,
  8762. dragenter: dragenter,
  8763. dragleave: dragleave,
  8764. dragover: dragover,
  8765. dragstart: dragstart,
  8766. drop: drop,
  8767. durationchange: durationchange,
  8768. emptied: emptied,
  8769. end: end,
  8770. ended: ended,
  8771. endEvent: endEvent,
  8772. error: error,
  8773. focus: focus,
  8774. focusin: focusin,
  8775. focusout: focusout,
  8776. fullscreenchange: fullscreenchange,
  8777. fullscreenerror: fullscreenerror,
  8778. gamepadconnected: gamepadconnected,
  8779. gamepaddisconnected: gamepaddisconnected,
  8780. gotpointercapture: gotpointercapture,
  8781. hashchange: hashchange,
  8782. lostpointercapture: lostpointercapture,
  8783. input: input,
  8784. invalid: invalid,
  8785. keydown: keydown,
  8786. keypress: keypress,
  8787. keyup: keyup,
  8788. languagechange: languagechange,
  8789. levelchange: levelchange,
  8790. load: load,
  8791. loadeddata: loadeddata,
  8792. loadedmetadata: loadedmetadata,
  8793. loadend: loadend,
  8794. loadstart: loadstart,
  8795. mark: mark,
  8796. message: message,
  8797. messageerror: messageerror,
  8798. mousedown: mousedown,
  8799. mouseenter: mouseenter,
  8800. mouseleave: mouseleave,
  8801. mousemove: mousemove,
  8802. mouseout: mouseout,
  8803. mouseover: mouseover,
  8804. mouseup: mouseup,
  8805. nomatch: nomatch,
  8806. notificationclick: notificationclick,
  8807. noupdate: noupdate,
  8808. obsolete: obsolete,
  8809. offline: offline,
  8810. online: online,
  8811. open: open,
  8812. orientationchange: orientationchange,
  8813. pagehide: pagehide,
  8814. pageshow: pageshow,
  8815. paste: paste,
  8816. pause: pause,
  8817. pointercancel: pointercancel,
  8818. pointerdown: pointerdown,
  8819. pointerenter: pointerenter,
  8820. pointerleave: pointerleave,
  8821. pointerlockchange: pointerlockchange,
  8822. pointerlockerror: pointerlockerror,
  8823. pointermove: pointermove,
  8824. pointerout: pointerout,
  8825. pointerover: pointerover,
  8826. pointerup: pointerup,
  8827. play: play,
  8828. playing: playing,
  8829. popstate: popstate,
  8830. progress: progress,
  8831. push: push,
  8832. pushsubscriptionchange: pushsubscriptionchange,
  8833. ratechange: ratechange,
  8834. readystatechange: readystatechange,
  8835. repeatEvent: repeatEvent,
  8836. reset: reset,
  8837. resize: resize,
  8838. resourcetimingbufferfull: resourcetimingbufferfull,
  8839. result: result,
  8840. resume: resume,
  8841. scroll: scroll,
  8842. seeked: seeked,
  8843. seeking: seeking,
  8844. select: select,
  8845. selectstart: selectstart,
  8846. selectionchange: selectionchange,
  8847. show: show,
  8848. slotchange: slotchange,
  8849. soundend: soundend,
  8850. soundstart: soundstart,
  8851. speechend: speechend,
  8852. speechstart: speechstart,
  8853. stalled: stalled,
  8854. start: start,
  8855. storage: storage,
  8856. submit: submit,
  8857. success: success,
  8858. suspend: suspend,
  8859. SVGAbort: SVGAbort,
  8860. SVGError: SVGError,
  8861. SVGLoad: SVGLoad,
  8862. SVGResize: SVGResize,
  8863. SVGScroll: SVGScroll,
  8864. SVGUnload: SVGUnload,
  8865. SVGZoom: SVGZoom,
  8866. timeout: timeout,
  8867. timeupdate: timeupdate,
  8868. touchcancel: touchcancel,
  8869. touchend: touchend,
  8870. touchmove: touchmove,
  8871. touchstart: touchstart,
  8872. transitionend: transitionend,
  8873. unload: unload,
  8874. updateready: updateready,
  8875. userproximity: userproximity,
  8876. voiceschanged: voiceschanged,
  8877. visibilitychange: visibilitychange,
  8878. volumechange: volumechange,
  8879. waiting: waiting,
  8880. wheel: wheel,
  8881. 'default': domEventTypes
  8882. });
  8883. var require$$0 = getCjsExportFromNamespace(domEventTypes$1);
  8884. var domEventTypes$2 = require$$0;
  8885. var defaultEventType = {
  8886. eventInterface: 'Event',
  8887. cancelable: true,
  8888. bubbles: true
  8889. };
  8890. var modifiers = {
  8891. enter: 13,
  8892. tab: 9,
  8893. delete: 46,
  8894. esc: 27,
  8895. space: 32,
  8896. up: 38,
  8897. down: 40,
  8898. left: 37,
  8899. right: 39,
  8900. end: 35,
  8901. home: 36,
  8902. backspace: 8,
  8903. insert: 45,
  8904. pageup: 33,
  8905. pagedown: 34
  8906. };
  8907. // get from https://github.com/ashubham/w3c-keys/blob/master/index.ts
  8908. var w3cKeys = {
  8909. enter: 'Enter',
  8910. tab: 'Tab',
  8911. delete: 'Delete',
  8912. esc: 'Esc',
  8913. escape: 'Escape',
  8914. space: ' ',
  8915. up: 'Up',
  8916. left: 'Left',
  8917. right: 'Right',
  8918. down: 'Down',
  8919. end: 'End',
  8920. home: 'Home',
  8921. backspace: 'Backspace',
  8922. insert: 'Insert',
  8923. pageup: 'PageUp',
  8924. pagedown: 'PageDown'
  8925. };
  8926. var codeToKeyNameMap = Object.entries(modifiers).reduce(
  8927. function (acc, ref) {
  8928. var obj;
  8929. var key = ref[0];
  8930. var value = ref[1];
  8931. return Object.assign(acc, ( obj = {}, obj[value] = w3cKeys[key], obj ));
  8932. },
  8933. {}
  8934. );
  8935. function getOptions(eventParams) {
  8936. var modifier = eventParams.modifier;
  8937. var meta = eventParams.meta;
  8938. var options = eventParams.options;
  8939. var keyCode = modifiers[modifier] || options.keyCode || options.code;
  8940. var key = codeToKeyNameMap[keyCode];
  8941. return Object.assign({}, options, // What the user passed in as the second argument to #trigger
  8942. {bubbles: meta.bubbles,
  8943. cancelable: meta.cancelable,
  8944. // Any derived options should go here
  8945. keyCode: keyCode,
  8946. code: keyCode,
  8947. key: key || options.key})
  8948. }
  8949. function createEvent(eventParams) {
  8950. var eventType = eventParams.eventType;
  8951. var meta = eventParams.meta; if ( meta === void 0 ) meta = {};
  8952. var SupportedEventInterface =
  8953. typeof window[meta.eventInterface] === 'function'
  8954. ? window[meta.eventInterface]
  8955. : window.Event;
  8956. var event = new SupportedEventInterface(
  8957. eventType,
  8958. // event properties can only be added when the event is instantiated
  8959. // custom properties must be added after the event has been instantiated
  8960. getOptions(eventParams)
  8961. );
  8962. return event
  8963. }
  8964. function createOldEvent(eventParams) {
  8965. var eventType = eventParams.eventType;
  8966. var modifier = eventParams.modifier;
  8967. var meta = eventParams.meta;
  8968. var bubbles = meta.bubbles;
  8969. var cancelable = meta.cancelable;
  8970. var event = document.createEvent('Event');
  8971. event.initEvent(eventType, bubbles, cancelable);
  8972. event.keyCode = modifiers[modifier];
  8973. return event
  8974. }
  8975. function createDOMEvent(type, options) {
  8976. var ref = type.split('.');
  8977. var eventType = ref[0];
  8978. var modifier = ref[1];
  8979. var meta = domEventTypes$2[eventType] || defaultEventType;
  8980. var eventParams = { eventType: eventType, modifier: modifier, meta: meta, options: options };
  8981. // Fallback for IE10,11 - https://stackoverflow.com/questions/26596123
  8982. var event =
  8983. typeof window.Event === 'function'
  8984. ? createEvent(eventParams)
  8985. : createOldEvent(eventParams);
  8986. var eventPrototype = Object.getPrototypeOf(event);
  8987. Object.keys(options || {}).forEach(function (key) {
  8988. var propertyDescriptor = Object.getOwnPropertyDescriptor(
  8989. eventPrototype,
  8990. key
  8991. );
  8992. var canSetProperty = !(
  8993. propertyDescriptor && propertyDescriptor.setter === undefined
  8994. );
  8995. if (canSetProperty) {
  8996. event[key] = options[key];
  8997. }
  8998. });
  8999. return event
  9000. }
  9001. //
  9002. var Wrapper = function Wrapper(
  9003. node,
  9004. options,
  9005. isVueWrapper
  9006. ) {
  9007. var vnode = node instanceof Element ? null : node;
  9008. var element = node instanceof Element ? node : node.elm;
  9009. // Prevent redefine by VueWrapper
  9010. if (!isVueWrapper) {
  9011. // $FlowIgnore : issue with defineProperty
  9012. Object.defineProperty(this, 'rootNode', {
  9013. get: function () { return vnode || element; },
  9014. set: function () { return throwError('wrapper.rootNode is read-only'); }
  9015. });
  9016. // $FlowIgnore
  9017. Object.defineProperty(this, 'vnode', {
  9018. get: function () { return vnode; },
  9019. set: function () { return throwError('wrapper.vnode is read-only'); }
  9020. });
  9021. // $FlowIgnore
  9022. Object.defineProperty(this, 'element', {
  9023. get: function () { return element; },
  9024. set: function () { return throwError('wrapper.element is read-only'); }
  9025. });
  9026. // $FlowIgnore
  9027. Object.defineProperty(this, 'vm', {
  9028. get: function () { return undefined; },
  9029. set: function () { return throwError('wrapper.vm is read-only'); }
  9030. });
  9031. }
  9032. var frozenOptions = Object.freeze(options);
  9033. // $FlowIgnore
  9034. Object.defineProperty(this, 'options', {
  9035. get: function () { return frozenOptions; },
  9036. set: function () { return throwError('wrapper.options is read-only'); }
  9037. });
  9038. if (
  9039. this.vnode &&
  9040. (this.vnode[FUNCTIONAL_OPTIONS] || this.vnode.functionalContext)
  9041. ) {
  9042. this.isFunctionalComponent = true;
  9043. }
  9044. };
  9045. /**
  9046. * Prints warning if component is destroyed
  9047. */
  9048. Wrapper.prototype.__warnIfDestroyed = function __warnIfDestroyed () {
  9049. if (!this.exists()) {
  9050. warn('Operations on destroyed component are discouraged');
  9051. }
  9052. };
  9053. Wrapper.prototype.at = function at () {
  9054. this.__warnIfDestroyed();
  9055. throwError('at() must be called on a WrapperArray');
  9056. };
  9057. /**
  9058. * Returns an Object containing all the attribute/value pairs on the element.
  9059. */
  9060. Wrapper.prototype.attributes = function attributes (key) {
  9061. this.__warnIfDestroyed();
  9062. var attributes = this.element.attributes;
  9063. var attributeMap = {};
  9064. for (var i = 0; i < attributes.length; i++) {
  9065. var att = attributes.item(i);
  9066. attributeMap[att.localName] = att.value;
  9067. }
  9068. return key ? attributeMap[key] : attributeMap
  9069. };
  9070. /**
  9071. * Returns an Array containing all the classes on the element
  9072. */
  9073. Wrapper.prototype.classes = function classes (className) {
  9074. var this$1 = this;
  9075. this.__warnIfDestroyed();
  9076. var classAttribute = this.element.getAttribute('class');
  9077. var classes = classAttribute ? classAttribute.split(' ') : [];
  9078. // Handle converting cssmodules identifiers back to the original class name
  9079. if (this.vm && this.vm.$style) {
  9080. var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
  9081. function (acc, key) {
  9082. // $FlowIgnore
  9083. var moduleIdent = this$1.vm.$style[key];
  9084. if (moduleIdent) {
  9085. acc[moduleIdent.split(' ')[0]] = key;
  9086. }
  9087. return acc
  9088. },
  9089. {}
  9090. );
  9091. classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
  9092. }
  9093. return className ? !!(classes.indexOf(className) > -1) : classes
  9094. };
  9095. /**
  9096. * Checks if wrapper contains provided selector.
  9097. * @deprecated
  9098. */
  9099. Wrapper.prototype.contains = function contains (rawSelector) {
  9100. warnDeprecated(
  9101. 'contains',
  9102. 'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
  9103. );
  9104. this.__warnIfDestroyed();
  9105. var selector = getSelector(rawSelector, 'contains');
  9106. var nodes = find(this.rootNode, this.vm, selector);
  9107. return nodes.length > 0
  9108. };
  9109. /**
  9110. * Calls destroy on vm
  9111. */
  9112. Wrapper.prototype.destroy = function destroy () {
  9113. if (!this.vm && !this.isFunctionalComponent) {
  9114. throwError(
  9115. "wrapper.destroy() can only be called on a Vue instance or " +
  9116. "functional component."
  9117. );
  9118. }
  9119. if (this.element.parentNode) {
  9120. this.element.parentNode.removeChild(this.element);
  9121. }
  9122. if (this.vm) {
  9123. // $FlowIgnore
  9124. this.vm.$destroy();
  9125. throwIfInstancesThrew(this.vm);
  9126. }
  9127. };
  9128. /**
  9129. * Returns an object containing custom events emitted by the Wrapper vm
  9130. */
  9131. Wrapper.prototype.emitted = function emitted (
  9132. event
  9133. ) {
  9134. if (!this._emitted && !this.vm) {
  9135. throwError("wrapper.emitted() can only be called on a Vue instance");
  9136. }
  9137. if (event) {
  9138. return this._emitted[event]
  9139. }
  9140. return this._emitted
  9141. };
  9142. /**
  9143. * Returns an Array containing custom events emitted by the Wrapper vm
  9144. * @deprecated
  9145. */
  9146. Wrapper.prototype.emittedByOrder = function emittedByOrder () {
  9147. warnDeprecated('emittedByOrder', 'Use `wrapper.emitted` instead');
  9148. if (!this._emittedByOrder && !this.vm) {
  9149. throwError(
  9150. "wrapper.emittedByOrder() can only be called on a Vue instance"
  9151. );
  9152. }
  9153. return this._emittedByOrder
  9154. };
  9155. /**
  9156. * Utility to check wrapper exists.
  9157. */
  9158. Wrapper.prototype.exists = function exists () {
  9159. if (this.vm) {
  9160. return !!this.vm && !this.vm._isDestroyed
  9161. }
  9162. return true
  9163. };
  9164. Wrapper.prototype.filter = function filter () {
  9165. throwError('filter() must be called on a WrapperArray');
  9166. };
  9167. /**
  9168. * Gets first node in tree of the current wrapper that
  9169. * matches the provided selector.
  9170. */
  9171. Wrapper.prototype.get = function get (rawSelector) {
  9172. this.__warnIfDestroyed();
  9173. var found = this.find(rawSelector);
  9174. if (found instanceof ErrorWrapper) {
  9175. throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
  9176. }
  9177. return found
  9178. };
  9179. /**
  9180. * Gets first node in tree of the current wrapper that
  9181. * matches the provided selector.
  9182. */
  9183. Wrapper.prototype.getComponent = function getComponent (rawSelector) {
  9184. this.__warnIfDestroyed();
  9185. var found = this.findComponent(rawSelector);
  9186. if (found instanceof ErrorWrapper) {
  9187. throw new Error(("Unable to get " + rawSelector + " within: " + (this.html())))
  9188. }
  9189. return found
  9190. };
  9191. /**
  9192. * Finds first DOM node in tree of the current wrapper that
  9193. * matches the provided selector.
  9194. */
  9195. Wrapper.prototype.find = function find (rawSelector) {
  9196. this.__warnIfDestroyed();
  9197. var selector = getSelector(rawSelector, 'find');
  9198. if (selector.type !== DOM_SELECTOR) {
  9199. warnDeprecated(
  9200. 'finding components with `find` or `get`',
  9201. 'Use `findComponent` and `getComponent` instead'
  9202. );
  9203. }
  9204. return this.__find(rawSelector, selector)
  9205. };
  9206. /**
  9207. * Finds first component in tree of the current wrapper that
  9208. * matches the provided selector.
  9209. */
  9210. Wrapper.prototype.findComponent = function findComponent (rawSelector) {
  9211. this.__warnIfDestroyed();
  9212. var selector = getSelector(rawSelector, 'findComponent');
  9213. return this.__find(rawSelector, selector)
  9214. };
  9215. Wrapper.prototype.__find = function __find (rawSelector, selector) {
  9216. var node = find(this.rootNode, this.vm, selector)[0];
  9217. if (!node) {
  9218. return new ErrorWrapper(rawSelector)
  9219. }
  9220. var wrapper = createWrapper(node, this.options);
  9221. wrapper.selector = rawSelector;
  9222. return wrapper
  9223. };
  9224. /**
  9225. * Finds DOM elements in tree of the current wrapper that matches
  9226. * the provided selector.
  9227. */
  9228. Wrapper.prototype.findAll = function findAll (rawSelector) {
  9229. this.__warnIfDestroyed();
  9230. var selector = getSelector(rawSelector, 'findAll');
  9231. if (selector.type !== DOM_SELECTOR) {
  9232. warnDeprecated(
  9233. 'finding components with `findAll`',
  9234. 'Use `findAllComponents` instead'
  9235. );
  9236. }
  9237. return this.__findAll(rawSelector, selector)
  9238. };
  9239. /**
  9240. * Finds components in tree of the current wrapper that matches
  9241. * the provided selector.
  9242. */
  9243. Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
  9244. this.__warnIfDestroyed();
  9245. var selector = getSelector(rawSelector, 'findAll');
  9246. return this.__findAll(rawSelector, selector, isVueWrapper)
  9247. };
  9248. Wrapper.prototype.__findAll = function __findAll (
  9249. rawSelector,
  9250. selector,
  9251. filterFn
  9252. ) {
  9253. var this$1 = this;
  9254. if ( filterFn === void 0 ) filterFn = function () { return true; };
  9255. var nodes = find(this.rootNode, this.vm, selector);
  9256. var wrappers = nodes
  9257. .map(function (node) {
  9258. // Using CSS Selector, returns a VueWrapper instance if the root element
  9259. // binds a Vue instance.
  9260. var wrapper = createWrapper(node, this$1.options);
  9261. wrapper.selector = rawSelector;
  9262. return wrapper
  9263. })
  9264. .filter(filterFn);
  9265. var wrapperArray = new WrapperArray(wrappers);
  9266. wrapperArray.selector = rawSelector;
  9267. return wrapperArray
  9268. };
  9269. /**
  9270. * Returns HTML of element as a string
  9271. */
  9272. Wrapper.prototype.html = function html () {
  9273. this.__warnIfDestroyed();
  9274. return pretty(this.element.outerHTML)
  9275. };
  9276. /**
  9277. * Checks if node matches selector or component definition
  9278. */
  9279. Wrapper.prototype.is = function is (rawSelector) {
  9280. this.__warnIfDestroyed();
  9281. var selector = getSelector(rawSelector, 'is');
  9282. if (selector.type === DOM_SELECTOR) {
  9283. warnDeprecated(
  9284. 'checking tag name with `is`',
  9285. 'Use `element.tagName` instead'
  9286. );
  9287. }
  9288. if (selector.type === REF_SELECTOR) {
  9289. throwError('$ref selectors can not be used with wrapper.is()');
  9290. }
  9291. return matches(this.rootNode, selector)
  9292. };
  9293. /**
  9294. * Checks if node is empty
  9295. * @deprecated
  9296. */
  9297. Wrapper.prototype.isEmpty = function isEmpty () {
  9298. warnDeprecated(
  9299. 'isEmpty',
  9300. 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
  9301. 'When using with findComponent, access the DOM element with findComponent(Comp).element'
  9302. );
  9303. this.__warnIfDestroyed();
  9304. if (!this.vnode) {
  9305. return this.element.innerHTML === ''
  9306. }
  9307. var nodes = [];
  9308. var node = this.vnode;
  9309. var i = 0;
  9310. while (node) {
  9311. if (node.child) {
  9312. nodes.push(node.child._vnode);
  9313. }
  9314. node.children &&
  9315. node.children.forEach(function (n) {
  9316. nodes.push(n);
  9317. });
  9318. node = nodes[i++];
  9319. }
  9320. return nodes.every(function (n) { return n.isComment || n.child; })
  9321. };
  9322. /**
  9323. * Checks if node is visible
  9324. */
  9325. Wrapper.prototype.isVisible = function isVisible () {
  9326. this.__warnIfDestroyed();
  9327. return isElementVisible(this.element)
  9328. };
  9329. /**
  9330. * Checks if wrapper is a vue instance
  9331. * @deprecated
  9332. */
  9333. Wrapper.prototype.isVueInstance = function isVueInstance () {
  9334. warnDeprecated("isVueInstance");
  9335. this.__warnIfDestroyed();
  9336. return !!this.vm
  9337. };
  9338. /**
  9339. * Returns name of component, or tag name if node is not a Vue component
  9340. * @deprecated
  9341. */
  9342. Wrapper.prototype.name = function name () {
  9343. warnDeprecated("name");
  9344. this.__warnIfDestroyed();
  9345. if (this.vm) {
  9346. return (
  9347. this.vm.$options.name ||
  9348. // compat for Vue < 2.3
  9349. (this.vm.$options.extendOptions && this.vm.$options.extendOptions.name)
  9350. )
  9351. }
  9352. if (!this.vnode) {
  9353. return this.element.tagName
  9354. }
  9355. return this.vnode.tag
  9356. };
  9357. /**
  9358. * Prints a simple overview of the wrapper current state
  9359. * with useful information for debugging
  9360. * @deprecated
  9361. */
  9362. Wrapper.prototype.overview = function overview () {
  9363. var this$1 = this;
  9364. warnDeprecated("overview");
  9365. this.__warnIfDestroyed();
  9366. if (!this.vm) {
  9367. throwError("wrapper.overview() can only be called on a Vue instance");
  9368. }
  9369. var identation = 4;
  9370. var formatJSON = function (json, replacer) {
  9371. if ( replacer === void 0 ) replacer = null;
  9372. return JSON.stringify(json, replacer, identation).replace(/"/g, '');
  9373. };
  9374. var visibility = this.isVisible() ? 'Visible' : 'Not visible';
  9375. var html = this.html()
  9376. ? this.html().replace(/^(?!\s*$)/gm, ' '.repeat(identation)) + '\n'
  9377. : '';
  9378. // $FlowIgnore
  9379. var data = formatJSON(this.vm.$data);
  9380. /* eslint-disable operator-linebreak */
  9381. // $FlowIgnore
  9382. var computed = this.vm._computedWatchers
  9383. ? formatJSON.apply(
  9384. // $FlowIgnore
  9385. void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
  9386. var obj;
  9387. return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
  9388. })
  9389. )
  9390. : // $FlowIgnore
  9391. this.vm.$options.computed
  9392. ? formatJSON.apply(
  9393. // $FlowIgnore
  9394. void 0, Object.entries(this.vm.$options.computed).map(function (ref) {
  9395. var obj;
  9396. var key = ref[0];
  9397. var value = ref[1];
  9398. return (( obj = {}, obj[key] = value(), obj ));
  9399. })
  9400. )
  9401. : '{}';
  9402. /* eslint-enable operator-linebreak */
  9403. var emittedJSONReplacer = function (key, value) { return value instanceof Array
  9404. ? value.map(function (calledWith, index) {
  9405. var callParams = calledWith.map(function (param) { return typeof param === 'object'
  9406. ? JSON.stringify(param)
  9407. .replace(/"/g, '')
  9408. .replace(/,/g, ', ')
  9409. : param; }
  9410. );
  9411. return (index + ": [ " + (callParams.join(', ')) + " ]")
  9412. })
  9413. : value; };
  9414. var emitted = formatJSON(this.emitted(), emittedJSONReplacer);
  9415. console.log(
  9416. '\n' +
  9417. "Wrapper (" + visibility + "):\n\n" +
  9418. "Html:\n" + html + "\n" +
  9419. "Data: " + data + "\n\n" +
  9420. "Computed: " + computed + "\n\n" +
  9421. "Emitted: " + emitted + "\n"
  9422. );
  9423. };
  9424. /**
  9425. * Returns an Object containing the prop name/value pairs on the element
  9426. */
  9427. Wrapper.prototype.props = function props (key) {
  9428. var this$1 = this;
  9429. if (this.isFunctionalComponent) {
  9430. throwError(
  9431. "wrapper.props() cannot be called on a mounted functional component."
  9432. );
  9433. }
  9434. if (!this.vm) {
  9435. throwError('wrapper.props() must be called on a Vue instance');
  9436. }
  9437. this.__warnIfDestroyed();
  9438. var props = {};
  9439. var keys = this.vm && this.vm.$options._propKeys;
  9440. if (keys) {
  9441. (keys || {}).forEach(function (key) {
  9442. if (this$1.vm) {
  9443. props[key] = this$1.vm[key];
  9444. }
  9445. });
  9446. }
  9447. if (key) {
  9448. return props[key]
  9449. }
  9450. return props
  9451. };
  9452. /**
  9453. * Checks radio button or checkbox element
  9454. * @deprecated
  9455. */
  9456. Wrapper.prototype.setChecked = function setChecked (checked) {
  9457. if ( checked === void 0 ) checked = true;
  9458. this.__warnIfDestroyed();
  9459. if (typeof checked !== 'boolean') {
  9460. throwError('wrapper.setChecked() must be passed a boolean');
  9461. }
  9462. var tagName = this.element.tagName;
  9463. // $FlowIgnore
  9464. var type = this.attributes().type;
  9465. var event = getCheckedEvent();
  9466. if (tagName === 'INPUT' && type === 'checkbox') {
  9467. // $FlowIgnore
  9468. if (this.element.checked === checked) {
  9469. return nextTick()
  9470. }
  9471. if (event !== 'click' || isPhantomJS) {
  9472. // $FlowIgnore
  9473. this.element.checked = checked;
  9474. }
  9475. return this.trigger(event)
  9476. }
  9477. if (tagName === 'INPUT' && type === 'radio') {
  9478. if (!checked) {
  9479. throwError(
  9480. "wrapper.setChecked() cannot be called with parameter false on a " +
  9481. "<input type=\"radio\" /> element."
  9482. );
  9483. }
  9484. // $FlowIgnore
  9485. if (this.element.checked === checked) {
  9486. return nextTick()
  9487. }
  9488. if (event !== 'click' || isPhantomJS) {
  9489. // $FlowIgnore
  9490. this.element.selected = true;
  9491. }
  9492. return this.trigger(event)
  9493. }
  9494. throwError("wrapper.setChecked() cannot be called on this element");
  9495. return nextTick()
  9496. };
  9497. /**
  9498. * Selects <option></option> element
  9499. * @deprecated
  9500. */
  9501. Wrapper.prototype.setSelected = function setSelected () {
  9502. this.__warnIfDestroyed();
  9503. var tagName = this.element.tagName;
  9504. if (tagName === 'SELECT') {
  9505. throwError(
  9506. "wrapper.setSelected() cannot be called on select. Call it on one of " +
  9507. "its options"
  9508. );
  9509. }
  9510. if (tagName !== 'OPTION') {
  9511. throwError("wrapper.setSelected() cannot be called on this element");
  9512. }
  9513. // $FlowIgnore
  9514. if (this.element.selected) {
  9515. return nextTick()
  9516. }
  9517. // $FlowIgnore
  9518. this.element.selected = true;
  9519. // $FlowIgnore
  9520. var parentElement = this.element.parentElement;
  9521. // $FlowIgnore
  9522. if (parentElement.tagName === 'OPTGROUP') {
  9523. // $FlowIgnore
  9524. parentElement = parentElement.parentElement;
  9525. }
  9526. // $FlowIgnore
  9527. return createWrapper(parentElement, this.options).trigger('change')
  9528. };
  9529. /**
  9530. * Sets vm data
  9531. */
  9532. Wrapper.prototype.setData = function setData (data) {
  9533. if (this.isFunctionalComponent) {
  9534. throwError("wrapper.setData() cannot be called on a functional component");
  9535. }
  9536. if (!this.vm) {
  9537. throwError("wrapper.setData() can only be called on a Vue instance");
  9538. }
  9539. this.__warnIfDestroyed();
  9540. recursivelySetData(this.vm, this.vm, data);
  9541. return nextTick()
  9542. };
  9543. /**
  9544. * Sets vm methods
  9545. * @deprecated
  9546. */
  9547. Wrapper.prototype.setMethods = function setMethods (methods) {
  9548. var this$1 = this;
  9549. warnDeprecated(
  9550. "setMethods",
  9551. "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"
  9552. );
  9553. if (!this.vm) {
  9554. throwError("wrapper.setMethods() can only be called on a Vue instance");
  9555. }
  9556. this.__warnIfDestroyed();
  9557. Object.keys(methods).forEach(function (key) {
  9558. // $FlowIgnore : Problem with possibly null this.vm
  9559. this$1.vm[key] = methods[key];
  9560. // $FlowIgnore : Problem with possibly null this.vm
  9561. this$1.vm.$options.methods[key] = methods[key];
  9562. });
  9563. if (this.vnode) {
  9564. var context = this.vnode.context;
  9565. if (context.$options.render) { context._update(context._render()); }
  9566. }
  9567. };
  9568. /**
  9569. * Sets vm props
  9570. */
  9571. Wrapper.prototype.setProps = function setProps (data) {
  9572. var this$1 = this;
  9573. // Validate the setProps method call
  9574. if (this.isFunctionalComponent) {
  9575. throwError(
  9576. "wrapper.setProps() cannot be called on a functional component"
  9577. );
  9578. }
  9579. if (!this.vm) {
  9580. throwError("wrapper.setProps() can only be called on a Vue instance");
  9581. }
  9582. // $FlowIgnore : Problem with possibly null this.vm
  9583. if (!this.vm.$parent.$options.$_isWrapperParent) {
  9584. throwError(
  9585. "wrapper.setProps() can only be called for top-level component"
  9586. );
  9587. }
  9588. this.__warnIfDestroyed();
  9589. Object.keys(data).forEach(function (key) {
  9590. // Don't let people set entire objects, because reactivity won't work
  9591. if (
  9592. typeof data[key] === 'object' &&
  9593. data[key] !== null &&
  9594. // $FlowIgnore : Problem with possibly null this.vm
  9595. data[key] === this$1.vm[key]
  9596. ) {
  9597. throwError(
  9598. "wrapper.setProps() called with the same object of the existing " +
  9599. key + " property. You must call wrapper.setProps() with a new " +
  9600. "object to trigger reactivity"
  9601. );
  9602. }
  9603. if (
  9604. VUE_VERSION <= 2.3 &&
  9605. (!this$1.vm ||
  9606. !this$1.vm.$options._propKeys ||
  9607. !this$1.vm.$options._propKeys.some(function (prop) { return prop === key; }))
  9608. ) {
  9609. throwError(
  9610. "wrapper.setProps() called with " + key + " property which " +
  9611. "is not defined on the component"
  9612. );
  9613. }
  9614. // $FlowIgnore : Problem with possibly null this.vm
  9615. var parent = this$1.vm.$parent;
  9616. parent.$set(parent.vueTestUtils_childProps, key, data[key]);
  9617. });
  9618. return nextTick()
  9619. };
  9620. /**
  9621. * Sets element value and triggers input event
  9622. */
  9623. Wrapper.prototype.setValue = function setValue (value) {
  9624. var tagName = this.element.tagName;
  9625. // $FlowIgnore
  9626. var type = this.attributes().type;
  9627. this.__warnIfDestroyed();
  9628. if (tagName === 'OPTION') {
  9629. throwError(
  9630. "wrapper.setValue() cannot be called on an <option> element. Use " +
  9631. "wrapper.setSelected() instead"
  9632. );
  9633. } else if (tagName === 'INPUT' && type === 'checkbox') {
  9634. throwError(
  9635. "wrapper.setValue() cannot be called on a <input type=\"checkbox\" /> " +
  9636. "element. Use wrapper.setChecked() instead"
  9637. );
  9638. } else if (tagName === 'INPUT' && type === 'radio') {
  9639. throwError(
  9640. "wrapper.setValue() cannot be called on a <input type=\"radio\" /> " +
  9641. "element. Use wrapper.setChecked() instead"
  9642. );
  9643. } else if (tagName === 'SELECT') {
  9644. if (Array.isArray(value)) {
  9645. // $FlowIgnore
  9646. var options = this.element.options;
  9647. for (var i = 0; i < options.length; i++) {
  9648. var option = options[i];
  9649. option.selected = value.indexOf(option.value) >= 0;
  9650. }
  9651. } else {
  9652. // $FlowIgnore
  9653. this.element.value = value;
  9654. }
  9655. this.trigger('change');
  9656. return nextTick()
  9657. } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
  9658. // $FlowIgnore
  9659. this.element.value = value;
  9660. this.trigger('input');
  9661. // for v-model.lazy, we need to trigger a change event, too.
  9662. // $FlowIgnore
  9663. if (this.element._vModifiers && this.element._vModifiers.lazy) {
  9664. this.trigger('change');
  9665. }
  9666. return nextTick()
  9667. }
  9668. throwError("wrapper.setValue() cannot be called on this element");
  9669. return nextTick()
  9670. };
  9671. /**
  9672. * Return text of wrapper element
  9673. */
  9674. Wrapper.prototype.text = function text () {
  9675. this.__warnIfDestroyed();
  9676. return this.element.textContent.trim()
  9677. };
  9678. /**
  9679. * Simulates event triggering
  9680. */
  9681. Wrapper.prototype.__simulateTrigger = function __simulateTrigger (type, options) {
  9682. var this$1 = this;
  9683. var regularEventTrigger = function (type, options) {
  9684. var event = createDOMEvent(type, options);
  9685. return this$1.element.dispatchEvent(event)
  9686. };
  9687. var focusEventTrigger = function (type, options) {
  9688. if (this$1.element instanceof HTMLElement) {
  9689. return this$1.element.focus()
  9690. }
  9691. regularEventTrigger(type, options);
  9692. };
  9693. var triggerProcedureMap = {
  9694. focus: focusEventTrigger,
  9695. __default: regularEventTrigger
  9696. };
  9697. var triggerFn = triggerProcedureMap[type] || triggerProcedureMap.__default;
  9698. return triggerFn(type, options)
  9699. };
  9700. /**
  9701. * Dispatches a DOM event on wrapper
  9702. */
  9703. Wrapper.prototype.trigger = function trigger (type, options) {
  9704. if ( options === void 0 ) options = {};
  9705. this.__warnIfDestroyed();
  9706. if (typeof type !== 'string') {
  9707. throwError('wrapper.trigger() must be passed a string');
  9708. }
  9709. if (options.target) {
  9710. throwError(
  9711. "you cannot set the target value of an event. See the notes section " +
  9712. "of the docs for more details—" +
  9713. "https://vue-test-utils.vuejs.org/api/wrapper/trigger.html"
  9714. );
  9715. }
  9716. /**
  9717. * Avoids firing events on specific disabled elements
  9718. * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
  9719. */
  9720. var supportedTags = [
  9721. 'BUTTON',
  9722. 'COMMAND',
  9723. 'FIELDSET',
  9724. 'KEYGEN',
  9725. 'OPTGROUP',
  9726. 'OPTION',
  9727. 'SELECT',
  9728. 'TEXTAREA',
  9729. 'INPUT'
  9730. ];
  9731. var tagName = this.element.tagName;
  9732. if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
  9733. return nextTick()
  9734. }
  9735. this.__simulateTrigger(type, options);
  9736. return nextTick()
  9737. };
  9738. //
  9739. var VueWrapper = /*@__PURE__*/(function (Wrapper) {
  9740. function VueWrapper(vm, options) {
  9741. var this$1 = this;
  9742. Wrapper.call(this, vm._vnode, options, true);
  9743. // $FlowIgnore : issue with defineProperty
  9744. Object.defineProperty(this, 'rootNode', {
  9745. get: function () { return vm.$vnode || { child: this$1.vm }; },
  9746. set: function () { return throwError('wrapper.vnode is read-only'); }
  9747. });
  9748. // $FlowIgnore : issue with defineProperty
  9749. Object.defineProperty(this, 'vnode', {
  9750. get: function () { return vm._vnode; },
  9751. set: function () { return throwError('wrapper.vnode is read-only'); }
  9752. });
  9753. // $FlowIgnore
  9754. Object.defineProperty(this, 'element', {
  9755. get: function () { return vm.$el; },
  9756. set: function () { return throwError('wrapper.element is read-only'); }
  9757. });
  9758. // $FlowIgnore
  9759. Object.defineProperty(this, 'vm', {
  9760. get: function () { return vm; },
  9761. set: function () { return throwError('wrapper.vm is read-only'); }
  9762. });
  9763. this.isFunctionalComponent = vm.$options._isFunctionalContainer;
  9764. this._emitted = vm.__emitted;
  9765. this._emittedByOrder = vm.__emittedByOrder;
  9766. }
  9767. if ( Wrapper ) VueWrapper.__proto__ = Wrapper;
  9768. VueWrapper.prototype = Object.create( Wrapper && Wrapper.prototype );
  9769. VueWrapper.prototype.constructor = VueWrapper;
  9770. return VueWrapper;
  9771. }(Wrapper));
  9772. //
  9773. var isEnabled = false;
  9774. var wrapperInstances = [];
  9775. function resetAutoDestroyState() {
  9776. isEnabled = false;
  9777. wrapperInstances.length = 0;
  9778. }
  9779. function enableAutoDestroy(hook) {
  9780. if (isEnabled) {
  9781. throwError('enableAutoDestroy cannot be called more than once');
  9782. }
  9783. isEnabled = true;
  9784. hook(function () {
  9785. wrapperInstances.forEach(function (wrapper) {
  9786. // skip child wrappers created by wrapper.find()
  9787. if (wrapper.vm || wrapper.isFunctionalComponent) {
  9788. wrapper.destroy();
  9789. }
  9790. });
  9791. wrapperInstances.length = 0;
  9792. });
  9793. }
  9794. function trackInstance(wrapper) {
  9795. if (!isEnabled) { return }
  9796. wrapperInstances.push(wrapper);
  9797. }
  9798. //
  9799. function createWrapper(
  9800. node,
  9801. options
  9802. ) {
  9803. if ( options === void 0 ) options = {};
  9804. var componentInstance = node.child;
  9805. if (componentInstance) {
  9806. var wrapper$1 = new VueWrapper(componentInstance, options);
  9807. trackInstance(wrapper$1);
  9808. return wrapper$1
  9809. }
  9810. var wrapper =
  9811. node instanceof Vue__default['default']
  9812. ? new VueWrapper(node, options)
  9813. : new Wrapper(node, options);
  9814. trackInstance(wrapper);
  9815. return wrapper
  9816. }
  9817. /**
  9818. * Removes all key-value entries from the list cache.
  9819. *
  9820. * @private
  9821. * @name clear
  9822. * @memberOf ListCache
  9823. */
  9824. function listCacheClear() {
  9825. this.__data__ = [];
  9826. this.size = 0;
  9827. }
  9828. var _listCacheClear = listCacheClear;
  9829. /**
  9830. * Performs a
  9831. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9832. * comparison between two values to determine if they are equivalent.
  9833. *
  9834. * @static
  9835. * @memberOf _
  9836. * @since 4.0.0
  9837. * @category Lang
  9838. * @param {*} value The value to compare.
  9839. * @param {*} other The other value to compare.
  9840. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  9841. * @example
  9842. *
  9843. * var object = { 'a': 1 };
  9844. * var other = { 'a': 1 };
  9845. *
  9846. * _.eq(object, object);
  9847. * // => true
  9848. *
  9849. * _.eq(object, other);
  9850. * // => false
  9851. *
  9852. * _.eq('a', 'a');
  9853. * // => true
  9854. *
  9855. * _.eq('a', Object('a'));
  9856. * // => false
  9857. *
  9858. * _.eq(NaN, NaN);
  9859. * // => true
  9860. */
  9861. function eq(value, other) {
  9862. return value === other || (value !== value && other !== other);
  9863. }
  9864. var eq_1 = eq;
  9865. /**
  9866. * Gets the index at which the `key` is found in `array` of key-value pairs.
  9867. *
  9868. * @private
  9869. * @param {Array} array The array to inspect.
  9870. * @param {*} key The key to search for.
  9871. * @returns {number} Returns the index of the matched value, else `-1`.
  9872. */
  9873. function assocIndexOf(array, key) {
  9874. var length = array.length;
  9875. while (length--) {
  9876. if (eq_1(array[length][0], key)) {
  9877. return length;
  9878. }
  9879. }
  9880. return -1;
  9881. }
  9882. var _assocIndexOf = assocIndexOf;
  9883. /** Used for built-in method references. */
  9884. var arrayProto = Array.prototype;
  9885. /** Built-in value references. */
  9886. var splice = arrayProto.splice;
  9887. /**
  9888. * Removes `key` and its value from the list cache.
  9889. *
  9890. * @private
  9891. * @name delete
  9892. * @memberOf ListCache
  9893. * @param {string} key The key of the value to remove.
  9894. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  9895. */
  9896. function listCacheDelete(key) {
  9897. var data = this.__data__,
  9898. index = _assocIndexOf(data, key);
  9899. if (index < 0) {
  9900. return false;
  9901. }
  9902. var lastIndex = data.length - 1;
  9903. if (index == lastIndex) {
  9904. data.pop();
  9905. } else {
  9906. splice.call(data, index, 1);
  9907. }
  9908. --this.size;
  9909. return true;
  9910. }
  9911. var _listCacheDelete = listCacheDelete;
  9912. /**
  9913. * Gets the list cache value for `key`.
  9914. *
  9915. * @private
  9916. * @name get
  9917. * @memberOf ListCache
  9918. * @param {string} key The key of the value to get.
  9919. * @returns {*} Returns the entry value.
  9920. */
  9921. function listCacheGet(key) {
  9922. var data = this.__data__,
  9923. index = _assocIndexOf(data, key);
  9924. return index < 0 ? undefined : data[index][1];
  9925. }
  9926. var _listCacheGet = listCacheGet;
  9927. /**
  9928. * Checks if a list cache value for `key` exists.
  9929. *
  9930. * @private
  9931. * @name has
  9932. * @memberOf ListCache
  9933. * @param {string} key The key of the entry to check.
  9934. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  9935. */
  9936. function listCacheHas(key) {
  9937. return _assocIndexOf(this.__data__, key) > -1;
  9938. }
  9939. var _listCacheHas = listCacheHas;
  9940. /**
  9941. * Sets the list cache `key` to `value`.
  9942. *
  9943. * @private
  9944. * @name set
  9945. * @memberOf ListCache
  9946. * @param {string} key The key of the value to set.
  9947. * @param {*} value The value to set.
  9948. * @returns {Object} Returns the list cache instance.
  9949. */
  9950. function listCacheSet(key, value) {
  9951. var data = this.__data__,
  9952. index = _assocIndexOf(data, key);
  9953. if (index < 0) {
  9954. ++this.size;
  9955. data.push([key, value]);
  9956. } else {
  9957. data[index][1] = value;
  9958. }
  9959. return this;
  9960. }
  9961. var _listCacheSet = listCacheSet;
  9962. /**
  9963. * Creates an list cache object.
  9964. *
  9965. * @private
  9966. * @constructor
  9967. * @param {Array} [entries] The key-value pairs to cache.
  9968. */
  9969. function ListCache(entries) {
  9970. var index = -1,
  9971. length = entries == null ? 0 : entries.length;
  9972. this.clear();
  9973. while (++index < length) {
  9974. var entry = entries[index];
  9975. this.set(entry[0], entry[1]);
  9976. }
  9977. }
  9978. // Add methods to `ListCache`.
  9979. ListCache.prototype.clear = _listCacheClear;
  9980. ListCache.prototype['delete'] = _listCacheDelete;
  9981. ListCache.prototype.get = _listCacheGet;
  9982. ListCache.prototype.has = _listCacheHas;
  9983. ListCache.prototype.set = _listCacheSet;
  9984. var _ListCache = ListCache;
  9985. /**
  9986. * Removes all key-value entries from the stack.
  9987. *
  9988. * @private
  9989. * @name clear
  9990. * @memberOf Stack
  9991. */
  9992. function stackClear() {
  9993. this.__data__ = new _ListCache;
  9994. this.size = 0;
  9995. }
  9996. var _stackClear = stackClear;
  9997. /**
  9998. * Removes `key` and its value from the stack.
  9999. *
  10000. * @private
  10001. * @name delete
  10002. * @memberOf Stack
  10003. * @param {string} key The key of the value to remove.
  10004. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10005. */
  10006. function stackDelete(key) {
  10007. var data = this.__data__,
  10008. result = data['delete'](key);
  10009. this.size = data.size;
  10010. return result;
  10011. }
  10012. var _stackDelete = stackDelete;
  10013. /**
  10014. * Gets the stack value for `key`.
  10015. *
  10016. * @private
  10017. * @name get
  10018. * @memberOf Stack
  10019. * @param {string} key The key of the value to get.
  10020. * @returns {*} Returns the entry value.
  10021. */
  10022. function stackGet(key) {
  10023. return this.__data__.get(key);
  10024. }
  10025. var _stackGet = stackGet;
  10026. /**
  10027. * Checks if a stack value for `key` exists.
  10028. *
  10029. * @private
  10030. * @name has
  10031. * @memberOf Stack
  10032. * @param {string} key The key of the entry to check.
  10033. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10034. */
  10035. function stackHas(key) {
  10036. return this.__data__.has(key);
  10037. }
  10038. var _stackHas = stackHas;
  10039. /** Detect free variable `global` from Node.js. */
  10040. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  10041. var _freeGlobal = freeGlobal;
  10042. /** Detect free variable `self`. */
  10043. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  10044. /** Used as a reference to the global object. */
  10045. var root = _freeGlobal || freeSelf || Function('return this')();
  10046. var _root = root;
  10047. /** Built-in value references. */
  10048. var Symbol = _root.Symbol;
  10049. var _Symbol = Symbol;
  10050. /** Used for built-in method references. */
  10051. var objectProto = Object.prototype;
  10052. /** Used to check objects for own properties. */
  10053. var hasOwnProperty$1 = objectProto.hasOwnProperty;
  10054. /**
  10055. * Used to resolve the
  10056. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  10057. * of values.
  10058. */
  10059. var nativeObjectToString = objectProto.toString;
  10060. /** Built-in value references. */
  10061. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  10062. /**
  10063. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  10064. *
  10065. * @private
  10066. * @param {*} value The value to query.
  10067. * @returns {string} Returns the raw `toStringTag`.
  10068. */
  10069. function getRawTag(value) {
  10070. var isOwn = hasOwnProperty$1.call(value, symToStringTag),
  10071. tag = value[symToStringTag];
  10072. try {
  10073. value[symToStringTag] = undefined;
  10074. var unmasked = true;
  10075. } catch (e) {}
  10076. var result = nativeObjectToString.call(value);
  10077. if (unmasked) {
  10078. if (isOwn) {
  10079. value[symToStringTag] = tag;
  10080. } else {
  10081. delete value[symToStringTag];
  10082. }
  10083. }
  10084. return result;
  10085. }
  10086. var _getRawTag = getRawTag;
  10087. /** Used for built-in method references. */
  10088. var objectProto$1 = Object.prototype;
  10089. /**
  10090. * Used to resolve the
  10091. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  10092. * of values.
  10093. */
  10094. var nativeObjectToString$1 = objectProto$1.toString;
  10095. /**
  10096. * Converts `value` to a string using `Object.prototype.toString`.
  10097. *
  10098. * @private
  10099. * @param {*} value The value to convert.
  10100. * @returns {string} Returns the converted string.
  10101. */
  10102. function objectToString(value) {
  10103. return nativeObjectToString$1.call(value);
  10104. }
  10105. var _objectToString = objectToString;
  10106. /** `Object#toString` result references. */
  10107. var nullTag = '[object Null]',
  10108. undefinedTag = '[object Undefined]';
  10109. /** Built-in value references. */
  10110. var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
  10111. /**
  10112. * The base implementation of `getTag` without fallbacks for buggy environments.
  10113. *
  10114. * @private
  10115. * @param {*} value The value to query.
  10116. * @returns {string} Returns the `toStringTag`.
  10117. */
  10118. function baseGetTag(value) {
  10119. if (value == null) {
  10120. return value === undefined ? undefinedTag : nullTag;
  10121. }
  10122. return (symToStringTag$1 && symToStringTag$1 in Object(value))
  10123. ? _getRawTag(value)
  10124. : _objectToString(value);
  10125. }
  10126. var _baseGetTag = baseGetTag;
  10127. /**
  10128. * Checks if `value` is the
  10129. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  10130. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  10131. *
  10132. * @static
  10133. * @memberOf _
  10134. * @since 0.1.0
  10135. * @category Lang
  10136. * @param {*} value The value to check.
  10137. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  10138. * @example
  10139. *
  10140. * _.isObject({});
  10141. * // => true
  10142. *
  10143. * _.isObject([1, 2, 3]);
  10144. * // => true
  10145. *
  10146. * _.isObject(_.noop);
  10147. * // => true
  10148. *
  10149. * _.isObject(null);
  10150. * // => false
  10151. */
  10152. function isObject(value) {
  10153. var type = typeof value;
  10154. return value != null && (type == 'object' || type == 'function');
  10155. }
  10156. var isObject_1 = isObject;
  10157. /** `Object#toString` result references. */
  10158. var asyncTag = '[object AsyncFunction]',
  10159. funcTag = '[object Function]',
  10160. genTag = '[object GeneratorFunction]',
  10161. proxyTag = '[object Proxy]';
  10162. /**
  10163. * Checks if `value` is classified as a `Function` object.
  10164. *
  10165. * @static
  10166. * @memberOf _
  10167. * @since 0.1.0
  10168. * @category Lang
  10169. * @param {*} value The value to check.
  10170. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  10171. * @example
  10172. *
  10173. * _.isFunction(_);
  10174. * // => true
  10175. *
  10176. * _.isFunction(/abc/);
  10177. * // => false
  10178. */
  10179. function isFunction(value) {
  10180. if (!isObject_1(value)) {
  10181. return false;
  10182. }
  10183. // The use of `Object#toString` avoids issues with the `typeof` operator
  10184. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  10185. var tag = _baseGetTag(value);
  10186. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  10187. }
  10188. var isFunction_1 = isFunction;
  10189. /** Used to detect overreaching core-js shims. */
  10190. var coreJsData = _root['__core-js_shared__'];
  10191. var _coreJsData = coreJsData;
  10192. /** Used to detect methods masquerading as native. */
  10193. var maskSrcKey = (function() {
  10194. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  10195. return uid ? ('Symbol(src)_1.' + uid) : '';
  10196. }());
  10197. /**
  10198. * Checks if `func` has its source masked.
  10199. *
  10200. * @private
  10201. * @param {Function} func The function to check.
  10202. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  10203. */
  10204. function isMasked(func) {
  10205. return !!maskSrcKey && (maskSrcKey in func);
  10206. }
  10207. var _isMasked = isMasked;
  10208. /** Used for built-in method references. */
  10209. var funcProto = Function.prototype;
  10210. /** Used to resolve the decompiled source of functions. */
  10211. var funcToString = funcProto.toString;
  10212. /**
  10213. * Converts `func` to its source code.
  10214. *
  10215. * @private
  10216. * @param {Function} func The function to convert.
  10217. * @returns {string} Returns the source code.
  10218. */
  10219. function toSource(func) {
  10220. if (func != null) {
  10221. try {
  10222. return funcToString.call(func);
  10223. } catch (e) {}
  10224. try {
  10225. return (func + '');
  10226. } catch (e$1) {}
  10227. }
  10228. return '';
  10229. }
  10230. var _toSource = toSource;
  10231. /**
  10232. * Used to match `RegExp`
  10233. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  10234. */
  10235. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  10236. /** Used to detect host constructors (Safari). */
  10237. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  10238. /** Used for built-in method references. */
  10239. var funcProto$1 = Function.prototype,
  10240. objectProto$2 = Object.prototype;
  10241. /** Used to resolve the decompiled source of functions. */
  10242. var funcToString$1 = funcProto$1.toString;
  10243. /** Used to check objects for own properties. */
  10244. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  10245. /** Used to detect if a method is native. */
  10246. var reIsNative = RegExp('^' +
  10247. funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  10248. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  10249. );
  10250. /**
  10251. * The base implementation of `_.isNative` without bad shim checks.
  10252. *
  10253. * @private
  10254. * @param {*} value The value to check.
  10255. * @returns {boolean} Returns `true` if `value` is a native function,
  10256. * else `false`.
  10257. */
  10258. function baseIsNative(value) {
  10259. if (!isObject_1(value) || _isMasked(value)) {
  10260. return false;
  10261. }
  10262. var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
  10263. return pattern.test(_toSource(value));
  10264. }
  10265. var _baseIsNative = baseIsNative;
  10266. /**
  10267. * Gets the value at `key` of `object`.
  10268. *
  10269. * @private
  10270. * @param {Object} [object] The object to query.
  10271. * @param {string} key The key of the property to get.
  10272. * @returns {*} Returns the property value.
  10273. */
  10274. function getValue(object, key) {
  10275. return object == null ? undefined : object[key];
  10276. }
  10277. var _getValue = getValue;
  10278. /**
  10279. * Gets the native function at `key` of `object`.
  10280. *
  10281. * @private
  10282. * @param {Object} object The object to query.
  10283. * @param {string} key The key of the method to get.
  10284. * @returns {*} Returns the function if it's native, else `undefined`.
  10285. */
  10286. function getNative(object, key) {
  10287. var value = _getValue(object, key);
  10288. return _baseIsNative(value) ? value : undefined;
  10289. }
  10290. var _getNative = getNative;
  10291. /* Built-in method references that are verified to be native. */
  10292. var Map = _getNative(_root, 'Map');
  10293. var _Map = Map;
  10294. /* Built-in method references that are verified to be native. */
  10295. var nativeCreate = _getNative(Object, 'create');
  10296. var _nativeCreate = nativeCreate;
  10297. /**
  10298. * Removes all key-value entries from the hash.
  10299. *
  10300. * @private
  10301. * @name clear
  10302. * @memberOf Hash
  10303. */
  10304. function hashClear() {
  10305. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  10306. this.size = 0;
  10307. }
  10308. var _hashClear = hashClear;
  10309. /**
  10310. * Removes `key` and its value from the hash.
  10311. *
  10312. * @private
  10313. * @name delete
  10314. * @memberOf Hash
  10315. * @param {Object} hash The hash to modify.
  10316. * @param {string} key The key of the value to remove.
  10317. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10318. */
  10319. function hashDelete(key) {
  10320. var result = this.has(key) && delete this.__data__[key];
  10321. this.size -= result ? 1 : 0;
  10322. return result;
  10323. }
  10324. var _hashDelete = hashDelete;
  10325. /** Used to stand-in for `undefined` hash values. */
  10326. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  10327. /** Used for built-in method references. */
  10328. var objectProto$3 = Object.prototype;
  10329. /** Used to check objects for own properties. */
  10330. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  10331. /**
  10332. * Gets the hash value for `key`.
  10333. *
  10334. * @private
  10335. * @name get
  10336. * @memberOf Hash
  10337. * @param {string} key The key of the value to get.
  10338. * @returns {*} Returns the entry value.
  10339. */
  10340. function hashGet(key) {
  10341. var data = this.__data__;
  10342. if (_nativeCreate) {
  10343. var result = data[key];
  10344. return result === HASH_UNDEFINED ? undefined : result;
  10345. }
  10346. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  10347. }
  10348. var _hashGet = hashGet;
  10349. /** Used for built-in method references. */
  10350. var objectProto$4 = Object.prototype;
  10351. /** Used to check objects for own properties. */
  10352. var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  10353. /**
  10354. * Checks if a hash value for `key` exists.
  10355. *
  10356. * @private
  10357. * @name has
  10358. * @memberOf Hash
  10359. * @param {string} key The key of the entry to check.
  10360. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10361. */
  10362. function hashHas(key) {
  10363. var data = this.__data__;
  10364. return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
  10365. }
  10366. var _hashHas = hashHas;
  10367. /** Used to stand-in for `undefined` hash values. */
  10368. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  10369. /**
  10370. * Sets the hash `key` to `value`.
  10371. *
  10372. * @private
  10373. * @name set
  10374. * @memberOf Hash
  10375. * @param {string} key The key of the value to set.
  10376. * @param {*} value The value to set.
  10377. * @returns {Object} Returns the hash instance.
  10378. */
  10379. function hashSet(key, value) {
  10380. var data = this.__data__;
  10381. this.size += this.has(key) ? 0 : 1;
  10382. data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  10383. return this;
  10384. }
  10385. var _hashSet = hashSet;
  10386. /**
  10387. * Creates a hash object.
  10388. *
  10389. * @private
  10390. * @constructor
  10391. * @param {Array} [entries] The key-value pairs to cache.
  10392. */
  10393. function Hash(entries) {
  10394. var index = -1,
  10395. length = entries == null ? 0 : entries.length;
  10396. this.clear();
  10397. while (++index < length) {
  10398. var entry = entries[index];
  10399. this.set(entry[0], entry[1]);
  10400. }
  10401. }
  10402. // Add methods to `Hash`.
  10403. Hash.prototype.clear = _hashClear;
  10404. Hash.prototype['delete'] = _hashDelete;
  10405. Hash.prototype.get = _hashGet;
  10406. Hash.prototype.has = _hashHas;
  10407. Hash.prototype.set = _hashSet;
  10408. var _Hash = Hash;
  10409. /**
  10410. * Removes all key-value entries from the map.
  10411. *
  10412. * @private
  10413. * @name clear
  10414. * @memberOf MapCache
  10415. */
  10416. function mapCacheClear() {
  10417. this.size = 0;
  10418. this.__data__ = {
  10419. 'hash': new _Hash,
  10420. 'map': new (_Map || _ListCache),
  10421. 'string': new _Hash
  10422. };
  10423. }
  10424. var _mapCacheClear = mapCacheClear;
  10425. /**
  10426. * Checks if `value` is suitable for use as unique object key.
  10427. *
  10428. * @private
  10429. * @param {*} value The value to check.
  10430. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10431. */
  10432. function isKeyable(value) {
  10433. var type = typeof value;
  10434. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  10435. ? (value !== '__proto__')
  10436. : (value === null);
  10437. }
  10438. var _isKeyable = isKeyable;
  10439. /**
  10440. * Gets the data for `map`.
  10441. *
  10442. * @private
  10443. * @param {Object} map The map to query.
  10444. * @param {string} key The reference key.
  10445. * @returns {*} Returns the map data.
  10446. */
  10447. function getMapData(map, key) {
  10448. var data = map.__data__;
  10449. return _isKeyable(key)
  10450. ? data[typeof key == 'string' ? 'string' : 'hash']
  10451. : data.map;
  10452. }
  10453. var _getMapData = getMapData;
  10454. /**
  10455. * Removes `key` and its value from the map.
  10456. *
  10457. * @private
  10458. * @name delete
  10459. * @memberOf MapCache
  10460. * @param {string} key The key of the value to remove.
  10461. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10462. */
  10463. function mapCacheDelete(key) {
  10464. var result = _getMapData(this, key)['delete'](key);
  10465. this.size -= result ? 1 : 0;
  10466. return result;
  10467. }
  10468. var _mapCacheDelete = mapCacheDelete;
  10469. /**
  10470. * Gets the map value for `key`.
  10471. *
  10472. * @private
  10473. * @name get
  10474. * @memberOf MapCache
  10475. * @param {string} key The key of the value to get.
  10476. * @returns {*} Returns the entry value.
  10477. */
  10478. function mapCacheGet(key) {
  10479. return _getMapData(this, key).get(key);
  10480. }
  10481. var _mapCacheGet = mapCacheGet;
  10482. /**
  10483. * Checks if a map value for `key` exists.
  10484. *
  10485. * @private
  10486. * @name has
  10487. * @memberOf MapCache
  10488. * @param {string} key The key of the entry to check.
  10489. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10490. */
  10491. function mapCacheHas(key) {
  10492. return _getMapData(this, key).has(key);
  10493. }
  10494. var _mapCacheHas = mapCacheHas;
  10495. /**
  10496. * Sets the map `key` to `value`.
  10497. *
  10498. * @private
  10499. * @name set
  10500. * @memberOf MapCache
  10501. * @param {string} key The key of the value to set.
  10502. * @param {*} value The value to set.
  10503. * @returns {Object} Returns the map cache instance.
  10504. */
  10505. function mapCacheSet(key, value) {
  10506. var data = _getMapData(this, key),
  10507. size = data.size;
  10508. data.set(key, value);
  10509. this.size += data.size == size ? 0 : 1;
  10510. return this;
  10511. }
  10512. var _mapCacheSet = mapCacheSet;
  10513. /**
  10514. * Creates a map cache object to store key-value pairs.
  10515. *
  10516. * @private
  10517. * @constructor
  10518. * @param {Array} [entries] The key-value pairs to cache.
  10519. */
  10520. function MapCache(entries) {
  10521. var index = -1,
  10522. length = entries == null ? 0 : entries.length;
  10523. this.clear();
  10524. while (++index < length) {
  10525. var entry = entries[index];
  10526. this.set(entry[0], entry[1]);
  10527. }
  10528. }
  10529. // Add methods to `MapCache`.
  10530. MapCache.prototype.clear = _mapCacheClear;
  10531. MapCache.prototype['delete'] = _mapCacheDelete;
  10532. MapCache.prototype.get = _mapCacheGet;
  10533. MapCache.prototype.has = _mapCacheHas;
  10534. MapCache.prototype.set = _mapCacheSet;
  10535. var _MapCache = MapCache;
  10536. /** Used as the size to enable large array optimizations. */
  10537. var LARGE_ARRAY_SIZE = 200;
  10538. /**
  10539. * Sets the stack `key` to `value`.
  10540. *
  10541. * @private
  10542. * @name set
  10543. * @memberOf Stack
  10544. * @param {string} key The key of the value to set.
  10545. * @param {*} value The value to set.
  10546. * @returns {Object} Returns the stack cache instance.
  10547. */
  10548. function stackSet(key, value) {
  10549. var data = this.__data__;
  10550. if (data instanceof _ListCache) {
  10551. var pairs = data.__data__;
  10552. if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  10553. pairs.push([key, value]);
  10554. this.size = ++data.size;
  10555. return this;
  10556. }
  10557. data = this.__data__ = new _MapCache(pairs);
  10558. }
  10559. data.set(key, value);
  10560. this.size = data.size;
  10561. return this;
  10562. }
  10563. var _stackSet = stackSet;
  10564. /**
  10565. * Creates a stack cache object to store key-value pairs.
  10566. *
  10567. * @private
  10568. * @constructor
  10569. * @param {Array} [entries] The key-value pairs to cache.
  10570. */
  10571. function Stack(entries) {
  10572. var data = this.__data__ = new _ListCache(entries);
  10573. this.size = data.size;
  10574. }
  10575. // Add methods to `Stack`.
  10576. Stack.prototype.clear = _stackClear;
  10577. Stack.prototype['delete'] = _stackDelete;
  10578. Stack.prototype.get = _stackGet;
  10579. Stack.prototype.has = _stackHas;
  10580. Stack.prototype.set = _stackSet;
  10581. var _Stack = Stack;
  10582. /**
  10583. * A specialized version of `_.forEach` for arrays without support for
  10584. * iteratee shorthands.
  10585. *
  10586. * @private
  10587. * @param {Array} [array] The array to iterate over.
  10588. * @param {Function} iteratee The function invoked per iteration.
  10589. * @returns {Array} Returns `array`.
  10590. */
  10591. function arrayEach(array, iteratee) {
  10592. var index = -1,
  10593. length = array == null ? 0 : array.length;
  10594. while (++index < length) {
  10595. if (iteratee(array[index], index, array) === false) {
  10596. break;
  10597. }
  10598. }
  10599. return array;
  10600. }
  10601. var _arrayEach = arrayEach;
  10602. var defineProperty = (function() {
  10603. try {
  10604. var func = _getNative(Object, 'defineProperty');
  10605. func({}, '', {});
  10606. return func;
  10607. } catch (e) {}
  10608. }());
  10609. var _defineProperty = defineProperty;
  10610. /**
  10611. * The base implementation of `assignValue` and `assignMergeValue` without
  10612. * value checks.
  10613. *
  10614. * @private
  10615. * @param {Object} object The object to modify.
  10616. * @param {string} key The key of the property to assign.
  10617. * @param {*} value The value to assign.
  10618. */
  10619. function baseAssignValue(object, key, value) {
  10620. if (key == '__proto__' && _defineProperty) {
  10621. _defineProperty(object, key, {
  10622. 'configurable': true,
  10623. 'enumerable': true,
  10624. 'value': value,
  10625. 'writable': true
  10626. });
  10627. } else {
  10628. object[key] = value;
  10629. }
  10630. }
  10631. var _baseAssignValue = baseAssignValue;
  10632. /** Used for built-in method references. */
  10633. var objectProto$5 = Object.prototype;
  10634. /** Used to check objects for own properties. */
  10635. var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
  10636. /**
  10637. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  10638. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10639. * for equality comparisons.
  10640. *
  10641. * @private
  10642. * @param {Object} object The object to modify.
  10643. * @param {string} key The key of the property to assign.
  10644. * @param {*} value The value to assign.
  10645. */
  10646. function assignValue(object, key, value) {
  10647. var objValue = object[key];
  10648. if (!(hasOwnProperty$5.call(object, key) && eq_1(objValue, value)) ||
  10649. (value === undefined && !(key in object))) {
  10650. _baseAssignValue(object, key, value);
  10651. }
  10652. }
  10653. var _assignValue = assignValue;
  10654. /**
  10655. * Copies properties of `source` to `object`.
  10656. *
  10657. * @private
  10658. * @param {Object} source The object to copy properties from.
  10659. * @param {Array} props The property identifiers to copy.
  10660. * @param {Object} [object={}] The object to copy properties to.
  10661. * @param {Function} [customizer] The function to customize copied values.
  10662. * @returns {Object} Returns `object`.
  10663. */
  10664. function copyObject(source, props, object, customizer) {
  10665. var isNew = !object;
  10666. object || (object = {});
  10667. var index = -1,
  10668. length = props.length;
  10669. while (++index < length) {
  10670. var key = props[index];
  10671. var newValue = customizer
  10672. ? customizer(object[key], source[key], key, object, source)
  10673. : undefined;
  10674. if (newValue === undefined) {
  10675. newValue = source[key];
  10676. }
  10677. if (isNew) {
  10678. _baseAssignValue(object, key, newValue);
  10679. } else {
  10680. _assignValue(object, key, newValue);
  10681. }
  10682. }
  10683. return object;
  10684. }
  10685. var _copyObject = copyObject;
  10686. /**
  10687. * The base implementation of `_.times` without support for iteratee shorthands
  10688. * or max array length checks.
  10689. *
  10690. * @private
  10691. * @param {number} n The number of times to invoke `iteratee`.
  10692. * @param {Function} iteratee The function invoked per iteration.
  10693. * @returns {Array} Returns the array of results.
  10694. */
  10695. function baseTimes(n, iteratee) {
  10696. var index = -1,
  10697. result = Array(n);
  10698. while (++index < n) {
  10699. result[index] = iteratee(index);
  10700. }
  10701. return result;
  10702. }
  10703. var _baseTimes = baseTimes;
  10704. /**
  10705. * Checks if `value` is object-like. A value is object-like if it's not `null`
  10706. * and has a `typeof` result of "object".
  10707. *
  10708. * @static
  10709. * @memberOf _
  10710. * @since 4.0.0
  10711. * @category Lang
  10712. * @param {*} value The value to check.
  10713. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  10714. * @example
  10715. *
  10716. * _.isObjectLike({});
  10717. * // => true
  10718. *
  10719. * _.isObjectLike([1, 2, 3]);
  10720. * // => true
  10721. *
  10722. * _.isObjectLike(_.noop);
  10723. * // => false
  10724. *
  10725. * _.isObjectLike(null);
  10726. * // => false
  10727. */
  10728. function isObjectLike(value) {
  10729. return value != null && typeof value == 'object';
  10730. }
  10731. var isObjectLike_1 = isObjectLike;
  10732. /** `Object#toString` result references. */
  10733. var argsTag = '[object Arguments]';
  10734. /**
  10735. * The base implementation of `_.isArguments`.
  10736. *
  10737. * @private
  10738. * @param {*} value The value to check.
  10739. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10740. */
  10741. function baseIsArguments(value) {
  10742. return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
  10743. }
  10744. var _baseIsArguments = baseIsArguments;
  10745. /** Used for built-in method references. */
  10746. var objectProto$6 = Object.prototype;
  10747. /** Used to check objects for own properties. */
  10748. var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
  10749. /** Built-in value references. */
  10750. var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
  10751. /**
  10752. * Checks if `value` is likely an `arguments` object.
  10753. *
  10754. * @static
  10755. * @memberOf _
  10756. * @since 0.1.0
  10757. * @category Lang
  10758. * @param {*} value The value to check.
  10759. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10760. * else `false`.
  10761. * @example
  10762. *
  10763. * _.isArguments(function() { return arguments; }());
  10764. * // => true
  10765. *
  10766. * _.isArguments([1, 2, 3]);
  10767. * // => false
  10768. */
  10769. var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
  10770. return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') &&
  10771. !propertyIsEnumerable.call(value, 'callee');
  10772. };
  10773. var isArguments_1 = isArguments;
  10774. /**
  10775. * Checks if `value` is classified as an `Array` object.
  10776. *
  10777. * @static
  10778. * @memberOf _
  10779. * @since 0.1.0
  10780. * @category Lang
  10781. * @param {*} value The value to check.
  10782. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  10783. * @example
  10784. *
  10785. * _.isArray([1, 2, 3]);
  10786. * // => true
  10787. *
  10788. * _.isArray(document.body.children);
  10789. * // => false
  10790. *
  10791. * _.isArray('abc');
  10792. * // => false
  10793. *
  10794. * _.isArray(_.noop);
  10795. * // => false
  10796. */
  10797. var isArray = Array.isArray;
  10798. var isArray_1 = isArray;
  10799. /**
  10800. * This method returns `false`.
  10801. *
  10802. * @static
  10803. * @memberOf _
  10804. * @since 4.13.0
  10805. * @category Util
  10806. * @returns {boolean} Returns `false`.
  10807. * @example
  10808. *
  10809. * _.times(2, _.stubFalse);
  10810. * // => [false, false]
  10811. */
  10812. function stubFalse() {
  10813. return false;
  10814. }
  10815. var stubFalse_1 = stubFalse;
  10816. var isBuffer_1$1 = createCommonjsModule(function (module, exports) {
  10817. /** Detect free variable `exports`. */
  10818. var freeExports = exports && !exports.nodeType && exports;
  10819. /** Detect free variable `module`. */
  10820. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  10821. /** Detect the popular CommonJS extension `module.exports`. */
  10822. var moduleExports = freeModule && freeModule.exports === freeExports;
  10823. /** Built-in value references. */
  10824. var Buffer = moduleExports ? _root.Buffer : undefined;
  10825. /* Built-in method references for those with the same name as other `lodash` methods. */
  10826. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  10827. /**
  10828. * Checks if `value` is a buffer.
  10829. *
  10830. * @static
  10831. * @memberOf _
  10832. * @since 4.3.0
  10833. * @category Lang
  10834. * @param {*} value The value to check.
  10835. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  10836. * @example
  10837. *
  10838. * _.isBuffer(new Buffer(2));
  10839. * // => true
  10840. *
  10841. * _.isBuffer(new Uint8Array(2));
  10842. * // => false
  10843. */
  10844. var isBuffer = nativeIsBuffer || stubFalse_1;
  10845. module.exports = isBuffer;
  10846. });
  10847. /** Used as references for various `Number` constants. */
  10848. var MAX_SAFE_INTEGER = 9007199254740991;
  10849. /** Used to detect unsigned integer values. */
  10850. var reIsUint = /^(?:0|[1-9]\d*)$/;
  10851. /**
  10852. * Checks if `value` is a valid array-like index.
  10853. *
  10854. * @private
  10855. * @param {*} value The value to check.
  10856. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  10857. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  10858. */
  10859. function isIndex(value, length) {
  10860. var type = typeof value;
  10861. length = length == null ? MAX_SAFE_INTEGER : length;
  10862. return !!length &&
  10863. (type == 'number' ||
  10864. (type != 'symbol' && reIsUint.test(value))) &&
  10865. (value > -1 && value % 1 == 0 && value < length);
  10866. }
  10867. var _isIndex = isIndex;
  10868. /** Used as references for various `Number` constants. */
  10869. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  10870. /**
  10871. * Checks if `value` is a valid array-like length.
  10872. *
  10873. * **Note:** This method is loosely based on
  10874. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  10875. *
  10876. * @static
  10877. * @memberOf _
  10878. * @since 4.0.0
  10879. * @category Lang
  10880. * @param {*} value The value to check.
  10881. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  10882. * @example
  10883. *
  10884. * _.isLength(3);
  10885. * // => true
  10886. *
  10887. * _.isLength(Number.MIN_VALUE);
  10888. * // => false
  10889. *
  10890. * _.isLength(Infinity);
  10891. * // => false
  10892. *
  10893. * _.isLength('3');
  10894. * // => false
  10895. */
  10896. function isLength(value) {
  10897. return typeof value == 'number' &&
  10898. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
  10899. }
  10900. var isLength_1 = isLength;
  10901. /** `Object#toString` result references. */
  10902. var argsTag$1 = '[object Arguments]',
  10903. arrayTag = '[object Array]',
  10904. boolTag = '[object Boolean]',
  10905. dateTag = '[object Date]',
  10906. errorTag = '[object Error]',
  10907. funcTag$1 = '[object Function]',
  10908. mapTag = '[object Map]',
  10909. numberTag = '[object Number]',
  10910. objectTag = '[object Object]',
  10911. regexpTag = '[object RegExp]',
  10912. setTag = '[object Set]',
  10913. stringTag = '[object String]',
  10914. weakMapTag = '[object WeakMap]';
  10915. var arrayBufferTag = '[object ArrayBuffer]',
  10916. dataViewTag = '[object DataView]',
  10917. float32Tag = '[object Float32Array]',
  10918. float64Tag = '[object Float64Array]',
  10919. int8Tag = '[object Int8Array]',
  10920. int16Tag = '[object Int16Array]',
  10921. int32Tag = '[object Int32Array]',
  10922. uint8Tag = '[object Uint8Array]',
  10923. uint8ClampedTag = '[object Uint8ClampedArray]',
  10924. uint16Tag = '[object Uint16Array]',
  10925. uint32Tag = '[object Uint32Array]';
  10926. /** Used to identify `toStringTag` values of typed arrays. */
  10927. var typedArrayTags = {};
  10928. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  10929. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  10930. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  10931. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  10932. typedArrayTags[uint32Tag] = true;
  10933. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
  10934. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  10935. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  10936. typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
  10937. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  10938. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  10939. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  10940. typedArrayTags[weakMapTag] = false;
  10941. /**
  10942. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  10943. *
  10944. * @private
  10945. * @param {*} value The value to check.
  10946. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10947. */
  10948. function baseIsTypedArray(value) {
  10949. return isObjectLike_1(value) &&
  10950. isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
  10951. }
  10952. var _baseIsTypedArray = baseIsTypedArray;
  10953. /**
  10954. * The base implementation of `_.unary` without support for storing metadata.
  10955. *
  10956. * @private
  10957. * @param {Function} func The function to cap arguments for.
  10958. * @returns {Function} Returns the new capped function.
  10959. */
  10960. function baseUnary(func) {
  10961. return function(value) {
  10962. return func(value);
  10963. };
  10964. }
  10965. var _baseUnary = baseUnary;
  10966. var _nodeUtil = createCommonjsModule(function (module, exports) {
  10967. /** Detect free variable `exports`. */
  10968. var freeExports = exports && !exports.nodeType && exports;
  10969. /** Detect free variable `module`. */
  10970. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  10971. /** Detect the popular CommonJS extension `module.exports`. */
  10972. var moduleExports = freeModule && freeModule.exports === freeExports;
  10973. /** Detect free variable `process` from Node.js. */
  10974. var freeProcess = moduleExports && _freeGlobal.process;
  10975. /** Used to access faster Node.js helpers. */
  10976. var nodeUtil = (function() {
  10977. try {
  10978. // Use `util.types` for Node.js 10+.
  10979. var types = freeModule && freeModule.require && freeModule.require('util').types;
  10980. if (types) {
  10981. return types;
  10982. }
  10983. // Legacy `process.binding('util')` for Node.js < 10.
  10984. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  10985. } catch (e) {}
  10986. }());
  10987. module.exports = nodeUtil;
  10988. });
  10989. /* Node.js helper references. */
  10990. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  10991. /**
  10992. * Checks if `value` is classified as a typed array.
  10993. *
  10994. * @static
  10995. * @memberOf _
  10996. * @since 3.0.0
  10997. * @category Lang
  10998. * @param {*} value The value to check.
  10999. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  11000. * @example
  11001. *
  11002. * _.isTypedArray(new Uint8Array);
  11003. * // => true
  11004. *
  11005. * _.isTypedArray([]);
  11006. * // => false
  11007. */
  11008. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  11009. var isTypedArray_1 = isTypedArray;
  11010. /** Used for built-in method references. */
  11011. var objectProto$7 = Object.prototype;
  11012. /** Used to check objects for own properties. */
  11013. var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
  11014. /**
  11015. * Creates an array of the enumerable property names of the array-like `value`.
  11016. *
  11017. * @private
  11018. * @param {*} value The value to query.
  11019. * @param {boolean} inherited Specify returning inherited property names.
  11020. * @returns {Array} Returns the array of property names.
  11021. */
  11022. function arrayLikeKeys(value, inherited) {
  11023. var isArr = isArray_1(value),
  11024. isArg = !isArr && isArguments_1(value),
  11025. isBuff = !isArr && !isArg && isBuffer_1$1(value),
  11026. isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
  11027. skipIndexes = isArr || isArg || isBuff || isType,
  11028. result = skipIndexes ? _baseTimes(value.length, String) : [],
  11029. length = result.length;
  11030. for (var key in value) {
  11031. if ((inherited || hasOwnProperty$7.call(value, key)) &&
  11032. !(skipIndexes && (
  11033. // Safari 9 has enumerable `arguments.length` in strict mode.
  11034. key == 'length' ||
  11035. // Node.js 0.10 has enumerable non-index properties on buffers.
  11036. (isBuff && (key == 'offset' || key == 'parent')) ||
  11037. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  11038. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  11039. // Skip index properties.
  11040. _isIndex(key, length)
  11041. ))) {
  11042. result.push(key);
  11043. }
  11044. }
  11045. return result;
  11046. }
  11047. var _arrayLikeKeys = arrayLikeKeys;
  11048. /** Used for built-in method references. */
  11049. var objectProto$8 = Object.prototype;
  11050. /**
  11051. * Checks if `value` is likely a prototype object.
  11052. *
  11053. * @private
  11054. * @param {*} value The value to check.
  11055. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  11056. */
  11057. function isPrototype(value) {
  11058. var Ctor = value && value.constructor,
  11059. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
  11060. return value === proto;
  11061. }
  11062. var _isPrototype = isPrototype;
  11063. /**
  11064. * Creates a unary function that invokes `func` with its argument transformed.
  11065. *
  11066. * @private
  11067. * @param {Function} func The function to wrap.
  11068. * @param {Function} transform The argument transform.
  11069. * @returns {Function} Returns the new function.
  11070. */
  11071. function overArg(func, transform) {
  11072. return function(arg) {
  11073. return func(transform(arg));
  11074. };
  11075. }
  11076. var _overArg = overArg;
  11077. /* Built-in method references for those with the same name as other `lodash` methods. */
  11078. var nativeKeys = _overArg(Object.keys, Object);
  11079. var _nativeKeys = nativeKeys;
  11080. /** Used for built-in method references. */
  11081. var objectProto$9 = Object.prototype;
  11082. /** Used to check objects for own properties. */
  11083. var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
  11084. /**
  11085. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  11086. *
  11087. * @private
  11088. * @param {Object} object The object to query.
  11089. * @returns {Array} Returns the array of property names.
  11090. */
  11091. function baseKeys(object) {
  11092. if (!_isPrototype(object)) {
  11093. return _nativeKeys(object);
  11094. }
  11095. var result = [];
  11096. for (var key in Object(object)) {
  11097. if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
  11098. result.push(key);
  11099. }
  11100. }
  11101. return result;
  11102. }
  11103. var _baseKeys = baseKeys;
  11104. /**
  11105. * Checks if `value` is array-like. A value is considered array-like if it's
  11106. * not a function and has a `value.length` that's an integer greater than or
  11107. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11108. *
  11109. * @static
  11110. * @memberOf _
  11111. * @since 4.0.0
  11112. * @category Lang
  11113. * @param {*} value The value to check.
  11114. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11115. * @example
  11116. *
  11117. * _.isArrayLike([1, 2, 3]);
  11118. * // => true
  11119. *
  11120. * _.isArrayLike(document.body.children);
  11121. * // => true
  11122. *
  11123. * _.isArrayLike('abc');
  11124. * // => true
  11125. *
  11126. * _.isArrayLike(_.noop);
  11127. * // => false
  11128. */
  11129. function isArrayLike(value) {
  11130. return value != null && isLength_1(value.length) && !isFunction_1(value);
  11131. }
  11132. var isArrayLike_1 = isArrayLike;
  11133. /**
  11134. * Creates an array of the own enumerable property names of `object`.
  11135. *
  11136. * **Note:** Non-object values are coerced to objects. See the
  11137. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11138. * for more details.
  11139. *
  11140. * @static
  11141. * @since 0.1.0
  11142. * @memberOf _
  11143. * @category Object
  11144. * @param {Object} object The object to query.
  11145. * @returns {Array} Returns the array of property names.
  11146. * @example
  11147. *
  11148. * function Foo() {
  11149. * this.a = 1;
  11150. * this.b = 2;
  11151. * }
  11152. *
  11153. * Foo.prototype.c = 3;
  11154. *
  11155. * _.keys(new Foo);
  11156. * // => ['a', 'b'] (iteration order is not guaranteed)
  11157. *
  11158. * _.keys('hi');
  11159. * // => ['0', '1']
  11160. */
  11161. function keys$1(object) {
  11162. return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  11163. }
  11164. var keys_1 = keys$1;
  11165. /**
  11166. * The base implementation of `_.assign` without support for multiple sources
  11167. * or `customizer` functions.
  11168. *
  11169. * @private
  11170. * @param {Object} object The destination object.
  11171. * @param {Object} source The source object.
  11172. * @returns {Object} Returns `object`.
  11173. */
  11174. function baseAssign(object, source) {
  11175. return object && _copyObject(source, keys_1(source), object);
  11176. }
  11177. var _baseAssign = baseAssign;
  11178. /**
  11179. * This function is like
  11180. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11181. * except that it includes inherited enumerable properties.
  11182. *
  11183. * @private
  11184. * @param {Object} object The object to query.
  11185. * @returns {Array} Returns the array of property names.
  11186. */
  11187. function nativeKeysIn(object) {
  11188. var result = [];
  11189. if (object != null) {
  11190. for (var key in Object(object)) {
  11191. result.push(key);
  11192. }
  11193. }
  11194. return result;
  11195. }
  11196. var _nativeKeysIn = nativeKeysIn;
  11197. /** Used for built-in method references. */
  11198. var objectProto$a = Object.prototype;
  11199. /** Used to check objects for own properties. */
  11200. var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
  11201. /**
  11202. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  11203. *
  11204. * @private
  11205. * @param {Object} object The object to query.
  11206. * @returns {Array} Returns the array of property names.
  11207. */
  11208. function baseKeysIn(object) {
  11209. if (!isObject_1(object)) {
  11210. return _nativeKeysIn(object);
  11211. }
  11212. var isProto = _isPrototype(object),
  11213. result = [];
  11214. for (var key in object) {
  11215. if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
  11216. result.push(key);
  11217. }
  11218. }
  11219. return result;
  11220. }
  11221. var _baseKeysIn = baseKeysIn;
  11222. /**
  11223. * Creates an array of the own and inherited enumerable property names of `object`.
  11224. *
  11225. * **Note:** Non-object values are coerced to objects.
  11226. *
  11227. * @static
  11228. * @memberOf _
  11229. * @since 3.0.0
  11230. * @category Object
  11231. * @param {Object} object The object to query.
  11232. * @returns {Array} Returns the array of property names.
  11233. * @example
  11234. *
  11235. * function Foo() {
  11236. * this.a = 1;
  11237. * this.b = 2;
  11238. * }
  11239. *
  11240. * Foo.prototype.c = 3;
  11241. *
  11242. * _.keysIn(new Foo);
  11243. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  11244. */
  11245. function keysIn(object) {
  11246. return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
  11247. }
  11248. var keysIn_1 = keysIn;
  11249. /**
  11250. * The base implementation of `_.assignIn` without support for multiple sources
  11251. * or `customizer` functions.
  11252. *
  11253. * @private
  11254. * @param {Object} object The destination object.
  11255. * @param {Object} source The source object.
  11256. * @returns {Object} Returns `object`.
  11257. */
  11258. function baseAssignIn(object, source) {
  11259. return object && _copyObject(source, keysIn_1(source), object);
  11260. }
  11261. var _baseAssignIn = baseAssignIn;
  11262. var _cloneBuffer = createCommonjsModule(function (module, exports) {
  11263. /** Detect free variable `exports`. */
  11264. var freeExports = exports && !exports.nodeType && exports;
  11265. /** Detect free variable `module`. */
  11266. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  11267. /** Detect the popular CommonJS extension `module.exports`. */
  11268. var moduleExports = freeModule && freeModule.exports === freeExports;
  11269. /** Built-in value references. */
  11270. var Buffer = moduleExports ? _root.Buffer : undefined,
  11271. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  11272. /**
  11273. * Creates a clone of `buffer`.
  11274. *
  11275. * @private
  11276. * @param {Buffer} buffer The buffer to clone.
  11277. * @param {boolean} [isDeep] Specify a deep clone.
  11278. * @returns {Buffer} Returns the cloned buffer.
  11279. */
  11280. function cloneBuffer(buffer, isDeep) {
  11281. if (isDeep) {
  11282. return buffer.slice();
  11283. }
  11284. var length = buffer.length,
  11285. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  11286. buffer.copy(result);
  11287. return result;
  11288. }
  11289. module.exports = cloneBuffer;
  11290. });
  11291. /**
  11292. * Copies the values of `source` to `array`.
  11293. *
  11294. * @private
  11295. * @param {Array} source The array to copy values from.
  11296. * @param {Array} [array=[]] The array to copy values to.
  11297. * @returns {Array} Returns `array`.
  11298. */
  11299. function copyArray(source, array) {
  11300. var index = -1,
  11301. length = source.length;
  11302. array || (array = Array(length));
  11303. while (++index < length) {
  11304. array[index] = source[index];
  11305. }
  11306. return array;
  11307. }
  11308. var _copyArray = copyArray;
  11309. /**
  11310. * A specialized version of `_.filter` for arrays without support for
  11311. * iteratee shorthands.
  11312. *
  11313. * @private
  11314. * @param {Array} [array] The array to iterate over.
  11315. * @param {Function} predicate The function invoked per iteration.
  11316. * @returns {Array} Returns the new filtered array.
  11317. */
  11318. function arrayFilter(array, predicate) {
  11319. var index = -1,
  11320. length = array == null ? 0 : array.length,
  11321. resIndex = 0,
  11322. result = [];
  11323. while (++index < length) {
  11324. var value = array[index];
  11325. if (predicate(value, index, array)) {
  11326. result[resIndex++] = value;
  11327. }
  11328. }
  11329. return result;
  11330. }
  11331. var _arrayFilter = arrayFilter;
  11332. /**
  11333. * This method returns a new empty array.
  11334. *
  11335. * @static
  11336. * @memberOf _
  11337. * @since 4.13.0
  11338. * @category Util
  11339. * @returns {Array} Returns the new empty array.
  11340. * @example
  11341. *
  11342. * var arrays = _.times(2, _.stubArray);
  11343. *
  11344. * console.log(arrays);
  11345. * // => [[], []]
  11346. *
  11347. * console.log(arrays[0] === arrays[1]);
  11348. * // => false
  11349. */
  11350. function stubArray() {
  11351. return [];
  11352. }
  11353. var stubArray_1 = stubArray;
  11354. /** Used for built-in method references. */
  11355. var objectProto$b = Object.prototype;
  11356. /** Built-in value references. */
  11357. var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
  11358. /* Built-in method references for those with the same name as other `lodash` methods. */
  11359. var nativeGetSymbols = Object.getOwnPropertySymbols;
  11360. /**
  11361. * Creates an array of the own enumerable symbols of `object`.
  11362. *
  11363. * @private
  11364. * @param {Object} object The object to query.
  11365. * @returns {Array} Returns the array of symbols.
  11366. */
  11367. var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
  11368. if (object == null) {
  11369. return [];
  11370. }
  11371. object = Object(object);
  11372. return _arrayFilter(nativeGetSymbols(object), function(symbol) {
  11373. return propertyIsEnumerable$1.call(object, symbol);
  11374. });
  11375. };
  11376. var _getSymbols = getSymbols;
  11377. /**
  11378. * Copies own symbols of `source` to `object`.
  11379. *
  11380. * @private
  11381. * @param {Object} source The object to copy symbols from.
  11382. * @param {Object} [object={}] The object to copy symbols to.
  11383. * @returns {Object} Returns `object`.
  11384. */
  11385. function copySymbols(source, object) {
  11386. return _copyObject(source, _getSymbols(source), object);
  11387. }
  11388. var _copySymbols = copySymbols;
  11389. /**
  11390. * Appends the elements of `values` to `array`.
  11391. *
  11392. * @private
  11393. * @param {Array} array The array to modify.
  11394. * @param {Array} values The values to append.
  11395. * @returns {Array} Returns `array`.
  11396. */
  11397. function arrayPush(array, values) {
  11398. var index = -1,
  11399. length = values.length,
  11400. offset = array.length;
  11401. while (++index < length) {
  11402. array[offset + index] = values[index];
  11403. }
  11404. return array;
  11405. }
  11406. var _arrayPush = arrayPush;
  11407. /** Built-in value references. */
  11408. var getPrototype = _overArg(Object.getPrototypeOf, Object);
  11409. var _getPrototype = getPrototype;
  11410. /* Built-in method references for those with the same name as other `lodash` methods. */
  11411. var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
  11412. /**
  11413. * Creates an array of the own and inherited enumerable symbols of `object`.
  11414. *
  11415. * @private
  11416. * @param {Object} object The object to query.
  11417. * @returns {Array} Returns the array of symbols.
  11418. */
  11419. var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
  11420. var result = [];
  11421. while (object) {
  11422. _arrayPush(result, _getSymbols(object));
  11423. object = _getPrototype(object);
  11424. }
  11425. return result;
  11426. };
  11427. var _getSymbolsIn = getSymbolsIn;
  11428. /**
  11429. * Copies own and inherited symbols of `source` to `object`.
  11430. *
  11431. * @private
  11432. * @param {Object} source The object to copy symbols from.
  11433. * @param {Object} [object={}] The object to copy symbols to.
  11434. * @returns {Object} Returns `object`.
  11435. */
  11436. function copySymbolsIn(source, object) {
  11437. return _copyObject(source, _getSymbolsIn(source), object);
  11438. }
  11439. var _copySymbolsIn = copySymbolsIn;
  11440. /**
  11441. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  11442. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  11443. * symbols of `object`.
  11444. *
  11445. * @private
  11446. * @param {Object} object The object to query.
  11447. * @param {Function} keysFunc The function to get the keys of `object`.
  11448. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  11449. * @returns {Array} Returns the array of property names and symbols.
  11450. */
  11451. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  11452. var result = keysFunc(object);
  11453. return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
  11454. }
  11455. var _baseGetAllKeys = baseGetAllKeys;
  11456. /**
  11457. * Creates an array of own enumerable property names and symbols of `object`.
  11458. *
  11459. * @private
  11460. * @param {Object} object The object to query.
  11461. * @returns {Array} Returns the array of property names and symbols.
  11462. */
  11463. function getAllKeys(object) {
  11464. return _baseGetAllKeys(object, keys_1, _getSymbols);
  11465. }
  11466. var _getAllKeys = getAllKeys;
  11467. /**
  11468. * Creates an array of own and inherited enumerable property names and
  11469. * symbols of `object`.
  11470. *
  11471. * @private
  11472. * @param {Object} object The object to query.
  11473. * @returns {Array} Returns the array of property names and symbols.
  11474. */
  11475. function getAllKeysIn(object) {
  11476. return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
  11477. }
  11478. var _getAllKeysIn = getAllKeysIn;
  11479. /* Built-in method references that are verified to be native. */
  11480. var DataView = _getNative(_root, 'DataView');
  11481. var _DataView = DataView;
  11482. /* Built-in method references that are verified to be native. */
  11483. var Promise$1 = _getNative(_root, 'Promise');
  11484. var _Promise = Promise$1;
  11485. /* Built-in method references that are verified to be native. */
  11486. var Set$1 = _getNative(_root, 'Set');
  11487. var _Set = Set$1;
  11488. /* Built-in method references that are verified to be native. */
  11489. var WeakMap = _getNative(_root, 'WeakMap');
  11490. var _WeakMap = WeakMap;
  11491. /** `Object#toString` result references. */
  11492. var mapTag$1 = '[object Map]',
  11493. objectTag$1 = '[object Object]',
  11494. promiseTag = '[object Promise]',
  11495. setTag$1 = '[object Set]',
  11496. weakMapTag$1 = '[object WeakMap]';
  11497. var dataViewTag$1 = '[object DataView]';
  11498. /** Used to detect maps, sets, and weakmaps. */
  11499. var dataViewCtorString = _toSource(_DataView),
  11500. mapCtorString = _toSource(_Map),
  11501. promiseCtorString = _toSource(_Promise),
  11502. setCtorString = _toSource(_Set),
  11503. weakMapCtorString = _toSource(_WeakMap);
  11504. /**
  11505. * Gets the `toStringTag` of `value`.
  11506. *
  11507. * @private
  11508. * @param {*} value The value to query.
  11509. * @returns {string} Returns the `toStringTag`.
  11510. */
  11511. var getTag = _baseGetTag;
  11512. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  11513. if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
  11514. (_Map && getTag(new _Map) != mapTag$1) ||
  11515. (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
  11516. (_Set && getTag(new _Set) != setTag$1) ||
  11517. (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
  11518. getTag = function(value) {
  11519. var result = _baseGetTag(value),
  11520. Ctor = result == objectTag$1 ? value.constructor : undefined,
  11521. ctorString = Ctor ? _toSource(Ctor) : '';
  11522. if (ctorString) {
  11523. switch (ctorString) {
  11524. case dataViewCtorString: return dataViewTag$1;
  11525. case mapCtorString: return mapTag$1;
  11526. case promiseCtorString: return promiseTag;
  11527. case setCtorString: return setTag$1;
  11528. case weakMapCtorString: return weakMapTag$1;
  11529. }
  11530. }
  11531. return result;
  11532. };
  11533. }
  11534. var _getTag = getTag;
  11535. /** Used for built-in method references. */
  11536. var objectProto$c = Object.prototype;
  11537. /** Used to check objects for own properties. */
  11538. var hasOwnProperty$a = objectProto$c.hasOwnProperty;
  11539. /**
  11540. * Initializes an array clone.
  11541. *
  11542. * @private
  11543. * @param {Array} array The array to clone.
  11544. * @returns {Array} Returns the initialized clone.
  11545. */
  11546. function initCloneArray(array) {
  11547. var length = array.length,
  11548. result = new array.constructor(length);
  11549. // Add properties assigned by `RegExp#exec`.
  11550. if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
  11551. result.index = array.index;
  11552. result.input = array.input;
  11553. }
  11554. return result;
  11555. }
  11556. var _initCloneArray = initCloneArray;
  11557. /** Built-in value references. */
  11558. var Uint8Array = _root.Uint8Array;
  11559. var _Uint8Array = Uint8Array;
  11560. /**
  11561. * Creates a clone of `arrayBuffer`.
  11562. *
  11563. * @private
  11564. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  11565. * @returns {ArrayBuffer} Returns the cloned array buffer.
  11566. */
  11567. function cloneArrayBuffer(arrayBuffer) {
  11568. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  11569. new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  11570. return result;
  11571. }
  11572. var _cloneArrayBuffer = cloneArrayBuffer;
  11573. /**
  11574. * Creates a clone of `dataView`.
  11575. *
  11576. * @private
  11577. * @param {Object} dataView The data view to clone.
  11578. * @param {boolean} [isDeep] Specify a deep clone.
  11579. * @returns {Object} Returns the cloned data view.
  11580. */
  11581. function cloneDataView(dataView, isDeep) {
  11582. var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  11583. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  11584. }
  11585. var _cloneDataView = cloneDataView;
  11586. /** Used to match `RegExp` flags from their coerced string values. */
  11587. var reFlags = /\w*$/;
  11588. /**
  11589. * Creates a clone of `regexp`.
  11590. *
  11591. * @private
  11592. * @param {Object} regexp The regexp to clone.
  11593. * @returns {Object} Returns the cloned regexp.
  11594. */
  11595. function cloneRegExp(regexp) {
  11596. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  11597. result.lastIndex = regexp.lastIndex;
  11598. return result;
  11599. }
  11600. var _cloneRegExp = cloneRegExp;
  11601. /** Used to convert symbols to primitives and strings. */
  11602. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  11603. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  11604. /**
  11605. * Creates a clone of the `symbol` object.
  11606. *
  11607. * @private
  11608. * @param {Object} symbol The symbol object to clone.
  11609. * @returns {Object} Returns the cloned symbol object.
  11610. */
  11611. function cloneSymbol(symbol) {
  11612. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  11613. }
  11614. var _cloneSymbol = cloneSymbol;
  11615. /**
  11616. * Creates a clone of `typedArray`.
  11617. *
  11618. * @private
  11619. * @param {Object} typedArray The typed array to clone.
  11620. * @param {boolean} [isDeep] Specify a deep clone.
  11621. * @returns {Object} Returns the cloned typed array.
  11622. */
  11623. function cloneTypedArray(typedArray, isDeep) {
  11624. var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  11625. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  11626. }
  11627. var _cloneTypedArray = cloneTypedArray;
  11628. /** `Object#toString` result references. */
  11629. var boolTag$1 = '[object Boolean]',
  11630. dateTag$1 = '[object Date]',
  11631. mapTag$2 = '[object Map]',
  11632. numberTag$1 = '[object Number]',
  11633. regexpTag$1 = '[object RegExp]',
  11634. setTag$2 = '[object Set]',
  11635. stringTag$1 = '[object String]',
  11636. symbolTag = '[object Symbol]';
  11637. var arrayBufferTag$1 = '[object ArrayBuffer]',
  11638. dataViewTag$2 = '[object DataView]',
  11639. float32Tag$1 = '[object Float32Array]',
  11640. float64Tag$1 = '[object Float64Array]',
  11641. int8Tag$1 = '[object Int8Array]',
  11642. int16Tag$1 = '[object Int16Array]',
  11643. int32Tag$1 = '[object Int32Array]',
  11644. uint8Tag$1 = '[object Uint8Array]',
  11645. uint8ClampedTag$1 = '[object Uint8ClampedArray]',
  11646. uint16Tag$1 = '[object Uint16Array]',
  11647. uint32Tag$1 = '[object Uint32Array]';
  11648. /**
  11649. * Initializes an object clone based on its `toStringTag`.
  11650. *
  11651. * **Note:** This function only supports cloning values with tags of
  11652. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  11653. *
  11654. * @private
  11655. * @param {Object} object The object to clone.
  11656. * @param {string} tag The `toStringTag` of the object to clone.
  11657. * @param {boolean} [isDeep] Specify a deep clone.
  11658. * @returns {Object} Returns the initialized clone.
  11659. */
  11660. function initCloneByTag(object, tag, isDeep) {
  11661. var Ctor = object.constructor;
  11662. switch (tag) {
  11663. case arrayBufferTag$1:
  11664. return _cloneArrayBuffer(object);
  11665. case boolTag$1:
  11666. case dateTag$1:
  11667. return new Ctor(+object);
  11668. case dataViewTag$2:
  11669. return _cloneDataView(object, isDeep);
  11670. case float32Tag$1: case float64Tag$1:
  11671. case int8Tag$1: case int16Tag$1: case int32Tag$1:
  11672. case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
  11673. return _cloneTypedArray(object, isDeep);
  11674. case mapTag$2:
  11675. return new Ctor;
  11676. case numberTag$1:
  11677. case stringTag$1:
  11678. return new Ctor(object);
  11679. case regexpTag$1:
  11680. return _cloneRegExp(object);
  11681. case setTag$2:
  11682. return new Ctor;
  11683. case symbolTag:
  11684. return _cloneSymbol(object);
  11685. }
  11686. }
  11687. var _initCloneByTag = initCloneByTag;
  11688. /** Built-in value references. */
  11689. var objectCreate = Object.create;
  11690. /**
  11691. * The base implementation of `_.create` without support for assigning
  11692. * properties to the created object.
  11693. *
  11694. * @private
  11695. * @param {Object} proto The object to inherit from.
  11696. * @returns {Object} Returns the new object.
  11697. */
  11698. var baseCreate = (function() {
  11699. function object() {}
  11700. return function(proto) {
  11701. if (!isObject_1(proto)) {
  11702. return {};
  11703. }
  11704. if (objectCreate) {
  11705. return objectCreate(proto);
  11706. }
  11707. object.prototype = proto;
  11708. var result = new object;
  11709. object.prototype = undefined;
  11710. return result;
  11711. };
  11712. }());
  11713. var _baseCreate = baseCreate;
  11714. /**
  11715. * Initializes an object clone.
  11716. *
  11717. * @private
  11718. * @param {Object} object The object to clone.
  11719. * @returns {Object} Returns the initialized clone.
  11720. */
  11721. function initCloneObject(object) {
  11722. return (typeof object.constructor == 'function' && !_isPrototype(object))
  11723. ? _baseCreate(_getPrototype(object))
  11724. : {};
  11725. }
  11726. var _initCloneObject = initCloneObject;
  11727. /** `Object#toString` result references. */
  11728. var mapTag$3 = '[object Map]';
  11729. /**
  11730. * The base implementation of `_.isMap` without Node.js optimizations.
  11731. *
  11732. * @private
  11733. * @param {*} value The value to check.
  11734. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11735. */
  11736. function baseIsMap(value) {
  11737. return isObjectLike_1(value) && _getTag(value) == mapTag$3;
  11738. }
  11739. var _baseIsMap = baseIsMap;
  11740. /* Node.js helper references. */
  11741. var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
  11742. /**
  11743. * Checks if `value` is classified as a `Map` object.
  11744. *
  11745. * @static
  11746. * @memberOf _
  11747. * @since 4.3.0
  11748. * @category Lang
  11749. * @param {*} value The value to check.
  11750. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11751. * @example
  11752. *
  11753. * _.isMap(new Map);
  11754. * // => true
  11755. *
  11756. * _.isMap(new WeakMap);
  11757. * // => false
  11758. */
  11759. var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
  11760. var isMap_1 = isMap;
  11761. /** `Object#toString` result references. */
  11762. var setTag$3 = '[object Set]';
  11763. /**
  11764. * The base implementation of `_.isSet` without Node.js optimizations.
  11765. *
  11766. * @private
  11767. * @param {*} value The value to check.
  11768. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  11769. */
  11770. function baseIsSet(value) {
  11771. return isObjectLike_1(value) && _getTag(value) == setTag$3;
  11772. }
  11773. var _baseIsSet = baseIsSet;
  11774. /* Node.js helper references. */
  11775. var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
  11776. /**
  11777. * Checks if `value` is classified as a `Set` object.
  11778. *
  11779. * @static
  11780. * @memberOf _
  11781. * @since 4.3.0
  11782. * @category Lang
  11783. * @param {*} value The value to check.
  11784. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  11785. * @example
  11786. *
  11787. * _.isSet(new Set);
  11788. * // => true
  11789. *
  11790. * _.isSet(new WeakSet);
  11791. * // => false
  11792. */
  11793. var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
  11794. var isSet_1 = isSet;
  11795. /** Used to compose bitmasks for cloning. */
  11796. var CLONE_DEEP_FLAG = 1,
  11797. CLONE_FLAT_FLAG = 2,
  11798. CLONE_SYMBOLS_FLAG = 4;
  11799. /** `Object#toString` result references. */
  11800. var argsTag$2 = '[object Arguments]',
  11801. arrayTag$1 = '[object Array]',
  11802. boolTag$2 = '[object Boolean]',
  11803. dateTag$2 = '[object Date]',
  11804. errorTag$1 = '[object Error]',
  11805. funcTag$2 = '[object Function]',
  11806. genTag$1 = '[object GeneratorFunction]',
  11807. mapTag$4 = '[object Map]',
  11808. numberTag$2 = '[object Number]',
  11809. objectTag$2 = '[object Object]',
  11810. regexpTag$2 = '[object RegExp]',
  11811. setTag$4 = '[object Set]',
  11812. stringTag$2 = '[object String]',
  11813. symbolTag$1 = '[object Symbol]',
  11814. weakMapTag$2 = '[object WeakMap]';
  11815. var arrayBufferTag$2 = '[object ArrayBuffer]',
  11816. dataViewTag$3 = '[object DataView]',
  11817. float32Tag$2 = '[object Float32Array]',
  11818. float64Tag$2 = '[object Float64Array]',
  11819. int8Tag$2 = '[object Int8Array]',
  11820. int16Tag$2 = '[object Int16Array]',
  11821. int32Tag$2 = '[object Int32Array]',
  11822. uint8Tag$2 = '[object Uint8Array]',
  11823. uint8ClampedTag$2 = '[object Uint8ClampedArray]',
  11824. uint16Tag$2 = '[object Uint16Array]',
  11825. uint32Tag$2 = '[object Uint32Array]';
  11826. /** Used to identify `toStringTag` values supported by `_.clone`. */
  11827. var cloneableTags = {};
  11828. cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
  11829. cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
  11830. cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
  11831. cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
  11832. cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
  11833. cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
  11834. cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
  11835. cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
  11836. cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
  11837. cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
  11838. cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
  11839. cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
  11840. cloneableTags[weakMapTag$2] = false;
  11841. /**
  11842. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  11843. * traversed objects.
  11844. *
  11845. * @private
  11846. * @param {*} value The value to clone.
  11847. * @param {boolean} bitmask The bitmask flags.
  11848. * 1 - Deep clone
  11849. * 2 - Flatten inherited properties
  11850. * 4 - Clone symbols
  11851. * @param {Function} [customizer] The function to customize cloning.
  11852. * @param {string} [key] The key of `value`.
  11853. * @param {Object} [object] The parent object of `value`.
  11854. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  11855. * @returns {*} Returns the cloned value.
  11856. */
  11857. function baseClone(value, bitmask, customizer, key, object, stack) {
  11858. var result,
  11859. isDeep = bitmask & CLONE_DEEP_FLAG,
  11860. isFlat = bitmask & CLONE_FLAT_FLAG,
  11861. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  11862. if (customizer) {
  11863. result = object ? customizer(value, key, object, stack) : customizer(value);
  11864. }
  11865. if (result !== undefined) {
  11866. return result;
  11867. }
  11868. if (!isObject_1(value)) {
  11869. return value;
  11870. }
  11871. var isArr = isArray_1(value);
  11872. if (isArr) {
  11873. result = _initCloneArray(value);
  11874. if (!isDeep) {
  11875. return _copyArray(value, result);
  11876. }
  11877. } else {
  11878. var tag = _getTag(value),
  11879. isFunc = tag == funcTag$2 || tag == genTag$1;
  11880. if (isBuffer_1$1(value)) {
  11881. return _cloneBuffer(value, isDeep);
  11882. }
  11883. if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
  11884. result = (isFlat || isFunc) ? {} : _initCloneObject(value);
  11885. if (!isDeep) {
  11886. return isFlat
  11887. ? _copySymbolsIn(value, _baseAssignIn(result, value))
  11888. : _copySymbols(value, _baseAssign(result, value));
  11889. }
  11890. } else {
  11891. if (!cloneableTags[tag]) {
  11892. return object ? value : {};
  11893. }
  11894. result = _initCloneByTag(value, tag, isDeep);
  11895. }
  11896. }
  11897. // Check for circular references and return its corresponding clone.
  11898. stack || (stack = new _Stack);
  11899. var stacked = stack.get(value);
  11900. if (stacked) {
  11901. return stacked;
  11902. }
  11903. stack.set(value, result);
  11904. if (isSet_1(value)) {
  11905. value.forEach(function(subValue) {
  11906. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  11907. });
  11908. } else if (isMap_1(value)) {
  11909. value.forEach(function(subValue, key) {
  11910. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  11911. });
  11912. }
  11913. var keysFunc = isFull
  11914. ? (isFlat ? _getAllKeysIn : _getAllKeys)
  11915. : (isFlat ? keysIn_1 : keys_1);
  11916. var props = isArr ? undefined : keysFunc(value);
  11917. _arrayEach(props || value, function(subValue, key) {
  11918. if (props) {
  11919. key = subValue;
  11920. subValue = value[key];
  11921. }
  11922. // Recursively populate clone (susceptible to call stack limits).
  11923. _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  11924. });
  11925. return result;
  11926. }
  11927. var _baseClone = baseClone;
  11928. /** Used to compose bitmasks for cloning. */
  11929. var CLONE_DEEP_FLAG$1 = 1,
  11930. CLONE_SYMBOLS_FLAG$1 = 4;
  11931. /**
  11932. * This method is like `_.clone` except that it recursively clones `value`.
  11933. *
  11934. * @static
  11935. * @memberOf _
  11936. * @since 1.0.0
  11937. * @category Lang
  11938. * @param {*} value The value to recursively clone.
  11939. * @returns {*} Returns the deep cloned value.
  11940. * @see _.clone
  11941. * @example
  11942. *
  11943. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11944. *
  11945. * var deep = _.cloneDeep(objects);
  11946. * console.log(deep[0] === objects[0]);
  11947. * // => false
  11948. */
  11949. function cloneDeep(value) {
  11950. return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
  11951. }
  11952. var cloneDeep_1 = cloneDeep;
  11953. //
  11954. /**
  11955. * Used internally by vue-server-test-utils and test-utils to propagate/create vue instances.
  11956. * This method is wrapped by createLocalVue in test-utils to provide a different public API signature
  11957. * @param {Component} _Vue
  11958. * @param {VueConfig} config
  11959. * @returns {Component}
  11960. */
  11961. function _createLocalVue(
  11962. _Vue,
  11963. config
  11964. ) {
  11965. if ( _Vue === void 0 ) _Vue = Vue__default['default'];
  11966. if ( config === void 0 ) config = {};
  11967. var instance = _Vue.extend();
  11968. // clone global APIs
  11969. Object.keys(_Vue).forEach(function (key) {
  11970. if (!instance.hasOwnProperty(key)) {
  11971. var original = _Vue[key];
  11972. // cloneDeep can fail when cloning Vue instances
  11973. // cloneDeep checks that the instance has a Symbol
  11974. // which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
  11975. try {
  11976. instance[key] =
  11977. typeof original === 'object' ? cloneDeep_1(original) : original;
  11978. } catch (e) {
  11979. instance[key] = original;
  11980. }
  11981. }
  11982. });
  11983. // config is not enumerable
  11984. instance.config = cloneDeep_1(Vue__default['default'].config);
  11985. // if a user defined errorHandler is defined by a localVue instance via createLocalVue, register it
  11986. instance.config.errorHandler = config.errorHandler;
  11987. // option merge strategies need to be exposed by reference
  11988. // so that merge strats registered by plugins can work properly
  11989. instance.config.optionMergeStrategies = Vue__default['default'].config.optionMergeStrategies;
  11990. // make sure all extends are based on this instance.
  11991. // this is important so that global components registered by plugins,
  11992. // e.g. router-link are created using the correct base constructor
  11993. instance.options._base = instance;
  11994. // compat for vue-router < 2.7.1 where it does not allow multiple installs
  11995. if (instance._installedPlugins && instance._installedPlugins.length) {
  11996. instance._installedPlugins.length = 0;
  11997. }
  11998. var use = instance.use;
  11999. instance.use = function (plugin) {
  12000. var rest = [], len = arguments.length - 1;
  12001. while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
  12002. if (plugin.installed === true) {
  12003. plugin.installed = false;
  12004. }
  12005. if (plugin.install && plugin.install.installed === true) {
  12006. plugin.install.installed = false;
  12007. }
  12008. use.call.apply(use, [ instance, plugin ].concat( rest ));
  12009. };
  12010. return instance
  12011. }
  12012. //
  12013. function isValidSlot(slot) {
  12014. return isVueComponent(slot) || typeof slot === 'string'
  12015. }
  12016. function requiresTemplateCompiler(slot) {
  12017. if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) {
  12018. throwError(
  12019. "vueTemplateCompiler is undefined, you must pass " +
  12020. "precompiled components if vue-template-compiler is " +
  12021. "undefined"
  12022. );
  12023. }
  12024. }
  12025. function validateSlots(slots) {
  12026. Object.keys(slots).forEach(function (key) {
  12027. var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
  12028. slot.forEach(function (slotValue) {
  12029. if (!isValidSlot(slotValue)) {
  12030. throwError(
  12031. "slots[key] must be a Component, string or an array " +
  12032. "of Components"
  12033. );
  12034. }
  12035. requiresTemplateCompiler(slotValue);
  12036. });
  12037. });
  12038. }
  12039. function vueExtendUnsupportedOption(option) {
  12040. return (
  12041. "options." + option + " is not supported for " +
  12042. "components created with Vue.extend in Vue < 2.3. " +
  12043. "You can set " + option + " to false to mount the component."
  12044. )
  12045. }
  12046. // these options aren't supported if Vue is version < 2.3
  12047. // for components using Vue.extend. This is due to a bug
  12048. // that means the mixins we use to add properties are not applied
  12049. // correctly
  12050. var UNSUPPORTED_VERSION_OPTIONS = ['mocks', 'stubs', 'localVue'];
  12051. function validateOptions(options, component) {
  12052. if (
  12053. options.attachTo &&
  12054. !isHTMLElement(options.attachTo) &&
  12055. !isDomSelector(options.attachTo)
  12056. ) {
  12057. throwError(
  12058. "options.attachTo should be a valid HTMLElement or CSS selector string"
  12059. );
  12060. }
  12061. if ('attachToDocument' in options) {
  12062. warnDeprecated(
  12063. "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
  12064. );
  12065. }
  12066. if (options.parentComponent && !isPlainObject(options.parentComponent)) {
  12067. throwError(
  12068. "options.parentComponent should be a valid Vue component options object"
  12069. );
  12070. }
  12071. if (!isFunctionalComponent(component) && options.context) {
  12072. throwError(
  12073. "mount.context can only be used when mounting a functional component"
  12074. );
  12075. }
  12076. if (options.context && !isPlainObject(options.context)) {
  12077. throwError('mount.context must be an object');
  12078. }
  12079. if (VUE_VERSION < 2.3 && isConstructor(component)) {
  12080. UNSUPPORTED_VERSION_OPTIONS.forEach(function (option) {
  12081. if (options[option]) {
  12082. throwError(vueExtendUnsupportedOption(option));
  12083. }
  12084. });
  12085. }
  12086. if (options.slots) {
  12087. compileTemplateForSlots(options.slots);
  12088. // validate slots outside of the createSlots function so
  12089. // that we can throw an error without it being caught by
  12090. // the Vue error handler
  12091. // $FlowIgnore
  12092. validateSlots(options.slots);
  12093. }
  12094. }
  12095. Vue__default['default'].config.productionTip = false;
  12096. Vue__default['default'].config.devtools = false;
  12097. function mount(component, options) {
  12098. if ( options === void 0 ) options = {};
  12099. warnIfNoWindow();
  12100. polyfill();
  12101. addGlobalErrorHandler(Vue__default['default']);
  12102. var _Vue = _createLocalVue(
  12103. options.localVue,
  12104. options.localVue ? options.localVue.config : undefined
  12105. );
  12106. var mergedOptions = mergeOptions(options, config);
  12107. validateOptions(mergedOptions, component);
  12108. var parentVm = createInstance(component, mergedOptions, _Vue);
  12109. var el =
  12110. options.attachToDocument || options.attachTo instanceof HTMLBodyElement
  12111. ? createElement()
  12112. : options.attachTo;
  12113. var vm = parentVm.$mount(el);
  12114. component._Ctor = {};
  12115. throwIfInstancesThrew(vm);
  12116. var wrapperOptions = {
  12117. attachedToDocument: !!el
  12118. };
  12119. var root = parentVm.$options._isFunctionalContainer
  12120. ? vm._vnode
  12121. : vm.$children[0];
  12122. return createWrapper(root, wrapperOptions)
  12123. }
  12124. //
  12125. function shallowMount(
  12126. component,
  12127. options
  12128. ) {
  12129. if ( options === void 0 ) options = {};
  12130. return mount(component, Object.assign({}, options,
  12131. {shouldProxy: true}))
  12132. }
  12133. //
  12134. /**
  12135. * Returns a local vue instance to add components, mixins and install plugins without polluting the global Vue class
  12136. * @param {VueConfig} config
  12137. * @returns {Component}
  12138. */
  12139. function createLocalVue(config) {
  12140. if ( config === void 0 ) config = {};
  12141. return _createLocalVue(undefined, config)
  12142. }
  12143. //
  12144. var toTypes = [String, Object];
  12145. var eventTypes = [String, Array];
  12146. var RouterLinkStub = {
  12147. name: 'RouterLinkStub',
  12148. props: {
  12149. to: {
  12150. type: toTypes,
  12151. required: true
  12152. },
  12153. tag: {
  12154. type: String,
  12155. default: 'a'
  12156. },
  12157. exact: Boolean,
  12158. exactPath: Boolean,
  12159. append: Boolean,
  12160. replace: Boolean,
  12161. activeClass: String,
  12162. exactActiveClass: String,
  12163. exactPathActiveClass: String,
  12164. event: {
  12165. type: eventTypes,
  12166. default: 'click'
  12167. }
  12168. },
  12169. render: function render(h) {
  12170. return h(this.tag, undefined, this.$slots.default)
  12171. }
  12172. };
  12173. function shallow(component, options) {
  12174. warn(
  12175. "shallow has been renamed to shallowMount. shallow " +
  12176. "will be removed in 1.0.0, use shallowMount instead"
  12177. );
  12178. return shallowMount(component, options)
  12179. }
  12180. exports.ErrorWrapper = ErrorWrapper;
  12181. exports.RouterLinkStub = RouterLinkStub;
  12182. exports.Wrapper = Wrapper;
  12183. exports.WrapperArray = WrapperArray;
  12184. exports.config = config;
  12185. exports.createLocalVue = createLocalVue;
  12186. exports.createWrapper = createWrapper;
  12187. exports.enableAutoDestroy = enableAutoDestroy;
  12188. exports.mount = mount;
  12189. exports.resetAutoDestroyState = resetAutoDestroyState;
  12190. exports.shallow = shallow;
  12191. exports.shallowMount = shallowMount;
  12192. Object.defineProperty(exports, '__esModule', { value: true });
  12193. })));