vue-test-utils.js 405 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var Vue = require('vue');
  4. var vueTemplateCompiler = require('vue-template-compiler');
  5. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  6. var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
  7. //
  8. function createVNodes(vm, slotValue, name) {
  9. var el = vueTemplateCompiler.compileToFunctions(
  10. ("<div><template slot=" + name + ">" + slotValue + "</template></div>")
  11. );
  12. var _staticRenderFns = vm._renderProxy.$options.staticRenderFns;
  13. var _staticTrees = vm._renderProxy._staticTrees;
  14. vm._renderProxy._staticTrees = [];
  15. vm._renderProxy.$options.staticRenderFns = el.staticRenderFns;
  16. var vnode = el.render.call(vm._renderProxy, vm.$createElement);
  17. vm._renderProxy.$options.staticRenderFns = _staticRenderFns;
  18. vm._renderProxy._staticTrees = _staticTrees;
  19. return vnode.children[0]
  20. }
  21. function createVNodesForSlot(
  22. vm,
  23. slotValue,
  24. name
  25. ) {
  26. if (typeof slotValue === 'string') {
  27. return createVNodes(vm, slotValue, name)
  28. }
  29. var vnode = vm.$createElement(slotValue)
  30. ;(vnode.data || (vnode.data = {})).slot = name;
  31. return vnode
  32. }
  33. function createSlotVNodes(
  34. vm,
  35. slots
  36. ) {
  37. return Object.keys(slots).reduce(function (acc, key) {
  38. var content = slots[key];
  39. if (Array.isArray(content)) {
  40. var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); }
  41. );
  42. return acc.concat(nodes)
  43. }
  44. return acc.concat(createVNodesForSlot(vm, content, key))
  45. }, [])
  46. }
  47. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  48. function createCommonjsModule(fn, basedir, module) {
  49. return module = {
  50. path: basedir,
  51. exports: {},
  52. require: function (path, base) {
  53. return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
  54. }
  55. }, fn(module, module.exports), module.exports;
  56. }
  57. function getCjsExportFromNamespace (n) {
  58. return n && n['default'] || n;
  59. }
  60. function commonjsRequire () {
  61. throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
  62. }
  63. var semver = createCommonjsModule(function (module, exports) {
  64. exports = module.exports = SemVer;
  65. var debug;
  66. /* istanbul ignore next */
  67. if (typeof process === 'object' &&
  68. process.env &&
  69. process.env.NODE_DEBUG &&
  70. /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
  71. debug = function () {
  72. var args = Array.prototype.slice.call(arguments, 0);
  73. args.unshift('SEMVER');
  74. console.log.apply(console, args);
  75. };
  76. } else {
  77. debug = function () {};
  78. }
  79. // Note: this is the semver.org version of the spec that it implements
  80. // Not necessarily the package version of this code.
  81. exports.SEMVER_SPEC_VERSION = '2.0.0';
  82. var MAX_LENGTH = 256;
  83. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
  84. /* istanbul ignore next */ 9007199254740991;
  85. // Max safe segment length for coercion.
  86. var MAX_SAFE_COMPONENT_LENGTH = 16;
  87. // The actual regexps go on exports.re
  88. var re = exports.re = [];
  89. var src = exports.src = [];
  90. var t = exports.tokens = {};
  91. var R = 0;
  92. function tok (n) {
  93. t[n] = R++;
  94. }
  95. // The following Regular Expressions can be used for tokenizing,
  96. // validating, and parsing SemVer version strings.
  97. // ## Numeric Identifier
  98. // A single `0`, or a non-zero digit followed by zero or more digits.
  99. tok('NUMERICIDENTIFIER');
  100. src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  101. tok('NUMERICIDENTIFIERLOOSE');
  102. src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
  103. // ## Non-numeric Identifier
  104. // Zero or more digits, followed by a letter or hyphen, and then zero or
  105. // more letters, digits, or hyphens.
  106. tok('NONNUMERICIDENTIFIER');
  107. src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
  108. // ## Main Version
  109. // Three dot-separated numeric identifiers.
  110. tok('MAINVERSION');
  111. src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
  112. '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
  113. '(' + src[t.NUMERICIDENTIFIER] + ')';
  114. tok('MAINVERSIONLOOSE');
  115. src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
  116. '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
  117. '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
  118. // ## Pre-release Version Identifier
  119. // A numeric identifier, or a non-numeric identifier.
  120. tok('PRERELEASEIDENTIFIER');
  121. src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
  122. '|' + src[t.NONNUMERICIDENTIFIER] + ')';
  123. tok('PRERELEASEIDENTIFIERLOOSE');
  124. src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
  125. '|' + src[t.NONNUMERICIDENTIFIER] + ')';
  126. // ## Pre-release Version
  127. // Hyphen, followed by one or more dot-separated pre-release version
  128. // identifiers.
  129. tok('PRERELEASE');
  130. src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
  131. '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
  132. tok('PRERELEASELOOSE');
  133. src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
  134. '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
  135. // ## Build Metadata Identifier
  136. // Any combination of digits, letters, or hyphens.
  137. tok('BUILDIDENTIFIER');
  138. src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
  139. // ## Build Metadata
  140. // Plus sign, followed by one or more period-separated build metadata
  141. // identifiers.
  142. tok('BUILD');
  143. src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
  144. '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
  145. // ## Full Version String
  146. // A main version, followed optionally by a pre-release version and
  147. // build metadata.
  148. // Note that the only major, minor, patch, and pre-release sections of
  149. // the version string are capturing groups. The build metadata is not a
  150. // capturing group, because it should not ever be used in version
  151. // comparison.
  152. tok('FULL');
  153. tok('FULLPLAIN');
  154. src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
  155. src[t.PRERELEASE] + '?' +
  156. src[t.BUILD] + '?';
  157. src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
  158. // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  159. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  160. // common in the npm registry.
  161. tok('LOOSEPLAIN');
  162. src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
  163. src[t.PRERELEASELOOSE] + '?' +
  164. src[t.BUILD] + '?';
  165. tok('LOOSE');
  166. src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
  167. tok('GTLT');
  168. src[t.GTLT] = '((?:<|>)?=?)';
  169. // Something like "2.*" or "1.2.x".
  170. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  171. // Only the first item is strictly required.
  172. tok('XRANGEIDENTIFIERLOOSE');
  173. src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  174. tok('XRANGEIDENTIFIER');
  175. src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
  176. tok('XRANGEPLAIN');
  177. src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
  178. '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
  179. '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
  180. '(?:' + src[t.PRERELEASE] + ')?' +
  181. src[t.BUILD] + '?' +
  182. ')?)?';
  183. tok('XRANGEPLAINLOOSE');
  184. src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  185. '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  186. '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
  187. '(?:' + src[t.PRERELEASELOOSE] + ')?' +
  188. src[t.BUILD] + '?' +
  189. ')?)?';
  190. tok('XRANGE');
  191. src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
  192. tok('XRANGELOOSE');
  193. src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
  194. // Coercion.
  195. // Extract anything that could conceivably be a part of a valid semver
  196. tok('COERCE');
  197. src[t.COERCE] = '(^|[^\\d])' +
  198. '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
  199. '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
  200. '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
  201. '(?:$|[^\\d])';
  202. tok('COERCERTL');
  203. re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
  204. // Tilde ranges.
  205. // Meaning is "reasonably at or greater than"
  206. tok('LONETILDE');
  207. src[t.LONETILDE] = '(?:~>?)';
  208. tok('TILDETRIM');
  209. src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
  210. re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
  211. var tildeTrimReplace = '$1~';
  212. tok('TILDE');
  213. src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
  214. tok('TILDELOOSE');
  215. src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
  216. // Caret ranges.
  217. // Meaning is "at least and backwards compatible with"
  218. tok('LONECARET');
  219. src[t.LONECARET] = '(?:\\^)';
  220. tok('CARETTRIM');
  221. src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
  222. re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
  223. var caretTrimReplace = '$1^';
  224. tok('CARET');
  225. src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
  226. tok('CARETLOOSE');
  227. src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
  228. // A simple gt/lt/eq thing, or just "" to indicate "any version"
  229. tok('COMPARATORLOOSE');
  230. src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
  231. tok('COMPARATOR');
  232. src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
  233. // An expression to strip any whitespace between the gtlt and the thing
  234. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  235. tok('COMPARATORTRIM');
  236. src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
  237. '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
  238. // this one has to use the /g flag
  239. re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
  240. var comparatorTrimReplace = '$1$2$3';
  241. // Something like `1.2.3 - 1.2.4`
  242. // Note that these all use the loose form, because they'll be
  243. // checked against either the strict or loose comparator form
  244. // later.
  245. tok('HYPHENRANGE');
  246. src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
  247. '\\s+-\\s+' +
  248. '(' + src[t.XRANGEPLAIN] + ')' +
  249. '\\s*$';
  250. tok('HYPHENRANGELOOSE');
  251. src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
  252. '\\s+-\\s+' +
  253. '(' + src[t.XRANGEPLAINLOOSE] + ')' +
  254. '\\s*$';
  255. // Star ranges basically just allow anything at all.
  256. tok('STAR');
  257. src[t.STAR] = '(<|>)?=?\\s*\\*';
  258. // Compile to actual regexp objects.
  259. // All are flag-free, unless they were created above with a flag.
  260. for (var i = 0; i < R; i++) {
  261. debug(i, src[i]);
  262. if (!re[i]) {
  263. re[i] = new RegExp(src[i]);
  264. }
  265. }
  266. exports.parse = parse;
  267. function parse (version, options) {
  268. if (!options || typeof options !== 'object') {
  269. options = {
  270. loose: !!options,
  271. includePrerelease: false
  272. };
  273. }
  274. if (version instanceof SemVer) {
  275. return version
  276. }
  277. if (typeof version !== 'string') {
  278. return null
  279. }
  280. if (version.length > MAX_LENGTH) {
  281. return null
  282. }
  283. var r = options.loose ? re[t.LOOSE] : re[t.FULL];
  284. if (!r.test(version)) {
  285. return null
  286. }
  287. try {
  288. return new SemVer(version, options)
  289. } catch (er) {
  290. return null
  291. }
  292. }
  293. exports.valid = valid;
  294. function valid (version, options) {
  295. var v = parse(version, options);
  296. return v ? v.version : null
  297. }
  298. exports.clean = clean;
  299. function clean (version, options) {
  300. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  301. return s ? s.version : null
  302. }
  303. exports.SemVer = SemVer;
  304. function SemVer (version, options) {
  305. if (!options || typeof options !== 'object') {
  306. options = {
  307. loose: !!options,
  308. includePrerelease: false
  309. };
  310. }
  311. if (version instanceof SemVer) {
  312. if (version.loose === options.loose) {
  313. return version
  314. } else {
  315. version = version.version;
  316. }
  317. } else if (typeof version !== 'string') {
  318. throw new TypeError('Invalid Version: ' + version)
  319. }
  320. if (version.length > MAX_LENGTH) {
  321. throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
  322. }
  323. if (!(this instanceof SemVer)) {
  324. return new SemVer(version, options)
  325. }
  326. debug('SemVer', version, options);
  327. this.options = options;
  328. this.loose = !!options.loose;
  329. var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
  330. if (!m) {
  331. throw new TypeError('Invalid Version: ' + version)
  332. }
  333. this.raw = version;
  334. // these are actually numbers
  335. this.major = +m[1];
  336. this.minor = +m[2];
  337. this.patch = +m[3];
  338. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  339. throw new TypeError('Invalid major version')
  340. }
  341. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  342. throw new TypeError('Invalid minor version')
  343. }
  344. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  345. throw new TypeError('Invalid patch version')
  346. }
  347. // numberify any prerelease numeric ids
  348. if (!m[4]) {
  349. this.prerelease = [];
  350. } else {
  351. this.prerelease = m[4].split('.').map(function (id) {
  352. if (/^[0-9]+$/.test(id)) {
  353. var num = +id;
  354. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  355. return num
  356. }
  357. }
  358. return id
  359. });
  360. }
  361. this.build = m[5] ? m[5].split('.') : [];
  362. this.format();
  363. }
  364. SemVer.prototype.format = function () {
  365. this.version = this.major + '.' + this.minor + '.' + this.patch;
  366. if (this.prerelease.length) {
  367. this.version += '-' + this.prerelease.join('.');
  368. }
  369. return this.version
  370. };
  371. SemVer.prototype.toString = function () {
  372. return this.version
  373. };
  374. SemVer.prototype.compare = function (other) {
  375. debug('SemVer.compare', this.version, this.options, other);
  376. if (!(other instanceof SemVer)) {
  377. other = new SemVer(other, this.options);
  378. }
  379. return this.compareMain(other) || this.comparePre(other)
  380. };
  381. SemVer.prototype.compareMain = function (other) {
  382. if (!(other instanceof SemVer)) {
  383. other = new SemVer(other, this.options);
  384. }
  385. return compareIdentifiers(this.major, other.major) ||
  386. compareIdentifiers(this.minor, other.minor) ||
  387. compareIdentifiers(this.patch, other.patch)
  388. };
  389. SemVer.prototype.comparePre = function (other) {
  390. if (!(other instanceof SemVer)) {
  391. other = new SemVer(other, this.options);
  392. }
  393. // NOT having a prerelease is > having one
  394. if (this.prerelease.length && !other.prerelease.length) {
  395. return -1
  396. } else if (!this.prerelease.length && other.prerelease.length) {
  397. return 1
  398. } else if (!this.prerelease.length && !other.prerelease.length) {
  399. return 0
  400. }
  401. var i = 0;
  402. do {
  403. var a = this.prerelease[i];
  404. var b = other.prerelease[i];
  405. debug('prerelease compare', i, a, b);
  406. if (a === undefined && b === undefined) {
  407. return 0
  408. } else if (b === undefined) {
  409. return 1
  410. } else if (a === undefined) {
  411. return -1
  412. } else if (a === b) {
  413. continue
  414. } else {
  415. return compareIdentifiers(a, b)
  416. }
  417. } while (++i)
  418. };
  419. SemVer.prototype.compareBuild = function (other) {
  420. if (!(other instanceof SemVer)) {
  421. other = new SemVer(other, this.options);
  422. }
  423. var i = 0;
  424. do {
  425. var a = this.build[i];
  426. var b = other.build[i];
  427. debug('prerelease compare', i, a, b);
  428. if (a === undefined && b === undefined) {
  429. return 0
  430. } else if (b === undefined) {
  431. return 1
  432. } else if (a === undefined) {
  433. return -1
  434. } else if (a === b) {
  435. continue
  436. } else {
  437. return compareIdentifiers(a, b)
  438. }
  439. } while (++i)
  440. };
  441. // preminor will bump the version up to the next minor release, and immediately
  442. // down to pre-release. premajor and prepatch work the same way.
  443. SemVer.prototype.inc = function (release, identifier) {
  444. switch (release) {
  445. case 'premajor':
  446. this.prerelease.length = 0;
  447. this.patch = 0;
  448. this.minor = 0;
  449. this.major++;
  450. this.inc('pre', identifier);
  451. break
  452. case 'preminor':
  453. this.prerelease.length = 0;
  454. this.patch = 0;
  455. this.minor++;
  456. this.inc('pre', identifier);
  457. break
  458. case 'prepatch':
  459. // If this is already a prerelease, it will bump to the next version
  460. // drop any prereleases that might already exist, since they are not
  461. // relevant at this point.
  462. this.prerelease.length = 0;
  463. this.inc('patch', identifier);
  464. this.inc('pre', identifier);
  465. break
  466. // If the input is a non-prerelease version, this acts the same as
  467. // prepatch.
  468. case 'prerelease':
  469. if (this.prerelease.length === 0) {
  470. this.inc('patch', identifier);
  471. }
  472. this.inc('pre', identifier);
  473. break
  474. case 'major':
  475. // If this is a pre-major version, bump up to the same major version.
  476. // Otherwise increment major.
  477. // 1.0.0-5 bumps to 1.0.0
  478. // 1.1.0 bumps to 2.0.0
  479. if (this.minor !== 0 ||
  480. this.patch !== 0 ||
  481. this.prerelease.length === 0) {
  482. this.major++;
  483. }
  484. this.minor = 0;
  485. this.patch = 0;
  486. this.prerelease = [];
  487. break
  488. case 'minor':
  489. // If this is a pre-minor version, bump up to the same minor version.
  490. // Otherwise increment minor.
  491. // 1.2.0-5 bumps to 1.2.0
  492. // 1.2.1 bumps to 1.3.0
  493. if (this.patch !== 0 || this.prerelease.length === 0) {
  494. this.minor++;
  495. }
  496. this.patch = 0;
  497. this.prerelease = [];
  498. break
  499. case 'patch':
  500. // If this is not a pre-release version, it will increment the patch.
  501. // If it is a pre-release it will bump up to the same patch version.
  502. // 1.2.0-5 patches to 1.2.0
  503. // 1.2.0 patches to 1.2.1
  504. if (this.prerelease.length === 0) {
  505. this.patch++;
  506. }
  507. this.prerelease = [];
  508. break
  509. // This probably shouldn't be used publicly.
  510. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  511. case 'pre':
  512. if (this.prerelease.length === 0) {
  513. this.prerelease = [0];
  514. } else {
  515. var i = this.prerelease.length;
  516. while (--i >= 0) {
  517. if (typeof this.prerelease[i] === 'number') {
  518. this.prerelease[i]++;
  519. i = -2;
  520. }
  521. }
  522. if (i === -1) {
  523. // didn't increment anything
  524. this.prerelease.push(0);
  525. }
  526. }
  527. if (identifier) {
  528. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  529. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  530. if (this.prerelease[0] === identifier) {
  531. if (isNaN(this.prerelease[1])) {
  532. this.prerelease = [identifier, 0];
  533. }
  534. } else {
  535. this.prerelease = [identifier, 0];
  536. }
  537. }
  538. break
  539. default:
  540. throw new Error('invalid increment argument: ' + release)
  541. }
  542. this.format();
  543. this.raw = this.version;
  544. return this
  545. };
  546. exports.inc = inc;
  547. function inc (version, release, loose, identifier) {
  548. if (typeof (loose) === 'string') {
  549. identifier = loose;
  550. loose = undefined;
  551. }
  552. try {
  553. return new SemVer(version, loose).inc(release, identifier).version
  554. } catch (er) {
  555. return null
  556. }
  557. }
  558. exports.diff = diff;
  559. function diff (version1, version2) {
  560. if (eq(version1, version2)) {
  561. return null
  562. } else {
  563. var v1 = parse(version1);
  564. var v2 = parse(version2);
  565. var prefix = '';
  566. if (v1.prerelease.length || v2.prerelease.length) {
  567. prefix = 'pre';
  568. var defaultResult = 'prerelease';
  569. }
  570. for (var key in v1) {
  571. if (key === 'major' || key === 'minor' || key === 'patch') {
  572. if (v1[key] !== v2[key]) {
  573. return prefix + key
  574. }
  575. }
  576. }
  577. return defaultResult // may be undefined
  578. }
  579. }
  580. exports.compareIdentifiers = compareIdentifiers;
  581. var numeric = /^[0-9]+$/;
  582. function compareIdentifiers (a, b) {
  583. var anum = numeric.test(a);
  584. var bnum = numeric.test(b);
  585. if (anum && bnum) {
  586. a = +a;
  587. b = +b;
  588. }
  589. return a === b ? 0
  590. : (anum && !bnum) ? -1
  591. : (bnum && !anum) ? 1
  592. : a < b ? -1
  593. : 1
  594. }
  595. exports.rcompareIdentifiers = rcompareIdentifiers;
  596. function rcompareIdentifiers (a, b) {
  597. return compareIdentifiers(b, a)
  598. }
  599. exports.major = major;
  600. function major (a, loose) {
  601. return new SemVer(a, loose).major
  602. }
  603. exports.minor = minor;
  604. function minor (a, loose) {
  605. return new SemVer(a, loose).minor
  606. }
  607. exports.patch = patch;
  608. function patch (a, loose) {
  609. return new SemVer(a, loose).patch
  610. }
  611. exports.compare = compare;
  612. function compare (a, b, loose) {
  613. return new SemVer(a, loose).compare(new SemVer(b, loose))
  614. }
  615. exports.compareLoose = compareLoose;
  616. function compareLoose (a, b) {
  617. return compare(a, b, true)
  618. }
  619. exports.compareBuild = compareBuild;
  620. function compareBuild (a, b, loose) {
  621. var versionA = new SemVer(a, loose);
  622. var versionB = new SemVer(b, loose);
  623. return versionA.compare(versionB) || versionA.compareBuild(versionB)
  624. }
  625. exports.rcompare = rcompare;
  626. function rcompare (a, b, loose) {
  627. return compare(b, a, loose)
  628. }
  629. exports.sort = sort;
  630. function sort (list, loose) {
  631. return list.sort(function (a, b) {
  632. return exports.compareBuild(a, b, loose)
  633. })
  634. }
  635. exports.rsort = rsort;
  636. function rsort (list, loose) {
  637. return list.sort(function (a, b) {
  638. return exports.compareBuild(b, a, loose)
  639. })
  640. }
  641. exports.gt = gt;
  642. function gt (a, b, loose) {
  643. return compare(a, b, loose) > 0
  644. }
  645. exports.lt = lt;
  646. function lt (a, b, loose) {
  647. return compare(a, b, loose) < 0
  648. }
  649. exports.eq = eq;
  650. function eq (a, b, loose) {
  651. return compare(a, b, loose) === 0
  652. }
  653. exports.neq = neq;
  654. function neq (a, b, loose) {
  655. return compare(a, b, loose) !== 0
  656. }
  657. exports.gte = gte;
  658. function gte (a, b, loose) {
  659. return compare(a, b, loose) >= 0
  660. }
  661. exports.lte = lte;
  662. function lte (a, b, loose) {
  663. return compare(a, b, loose) <= 0
  664. }
  665. exports.cmp = cmp;
  666. function cmp (a, op, b, loose) {
  667. switch (op) {
  668. case '===':
  669. if (typeof a === 'object')
  670. { a = a.version; }
  671. if (typeof b === 'object')
  672. { b = b.version; }
  673. return a === b
  674. case '!==':
  675. if (typeof a === 'object')
  676. { a = a.version; }
  677. if (typeof b === 'object')
  678. { b = b.version; }
  679. return a !== b
  680. case '':
  681. case '=':
  682. case '==':
  683. return eq(a, b, loose)
  684. case '!=':
  685. return neq(a, b, loose)
  686. case '>':
  687. return gt(a, b, loose)
  688. case '>=':
  689. return gte(a, b, loose)
  690. case '<':
  691. return lt(a, b, loose)
  692. case '<=':
  693. return lte(a, b, loose)
  694. default:
  695. throw new TypeError('Invalid operator: ' + op)
  696. }
  697. }
  698. exports.Comparator = Comparator;
  699. function Comparator (comp, options) {
  700. if (!options || typeof options !== 'object') {
  701. options = {
  702. loose: !!options,
  703. includePrerelease: false
  704. };
  705. }
  706. if (comp instanceof Comparator) {
  707. if (comp.loose === !!options.loose) {
  708. return comp
  709. } else {
  710. comp = comp.value;
  711. }
  712. }
  713. if (!(this instanceof Comparator)) {
  714. return new Comparator(comp, options)
  715. }
  716. debug('comparator', comp, options);
  717. this.options = options;
  718. this.loose = !!options.loose;
  719. this.parse(comp);
  720. if (this.semver === ANY) {
  721. this.value = '';
  722. } else {
  723. this.value = this.operator + this.semver.version;
  724. }
  725. debug('comp', this);
  726. }
  727. var ANY = {};
  728. Comparator.prototype.parse = function (comp) {
  729. var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
  730. var m = comp.match(r);
  731. if (!m) {
  732. throw new TypeError('Invalid comparator: ' + comp)
  733. }
  734. this.operator = m[1] !== undefined ? m[1] : '';
  735. if (this.operator === '=') {
  736. this.operator = '';
  737. }
  738. // if it literally is just '>' or '' then allow anything.
  739. if (!m[2]) {
  740. this.semver = ANY;
  741. } else {
  742. this.semver = new SemVer(m[2], this.options.loose);
  743. }
  744. };
  745. Comparator.prototype.toString = function () {
  746. return this.value
  747. };
  748. Comparator.prototype.test = function (version) {
  749. debug('Comparator.test', version, this.options.loose);
  750. if (this.semver === ANY || version === ANY) {
  751. return true
  752. }
  753. if (typeof version === 'string') {
  754. try {
  755. version = new SemVer(version, this.options);
  756. } catch (er) {
  757. return false
  758. }
  759. }
  760. return cmp(version, this.operator, this.semver, this.options)
  761. };
  762. Comparator.prototype.intersects = function (comp, options) {
  763. if (!(comp instanceof Comparator)) {
  764. throw new TypeError('a Comparator is required')
  765. }
  766. if (!options || typeof options !== 'object') {
  767. options = {
  768. loose: !!options,
  769. includePrerelease: false
  770. };
  771. }
  772. var rangeTmp;
  773. if (this.operator === '') {
  774. if (this.value === '') {
  775. return true
  776. }
  777. rangeTmp = new Range(comp.value, options);
  778. return satisfies(this.value, rangeTmp, options)
  779. } else if (comp.operator === '') {
  780. if (comp.value === '') {
  781. return true
  782. }
  783. rangeTmp = new Range(this.value, options);
  784. return satisfies(comp.semver, rangeTmp, options)
  785. }
  786. var sameDirectionIncreasing =
  787. (this.operator === '>=' || this.operator === '>') &&
  788. (comp.operator === '>=' || comp.operator === '>');
  789. var sameDirectionDecreasing =
  790. (this.operator === '<=' || this.operator === '<') &&
  791. (comp.operator === '<=' || comp.operator === '<');
  792. var sameSemVer = this.semver.version === comp.semver.version;
  793. var differentDirectionsInclusive =
  794. (this.operator === '>=' || this.operator === '<=') &&
  795. (comp.operator === '>=' || comp.operator === '<=');
  796. var oppositeDirectionsLessThan =
  797. cmp(this.semver, '<', comp.semver, options) &&
  798. ((this.operator === '>=' || this.operator === '>') &&
  799. (comp.operator === '<=' || comp.operator === '<'));
  800. var oppositeDirectionsGreaterThan =
  801. cmp(this.semver, '>', comp.semver, options) &&
  802. ((this.operator === '<=' || this.operator === '<') &&
  803. (comp.operator === '>=' || comp.operator === '>'));
  804. return sameDirectionIncreasing || sameDirectionDecreasing ||
  805. (sameSemVer && differentDirectionsInclusive) ||
  806. oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
  807. };
  808. exports.Range = Range;
  809. function Range (range, options) {
  810. if (!options || typeof options !== 'object') {
  811. options = {
  812. loose: !!options,
  813. includePrerelease: false
  814. };
  815. }
  816. if (range instanceof Range) {
  817. if (range.loose === !!options.loose &&
  818. range.includePrerelease === !!options.includePrerelease) {
  819. return range
  820. } else {
  821. return new Range(range.raw, options)
  822. }
  823. }
  824. if (range instanceof Comparator) {
  825. return new Range(range.value, options)
  826. }
  827. if (!(this instanceof Range)) {
  828. return new Range(range, options)
  829. }
  830. this.options = options;
  831. this.loose = !!options.loose;
  832. this.includePrerelease = !!options.includePrerelease;
  833. // First, split based on boolean or ||
  834. this.raw = range;
  835. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  836. return this.parseRange(range.trim())
  837. }, this).filter(function (c) {
  838. // throw out any that are not relevant for whatever reason
  839. return c.length
  840. });
  841. if (!this.set.length) {
  842. throw new TypeError('Invalid SemVer Range: ' + range)
  843. }
  844. this.format();
  845. }
  846. Range.prototype.format = function () {
  847. this.range = this.set.map(function (comps) {
  848. return comps.join(' ').trim()
  849. }).join('||').trim();
  850. return this.range
  851. };
  852. Range.prototype.toString = function () {
  853. return this.range
  854. };
  855. Range.prototype.parseRange = function (range) {
  856. var loose = this.options.loose;
  857. range = range.trim();
  858. // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  859. var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
  860. range = range.replace(hr, hyphenReplace);
  861. debug('hyphen replace', range);
  862. // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  863. range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
  864. debug('comparator trim', range, re[t.COMPARATORTRIM]);
  865. // `~ 1.2.3` => `~1.2.3`
  866. range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
  867. // `^ 1.2.3` => `^1.2.3`
  868. range = range.replace(re[t.CARETTRIM], caretTrimReplace);
  869. // normalize spaces
  870. range = range.split(/\s+/).join(' ');
  871. // At this point, the range is completely trimmed and
  872. // ready to be split into comparators.
  873. var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
  874. var set = range.split(' ').map(function (comp) {
  875. return parseComparator(comp, this.options)
  876. }, this).join(' ').split(/\s+/);
  877. if (this.options.loose) {
  878. // in loose mode, throw out any that are not valid comparators
  879. set = set.filter(function (comp) {
  880. return !!comp.match(compRe)
  881. });
  882. }
  883. set = set.map(function (comp) {
  884. return new Comparator(comp, this.options)
  885. }, this);
  886. return set
  887. };
  888. Range.prototype.intersects = function (range, options) {
  889. if (!(range instanceof Range)) {
  890. throw new TypeError('a Range is required')
  891. }
  892. return this.set.some(function (thisComparators) {
  893. return (
  894. isSatisfiable(thisComparators, options) &&
  895. range.set.some(function (rangeComparators) {
  896. return (
  897. isSatisfiable(rangeComparators, options) &&
  898. thisComparators.every(function (thisComparator) {
  899. return rangeComparators.every(function (rangeComparator) {
  900. return thisComparator.intersects(rangeComparator, options)
  901. })
  902. })
  903. )
  904. })
  905. )
  906. })
  907. };
  908. // take a set of comparators and determine whether there
  909. // exists a version which can satisfy it
  910. function isSatisfiable (comparators, options) {
  911. var result = true;
  912. var remainingComparators = comparators.slice();
  913. var testComparator = remainingComparators.pop();
  914. while (result && remainingComparators.length) {
  915. result = remainingComparators.every(function (otherComparator) {
  916. return testComparator.intersects(otherComparator, options)
  917. });
  918. testComparator = remainingComparators.pop();
  919. }
  920. return result
  921. }
  922. // Mostly just for testing and legacy API reasons
  923. exports.toComparators = toComparators;
  924. function toComparators (range, options) {
  925. return new Range(range, options).set.map(function (comp) {
  926. return comp.map(function (c) {
  927. return c.value
  928. }).join(' ').trim().split(' ')
  929. })
  930. }
  931. // comprised of xranges, tildes, stars, and gtlt's at this point.
  932. // already replaced the hyphen ranges
  933. // turn into a set of JUST comparators.
  934. function parseComparator (comp, options) {
  935. debug('comp', comp, options);
  936. comp = replaceCarets(comp, options);
  937. debug('caret', comp);
  938. comp = replaceTildes(comp, options);
  939. debug('tildes', comp);
  940. comp = replaceXRanges(comp, options);
  941. debug('xrange', comp);
  942. comp = replaceStars(comp, options);
  943. debug('stars', comp);
  944. return comp
  945. }
  946. function isX (id) {
  947. return !id || id.toLowerCase() === 'x' || id === '*'
  948. }
  949. // ~, ~> --> * (any, kinda silly)
  950. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  951. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  952. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  953. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  954. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  955. function replaceTildes (comp, options) {
  956. return comp.trim().split(/\s+/).map(function (comp) {
  957. return replaceTilde(comp, options)
  958. }).join(' ')
  959. }
  960. function replaceTilde (comp, options) {
  961. var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
  962. return comp.replace(r, function (_, M, m, p, pr) {
  963. debug('tilde', comp, _, M, m, p, pr);
  964. var ret;
  965. if (isX(M)) {
  966. ret = '';
  967. } else if (isX(m)) {
  968. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  969. } else if (isX(p)) {
  970. // ~1.2 == >=1.2.0 <1.3.0
  971. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  972. } else if (pr) {
  973. debug('replaceTilde pr', pr);
  974. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  975. ' <' + M + '.' + (+m + 1) + '.0';
  976. } else {
  977. // ~1.2.3 == >=1.2.3 <1.3.0
  978. ret = '>=' + M + '.' + m + '.' + p +
  979. ' <' + M + '.' + (+m + 1) + '.0';
  980. }
  981. debug('tilde return', ret);
  982. return ret
  983. })
  984. }
  985. // ^ --> * (any, kinda silly)
  986. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  987. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  988. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  989. // ^1.2.3 --> >=1.2.3 <2.0.0
  990. // ^1.2.0 --> >=1.2.0 <2.0.0
  991. function replaceCarets (comp, options) {
  992. return comp.trim().split(/\s+/).map(function (comp) {
  993. return replaceCaret(comp, options)
  994. }).join(' ')
  995. }
  996. function replaceCaret (comp, options) {
  997. debug('caret', comp, options);
  998. var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
  999. return comp.replace(r, function (_, M, m, p, pr) {
  1000. debug('caret', comp, _, M, m, p, pr);
  1001. var ret;
  1002. if (isX(M)) {
  1003. ret = '';
  1004. } else if (isX(m)) {
  1005. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  1006. } else if (isX(p)) {
  1007. if (M === '0') {
  1008. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  1009. } else {
  1010. ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  1011. }
  1012. } else if (pr) {
  1013. debug('replaceCaret pr', pr);
  1014. if (M === '0') {
  1015. if (m === '0') {
  1016. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1017. ' <' + M + '.' + m + '.' + (+p + 1);
  1018. } else {
  1019. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1020. ' <' + M + '.' + (+m + 1) + '.0';
  1021. }
  1022. } else {
  1023. ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
  1024. ' <' + (+M + 1) + '.0.0';
  1025. }
  1026. } else {
  1027. debug('no pr');
  1028. if (M === '0') {
  1029. if (m === '0') {
  1030. ret = '>=' + M + '.' + m + '.' + p +
  1031. ' <' + M + '.' + m + '.' + (+p + 1);
  1032. } else {
  1033. ret = '>=' + M + '.' + m + '.' + p +
  1034. ' <' + M + '.' + (+m + 1) + '.0';
  1035. }
  1036. } else {
  1037. ret = '>=' + M + '.' + m + '.' + p +
  1038. ' <' + (+M + 1) + '.0.0';
  1039. }
  1040. }
  1041. debug('caret return', ret);
  1042. return ret
  1043. })
  1044. }
  1045. function replaceXRanges (comp, options) {
  1046. debug('replaceXRanges', comp, options);
  1047. return comp.split(/\s+/).map(function (comp) {
  1048. return replaceXRange(comp, options)
  1049. }).join(' ')
  1050. }
  1051. function replaceXRange (comp, options) {
  1052. comp = comp.trim();
  1053. var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
  1054. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  1055. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  1056. var xM = isX(M);
  1057. var xm = xM || isX(m);
  1058. var xp = xm || isX(p);
  1059. var anyX = xp;
  1060. if (gtlt === '=' && anyX) {
  1061. gtlt = '';
  1062. }
  1063. // if we're including prereleases in the match, then we need
  1064. // to fix this to -0, the lowest possible prerelease value
  1065. pr = options.includePrerelease ? '-0' : '';
  1066. if (xM) {
  1067. if (gtlt === '>' || gtlt === '<') {
  1068. // nothing is allowed
  1069. ret = '<0.0.0-0';
  1070. } else {
  1071. // nothing is forbidden
  1072. ret = '*';
  1073. }
  1074. } else if (gtlt && anyX) {
  1075. // we know patch is an x, because we have any x at all.
  1076. // replace X with 0
  1077. if (xm) {
  1078. m = 0;
  1079. }
  1080. p = 0;
  1081. if (gtlt === '>') {
  1082. // >1 => >=2.0.0
  1083. // >1.2 => >=1.3.0
  1084. // >1.2.3 => >= 1.2.4
  1085. gtlt = '>=';
  1086. if (xm) {
  1087. M = +M + 1;
  1088. m = 0;
  1089. p = 0;
  1090. } else {
  1091. m = +m + 1;
  1092. p = 0;
  1093. }
  1094. } else if (gtlt === '<=') {
  1095. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  1096. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  1097. gtlt = '<';
  1098. if (xm) {
  1099. M = +M + 1;
  1100. } else {
  1101. m = +m + 1;
  1102. }
  1103. }
  1104. ret = gtlt + M + '.' + m + '.' + p + pr;
  1105. } else if (xm) {
  1106. ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
  1107. } else if (xp) {
  1108. ret = '>=' + M + '.' + m + '.0' + pr +
  1109. ' <' + M + '.' + (+m + 1) + '.0' + pr;
  1110. }
  1111. debug('xRange return', ret);
  1112. return ret
  1113. })
  1114. }
  1115. // Because * is AND-ed with everything else in the comparator,
  1116. // and '' means "any version", just remove the *s entirely.
  1117. function replaceStars (comp, options) {
  1118. debug('replaceStars', comp, options);
  1119. // Looseness is ignored here. star is always as loose as it gets!
  1120. return comp.trim().replace(re[t.STAR], '')
  1121. }
  1122. // This function is passed to string.replace(re[t.HYPHENRANGE])
  1123. // M, m, patch, prerelease, build
  1124. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  1125. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  1126. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  1127. function hyphenReplace ($0,
  1128. from, fM, fm, fp, fpr, fb,
  1129. to, tM, tm, tp, tpr, tb) {
  1130. if (isX(fM)) {
  1131. from = '';
  1132. } else if (isX(fm)) {
  1133. from = '>=' + fM + '.0.0';
  1134. } else if (isX(fp)) {
  1135. from = '>=' + fM + '.' + fm + '.0';
  1136. } else {
  1137. from = '>=' + from;
  1138. }
  1139. if (isX(tM)) {
  1140. to = '';
  1141. } else if (isX(tm)) {
  1142. to = '<' + (+tM + 1) + '.0.0';
  1143. } else if (isX(tp)) {
  1144. to = '<' + tM + '.' + (+tm + 1) + '.0';
  1145. } else if (tpr) {
  1146. to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
  1147. } else {
  1148. to = '<=' + to;
  1149. }
  1150. return (from + ' ' + to).trim()
  1151. }
  1152. // if ANY of the sets match ALL of its comparators, then pass
  1153. Range.prototype.test = function (version) {
  1154. if (!version) {
  1155. return false
  1156. }
  1157. if (typeof version === 'string') {
  1158. try {
  1159. version = new SemVer(version, this.options);
  1160. } catch (er) {
  1161. return false
  1162. }
  1163. }
  1164. for (var i = 0; i < this.set.length; i++) {
  1165. if (testSet(this.set[i], version, this.options)) {
  1166. return true
  1167. }
  1168. }
  1169. return false
  1170. };
  1171. function testSet (set, version, options) {
  1172. for (var i = 0; i < set.length; i++) {
  1173. if (!set[i].test(version)) {
  1174. return false
  1175. }
  1176. }
  1177. if (version.prerelease.length && !options.includePrerelease) {
  1178. // Find the set of versions that are allowed to have prereleases
  1179. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  1180. // That should allow `1.2.3-pr.2` to pass.
  1181. // However, `1.2.4-alpha.notready` should NOT be allowed,
  1182. // even though it's within the range set by the comparators.
  1183. for (i = 0; i < set.length; i++) {
  1184. debug(set[i].semver);
  1185. if (set[i].semver === ANY) {
  1186. continue
  1187. }
  1188. if (set[i].semver.prerelease.length > 0) {
  1189. var allowed = set[i].semver;
  1190. if (allowed.major === version.major &&
  1191. allowed.minor === version.minor &&
  1192. allowed.patch === version.patch) {
  1193. return true
  1194. }
  1195. }
  1196. }
  1197. // Version has a -pre, but it's not one of the ones we like.
  1198. return false
  1199. }
  1200. return true
  1201. }
  1202. exports.satisfies = satisfies;
  1203. function satisfies (version, range, options) {
  1204. try {
  1205. range = new Range(range, options);
  1206. } catch (er) {
  1207. return false
  1208. }
  1209. return range.test(version)
  1210. }
  1211. exports.maxSatisfying = maxSatisfying;
  1212. function maxSatisfying (versions, range, options) {
  1213. var max = null;
  1214. var maxSV = null;
  1215. try {
  1216. var rangeObj = new Range(range, options);
  1217. } catch (er) {
  1218. return null
  1219. }
  1220. versions.forEach(function (v) {
  1221. if (rangeObj.test(v)) {
  1222. // satisfies(v, range, options)
  1223. if (!max || maxSV.compare(v) === -1) {
  1224. // compare(max, v, true)
  1225. max = v;
  1226. maxSV = new SemVer(max, options);
  1227. }
  1228. }
  1229. });
  1230. return max
  1231. }
  1232. exports.minSatisfying = minSatisfying;
  1233. function minSatisfying (versions, range, options) {
  1234. var min = null;
  1235. var minSV = null;
  1236. try {
  1237. var rangeObj = new Range(range, options);
  1238. } catch (er) {
  1239. return null
  1240. }
  1241. versions.forEach(function (v) {
  1242. if (rangeObj.test(v)) {
  1243. // satisfies(v, range, options)
  1244. if (!min || minSV.compare(v) === 1) {
  1245. // compare(min, v, true)
  1246. min = v;
  1247. minSV = new SemVer(min, options);
  1248. }
  1249. }
  1250. });
  1251. return min
  1252. }
  1253. exports.minVersion = minVersion;
  1254. function minVersion (range, loose) {
  1255. range = new Range(range, loose);
  1256. var minver = new SemVer('0.0.0');
  1257. if (range.test(minver)) {
  1258. return minver
  1259. }
  1260. minver = new SemVer('0.0.0-0');
  1261. if (range.test(minver)) {
  1262. return minver
  1263. }
  1264. minver = null;
  1265. for (var i = 0; i < range.set.length; ++i) {
  1266. var comparators = range.set[i];
  1267. comparators.forEach(function (comparator) {
  1268. // Clone to avoid manipulating the comparator's semver object.
  1269. var compver = new SemVer(comparator.semver.version);
  1270. switch (comparator.operator) {
  1271. case '>':
  1272. if (compver.prerelease.length === 0) {
  1273. compver.patch++;
  1274. } else {
  1275. compver.prerelease.push(0);
  1276. }
  1277. compver.raw = compver.format();
  1278. /* fallthrough */
  1279. case '':
  1280. case '>=':
  1281. if (!minver || gt(minver, compver)) {
  1282. minver = compver;
  1283. }
  1284. break
  1285. case '<':
  1286. case '<=':
  1287. /* Ignore maximum versions */
  1288. break
  1289. /* istanbul ignore next */
  1290. default:
  1291. throw new Error('Unexpected operation: ' + comparator.operator)
  1292. }
  1293. });
  1294. }
  1295. if (minver && range.test(minver)) {
  1296. return minver
  1297. }
  1298. return null
  1299. }
  1300. exports.validRange = validRange;
  1301. function validRange (range, options) {
  1302. try {
  1303. // Return '*' instead of '' so that truthiness works.
  1304. // This will throw if it's invalid anyway
  1305. return new Range(range, options).range || '*'
  1306. } catch (er) {
  1307. return null
  1308. }
  1309. }
  1310. // Determine if version is less than all the versions possible in the range
  1311. exports.ltr = ltr;
  1312. function ltr (version, range, options) {
  1313. return outside(version, range, '<', options)
  1314. }
  1315. // Determine if version is greater than all the versions possible in the range.
  1316. exports.gtr = gtr;
  1317. function gtr (version, range, options) {
  1318. return outside(version, range, '>', options)
  1319. }
  1320. exports.outside = outside;
  1321. function outside (version, range, hilo, options) {
  1322. version = new SemVer(version, options);
  1323. range = new Range(range, options);
  1324. var gtfn, ltefn, ltfn, comp, ecomp;
  1325. switch (hilo) {
  1326. case '>':
  1327. gtfn = gt;
  1328. ltefn = lte;
  1329. ltfn = lt;
  1330. comp = '>';
  1331. ecomp = '>=';
  1332. break
  1333. case '<':
  1334. gtfn = lt;
  1335. ltefn = gte;
  1336. ltfn = gt;
  1337. comp = '<';
  1338. ecomp = '<=';
  1339. break
  1340. default:
  1341. throw new TypeError('Must provide a hilo val of "<" or ">"')
  1342. }
  1343. // If it satisifes the range it is not outside
  1344. if (satisfies(version, range, options)) {
  1345. return false
  1346. }
  1347. // From now on, variable terms are as if we're in "gtr" mode.
  1348. // but note that everything is flipped for the "ltr" function.
  1349. for (var i = 0; i < range.set.length; ++i) {
  1350. var comparators = range.set[i];
  1351. var high = null;
  1352. var low = null;
  1353. comparators.forEach(function (comparator) {
  1354. if (comparator.semver === ANY) {
  1355. comparator = new Comparator('>=0.0.0');
  1356. }
  1357. high = high || comparator;
  1358. low = low || comparator;
  1359. if (gtfn(comparator.semver, high.semver, options)) {
  1360. high = comparator;
  1361. } else if (ltfn(comparator.semver, low.semver, options)) {
  1362. low = comparator;
  1363. }
  1364. });
  1365. // If the edge version comparator has a operator then our version
  1366. // isn't outside it
  1367. if (high.operator === comp || high.operator === ecomp) {
  1368. return false
  1369. }
  1370. // If the lowest version comparator has an operator and our version
  1371. // is less than it then it isn't higher than the range
  1372. if ((!low.operator || low.operator === comp) &&
  1373. ltefn(version, low.semver)) {
  1374. return false
  1375. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  1376. return false
  1377. }
  1378. }
  1379. return true
  1380. }
  1381. exports.prerelease = prerelease;
  1382. function prerelease (version, options) {
  1383. var parsed = parse(version, options);
  1384. return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
  1385. }
  1386. exports.intersects = intersects;
  1387. function intersects (r1, r2, options) {
  1388. r1 = new Range(r1, options);
  1389. r2 = new Range(r2, options);
  1390. return r1.intersects(r2)
  1391. }
  1392. exports.coerce = coerce;
  1393. function coerce (version, options) {
  1394. if (version instanceof SemVer) {
  1395. return version
  1396. }
  1397. if (typeof version === 'number') {
  1398. version = String(version);
  1399. }
  1400. if (typeof version !== 'string') {
  1401. return null
  1402. }
  1403. options = options || {};
  1404. var match = null;
  1405. if (!options.rtl) {
  1406. match = version.match(re[t.COERCE]);
  1407. } else {
  1408. // Find the right-most coercible string that does not share
  1409. // a terminus with a more left-ward coercible string.
  1410. // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
  1411. //
  1412. // Walk through the string checking with a /g regexp
  1413. // Manually set the index so as to pick up overlapping matches.
  1414. // Stop when we get a match that ends at the string end, since no
  1415. // coercible string can be more right-ward without the same terminus.
  1416. var next;
  1417. while ((next = re[t.COERCERTL].exec(version)) &&
  1418. (!match || match.index + match[0].length !== version.length)
  1419. ) {
  1420. if (!match ||
  1421. next.index + next[0].length !== match.index + match[0].length) {
  1422. match = next;
  1423. }
  1424. re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
  1425. }
  1426. // leave it in a clean state
  1427. re[t.COERCERTL].lastIndex = -1;
  1428. }
  1429. if (match === null) {
  1430. return null
  1431. }
  1432. return parse(match[2] +
  1433. '.' + (match[3] || '0') +
  1434. '.' + (match[4] || '0'), options)
  1435. }
  1436. });
  1437. var NAME_SELECTOR = 'NAME_SELECTOR';
  1438. var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
  1439. var REF_SELECTOR = 'REF_SELECTOR';
  1440. var DOM_SELECTOR = 'DOM_SELECTOR';
  1441. var INVALID_SELECTOR = 'INVALID_SELECTOR';
  1442. var VUE_VERSION = Number(
  1443. ((Vue__default['default'].version.split('.')[0]) + "." + (Vue__default['default'].version.split('.')[1]))
  1444. );
  1445. var FUNCTIONAL_OPTIONS =
  1446. VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
  1447. var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue__default['default'].version, '2.1.8')
  1448. ? 'beforeCreate'
  1449. : 'beforeMount';
  1450. var CREATE_ELEMENT_ALIAS = semver.gt(Vue__default['default'].version, '2.1.5')
  1451. ? '_c'
  1452. : '_h';
  1453. //
  1454. function throwError(msg) {
  1455. throw new Error(("[vue-test-utils]: " + msg))
  1456. }
  1457. function warn(msg) {
  1458. console.error(("[vue-test-utils]: " + msg));
  1459. }
  1460. var camelizeRE = /-(\w)/g;
  1461. var camelize = function (str) {
  1462. var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }
  1463. );
  1464. return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
  1465. };
  1466. /**
  1467. * Capitalize a string.
  1468. */
  1469. var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
  1470. /**
  1471. * Hyphenate a camelCase string.
  1472. */
  1473. var hyphenateRE = /\B([A-Z])/g;
  1474. var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
  1475. function hasOwnProperty(obj, prop) {
  1476. return Object.prototype.hasOwnProperty.call(obj, prop)
  1477. }
  1478. function keys(obj) {
  1479. // $FlowIgnore
  1480. return Object.keys(obj)
  1481. }
  1482. function resolveComponent(id, components) {
  1483. if (typeof id !== 'string') {
  1484. return
  1485. }
  1486. // check local registration variations first
  1487. if (hasOwnProperty(components, id)) {
  1488. return components[id]
  1489. }
  1490. var camelizedId = camelize(id);
  1491. if (hasOwnProperty(components, camelizedId)) {
  1492. return components[camelizedId]
  1493. }
  1494. var PascalCaseId = capitalize(camelizedId);
  1495. if (hasOwnProperty(components, PascalCaseId)) {
  1496. return components[PascalCaseId]
  1497. }
  1498. // fallback to prototype chain
  1499. return components[id] || components[camelizedId] || components[PascalCaseId]
  1500. }
  1501. var UA =
  1502. typeof window !== 'undefined' &&
  1503. 'navigator' in window &&
  1504. navigator.userAgent.toLowerCase();
  1505. var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
  1506. var isEdge = UA && UA.indexOf('edge/') > 0;
  1507. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  1508. // get the event used to trigger v-model handler that updates bound data
  1509. function getCheckedEvent() {
  1510. var version = Vue__default['default'].version;
  1511. if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
  1512. return 'click'
  1513. }
  1514. if (semver.satisfies(version, '2.2 - 2.4')) {
  1515. return isChrome ? 'click' : 'change'
  1516. }
  1517. // change is handler for version 2.0 - 2.1.8, and 2.5+
  1518. return 'change'
  1519. }
  1520. /**
  1521. * Normalize nextTick to return a promise for all Vue 2 versions.
  1522. * Vue < 2.1 does not return a Promise from nextTick
  1523. * @return {Promise<R>}
  1524. */
  1525. function nextTick() {
  1526. if (VUE_VERSION > 2) { return Vue__default['default'].nextTick() }
  1527. return new Promise(function (resolve) {
  1528. Vue__default['default'].nextTick(resolve);
  1529. })
  1530. }
  1531. function warnDeprecated(method, fallback) {
  1532. if ( fallback === void 0 ) fallback = '';
  1533. if (!config.showDeprecationWarnings) { return }
  1534. var msg = method + " is deprecated and will be removed in the next major version.";
  1535. if (fallback) { msg += " " + fallback + "."; }
  1536. if (config.deprecationWarningHandler) {
  1537. config.deprecationWarningHandler(method, msg);
  1538. } else {
  1539. warn(msg);
  1540. }
  1541. }
  1542. function isVueWrapper(wrapper) {
  1543. return wrapper.vm || wrapper.isFunctionalComponent
  1544. }
  1545. //
  1546. function addMocks(
  1547. _Vue,
  1548. mockedProperties
  1549. ) {
  1550. if ( mockedProperties === void 0 ) mockedProperties = {};
  1551. if (mockedProperties === false) {
  1552. return
  1553. }
  1554. Object.keys(mockedProperties).forEach(function (key) {
  1555. try {
  1556. // $FlowIgnore
  1557. _Vue.prototype[key] = mockedProperties[key];
  1558. } catch (e) {
  1559. warn(
  1560. "could not overwrite property " + key + ", this is " +
  1561. "usually caused by a plugin that has added " +
  1562. "the property as a read-only value"
  1563. );
  1564. }
  1565. // $FlowIgnore
  1566. Vue__default['default'].util.defineReactive(_Vue, key, mockedProperties[key]);
  1567. });
  1568. }
  1569. //
  1570. function logEvents(
  1571. vm,
  1572. emitted,
  1573. emittedByOrder
  1574. ) {
  1575. var emit = vm.$emit;
  1576. vm.$emit = function (name) {
  1577. var args = [], len = arguments.length - 1;
  1578. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  1579. (emitted[name] || (emitted[name] = [])).push(args);
  1580. emittedByOrder.push({ name: name, args: args });
  1581. return emit.call.apply(emit, [ vm, name ].concat( args ))
  1582. };
  1583. }
  1584. function addEventLogger(_Vue) {
  1585. _Vue.mixin({
  1586. beforeCreate: function() {
  1587. this.__emitted = Object.create(null);
  1588. this.__emittedByOrder = [];
  1589. logEvents(this, this.__emitted, this.__emittedByOrder);
  1590. }
  1591. });
  1592. }
  1593. function addStubs(_Vue, stubComponents) {
  1594. var obj;
  1595. function addStubComponentsMixin() {
  1596. Object.assign(this.$options.components, stubComponents);
  1597. }
  1598. _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = addStubComponentsMixin, obj ));
  1599. }
  1600. //
  1601. function isDomSelector(selector) {
  1602. if (typeof selector !== 'string') {
  1603. return false
  1604. }
  1605. try {
  1606. if (typeof document === 'undefined') {
  1607. throwError(
  1608. "mount must be run in a browser environment like " +
  1609. "PhantomJS, jsdom or chrome"
  1610. );
  1611. }
  1612. } catch (error) {
  1613. throwError(
  1614. "mount must be run in a browser environment like " +
  1615. "PhantomJS, jsdom or chrome"
  1616. );
  1617. }
  1618. try {
  1619. document.querySelector(selector);
  1620. return true
  1621. } catch (error$1) {
  1622. return false
  1623. }
  1624. }
  1625. function isVueComponent(c) {
  1626. if (isConstructor(c)) {
  1627. return true
  1628. }
  1629. if (c === null || typeof c !== 'object') {
  1630. return false
  1631. }
  1632. if (c.extends || c._Ctor) {
  1633. return true
  1634. }
  1635. if (typeof c.template === 'string') {
  1636. return true
  1637. }
  1638. if (typeof c.setup === 'function' && !c.render) {
  1639. return true
  1640. }
  1641. return typeof c.render === 'function'
  1642. }
  1643. function componentNeedsCompiling(component) {
  1644. return (
  1645. component &&
  1646. !component.render &&
  1647. (component.template || component.extends || component.extendOptions) &&
  1648. !component.functional
  1649. )
  1650. }
  1651. function isRefSelector(refOptionsObject) {
  1652. if (
  1653. typeof refOptionsObject !== 'object' ||
  1654. Object.keys(refOptionsObject || {}).length !== 1
  1655. ) {
  1656. return false
  1657. }
  1658. return typeof refOptionsObject.ref === 'string'
  1659. }
  1660. function isNameSelector(nameOptionsObject) {
  1661. if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
  1662. return false
  1663. }
  1664. return !!nameOptionsObject.name
  1665. }
  1666. function isConstructor(c) {
  1667. return typeof c === 'function' && c.cid
  1668. }
  1669. function isDynamicComponent(c) {
  1670. return typeof c === 'function' && !c.cid
  1671. }
  1672. function isComponentOptions(c) {
  1673. return c !== null && typeof c === 'object' && (c.template || c.render)
  1674. }
  1675. function isFunctionalComponent(c) {
  1676. if (!isVueComponent(c)) {
  1677. return false
  1678. }
  1679. if (isConstructor(c)) {
  1680. return c.options.functional
  1681. }
  1682. return c.functional
  1683. }
  1684. function templateContainsComponent(
  1685. template,
  1686. name
  1687. ) {
  1688. return [capitalize, camelize, hyphenate].some(function (format) {
  1689. var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
  1690. return re.test(template)
  1691. })
  1692. }
  1693. function isPlainObject(c) {
  1694. return Object.prototype.toString.call(c) === '[object Object]'
  1695. }
  1696. function isHTMLElement(c) {
  1697. if (typeof HTMLElement === 'undefined') {
  1698. return false
  1699. }
  1700. // eslint-disable-next-line no-undef
  1701. return c instanceof HTMLElement
  1702. }
  1703. function makeMap(str, expectsLowerCase) {
  1704. var map = Object.create(null);
  1705. var list = str.split(',');
  1706. for (var i = 0; i < list.length; i++) {
  1707. map[list[i]] = true;
  1708. }
  1709. return expectsLowerCase
  1710. ? function(val) {
  1711. return map[val.toLowerCase()]
  1712. }
  1713. : function(val) {
  1714. return map[val]
  1715. }
  1716. }
  1717. var isHTMLTag = makeMap(
  1718. 'html,body,base,head,link,meta,style,title,' +
  1719. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1720. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1721. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1722. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,' +
  1723. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1724. 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' +
  1725. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1726. 'output,progress,select,textarea,' +
  1727. 'details,dialog,menu,menuitem,summary,' +
  1728. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1729. );
  1730. // this map is intentionally selective, only covering SVG elements that may
  1731. // contain child elements.
  1732. var isSVG = makeMap(
  1733. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1734. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1735. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1736. true
  1737. );
  1738. var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };
  1739. //
  1740. function compileTemplate(component) {
  1741. if (component.template) {
  1742. if (!vueTemplateCompiler.compileToFunctions) {
  1743. throwError(
  1744. "vueTemplateCompiler is undefined, you must pass " +
  1745. "precompiled components if vue-template-compiler is " +
  1746. "undefined"
  1747. );
  1748. }
  1749. if (component.template.charAt('#') === '#') {
  1750. var el = document.querySelector(component.template);
  1751. if (!el) {
  1752. throwError('Cannot find element' + component.template);
  1753. el = document.createElement('div');
  1754. }
  1755. component.template = el.innerHTML;
  1756. }
  1757. Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
  1758. {name: component.name}));
  1759. }
  1760. if (component.components) {
  1761. Object.keys(component.components).forEach(function (c) {
  1762. var cmp = component.components[c];
  1763. if (!cmp.render) {
  1764. compileTemplate(cmp);
  1765. }
  1766. });
  1767. }
  1768. if (component.extends) {
  1769. compileTemplate(component.extends);
  1770. }
  1771. if (component.extendOptions && !component.options.render) {
  1772. compileTemplate(component.options);
  1773. }
  1774. }
  1775. function compileTemplateForSlots(slots) {
  1776. Object.keys(slots).forEach(function (key) {
  1777. var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
  1778. slot.forEach(function (slotValue) {
  1779. if (componentNeedsCompiling(slotValue)) {
  1780. compileTemplate(slotValue);
  1781. }
  1782. });
  1783. });
  1784. }
  1785. //
  1786. var MOUNTING_OPTIONS = [
  1787. 'attachToDocument',
  1788. 'mocks',
  1789. 'slots',
  1790. 'localVue',
  1791. 'stubs',
  1792. 'context',
  1793. 'clone',
  1794. 'attrs',
  1795. 'listeners',
  1796. 'propsData',
  1797. 'shouldProxy'
  1798. ];
  1799. function extractInstanceOptions(options) {
  1800. var instanceOptions = Object.assign({}, options);
  1801. MOUNTING_OPTIONS.forEach(function (mountingOption) {
  1802. delete instanceOptions[mountingOption];
  1803. });
  1804. return instanceOptions
  1805. }
  1806. //
  1807. function isDestructuringSlotScope(slotScope) {
  1808. return /^{.*}$/.test(slotScope)
  1809. }
  1810. function getVueTemplateCompilerHelpers(
  1811. _Vue
  1812. ) {
  1813. // $FlowIgnore
  1814. var vue = new _Vue();
  1815. var helpers = {};
  1816. var names = [
  1817. '_c',
  1818. '_o',
  1819. '_n',
  1820. '_s',
  1821. '_l',
  1822. '_t',
  1823. '_q',
  1824. '_i',
  1825. '_m',
  1826. '_f',
  1827. '_k',
  1828. '_b',
  1829. '_v',
  1830. '_e',
  1831. '_u',
  1832. '_g'
  1833. ];
  1834. names.forEach(function (name) {
  1835. helpers[name] = vue._renderProxy[name];
  1836. });
  1837. helpers.$createElement = vue._renderProxy.$createElement;
  1838. helpers.$set = vue._renderProxy.$set;
  1839. return helpers
  1840. }
  1841. function validateEnvironment() {
  1842. if (VUE_VERSION < 2.1) {
  1843. throwError("the scopedSlots option is only supported in vue@2.1+.");
  1844. }
  1845. }
  1846. function isScopedSlot(slot) {
  1847. if (typeof slot === 'function') { return { match: null, slot: slot } }
  1848. var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
  1849. var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
  1850. var shortVSlotRe = /<template #.*="(.+)"/;
  1851. var hasOldSlotScope = slot.match(slotScopeRe);
  1852. var hasVSlotScopeAttr = slot.match(vSlotRe);
  1853. var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);
  1854. if (hasOldSlotScope) {
  1855. return { slot: slot, match: hasOldSlotScope }
  1856. } else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
  1857. // Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
  1858. var sanitizedSlot = slot.replace(
  1859. /(<template)([^>]+)(>.+<\/template>)/,
  1860. '$1$3'
  1861. );
  1862. return {
  1863. slot: sanitizedSlot,
  1864. match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
  1865. }
  1866. }
  1867. // we have no matches, so we just return
  1868. return {
  1869. slot: slot,
  1870. match: null
  1871. }
  1872. }
  1873. // Hide warning about <template> disallowed as root element
  1874. function customWarn(msg) {
  1875. if (msg.indexOf('Cannot use <template> as component root element') === -1) {
  1876. console.error(msg);
  1877. }
  1878. }
  1879. function createScopedSlots(
  1880. scopedSlotsOption,
  1881. _Vue
  1882. ) {
  1883. var scopedSlots = {};
  1884. if (!scopedSlotsOption) {
  1885. return scopedSlots
  1886. }
  1887. validateEnvironment();
  1888. var helpers = getVueTemplateCompilerHelpers(_Vue);
  1889. var loop = function ( scopedSlotName ) {
  1890. var slot = scopedSlotsOption[scopedSlotName];
  1891. var isFn = typeof slot === 'function';
  1892. var scopedSlotMatches = isScopedSlot(slot);
  1893. // Type check to silence flow (can't use isFn)
  1894. var renderFn =
  1895. typeof slot === 'function'
  1896. ? slot
  1897. : vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
  1898. .render;
  1899. var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
  1900. scopedSlots[scopedSlotName] = function(props) {
  1901. var obj;
  1902. var res;
  1903. if (isFn) {
  1904. res = renderFn.call(Object.assign({}, helpers), props);
  1905. } else if (slotScope && !isDestructuringSlotScope(slotScope)) {
  1906. res = renderFn.call(Object.assign({}, helpers, ( obj = {}, obj[slotScope] = props, obj )));
  1907. } else if (slotScope && isDestructuringSlotScope(slotScope)) {
  1908. res = renderFn.call(Object.assign({}, helpers, props));
  1909. } else {
  1910. res = renderFn.call(Object.assign({}, helpers, {props: props}));
  1911. }
  1912. // res is Array if <template> is a root element
  1913. return Array.isArray(res) ? res[0] : res
  1914. };
  1915. };
  1916. for (var scopedSlotName in scopedSlotsOption) loop( scopedSlotName );
  1917. return scopedSlots
  1918. }
  1919. //
  1920. var FUNCTION_PLACEHOLDER = '[Function]';
  1921. function isVueComponentStub(comp) {
  1922. return (comp && comp.template) || isVueComponent(comp)
  1923. }
  1924. function isValidStub(stub) {
  1925. return (
  1926. typeof stub === 'boolean' ||
  1927. (!!stub && typeof stub === 'string') ||
  1928. isVueComponentStub(stub)
  1929. )
  1930. }
  1931. function resolveComponent$1(obj, component) {
  1932. return (
  1933. obj[component] ||
  1934. obj[hyphenate(component)] ||
  1935. obj[camelize(component)] ||
  1936. obj[capitalize(camelize(component))] ||
  1937. obj[capitalize(component)] ||
  1938. {}
  1939. )
  1940. }
  1941. function getCoreProperties(componentOptions) {
  1942. return {
  1943. attrs: componentOptions.attrs,
  1944. name: componentOptions.name,
  1945. model: componentOptions.model,
  1946. props: componentOptions.props,
  1947. on: componentOptions.on,
  1948. key: componentOptions.key,
  1949. domProps: componentOptions.domProps,
  1950. class: componentOptions.class,
  1951. staticClass: componentOptions.staticClass,
  1952. staticStyle: componentOptions.staticStyle,
  1953. style: componentOptions.style,
  1954. normalizedStyle: componentOptions.normalizedStyle,
  1955. nativeOn: componentOptions.nativeOn,
  1956. functional: componentOptions.functional,
  1957. abstract: componentOptions.abstract
  1958. }
  1959. }
  1960. function resolveOptions(component, _Vue) {
  1961. if (isDynamicComponent(component)) {
  1962. return {}
  1963. }
  1964. return isConstructor(component)
  1965. ? component.options
  1966. : _Vue.extend(component).options
  1967. }
  1968. function getScopedSlotRenderFunctions(ctx) {
  1969. // In Vue 2.6+ a new v-slot syntax was introduced
  1970. // scopedSlots are now saved in parent._vnode.data.scopedSlots
  1971. // We filter out _normalized, $stable and $key keys
  1972. if (
  1973. ctx &&
  1974. ctx.$options &&
  1975. ctx.$options.parent &&
  1976. ctx.$options.parent._vnode &&
  1977. ctx.$options.parent._vnode.data &&
  1978. ctx.$options.parent._vnode.data.scopedSlots
  1979. ) {
  1980. var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
  1981. return keys(slotKeys).filter(
  1982. function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
  1983. )
  1984. }
  1985. return []
  1986. }
  1987. function createStubFromComponent(
  1988. originalComponent,
  1989. name,
  1990. _Vue
  1991. ) {
  1992. var componentOptions = resolveOptions(originalComponent, _Vue);
  1993. var tagName = (name || 'anonymous') + "-stub";
  1994. // ignoreElements does not exist in Vue 2.0.x
  1995. if (Vue__default['default'].config.ignoredElements) {
  1996. Vue__default['default'].config.ignoredElements.push(tagName);
  1997. }
  1998. return Object.assign({}, getCoreProperties(componentOptions),
  1999. {$_vueTestUtils_original: originalComponent,
  2000. $_doNotStubChildren: true,
  2001. render: function render(h, context) {
  2002. var this$1 = this;
  2003. return h(
  2004. tagName,
  2005. componentOptions.functional
  2006. ? Object.assign({}, context.data,
  2007. {attrs: Object.assign({}, shapeStubProps(context.props),
  2008. context.data.attrs)})
  2009. : {
  2010. attrs: Object.assign({}, shapeStubProps(this.$props))
  2011. },
  2012. context
  2013. ? context.children
  2014. : this.$options._renderChildren ||
  2015. getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
  2016. )
  2017. )
  2018. }})
  2019. }
  2020. function shapeStubProps(props) {
  2021. var shapedProps = {};
  2022. for (var propName in props) {
  2023. if (typeof props[propName] === 'function') {
  2024. shapedProps[propName] = FUNCTION_PLACEHOLDER;
  2025. continue
  2026. }
  2027. if (Array.isArray(props[propName])) {
  2028. shapedProps[propName] = props[propName].map(function (value) {
  2029. return typeof value === 'function' ? FUNCTION_PLACEHOLDER : value
  2030. });
  2031. continue
  2032. }
  2033. shapedProps[propName] = props[propName];
  2034. }
  2035. return shapedProps
  2036. }
  2037. // DEPRECATED: converts string stub to template stub.
  2038. function createStubFromString(templateString, name) {
  2039. warnDeprecated('Using a string for stubs');
  2040. if (templateContainsComponent(templateString, name)) {
  2041. throwError('options.stub cannot contain a circular reference');
  2042. }
  2043. return {
  2044. template: templateString,
  2045. $_doNotStubChildren: true
  2046. }
  2047. }
  2048. function setStubComponentName(
  2049. stub,
  2050. originalComponent,
  2051. _Vue
  2052. ) {
  2053. if ( originalComponent === void 0 ) originalComponent = {};
  2054. if (stub.name) { return }
  2055. var componentOptions = resolveOptions(originalComponent, _Vue);
  2056. stub.name = getCoreProperties(componentOptions).name;
  2057. }
  2058. function validateStub(stub) {
  2059. if (!isValidStub(stub)) {
  2060. throwError("options.stub values must be passed a string or " + "component");
  2061. }
  2062. }
  2063. function createStubsFromStubsObject(
  2064. originalComponents,
  2065. stubs,
  2066. _Vue
  2067. ) {
  2068. if ( originalComponents === void 0 ) originalComponents = {};
  2069. return Object.keys(stubs || {}).reduce(function (acc, stubName) {
  2070. var stub = stubs[stubName];
  2071. validateStub(stub);
  2072. if (stub === false) {
  2073. return acc
  2074. }
  2075. var component = resolveComponent$1(originalComponents, stubName);
  2076. if (stub === true) {
  2077. acc[stubName] = createStubFromComponent(component, stubName, _Vue);
  2078. return acc
  2079. }
  2080. if (typeof stub === 'string') {
  2081. stub = createStubFromString(stub, stubName);
  2082. stubs[stubName];
  2083. }
  2084. setStubComponentName(stub, component, _Vue);
  2085. if (componentNeedsCompiling(stub)) {
  2086. compileTemplate(stub);
  2087. }
  2088. acc[stubName] = stub;
  2089. stub._Ctor = {};
  2090. return acc
  2091. }, {})
  2092. }
  2093. var isAllowlisted = function (el, allowlist) { return resolveComponent(el, allowlist); };
  2094. var isAlreadyStubbed = function (el, stubs) { return stubs.has(el); };
  2095. function shouldExtend(component, _Vue) {
  2096. return isConstructor(component) || (component && component.extends)
  2097. }
  2098. function extend(component, _Vue) {
  2099. var componentOptions = component.options ? component.options : component;
  2100. var stub = _Vue.extend(componentOptions);
  2101. stub.options.$_vueTestUtils_original = component;
  2102. stub.options._base = _Vue;
  2103. return stub
  2104. }
  2105. function createStubIfNeeded(shouldStub, component, _Vue, el) {
  2106. if (shouldStub) {
  2107. return createStubFromComponent(component || {}, el, _Vue)
  2108. }
  2109. if (shouldExtend(component)) {
  2110. return extend(component, _Vue)
  2111. }
  2112. }
  2113. function shouldNotBeStubbed(el, allowlist, modifiedComponents) {
  2114. return (
  2115. (typeof el === 'string' && isReservedTag(el)) ||
  2116. isAllowlisted(el, allowlist) ||
  2117. isAlreadyStubbed(el, modifiedComponents)
  2118. )
  2119. }
  2120. function patchCreateElement(_Vue, stubs, stubAllComponents) {
  2121. var obj;
  2122. // This mixin patches vm.$createElement so that we can stub all components
  2123. // before they are rendered in shallow mode. We also need to ensure that
  2124. // component constructors were created from the _Vue constructor. If not,
  2125. // we must replace them with components created from the _Vue constructor
  2126. // before calling the original $createElement. This ensures that components
  2127. // have the correct instance properties and stubs when they are rendered.
  2128. function patchCreateElementMixin() {
  2129. var vm = this;
  2130. if (vm.$options.$_doNotStubChildren || vm.$options._isFunctionalContainer) {
  2131. return
  2132. }
  2133. var modifiedComponents = new Set();
  2134. var originalCreateElement = vm.$createElement;
  2135. var originalComponents = vm.$options.components;
  2136. var createElement = function (el) {
  2137. var obj;
  2138. var args = [], len = arguments.length - 1;
  2139. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  2140. if (shouldNotBeStubbed(el, stubs, modifiedComponents)) {
  2141. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2142. }
  2143. if (isConstructor(el) || isComponentOptions(el)) {
  2144. if (stubAllComponents) {
  2145. var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
  2146. return originalCreateElement.apply(void 0, [ stub ].concat( args ))
  2147. }
  2148. var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
  2149. return originalCreateElement.apply(void 0, [ Constructor ].concat( args ))
  2150. }
  2151. if (typeof el === 'string') {
  2152. var original = resolveComponent(el, originalComponents);
  2153. if (!original) {
  2154. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2155. }
  2156. if (isDynamicComponent(original)) {
  2157. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2158. }
  2159. var stub$1 = createStubIfNeeded(stubAllComponents, original, _Vue, el);
  2160. if (stub$1) {
  2161. Object.assign(vm.$options.components, ( obj = {}, obj[el] = stub$1, obj ));
  2162. modifiedComponents.add(el);
  2163. }
  2164. }
  2165. return originalCreateElement.apply(void 0, [ el ].concat( args ))
  2166. };
  2167. vm[CREATE_ELEMENT_ALIAS] = createElement;
  2168. vm.$createElement = createElement;
  2169. }
  2170. _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = patchCreateElementMixin, obj ));
  2171. }
  2172. //
  2173. 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; }
  2174. function createContext(options, scopedSlots, currentProps) {
  2175. var on = Object.assign({}, (options.context && options.context.on),
  2176. options.listeners);
  2177. return Object.assign({}, {attrs: Object.assign({}, options.attrs,
  2178. // pass as attrs so that inheritAttrs works correctly
  2179. // props should take precedence over attrs
  2180. currentProps)},
  2181. (options.context || {}),
  2182. {on: on,
  2183. scopedSlots: scopedSlots})
  2184. }
  2185. function createChildren(vm, h, ref) {
  2186. var slots = ref.slots;
  2187. var context = ref.context;
  2188. var slotVNodes = slots ? createSlotVNodes(vm, slots) : undefined;
  2189. return (
  2190. (context &&
  2191. context.children &&
  2192. context.children.map(function (x) { return (typeof x === 'function' ? x(h) : x); })) ||
  2193. slotVNodes
  2194. )
  2195. }
  2196. function getValuesFromCallableOption(optionValue) {
  2197. if (typeof optionValue === 'function') {
  2198. return optionValue.call(this)
  2199. }
  2200. return optionValue
  2201. }
  2202. function createInstance(
  2203. component,
  2204. options,
  2205. _Vue
  2206. ) {
  2207. var componentOptions = isConstructor(component)
  2208. ? component.options
  2209. : component;
  2210. // instance options are options that are passed to the
  2211. // root instance when it's instantiated
  2212. var instanceOptions = extractInstanceOptions(options);
  2213. var globalComponents = _Vue.options.components || {};
  2214. var componentsToStub = Object.assign(
  2215. Object.create(globalComponents),
  2216. componentOptions.components
  2217. );
  2218. var stubComponentsObject = createStubsFromStubsObject(
  2219. componentsToStub,
  2220. // $FlowIgnore
  2221. options.stubs,
  2222. _Vue
  2223. );
  2224. addEventLogger(_Vue);
  2225. addMocks(_Vue, options.mocks);
  2226. addStubs(_Vue, stubComponentsObject);
  2227. patchCreateElement(_Vue, stubComponentsObject, options.shouldProxy);
  2228. if (componentNeedsCompiling(componentOptions)) {
  2229. compileTemplate(componentOptions);
  2230. }
  2231. // used to identify extended component using constructor
  2232. componentOptions.$_vueTestUtils_original = component;
  2233. // watchers provided in mounting options should override preexisting ones
  2234. if (componentOptions.watch && instanceOptions.watch) {
  2235. var componentWatchers = Object.keys(componentOptions.watch);
  2236. var instanceWatchers = Object.keys(instanceOptions.watch);
  2237. for (var i = 0; i < instanceWatchers.length; i++) {
  2238. var k = instanceWatchers[i];
  2239. // override the componentOptions with the one provided in mounting options
  2240. if (componentWatchers.includes(k)) {
  2241. componentOptions.watch[k] = instanceOptions.watch[k];
  2242. }
  2243. }
  2244. }
  2245. // make sure all extends are based on this instance
  2246. var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
  2247. Constructor.options._base = _Vue;
  2248. var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);
  2249. var parentComponentOptions = options.parentComponent || {};
  2250. var originalParentComponentProvide = parentComponentOptions.provide;
  2251. parentComponentOptions.provide = function() {
  2252. return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
  2253. // $FlowIgnore
  2254. getValuesFromCallableOption.call(this, options.provide))
  2255. };
  2256. var originalParentComponentData = parentComponentOptions.data;
  2257. parentComponentOptions.data = function() {
  2258. return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentData),
  2259. {vueTestUtils_childProps: Object.assign({}, options.propsData)})
  2260. };
  2261. parentComponentOptions.$_doNotStubChildren = true;
  2262. parentComponentOptions.$_isWrapperParent = true;
  2263. parentComponentOptions._isFunctionalContainer = componentOptions.functional;
  2264. parentComponentOptions.render = function(h) {
  2265. return h(
  2266. Constructor,
  2267. createContext(options, scopedSlots, this.vueTestUtils_childProps),
  2268. createChildren(this, h, options)
  2269. )
  2270. };
  2271. // options "propsData" can only be used during instance creation with the `new` keyword
  2272. // "data" should be set only on component under test to avoid reactivity issues
  2273. var propsData = options.propsData;
  2274. var data = options.data;
  2275. var rest$1 = objectWithoutProperties( options, ["propsData", "data"] );
  2276. var rest = rest$1; // eslint-disable-line
  2277. var Parent = _Vue.extend(Object.assign({}, rest,
  2278. parentComponentOptions));
  2279. return new Parent()
  2280. }
  2281. //
  2282. function createElement() {
  2283. if (document) {
  2284. var elem = document.createElement('div');
  2285. if (document.body) {
  2286. document.body.appendChild(elem);
  2287. }
  2288. return elem
  2289. }
  2290. }
  2291. //
  2292. function findDOMNodes(
  2293. element,
  2294. selector
  2295. ) {
  2296. var nodes = [];
  2297. if (!element || !element.querySelectorAll || !element.matches) {
  2298. return nodes
  2299. }
  2300. if (element.matches(selector)) {
  2301. nodes.push(element);
  2302. }
  2303. // $FlowIgnore
  2304. return nodes.concat([].slice.call(element.querySelectorAll(selector)))
  2305. }
  2306. function vmMatchesName(vm, name) {
  2307. // We want to mirror how Vue resolves component names in SFCs:
  2308. // For example, <test-component />, <TestComponent /> and `<testComponent />
  2309. // all resolve to the same component
  2310. var componentName = isFunctionalComponent(vm)
  2311. ? vm.name
  2312. : vm.$options && vm.$options.name;
  2313. return (
  2314. !!name &&
  2315. !!componentName &&
  2316. (componentName === name ||
  2317. // testComponent -> TestComponent
  2318. componentName === capitalize(name) ||
  2319. // test-component -> TestComponent
  2320. componentName === capitalize(camelize(name)) ||
  2321. // same match as above, but the component name vs query
  2322. capitalize(camelize(componentName)) === name)
  2323. )
  2324. }
  2325. function vmCtorMatches(vm, component) {
  2326. if (
  2327. (vm.$options && vm.$options.$_vueTestUtils_original === component) ||
  2328. vm.$_vueTestUtils_original === component
  2329. ) {
  2330. return true
  2331. }
  2332. var Ctor = isConstructor(component)
  2333. ? component.options._Ctor
  2334. : component._Ctor;
  2335. if (!Ctor) {
  2336. return false
  2337. }
  2338. if (vm.constructor.extendOptions === component) {
  2339. return true
  2340. }
  2341. if (component.functional) {
  2342. return Object.keys(vm._Ctor || {}).some(function (c) {
  2343. return component === vm._Ctor[c].extendOptions
  2344. })
  2345. }
  2346. }
  2347. function matches(node, selector) {
  2348. if (selector.type === DOM_SELECTOR) {
  2349. var element = node instanceof Element ? node : node.elm;
  2350. return element && element.matches && element.matches(selector.value)
  2351. }
  2352. var isFunctionalSelector = isConstructor(selector.value)
  2353. ? selector.value.options.functional
  2354. : selector.value.functional;
  2355. var componentInstance =
  2356. (isFunctionalSelector ? node[FUNCTIONAL_OPTIONS] : node.child) ||
  2357. node[FUNCTIONAL_OPTIONS] ||
  2358. node.child;
  2359. if (!componentInstance) {
  2360. return false
  2361. }
  2362. if (selector.type === COMPONENT_SELECTOR) {
  2363. if (vmCtorMatches(componentInstance, selector.value)) {
  2364. return true
  2365. }
  2366. }
  2367. // Fallback to name selector for COMPONENT_SELECTOR for Vue < 2.1
  2368. var nameSelector = isConstructor(selector.value)
  2369. ? selector.value.extendOptions.name
  2370. : selector.value.name;
  2371. return vmMatchesName(componentInstance, nameSelector)
  2372. }
  2373. //
  2374. /**
  2375. * Traverses a vue instance for its parents and returns them in an array format
  2376. * @param {Component} vm
  2377. * @returns {Component[]} The component and its corresponding parents, in order from left to right
  2378. */
  2379. function findAllParentInstances(childVm) {
  2380. var instances = [childVm];
  2381. function getParent(_vm) {
  2382. if (_vm && _vm.$parent) {
  2383. instances.push(_vm.$parent);
  2384. return getParent(_vm.$parent)
  2385. }
  2386. return _vm
  2387. }
  2388. getParent(childVm);
  2389. return instances
  2390. }
  2391. function findAllInstances(rootVm) {
  2392. var instances = [rootVm];
  2393. var i = 0;
  2394. while (i < instances.length) {
  2395. var vm = instances[i]
  2396. ;(vm.$children || []).forEach(function (child) {
  2397. instances.push(child);
  2398. });
  2399. i++;
  2400. }
  2401. return instances
  2402. }
  2403. function findAllVNodes(vnode, selector) {
  2404. var matchingNodes = [];
  2405. var nodes = [vnode];
  2406. while (nodes.length) {
  2407. var node = nodes.shift();
  2408. if (node.children) {
  2409. var children = [].concat( node.children ).reverse();
  2410. children.forEach(function (n) {
  2411. nodes.unshift(n);
  2412. });
  2413. }
  2414. if (node.child) {
  2415. nodes.unshift(node.child._vnode);
  2416. }
  2417. if (matches(node, selector)) {
  2418. matchingNodes.push(node);
  2419. }
  2420. }
  2421. return matchingNodes
  2422. }
  2423. function removeDuplicateNodes(vNodes) {
  2424. var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
  2425. return vNodes.filter(function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); })
  2426. }
  2427. function find(
  2428. root,
  2429. vm,
  2430. selector
  2431. ) {
  2432. if (root instanceof Element && selector.type !== DOM_SELECTOR) {
  2433. throwError(
  2434. "cannot find a Vue instance on a DOM node. The node " +
  2435. "you are calling find on does not exist in the " +
  2436. "VDom. Are you adding the node as innerHTML?"
  2437. );
  2438. }
  2439. if (
  2440. selector.type === COMPONENT_SELECTOR &&
  2441. (selector.value.functional ||
  2442. (selector.value.options && selector.value.options.functional)) &&
  2443. VUE_VERSION < 2.3
  2444. ) {
  2445. throwError(
  2446. "find for functional components is not supported " + "in Vue < 2.3"
  2447. );
  2448. }
  2449. if (root instanceof Element) {
  2450. return findDOMNodes(root, selector.value)
  2451. }
  2452. if (!root && selector.type !== DOM_SELECTOR) {
  2453. throwError(
  2454. "cannot find a Vue instance on a DOM node. The node " +
  2455. "you are calling find on does not exist in the " +
  2456. "VDom. Are you adding the node as innerHTML?"
  2457. );
  2458. }
  2459. if (!vm && selector.type === REF_SELECTOR) {
  2460. throwError("$ref selectors can only be used on Vue component " + "wrappers");
  2461. }
  2462. if (vm && vm.$refs && selector.value.ref in vm.$refs) {
  2463. var refs = vm.$refs[selector.value.ref];
  2464. return Array.isArray(refs) ? refs : [refs]
  2465. }
  2466. var nodes = findAllVNodes(root, selector);
  2467. var dedupedNodes = removeDuplicateNodes(nodes);
  2468. if (nodes.length > 0 || selector.type !== DOM_SELECTOR) {
  2469. return dedupedNodes
  2470. }
  2471. // Fallback in case element exists in HTML, but not in vnode tree
  2472. // (e.g. if innerHTML is set as a domProp)
  2473. return findDOMNodes(root.elm, selector.value)
  2474. }
  2475. function errorHandler(errorOrString, vm, info) {
  2476. var error =
  2477. typeof errorOrString === 'object' ? errorOrString : new Error(errorOrString);
  2478. // If a user defined errorHandler was register via createLocalVue
  2479. // find and call the user defined errorHandler
  2480. var instancedErrorHandlers = findAllParentInstances(vm)
  2481. .filter(
  2482. function (_vm) { return _vm &&
  2483. _vm.$options &&
  2484. _vm.$options.localVue &&
  2485. _vm.$options.localVue.config &&
  2486. _vm.$options.localVue.config.errorHandler; }
  2487. )
  2488. .map(function (_vm) { return _vm.$options.localVue.config.errorHandler; });
  2489. if (vm) {
  2490. vm._error = error;
  2491. }
  2492. if (!instancedErrorHandlers.length) {
  2493. throw error
  2494. }
  2495. // should be one error handler, as only once can be registered with local vue
  2496. // regardless, if more exist (for whatever reason), invoke the other user defined error handlers
  2497. instancedErrorHandlers.forEach(function (instancedErrorHandler) {
  2498. instancedErrorHandler(error, vm, info);
  2499. });
  2500. }
  2501. function throwIfInstancesThrew(vm) {
  2502. var instancesWithError = findAllInstances(vm).filter(function (_vm) { return _vm._error; });
  2503. if (instancesWithError.length > 0) {
  2504. throw instancesWithError[0]._error
  2505. }
  2506. }
  2507. var hasWarned = false;
  2508. // Vue swallows errors thrown by instances, even if the global error handler
  2509. // throws. In order to throw in the test, we add an _error property to an
  2510. // instance when it throws. Then we loop through the instances with
  2511. // throwIfInstancesThrew and throw an error in the test context if any
  2512. // instances threw.
  2513. function addGlobalErrorHandler(_Vue) {
  2514. var existingErrorHandler = _Vue.config.errorHandler;
  2515. if (existingErrorHandler === errorHandler) {
  2516. return
  2517. }
  2518. if (_Vue.config.errorHandler && !hasWarned) {
  2519. warn(
  2520. "Global error handler detected (Vue.config.errorHandler). \n" +
  2521. "Vue Test Utils sets a custom error handler to throw errors " +
  2522. "thrown by instances. If you want this behavior in " +
  2523. "your tests, you must remove the global error handler."
  2524. );
  2525. hasWarned = true;
  2526. } else {
  2527. _Vue.config.errorHandler = errorHandler;
  2528. }
  2529. }
  2530. function normalizeStubs(stubs) {
  2531. if ( stubs === void 0 ) stubs = {};
  2532. if (stubs === false) {
  2533. return false
  2534. }
  2535. if (isPlainObject(stubs)) {
  2536. return stubs
  2537. }
  2538. if (Array.isArray(stubs)) {
  2539. return stubs.reduce(function (acc, stub) {
  2540. if (typeof stub !== 'string') {
  2541. throwError('each item in an options.stubs array must be a string');
  2542. }
  2543. acc[stub] = true;
  2544. return acc
  2545. }, {})
  2546. }
  2547. throwError('options.stubs must be an object or an Array');
  2548. }
  2549. function normalizeProvide(provide) {
  2550. // Objects are not resolved in extended components in Vue < 2.5
  2551. // https://github.com/vuejs/vue/issues/6436
  2552. if (typeof provide === 'object' && VUE_VERSION < 2.5) {
  2553. var obj = Object.assign({}, provide);
  2554. return function () { return obj; }
  2555. }
  2556. return provide
  2557. }
  2558. //
  2559. function getOption(option, config) {
  2560. if (option === false) {
  2561. return false
  2562. }
  2563. if (option || (config && Object.keys(config).length > 0)) {
  2564. if (option instanceof Function) {
  2565. return option
  2566. }
  2567. if (config instanceof Function) {
  2568. throw new Error("Config can't be a Function.")
  2569. }
  2570. return Object.assign({}, config,
  2571. option)
  2572. }
  2573. }
  2574. function getStubs(stubs, configStubs) {
  2575. var normalizedStubs = normalizeStubs(stubs);
  2576. var normalizedConfigStubs = normalizeStubs(configStubs);
  2577. return getOption(normalizedStubs, normalizedConfigStubs)
  2578. }
  2579. function mergeOptions(
  2580. options,
  2581. config
  2582. ) {
  2583. var mocks = (getOption(options.mocks, config.mocks));
  2584. var methods = (getOption(options.methods, config.methods));
  2585. if (methods && Object.keys(methods).length) {
  2586. warnDeprecated(
  2587. 'overwriting methods via the `methods` property',
  2588. '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'
  2589. );
  2590. }
  2591. var provide = (getOption(options.provide, config.provide));
  2592. var stubs = (getStubs(options.stubs, config.stubs));
  2593. // $FlowIgnore
  2594. return Object.assign({}, options,
  2595. {provide: normalizeProvide(provide),
  2596. stubs: stubs,
  2597. mocks: mocks,
  2598. methods: methods})
  2599. }
  2600. var config = {
  2601. stubs: {
  2602. transition: true,
  2603. 'transition-group': true
  2604. },
  2605. mocks: {},
  2606. methods: {},
  2607. provide: {},
  2608. showDeprecationWarnings:
  2609. true
  2610. };
  2611. //
  2612. function warnIfNoWindow() {
  2613. if (typeof window === 'undefined') {
  2614. throwError(
  2615. "window is undefined, vue-test-utils needs to be " +
  2616. "run in a browser environment. \n" +
  2617. "You can run the tests in node using jsdom \n" +
  2618. "See https://vue-test-utils.vuejs.org/guides/#browser-environment " +
  2619. "for more details."
  2620. );
  2621. }
  2622. }
  2623. function polyfill() {
  2624. // Polyfill `Element.matches()` for IE and older versions of Chrome:
  2625. // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
  2626. if (!Element.prototype.matches) {
  2627. Element.prototype.matches =
  2628. Element.prototype.msMatchesSelector ||
  2629. Element.prototype.webkitMatchesSelector;
  2630. }
  2631. }
  2632. /*jshint node:true */
  2633. function OutputLine(parent) {
  2634. this.__parent = parent;
  2635. this.__character_count = 0;
  2636. // use indent_count as a marker for this.__lines that have preserved indentation
  2637. this.__indent_count = -1;
  2638. this.__alignment_count = 0;
  2639. this.__wrap_point_index = 0;
  2640. this.__wrap_point_character_count = 0;
  2641. this.__wrap_point_indent_count = -1;
  2642. this.__wrap_point_alignment_count = 0;
  2643. this.__items = [];
  2644. }
  2645. OutputLine.prototype.clone_empty = function() {
  2646. var line = new OutputLine(this.__parent);
  2647. line.set_indent(this.__indent_count, this.__alignment_count);
  2648. return line;
  2649. };
  2650. OutputLine.prototype.item = function(index) {
  2651. if (index < 0) {
  2652. return this.__items[this.__items.length + index];
  2653. } else {
  2654. return this.__items[index];
  2655. }
  2656. };
  2657. OutputLine.prototype.has_match = function(pattern) {
  2658. for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
  2659. if (this.__items[lastCheckedOutput].match(pattern)) {
  2660. return true;
  2661. }
  2662. }
  2663. return false;
  2664. };
  2665. OutputLine.prototype.set_indent = function(indent, alignment) {
  2666. if (this.is_empty()) {
  2667. this.__indent_count = indent || 0;
  2668. this.__alignment_count = alignment || 0;
  2669. this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
  2670. }
  2671. };
  2672. OutputLine.prototype._set_wrap_point = function() {
  2673. if (this.__parent.wrap_line_length) {
  2674. this.__wrap_point_index = this.__items.length;
  2675. this.__wrap_point_character_count = this.__character_count;
  2676. this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
  2677. this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
  2678. }
  2679. };
  2680. OutputLine.prototype._should_wrap = function() {
  2681. return this.__wrap_point_index &&
  2682. this.__character_count > this.__parent.wrap_line_length &&
  2683. this.__wrap_point_character_count > this.__parent.next_line.__character_count;
  2684. };
  2685. OutputLine.prototype._allow_wrap = function() {
  2686. if (this._should_wrap()) {
  2687. this.__parent.add_new_line();
  2688. var next = this.__parent.current_line;
  2689. next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
  2690. next.__items = this.__items.slice(this.__wrap_point_index);
  2691. this.__items = this.__items.slice(0, this.__wrap_point_index);
  2692. next.__character_count += this.__character_count - this.__wrap_point_character_count;
  2693. this.__character_count = this.__wrap_point_character_count;
  2694. if (next.__items[0] === " ") {
  2695. next.__items.splice(0, 1);
  2696. next.__character_count -= 1;
  2697. }
  2698. return true;
  2699. }
  2700. return false;
  2701. };
  2702. OutputLine.prototype.is_empty = function() {
  2703. return this.__items.length === 0;
  2704. };
  2705. OutputLine.prototype.last = function() {
  2706. if (!this.is_empty()) {
  2707. return this.__items[this.__items.length - 1];
  2708. } else {
  2709. return null;
  2710. }
  2711. };
  2712. OutputLine.prototype.push = function(item) {
  2713. this.__items.push(item);
  2714. var last_newline_index = item.lastIndexOf('\n');
  2715. if (last_newline_index !== -1) {
  2716. this.__character_count = item.length - last_newline_index;
  2717. } else {
  2718. this.__character_count += item.length;
  2719. }
  2720. };
  2721. OutputLine.prototype.pop = function() {
  2722. var item = null;
  2723. if (!this.is_empty()) {
  2724. item = this.__items.pop();
  2725. this.__character_count -= item.length;
  2726. }
  2727. return item;
  2728. };
  2729. OutputLine.prototype._remove_indent = function() {
  2730. if (this.__indent_count > 0) {
  2731. this.__indent_count -= 1;
  2732. this.__character_count -= this.__parent.indent_size;
  2733. }
  2734. };
  2735. OutputLine.prototype._remove_wrap_indent = function() {
  2736. if (this.__wrap_point_indent_count > 0) {
  2737. this.__wrap_point_indent_count -= 1;
  2738. }
  2739. };
  2740. OutputLine.prototype.trim = function() {
  2741. while (this.last() === ' ') {
  2742. this.__items.pop();
  2743. this.__character_count -= 1;
  2744. }
  2745. };
  2746. OutputLine.prototype.toString = function() {
  2747. var result = '';
  2748. if (this.is_empty()) {
  2749. if (this.__parent.indent_empty_lines) {
  2750. result = this.__parent.get_indent_string(this.__indent_count);
  2751. }
  2752. } else {
  2753. result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
  2754. result += this.__items.join('');
  2755. }
  2756. return result;
  2757. };
  2758. function IndentStringCache(options, baseIndentString) {
  2759. this.__cache = [''];
  2760. this.__indent_size = options.indent_size;
  2761. this.__indent_string = options.indent_char;
  2762. if (!options.indent_with_tabs) {
  2763. this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
  2764. }
  2765. // Set to null to continue support for auto detection of base indent
  2766. baseIndentString = baseIndentString || '';
  2767. if (options.indent_level > 0) {
  2768. baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
  2769. }
  2770. this.__base_string = baseIndentString;
  2771. this.__base_string_length = baseIndentString.length;
  2772. }
  2773. IndentStringCache.prototype.get_indent_size = function(indent, column) {
  2774. var result = this.__base_string_length;
  2775. column = column || 0;
  2776. if (indent < 0) {
  2777. result = 0;
  2778. }
  2779. result += indent * this.__indent_size;
  2780. result += column;
  2781. return result;
  2782. };
  2783. IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
  2784. var result = this.__base_string;
  2785. column = column || 0;
  2786. if (indent_level < 0) {
  2787. indent_level = 0;
  2788. result = '';
  2789. }
  2790. column += indent_level * this.__indent_size;
  2791. this.__ensure_cache(column);
  2792. result += this.__cache[column];
  2793. return result;
  2794. };
  2795. IndentStringCache.prototype.__ensure_cache = function(column) {
  2796. while (column >= this.__cache.length) {
  2797. this.__add_column();
  2798. }
  2799. };
  2800. IndentStringCache.prototype.__add_column = function() {
  2801. var column = this.__cache.length;
  2802. var indent = 0;
  2803. var result = '';
  2804. if (this.__indent_size && column >= this.__indent_size) {
  2805. indent = Math.floor(column / this.__indent_size);
  2806. column -= indent * this.__indent_size;
  2807. result = new Array(indent + 1).join(this.__indent_string);
  2808. }
  2809. if (column) {
  2810. result += new Array(column + 1).join(' ');
  2811. }
  2812. this.__cache.push(result);
  2813. };
  2814. function Output(options, baseIndentString) {
  2815. this.__indent_cache = new IndentStringCache(options, baseIndentString);
  2816. this.raw = false;
  2817. this._end_with_newline = options.end_with_newline;
  2818. this.indent_size = options.indent_size;
  2819. this.wrap_line_length = options.wrap_line_length;
  2820. this.indent_empty_lines = options.indent_empty_lines;
  2821. this.__lines = [];
  2822. this.previous_line = null;
  2823. this.current_line = null;
  2824. this.next_line = new OutputLine(this);
  2825. this.space_before_token = false;
  2826. this.non_breaking_space = false;
  2827. this.previous_token_wrapped = false;
  2828. // initialize
  2829. this.__add_outputline();
  2830. }
  2831. Output.prototype.__add_outputline = function() {
  2832. this.previous_line = this.current_line;
  2833. this.current_line = this.next_line.clone_empty();
  2834. this.__lines.push(this.current_line);
  2835. };
  2836. Output.prototype.get_line_number = function() {
  2837. return this.__lines.length;
  2838. };
  2839. Output.prototype.get_indent_string = function(indent, column) {
  2840. return this.__indent_cache.get_indent_string(indent, column);
  2841. };
  2842. Output.prototype.get_indent_size = function(indent, column) {
  2843. return this.__indent_cache.get_indent_size(indent, column);
  2844. };
  2845. Output.prototype.is_empty = function() {
  2846. return !this.previous_line && this.current_line.is_empty();
  2847. };
  2848. Output.prototype.add_new_line = function(force_newline) {
  2849. // never newline at the start of file
  2850. // otherwise, newline only if we didn't just add one or we're forced
  2851. if (this.is_empty() ||
  2852. (!force_newline && this.just_added_newline())) {
  2853. return false;
  2854. }
  2855. // if raw output is enabled, don't print additional newlines,
  2856. // but still return True as though you had
  2857. if (!this.raw) {
  2858. this.__add_outputline();
  2859. }
  2860. return true;
  2861. };
  2862. Output.prototype.get_code = function(eol) {
  2863. this.trim(true);
  2864. // handle some edge cases where the last tokens
  2865. // has text that ends with newline(s)
  2866. var last_item = this.current_line.pop();
  2867. if (last_item) {
  2868. if (last_item[last_item.length - 1] === '\n') {
  2869. last_item = last_item.replace(/\n+$/g, '');
  2870. }
  2871. this.current_line.push(last_item);
  2872. }
  2873. if (this._end_with_newline) {
  2874. this.__add_outputline();
  2875. }
  2876. var sweet_code = this.__lines.join('\n');
  2877. if (eol !== '\n') {
  2878. sweet_code = sweet_code.replace(/[\n]/g, eol);
  2879. }
  2880. return sweet_code;
  2881. };
  2882. Output.prototype.set_wrap_point = function() {
  2883. this.current_line._set_wrap_point();
  2884. };
  2885. Output.prototype.set_indent = function(indent, alignment) {
  2886. indent = indent || 0;
  2887. alignment = alignment || 0;
  2888. // Next line stores alignment values
  2889. this.next_line.set_indent(indent, alignment);
  2890. // Never indent your first output indent at the start of the file
  2891. if (this.__lines.length > 1) {
  2892. this.current_line.set_indent(indent, alignment);
  2893. return true;
  2894. }
  2895. this.current_line.set_indent();
  2896. return false;
  2897. };
  2898. Output.prototype.add_raw_token = function(token) {
  2899. for (var x = 0; x < token.newlines; x++) {
  2900. this.__add_outputline();
  2901. }
  2902. this.current_line.set_indent(-1);
  2903. this.current_line.push(token.whitespace_before);
  2904. this.current_line.push(token.text);
  2905. this.space_before_token = false;
  2906. this.non_breaking_space = false;
  2907. this.previous_token_wrapped = false;
  2908. };
  2909. Output.prototype.add_token = function(printable_token) {
  2910. this.__add_space_before_token();
  2911. this.current_line.push(printable_token);
  2912. this.space_before_token = false;
  2913. this.non_breaking_space = false;
  2914. this.previous_token_wrapped = this.current_line._allow_wrap();
  2915. };
  2916. Output.prototype.__add_space_before_token = function() {
  2917. if (this.space_before_token && !this.just_added_newline()) {
  2918. if (!this.non_breaking_space) {
  2919. this.set_wrap_point();
  2920. }
  2921. this.current_line.push(' ');
  2922. }
  2923. };
  2924. Output.prototype.remove_indent = function(index) {
  2925. var output_length = this.__lines.length;
  2926. while (index < output_length) {
  2927. this.__lines[index]._remove_indent();
  2928. index++;
  2929. }
  2930. this.current_line._remove_wrap_indent();
  2931. };
  2932. Output.prototype.trim = function(eat_newlines) {
  2933. eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
  2934. this.current_line.trim();
  2935. while (eat_newlines && this.__lines.length > 1 &&
  2936. this.current_line.is_empty()) {
  2937. this.__lines.pop();
  2938. this.current_line = this.__lines[this.__lines.length - 1];
  2939. this.current_line.trim();
  2940. }
  2941. this.previous_line = this.__lines.length > 1 ?
  2942. this.__lines[this.__lines.length - 2] : null;
  2943. };
  2944. Output.prototype.just_added_newline = function() {
  2945. return this.current_line.is_empty();
  2946. };
  2947. Output.prototype.just_added_blankline = function() {
  2948. return this.is_empty() ||
  2949. (this.current_line.is_empty() && this.previous_line.is_empty());
  2950. };
  2951. Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
  2952. var index = this.__lines.length - 2;
  2953. while (index >= 0) {
  2954. var potentialEmptyLine = this.__lines[index];
  2955. if (potentialEmptyLine.is_empty()) {
  2956. break;
  2957. } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
  2958. potentialEmptyLine.item(-1) !== ends_with) {
  2959. this.__lines.splice(index + 1, 0, new OutputLine(this));
  2960. this.previous_line = this.__lines[this.__lines.length - 2];
  2961. break;
  2962. }
  2963. index--;
  2964. }
  2965. };
  2966. var Output_1 = Output;
  2967. var output = {
  2968. Output: Output_1
  2969. };
  2970. /*jshint node:true */
  2971. function Token(type, text, newlines, whitespace_before) {
  2972. this.type = type;
  2973. this.text = text;
  2974. // comments_before are
  2975. // comments that have a new line before them
  2976. // and may or may not have a newline after
  2977. // this is a set of comments before
  2978. this.comments_before = null; /* inline comment*/
  2979. // this.comments_after = new TokenStream(); // no new line before and newline after
  2980. this.newlines = newlines || 0;
  2981. this.whitespace_before = whitespace_before || '';
  2982. this.parent = null;
  2983. this.next = null;
  2984. this.previous = null;
  2985. this.opened = null;
  2986. this.closed = null;
  2987. this.directives = null;
  2988. }
  2989. var Token_1 = Token;
  2990. var token = {
  2991. Token: Token_1
  2992. };
  2993. var acorn = createCommonjsModule(function (module, exports) {
  2994. // acorn used char codes to squeeze the last bit of performance out
  2995. // Beautifier is okay without that, so we're using regex
  2996. // permit $ (36) and @ (64). @ is used in ES7 decorators.
  2997. // 65 through 91 are uppercase letters.
  2998. // permit _ (95).
  2999. // 97 through 123 are lowercase letters.
  3000. var baseASCIIidentifierStartChars = "\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
  3001. // inside an identifier @ is not allowed but 0-9 are.
  3002. var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
  3003. // Big ugly regular expressions that match characters in the
  3004. // whitespace, identifier, and identifier-start categories. These
  3005. // are only applied when a character is found to actually have a
  3006. // code point above 128.
  3007. 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";
  3008. 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";
  3009. //var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3010. //var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3011. var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
  3012. var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
  3013. exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
  3014. exports.identifierStart = new RegExp(identifierStart);
  3015. exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
  3016. // Whether a single character denotes a newline.
  3017. exports.newline = /[\n\r\u2028\u2029]/;
  3018. // Matches a whole line break (where CRLF is considered a single
  3019. // line break). Used to count lines.
  3020. // in javascript, these two differ
  3021. // in python they are the same, different methods are called on them
  3022. exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
  3023. exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
  3024. });
  3025. /*jshint node:true */
  3026. function Options(options, merge_child_field) {
  3027. this.raw_options = _mergeOpts(options, merge_child_field);
  3028. // Support passing the source text back with no change
  3029. this.disabled = this._get_boolean('disabled');
  3030. this.eol = this._get_characters('eol', 'auto');
  3031. this.end_with_newline = this._get_boolean('end_with_newline');
  3032. this.indent_size = this._get_number('indent_size', 4);
  3033. this.indent_char = this._get_characters('indent_char', ' ');
  3034. this.indent_level = this._get_number('indent_level');
  3035. this.preserve_newlines = this._get_boolean('preserve_newlines', true);
  3036. this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
  3037. if (!this.preserve_newlines) {
  3038. this.max_preserve_newlines = 0;
  3039. }
  3040. this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
  3041. if (this.indent_with_tabs) {
  3042. this.indent_char = '\t';
  3043. // indent_size behavior changed after 1.8.6
  3044. // It used to be that indent_size would be
  3045. // set to 1 for indent_with_tabs. That is no longer needed and
  3046. // actually doesn't make sense - why not use spaces? Further,
  3047. // that might produce unexpected behavior - tabs being used
  3048. // for single-column alignment. So, when indent_with_tabs is true
  3049. // and indent_size is 1, reset indent_size to 4.
  3050. if (this.indent_size === 1) {
  3051. this.indent_size = 4;
  3052. }
  3053. }
  3054. // Backwards compat with 1.3.x
  3055. this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
  3056. this.indent_empty_lines = this._get_boolean('indent_empty_lines');
  3057. // valid templating languages ['django', 'erb', 'handlebars', 'php']
  3058. // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
  3059. // other values ignored
  3060. this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
  3061. }
  3062. Options.prototype._get_array = function(name, default_value) {
  3063. var option_value = this.raw_options[name];
  3064. var result = default_value || [];
  3065. if (typeof option_value === 'object') {
  3066. if (option_value !== null && typeof option_value.concat === 'function') {
  3067. result = option_value.concat();
  3068. }
  3069. } else if (typeof option_value === 'string') {
  3070. result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
  3071. }
  3072. return result;
  3073. };
  3074. Options.prototype._get_boolean = function(name, default_value) {
  3075. var option_value = this.raw_options[name];
  3076. var result = option_value === undefined ? !!default_value : !!option_value;
  3077. return result;
  3078. };
  3079. Options.prototype._get_characters = function(name, default_value) {
  3080. var option_value = this.raw_options[name];
  3081. var result = default_value || '';
  3082. if (typeof option_value === 'string') {
  3083. result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
  3084. }
  3085. return result;
  3086. };
  3087. Options.prototype._get_number = function(name, default_value) {
  3088. var option_value = this.raw_options[name];
  3089. default_value = parseInt(default_value, 10);
  3090. if (isNaN(default_value)) {
  3091. default_value = 0;
  3092. }
  3093. var result = parseInt(option_value, 10);
  3094. if (isNaN(result)) {
  3095. result = default_value;
  3096. }
  3097. return result;
  3098. };
  3099. Options.prototype._get_selection = function(name, selection_list, default_value) {
  3100. var result = this._get_selection_list(name, selection_list, default_value);
  3101. if (result.length !== 1) {
  3102. throw new Error(
  3103. "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
  3104. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  3105. }
  3106. return result[0];
  3107. };
  3108. Options.prototype._get_selection_list = function(name, selection_list, default_value) {
  3109. if (!selection_list || selection_list.length === 0) {
  3110. throw new Error("Selection list cannot be empty.");
  3111. }
  3112. default_value = default_value || [selection_list[0]];
  3113. if (!this._is_valid_selection(default_value, selection_list)) {
  3114. throw new Error("Invalid Default Value!");
  3115. }
  3116. var result = this._get_array(name, default_value);
  3117. if (!this._is_valid_selection(result, selection_list)) {
  3118. throw new Error(
  3119. "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
  3120. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  3121. }
  3122. return result;
  3123. };
  3124. Options.prototype._is_valid_selection = function(result, selection_list) {
  3125. return result.length && selection_list.length &&
  3126. !result.some(function(item) { return selection_list.indexOf(item) === -1; });
  3127. };
  3128. // merges child options up with the parent options object
  3129. // Example: obj = {a: 1, b: {a: 2}}
  3130. // mergeOpts(obj, 'b')
  3131. //
  3132. // Returns: {a: 2}
  3133. function _mergeOpts(allOptions, childFieldName) {
  3134. var finalOpts = {};
  3135. allOptions = _normalizeOpts(allOptions);
  3136. var name;
  3137. for (name in allOptions) {
  3138. if (name !== childFieldName) {
  3139. finalOpts[name] = allOptions[name];
  3140. }
  3141. }
  3142. //merge in the per type settings for the childFieldName
  3143. if (childFieldName && allOptions[childFieldName]) {
  3144. for (name in allOptions[childFieldName]) {
  3145. finalOpts[name] = allOptions[childFieldName][name];
  3146. }
  3147. }
  3148. return finalOpts;
  3149. }
  3150. function _normalizeOpts(options) {
  3151. var convertedOpts = {};
  3152. var key;
  3153. for (key in options) {
  3154. var newKey = key.replace(/-/g, "_");
  3155. convertedOpts[newKey] = options[key];
  3156. }
  3157. return convertedOpts;
  3158. }
  3159. var Options_1 = Options;
  3160. var normalizeOpts = _normalizeOpts;
  3161. var mergeOpts = _mergeOpts;
  3162. var options = {
  3163. Options: Options_1,
  3164. normalizeOpts: normalizeOpts,
  3165. mergeOpts: mergeOpts
  3166. };
  3167. var BaseOptions = options.Options;
  3168. var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
  3169. function Options$1(options) {
  3170. BaseOptions.call(this, options, 'js');
  3171. // compatibility, re
  3172. var raw_brace_style = this.raw_options.brace_style || null;
  3173. if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
  3174. this.raw_options.brace_style = "expand";
  3175. } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
  3176. this.raw_options.brace_style = "collapse,preserve-inline";
  3177. } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
  3178. this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
  3179. // } else if (!raw_brace_style) { //Nothing exists to set it
  3180. // raw_brace_style = "collapse";
  3181. }
  3182. //preserve-inline in delimited string will trigger brace_preserve_inline, everything
  3183. //else is considered a brace_style and the last one only will have an effect
  3184. var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
  3185. this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
  3186. this.brace_style = "collapse";
  3187. for (var bs = 0; bs < brace_style_split.length; bs++) {
  3188. if (brace_style_split[bs] === "preserve-inline") {
  3189. this.brace_preserve_inline = true;
  3190. } else {
  3191. this.brace_style = brace_style_split[bs];
  3192. }
  3193. }
  3194. this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
  3195. this.break_chained_methods = this._get_boolean('break_chained_methods');
  3196. this.space_in_paren = this._get_boolean('space_in_paren');
  3197. this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
  3198. this.jslint_happy = this._get_boolean('jslint_happy');
  3199. this.space_after_anon_function = this._get_boolean('space_after_anon_function');
  3200. this.space_after_named_function = this._get_boolean('space_after_named_function');
  3201. this.keep_array_indentation = this._get_boolean('keep_array_indentation');
  3202. this.space_before_conditional = this._get_boolean('space_before_conditional', true);
  3203. this.unescape_strings = this._get_boolean('unescape_strings');
  3204. this.e4x = this._get_boolean('e4x');
  3205. this.comma_first = this._get_boolean('comma_first');
  3206. this.operator_position = this._get_selection('operator_position', validPositionValues);
  3207. // For testing of beautify preserve:start directive
  3208. this.test_output_raw = this._get_boolean('test_output_raw');
  3209. // force this._options.space_after_anon_function to true if this._options.jslint_happy
  3210. if (this.jslint_happy) {
  3211. this.space_after_anon_function = true;
  3212. }
  3213. }
  3214. Options$1.prototype = new BaseOptions();
  3215. var Options_1$1 = Options$1;
  3216. var options$1 = {
  3217. Options: Options_1$1
  3218. };
  3219. /*jshint node:true */
  3220. var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
  3221. function InputScanner(input_string) {
  3222. this.__input = input_string || '';
  3223. this.__input_length = this.__input.length;
  3224. this.__position = 0;
  3225. }
  3226. InputScanner.prototype.restart = function() {
  3227. this.__position = 0;
  3228. };
  3229. InputScanner.prototype.back = function() {
  3230. if (this.__position > 0) {
  3231. this.__position -= 1;
  3232. }
  3233. };
  3234. InputScanner.prototype.hasNext = function() {
  3235. return this.__position < this.__input_length;
  3236. };
  3237. InputScanner.prototype.next = function() {
  3238. var val = null;
  3239. if (this.hasNext()) {
  3240. val = this.__input.charAt(this.__position);
  3241. this.__position += 1;
  3242. }
  3243. return val;
  3244. };
  3245. InputScanner.prototype.peek = function(index) {
  3246. var val = null;
  3247. index = index || 0;
  3248. index += this.__position;
  3249. if (index >= 0 && index < this.__input_length) {
  3250. val = this.__input.charAt(index);
  3251. }
  3252. return val;
  3253. };
  3254. // This is a JavaScript only helper function (not in python)
  3255. // Javascript doesn't have a match method
  3256. // and not all implementation support "sticky" flag.
  3257. // If they do not support sticky then both this.match() and this.test() method
  3258. // must get the match and check the index of the match.
  3259. // If sticky is supported and set, this method will use it.
  3260. // Otherwise it will check that global is set, and fall back to the slower method.
  3261. InputScanner.prototype.__match = function(pattern, index) {
  3262. pattern.lastIndex = index;
  3263. var pattern_match = pattern.exec(this.__input);
  3264. if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
  3265. if (pattern_match.index !== index) {
  3266. pattern_match = null;
  3267. }
  3268. }
  3269. return pattern_match;
  3270. };
  3271. InputScanner.prototype.test = function(pattern, index) {
  3272. index = index || 0;
  3273. index += this.__position;
  3274. if (index >= 0 && index < this.__input_length) {
  3275. return !!this.__match(pattern, index);
  3276. } else {
  3277. return false;
  3278. }
  3279. };
  3280. InputScanner.prototype.testChar = function(pattern, index) {
  3281. // test one character regex match
  3282. var val = this.peek(index);
  3283. pattern.lastIndex = 0;
  3284. return val !== null && pattern.test(val);
  3285. };
  3286. InputScanner.prototype.match = function(pattern) {
  3287. var pattern_match = this.__match(pattern, this.__position);
  3288. if (pattern_match) {
  3289. this.__position += pattern_match[0].length;
  3290. } else {
  3291. pattern_match = null;
  3292. }
  3293. return pattern_match;
  3294. };
  3295. InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
  3296. var val = '';
  3297. var match;
  3298. if (starting_pattern) {
  3299. match = this.match(starting_pattern);
  3300. if (match) {
  3301. val += match[0];
  3302. }
  3303. }
  3304. if (until_pattern && (match || !starting_pattern)) {
  3305. val += this.readUntil(until_pattern, until_after);
  3306. }
  3307. return val;
  3308. };
  3309. InputScanner.prototype.readUntil = function(pattern, until_after) {
  3310. var val = '';
  3311. var match_index = this.__position;
  3312. pattern.lastIndex = this.__position;
  3313. var pattern_match = pattern.exec(this.__input);
  3314. if (pattern_match) {
  3315. match_index = pattern_match.index;
  3316. if (until_after) {
  3317. match_index += pattern_match[0].length;
  3318. }
  3319. } else {
  3320. match_index = this.__input_length;
  3321. }
  3322. val = this.__input.substring(this.__position, match_index);
  3323. this.__position = match_index;
  3324. return val;
  3325. };
  3326. InputScanner.prototype.readUntilAfter = function(pattern) {
  3327. return this.readUntil(pattern, true);
  3328. };
  3329. InputScanner.prototype.get_regexp = function(pattern, match_from) {
  3330. var result = null;
  3331. var flags = 'g';
  3332. if (match_from && regexp_has_sticky) {
  3333. flags = 'y';
  3334. }
  3335. // strings are converted to regexp
  3336. if (typeof pattern === "string" && pattern !== '') {
  3337. // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
  3338. result = new RegExp(pattern, flags);
  3339. } else if (pattern) {
  3340. result = new RegExp(pattern.source, flags);
  3341. }
  3342. return result;
  3343. };
  3344. InputScanner.prototype.get_literal_regexp = function(literal_string) {
  3345. return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
  3346. };
  3347. /* css beautifier legacy helpers */
  3348. InputScanner.prototype.peekUntilAfter = function(pattern) {
  3349. var start = this.__position;
  3350. var val = this.readUntilAfter(pattern);
  3351. this.__position = start;
  3352. return val;
  3353. };
  3354. InputScanner.prototype.lookBack = function(testVal) {
  3355. var start = this.__position - 1;
  3356. return start >= testVal.length && this.__input.substring(start - testVal.length, start)
  3357. .toLowerCase() === testVal;
  3358. };
  3359. var InputScanner_1 = InputScanner;
  3360. var inputscanner = {
  3361. InputScanner: InputScanner_1
  3362. };
  3363. /*jshint node:true */
  3364. function TokenStream(parent_token) {
  3365. // private
  3366. this.__tokens = [];
  3367. this.__tokens_length = this.__tokens.length;
  3368. this.__position = 0;
  3369. this.__parent_token = parent_token;
  3370. }
  3371. TokenStream.prototype.restart = function() {
  3372. this.__position = 0;
  3373. };
  3374. TokenStream.prototype.isEmpty = function() {
  3375. return this.__tokens_length === 0;
  3376. };
  3377. TokenStream.prototype.hasNext = function() {
  3378. return this.__position < this.__tokens_length;
  3379. };
  3380. TokenStream.prototype.next = function() {
  3381. var val = null;
  3382. if (this.hasNext()) {
  3383. val = this.__tokens[this.__position];
  3384. this.__position += 1;
  3385. }
  3386. return val;
  3387. };
  3388. TokenStream.prototype.peek = function(index) {
  3389. var val = null;
  3390. index = index || 0;
  3391. index += this.__position;
  3392. if (index >= 0 && index < this.__tokens_length) {
  3393. val = this.__tokens[index];
  3394. }
  3395. return val;
  3396. };
  3397. TokenStream.prototype.add = function(token) {
  3398. if (this.__parent_token) {
  3399. token.parent = this.__parent_token;
  3400. }
  3401. this.__tokens.push(token);
  3402. this.__tokens_length += 1;
  3403. };
  3404. var TokenStream_1 = TokenStream;
  3405. var tokenstream = {
  3406. TokenStream: TokenStream_1
  3407. };
  3408. /*jshint node:true */
  3409. function Pattern(input_scanner, parent) {
  3410. this._input = input_scanner;
  3411. this._starting_pattern = null;
  3412. this._match_pattern = null;
  3413. this._until_pattern = null;
  3414. this._until_after = false;
  3415. if (parent) {
  3416. this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
  3417. this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
  3418. this._until_pattern = this._input.get_regexp(parent._until_pattern);
  3419. this._until_after = parent._until_after;
  3420. }
  3421. }
  3422. Pattern.prototype.read = function() {
  3423. var result = this._input.read(this._starting_pattern);
  3424. if (!this._starting_pattern || result) {
  3425. result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
  3426. }
  3427. return result;
  3428. };
  3429. Pattern.prototype.read_match = function() {
  3430. return this._input.match(this._match_pattern);
  3431. };
  3432. Pattern.prototype.until_after = function(pattern) {
  3433. var result = this._create();
  3434. result._until_after = true;
  3435. result._until_pattern = this._input.get_regexp(pattern);
  3436. result._update();
  3437. return result;
  3438. };
  3439. Pattern.prototype.until = function(pattern) {
  3440. var result = this._create();
  3441. result._until_after = false;
  3442. result._until_pattern = this._input.get_regexp(pattern);
  3443. result._update();
  3444. return result;
  3445. };
  3446. Pattern.prototype.starting_with = function(pattern) {
  3447. var result = this._create();
  3448. result._starting_pattern = this._input.get_regexp(pattern, true);
  3449. result._update();
  3450. return result;
  3451. };
  3452. Pattern.prototype.matching = function(pattern) {
  3453. var result = this._create();
  3454. result._match_pattern = this._input.get_regexp(pattern, true);
  3455. result._update();
  3456. return result;
  3457. };
  3458. Pattern.prototype._create = function() {
  3459. return new Pattern(this._input, this);
  3460. };
  3461. Pattern.prototype._update = function() {};
  3462. var Pattern_1 = Pattern;
  3463. var pattern = {
  3464. Pattern: Pattern_1
  3465. };
  3466. var Pattern$1 = pattern.Pattern;
  3467. function WhitespacePattern(input_scanner, parent) {
  3468. Pattern$1.call(this, input_scanner, parent);
  3469. if (parent) {
  3470. this._line_regexp = this._input.get_regexp(parent._line_regexp);
  3471. } else {
  3472. this.__set_whitespace_patterns('', '');
  3473. }
  3474. this.newline_count = 0;
  3475. this.whitespace_before_token = '';
  3476. }
  3477. WhitespacePattern.prototype = new Pattern$1();
  3478. WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
  3479. whitespace_chars += '\\t ';
  3480. newline_chars += '\\n\\r';
  3481. this._match_pattern = this._input.get_regexp(
  3482. '[' + whitespace_chars + newline_chars + ']+', true);
  3483. this._newline_regexp = this._input.get_regexp(
  3484. '\\r\\n|[' + newline_chars + ']');
  3485. };
  3486. WhitespacePattern.prototype.read = function() {
  3487. this.newline_count = 0;
  3488. this.whitespace_before_token = '';
  3489. var resulting_string = this._input.read(this._match_pattern);
  3490. if (resulting_string === ' ') {
  3491. this.whitespace_before_token = ' ';
  3492. } else if (resulting_string) {
  3493. var matches = this.__split(this._newline_regexp, resulting_string);
  3494. this.newline_count = matches.length - 1;
  3495. this.whitespace_before_token = matches[this.newline_count];
  3496. }
  3497. return resulting_string;
  3498. };
  3499. WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
  3500. var result = this._create();
  3501. result.__set_whitespace_patterns(whitespace_chars, newline_chars);
  3502. result._update();
  3503. return result;
  3504. };
  3505. WhitespacePattern.prototype._create = function() {
  3506. return new WhitespacePattern(this._input, this);
  3507. };
  3508. WhitespacePattern.prototype.__split = function(regexp, input_string) {
  3509. regexp.lastIndex = 0;
  3510. var start_index = 0;
  3511. var result = [];
  3512. var next_match = regexp.exec(input_string);
  3513. while (next_match) {
  3514. result.push(input_string.substring(start_index, next_match.index));
  3515. start_index = next_match.index + next_match[0].length;
  3516. next_match = regexp.exec(input_string);
  3517. }
  3518. if (start_index < input_string.length) {
  3519. result.push(input_string.substring(start_index, input_string.length));
  3520. } else {
  3521. result.push('');
  3522. }
  3523. return result;
  3524. };
  3525. var WhitespacePattern_1 = WhitespacePattern;
  3526. var whitespacepattern = {
  3527. WhitespacePattern: WhitespacePattern_1
  3528. };
  3529. var InputScanner$1 = inputscanner.InputScanner;
  3530. var Token$1 = token.Token;
  3531. var TokenStream$1 = tokenstream.TokenStream;
  3532. var WhitespacePattern$1 = whitespacepattern.WhitespacePattern;
  3533. var TOKEN = {
  3534. START: 'TK_START',
  3535. RAW: 'TK_RAW',
  3536. EOF: 'TK_EOF'
  3537. };
  3538. var Tokenizer = function(input_string, options) {
  3539. this._input = new InputScanner$1(input_string);
  3540. this._options = options || {};
  3541. this.__tokens = null;
  3542. this._patterns = {};
  3543. this._patterns.whitespace = new WhitespacePattern$1(this._input);
  3544. };
  3545. Tokenizer.prototype.tokenize = function() {
  3546. this._input.restart();
  3547. this.__tokens = new TokenStream$1();
  3548. this._reset();
  3549. var current;
  3550. var previous = new Token$1(TOKEN.START, '');
  3551. var open_token = null;
  3552. var open_stack = [];
  3553. var comments = new TokenStream$1();
  3554. while (previous.type !== TOKEN.EOF) {
  3555. current = this._get_next_token(previous, open_token);
  3556. while (this._is_comment(current)) {
  3557. comments.add(current);
  3558. current = this._get_next_token(previous, open_token);
  3559. }
  3560. if (!comments.isEmpty()) {
  3561. current.comments_before = comments;
  3562. comments = new TokenStream$1();
  3563. }
  3564. current.parent = open_token;
  3565. if (this._is_opening(current)) {
  3566. open_stack.push(open_token);
  3567. open_token = current;
  3568. } else if (open_token && this._is_closing(current, open_token)) {
  3569. current.opened = open_token;
  3570. open_token.closed = current;
  3571. open_token = open_stack.pop();
  3572. current.parent = open_token;
  3573. }
  3574. current.previous = previous;
  3575. previous.next = current;
  3576. this.__tokens.add(current);
  3577. previous = current;
  3578. }
  3579. return this.__tokens;
  3580. };
  3581. Tokenizer.prototype._is_first_token = function() {
  3582. return this.__tokens.isEmpty();
  3583. };
  3584. Tokenizer.prototype._reset = function() {};
  3585. Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  3586. this._readWhitespace();
  3587. var resulting_string = this._input.read(/.+/g);
  3588. if (resulting_string) {
  3589. return this._create_token(TOKEN.RAW, resulting_string);
  3590. } else {
  3591. return this._create_token(TOKEN.EOF, '');
  3592. }
  3593. };
  3594. Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
  3595. return false;
  3596. };
  3597. Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
  3598. return false;
  3599. };
  3600. Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
  3601. return false;
  3602. };
  3603. Tokenizer.prototype._create_token = function(type, text) {
  3604. var token = new Token$1(type, text,
  3605. this._patterns.whitespace.newline_count,
  3606. this._patterns.whitespace.whitespace_before_token);
  3607. return token;
  3608. };
  3609. Tokenizer.prototype._readWhitespace = function() {
  3610. return this._patterns.whitespace.read();
  3611. };
  3612. var Tokenizer_1 = Tokenizer;
  3613. var TOKEN_1 = TOKEN;
  3614. var tokenizer = {
  3615. Tokenizer: Tokenizer_1,
  3616. TOKEN: TOKEN_1
  3617. };
  3618. /*jshint node:true */
  3619. function Directives(start_block_pattern, end_block_pattern) {
  3620. start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
  3621. end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
  3622. this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
  3623. this.__directive_pattern = / (\w+)[:](\w+)/g;
  3624. this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
  3625. }
  3626. Directives.prototype.get_directives = function(text) {
  3627. if (!text.match(this.__directives_block_pattern)) {
  3628. return null;
  3629. }
  3630. var directives = {};
  3631. this.__directive_pattern.lastIndex = 0;
  3632. var directive_match = this.__directive_pattern.exec(text);
  3633. while (directive_match) {
  3634. directives[directive_match[1]] = directive_match[2];
  3635. directive_match = this.__directive_pattern.exec(text);
  3636. }
  3637. return directives;
  3638. };
  3639. Directives.prototype.readIgnored = function(input) {
  3640. return input.readUntilAfter(this.__directives_end_ignore_pattern);
  3641. };
  3642. var Directives_1 = Directives;
  3643. var directives = {
  3644. Directives: Directives_1
  3645. };
  3646. var Pattern$2 = pattern.Pattern;
  3647. var template_names = {
  3648. django: false,
  3649. erb: false,
  3650. handlebars: false,
  3651. php: false
  3652. };
  3653. // This lets templates appear anywhere we would do a readUntil
  3654. // The cost is higher but it is pay to play.
  3655. function TemplatablePattern(input_scanner, parent) {
  3656. Pattern$2.call(this, input_scanner, parent);
  3657. this.__template_pattern = null;
  3658. this._disabled = Object.assign({}, template_names);
  3659. this._excluded = Object.assign({}, template_names);
  3660. if (parent) {
  3661. this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
  3662. this._excluded = Object.assign(this._excluded, parent._excluded);
  3663. this._disabled = Object.assign(this._disabled, parent._disabled);
  3664. }
  3665. var pattern = new Pattern$2(input_scanner);
  3666. this.__patterns = {
  3667. handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
  3668. handlebars: pattern.starting_with(/{{/).until_after(/}}/),
  3669. php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
  3670. erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
  3671. // django coflicts with handlebars a bit.
  3672. django: pattern.starting_with(/{%/).until_after(/%}/),
  3673. django_value: pattern.starting_with(/{{/).until_after(/}}/),
  3674. django_comment: pattern.starting_with(/{#/).until_after(/#}/)
  3675. };
  3676. }
  3677. TemplatablePattern.prototype = new Pattern$2();
  3678. TemplatablePattern.prototype._create = function() {
  3679. return new TemplatablePattern(this._input, this);
  3680. };
  3681. TemplatablePattern.prototype._update = function() {
  3682. this.__set_templated_pattern();
  3683. };
  3684. TemplatablePattern.prototype.disable = function(language) {
  3685. var result = this._create();
  3686. result._disabled[language] = true;
  3687. result._update();
  3688. return result;
  3689. };
  3690. TemplatablePattern.prototype.read_options = function(options) {
  3691. var result = this._create();
  3692. for (var language in template_names) {
  3693. result._disabled[language] = options.templating.indexOf(language) === -1;
  3694. }
  3695. result._update();
  3696. return result;
  3697. };
  3698. TemplatablePattern.prototype.exclude = function(language) {
  3699. var result = this._create();
  3700. result._excluded[language] = true;
  3701. result._update();
  3702. return result;
  3703. };
  3704. TemplatablePattern.prototype.read = function() {
  3705. var result = '';
  3706. if (this._match_pattern) {
  3707. result = this._input.read(this._starting_pattern);
  3708. } else {
  3709. result = this._input.read(this._starting_pattern, this.__template_pattern);
  3710. }
  3711. var next = this._read_template();
  3712. while (next) {
  3713. if (this._match_pattern) {
  3714. next += this._input.read(this._match_pattern);
  3715. } else {
  3716. next += this._input.readUntil(this.__template_pattern);
  3717. }
  3718. result += next;
  3719. next = this._read_template();
  3720. }
  3721. if (this._until_after) {
  3722. result += this._input.readUntilAfter(this._until_pattern);
  3723. }
  3724. return result;
  3725. };
  3726. TemplatablePattern.prototype.__set_templated_pattern = function() {
  3727. var items = [];
  3728. if (!this._disabled.php) {
  3729. items.push(this.__patterns.php._starting_pattern.source);
  3730. }
  3731. if (!this._disabled.handlebars) {
  3732. items.push(this.__patterns.handlebars._starting_pattern.source);
  3733. }
  3734. if (!this._disabled.erb) {
  3735. items.push(this.__patterns.erb._starting_pattern.source);
  3736. }
  3737. if (!this._disabled.django) {
  3738. items.push(this.__patterns.django._starting_pattern.source);
  3739. items.push(this.__patterns.django_value._starting_pattern.source);
  3740. items.push(this.__patterns.django_comment._starting_pattern.source);
  3741. }
  3742. if (this._until_pattern) {
  3743. items.push(this._until_pattern.source);
  3744. }
  3745. this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
  3746. };
  3747. TemplatablePattern.prototype._read_template = function() {
  3748. var resulting_string = '';
  3749. var c = this._input.peek();
  3750. if (c === '<') {
  3751. var peek1 = this._input.peek(1);
  3752. //if we're in a comment, do something special
  3753. // We treat all comments as literals, even more than preformatted tags
  3754. // we just look for the appropriate close tag
  3755. if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
  3756. resulting_string = resulting_string ||
  3757. this.__patterns.php.read();
  3758. }
  3759. if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
  3760. resulting_string = resulting_string ||
  3761. this.__patterns.erb.read();
  3762. }
  3763. } else if (c === '{') {
  3764. if (!this._disabled.handlebars && !this._excluded.handlebars) {
  3765. resulting_string = resulting_string ||
  3766. this.__patterns.handlebars_comment.read();
  3767. resulting_string = resulting_string ||
  3768. this.__patterns.handlebars.read();
  3769. }
  3770. if (!this._disabled.django) {
  3771. // django coflicts with handlebars a bit.
  3772. if (!this._excluded.django && !this._excluded.handlebars) {
  3773. resulting_string = resulting_string ||
  3774. this.__patterns.django_value.read();
  3775. }
  3776. if (!this._excluded.django) {
  3777. resulting_string = resulting_string ||
  3778. this.__patterns.django_comment.read();
  3779. resulting_string = resulting_string ||
  3780. this.__patterns.django.read();
  3781. }
  3782. }
  3783. }
  3784. return resulting_string;
  3785. };
  3786. var TemplatablePattern_1 = TemplatablePattern;
  3787. var templatablepattern = {
  3788. TemplatablePattern: TemplatablePattern_1
  3789. };
  3790. var InputScanner$2 = inputscanner.InputScanner;
  3791. var BaseTokenizer = tokenizer.Tokenizer;
  3792. var BASETOKEN = tokenizer.TOKEN;
  3793. var Directives$1 = directives.Directives;
  3794. var Pattern$3 = pattern.Pattern;
  3795. var TemplatablePattern$1 = templatablepattern.TemplatablePattern;
  3796. function in_array(what, arr) {
  3797. return arr.indexOf(what) !== -1;
  3798. }
  3799. var TOKEN$1 = {
  3800. START_EXPR: 'TK_START_EXPR',
  3801. END_EXPR: 'TK_END_EXPR',
  3802. START_BLOCK: 'TK_START_BLOCK',
  3803. END_BLOCK: 'TK_END_BLOCK',
  3804. WORD: 'TK_WORD',
  3805. RESERVED: 'TK_RESERVED',
  3806. SEMICOLON: 'TK_SEMICOLON',
  3807. STRING: 'TK_STRING',
  3808. EQUALS: 'TK_EQUALS',
  3809. OPERATOR: 'TK_OPERATOR',
  3810. COMMA: 'TK_COMMA',
  3811. BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
  3812. COMMENT: 'TK_COMMENT',
  3813. DOT: 'TK_DOT',
  3814. UNKNOWN: 'TK_UNKNOWN',
  3815. START: BASETOKEN.START,
  3816. RAW: BASETOKEN.RAW,
  3817. EOF: BASETOKEN.EOF
  3818. };
  3819. var directives_core = new Directives$1(/\/\*/, /\*\//);
  3820. var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/;
  3821. var digit = /[0-9]/;
  3822. // Dot "." must be distinguished from "..." and decimal
  3823. var dot_pattern = /[^\d\.]/;
  3824. var positionable_operators = (
  3825. ">>> === !== " +
  3826. "<< && >= ** != == <= >> || " +
  3827. "< / - + > : & % ? ^ | *").split(' ');
  3828. // IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
  3829. // Also, you must update possitionable operators separately from punct
  3830. var punct =
  3831. ">>>= " +
  3832. "... >>= <<= === >>> !== **= " +
  3833. "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
  3834. "= ! ? > < : / ^ - + * & % ~ |";
  3835. punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
  3836. punct = punct.replace(/ /g, '|');
  3837. var punct_pattern = new RegExp(punct);
  3838. // words which should always start on new line.
  3839. var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
  3840. var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']);
  3841. var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
  3842. // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
  3843. var in_html_comment;
  3844. var Tokenizer$1 = function(input_string, options) {
  3845. BaseTokenizer.call(this, input_string, options);
  3846. this._patterns.whitespace = this._patterns.whitespace.matching(
  3847. /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
  3848. /\u2028\u2029/.source);
  3849. var pattern_reader = new Pattern$3(this._input);
  3850. var templatable = new TemplatablePattern$1(this._input)
  3851. .read_options(this._options);
  3852. this.__patterns = {
  3853. template: templatable,
  3854. identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
  3855. number: pattern_reader.matching(number_pattern),
  3856. punct: pattern_reader.matching(punct_pattern),
  3857. // comment ends just before nearest linefeed or end of file
  3858. comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
  3859. // /* ... */ comment ends with nearest */ or end of file
  3860. block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
  3861. html_comment_start: pattern_reader.matching(/<!--/),
  3862. html_comment_end: pattern_reader.matching(/-->/),
  3863. include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
  3864. shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
  3865. 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*>/),
  3866. single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
  3867. double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
  3868. template_text: templatable.until(/[`\\$]/),
  3869. template_expression: templatable.until(/[`}\\]/)
  3870. };
  3871. };
  3872. Tokenizer$1.prototype = new BaseTokenizer();
  3873. Tokenizer$1.prototype._is_comment = function(current_token) {
  3874. return current_token.type === TOKEN$1.COMMENT || current_token.type === TOKEN$1.BLOCK_COMMENT || current_token.type === TOKEN$1.UNKNOWN;
  3875. };
  3876. Tokenizer$1.prototype._is_opening = function(current_token) {
  3877. return current_token.type === TOKEN$1.START_BLOCK || current_token.type === TOKEN$1.START_EXPR;
  3878. };
  3879. Tokenizer$1.prototype._is_closing = function(current_token, open_token) {
  3880. return (current_token.type === TOKEN$1.END_BLOCK || current_token.type === TOKEN$1.END_EXPR) &&
  3881. (open_token && (
  3882. (current_token.text === ']' && open_token.text === '[') ||
  3883. (current_token.text === ')' && open_token.text === '(') ||
  3884. (current_token.text === '}' && open_token.text === '{')));
  3885. };
  3886. Tokenizer$1.prototype._reset = function() {
  3887. in_html_comment = false;
  3888. };
  3889. Tokenizer$1.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  3890. var token = null;
  3891. this._readWhitespace();
  3892. var c = this._input.peek();
  3893. if (c === null) {
  3894. return this._create_token(TOKEN$1.EOF, '');
  3895. }
  3896. token = token || this._read_string(c);
  3897. token = token || this._read_word(previous_token);
  3898. token = token || this._read_singles(c);
  3899. token = token || this._read_comment(c);
  3900. token = token || this._read_regexp(c, previous_token);
  3901. token = token || this._read_xml(c, previous_token);
  3902. token = token || this._read_non_javascript(c);
  3903. token = token || this._read_punctuation();
  3904. token = token || this._create_token(TOKEN$1.UNKNOWN, this._input.next());
  3905. return token;
  3906. };
  3907. Tokenizer$1.prototype._read_word = function(previous_token) {
  3908. var resulting_string;
  3909. resulting_string = this.__patterns.identifier.read();
  3910. if (resulting_string !== '') {
  3911. resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
  3912. if (!(previous_token.type === TOKEN$1.DOT ||
  3913. (previous_token.type === TOKEN$1.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
  3914. reserved_word_pattern.test(resulting_string)) {
  3915. if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators
  3916. return this._create_token(TOKEN$1.OPERATOR, resulting_string);
  3917. }
  3918. return this._create_token(TOKEN$1.RESERVED, resulting_string);
  3919. }
  3920. return this._create_token(TOKEN$1.WORD, resulting_string);
  3921. }
  3922. resulting_string = this.__patterns.number.read();
  3923. if (resulting_string !== '') {
  3924. return this._create_token(TOKEN$1.WORD, resulting_string);
  3925. }
  3926. };
  3927. Tokenizer$1.prototype._read_singles = function(c) {
  3928. var token = null;
  3929. if (c === '(' || c === '[') {
  3930. token = this._create_token(TOKEN$1.START_EXPR, c);
  3931. } else if (c === ')' || c === ']') {
  3932. token = this._create_token(TOKEN$1.END_EXPR, c);
  3933. } else if (c === '{') {
  3934. token = this._create_token(TOKEN$1.START_BLOCK, c);
  3935. } else if (c === '}') {
  3936. token = this._create_token(TOKEN$1.END_BLOCK, c);
  3937. } else if (c === ';') {
  3938. token = this._create_token(TOKEN$1.SEMICOLON, c);
  3939. } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
  3940. token = this._create_token(TOKEN$1.DOT, c);
  3941. } else if (c === ',') {
  3942. token = this._create_token(TOKEN$1.COMMA, c);
  3943. }
  3944. if (token) {
  3945. this._input.next();
  3946. }
  3947. return token;
  3948. };
  3949. Tokenizer$1.prototype._read_punctuation = function() {
  3950. var resulting_string = this.__patterns.punct.read();
  3951. if (resulting_string !== '') {
  3952. if (resulting_string === '=') {
  3953. return this._create_token(TOKEN$1.EQUALS, resulting_string);
  3954. } else {
  3955. return this._create_token(TOKEN$1.OPERATOR, resulting_string);
  3956. }
  3957. }
  3958. };
  3959. Tokenizer$1.prototype._read_non_javascript = function(c) {
  3960. var resulting_string = '';
  3961. if (c === '#') {
  3962. if (this._is_first_token()) {
  3963. resulting_string = this.__patterns.shebang.read();
  3964. if (resulting_string) {
  3965. return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
  3966. }
  3967. }
  3968. // handles extendscript #includes
  3969. resulting_string = this.__patterns.include.read();
  3970. if (resulting_string) {
  3971. return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
  3972. }
  3973. c = this._input.next();
  3974. // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
  3975. var sharp = '#';
  3976. if (this._input.hasNext() && this._input.testChar(digit)) {
  3977. do {
  3978. c = this._input.next();
  3979. sharp += c;
  3980. } while (this._input.hasNext() && c !== '#' && c !== '=');
  3981. if (c === '#') ; else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
  3982. sharp += '[]';
  3983. this._input.next();
  3984. this._input.next();
  3985. } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
  3986. sharp += '{}';
  3987. this._input.next();
  3988. this._input.next();
  3989. }
  3990. return this._create_token(TOKEN$1.WORD, sharp);
  3991. }
  3992. this._input.back();
  3993. } else if (c === '<' && this._is_first_token()) {
  3994. resulting_string = this.__patterns.html_comment_start.read();
  3995. if (resulting_string) {
  3996. while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
  3997. resulting_string += this._input.next();
  3998. }
  3999. in_html_comment = true;
  4000. return this._create_token(TOKEN$1.COMMENT, resulting_string);
  4001. }
  4002. } else if (in_html_comment && c === '-') {
  4003. resulting_string = this.__patterns.html_comment_end.read();
  4004. if (resulting_string) {
  4005. in_html_comment = false;
  4006. return this._create_token(TOKEN$1.COMMENT, resulting_string);
  4007. }
  4008. }
  4009. return null;
  4010. };
  4011. Tokenizer$1.prototype._read_comment = function(c) {
  4012. var token = null;
  4013. if (c === '/') {
  4014. var comment = '';
  4015. if (this._input.peek(1) === '*') {
  4016. // peek for comment /* ... */
  4017. comment = this.__patterns.block_comment.read();
  4018. var directives = directives_core.get_directives(comment);
  4019. if (directives && directives.ignore === 'start') {
  4020. comment += directives_core.readIgnored(this._input);
  4021. }
  4022. comment = comment.replace(acorn.allLineBreaks, '\n');
  4023. token = this._create_token(TOKEN$1.BLOCK_COMMENT, comment);
  4024. token.directives = directives;
  4025. } else if (this._input.peek(1) === '/') {
  4026. // peek for comment // ...
  4027. comment = this.__patterns.comment.read();
  4028. token = this._create_token(TOKEN$1.COMMENT, comment);
  4029. }
  4030. }
  4031. return token;
  4032. };
  4033. Tokenizer$1.prototype._read_string = function(c) {
  4034. if (c === '`' || c === "'" || c === '"') {
  4035. var resulting_string = this._input.next();
  4036. this.has_char_escapes = false;
  4037. if (c === '`') {
  4038. resulting_string += this._read_string_recursive('`', true, '${');
  4039. } else {
  4040. resulting_string += this._read_string_recursive(c);
  4041. }
  4042. if (this.has_char_escapes && this._options.unescape_strings) {
  4043. resulting_string = unescape_string(resulting_string);
  4044. }
  4045. if (this._input.peek() === c) {
  4046. resulting_string += this._input.next();
  4047. }
  4048. resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
  4049. return this._create_token(TOKEN$1.STRING, resulting_string);
  4050. }
  4051. return null;
  4052. };
  4053. Tokenizer$1.prototype._allow_regexp_or_xml = function(previous_token) {
  4054. // regex and xml can only appear in specific locations during parsing
  4055. return (previous_token.type === TOKEN$1.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
  4056. (previous_token.type === TOKEN$1.END_EXPR && previous_token.text === ')' &&
  4057. previous_token.opened.previous.type === TOKEN$1.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
  4058. (in_array(previous_token.type, [TOKEN$1.COMMENT, TOKEN$1.START_EXPR, TOKEN$1.START_BLOCK, TOKEN$1.START,
  4059. TOKEN$1.END_BLOCK, TOKEN$1.OPERATOR, TOKEN$1.EQUALS, TOKEN$1.EOF, TOKEN$1.SEMICOLON, TOKEN$1.COMMA
  4060. ]));
  4061. };
  4062. Tokenizer$1.prototype._read_regexp = function(c, previous_token) {
  4063. if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
  4064. // handle regexp
  4065. //
  4066. var resulting_string = this._input.next();
  4067. var esc = false;
  4068. var in_char_class = false;
  4069. while (this._input.hasNext() &&
  4070. ((esc || in_char_class || this._input.peek() !== c) &&
  4071. !this._input.testChar(acorn.newline))) {
  4072. resulting_string += this._input.peek();
  4073. if (!esc) {
  4074. esc = this._input.peek() === '\\';
  4075. if (this._input.peek() === '[') {
  4076. in_char_class = true;
  4077. } else if (this._input.peek() === ']') {
  4078. in_char_class = false;
  4079. }
  4080. } else {
  4081. esc = false;
  4082. }
  4083. this._input.next();
  4084. }
  4085. if (this._input.peek() === c) {
  4086. resulting_string += this._input.next();
  4087. // regexps may have modifiers /regexp/MOD , so fetch those, too
  4088. // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
  4089. resulting_string += this._input.read(acorn.identifier);
  4090. }
  4091. return this._create_token(TOKEN$1.STRING, resulting_string);
  4092. }
  4093. return null;
  4094. };
  4095. Tokenizer$1.prototype._read_xml = function(c, previous_token) {
  4096. if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
  4097. var xmlStr = '';
  4098. var match = this.__patterns.xml.read_match();
  4099. // handle e4x xml literals
  4100. //
  4101. if (match) {
  4102. // Trim root tag to attempt to
  4103. var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
  4104. var isCurlyRoot = rootTag.indexOf('{') === 0;
  4105. var depth = 0;
  4106. while (match) {
  4107. var isEndTag = !!match[1];
  4108. var tagName = match[2];
  4109. var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
  4110. if (!isSingletonTag &&
  4111. (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
  4112. if (isEndTag) {
  4113. --depth;
  4114. } else {
  4115. ++depth;
  4116. }
  4117. }
  4118. xmlStr += match[0];
  4119. if (depth <= 0) {
  4120. break;
  4121. }
  4122. match = this.__patterns.xml.read_match();
  4123. }
  4124. // if we didn't close correctly, keep unformatted.
  4125. if (!match) {
  4126. xmlStr += this._input.match(/[\s\S]*/g)[0];
  4127. }
  4128. xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
  4129. return this._create_token(TOKEN$1.STRING, xmlStr);
  4130. }
  4131. }
  4132. return null;
  4133. };
  4134. function unescape_string(s) {
  4135. // You think that a regex would work for this
  4136. // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
  4137. // return String.fromCharCode(parseInt(val, 16));
  4138. // })
  4139. // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
  4140. var out = '',
  4141. escaped = 0;
  4142. var input_scan = new InputScanner$2(s);
  4143. var matched = null;
  4144. while (input_scan.hasNext()) {
  4145. // Keep any whitespace, non-slash characters
  4146. // also keep slash pairs.
  4147. matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
  4148. if (matched) {
  4149. out += matched[0];
  4150. }
  4151. if (input_scan.peek() === '\\') {
  4152. input_scan.next();
  4153. if (input_scan.peek() === 'x') {
  4154. matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
  4155. } else if (input_scan.peek() === 'u') {
  4156. matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
  4157. } else {
  4158. out += '\\';
  4159. if (input_scan.hasNext()) {
  4160. out += input_scan.next();
  4161. }
  4162. continue;
  4163. }
  4164. // If there's some error decoding, return the original string
  4165. if (!matched) {
  4166. return s;
  4167. }
  4168. escaped = parseInt(matched[1], 16);
  4169. if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
  4170. // we bail out on \x7f..\xff,
  4171. // leaving whole string escaped,
  4172. // as it's probably completely binary
  4173. return s;
  4174. } else if (escaped >= 0x00 && escaped < 0x20) {
  4175. // leave 0x00...0x1f escaped
  4176. out += '\\' + matched[0];
  4177. continue;
  4178. } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
  4179. // single-quote, apostrophe, backslash - escape these
  4180. out += '\\' + String.fromCharCode(escaped);
  4181. } else {
  4182. out += String.fromCharCode(escaped);
  4183. }
  4184. }
  4185. }
  4186. return out;
  4187. }
  4188. // handle string
  4189. //
  4190. Tokenizer$1.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
  4191. var current_char;
  4192. var pattern;
  4193. if (delimiter === '\'') {
  4194. pattern = this.__patterns.single_quote;
  4195. } else if (delimiter === '"') {
  4196. pattern = this.__patterns.double_quote;
  4197. } else if (delimiter === '`') {
  4198. pattern = this.__patterns.template_text;
  4199. } else if (delimiter === '}') {
  4200. pattern = this.__patterns.template_expression;
  4201. }
  4202. var resulting_string = pattern.read();
  4203. var next = '';
  4204. while (this._input.hasNext()) {
  4205. next = this._input.next();
  4206. if (next === delimiter ||
  4207. (!allow_unescaped_newlines && acorn.newline.test(next))) {
  4208. this._input.back();
  4209. break;
  4210. } else if (next === '\\' && this._input.hasNext()) {
  4211. current_char = this._input.peek();
  4212. if (current_char === 'x' || current_char === 'u') {
  4213. this.has_char_escapes = true;
  4214. } else if (current_char === '\r' && this._input.peek(1) === '\n') {
  4215. this._input.next();
  4216. }
  4217. next += this._input.next();
  4218. } else if (start_sub) {
  4219. if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
  4220. next += this._input.next();
  4221. }
  4222. if (start_sub === next) {
  4223. if (delimiter === '`') {
  4224. next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
  4225. } else {
  4226. next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
  4227. }
  4228. if (this._input.hasNext()) {
  4229. next += this._input.next();
  4230. }
  4231. }
  4232. }
  4233. next += pattern.read();
  4234. resulting_string += next;
  4235. }
  4236. return resulting_string;
  4237. };
  4238. var Tokenizer_1$1 = Tokenizer$1;
  4239. var TOKEN_1$1 = TOKEN$1;
  4240. var positionable_operators_1 = positionable_operators.slice();
  4241. var line_starters_1 = line_starters.slice();
  4242. var tokenizer$1 = {
  4243. Tokenizer: Tokenizer_1$1,
  4244. TOKEN: TOKEN_1$1,
  4245. positionable_operators: positionable_operators_1,
  4246. line_starters: line_starters_1
  4247. };
  4248. var Output$1 = output.Output;
  4249. var Token$2 = token.Token;
  4250. var Options$2 = options$1.Options;
  4251. var Tokenizer$2 = tokenizer$1.Tokenizer;
  4252. var line_starters$1 = tokenizer$1.line_starters;
  4253. var positionable_operators$1 = tokenizer$1.positionable_operators;
  4254. var TOKEN$2 = tokenizer$1.TOKEN;
  4255. function in_array$1(what, arr) {
  4256. return arr.indexOf(what) !== -1;
  4257. }
  4258. function ltrim(s) {
  4259. return s.replace(/^\s+/g, '');
  4260. }
  4261. function generateMapFromStrings(list) {
  4262. var result = {};
  4263. for (var x = 0; x < list.length; x++) {
  4264. // make the mapped names underscored instead of dash
  4265. result[list[x].replace(/-/g, '_')] = list[x];
  4266. }
  4267. return result;
  4268. }
  4269. function reserved_word(token, word) {
  4270. return token && token.type === TOKEN$2.RESERVED && token.text === word;
  4271. }
  4272. function reserved_array(token, words) {
  4273. return token && token.type === TOKEN$2.RESERVED && in_array$1(token.text, words);
  4274. }
  4275. // Unsure of what they mean, but they work. Worth cleaning up in future.
  4276. var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
  4277. var validPositionValues$1 = ['before-newline', 'after-newline', 'preserve-newline'];
  4278. // Generate map from array
  4279. var OPERATOR_POSITION = generateMapFromStrings(validPositionValues$1);
  4280. var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
  4281. var MODE = {
  4282. BlockStatement: 'BlockStatement', // 'BLOCK'
  4283. Statement: 'Statement', // 'STATEMENT'
  4284. ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
  4285. ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
  4286. ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
  4287. Conditional: 'Conditional', //'(COND-EXPRESSION)',
  4288. Expression: 'Expression' //'(EXPRESSION)'
  4289. };
  4290. function remove_redundant_indentation(output, frame) {
  4291. // This implementation is effective but has some issues:
  4292. // - can cause line wrap to happen too soon due to indent removal
  4293. // after wrap points are calculated
  4294. // These issues are minor compared to ugly indentation.
  4295. if (frame.multiline_frame ||
  4296. frame.mode === MODE.ForInitializer ||
  4297. frame.mode === MODE.Conditional) {
  4298. return;
  4299. }
  4300. // remove one indent from each line inside this section
  4301. output.remove_indent(frame.start_line_index);
  4302. }
  4303. // we could use just string.split, but
  4304. // IE doesn't like returning empty strings
  4305. function split_linebreaks(s) {
  4306. //return s.split(/\x0d\x0a|\x0a/);
  4307. s = s.replace(acorn.allLineBreaks, '\n');
  4308. var out = [],
  4309. idx = s.indexOf("\n");
  4310. while (idx !== -1) {
  4311. out.push(s.substring(0, idx));
  4312. s = s.substring(idx + 1);
  4313. idx = s.indexOf("\n");
  4314. }
  4315. if (s.length) {
  4316. out.push(s);
  4317. }
  4318. return out;
  4319. }
  4320. function is_array(mode) {
  4321. return mode === MODE.ArrayLiteral;
  4322. }
  4323. function is_expression(mode) {
  4324. return in_array$1(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
  4325. }
  4326. function all_lines_start_with(lines, c) {
  4327. for (var i = 0; i < lines.length; i++) {
  4328. var line = lines[i].trim();
  4329. if (line.charAt(0) !== c) {
  4330. return false;
  4331. }
  4332. }
  4333. return true;
  4334. }
  4335. function each_line_matches_indent(lines, indent) {
  4336. var i = 0,
  4337. len = lines.length,
  4338. line;
  4339. for (; i < len; i++) {
  4340. line = lines[i];
  4341. // allow empty lines to pass through
  4342. if (line && line.indexOf(indent) !== 0) {
  4343. return false;
  4344. }
  4345. }
  4346. return true;
  4347. }
  4348. function Beautifier(source_text, options) {
  4349. options = options || {};
  4350. this._source_text = source_text || '';
  4351. this._output = null;
  4352. this._tokens = null;
  4353. this._last_last_text = null;
  4354. this._flags = null;
  4355. this._previous_flags = null;
  4356. this._flag_store = null;
  4357. this._options = new Options$2(options);
  4358. }
  4359. Beautifier.prototype.create_flags = function(flags_base, mode) {
  4360. var next_indent_level = 0;
  4361. if (flags_base) {
  4362. next_indent_level = flags_base.indentation_level;
  4363. if (!this._output.just_added_newline() &&
  4364. flags_base.line_indent_level > next_indent_level) {
  4365. next_indent_level = flags_base.line_indent_level;
  4366. }
  4367. }
  4368. var next_flags = {
  4369. mode: mode,
  4370. parent: flags_base,
  4371. last_token: flags_base ? flags_base.last_token : new Token$2(TOKEN$2.START_BLOCK, ''), // last token text
  4372. last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
  4373. declaration_statement: false,
  4374. declaration_assignment: false,
  4375. multiline_frame: false,
  4376. inline_frame: false,
  4377. if_block: false,
  4378. else_block: false,
  4379. do_block: false,
  4380. do_while: false,
  4381. import_block: false,
  4382. in_case_statement: false, // switch(..){ INSIDE HERE }
  4383. in_case: false, // we're on the exact line with "case 0:"
  4384. case_body: false, // the indented case-action block
  4385. indentation_level: next_indent_level,
  4386. alignment: 0,
  4387. line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
  4388. start_line_index: this._output.get_line_number(),
  4389. ternary_depth: 0
  4390. };
  4391. return next_flags;
  4392. };
  4393. Beautifier.prototype._reset = function(source_text) {
  4394. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  4395. this._last_last_text = ''; // pre-last token text
  4396. this._output = new Output$1(this._options, baseIndentString);
  4397. // If testing the ignore directive, start with output disable set to true
  4398. this._output.raw = this._options.test_output_raw;
  4399. // Stack of parsing/formatting states, including MODE.
  4400. // We tokenize, parse, and output in an almost purely a forward-only stream of token input
  4401. // and formatted output. This makes the beautifier less accurate than full parsers
  4402. // but also far more tolerant of syntax errors.
  4403. //
  4404. // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
  4405. // MODE.BlockStatement on the the stack, even though it could be object literal. If we later
  4406. // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
  4407. // most full parsers would die, but the beautifier gracefully falls back to
  4408. // MODE.BlockStatement and continues on.
  4409. this._flag_store = [];
  4410. this.set_mode(MODE.BlockStatement);
  4411. var tokenizer = new Tokenizer$2(source_text, this._options);
  4412. this._tokens = tokenizer.tokenize();
  4413. return source_text;
  4414. };
  4415. Beautifier.prototype.beautify = function() {
  4416. // if disabled, return the input unchanged.
  4417. if (this._options.disabled) {
  4418. return this._source_text;
  4419. }
  4420. var sweet_code;
  4421. var source_text = this._reset(this._source_text);
  4422. var eol = this._options.eol;
  4423. if (this._options.eol === 'auto') {
  4424. eol = '\n';
  4425. if (source_text && acorn.lineBreak.test(source_text || '')) {
  4426. eol = source_text.match(acorn.lineBreak)[0];
  4427. }
  4428. }
  4429. var current_token = this._tokens.next();
  4430. while (current_token) {
  4431. this.handle_token(current_token);
  4432. this._last_last_text = this._flags.last_token.text;
  4433. this._flags.last_token = current_token;
  4434. current_token = this._tokens.next();
  4435. }
  4436. sweet_code = this._output.get_code(eol);
  4437. return sweet_code;
  4438. };
  4439. Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
  4440. if (current_token.type === TOKEN$2.START_EXPR) {
  4441. this.handle_start_expr(current_token);
  4442. } else if (current_token.type === TOKEN$2.END_EXPR) {
  4443. this.handle_end_expr(current_token);
  4444. } else if (current_token.type === TOKEN$2.START_BLOCK) {
  4445. this.handle_start_block(current_token);
  4446. } else if (current_token.type === TOKEN$2.END_BLOCK) {
  4447. this.handle_end_block(current_token);
  4448. } else if (current_token.type === TOKEN$2.WORD) {
  4449. this.handle_word(current_token);
  4450. } else if (current_token.type === TOKEN$2.RESERVED) {
  4451. this.handle_word(current_token);
  4452. } else if (current_token.type === TOKEN$2.SEMICOLON) {
  4453. this.handle_semicolon(current_token);
  4454. } else if (current_token.type === TOKEN$2.STRING) {
  4455. this.handle_string(current_token);
  4456. } else if (current_token.type === TOKEN$2.EQUALS) {
  4457. this.handle_equals(current_token);
  4458. } else if (current_token.type === TOKEN$2.OPERATOR) {
  4459. this.handle_operator(current_token);
  4460. } else if (current_token.type === TOKEN$2.COMMA) {
  4461. this.handle_comma(current_token);
  4462. } else if (current_token.type === TOKEN$2.BLOCK_COMMENT) {
  4463. this.handle_block_comment(current_token, preserve_statement_flags);
  4464. } else if (current_token.type === TOKEN$2.COMMENT) {
  4465. this.handle_comment(current_token, preserve_statement_flags);
  4466. } else if (current_token.type === TOKEN$2.DOT) {
  4467. this.handle_dot(current_token);
  4468. } else if (current_token.type === TOKEN$2.EOF) {
  4469. this.handle_eof(current_token);
  4470. } else if (current_token.type === TOKEN$2.UNKNOWN) {
  4471. this.handle_unknown(current_token, preserve_statement_flags);
  4472. } else {
  4473. this.handle_unknown(current_token, preserve_statement_flags);
  4474. }
  4475. };
  4476. Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
  4477. var newlines = current_token.newlines;
  4478. var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
  4479. if (current_token.comments_before) {
  4480. var comment_token = current_token.comments_before.next();
  4481. while (comment_token) {
  4482. // The cleanest handling of inline comments is to treat them as though they aren't there.
  4483. // Just continue formatting and the behavior should be logical.
  4484. // Also ignore unknown tokens. Again, this should result in better behavior.
  4485. this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
  4486. this.handle_token(comment_token, preserve_statement_flags);
  4487. comment_token = current_token.comments_before.next();
  4488. }
  4489. }
  4490. if (keep_whitespace) {
  4491. for (var i = 0; i < newlines; i += 1) {
  4492. this.print_newline(i > 0, preserve_statement_flags);
  4493. }
  4494. } else {
  4495. if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
  4496. newlines = this._options.max_preserve_newlines;
  4497. }
  4498. if (this._options.preserve_newlines) {
  4499. if (newlines > 1) {
  4500. this.print_newline(false, preserve_statement_flags);
  4501. for (var j = 1; j < newlines; j += 1) {
  4502. this.print_newline(true, preserve_statement_flags);
  4503. }
  4504. }
  4505. }
  4506. }
  4507. };
  4508. var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
  4509. Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
  4510. force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
  4511. // Never wrap the first token on a line
  4512. if (this._output.just_added_newline()) {
  4513. return;
  4514. }
  4515. var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
  4516. var operatorLogicApplies = in_array$1(this._flags.last_token.text, positionable_operators$1) ||
  4517. in_array$1(current_token.text, positionable_operators$1);
  4518. if (operatorLogicApplies) {
  4519. var shouldPrintOperatorNewline = (
  4520. in_array$1(this._flags.last_token.text, positionable_operators$1) &&
  4521. in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
  4522. ) ||
  4523. in_array$1(current_token.text, positionable_operators$1);
  4524. shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
  4525. }
  4526. if (shouldPreserveOrForce) {
  4527. this.print_newline(false, true);
  4528. } else if (this._options.wrap_line_length) {
  4529. if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
  4530. // These tokens should never have a newline inserted
  4531. // between them and the following expression.
  4532. return;
  4533. }
  4534. this._output.set_wrap_point();
  4535. }
  4536. };
  4537. Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
  4538. if (!preserve_statement_flags) {
  4539. 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 === '++')) {
  4540. var next_token = this._tokens.peek();
  4541. while (this._flags.mode === MODE.Statement &&
  4542. !(this._flags.if_block && reserved_word(next_token, 'else')) &&
  4543. !this._flags.do_block) {
  4544. this.restore_mode();
  4545. }
  4546. }
  4547. }
  4548. if (this._output.add_new_line(force_newline)) {
  4549. this._flags.multiline_frame = true;
  4550. }
  4551. };
  4552. Beautifier.prototype.print_token_line_indentation = function(current_token) {
  4553. if (this._output.just_added_newline()) {
  4554. if (this._options.keep_array_indentation &&
  4555. current_token.newlines &&
  4556. (current_token.text === '[' || is_array(this._flags.mode))) {
  4557. this._output.current_line.set_indent(-1);
  4558. this._output.current_line.push(current_token.whitespace_before);
  4559. this._output.space_before_token = false;
  4560. } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
  4561. this._flags.line_indent_level = this._flags.indentation_level;
  4562. }
  4563. }
  4564. };
  4565. Beautifier.prototype.print_token = function(current_token) {
  4566. if (this._output.raw) {
  4567. this._output.add_raw_token(current_token);
  4568. return;
  4569. }
  4570. if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN$2.COMMA &&
  4571. this._output.just_added_newline()) {
  4572. if (this._output.previous_line.last() === ',') {
  4573. var popped = this._output.previous_line.pop();
  4574. // if the comma was already at the start of the line,
  4575. // pull back onto that line and reprint the indentation
  4576. if (this._output.previous_line.is_empty()) {
  4577. this._output.previous_line.push(popped);
  4578. this._output.trim(true);
  4579. this._output.current_line.pop();
  4580. this._output.trim();
  4581. }
  4582. // add the comma in front of the next token
  4583. this.print_token_line_indentation(current_token);
  4584. this._output.add_token(',');
  4585. this._output.space_before_token = true;
  4586. }
  4587. }
  4588. this.print_token_line_indentation(current_token);
  4589. this._output.non_breaking_space = true;
  4590. this._output.add_token(current_token.text);
  4591. if (this._output.previous_token_wrapped) {
  4592. this._flags.multiline_frame = true;
  4593. }
  4594. };
  4595. Beautifier.prototype.indent = function() {
  4596. this._flags.indentation_level += 1;
  4597. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4598. };
  4599. Beautifier.prototype.deindent = function() {
  4600. if (this._flags.indentation_level > 0 &&
  4601. ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
  4602. this._flags.indentation_level -= 1;
  4603. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4604. }
  4605. };
  4606. Beautifier.prototype.set_mode = function(mode) {
  4607. if (this._flags) {
  4608. this._flag_store.push(this._flags);
  4609. this._previous_flags = this._flags;
  4610. } else {
  4611. this._previous_flags = this.create_flags(null, mode);
  4612. }
  4613. this._flags = this.create_flags(this._previous_flags, mode);
  4614. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4615. };
  4616. Beautifier.prototype.restore_mode = function() {
  4617. if (this._flag_store.length > 0) {
  4618. this._previous_flags = this._flags;
  4619. this._flags = this._flag_store.pop();
  4620. if (this._previous_flags.mode === MODE.Statement) {
  4621. remove_redundant_indentation(this._output, this._previous_flags);
  4622. }
  4623. this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
  4624. }
  4625. };
  4626. Beautifier.prototype.start_of_object_property = function() {
  4627. return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
  4628. (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
  4629. };
  4630. Beautifier.prototype.start_of_statement = function(current_token) {
  4631. var start = false;
  4632. start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD;
  4633. start = start || reserved_word(this._flags.last_token, 'do');
  4634. 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;
  4635. start = start || reserved_word(this._flags.last_token, 'else') &&
  4636. !(reserved_word(current_token, 'if') && !current_token.comments_before);
  4637. start = start || (this._flags.last_token.type === TOKEN$2.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
  4638. start = start || (this._flags.last_token.type === TOKEN$2.WORD && this._flags.mode === MODE.BlockStatement &&
  4639. !this._flags.in_case &&
  4640. !(current_token.text === '--' || current_token.text === '++') &&
  4641. this._last_last_text !== 'function' &&
  4642. current_token.type !== TOKEN$2.WORD && current_token.type !== TOKEN$2.RESERVED);
  4643. start = start || (this._flags.mode === MODE.ObjectLiteral && (
  4644. (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
  4645. if (start) {
  4646. this.set_mode(MODE.Statement);
  4647. this.indent();
  4648. this.handle_whitespace_and_comments(current_token, true);
  4649. // Issue #276:
  4650. // If starting a new statement with [if, for, while, do], push to a new line.
  4651. // if (a) if (b) if(c) d(); else e(); else f();
  4652. if (!this.start_of_object_property()) {
  4653. this.allow_wrap_or_preserved_newline(current_token,
  4654. reserved_array(current_token, ['do', 'for', 'if', 'while']));
  4655. }
  4656. return true;
  4657. }
  4658. return false;
  4659. };
  4660. Beautifier.prototype.handle_start_expr = function(current_token) {
  4661. // The conditional starts the statement if appropriate.
  4662. if (!this.start_of_statement(current_token)) {
  4663. this.handle_whitespace_and_comments(current_token);
  4664. }
  4665. var next_mode = MODE.Expression;
  4666. if (current_token.text === '[') {
  4667. if (this._flags.last_token.type === TOKEN$2.WORD || this._flags.last_token.text === ')') {
  4668. // this is array index specifier, break immediately
  4669. // a[x], fn()[x]
  4670. if (reserved_array(this._flags.last_token, line_starters$1)) {
  4671. this._output.space_before_token = true;
  4672. }
  4673. this.print_token(current_token);
  4674. this.set_mode(next_mode);
  4675. this.indent();
  4676. if (this._options.space_in_paren) {
  4677. this._output.space_before_token = true;
  4678. }
  4679. return;
  4680. }
  4681. next_mode = MODE.ArrayLiteral;
  4682. if (is_array(this._flags.mode)) {
  4683. if (this._flags.last_token.text === '[' ||
  4684. (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
  4685. // ], [ goes to new line
  4686. // }, [ goes to new line
  4687. if (!this._options.keep_array_indentation) {
  4688. this.print_newline();
  4689. }
  4690. }
  4691. }
  4692. if (!in_array$1(this._flags.last_token.type, [TOKEN$2.START_EXPR, TOKEN$2.END_EXPR, TOKEN$2.WORD, TOKEN$2.OPERATOR])) {
  4693. this._output.space_before_token = true;
  4694. }
  4695. } else {
  4696. if (this._flags.last_token.type === TOKEN$2.RESERVED) {
  4697. if (this._flags.last_token.text === 'for') {
  4698. this._output.space_before_token = this._options.space_before_conditional;
  4699. next_mode = MODE.ForInitializer;
  4700. } else if (in_array$1(this._flags.last_token.text, ['if', 'while'])) {
  4701. this._output.space_before_token = this._options.space_before_conditional;
  4702. next_mode = MODE.Conditional;
  4703. } else if (in_array$1(this._flags.last_word, ['await', 'async'])) {
  4704. // Should be a space between await and an IIFE, or async and an arrow function
  4705. this._output.space_before_token = true;
  4706. } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
  4707. this._output.space_before_token = false;
  4708. } else if (in_array$1(this._flags.last_token.text, line_starters$1) || this._flags.last_token.text === 'catch') {
  4709. this._output.space_before_token = true;
  4710. }
  4711. } else if (this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
  4712. // Support of this kind of newline preservation.
  4713. // a = (b &&
  4714. // (c || d));
  4715. if (!this.start_of_object_property()) {
  4716. this.allow_wrap_or_preserved_newline(current_token);
  4717. }
  4718. } else if (this._flags.last_token.type === TOKEN$2.WORD) {
  4719. this._output.space_before_token = false;
  4720. // function name() vs function name ()
  4721. // function* name() vs function* name ()
  4722. // async name() vs async name ()
  4723. // In ES6, you can also define the method properties of an object
  4724. // var obj = {a: function() {}}
  4725. // It can be abbreviated
  4726. // var obj = {a() {}}
  4727. // var obj = { a() {}} vs var obj = { a () {}}
  4728. // var obj = { * a() {}} vs var obj = { * a () {}}
  4729. var peek_back_two = this._tokens.peek(-3);
  4730. if (this._options.space_after_named_function && peek_back_two) {
  4731. // peek starts at next character so -1 is current token
  4732. var peek_back_three = this._tokens.peek(-4);
  4733. if (reserved_array(peek_back_two, ['async', 'function']) ||
  4734. (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
  4735. this._output.space_before_token = true;
  4736. } else if (this._flags.mode === MODE.ObjectLiteral) {
  4737. if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
  4738. (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
  4739. this._output.space_before_token = true;
  4740. }
  4741. }
  4742. }
  4743. } else {
  4744. // Support preserving wrapped arrow function expressions
  4745. // a.b('c',
  4746. // () => d.e
  4747. // )
  4748. this.allow_wrap_or_preserved_newline(current_token);
  4749. }
  4750. // function() vs function ()
  4751. // yield*() vs yield* ()
  4752. // function*() vs function* ()
  4753. if ((this._flags.last_token.type === TOKEN$2.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
  4754. (this._flags.last_token.text === '*' &&
  4755. (in_array$1(this._last_last_text, ['function', 'yield']) ||
  4756. (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
  4757. this._output.space_before_token = this._options.space_after_anon_function;
  4758. }
  4759. }
  4760. if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN$2.START_BLOCK) {
  4761. this.print_newline();
  4762. } 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) {
  4763. // do nothing on (( and )( and ][ and ]( and .(
  4764. // TODO: Consider whether forcing this is required. Review failing tests when removed.
  4765. this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
  4766. }
  4767. this.print_token(current_token);
  4768. this.set_mode(next_mode);
  4769. if (this._options.space_in_paren) {
  4770. this._output.space_before_token = true;
  4771. }
  4772. // In all cases, if we newline while inside an expression it should be indented.
  4773. this.indent();
  4774. };
  4775. Beautifier.prototype.handle_end_expr = function(current_token) {
  4776. // statements inside expressions are not valid syntax, but...
  4777. // statements must all be closed when their container closes
  4778. while (this._flags.mode === MODE.Statement) {
  4779. this.restore_mode();
  4780. }
  4781. this.handle_whitespace_and_comments(current_token);
  4782. if (this._flags.multiline_frame) {
  4783. this.allow_wrap_or_preserved_newline(current_token,
  4784. current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
  4785. }
  4786. if (this._options.space_in_paren) {
  4787. if (this._flags.last_token.type === TOKEN$2.START_EXPR && !this._options.space_in_empty_paren) {
  4788. // () [] no inner space in empty parens like these, ever, ref #320
  4789. this._output.trim();
  4790. this._output.space_before_token = false;
  4791. } else {
  4792. this._output.space_before_token = true;
  4793. }
  4794. }
  4795. this.deindent();
  4796. this.print_token(current_token);
  4797. this.restore_mode();
  4798. remove_redundant_indentation(this._output, this._previous_flags);
  4799. // do {} while () // no statement required after
  4800. if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
  4801. this._previous_flags.mode = MODE.Expression;
  4802. this._flags.do_block = false;
  4803. this._flags.do_while = false;
  4804. }
  4805. };
  4806. Beautifier.prototype.handle_start_block = function(current_token) {
  4807. this.handle_whitespace_and_comments(current_token);
  4808. // Check if this is should be treated as a ObjectLiteral
  4809. var next_token = this._tokens.peek();
  4810. var second_token = this._tokens.peek(1);
  4811. if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN$2.END_EXPR) {
  4812. this.set_mode(MODE.BlockStatement);
  4813. this._flags.in_case_statement = true;
  4814. } else if (this._flags.case_body) {
  4815. this.set_mode(MODE.BlockStatement);
  4816. } else if (second_token && (
  4817. (in_array$1(second_token.text, [':', ',']) && in_array$1(next_token.type, [TOKEN$2.STRING, TOKEN$2.WORD, TOKEN$2.RESERVED])) ||
  4818. (in_array$1(next_token.text, ['get', 'set', '...']) && in_array$1(second_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]))
  4819. )) {
  4820. // We don't support TypeScript,but we didn't break it for a very long time.
  4821. // We'll try to keep not breaking it.
  4822. if (!in_array$1(this._last_last_text, ['class', 'interface'])) {
  4823. this.set_mode(MODE.ObjectLiteral);
  4824. } else {
  4825. this.set_mode(MODE.BlockStatement);
  4826. }
  4827. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR && this._flags.last_token.text === '=>') {
  4828. // arrow function: (param1, paramN) => { statements }
  4829. this.set_mode(MODE.BlockStatement);
  4830. } else if (in_array$1(this._flags.last_token.type, [TOKEN$2.EQUALS, TOKEN$2.START_EXPR, TOKEN$2.COMMA, TOKEN$2.OPERATOR]) ||
  4831. reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
  4832. ) {
  4833. // Detecting shorthand function syntax is difficult by scanning forward,
  4834. // so check the surrounding context.
  4835. // If the block is being returned, imported, export default, passed as arg,
  4836. // assigned with = or assigned in a nested object, treat as an ObjectLiteral.
  4837. this.set_mode(MODE.ObjectLiteral);
  4838. } else {
  4839. this.set_mode(MODE.BlockStatement);
  4840. }
  4841. var empty_braces = !next_token.comments_before && next_token.text === '}';
  4842. var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
  4843. this._flags.last_token.type === TOKEN$2.END_EXPR;
  4844. if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
  4845. {
  4846. // search forward for a newline wanted inside this block
  4847. var index = 0;
  4848. var check_token = null;
  4849. this._flags.inline_frame = true;
  4850. do {
  4851. index += 1;
  4852. check_token = this._tokens.peek(index - 1);
  4853. if (check_token.newlines) {
  4854. this._flags.inline_frame = false;
  4855. break;
  4856. }
  4857. } while (check_token.type !== TOKEN$2.EOF &&
  4858. !(check_token.type === TOKEN$2.END_BLOCK && check_token.opened === current_token));
  4859. }
  4860. if ((this._options.brace_style === "expand" ||
  4861. (this._options.brace_style === "none" && current_token.newlines)) &&
  4862. !this._flags.inline_frame) {
  4863. if (this._flags.last_token.type !== TOKEN$2.OPERATOR &&
  4864. (empty_anonymous_function ||
  4865. this._flags.last_token.type === TOKEN$2.EQUALS ||
  4866. (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
  4867. this._output.space_before_token = true;
  4868. } else {
  4869. this.print_newline(false, true);
  4870. }
  4871. } else { // collapse || inline_frame
  4872. if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.COMMA)) {
  4873. if (this._flags.last_token.type === TOKEN$2.COMMA || this._options.space_in_paren) {
  4874. this._output.space_before_token = true;
  4875. }
  4876. if (this._flags.last_token.type === TOKEN$2.COMMA || (this._flags.last_token.type === TOKEN$2.START_EXPR && this._flags.inline_frame)) {
  4877. this.allow_wrap_or_preserved_newline(current_token);
  4878. this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
  4879. this._flags.multiline_frame = false;
  4880. }
  4881. }
  4882. if (this._flags.last_token.type !== TOKEN$2.OPERATOR && this._flags.last_token.type !== TOKEN$2.START_EXPR) {
  4883. if (this._flags.last_token.type === TOKEN$2.START_BLOCK && !this._flags.inline_frame) {
  4884. this.print_newline();
  4885. } else {
  4886. this._output.space_before_token = true;
  4887. }
  4888. }
  4889. }
  4890. this.print_token(current_token);
  4891. this.indent();
  4892. // Except for specific cases, open braces are followed by a new line.
  4893. if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
  4894. this.print_newline();
  4895. }
  4896. };
  4897. Beautifier.prototype.handle_end_block = function(current_token) {
  4898. // statements must all be closed when their container closes
  4899. this.handle_whitespace_and_comments(current_token);
  4900. while (this._flags.mode === MODE.Statement) {
  4901. this.restore_mode();
  4902. }
  4903. var empty_braces = this._flags.last_token.type === TOKEN$2.START_BLOCK;
  4904. if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
  4905. this._output.space_before_token = true;
  4906. } else if (this._options.brace_style === "expand") {
  4907. if (!empty_braces) {
  4908. this.print_newline();
  4909. }
  4910. } else {
  4911. // skip {}
  4912. if (!empty_braces) {
  4913. if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
  4914. // we REALLY need a newline here, but newliner would skip that
  4915. this._options.keep_array_indentation = false;
  4916. this.print_newline();
  4917. this._options.keep_array_indentation = true;
  4918. } else {
  4919. this.print_newline();
  4920. }
  4921. }
  4922. }
  4923. this.restore_mode();
  4924. this.print_token(current_token);
  4925. };
  4926. Beautifier.prototype.handle_word = function(current_token) {
  4927. if (current_token.type === TOKEN$2.RESERVED) {
  4928. if (in_array$1(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
  4929. current_token.type = TOKEN$2.WORD;
  4930. } else if (current_token.text === 'import' && this._tokens.peek().text === '(') {
  4931. current_token.type = TOKEN$2.WORD;
  4932. } else if (in_array$1(current_token.text, ['as', 'from']) && !this._flags.import_block) {
  4933. current_token.type = TOKEN$2.WORD;
  4934. } else if (this._flags.mode === MODE.ObjectLiteral) {
  4935. var next_token = this._tokens.peek();
  4936. if (next_token.text === ':') {
  4937. current_token.type = TOKEN$2.WORD;
  4938. }
  4939. }
  4940. }
  4941. if (this.start_of_statement(current_token)) {
  4942. // The conditional starts the statement if appropriate.
  4943. if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD) {
  4944. this._flags.declaration_statement = true;
  4945. }
  4946. } else if (current_token.newlines && !is_expression(this._flags.mode) &&
  4947. (this._flags.last_token.type !== TOKEN$2.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
  4948. this._flags.last_token.type !== TOKEN$2.EQUALS &&
  4949. (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
  4950. this.handle_whitespace_and_comments(current_token);
  4951. this.print_newline();
  4952. } else {
  4953. this.handle_whitespace_and_comments(current_token);
  4954. }
  4955. if (this._flags.do_block && !this._flags.do_while) {
  4956. if (reserved_word(current_token, 'while')) {
  4957. // do {} ## while ()
  4958. this._output.space_before_token = true;
  4959. this.print_token(current_token);
  4960. this._output.space_before_token = true;
  4961. this._flags.do_while = true;
  4962. return;
  4963. } else {
  4964. // do {} should always have while as the next word.
  4965. // if we don't see the expected while, recover
  4966. this.print_newline();
  4967. this._flags.do_block = false;
  4968. }
  4969. }
  4970. // if may be followed by else, or not
  4971. // Bare/inline ifs are tricky
  4972. // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
  4973. if (this._flags.if_block) {
  4974. if (!this._flags.else_block && reserved_word(current_token, 'else')) {
  4975. this._flags.else_block = true;
  4976. } else {
  4977. while (this._flags.mode === MODE.Statement) {
  4978. this.restore_mode();
  4979. }
  4980. this._flags.if_block = false;
  4981. this._flags.else_block = false;
  4982. }
  4983. }
  4984. if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
  4985. this.print_newline();
  4986. if (this._flags.last_token.type !== TOKEN$2.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) {
  4987. // switch cases following one another
  4988. this.deindent();
  4989. }
  4990. this._flags.case_body = false;
  4991. this.print_token(current_token);
  4992. this._flags.in_case = true;
  4993. return;
  4994. }
  4995. 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) {
  4996. if (!this.start_of_object_property()) {
  4997. this.allow_wrap_or_preserved_newline(current_token);
  4998. }
  4999. }
  5000. if (reserved_word(current_token, 'function')) {
  5001. if (in_array$1(this._flags.last_token.text, ['}', ';']) ||
  5002. (this._output.just_added_newline() && !(in_array$1(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN$2.OPERATOR))) {
  5003. // make sure there is a nice clean space of at least one blank line
  5004. // before a new function definition
  5005. if (!this._output.just_added_blankline() && !current_token.comments_before) {
  5006. this.print_newline();
  5007. this.print_newline(true);
  5008. }
  5009. }
  5010. if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD) {
  5011. if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
  5012. reserved_array(this._flags.last_token, newline_restricted_tokens)) {
  5013. this._output.space_before_token = true;
  5014. } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
  5015. this._output.space_before_token = true;
  5016. } else if (this._flags.last_token.text === 'declare') {
  5017. // accomodates Typescript declare function formatting
  5018. this._output.space_before_token = true;
  5019. } else {
  5020. this.print_newline();
  5021. }
  5022. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR || this._flags.last_token.text === '=') {
  5023. // foo = function
  5024. this._output.space_before_token = true;
  5025. } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
  5026. this.print_newline();
  5027. }
  5028. this.print_token(current_token);
  5029. this._flags.last_word = current_token.text;
  5030. return;
  5031. }
  5032. var prefix = 'NONE';
  5033. if (this._flags.last_token.type === TOKEN$2.END_BLOCK) {
  5034. if (this._previous_flags.inline_frame) {
  5035. prefix = 'SPACE';
  5036. } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
  5037. prefix = 'NEWLINE';
  5038. } else {
  5039. if (this._options.brace_style === "expand" ||
  5040. this._options.brace_style === "end-expand" ||
  5041. (this._options.brace_style === "none" && current_token.newlines)) {
  5042. prefix = 'NEWLINE';
  5043. } else {
  5044. prefix = 'SPACE';
  5045. this._output.space_before_token = true;
  5046. }
  5047. }
  5048. } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
  5049. // TODO: Should this be for STATEMENT as well?
  5050. prefix = 'NEWLINE';
  5051. } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && is_expression(this._flags.mode)) {
  5052. prefix = 'SPACE';
  5053. } else if (this._flags.last_token.type === TOKEN$2.STRING) {
  5054. prefix = 'NEWLINE';
  5055. } else if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD ||
  5056. (this._flags.last_token.text === '*' &&
  5057. (in_array$1(this._last_last_text, ['function', 'yield']) ||
  5058. (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
  5059. prefix = 'SPACE';
  5060. } else if (this._flags.last_token.type === TOKEN$2.START_BLOCK) {
  5061. if (this._flags.inline_frame) {
  5062. prefix = 'SPACE';
  5063. } else {
  5064. prefix = 'NEWLINE';
  5065. }
  5066. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
  5067. this._output.space_before_token = true;
  5068. prefix = 'NEWLINE';
  5069. }
  5070. if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
  5071. if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
  5072. prefix = 'SPACE';
  5073. } else {
  5074. prefix = 'NEWLINE';
  5075. }
  5076. }
  5077. if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
  5078. if ((!(this._flags.last_token.type === TOKEN$2.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
  5079. this._options.brace_style === "expand" ||
  5080. this._options.brace_style === "end-expand" ||
  5081. (this._options.brace_style === "none" && current_token.newlines)) &&
  5082. !this._flags.inline_frame) {
  5083. this.print_newline();
  5084. } else {
  5085. this._output.trim(true);
  5086. var line = this._output.current_line;
  5087. // If we trimmed and there's something other than a close block before us
  5088. // put a newline back in. Handles '} // comment' scenario.
  5089. if (line.last() !== '}') {
  5090. this.print_newline();
  5091. }
  5092. this._output.space_before_token = true;
  5093. }
  5094. } else if (prefix === 'NEWLINE') {
  5095. if (reserved_array(this._flags.last_token, special_words)) {
  5096. // no newline between 'return nnn'
  5097. this._output.space_before_token = true;
  5098. } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
  5099. // accomodates Typescript declare formatting
  5100. this._output.space_before_token = true;
  5101. } else if (this._flags.last_token.type !== TOKEN$2.END_EXPR) {
  5102. if ((this._flags.last_token.type !== TOKEN$2.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
  5103. // no need to force newline on 'var': for (var x = 0...)
  5104. if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
  5105. // no newline for } else if {
  5106. this._output.space_before_token = true;
  5107. } else {
  5108. this.print_newline();
  5109. }
  5110. }
  5111. } else if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
  5112. this.print_newline();
  5113. }
  5114. } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
  5115. this.print_newline(); // }, in lists get a newline treatment
  5116. } else if (prefix === 'SPACE') {
  5117. this._output.space_before_token = true;
  5118. }
  5119. if (current_token.previous && (current_token.previous.type === TOKEN$2.WORD || current_token.previous.type === TOKEN$2.RESERVED)) {
  5120. this._output.space_before_token = true;
  5121. }
  5122. this.print_token(current_token);
  5123. this._flags.last_word = current_token.text;
  5124. if (current_token.type === TOKEN$2.RESERVED) {
  5125. if (current_token.text === 'do') {
  5126. this._flags.do_block = true;
  5127. } else if (current_token.text === 'if') {
  5128. this._flags.if_block = true;
  5129. } else if (current_token.text === 'import') {
  5130. this._flags.import_block = true;
  5131. } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
  5132. this._flags.import_block = false;
  5133. }
  5134. }
  5135. };
  5136. Beautifier.prototype.handle_semicolon = function(current_token) {
  5137. if (this.start_of_statement(current_token)) {
  5138. // The conditional starts the statement if appropriate.
  5139. // Semicolon can be the start (and end) of a statement
  5140. this._output.space_before_token = false;
  5141. } else {
  5142. this.handle_whitespace_and_comments(current_token);
  5143. }
  5144. var next_token = this._tokens.peek();
  5145. while (this._flags.mode === MODE.Statement &&
  5146. !(this._flags.if_block && reserved_word(next_token, 'else')) &&
  5147. !this._flags.do_block) {
  5148. this.restore_mode();
  5149. }
  5150. // hacky but effective for the moment
  5151. if (this._flags.import_block) {
  5152. this._flags.import_block = false;
  5153. }
  5154. this.print_token(current_token);
  5155. };
  5156. Beautifier.prototype.handle_string = function(current_token) {
  5157. if (this.start_of_statement(current_token)) {
  5158. // The conditional starts the statement if appropriate.
  5159. // One difference - strings want at least a space before
  5160. this._output.space_before_token = true;
  5161. } else {
  5162. this.handle_whitespace_and_comments(current_token);
  5163. if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD || this._flags.inline_frame) {
  5164. this._output.space_before_token = true;
  5165. } 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) {
  5166. if (!this.start_of_object_property()) {
  5167. this.allow_wrap_or_preserved_newline(current_token);
  5168. }
  5169. } else {
  5170. this.print_newline();
  5171. }
  5172. }
  5173. this.print_token(current_token);
  5174. };
  5175. Beautifier.prototype.handle_equals = function(current_token) {
  5176. if (this.start_of_statement(current_token)) ; else {
  5177. this.handle_whitespace_and_comments(current_token);
  5178. }
  5179. if (this._flags.declaration_statement) {
  5180. // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
  5181. this._flags.declaration_assignment = true;
  5182. }
  5183. this._output.space_before_token = true;
  5184. this.print_token(current_token);
  5185. this._output.space_before_token = true;
  5186. };
  5187. Beautifier.prototype.handle_comma = function(current_token) {
  5188. this.handle_whitespace_and_comments(current_token, true);
  5189. this.print_token(current_token);
  5190. this._output.space_before_token = true;
  5191. if (this._flags.declaration_statement) {
  5192. if (is_expression(this._flags.parent.mode)) {
  5193. // do not break on comma, for(var a = 1, b = 2)
  5194. this._flags.declaration_assignment = false;
  5195. }
  5196. if (this._flags.declaration_assignment) {
  5197. this._flags.declaration_assignment = false;
  5198. this.print_newline(false, true);
  5199. } else if (this._options.comma_first) {
  5200. // for comma-first, we want to allow a newline before the comma
  5201. // to turn into a newline after the comma, which we will fixup later
  5202. this.allow_wrap_or_preserved_newline(current_token);
  5203. }
  5204. } else if (this._flags.mode === MODE.ObjectLiteral ||
  5205. (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
  5206. if (this._flags.mode === MODE.Statement) {
  5207. this.restore_mode();
  5208. }
  5209. if (!this._flags.inline_frame) {
  5210. this.print_newline();
  5211. }
  5212. } else if (this._options.comma_first) {
  5213. // EXPR or DO_BLOCK
  5214. // for comma-first, we want to allow a newline before the comma
  5215. // to turn into a newline after the comma, which we will fixup later
  5216. this.allow_wrap_or_preserved_newline(current_token);
  5217. }
  5218. };
  5219. Beautifier.prototype.handle_operator = function(current_token) {
  5220. var isGeneratorAsterisk = current_token.text === '*' &&
  5221. (reserved_array(this._flags.last_token, ['function', 'yield']) ||
  5222. (in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.COMMA, TOKEN$2.END_BLOCK, TOKEN$2.SEMICOLON]))
  5223. );
  5224. var isUnary = in_array$1(current_token.text, ['-', '+']) && (
  5225. in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.START_EXPR, TOKEN$2.EQUALS, TOKEN$2.OPERATOR]) ||
  5226. in_array$1(this._flags.last_token.text, line_starters$1) ||
  5227. this._flags.last_token.text === ','
  5228. );
  5229. if (this.start_of_statement(current_token)) ; else {
  5230. var preserve_statement_flags = !isGeneratorAsterisk;
  5231. this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
  5232. }
  5233. if (reserved_array(this._flags.last_token, special_words)) {
  5234. // "return" had a special handling in TK_WORD. Now we need to return the favor
  5235. this._output.space_before_token = true;
  5236. this.print_token(current_token);
  5237. return;
  5238. }
  5239. // hack for actionscript's import .*;
  5240. if (current_token.text === '*' && this._flags.last_token.type === TOKEN$2.DOT) {
  5241. this.print_token(current_token);
  5242. return;
  5243. }
  5244. if (current_token.text === '::') {
  5245. // no spaces around exotic namespacing syntax operator
  5246. this.print_token(current_token);
  5247. return;
  5248. }
  5249. // Allow line wrapping between operators when operator_position is
  5250. // set to before or preserve
  5251. if (this._flags.last_token.type === TOKEN$2.OPERATOR && in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
  5252. this.allow_wrap_or_preserved_newline(current_token);
  5253. }
  5254. if (current_token.text === ':' && this._flags.in_case) {
  5255. this.print_token(current_token);
  5256. this._flags.in_case = false;
  5257. this._flags.case_body = true;
  5258. if (this._tokens.peek().type !== TOKEN$2.START_BLOCK) {
  5259. this.indent();
  5260. this.print_newline();
  5261. } else {
  5262. this._output.space_before_token = true;
  5263. }
  5264. return;
  5265. }
  5266. var space_before = true;
  5267. var space_after = true;
  5268. var in_ternary = false;
  5269. if (current_token.text === ':') {
  5270. if (this._flags.ternary_depth === 0) {
  5271. // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
  5272. space_before = false;
  5273. } else {
  5274. this._flags.ternary_depth -= 1;
  5275. in_ternary = true;
  5276. }
  5277. } else if (current_token.text === '?') {
  5278. this._flags.ternary_depth += 1;
  5279. }
  5280. // let's handle the operator_position option prior to any conflicting logic
  5281. if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array$1(current_token.text, positionable_operators$1)) {
  5282. var isColon = current_token.text === ':';
  5283. var isTernaryColon = (isColon && in_ternary);
  5284. var isOtherColon = (isColon && !in_ternary);
  5285. switch (this._options.operator_position) {
  5286. case OPERATOR_POSITION.before_newline:
  5287. // if the current token is : and it's not a ternary statement then we set space_before to false
  5288. this._output.space_before_token = !isOtherColon;
  5289. this.print_token(current_token);
  5290. if (!isColon || isTernaryColon) {
  5291. this.allow_wrap_or_preserved_newline(current_token);
  5292. }
  5293. this._output.space_before_token = true;
  5294. return;
  5295. case OPERATOR_POSITION.after_newline:
  5296. // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
  5297. // then print a newline.
  5298. this._output.space_before_token = true;
  5299. if (!isColon || isTernaryColon) {
  5300. if (this._tokens.peek().newlines) {
  5301. this.print_newline(false, true);
  5302. } else {
  5303. this.allow_wrap_or_preserved_newline(current_token);
  5304. }
  5305. } else {
  5306. this._output.space_before_token = false;
  5307. }
  5308. this.print_token(current_token);
  5309. this._output.space_before_token = true;
  5310. return;
  5311. case OPERATOR_POSITION.preserve_newline:
  5312. if (!isOtherColon) {
  5313. this.allow_wrap_or_preserved_newline(current_token);
  5314. }
  5315. // if we just added a newline, or the current token is : and it's not a ternary statement,
  5316. // then we set space_before to false
  5317. space_before = !(this._output.just_added_newline() || isOtherColon);
  5318. this._output.space_before_token = space_before;
  5319. this.print_token(current_token);
  5320. this._output.space_before_token = true;
  5321. return;
  5322. }
  5323. }
  5324. if (isGeneratorAsterisk) {
  5325. this.allow_wrap_or_preserved_newline(current_token);
  5326. space_before = false;
  5327. var next_token = this._tokens.peek();
  5328. space_after = next_token && in_array$1(next_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]);
  5329. } else if (current_token.text === '...') {
  5330. this.allow_wrap_or_preserved_newline(current_token);
  5331. space_before = this._flags.last_token.type === TOKEN$2.START_BLOCK;
  5332. space_after = false;
  5333. } else if (in_array$1(current_token.text, ['--', '++', '!', '~']) || isUnary) {
  5334. // unary operators (and binary +/- pretending to be unary) special cases
  5335. if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR) {
  5336. this.allow_wrap_or_preserved_newline(current_token);
  5337. }
  5338. space_before = false;
  5339. space_after = false;
  5340. // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
  5341. // if there is a newline between -- or ++ and anything else we should preserve it.
  5342. if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
  5343. this.print_newline(false, true);
  5344. }
  5345. if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
  5346. // for (;; ++i)
  5347. // ^^^
  5348. space_before = true;
  5349. }
  5350. if (this._flags.last_token.type === TOKEN$2.RESERVED) {
  5351. space_before = true;
  5352. } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
  5353. space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
  5354. } else if (this._flags.last_token.type === TOKEN$2.OPERATOR) {
  5355. // a++ + ++b;
  5356. // a - -b
  5357. space_before = in_array$1(current_token.text, ['--', '-', '++', '+']) && in_array$1(this._flags.last_token.text, ['--', '-', '++', '+']);
  5358. // + and - are not unary when preceeded by -- or ++ operator
  5359. // a-- + b
  5360. // a * +b
  5361. // a - -b
  5362. if (in_array$1(current_token.text, ['+', '-']) && in_array$1(this._flags.last_token.text, ['--', '++'])) {
  5363. space_after = true;
  5364. }
  5365. }
  5366. if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
  5367. (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
  5368. // { foo; --i }
  5369. // foo(); --bar;
  5370. this.print_newline();
  5371. }
  5372. }
  5373. this._output.space_before_token = this._output.space_before_token || space_before;
  5374. this.print_token(current_token);
  5375. this._output.space_before_token = space_after;
  5376. };
  5377. Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
  5378. if (this._output.raw) {
  5379. this._output.add_raw_token(current_token);
  5380. if (current_token.directives && current_token.directives.preserve === 'end') {
  5381. // If we're testing the raw output behavior, do not allow a directive to turn it off.
  5382. this._output.raw = this._options.test_output_raw;
  5383. }
  5384. return;
  5385. }
  5386. if (current_token.directives) {
  5387. this.print_newline(false, preserve_statement_flags);
  5388. this.print_token(current_token);
  5389. if (current_token.directives.preserve === 'start') {
  5390. this._output.raw = true;
  5391. }
  5392. this.print_newline(false, true);
  5393. return;
  5394. }
  5395. // inline block
  5396. if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
  5397. this._output.space_before_token = true;
  5398. this.print_token(current_token);
  5399. this._output.space_before_token = true;
  5400. return;
  5401. } else {
  5402. this.print_block_commment(current_token, preserve_statement_flags);
  5403. }
  5404. };
  5405. Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
  5406. var lines = split_linebreaks(current_token.text);
  5407. var j; // iterator for this case
  5408. var javadoc = false;
  5409. var starless = false;
  5410. var lastIndent = current_token.whitespace_before;
  5411. var lastIndentLength = lastIndent.length;
  5412. // block comment starts with a new line
  5413. this.print_newline(false, preserve_statement_flags);
  5414. // first line always indented
  5415. this.print_token_line_indentation(current_token);
  5416. this._output.add_token(lines[0]);
  5417. this.print_newline(false, preserve_statement_flags);
  5418. if (lines.length > 1) {
  5419. lines = lines.slice(1);
  5420. javadoc = all_lines_start_with(lines, '*');
  5421. starless = each_line_matches_indent(lines, lastIndent);
  5422. if (javadoc) {
  5423. this._flags.alignment = 1;
  5424. }
  5425. for (j = 0; j < lines.length; j++) {
  5426. if (javadoc) {
  5427. // javadoc: reformat and re-indent
  5428. this.print_token_line_indentation(current_token);
  5429. this._output.add_token(ltrim(lines[j]));
  5430. } else if (starless && lines[j]) {
  5431. // starless: re-indent non-empty content, avoiding trim
  5432. this.print_token_line_indentation(current_token);
  5433. this._output.add_token(lines[j].substring(lastIndentLength));
  5434. } else {
  5435. // normal comments output raw
  5436. this._output.current_line.set_indent(-1);
  5437. this._output.add_token(lines[j]);
  5438. }
  5439. // for comments on their own line or more than one line, make sure there's a new line after
  5440. this.print_newline(false, preserve_statement_flags);
  5441. }
  5442. this._flags.alignment = 0;
  5443. }
  5444. };
  5445. Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
  5446. if (current_token.newlines) {
  5447. this.print_newline(false, preserve_statement_flags);
  5448. } else {
  5449. this._output.trim(true);
  5450. }
  5451. this._output.space_before_token = true;
  5452. this.print_token(current_token);
  5453. this.print_newline(false, preserve_statement_flags);
  5454. };
  5455. Beautifier.prototype.handle_dot = function(current_token) {
  5456. if (this.start_of_statement(current_token)) ; else {
  5457. this.handle_whitespace_and_comments(current_token, true);
  5458. }
  5459. if (reserved_array(this._flags.last_token, special_words)) {
  5460. this._output.space_before_token = false;
  5461. } else {
  5462. // allow preserved newlines before dots in general
  5463. // force newlines on dots after close paren when break_chained - for bar().baz()
  5464. this.allow_wrap_or_preserved_newline(current_token,
  5465. this._flags.last_token.text === ')' && this._options.break_chained_methods);
  5466. }
  5467. // Only unindent chained method dot if this dot starts a new line.
  5468. // Otherwise the automatic extra indentation removal will handle the over indent
  5469. if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
  5470. this.deindent();
  5471. }
  5472. this.print_token(current_token);
  5473. };
  5474. Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
  5475. this.print_token(current_token);
  5476. if (current_token.text[current_token.text.length - 1] === '\n') {
  5477. this.print_newline(false, preserve_statement_flags);
  5478. }
  5479. };
  5480. Beautifier.prototype.handle_eof = function(current_token) {
  5481. // Unwind any open statements
  5482. while (this._flags.mode === MODE.Statement) {
  5483. this.restore_mode();
  5484. }
  5485. this.handle_whitespace_and_comments(current_token);
  5486. };
  5487. var Beautifier_1 = Beautifier;
  5488. var beautifier = {
  5489. Beautifier: Beautifier_1
  5490. };
  5491. var Beautifier$1 = beautifier.Beautifier,
  5492. Options$3 = options$1.Options;
  5493. function js_beautify(js_source_text, options) {
  5494. var beautifier = new Beautifier$1(js_source_text, options);
  5495. return beautifier.beautify();
  5496. }
  5497. var javascript = js_beautify;
  5498. var defaultOptions = function() {
  5499. return new Options$3();
  5500. };
  5501. javascript.defaultOptions = defaultOptions;
  5502. var BaseOptions$1 = options.Options;
  5503. function Options$4(options) {
  5504. BaseOptions$1.call(this, options, 'css');
  5505. this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
  5506. this.newline_between_rules = this._get_boolean('newline_between_rules', true);
  5507. var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
  5508. this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
  5509. }
  5510. Options$4.prototype = new BaseOptions$1();
  5511. var Options_1$2 = Options$4;
  5512. var options$2 = {
  5513. Options: Options_1$2
  5514. };
  5515. var Options$5 = options$2.Options;
  5516. var Output$2 = output.Output;
  5517. var InputScanner$3 = inputscanner.InputScanner;
  5518. var Directives$2 = directives.Directives;
  5519. var directives_core$1 = new Directives$2(/\/\*/, /\*\//);
  5520. var lineBreak = /\r\n|[\r\n]/;
  5521. var allLineBreaks = /\r\n|[\r\n]/g;
  5522. // tokenizer
  5523. var whitespaceChar = /\s/;
  5524. var whitespacePattern = /(?:\s|\n)+/g;
  5525. var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
  5526. var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
  5527. function Beautifier$2(source_text, options) {
  5528. this._source_text = source_text || '';
  5529. // Allow the setting of language/file-type specific options
  5530. // with inheritance of overall settings
  5531. this._options = new Options$5(options);
  5532. this._ch = null;
  5533. this._input = null;
  5534. // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
  5535. this.NESTED_AT_RULE = {
  5536. "@page": true,
  5537. "@font-face": true,
  5538. "@keyframes": true,
  5539. // also in CONDITIONAL_GROUP_RULE below
  5540. "@media": true,
  5541. "@supports": true,
  5542. "@document": true
  5543. };
  5544. this.CONDITIONAL_GROUP_RULE = {
  5545. "@media": true,
  5546. "@supports": true,
  5547. "@document": true
  5548. };
  5549. }
  5550. Beautifier$2.prototype.eatString = function(endChars) {
  5551. var result = '';
  5552. this._ch = this._input.next();
  5553. while (this._ch) {
  5554. result += this._ch;
  5555. if (this._ch === "\\") {
  5556. result += this._input.next();
  5557. } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
  5558. break;
  5559. }
  5560. this._ch = this._input.next();
  5561. }
  5562. return result;
  5563. };
  5564. // Skips any white space in the source text from the current position.
  5565. // When allowAtLeastOneNewLine is true, will output new lines for each
  5566. // newline character found; if the user has preserve_newlines off, only
  5567. // the first newline will be output
  5568. Beautifier$2.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
  5569. var result = whitespaceChar.test(this._input.peek());
  5570. var isFirstNewLine = true;
  5571. while (whitespaceChar.test(this._input.peek())) {
  5572. this._ch = this._input.next();
  5573. if (allowAtLeastOneNewLine && this._ch === '\n') {
  5574. if (this._options.preserve_newlines || isFirstNewLine) {
  5575. isFirstNewLine = false;
  5576. this._output.add_new_line(true);
  5577. }
  5578. }
  5579. }
  5580. return result;
  5581. };
  5582. // Nested pseudo-class if we are insideRule
  5583. // and the next special character found opens
  5584. // a new block
  5585. Beautifier$2.prototype.foundNestedPseudoClass = function() {
  5586. var openParen = 0;
  5587. var i = 1;
  5588. var ch = this._input.peek(i);
  5589. while (ch) {
  5590. if (ch === "{") {
  5591. return true;
  5592. } else if (ch === '(') {
  5593. // pseudoclasses can contain ()
  5594. openParen += 1;
  5595. } else if (ch === ')') {
  5596. if (openParen === 0) {
  5597. return false;
  5598. }
  5599. openParen -= 1;
  5600. } else if (ch === ";" || ch === "}") {
  5601. return false;
  5602. }
  5603. i++;
  5604. ch = this._input.peek(i);
  5605. }
  5606. return false;
  5607. };
  5608. Beautifier$2.prototype.print_string = function(output_string) {
  5609. this._output.set_indent(this._indentLevel);
  5610. this._output.non_breaking_space = true;
  5611. this._output.add_token(output_string);
  5612. };
  5613. Beautifier$2.prototype.preserveSingleSpace = function(isAfterSpace) {
  5614. if (isAfterSpace) {
  5615. this._output.space_before_token = true;
  5616. }
  5617. };
  5618. Beautifier$2.prototype.indent = function() {
  5619. this._indentLevel++;
  5620. };
  5621. Beautifier$2.prototype.outdent = function() {
  5622. if (this._indentLevel > 0) {
  5623. this._indentLevel--;
  5624. }
  5625. };
  5626. /*_____________________--------------------_____________________*/
  5627. Beautifier$2.prototype.beautify = function() {
  5628. if (this._options.disabled) {
  5629. return this._source_text;
  5630. }
  5631. var source_text = this._source_text;
  5632. var eol = this._options.eol;
  5633. if (eol === 'auto') {
  5634. eol = '\n';
  5635. if (source_text && lineBreak.test(source_text || '')) {
  5636. eol = source_text.match(lineBreak)[0];
  5637. }
  5638. }
  5639. // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
  5640. source_text = source_text.replace(allLineBreaks, '\n');
  5641. // reset
  5642. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  5643. this._output = new Output$2(this._options, baseIndentString);
  5644. this._input = new InputScanner$3(source_text);
  5645. this._indentLevel = 0;
  5646. this._nestedLevel = 0;
  5647. this._ch = null;
  5648. var parenLevel = 0;
  5649. var insideRule = false;
  5650. // This is the value side of a property value pair (blue in the following ex)
  5651. // label { content: blue }
  5652. var insidePropertyValue = false;
  5653. var enteringConditionalGroup = false;
  5654. var insideAtExtend = false;
  5655. var insideAtImport = false;
  5656. var topCharacter = this._ch;
  5657. var whitespace;
  5658. var isAfterSpace;
  5659. var previous_ch;
  5660. while (true) {
  5661. whitespace = this._input.read(whitespacePattern);
  5662. isAfterSpace = whitespace !== '';
  5663. previous_ch = topCharacter;
  5664. this._ch = this._input.next();
  5665. if (this._ch === '\\' && this._input.hasNext()) {
  5666. this._ch += this._input.next();
  5667. }
  5668. topCharacter = this._ch;
  5669. if (!this._ch) {
  5670. break;
  5671. } else if (this._ch === '/' && this._input.peek() === '*') {
  5672. // /* css comment */
  5673. // Always start block comments on a new line.
  5674. // This handles scenarios where a block comment immediately
  5675. // follows a property definition on the same line or where
  5676. // minified code is being beautified.
  5677. this._output.add_new_line();
  5678. this._input.back();
  5679. var comment = this._input.read(block_comment_pattern);
  5680. // Handle ignore directive
  5681. var directives = directives_core$1.get_directives(comment);
  5682. if (directives && directives.ignore === 'start') {
  5683. comment += directives_core$1.readIgnored(this._input);
  5684. }
  5685. this.print_string(comment);
  5686. // Ensures any new lines following the comment are preserved
  5687. this.eatWhitespace(true);
  5688. // Block comments are followed by a new line so they don't
  5689. // share a line with other properties
  5690. this._output.add_new_line();
  5691. } else if (this._ch === '/' && this._input.peek() === '/') {
  5692. // // single line comment
  5693. // Preserves the space before a comment
  5694. // on the same line as a rule
  5695. this._output.space_before_token = true;
  5696. this._input.back();
  5697. this.print_string(this._input.read(comment_pattern));
  5698. // Ensures any new lines following the comment are preserved
  5699. this.eatWhitespace(true);
  5700. } else if (this._ch === '@') {
  5701. this.preserveSingleSpace(isAfterSpace);
  5702. // deal with less propery mixins @{...}
  5703. if (this._input.peek() === '{') {
  5704. this.print_string(this._ch + this.eatString('}'));
  5705. } else {
  5706. this.print_string(this._ch);
  5707. // strip trailing space, if present, for hash property checks
  5708. var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
  5709. if (variableOrRule.match(/[ :]$/)) {
  5710. // we have a variable or pseudo-class, add it and insert one space before continuing
  5711. variableOrRule = this.eatString(": ").replace(/\s$/, '');
  5712. this.print_string(variableOrRule);
  5713. this._output.space_before_token = true;
  5714. }
  5715. variableOrRule = variableOrRule.replace(/\s$/, '');
  5716. if (variableOrRule === 'extend') {
  5717. insideAtExtend = true;
  5718. } else if (variableOrRule === 'import') {
  5719. insideAtImport = true;
  5720. }
  5721. // might be a nesting at-rule
  5722. if (variableOrRule in this.NESTED_AT_RULE) {
  5723. this._nestedLevel += 1;
  5724. if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
  5725. enteringConditionalGroup = true;
  5726. }
  5727. // might be less variable
  5728. } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
  5729. insidePropertyValue = true;
  5730. this.indent();
  5731. }
  5732. }
  5733. } else if (this._ch === '#' && this._input.peek() === '{') {
  5734. this.preserveSingleSpace(isAfterSpace);
  5735. this.print_string(this._ch + this.eatString('}'));
  5736. } else if (this._ch === '{') {
  5737. if (insidePropertyValue) {
  5738. insidePropertyValue = false;
  5739. this.outdent();
  5740. }
  5741. this.indent();
  5742. this._output.space_before_token = true;
  5743. this.print_string(this._ch);
  5744. // when entering conditional groups, only rulesets are allowed
  5745. if (enteringConditionalGroup) {
  5746. enteringConditionalGroup = false;
  5747. insideRule = (this._indentLevel > this._nestedLevel);
  5748. } else {
  5749. // otherwise, declarations are also allowed
  5750. insideRule = (this._indentLevel >= this._nestedLevel);
  5751. }
  5752. if (this._options.newline_between_rules && insideRule) {
  5753. if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
  5754. this._output.ensure_empty_line_above('/', ',');
  5755. }
  5756. }
  5757. this.eatWhitespace(true);
  5758. this._output.add_new_line();
  5759. } else if (this._ch === '}') {
  5760. this.outdent();
  5761. this._output.add_new_line();
  5762. if (previous_ch === '{') {
  5763. this._output.trim(true);
  5764. }
  5765. insideAtImport = false;
  5766. insideAtExtend = false;
  5767. if (insidePropertyValue) {
  5768. this.outdent();
  5769. insidePropertyValue = false;
  5770. }
  5771. this.print_string(this._ch);
  5772. insideRule = false;
  5773. if (this._nestedLevel) {
  5774. this._nestedLevel--;
  5775. }
  5776. this.eatWhitespace(true);
  5777. this._output.add_new_line();
  5778. if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
  5779. if (this._input.peek() !== '}') {
  5780. this._output.add_new_line(true);
  5781. }
  5782. }
  5783. } else if (this._ch === ":") {
  5784. if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
  5785. // 'property: value' delimiter
  5786. // which could be in a conditional group query
  5787. this.print_string(':');
  5788. if (!insidePropertyValue) {
  5789. insidePropertyValue = true;
  5790. this._output.space_before_token = true;
  5791. this.eatWhitespace(true);
  5792. this.indent();
  5793. }
  5794. } else {
  5795. // sass/less parent reference don't use a space
  5796. // sass nested pseudo-class don't use a space
  5797. // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
  5798. if (this._input.lookBack(" ")) {
  5799. this._output.space_before_token = true;
  5800. }
  5801. if (this._input.peek() === ":") {
  5802. // pseudo-element
  5803. this._ch = this._input.next();
  5804. this.print_string("::");
  5805. } else {
  5806. // pseudo-class
  5807. this.print_string(':');
  5808. }
  5809. }
  5810. } else if (this._ch === '"' || this._ch === '\'') {
  5811. this.preserveSingleSpace(isAfterSpace);
  5812. this.print_string(this._ch + this.eatString(this._ch));
  5813. this.eatWhitespace(true);
  5814. } else if (this._ch === ';') {
  5815. if (parenLevel === 0) {
  5816. if (insidePropertyValue) {
  5817. this.outdent();
  5818. insidePropertyValue = false;
  5819. }
  5820. insideAtExtend = false;
  5821. insideAtImport = false;
  5822. this.print_string(this._ch);
  5823. this.eatWhitespace(true);
  5824. // This maintains single line comments on the same
  5825. // line. Block comments are also affected, but
  5826. // a new line is always output before one inside
  5827. // that section
  5828. if (this._input.peek() !== '/') {
  5829. this._output.add_new_line();
  5830. }
  5831. } else {
  5832. this.print_string(this._ch);
  5833. this.eatWhitespace(true);
  5834. this._output.space_before_token = true;
  5835. }
  5836. } else if (this._ch === '(') { // may be a url
  5837. if (this._input.lookBack("url")) {
  5838. this.print_string(this._ch);
  5839. this.eatWhitespace();
  5840. parenLevel++;
  5841. this.indent();
  5842. this._ch = this._input.next();
  5843. if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
  5844. this._input.back();
  5845. } else if (this._ch) {
  5846. this.print_string(this._ch + this.eatString(')'));
  5847. if (parenLevel) {
  5848. parenLevel--;
  5849. this.outdent();
  5850. }
  5851. }
  5852. } else {
  5853. this.preserveSingleSpace(isAfterSpace);
  5854. this.print_string(this._ch);
  5855. this.eatWhitespace();
  5856. parenLevel++;
  5857. this.indent();
  5858. }
  5859. } else if (this._ch === ')') {
  5860. if (parenLevel) {
  5861. parenLevel--;
  5862. this.outdent();
  5863. }
  5864. this.print_string(this._ch);
  5865. } else if (this._ch === ',') {
  5866. this.print_string(this._ch);
  5867. this.eatWhitespace(true);
  5868. if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport) {
  5869. this._output.add_new_line();
  5870. } else {
  5871. this._output.space_before_token = true;
  5872. }
  5873. } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
  5874. //handle combinator spacing
  5875. if (this._options.space_around_combinator) {
  5876. this._output.space_before_token = true;
  5877. this.print_string(this._ch);
  5878. this._output.space_before_token = true;
  5879. } else {
  5880. this.print_string(this._ch);
  5881. this.eatWhitespace();
  5882. // squash extra whitespace
  5883. if (this._ch && whitespaceChar.test(this._ch)) {
  5884. this._ch = '';
  5885. }
  5886. }
  5887. } else if (this._ch === ']') {
  5888. this.print_string(this._ch);
  5889. } else if (this._ch === '[') {
  5890. this.preserveSingleSpace(isAfterSpace);
  5891. this.print_string(this._ch);
  5892. } else if (this._ch === '=') { // no whitespace before or after
  5893. this.eatWhitespace();
  5894. this.print_string('=');
  5895. if (whitespaceChar.test(this._ch)) {
  5896. this._ch = '';
  5897. }
  5898. } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
  5899. this.print_string(' ');
  5900. this.print_string(this._ch);
  5901. } else {
  5902. this.preserveSingleSpace(isAfterSpace);
  5903. this.print_string(this._ch);
  5904. }
  5905. }
  5906. var sweetCode = this._output.get_code(eol);
  5907. return sweetCode;
  5908. };
  5909. var Beautifier_1$1 = Beautifier$2;
  5910. var beautifier$1 = {
  5911. Beautifier: Beautifier_1$1
  5912. };
  5913. var Beautifier$3 = beautifier$1.Beautifier,
  5914. Options$6 = options$2.Options;
  5915. function css_beautify(source_text, options) {
  5916. var beautifier = new Beautifier$3(source_text, options);
  5917. return beautifier.beautify();
  5918. }
  5919. var css = css_beautify;
  5920. var defaultOptions$1 = function() {
  5921. return new Options$6();
  5922. };
  5923. css.defaultOptions = defaultOptions$1;
  5924. var BaseOptions$2 = options.Options;
  5925. function Options$7(options) {
  5926. BaseOptions$2.call(this, options, 'html');
  5927. if (this.templating.length === 1 && this.templating[0] === 'auto') {
  5928. this.templating = ['django', 'erb', 'handlebars', 'php'];
  5929. }
  5930. this.indent_inner_html = this._get_boolean('indent_inner_html');
  5931. this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
  5932. this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
  5933. this.indent_handlebars = this._get_boolean('indent_handlebars', true);
  5934. this.wrap_attributes = this._get_selection('wrap_attributes',
  5935. ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
  5936. this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
  5937. this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
  5938. // Block vs inline elements
  5939. // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
  5940. // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
  5941. // https://www.w3.org/TR/html5/dom.html#phrasing-content
  5942. this.inline = this._get_array('inline', [
  5943. 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
  5944. 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
  5945. 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
  5946. 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
  5947. 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
  5948. 'video', 'wbr', 'text',
  5949. // obsolete inline tags
  5950. 'acronym', 'big', 'strike', 'tt'
  5951. ]);
  5952. this.void_elements = this._get_array('void_elements', [
  5953. // HTLM void elements - aka self-closing tags - aka singletons
  5954. // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
  5955. 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
  5956. 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
  5957. // NOTE: Optional tags are too complex for a simple list
  5958. // they are hard coded in _do_optional_end_element
  5959. // Doctype and xml elements
  5960. '!doctype', '?xml',
  5961. // obsolete tags
  5962. // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
  5963. // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
  5964. 'basefont', 'isindex'
  5965. ]);
  5966. this.unformatted = this._get_array('unformatted', []);
  5967. this.content_unformatted = this._get_array('content_unformatted', [
  5968. 'pre', 'textarea'
  5969. ]);
  5970. this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
  5971. this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
  5972. }
  5973. Options$7.prototype = new BaseOptions$2();
  5974. var Options_1$3 = Options$7;
  5975. var options$3 = {
  5976. Options: Options_1$3
  5977. };
  5978. var BaseTokenizer$1 = tokenizer.Tokenizer;
  5979. var BASETOKEN$1 = tokenizer.TOKEN;
  5980. var Directives$3 = directives.Directives;
  5981. var TemplatablePattern$2 = templatablepattern.TemplatablePattern;
  5982. var Pattern$4 = pattern.Pattern;
  5983. var TOKEN$3 = {
  5984. TAG_OPEN: 'TK_TAG_OPEN',
  5985. TAG_CLOSE: 'TK_TAG_CLOSE',
  5986. ATTRIBUTE: 'TK_ATTRIBUTE',
  5987. EQUALS: 'TK_EQUALS',
  5988. VALUE: 'TK_VALUE',
  5989. COMMENT: 'TK_COMMENT',
  5990. TEXT: 'TK_TEXT',
  5991. UNKNOWN: 'TK_UNKNOWN',
  5992. START: BASETOKEN$1.START,
  5993. RAW: BASETOKEN$1.RAW,
  5994. EOF: BASETOKEN$1.EOF
  5995. };
  5996. var directives_core$2 = new Directives$3(/<\!--/, /-->/);
  5997. var Tokenizer$3 = function(input_string, options) {
  5998. BaseTokenizer$1.call(this, input_string, options);
  5999. this._current_tag_name = '';
  6000. // Words end at whitespace or when a tag starts
  6001. // if we are indenting handlebars, they are considered tags
  6002. var templatable_reader = new TemplatablePattern$2(this._input).read_options(this._options);
  6003. var pattern_reader = new Pattern$4(this._input);
  6004. this.__patterns = {
  6005. word: templatable_reader.until(/[\n\r\t <]/),
  6006. single_quote: templatable_reader.until_after(/'/),
  6007. double_quote: templatable_reader.until_after(/"/),
  6008. attribute: templatable_reader.until(/[\n\r\t =\/>]/),
  6009. element_name: templatable_reader.until(/[\n\r\t >\/]/),
  6010. handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
  6011. handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
  6012. handlebars_open: pattern_reader.until(/[\n\r\t }]/),
  6013. handlebars_raw_close: pattern_reader.until(/}}/),
  6014. comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
  6015. cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
  6016. // https://en.wikipedia.org/wiki/Conditional_comment
  6017. conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
  6018. processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
  6019. };
  6020. if (this._options.indent_handlebars) {
  6021. this.__patterns.word = this.__patterns.word.exclude('handlebars');
  6022. }
  6023. this._unformatted_content_delimiter = null;
  6024. if (this._options.unformatted_content_delimiter) {
  6025. var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
  6026. this.__patterns.unformatted_content_delimiter =
  6027. pattern_reader.matching(literal_regexp)
  6028. .until_after(literal_regexp);
  6029. }
  6030. };
  6031. Tokenizer$3.prototype = new BaseTokenizer$1();
  6032. Tokenizer$3.prototype._is_comment = function(current_token) { // jshint unused:false
  6033. return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
  6034. };
  6035. Tokenizer$3.prototype._is_opening = function(current_token) {
  6036. return current_token.type === TOKEN$3.TAG_OPEN;
  6037. };
  6038. Tokenizer$3.prototype._is_closing = function(current_token, open_token) {
  6039. return current_token.type === TOKEN$3.TAG_CLOSE &&
  6040. (open_token && (
  6041. ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
  6042. (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')));
  6043. };
  6044. Tokenizer$3.prototype._reset = function() {
  6045. this._current_tag_name = '';
  6046. };
  6047. Tokenizer$3.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
  6048. var token = null;
  6049. this._readWhitespace();
  6050. var c = this._input.peek();
  6051. if (c === null) {
  6052. return this._create_token(TOKEN$3.EOF, '');
  6053. }
  6054. token = token || this._read_open_handlebars(c, open_token);
  6055. token = token || this._read_attribute(c, previous_token, open_token);
  6056. token = token || this._read_raw_content(c, previous_token, open_token);
  6057. token = token || this._read_close(c, open_token);
  6058. token = token || this._read_content_word(c);
  6059. token = token || this._read_comment(c);
  6060. token = token || this._read_open(c, open_token);
  6061. token = token || this._create_token(TOKEN$3.UNKNOWN, this._input.next());
  6062. return token;
  6063. };
  6064. Tokenizer$3.prototype._read_comment = function(c) { // jshint unused:false
  6065. var token = null;
  6066. var resulting_string = null;
  6067. var directives = null;
  6068. if (c === '<') {
  6069. var peek1 = this._input.peek(1);
  6070. //if we're in a comment, do something special
  6071. // We treat all comments as literals, even more than preformatted tags
  6072. // we just look for the appropriate close tag
  6073. if (c === '<' && (peek1 === '!' || peek1 === '?')) {
  6074. resulting_string = this.__patterns.comment.read();
  6075. // only process directive on html comments
  6076. if (resulting_string) {
  6077. directives = directives_core$2.get_directives(resulting_string);
  6078. if (directives && directives.ignore === 'start') {
  6079. resulting_string += directives_core$2.readIgnored(this._input);
  6080. }
  6081. } else {
  6082. resulting_string = this.__patterns.cdata.read();
  6083. resulting_string = resulting_string || this.__patterns.conditional_comment.read();
  6084. resulting_string = resulting_string || this.__patterns.processing.read();
  6085. }
  6086. }
  6087. if (resulting_string) {
  6088. token = this._create_token(TOKEN$3.COMMENT, resulting_string);
  6089. token.directives = directives;
  6090. }
  6091. }
  6092. return token;
  6093. };
  6094. Tokenizer$3.prototype._read_open = function(c, open_token) {
  6095. var resulting_string = null;
  6096. var token = null;
  6097. if (!open_token) {
  6098. if (c === '<') {
  6099. resulting_string = this._input.next();
  6100. if (this._input.peek() === '/') {
  6101. resulting_string += this._input.next();
  6102. }
  6103. resulting_string += this.__patterns.element_name.read();
  6104. token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
  6105. }
  6106. }
  6107. return token;
  6108. };
  6109. Tokenizer$3.prototype._read_open_handlebars = function(c, open_token) {
  6110. var resulting_string = null;
  6111. var token = null;
  6112. if (!open_token) {
  6113. if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
  6114. if (this._input.peek(2) === '!') {
  6115. resulting_string = this.__patterns.handlebars_comment.read();
  6116. resulting_string = resulting_string || this.__patterns.handlebars.read();
  6117. token = this._create_token(TOKEN$3.COMMENT, resulting_string);
  6118. } else {
  6119. resulting_string = this.__patterns.handlebars_open.read();
  6120. token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
  6121. }
  6122. }
  6123. }
  6124. return token;
  6125. };
  6126. Tokenizer$3.prototype._read_close = function(c, open_token) {
  6127. var resulting_string = null;
  6128. var token = null;
  6129. if (open_token) {
  6130. if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
  6131. resulting_string = this._input.next();
  6132. if (c === '/') { // for close tag "/>"
  6133. resulting_string += this._input.next();
  6134. }
  6135. token = this._create_token(TOKEN$3.TAG_CLOSE, resulting_string);
  6136. } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
  6137. this._input.next();
  6138. this._input.next();
  6139. token = this._create_token(TOKEN$3.TAG_CLOSE, '}}');
  6140. }
  6141. }
  6142. return token;
  6143. };
  6144. Tokenizer$3.prototype._read_attribute = function(c, previous_token, open_token) {
  6145. var token = null;
  6146. var resulting_string = '';
  6147. if (open_token && open_token.text[0] === '<') {
  6148. if (c === '=') {
  6149. token = this._create_token(TOKEN$3.EQUALS, this._input.next());
  6150. } else if (c === '"' || c === "'") {
  6151. var content = this._input.next();
  6152. if (c === '"') {
  6153. content += this.__patterns.double_quote.read();
  6154. } else {
  6155. content += this.__patterns.single_quote.read();
  6156. }
  6157. token = this._create_token(TOKEN$3.VALUE, content);
  6158. } else {
  6159. resulting_string = this.__patterns.attribute.read();
  6160. if (resulting_string) {
  6161. if (previous_token.type === TOKEN$3.EQUALS) {
  6162. token = this._create_token(TOKEN$3.VALUE, resulting_string);
  6163. } else {
  6164. token = this._create_token(TOKEN$3.ATTRIBUTE, resulting_string);
  6165. }
  6166. }
  6167. }
  6168. }
  6169. return token;
  6170. };
  6171. Tokenizer$3.prototype._is_content_unformatted = function(tag_name) {
  6172. // void_elements have no content and so cannot have unformatted content
  6173. // script and style tags should always be read as unformatted content
  6174. // finally content_unformatted and unformatted element contents are unformatted
  6175. return this._options.void_elements.indexOf(tag_name) === -1 &&
  6176. (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
  6177. this._options.unformatted.indexOf(tag_name) !== -1);
  6178. };
  6179. Tokenizer$3.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
  6180. var resulting_string = '';
  6181. if (open_token && open_token.text[0] === '{') {
  6182. resulting_string = this.__patterns.handlebars_raw_close.read();
  6183. } else if (previous_token.type === TOKEN$3.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
  6184. var tag_name = previous_token.opened.text.substr(1).toLowerCase();
  6185. if (tag_name === 'script' || tag_name === 'style') {
  6186. // Script and style tags are allowed to have comments wrapping their content
  6187. // or just have regular content.
  6188. var token = this._read_comment(c);
  6189. if (token) {
  6190. token.type = TOKEN$3.TEXT;
  6191. return token;
  6192. }
  6193. resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
  6194. } else if (this._is_content_unformatted(tag_name)) {
  6195. resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
  6196. }
  6197. }
  6198. if (resulting_string) {
  6199. return this._create_token(TOKEN$3.TEXT, resulting_string);
  6200. }
  6201. return null;
  6202. };
  6203. Tokenizer$3.prototype._read_content_word = function(c) {
  6204. var resulting_string = '';
  6205. if (this._options.unformatted_content_delimiter) {
  6206. if (c === this._options.unformatted_content_delimiter[0]) {
  6207. resulting_string = this.__patterns.unformatted_content_delimiter.read();
  6208. }
  6209. }
  6210. if (!resulting_string) {
  6211. resulting_string = this.__patterns.word.read();
  6212. }
  6213. if (resulting_string) {
  6214. return this._create_token(TOKEN$3.TEXT, resulting_string);
  6215. }
  6216. };
  6217. var Tokenizer_1$2 = Tokenizer$3;
  6218. var TOKEN_1$2 = TOKEN$3;
  6219. var tokenizer$2 = {
  6220. Tokenizer: Tokenizer_1$2,
  6221. TOKEN: TOKEN_1$2
  6222. };
  6223. var Options$8 = options$3.Options;
  6224. var Output$3 = output.Output;
  6225. var Tokenizer$4 = tokenizer$2.Tokenizer;
  6226. var TOKEN$4 = tokenizer$2.TOKEN;
  6227. var lineBreak$1 = /\r\n|[\r\n]/;
  6228. var allLineBreaks$1 = /\r\n|[\r\n]/g;
  6229. var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
  6230. this.indent_level = 0;
  6231. this.alignment_size = 0;
  6232. this.max_preserve_newlines = options.max_preserve_newlines;
  6233. this.preserve_newlines = options.preserve_newlines;
  6234. this._output = new Output$3(options, base_indent_string);
  6235. };
  6236. Printer.prototype.current_line_has_match = function(pattern) {
  6237. return this._output.current_line.has_match(pattern);
  6238. };
  6239. Printer.prototype.set_space_before_token = function(value, non_breaking) {
  6240. this._output.space_before_token = value;
  6241. this._output.non_breaking_space = non_breaking;
  6242. };
  6243. Printer.prototype.set_wrap_point = function() {
  6244. this._output.set_indent(this.indent_level, this.alignment_size);
  6245. this._output.set_wrap_point();
  6246. };
  6247. Printer.prototype.add_raw_token = function(token) {
  6248. this._output.add_raw_token(token);
  6249. };
  6250. Printer.prototype.print_preserved_newlines = function(raw_token) {
  6251. var newlines = 0;
  6252. if (raw_token.type !== TOKEN$4.TEXT && raw_token.previous.type !== TOKEN$4.TEXT) {
  6253. newlines = raw_token.newlines ? 1 : 0;
  6254. }
  6255. if (this.preserve_newlines) {
  6256. newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
  6257. }
  6258. for (var n = 0; n < newlines; n++) {
  6259. this.print_newline(n > 0);
  6260. }
  6261. return newlines !== 0;
  6262. };
  6263. Printer.prototype.traverse_whitespace = function(raw_token) {
  6264. if (raw_token.whitespace_before || raw_token.newlines) {
  6265. if (!this.print_preserved_newlines(raw_token)) {
  6266. this._output.space_before_token = true;
  6267. }
  6268. return true;
  6269. }
  6270. return false;
  6271. };
  6272. Printer.prototype.previous_token_wrapped = function() {
  6273. return this._output.previous_token_wrapped;
  6274. };
  6275. Printer.prototype.print_newline = function(force) {
  6276. this._output.add_new_line(force);
  6277. };
  6278. Printer.prototype.print_token = function(token) {
  6279. if (token.text) {
  6280. this._output.set_indent(this.indent_level, this.alignment_size);
  6281. this._output.add_token(token.text);
  6282. }
  6283. };
  6284. Printer.prototype.indent = function() {
  6285. this.indent_level++;
  6286. };
  6287. Printer.prototype.get_full_indent = function(level) {
  6288. level = this.indent_level + (level || 0);
  6289. if (level < 1) {
  6290. return '';
  6291. }
  6292. return this._output.get_indent_string(level);
  6293. };
  6294. var get_type_attribute = function(start_token) {
  6295. var result = null;
  6296. var raw_token = start_token.next;
  6297. // Search attributes for a type attribute
  6298. while (raw_token.type !== TOKEN$4.EOF && start_token.closed !== raw_token) {
  6299. if (raw_token.type === TOKEN$4.ATTRIBUTE && raw_token.text === 'type') {
  6300. if (raw_token.next && raw_token.next.type === TOKEN$4.EQUALS &&
  6301. raw_token.next.next && raw_token.next.next.type === TOKEN$4.VALUE) {
  6302. result = raw_token.next.next.text;
  6303. }
  6304. break;
  6305. }
  6306. raw_token = raw_token.next;
  6307. }
  6308. return result;
  6309. };
  6310. var get_custom_beautifier_name = function(tag_check, raw_token) {
  6311. var typeAttribute = null;
  6312. var result = null;
  6313. if (!raw_token.closed) {
  6314. return null;
  6315. }
  6316. if (tag_check === 'script') {
  6317. typeAttribute = 'text/javascript';
  6318. } else if (tag_check === 'style') {
  6319. typeAttribute = 'text/css';
  6320. }
  6321. typeAttribute = get_type_attribute(raw_token) || typeAttribute;
  6322. // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
  6323. // For those without a type attribute use default;
  6324. if (typeAttribute.search('text/css') > -1) {
  6325. result = 'css';
  6326. } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
  6327. result = 'javascript';
  6328. } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
  6329. result = 'html';
  6330. } else if (typeAttribute.search(/test\/null/) > -1) {
  6331. // Test only mime-type for testing the beautifier when null is passed as beautifing function
  6332. result = 'null';
  6333. }
  6334. return result;
  6335. };
  6336. function in_array$2(what, arr) {
  6337. return arr.indexOf(what) !== -1;
  6338. }
  6339. function TagFrame(parent, parser_token, indent_level) {
  6340. this.parent = parent || null;
  6341. this.tag = parser_token ? parser_token.tag_name : '';
  6342. this.indent_level = indent_level || 0;
  6343. this.parser_token = parser_token || null;
  6344. }
  6345. function TagStack(printer) {
  6346. this._printer = printer;
  6347. this._current_frame = null;
  6348. }
  6349. TagStack.prototype.get_parser_token = function() {
  6350. return this._current_frame ? this._current_frame.parser_token : null;
  6351. };
  6352. TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
  6353. var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
  6354. this._current_frame = new_frame;
  6355. };
  6356. TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
  6357. var parser_token = null;
  6358. if (frame) {
  6359. parser_token = frame.parser_token;
  6360. this._printer.indent_level = frame.indent_level;
  6361. this._current_frame = frame.parent;
  6362. }
  6363. return parser_token;
  6364. };
  6365. TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
  6366. var frame = this._current_frame;
  6367. while (frame) { //till we reach '' (the initial value);
  6368. if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
  6369. break;
  6370. } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
  6371. frame = null;
  6372. break;
  6373. }
  6374. frame = frame.parent;
  6375. }
  6376. return frame;
  6377. };
  6378. TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
  6379. var frame = this._get_frame([tag], stop_list);
  6380. return this._try_pop_frame(frame);
  6381. };
  6382. TagStack.prototype.indent_to_tag = function(tag_list) {
  6383. var frame = this._get_frame(tag_list);
  6384. if (frame) {
  6385. this._printer.indent_level = frame.indent_level;
  6386. }
  6387. };
  6388. function Beautifier$4(source_text, options, js_beautify, css_beautify) {
  6389. //Wrapper function to invoke all the necessary constructors and deal with the output.
  6390. this._source_text = source_text || '';
  6391. options = options || {};
  6392. this._js_beautify = js_beautify;
  6393. this._css_beautify = css_beautify;
  6394. this._tag_stack = null;
  6395. // Allow the setting of language/file-type specific options
  6396. // with inheritance of overall settings
  6397. var optionHtml = new Options$8(options, 'html');
  6398. this._options = optionHtml;
  6399. this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
  6400. this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
  6401. this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
  6402. this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
  6403. this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
  6404. this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
  6405. }
  6406. Beautifier$4.prototype.beautify = function() {
  6407. // if disabled, return the input unchanged.
  6408. if (this._options.disabled) {
  6409. return this._source_text;
  6410. }
  6411. var source_text = this._source_text;
  6412. var eol = this._options.eol;
  6413. if (this._options.eol === 'auto') {
  6414. eol = '\n';
  6415. if (source_text && lineBreak$1.test(source_text)) {
  6416. eol = source_text.match(lineBreak$1)[0];
  6417. }
  6418. }
  6419. // HACK: newline parsing inconsistent. This brute force normalizes the input.
  6420. source_text = source_text.replace(allLineBreaks$1, '\n');
  6421. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  6422. var last_token = {
  6423. text: '',
  6424. type: ''
  6425. };
  6426. var last_tag_token = new TagOpenParserToken();
  6427. var printer = new Printer(this._options, baseIndentString);
  6428. var tokens = new Tokenizer$4(source_text, this._options).tokenize();
  6429. this._tag_stack = new TagStack(printer);
  6430. var parser_token = null;
  6431. var raw_token = tokens.next();
  6432. while (raw_token.type !== TOKEN$4.EOF) {
  6433. if (raw_token.type === TOKEN$4.TAG_OPEN || raw_token.type === TOKEN$4.COMMENT) {
  6434. parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
  6435. last_tag_token = parser_token;
  6436. } else if ((raw_token.type === TOKEN$4.ATTRIBUTE || raw_token.type === TOKEN$4.EQUALS || raw_token.type === TOKEN$4.VALUE) ||
  6437. (raw_token.type === TOKEN$4.TEXT && !last_tag_token.tag_complete)) {
  6438. parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
  6439. } else if (raw_token.type === TOKEN$4.TAG_CLOSE) {
  6440. parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
  6441. } else if (raw_token.type === TOKEN$4.TEXT) {
  6442. parser_token = this._handle_text(printer, raw_token, last_tag_token);
  6443. } else {
  6444. // This should never happen, but if it does. Print the raw token
  6445. printer.add_raw_token(raw_token);
  6446. }
  6447. last_token = parser_token;
  6448. raw_token = tokens.next();
  6449. }
  6450. var sweet_code = printer._output.get_code(eol);
  6451. return sweet_code;
  6452. };
  6453. Beautifier$4.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
  6454. var parser_token = {
  6455. text: raw_token.text,
  6456. type: raw_token.type
  6457. };
  6458. printer.alignment_size = 0;
  6459. last_tag_token.tag_complete = true;
  6460. printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
  6461. if (last_tag_token.is_unformatted) {
  6462. printer.add_raw_token(raw_token);
  6463. } else {
  6464. if (last_tag_token.tag_start_char === '<') {
  6465. printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
  6466. if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
  6467. printer.print_newline(false);
  6468. }
  6469. }
  6470. printer.print_token(raw_token);
  6471. }
  6472. if (last_tag_token.indent_content &&
  6473. !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
  6474. printer.indent();
  6475. // only indent once per opened tag
  6476. last_tag_token.indent_content = false;
  6477. }
  6478. if (!last_tag_token.is_inline_element &&
  6479. !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
  6480. printer.set_wrap_point();
  6481. }
  6482. return parser_token;
  6483. };
  6484. Beautifier$4.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
  6485. var wrapped = last_tag_token.has_wrapped_attrs;
  6486. var parser_token = {
  6487. text: raw_token.text,
  6488. type: raw_token.type
  6489. };
  6490. printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
  6491. if (last_tag_token.is_unformatted) {
  6492. printer.add_raw_token(raw_token);
  6493. } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN$4.TEXT) {
  6494. // For the insides of handlebars allow newlines or a single space between open and contents
  6495. if (printer.print_preserved_newlines(raw_token)) {
  6496. raw_token.newlines = 0;
  6497. printer.add_raw_token(raw_token);
  6498. } else {
  6499. printer.print_token(raw_token);
  6500. }
  6501. } else {
  6502. if (raw_token.type === TOKEN$4.ATTRIBUTE) {
  6503. printer.set_space_before_token(true);
  6504. last_tag_token.attr_count += 1;
  6505. } else if (raw_token.type === TOKEN$4.EQUALS) { //no space before =
  6506. printer.set_space_before_token(false);
  6507. } else if (raw_token.type === TOKEN$4.VALUE && raw_token.previous.type === TOKEN$4.EQUALS) { //no space before value
  6508. printer.set_space_before_token(false);
  6509. }
  6510. if (raw_token.type === TOKEN$4.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
  6511. if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
  6512. printer.traverse_whitespace(raw_token);
  6513. wrapped = wrapped || raw_token.newlines !== 0;
  6514. }
  6515. if (this._is_wrap_attributes_force) {
  6516. var force_attr_wrap = last_tag_token.attr_count > 1;
  6517. if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
  6518. var is_only_attribute = true;
  6519. var peek_index = 0;
  6520. var peek_token;
  6521. do {
  6522. peek_token = tokens.peek(peek_index);
  6523. if (peek_token.type === TOKEN$4.ATTRIBUTE) {
  6524. is_only_attribute = false;
  6525. break;
  6526. }
  6527. peek_index += 1;
  6528. } while (peek_index < 4 && peek_token.type !== TOKEN$4.EOF && peek_token.type !== TOKEN$4.TAG_CLOSE);
  6529. force_attr_wrap = !is_only_attribute;
  6530. }
  6531. if (force_attr_wrap) {
  6532. printer.print_newline(false);
  6533. wrapped = true;
  6534. }
  6535. }
  6536. }
  6537. printer.print_token(raw_token);
  6538. wrapped = wrapped || printer.previous_token_wrapped();
  6539. last_tag_token.has_wrapped_attrs = wrapped;
  6540. }
  6541. return parser_token;
  6542. };
  6543. Beautifier$4.prototype._handle_text = function(printer, raw_token, last_tag_token) {
  6544. var parser_token = {
  6545. text: raw_token.text,
  6546. type: 'TK_CONTENT'
  6547. };
  6548. if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
  6549. this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
  6550. } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
  6551. printer.add_raw_token(raw_token);
  6552. } else {
  6553. printer.traverse_whitespace(raw_token);
  6554. printer.print_token(raw_token);
  6555. }
  6556. return parser_token;
  6557. };
  6558. Beautifier$4.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
  6559. var local = this;
  6560. if (raw_token.text !== '') {
  6561. var text = raw_token.text,
  6562. _beautifier,
  6563. script_indent_level = 1,
  6564. pre = '',
  6565. post = '';
  6566. if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
  6567. _beautifier = this._js_beautify;
  6568. } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
  6569. _beautifier = this._css_beautify;
  6570. } else if (last_tag_token.custom_beautifier_name === 'html') {
  6571. _beautifier = function(html_source, options) {
  6572. var beautifier = new Beautifier$4(html_source, options, local._js_beautify, local._css_beautify);
  6573. return beautifier.beautify();
  6574. };
  6575. }
  6576. if (this._options.indent_scripts === "keep") {
  6577. script_indent_level = 0;
  6578. } else if (this._options.indent_scripts === "separate") {
  6579. script_indent_level = -printer.indent_level;
  6580. }
  6581. var indentation = printer.get_full_indent(script_indent_level);
  6582. // if there is at least one empty line at the end of this text, strip it
  6583. // we'll be adding one back after the text but before the containing tag.
  6584. text = text.replace(/\n[ \t]*$/, '');
  6585. // Handle the case where content is wrapped in a comment or cdata.
  6586. if (last_tag_token.custom_beautifier_name !== 'html' &&
  6587. text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
  6588. var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
  6589. // if we start to wrap but don't finish, print raw
  6590. if (!matched) {
  6591. printer.add_raw_token(raw_token);
  6592. return;
  6593. }
  6594. pre = indentation + matched[1] + '\n';
  6595. text = matched[4];
  6596. if (matched[5]) {
  6597. post = indentation + matched[5];
  6598. }
  6599. // if there is at least one empty line at the end of this text, strip it
  6600. // we'll be adding one back after the text but before the containing tag.
  6601. text = text.replace(/\n[ \t]*$/, '');
  6602. if (matched[2] || matched[3].indexOf('\n') !== -1) {
  6603. // if the first line of the non-comment text has spaces
  6604. // use that as the basis for indenting in null case.
  6605. matched = matched[3].match(/[ \t]+$/);
  6606. if (matched) {
  6607. raw_token.whitespace_before = matched[0];
  6608. }
  6609. }
  6610. }
  6611. if (text) {
  6612. if (_beautifier) {
  6613. // call the Beautifier if avaliable
  6614. var Child_options = function() {
  6615. this.eol = '\n';
  6616. };
  6617. Child_options.prototype = this._options.raw_options;
  6618. var child_options = new Child_options();
  6619. text = _beautifier(indentation + text, child_options);
  6620. } else {
  6621. // simply indent the string otherwise
  6622. var white = raw_token.whitespace_before;
  6623. if (white) {
  6624. text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
  6625. }
  6626. text = indentation + text.replace(/\n/g, '\n' + indentation);
  6627. }
  6628. }
  6629. if (pre) {
  6630. if (!text) {
  6631. text = pre + post;
  6632. } else {
  6633. text = pre + text + '\n' + post;
  6634. }
  6635. }
  6636. printer.print_newline(false);
  6637. if (text) {
  6638. raw_token.text = text;
  6639. raw_token.whitespace_before = '';
  6640. raw_token.newlines = 0;
  6641. printer.add_raw_token(raw_token);
  6642. printer.print_newline(true);
  6643. }
  6644. }
  6645. };
  6646. Beautifier$4.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
  6647. var parser_token = this._get_tag_open_token(raw_token);
  6648. if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
  6649. raw_token.type === TOKEN$4.TAG_OPEN && raw_token.text.indexOf('</') === 0) {
  6650. // End element tags for unformatted or content_unformatted elements
  6651. // are printed raw to keep any newlines inside them exactly the same.
  6652. printer.add_raw_token(raw_token);
  6653. } else {
  6654. printer.traverse_whitespace(raw_token);
  6655. this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
  6656. if (!parser_token.is_inline_element) {
  6657. printer.set_wrap_point();
  6658. }
  6659. printer.print_token(raw_token);
  6660. }
  6661. //indent attributes an auto, forced, aligned or forced-align line-wrap
  6662. if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
  6663. parser_token.alignment_size = raw_token.text.length + 1;
  6664. }
  6665. if (!parser_token.tag_complete && !parser_token.is_unformatted) {
  6666. printer.alignment_size = parser_token.alignment_size;
  6667. }
  6668. return parser_token;
  6669. };
  6670. var TagOpenParserToken = function(parent, raw_token) {
  6671. this.parent = parent || null;
  6672. this.text = '';
  6673. this.type = 'TK_TAG_OPEN';
  6674. this.tag_name = '';
  6675. this.is_inline_element = false;
  6676. this.is_unformatted = false;
  6677. this.is_content_unformatted = false;
  6678. this.is_empty_element = false;
  6679. this.is_start_tag = false;
  6680. this.is_end_tag = false;
  6681. this.indent_content = false;
  6682. this.multiline_content = false;
  6683. this.custom_beautifier_name = null;
  6684. this.start_tag_token = null;
  6685. this.attr_count = 0;
  6686. this.has_wrapped_attrs = false;
  6687. this.alignment_size = 0;
  6688. this.tag_complete = false;
  6689. this.tag_start_char = '';
  6690. this.tag_check = '';
  6691. if (!raw_token) {
  6692. this.tag_complete = true;
  6693. } else {
  6694. var tag_check_match;
  6695. this.tag_start_char = raw_token.text[0];
  6696. this.text = raw_token.text;
  6697. if (this.tag_start_char === '<') {
  6698. tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
  6699. this.tag_check = tag_check_match ? tag_check_match[1] : '';
  6700. } else {
  6701. tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
  6702. this.tag_check = tag_check_match ? tag_check_match[1] : '';
  6703. }
  6704. this.tag_check = this.tag_check.toLowerCase();
  6705. if (raw_token.type === TOKEN$4.COMMENT) {
  6706. this.tag_complete = true;
  6707. }
  6708. this.is_start_tag = this.tag_check.charAt(0) !== '/';
  6709. this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
  6710. this.is_end_tag = !this.is_start_tag ||
  6711. (raw_token.closed && raw_token.closed.text === '/>');
  6712. // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
  6713. this.is_end_tag = this.is_end_tag ||
  6714. (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2)))));
  6715. }
  6716. };
  6717. Beautifier$4.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
  6718. var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
  6719. parser_token.alignment_size = this._options.wrap_attributes_indent_size;
  6720. parser_token.is_end_tag = parser_token.is_end_tag ||
  6721. in_array$2(parser_token.tag_check, this._options.void_elements);
  6722. parser_token.is_empty_element = parser_token.tag_complete ||
  6723. (parser_token.is_start_tag && parser_token.is_end_tag);
  6724. parser_token.is_unformatted = !parser_token.tag_complete && in_array$2(parser_token.tag_check, this._options.unformatted);
  6725. parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array$2(parser_token.tag_check, this._options.content_unformatted);
  6726. parser_token.is_inline_element = in_array$2(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{';
  6727. return parser_token;
  6728. };
  6729. Beautifier$4.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
  6730. if (!parser_token.is_empty_element) {
  6731. if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
  6732. parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
  6733. } else { // it's a start-tag
  6734. // check if this tag is starting an element that has optional end element
  6735. // and do an ending needed
  6736. if (this._do_optional_end_element(parser_token)) {
  6737. if (!parser_token.is_inline_element) {
  6738. if (parser_token.parent) {
  6739. parser_token.parent.multiline_content = true;
  6740. }
  6741. printer.print_newline(false);
  6742. }
  6743. }
  6744. this._tag_stack.record_tag(parser_token); //push it on the tag stack
  6745. if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
  6746. !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
  6747. parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
  6748. }
  6749. }
  6750. }
  6751. if (in_array$2(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
  6752. printer.print_newline(false);
  6753. if (!printer._output.just_added_blankline()) {
  6754. printer.print_newline(true);
  6755. }
  6756. }
  6757. if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
  6758. // if you hit an else case, reset the indent level if you are inside an:
  6759. // 'if', 'unless', or 'each' block.
  6760. if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
  6761. this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
  6762. parser_token.indent_content = true;
  6763. // Don't add a newline if opening {{#if}} tag is on the current line
  6764. var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
  6765. if (!foundIfOnCurrentLine) {
  6766. printer.print_newline(false);
  6767. }
  6768. }
  6769. // Don't add a newline before elements that should remain where they are.
  6770. if (parser_token.tag_name === '!--' && last_token.type === TOKEN$4.TAG_CLOSE &&
  6771. last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) ; else if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
  6772. printer.print_newline(false);
  6773. }
  6774. } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) {
  6775. if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
  6776. printer.print_newline(false);
  6777. }
  6778. } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
  6779. if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) ||
  6780. !(parser_token.is_inline_element ||
  6781. (last_tag_token.is_inline_element) ||
  6782. (last_token.type === TOKEN$4.TAG_CLOSE &&
  6783. parser_token.start_tag_token === last_tag_token) ||
  6784. (last_token.type === 'TK_CONTENT')
  6785. )) {
  6786. printer.print_newline(false);
  6787. }
  6788. } else { // it's a start-tag
  6789. parser_token.indent_content = !parser_token.custom_beautifier_name;
  6790. if (parser_token.tag_start_char === '<') {
  6791. if (parser_token.tag_name === 'html') {
  6792. parser_token.indent_content = this._options.indent_inner_html;
  6793. } else if (parser_token.tag_name === 'head') {
  6794. parser_token.indent_content = this._options.indent_head_inner_html;
  6795. } else if (parser_token.tag_name === 'body') {
  6796. parser_token.indent_content = this._options.indent_body_inner_html;
  6797. }
  6798. }
  6799. if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') {
  6800. if (parser_token.parent) {
  6801. parser_token.parent.multiline_content = true;
  6802. }
  6803. printer.print_newline(false);
  6804. }
  6805. }
  6806. };
  6807. //To be used for <p> tag special case:
  6808. //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'];
  6809. Beautifier$4.prototype._do_optional_end_element = function(parser_token) {
  6810. var result = null;
  6811. // NOTE: cases of "if there is no more content in the parent element"
  6812. // are handled automatically by the beautifier.
  6813. // It assumes parent or ancestor close tag closes all children.
  6814. // https://www.w3.org/TR/html5/syntax.html#optional-tags
  6815. if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
  6816. return;
  6817. } else if (parser_token.tag_name === 'body') {
  6818. // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
  6819. result = result || this._tag_stack.try_pop('head');
  6820. //} else if (parser_token.tag_name === 'body') {
  6821. // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
  6822. } else if (parser_token.tag_name === 'li') {
  6823. // 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.
  6824. result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
  6825. } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
  6826. // 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.
  6827. // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
  6828. result = result || this._tag_stack.try_pop('dt', ['dl']);
  6829. result = result || this._tag_stack.try_pop('dd', ['dl']);
  6830. //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
  6831. //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
  6832. //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.
  6833. //result = result || this._tag_stack.try_pop('p', ['body']);
  6834. } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
  6835. // 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.
  6836. // 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.
  6837. result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
  6838. result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
  6839. } else if (parser_token.tag_name === 'optgroup') {
  6840. // 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.
  6841. // 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.
  6842. result = result || this._tag_stack.try_pop('optgroup', ['select']);
  6843. //result = result || this._tag_stack.try_pop('option', ['select']);
  6844. } else if (parser_token.tag_name === 'option') {
  6845. // 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.
  6846. result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
  6847. } else if (parser_token.tag_name === 'colgroup') {
  6848. // 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.
  6849. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6850. result = result || this._tag_stack.try_pop('caption', ['table']);
  6851. } else if (parser_token.tag_name === 'thead') {
  6852. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6853. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6854. result = result || this._tag_stack.try_pop('caption', ['table']);
  6855. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6856. //} else if (parser_token.tag_name === 'caption') {
  6857. // 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.
  6858. } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
  6859. // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
  6860. // 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.
  6861. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6862. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6863. result = result || this._tag_stack.try_pop('caption', ['table']);
  6864. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6865. result = result || this._tag_stack.try_pop('thead', ['table']);
  6866. result = result || this._tag_stack.try_pop('tbody', ['table']);
  6867. //} else if (parser_token.tag_name === 'tfoot') {
  6868. // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
  6869. } else if (parser_token.tag_name === 'tr') {
  6870. // 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.
  6871. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
  6872. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
  6873. result = result || this._tag_stack.try_pop('caption', ['table']);
  6874. result = result || this._tag_stack.try_pop('colgroup', ['table']);
  6875. result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
  6876. } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
  6877. // 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.
  6878. // 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.
  6879. result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
  6880. result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
  6881. }
  6882. // Start element omission not handled currently
  6883. // 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.
  6884. // 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.)
  6885. // 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.)
  6886. // Fix up the parent of the parser token
  6887. parser_token.parent = this._tag_stack.get_parser_token();
  6888. return result;
  6889. };
  6890. var Beautifier_1$2 = Beautifier$4;
  6891. var beautifier$2 = {
  6892. Beautifier: Beautifier_1$2
  6893. };
  6894. var Beautifier$5 = beautifier$2.Beautifier,
  6895. Options$9 = options$3.Options;
  6896. function style_html(html_source, options, js_beautify, css_beautify) {
  6897. var beautifier = new Beautifier$5(html_source, options, js_beautify, css_beautify);
  6898. return beautifier.beautify();
  6899. }
  6900. var html = style_html;
  6901. var defaultOptions$2 = function() {
  6902. return new Options$9();
  6903. };
  6904. html.defaultOptions = defaultOptions$2;
  6905. function style_html$1(html_source, options, js, css$1) {
  6906. js = js || javascript;
  6907. css$1 = css$1 || css;
  6908. return html(html_source, options, js, css$1);
  6909. }
  6910. style_html$1.defaultOptions = html.defaultOptions;
  6911. var js = javascript;
  6912. var css$1 = css;
  6913. var html$1 = style_html$1;
  6914. var src = {
  6915. js: js,
  6916. css: css$1,
  6917. html: html$1
  6918. };
  6919. var js$1 = createCommonjsModule(function (module) {
  6920. /**
  6921. The following batches are equivalent:
  6922. var beautify_js = require('js-beautify');
  6923. var beautify_js = require('js-beautify').js;
  6924. var beautify_js = require('js-beautify').js_beautify;
  6925. var beautify_css = require('js-beautify').css;
  6926. var beautify_css = require('js-beautify').css_beautify;
  6927. var beautify_html = require('js-beautify').html;
  6928. var beautify_html = require('js-beautify').html_beautify;
  6929. All methods returned accept two arguments, the source string and an options object.
  6930. **/
  6931. function get_beautify(js_beautify, css_beautify, html_beautify) {
  6932. // the default is js
  6933. var beautify = function(src, config) {
  6934. return js_beautify.js_beautify(src, config);
  6935. };
  6936. // short aliases
  6937. beautify.js = js_beautify.js_beautify;
  6938. beautify.css = css_beautify.css_beautify;
  6939. beautify.html = html_beautify.html_beautify;
  6940. // legacy aliases
  6941. beautify.js_beautify = js_beautify.js_beautify;
  6942. beautify.css_beautify = css_beautify.css_beautify;
  6943. beautify.html_beautify = html_beautify.html_beautify;
  6944. return beautify;
  6945. }
  6946. {
  6947. (function(mod) {
  6948. var beautifier = src;
  6949. beautifier.js_beautify = beautifier.js;
  6950. beautifier.css_beautify = beautifier.css;
  6951. beautifier.html_beautify = beautifier.html;
  6952. mod.exports = get_beautify(beautifier, beautifier, beautifier);
  6953. })(module);
  6954. }
  6955. });
  6956. /*!
  6957. * is-whitespace <https://github.com/jonschlinkert/is-whitespace>
  6958. *
  6959. * Copyright (c) 2014-2015, Jon Schlinkert.
  6960. * Licensed under the MIT License.
  6961. */
  6962. var cache;
  6963. var isWhitespace = function isWhitespace(str) {
  6964. return (typeof str === 'string') && regex().test(str);
  6965. };
  6966. function regex() {
  6967. // ensure that runtime compilation only happens once
  6968. 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"]+$'));
  6969. }
  6970. /*!
  6971. * is-extendable <https://github.com/jonschlinkert/is-extendable>
  6972. *
  6973. * Copyright (c) 2015, Jon Schlinkert.
  6974. * Licensed under the MIT License.
  6975. */
  6976. var isExtendable = function isExtendable(val) {
  6977. return typeof val !== 'undefined' && val !== null
  6978. && (typeof val === 'object' || typeof val === 'function');
  6979. };
  6980. var extendShallow = function extend(o/*, objects*/) {
  6981. var arguments$1 = arguments;
  6982. if (!isExtendable(o)) { o = {}; }
  6983. var len = arguments.length;
  6984. for (var i = 1; i < len; i++) {
  6985. var obj = arguments$1[i];
  6986. if (isExtendable(obj)) {
  6987. assign(o, obj);
  6988. }
  6989. }
  6990. return o;
  6991. };
  6992. function assign(a, b) {
  6993. for (var key in b) {
  6994. if (hasOwn(b, key)) {
  6995. a[key] = b[key];
  6996. }
  6997. }
  6998. }
  6999. /**
  7000. * Returns true if the given `key` is an own property of `obj`.
  7001. */
  7002. function hasOwn(obj, key) {
  7003. return Object.prototype.hasOwnProperty.call(obj, key);
  7004. }
  7005. /*!
  7006. * Determine if an object is a Buffer
  7007. *
  7008. * @author Feross Aboukhadijeh <https://feross.org>
  7009. * @license MIT
  7010. */
  7011. // The _isBuffer check is for Safari 5-7 support, because it's missing
  7012. // Object.prototype.constructor. Remove this eventually
  7013. var isBuffer_1 = function (obj) {
  7014. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  7015. };
  7016. function isBuffer (obj) {
  7017. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  7018. }
  7019. // For Node v0.10 support. Remove this eventually.
  7020. function isSlowBuffer (obj) {
  7021. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  7022. }
  7023. var toString = Object.prototype.toString;
  7024. /**
  7025. * Get the native `typeof` a value.
  7026. *
  7027. * @param {*} `val`
  7028. * @return {*} Native javascript type
  7029. */
  7030. var kindOf = function kindOf(val) {
  7031. // primitivies
  7032. if (typeof val === 'undefined') {
  7033. return 'undefined';
  7034. }
  7035. if (val === null) {
  7036. return 'null';
  7037. }
  7038. if (val === true || val === false || val instanceof Boolean) {
  7039. return 'boolean';
  7040. }
  7041. if (typeof val === 'string' || val instanceof String) {
  7042. return 'string';
  7043. }
  7044. if (typeof val === 'number' || val instanceof Number) {
  7045. return 'number';
  7046. }
  7047. // functions
  7048. if (typeof val === 'function' || val instanceof Function) {
  7049. return 'function';
  7050. }
  7051. // array
  7052. if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
  7053. return 'array';
  7054. }
  7055. // check for instances of RegExp and Date before calling `toString`
  7056. if (val instanceof RegExp) {
  7057. return 'regexp';
  7058. }
  7059. if (val instanceof Date) {
  7060. return 'date';
  7061. }
  7062. // other objects
  7063. var type = toString.call(val);
  7064. if (type === '[object RegExp]') {
  7065. return 'regexp';
  7066. }
  7067. if (type === '[object Date]') {
  7068. return 'date';
  7069. }
  7070. if (type === '[object Arguments]') {
  7071. return 'arguments';
  7072. }
  7073. if (type === '[object Error]') {
  7074. return 'error';
  7075. }
  7076. // buffer
  7077. if (isBuffer_1(val)) {
  7078. return 'buffer';
  7079. }
  7080. // es6: Map, WeakMap, Set, WeakSet
  7081. if (type === '[object Set]') {
  7082. return 'set';
  7083. }
  7084. if (type === '[object WeakSet]') {
  7085. return 'weakset';
  7086. }
  7087. if (type === '[object Map]') {
  7088. return 'map';
  7089. }
  7090. if (type === '[object WeakMap]') {
  7091. return 'weakmap';
  7092. }
  7093. if (type === '[object Symbol]') {
  7094. return 'symbol';
  7095. }
  7096. // typed arrays
  7097. if (type === '[object Int8Array]') {
  7098. return 'int8array';
  7099. }
  7100. if (type === '[object Uint8Array]') {
  7101. return 'uint8array';
  7102. }
  7103. if (type === '[object Uint8ClampedArray]') {
  7104. return 'uint8clampedarray';
  7105. }
  7106. if (type === '[object Int16Array]') {
  7107. return 'int16array';
  7108. }
  7109. if (type === '[object Uint16Array]') {
  7110. return 'uint16array';
  7111. }
  7112. if (type === '[object Int32Array]') {
  7113. return 'int32array';
  7114. }
  7115. if (type === '[object Uint32Array]') {
  7116. return 'uint32array';
  7117. }
  7118. if (type === '[object Float32Array]') {
  7119. return 'float32array';
  7120. }
  7121. if (type === '[object Float64Array]') {
  7122. return 'float64array';
  7123. }
  7124. // must be a plain object
  7125. return 'object';
  7126. };
  7127. var condenseNewlines = function(str, options) {
  7128. var opts = extendShallow({}, options);
  7129. var sep = opts.sep || '\n\n';
  7130. var min = opts.min;
  7131. var re;
  7132. if (typeof min === 'number' && min !== 2) {
  7133. re = new RegExp('(\\r\\n|\\n|\\u2424) {' + min + ',}');
  7134. }
  7135. if (typeof re === 'undefined') {
  7136. re = opts.regex || /(\r\n|\n|\u2424){2,}/g;
  7137. }
  7138. // if a line is 100% whitespace it will be trimmed, so that
  7139. // later we can condense newlines correctly
  7140. if (opts.keepWhitespace !== true) {
  7141. str = str.split('\n').map(function(line) {
  7142. return isWhitespace(line) ? line.trim() : line;
  7143. }).join('\n');
  7144. }
  7145. str = trailingNewline(str, opts);
  7146. return str.replace(re, sep);
  7147. };
  7148. function trailingNewline(str, options) {
  7149. var val = options.trailingNewline;
  7150. if (val === false) {
  7151. return str;
  7152. }
  7153. switch (kindOf(val)) {
  7154. case 'string':
  7155. str = str.replace(/\s+$/, options.trailingNewline);
  7156. break;
  7157. case 'function':
  7158. str = options.trailingNewline(str);
  7159. break;
  7160. case 'undefined':
  7161. case 'boolean':
  7162. default: {
  7163. str = str.replace(/\s+$/, '\n');
  7164. break;
  7165. }
  7166. }
  7167. return str;
  7168. }
  7169. var defaults = {
  7170. unformatted: ['code', 'pre', 'em', 'strong', 'span'],
  7171. indent_inner_html: true,
  7172. indent_char: ' ',
  7173. indent_size: 2,
  7174. sep: '\n'
  7175. };
  7176. var pretty = function pretty(str, options) {
  7177. var opts = extendShallow({}, defaults, options);
  7178. str = js$1.html(str, opts);
  7179. if (opts.ocd === true) {
  7180. if (opts.newlines) { opts.sep = opts.newlines; }
  7181. return ocd(str, opts);
  7182. }
  7183. return str;
  7184. };
  7185. function ocd(str, options) {
  7186. // Normalize and condense all newlines
  7187. return condenseNewlines(str, options)
  7188. // Remove empty whitespace the top of a file.
  7189. .replace(/^\s+/g, '')
  7190. // Remove extra whitespace from eof
  7191. .replace(/\s+$/g, '\n')
  7192. // Add a space above each comment
  7193. .replace(/(\s*<!--)/g, '\n$1')
  7194. // Bring closing comments up to the same line as closing tag.
  7195. .replace(/>(\s*)(?=<!--\s*\/)/g, '> ');
  7196. }
  7197. //
  7198. function getSelectorType(selector) {
  7199. if (isDomSelector(selector)) { return DOM_SELECTOR }
  7200. if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
  7201. if (isNameSelector(selector)) { return NAME_SELECTOR }
  7202. if (isRefSelector(selector)) { return REF_SELECTOR }
  7203. return INVALID_SELECTOR
  7204. }
  7205. function getSelector(
  7206. selector,
  7207. methodName
  7208. ) {
  7209. var type = getSelectorType(selector);
  7210. if (type === INVALID_SELECTOR) {
  7211. throwError(
  7212. "wrapper." + methodName + "() must be passed a valid CSS selector, Vue " +
  7213. "constructor, or valid find option object"
  7214. );
  7215. }
  7216. return {
  7217. type: type,
  7218. value: selector
  7219. }
  7220. }
  7221. //
  7222. var WrapperArray = function WrapperArray(wrappers) {
  7223. var length = wrappers.length;
  7224. // $FlowIgnore
  7225. Object.defineProperty(this, 'wrappers', {
  7226. get: function () { return wrappers; },
  7227. set: function () { return throwError('wrapperArray.wrappers is read-only'); }
  7228. });
  7229. // $FlowIgnore
  7230. Object.defineProperty(this, 'length', {
  7231. get: function () { return length; },
  7232. set: function () { return throwError('wrapperArray.length is read-only'); }
  7233. });
  7234. };
  7235. WrapperArray.prototype.at = function at (index) {
  7236. var normalizedIndex = index < 0 ? this.length + index : index;
  7237. if (normalizedIndex > this.length - 1 || normalizedIndex < 0) {
  7238. var error = "no item exists at " + index;
  7239. error += index < 0 ? (" (normalized to " + normalizedIndex + ")") : '';
  7240. throwError(error);
  7241. }
  7242. return this.wrappers[normalizedIndex]
  7243. };
  7244. WrapperArray.prototype.attributes = function attributes () {
  7245. this.throwErrorIfWrappersIsEmpty('attributes');
  7246. throwError(
  7247. "attributes must be called on a single wrapper, use " +
  7248. "at(i) to access a wrapper"
  7249. );
  7250. };
  7251. WrapperArray.prototype.classes = function classes () {
  7252. this.throwErrorIfWrappersIsEmpty('classes');
  7253. throwError(
  7254. "classes must be called on a single wrapper, use " +
  7255. "at(i) to access a wrapper"
  7256. );
  7257. };
  7258. WrapperArray.prototype.contains = function contains (selector) {
  7259. this.throwErrorIfWrappersIsEmpty('contains');
  7260. return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
  7261. };
  7262. WrapperArray.prototype.exists = function exists () {
  7263. return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
  7264. };
  7265. WrapperArray.prototype.filter = function filter (predicate) {
  7266. return new WrapperArray(this.wrappers.filter(predicate))
  7267. };
  7268. WrapperArray.prototype.emitted = function emitted () {
  7269. this.throwErrorIfWrappersIsEmpty('emitted');
  7270. throwError(
  7271. "emitted must be called on a single wrapper, use " +
  7272. "at(i) to access a wrapper"
  7273. );
  7274. };
  7275. WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
  7276. this.throwErrorIfWrappersIsEmpty('emittedByOrder');
  7277. throwError(
  7278. "emittedByOrder must be called on a single wrapper, " +
  7279. "use at(i) to access a wrapper"
  7280. );
  7281. };
  7282. WrapperArray.prototype.findAll = function findAll () {
  7283. this.throwErrorIfWrappersIsEmpty('findAll');
  7284. throwError(
  7285. "findAll must be called on a single wrapper, use " +
  7286. "at(i) to access a wrapper"
  7287. );
  7288. };
  7289. WrapperArray.prototype.find = function find () {
  7290. this.throwErrorIfWrappersIsEmpty('find');
  7291. throwError(
  7292. "find must be called on a single wrapper, use at(i) " +
  7293. "to access a wrapper"
  7294. );
  7295. };
  7296. WrapperArray.prototype.html = function html () {
  7297. this.throwErrorIfWrappersIsEmpty('html');
  7298. throwError(
  7299. "html must be called on a single wrapper, use at(i) " +
  7300. "to access a wrapper"
  7301. );
  7302. };
  7303. WrapperArray.prototype.is = function is (selector) {
  7304. this.throwErrorIfWrappersIsEmpty('is');
  7305. return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
  7306. };
  7307. WrapperArray.prototype.isEmpty = function isEmpty () {
  7308. this.throwErrorIfWrappersIsEmpty('isEmpty');
  7309. return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
  7310. };
  7311. WrapperArray.prototype.isVisible = function isVisible () {
  7312. this.throwErrorIfWrappersIsEmpty('isVisible');
  7313. return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
  7314. };
  7315. WrapperArray.prototype.isVueInstance = function isVueInstance () {
  7316. this.throwErrorIfWrappersIsEmpty('isVueInstance');
  7317. return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
  7318. };
  7319. WrapperArray.prototype.name = function name () {
  7320. this.throwErrorIfWrappersIsEmpty('name');
  7321. throwError(
  7322. "name must be called on a single wrapper, use at(i) " +
  7323. "to access a wrapper"
  7324. );
  7325. };
  7326. WrapperArray.prototype.overview = function overview () {
  7327. this.throwErrorIfWrappersIsEmpty('overview()');
  7328. throwError(
  7329. "overview() must be called on a single wrapper, use at(i) " +
  7330. "to access a wrapper"
  7331. );
  7332. };
  7333. WrapperArray.prototype.props = function props () {
  7334. this.throwErrorIfWrappersIsEmpty('props');
  7335. throwError(
  7336. "props must be called on a single wrapper, use " +
  7337. "at(i) to access a wrapper"
  7338. );
  7339. };
  7340. WrapperArray.prototype.text = function text () {
  7341. this.throwErrorIfWrappersIsEmpty('text');
  7342. throwError(
  7343. "text must be called on a single wrapper, use at(i) " +
  7344. "to access a wrapper"
  7345. );
  7346. };
  7347. WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
  7348. if (this.wrappers.length === 0) {
  7349. throwError((method + " cannot be called on 0 items"));
  7350. }
  7351. };
  7352. WrapperArray.prototype.setData = function setData (data) {
  7353. this.throwErrorIfWrappersIsEmpty('setData');
  7354. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setData(data); }))
  7355. };
  7356. WrapperArray.prototype.setMethods = function setMethods (props) {
  7357. this.throwErrorIfWrappersIsEmpty('setMethods');
  7358. this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
  7359. };
  7360. WrapperArray.prototype.setProps = function setProps (props) {
  7361. this.throwErrorIfWrappersIsEmpty('setProps');
  7362. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setProps(props); }))
  7363. };
  7364. WrapperArray.prototype.setValue = function setValue (value) {
  7365. this.throwErrorIfWrappersIsEmpty('setValue');
  7366. return Promise.all(this.wrappers.map(function (wrapper) { return wrapper.setValue(value); }))
  7367. };
  7368. WrapperArray.prototype.setChecked = function setChecked (checked) {
  7369. if ( checked === void 0 ) checked = true;
  7370. this.throwErrorIfWrappersIsEmpty('setChecked');
  7371. return Promise.all(
  7372. this.wrappers.map(function (wrapper) { return wrapper.setChecked(checked); })
  7373. )
  7374. };
  7375. WrapperArray.prototype.setSelected = function setSelected () {
  7376. this.throwErrorIfWrappersIsEmpty('setSelected');
  7377. throwError(
  7378. "setSelected must be called on a single wrapper, " +
  7379. "use at(i) to access a wrapper"
  7380. );
  7381. };
  7382. WrapperArray.prototype.trigger = function trigger (event, options) {
  7383. this.throwErrorIfWrappersIsEmpty('trigger');
  7384. return Promise.all(
  7385. this.wrappers.map(function (wrapper) { return wrapper.trigger(event, options); })
  7386. )
  7387. };
  7388. WrapperArray.prototype.destroy = function destroy () {
  7389. this.throwErrorIfWrappersIsEmpty('destroy');
  7390. this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
  7391. };
  7392. //
  7393. var buildSelectorString = function (selector) {
  7394. if (getSelectorType(selector) === REF_SELECTOR) {
  7395. return ("ref=\"" + (selector.value.ref) + "\"")
  7396. }
  7397. if (typeof selector === 'string') {
  7398. return selector
  7399. }
  7400. return 'Component'
  7401. };
  7402. var ErrorWrapper = function ErrorWrapper(selector) {
  7403. this.selector = selector;
  7404. };
  7405. ErrorWrapper.prototype.at = function at () {
  7406. throwError(
  7407. ("find did not return " + (buildSelectorString(
  7408. this.selector
  7409. )) + ", cannot call at() on empty Wrapper")
  7410. );
  7411. };
  7412. ErrorWrapper.prototype.attributes = function attributes () {
  7413. throwError(
  7414. ("find did not return " + (buildSelectorString(
  7415. this.selector
  7416. )) + ", cannot call attributes() on empty Wrapper")
  7417. );
  7418. };
  7419. ErrorWrapper.prototype.classes = function classes () {
  7420. throwError(
  7421. ("find did not return " + (buildSelectorString(
  7422. this.selector
  7423. )) + ", cannot call classes() on empty Wrapper")
  7424. );
  7425. };
  7426. ErrorWrapper.prototype.contains = function contains () {
  7427. throwError(
  7428. ("find did not return " + (buildSelectorString(
  7429. this.selector
  7430. )) + ", cannot call contains() on empty Wrapper")
  7431. );
  7432. };
  7433. ErrorWrapper.prototype.emitted = function emitted () {
  7434. throwError(
  7435. ("find did not return " + (buildSelectorString(
  7436. this.selector
  7437. )) + ", cannot call emitted() on empty Wrapper")
  7438. );
  7439. };
  7440. ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
  7441. throwError(
  7442. ("find did not return " + (buildSelectorString(
  7443. this.selector
  7444. )) + ", cannot call emittedByOrder() on empty Wrapper")
  7445. );
  7446. };
  7447. ErrorWrapper.prototype.exists = function exists () {
  7448. return false
  7449. };
  7450. ErrorWrapper.prototype.filter = function filter () {
  7451. throwError(
  7452. ("find did not return " + (buildSelectorString(
  7453. this.selector
  7454. )) + ", cannot call filter() on empty Wrapper")
  7455. );
  7456. };
  7457. ErrorWrapper.prototype.visible = function visible () {
  7458. throwError(
  7459. ("find did not return " + (buildSelectorString(
  7460. this.selector
  7461. )) + ", cannot call visible() on empty Wrapper")
  7462. );
  7463. };
  7464. ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
  7465. throwError(
  7466. ("find did not return " + (buildSelectorString(
  7467. this.selector
  7468. )) + ", cannot call hasAttribute() on empty Wrapper")
  7469. );
  7470. };
  7471. ErrorWrapper.prototype.hasClass = function hasClass () {
  7472. throwError(
  7473. ("find did not return " + (buildSelectorString(
  7474. this.selector
  7475. )) + ", cannot call hasClass() on empty Wrapper")
  7476. );
  7477. };
  7478. ErrorWrapper.prototype.hasProp = function hasProp () {
  7479. throwError(
  7480. ("find did not return " + (buildSelectorString(
  7481. this.selector
  7482. )) + ", cannot call hasProp() on empty Wrapper")
  7483. );
  7484. };
  7485. ErrorWrapper.prototype.hasStyle = function hasStyle () {
  7486. throwError(
  7487. ("find did not return " + (buildSelectorString(
  7488. this.selector
  7489. )) + ", cannot call hasStyle() on empty Wrapper")
  7490. );
  7491. };
  7492. ErrorWrapper.prototype.findAll = function findAll () {
  7493. throwError(
  7494. ("find did not return " + (buildSelectorString(
  7495. this.selector
  7496. )) + ", cannot call findAll() on empty Wrapper")
  7497. );
  7498. };
  7499. ErrorWrapper.prototype.find = function find () {
  7500. throwError(
  7501. ("find did not return " + (buildSelectorString(
  7502. this.selector
  7503. )) + ", cannot call find() on empty Wrapper")
  7504. );
  7505. };
  7506. ErrorWrapper.prototype.html = function html () {
  7507. throwError(
  7508. ("find did not return " + (buildSelectorString(
  7509. this.selector
  7510. )) + ", cannot call html() on empty Wrapper")
  7511. );
  7512. };
  7513. ErrorWrapper.prototype.is = function is () {
  7514. throwError(
  7515. ("find did not return " + (buildSelectorString(
  7516. this.selector
  7517. )) + ", cannot call is() on empty Wrapper")
  7518. );
  7519. };
  7520. ErrorWrapper.prototype.isEmpty = function isEmpty () {
  7521. throwError(
  7522. ("find did not return " + (buildSelectorString(
  7523. this.selector
  7524. )) + ", cannot call isEmpty() on empty Wrapper")
  7525. );
  7526. };
  7527. ErrorWrapper.prototype.isVisible = function isVisible () {
  7528. throwError(
  7529. ("find did not return " + (buildSelectorString(
  7530. this.selector
  7531. )) + ", cannot call isVisible() on empty Wrapper")
  7532. );
  7533. };
  7534. ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
  7535. throwError(
  7536. ("find did not return " + (buildSelectorString(
  7537. this.selector
  7538. )) + ", cannot call isVueInstance() on empty Wrapper")
  7539. );
  7540. };
  7541. ErrorWrapper.prototype.name = function name () {
  7542. throwError(
  7543. ("find did not return " + (buildSelectorString(
  7544. this.selector
  7545. )) + ", cannot call name() on empty Wrapper")
  7546. );
  7547. };
  7548. ErrorWrapper.prototype.overview = function overview () {
  7549. throwError(
  7550. ("find did not return " + (buildSelectorString(
  7551. this.selector
  7552. )) + ", cannot call overview() on empty Wrapper")
  7553. );
  7554. };
  7555. ErrorWrapper.prototype.props = function props () {
  7556. throwError(
  7557. ("find did not return " + (buildSelectorString(
  7558. this.selector
  7559. )) + ", cannot call props() on empty Wrapper")
  7560. );
  7561. };
  7562. ErrorWrapper.prototype.text = function text () {
  7563. throwError(
  7564. ("find did not return " + (buildSelectorString(
  7565. this.selector
  7566. )) + ", cannot call text() on empty Wrapper")
  7567. );
  7568. };
  7569. ErrorWrapper.prototype.setComputed = function setComputed () {
  7570. throwError(
  7571. ("find did not return " + (buildSelectorString(
  7572. this.selector
  7573. )) + ", cannot call setComputed() on empty Wrapper")
  7574. );
  7575. };
  7576. ErrorWrapper.prototype.setData = function setData () {
  7577. throwError(
  7578. ("find did not return " + (buildSelectorString(
  7579. this.selector
  7580. )) + ", cannot call setData() on empty Wrapper")
  7581. );
  7582. };
  7583. ErrorWrapper.prototype.setMethods = function setMethods () {
  7584. throwError(
  7585. ("find did not return " + (buildSelectorString(
  7586. this.selector
  7587. )) + ", cannot call setMethods() on empty Wrapper")
  7588. );
  7589. };
  7590. ErrorWrapper.prototype.setProps = function setProps () {
  7591. throwError(
  7592. ("find did not return " + (buildSelectorString(
  7593. this.selector
  7594. )) + ", cannot call setProps() on empty Wrapper")
  7595. );
  7596. };
  7597. ErrorWrapper.prototype.setValue = function setValue () {
  7598. throwError(
  7599. ("find did not return " + (buildSelectorString(
  7600. this.selector
  7601. )) + ", cannot call setValue() on empty Wrapper")
  7602. );
  7603. };
  7604. ErrorWrapper.prototype.setChecked = function setChecked () {
  7605. throwError(
  7606. ("find did not return " + (buildSelectorString(
  7607. this.selector
  7608. )) + ", cannot call setChecked() on empty Wrapper")
  7609. );
  7610. };
  7611. ErrorWrapper.prototype.setSelected = function setSelected () {
  7612. throwError(
  7613. ("find did not return " + (buildSelectorString(
  7614. this.selector
  7615. )) + ", cannot call setSelected() on empty Wrapper")
  7616. );
  7617. };
  7618. ErrorWrapper.prototype.trigger = function trigger () {
  7619. throwError(
  7620. ("find did not return " + (buildSelectorString(
  7621. this.selector
  7622. )) + ", cannot call trigger() on empty Wrapper")
  7623. );
  7624. };
  7625. ErrorWrapper.prototype.destroy = function destroy () {
  7626. throwError(
  7627. ("find did not return " + (buildSelectorString(
  7628. this.selector
  7629. )) + ", cannot call destroy() on empty Wrapper")
  7630. );
  7631. };
  7632. /*!
  7633. * isElementVisible
  7634. * Ported from https://github.com/testing-library/jest-dom
  7635. * Licensed under the MIT License.
  7636. */
  7637. function isStyleVisible(element) {
  7638. var ref = element.style;
  7639. var display = ref.display;
  7640. var visibility = ref.visibility;
  7641. var opacity = ref.opacity;
  7642. return (
  7643. display !== 'none' &&
  7644. visibility !== 'hidden' &&
  7645. visibility !== 'collapse' &&
  7646. opacity !== '0' &&
  7647. opacity !== 0
  7648. )
  7649. }
  7650. function isAttributeVisible(element, previousElement) {
  7651. return (
  7652. !element.hasAttribute('hidden') &&
  7653. (element.nodeName === 'DETAILS' && previousElement.nodeName !== 'SUMMARY'
  7654. ? element.hasAttribute('open')
  7655. : true)
  7656. )
  7657. }
  7658. function isElementVisible(element, previousElement) {
  7659. return (
  7660. element.nodeName !== '#comment' &&
  7661. isStyleVisible(element) &&
  7662. isAttributeVisible(element, previousElement) &&
  7663. (!element.parentElement || isElementVisible(element.parentElement, element))
  7664. )
  7665. }
  7666. function recursivelySetData(vm, target, data) {
  7667. Object.keys(data).forEach(function (key) {
  7668. var val = data[key];
  7669. var targetVal = target[key];
  7670. if (
  7671. isPlainObject(val) &&
  7672. isPlainObject(targetVal) &&
  7673. Object.keys(val).length > 0
  7674. ) {
  7675. recursivelySetData(vm, targetVal, val);
  7676. } else {
  7677. vm.$set(target, key, val);
  7678. }
  7679. });
  7680. }
  7681. var abort = {
  7682. eventInterface: "Event",
  7683. bubbles: false,
  7684. cancelable: false
  7685. };
  7686. var afterprint = {
  7687. eventInterface: "Event",
  7688. bubbles: false,
  7689. cancelable: false
  7690. };
  7691. var animationend = {
  7692. eventInterface: "AnimationEvent",
  7693. bubbles: true,
  7694. cancelable: false
  7695. };
  7696. var animationiteration = {
  7697. eventInterface: "AnimationEvent",
  7698. bubbles: true,
  7699. cancelable: false
  7700. };
  7701. var animationstart = {
  7702. eventInterface: "AnimationEvent",
  7703. bubbles: true,
  7704. cancelable: false
  7705. };
  7706. var appinstalled = {
  7707. eventInterface: "Event",
  7708. bubbles: false,
  7709. cancelable: false
  7710. };
  7711. var audioprocess = {
  7712. eventInterface: "AudioProcessingEvent"
  7713. };
  7714. var audioend = {
  7715. eventInterface: "Event",
  7716. bubbles: false,
  7717. cancelable: false
  7718. };
  7719. var audiostart = {
  7720. eventInterface: "Event",
  7721. bubbles: false,
  7722. cancelable: false
  7723. };
  7724. var beforeprint = {
  7725. eventInterface: "Event",
  7726. bubbles: false,
  7727. cancelable: false
  7728. };
  7729. var beforeunload = {
  7730. eventInterface: "BeforeUnloadEvent",
  7731. bubbles: false,
  7732. cancelable: true
  7733. };
  7734. var beginEvent = {
  7735. eventInterface: "TimeEvent",
  7736. bubbles: false,
  7737. cancelable: false
  7738. };
  7739. var blur = {
  7740. eventInterface: "FocusEvent",
  7741. bubbles: false,
  7742. cancelable: false
  7743. };
  7744. var boundary = {
  7745. eventInterface: "SpeechSynthesisEvent",
  7746. bubbles: false,
  7747. cancelable: false
  7748. };
  7749. var cached = {
  7750. eventInterface: "Event",
  7751. bubbles: false,
  7752. cancelable: false
  7753. };
  7754. var canplay = {
  7755. eventInterface: "Event",
  7756. bubbles: false,
  7757. cancelable: false
  7758. };
  7759. var canplaythrough = {
  7760. eventInterface: "Event",
  7761. bubbles: false,
  7762. cancelable: false
  7763. };
  7764. var change = {
  7765. eventInterface: "Event",
  7766. bubbles: true,
  7767. cancelable: false
  7768. };
  7769. var chargingchange = {
  7770. eventInterface: "Event",
  7771. bubbles: false,
  7772. cancelable: false
  7773. };
  7774. var chargingtimechange = {
  7775. eventInterface: "Event",
  7776. bubbles: false,
  7777. cancelable: false
  7778. };
  7779. var checking = {
  7780. eventInterface: "Event",
  7781. bubbles: false,
  7782. cancelable: false
  7783. };
  7784. var click = {
  7785. eventInterface: "MouseEvent",
  7786. bubbles: true,
  7787. cancelable: true
  7788. };
  7789. var close = {
  7790. eventInterface: "Event",
  7791. bubbles: false,
  7792. cancelable: false
  7793. };
  7794. var complete = {
  7795. eventInterface: "OfflineAudioCompletionEvent"
  7796. };
  7797. var compositionend = {
  7798. eventInterface: "CompositionEvent",
  7799. bubbles: true,
  7800. cancelable: true
  7801. };
  7802. var compositionstart = {
  7803. eventInterface: "CompositionEvent",
  7804. bubbles: true,
  7805. cancelable: true
  7806. };
  7807. var compositionupdate = {
  7808. eventInterface: "CompositionEvent",
  7809. bubbles: true,
  7810. cancelable: false
  7811. };
  7812. var contextmenu = {
  7813. eventInterface: "MouseEvent",
  7814. bubbles: true,
  7815. cancelable: true
  7816. };
  7817. var copy = {
  7818. eventInterface: "ClipboardEvent"
  7819. };
  7820. var cut = {
  7821. eventInterface: "ClipboardEvent",
  7822. bubbles: true,
  7823. cancelable: true
  7824. };
  7825. var dblclick = {
  7826. eventInterface: "MouseEvent",
  7827. bubbles: true,
  7828. cancelable: true
  7829. };
  7830. var devicechange = {
  7831. eventInterface: "Event",
  7832. bubbles: false,
  7833. cancelable: false
  7834. };
  7835. var devicelight = {
  7836. eventInterface: "DeviceLightEvent",
  7837. bubbles: false,
  7838. cancelable: false
  7839. };
  7840. var devicemotion = {
  7841. eventInterface: "DeviceMotionEvent",
  7842. bubbles: false,
  7843. cancelable: false
  7844. };
  7845. var deviceorientation = {
  7846. eventInterface: "DeviceOrientationEvent",
  7847. bubbles: false,
  7848. cancelable: false
  7849. };
  7850. var deviceproximity = {
  7851. eventInterface: "DeviceProximityEvent",
  7852. bubbles: false,
  7853. cancelable: false
  7854. };
  7855. var dischargingtimechange = {
  7856. eventInterface: "Event",
  7857. bubbles: false,
  7858. cancelable: false
  7859. };
  7860. var DOMActivate = {
  7861. eventInterface: "UIEvent",
  7862. bubbles: true,
  7863. cancelable: true
  7864. };
  7865. var DOMAttributeNameChanged = {
  7866. eventInterface: "MutationNameEvent",
  7867. bubbles: true,
  7868. cancelable: true
  7869. };
  7870. var DOMAttrModified = {
  7871. eventInterface: "MutationEvent",
  7872. bubbles: true,
  7873. cancelable: true
  7874. };
  7875. var DOMCharacterDataModified = {
  7876. eventInterface: "MutationEvent",
  7877. bubbles: true,
  7878. cancelable: true
  7879. };
  7880. var DOMContentLoaded = {
  7881. eventInterface: "Event",
  7882. bubbles: true,
  7883. cancelable: true
  7884. };
  7885. var DOMElementNameChanged = {
  7886. eventInterface: "MutationNameEvent",
  7887. bubbles: true,
  7888. cancelable: true
  7889. };
  7890. var DOMFocusIn = {
  7891. eventInterface: "FocusEvent",
  7892. bubbles: true,
  7893. cancelable: true
  7894. };
  7895. var DOMFocusOut = {
  7896. eventInterface: "FocusEvent",
  7897. bubbles: true,
  7898. cancelable: true
  7899. };
  7900. var DOMNodeInserted = {
  7901. eventInterface: "MutationEvent",
  7902. bubbles: true,
  7903. cancelable: true
  7904. };
  7905. var DOMNodeInsertedIntoDocument = {
  7906. eventInterface: "MutationEvent",
  7907. bubbles: true,
  7908. cancelable: true
  7909. };
  7910. var DOMNodeRemoved = {
  7911. eventInterface: "MutationEvent",
  7912. bubbles: true,
  7913. cancelable: true
  7914. };
  7915. var DOMNodeRemovedFromDocument = {
  7916. eventInterface: "MutationEvent",
  7917. bubbles: true,
  7918. cancelable: true
  7919. };
  7920. var DOMSubtreeModified = {
  7921. eventInterface: "MutationEvent"
  7922. };
  7923. var downloading = {
  7924. eventInterface: "Event",
  7925. bubbles: false,
  7926. cancelable: false
  7927. };
  7928. var drag = {
  7929. eventInterface: "DragEvent",
  7930. bubbles: true,
  7931. cancelable: true
  7932. };
  7933. var dragend = {
  7934. eventInterface: "DragEvent",
  7935. bubbles: true,
  7936. cancelable: false
  7937. };
  7938. var dragenter = {
  7939. eventInterface: "DragEvent",
  7940. bubbles: true,
  7941. cancelable: true
  7942. };
  7943. var dragleave = {
  7944. eventInterface: "DragEvent",
  7945. bubbles: true,
  7946. cancelable: false
  7947. };
  7948. var dragover = {
  7949. eventInterface: "DragEvent",
  7950. bubbles: true,
  7951. cancelable: true
  7952. };
  7953. var dragstart = {
  7954. eventInterface: "DragEvent",
  7955. bubbles: true,
  7956. cancelable: true
  7957. };
  7958. var drop = {
  7959. eventInterface: "DragEvent",
  7960. bubbles: true,
  7961. cancelable: true
  7962. };
  7963. var durationchange = {
  7964. eventInterface: "Event",
  7965. bubbles: false,
  7966. cancelable: false
  7967. };
  7968. var emptied = {
  7969. eventInterface: "Event",
  7970. bubbles: false,
  7971. cancelable: false
  7972. };
  7973. var end = {
  7974. eventInterface: "Event",
  7975. bubbles: false,
  7976. cancelable: false
  7977. };
  7978. var ended = {
  7979. eventInterface: "Event",
  7980. bubbles: false,
  7981. cancelable: false
  7982. };
  7983. var endEvent = {
  7984. eventInterface: "TimeEvent",
  7985. bubbles: false,
  7986. cancelable: false
  7987. };
  7988. var error = {
  7989. eventInterface: "Event",
  7990. bubbles: false,
  7991. cancelable: false
  7992. };
  7993. var focus = {
  7994. eventInterface: "FocusEvent",
  7995. bubbles: false,
  7996. cancelable: false
  7997. };
  7998. var focusin = {
  7999. eventInterface: "FocusEvent",
  8000. bubbles: true,
  8001. cancelable: false
  8002. };
  8003. var focusout = {
  8004. eventInterface: "FocusEvent",
  8005. bubbles: true,
  8006. cancelable: false
  8007. };
  8008. var fullscreenchange = {
  8009. eventInterface: "Event",
  8010. bubbles: true,
  8011. cancelable: false
  8012. };
  8013. var fullscreenerror = {
  8014. eventInterface: "Event",
  8015. bubbles: true,
  8016. cancelable: false
  8017. };
  8018. var gamepadconnected = {
  8019. eventInterface: "GamepadEvent",
  8020. bubbles: false,
  8021. cancelable: false
  8022. };
  8023. var gamepaddisconnected = {
  8024. eventInterface: "GamepadEvent",
  8025. bubbles: false,
  8026. cancelable: false
  8027. };
  8028. var gotpointercapture = {
  8029. eventInterface: "PointerEvent",
  8030. bubbles: false,
  8031. cancelable: false
  8032. };
  8033. var hashchange = {
  8034. eventInterface: "HashChangeEvent",
  8035. bubbles: true,
  8036. cancelable: false
  8037. };
  8038. var lostpointercapture = {
  8039. eventInterface: "PointerEvent",
  8040. bubbles: false,
  8041. cancelable: false
  8042. };
  8043. var input = {
  8044. eventInterface: "Event",
  8045. bubbles: true,
  8046. cancelable: false
  8047. };
  8048. var invalid = {
  8049. eventInterface: "Event",
  8050. cancelable: true,
  8051. bubbles: false
  8052. };
  8053. var keydown = {
  8054. eventInterface: "KeyboardEvent",
  8055. bubbles: true,
  8056. cancelable: true
  8057. };
  8058. var keypress = {
  8059. eventInterface: "KeyboardEvent",
  8060. bubbles: true,
  8061. cancelable: true
  8062. };
  8063. var keyup = {
  8064. eventInterface: "KeyboardEvent",
  8065. bubbles: true,
  8066. cancelable: true
  8067. };
  8068. var languagechange = {
  8069. eventInterface: "Event",
  8070. bubbles: false,
  8071. cancelable: false
  8072. };
  8073. var levelchange = {
  8074. eventInterface: "Event",
  8075. bubbles: false,
  8076. cancelable: false
  8077. };
  8078. var load = {
  8079. eventInterface: "UIEvent",
  8080. bubbles: false,
  8081. cancelable: false
  8082. };
  8083. var loadeddata = {
  8084. eventInterface: "Event",
  8085. bubbles: false,
  8086. cancelable: false
  8087. };
  8088. var loadedmetadata = {
  8089. eventInterface: "Event",
  8090. bubbles: false,
  8091. cancelable: false
  8092. };
  8093. var loadend = {
  8094. eventInterface: "ProgressEvent",
  8095. bubbles: false,
  8096. cancelable: false
  8097. };
  8098. var loadstart = {
  8099. eventInterface: "ProgressEvent",
  8100. bubbles: false,
  8101. cancelable: false
  8102. };
  8103. var mark = {
  8104. eventInterface: "SpeechSynthesisEvent",
  8105. bubbles: false,
  8106. cancelable: false
  8107. };
  8108. var message = {
  8109. eventInterface: "MessageEvent",
  8110. bubbles: false,
  8111. cancelable: false
  8112. };
  8113. var messageerror = {
  8114. eventInterface: "MessageEvent",
  8115. bubbles: false,
  8116. cancelable: false
  8117. };
  8118. var mousedown = {
  8119. eventInterface: "MouseEvent",
  8120. bubbles: true,
  8121. cancelable: true
  8122. };
  8123. var mouseenter = {
  8124. eventInterface: "MouseEvent",
  8125. bubbles: false,
  8126. cancelable: false
  8127. };
  8128. var mouseleave = {
  8129. eventInterface: "MouseEvent",
  8130. bubbles: false,
  8131. cancelable: false
  8132. };
  8133. var mousemove = {
  8134. eventInterface: "MouseEvent",
  8135. bubbles: true,
  8136. cancelable: true
  8137. };
  8138. var mouseout = {
  8139. eventInterface: "MouseEvent",
  8140. bubbles: true,
  8141. cancelable: true
  8142. };
  8143. var mouseover = {
  8144. eventInterface: "MouseEvent",
  8145. bubbles: true,
  8146. cancelable: true
  8147. };
  8148. var mouseup = {
  8149. eventInterface: "MouseEvent",
  8150. bubbles: true,
  8151. cancelable: true
  8152. };
  8153. var nomatch = {
  8154. eventInterface: "SpeechRecognitionEvent",
  8155. bubbles: false,
  8156. cancelable: false
  8157. };
  8158. var notificationclick = {
  8159. eventInterface: "NotificationEvent",
  8160. bubbles: false,
  8161. cancelable: false
  8162. };
  8163. var noupdate = {
  8164. eventInterface: "Event",
  8165. bubbles: false,
  8166. cancelable: false
  8167. };
  8168. var obsolete = {
  8169. eventInterface: "Event",
  8170. bubbles: false,
  8171. cancelable: false
  8172. };
  8173. var offline = {
  8174. eventInterface: "Event",
  8175. bubbles: false,
  8176. cancelable: false
  8177. };
  8178. var online = {
  8179. eventInterface: "Event",
  8180. bubbles: false,
  8181. cancelable: false
  8182. };
  8183. var open = {
  8184. eventInterface: "Event",
  8185. bubbles: false,
  8186. cancelable: false
  8187. };
  8188. var orientationchange = {
  8189. eventInterface: "Event",
  8190. bubbles: false,
  8191. cancelable: false
  8192. };
  8193. var pagehide = {
  8194. eventInterface: "PageTransitionEvent",
  8195. bubbles: false,
  8196. cancelable: false
  8197. };
  8198. var pageshow = {
  8199. eventInterface: "PageTransitionEvent",
  8200. bubbles: false,
  8201. cancelable: false
  8202. };
  8203. var paste = {
  8204. eventInterface: "ClipboardEvent",
  8205. bubbles: true,
  8206. cancelable: true
  8207. };
  8208. var pause = {
  8209. eventInterface: "SpeechSynthesisEvent",
  8210. bubbles: false,
  8211. cancelable: false
  8212. };
  8213. var pointercancel = {
  8214. eventInterface: "PointerEvent",
  8215. bubbles: true,
  8216. cancelable: false
  8217. };
  8218. var pointerdown = {
  8219. eventInterface: "PointerEvent",
  8220. bubbles: true,
  8221. cancelable: true
  8222. };
  8223. var pointerenter = {
  8224. eventInterface: "PointerEvent",
  8225. bubbles: false,
  8226. cancelable: false
  8227. };
  8228. var pointerleave = {
  8229. eventInterface: "PointerEvent",
  8230. bubbles: false,
  8231. cancelable: false
  8232. };
  8233. var pointerlockchange = {
  8234. eventInterface: "Event",
  8235. bubbles: true,
  8236. cancelable: false
  8237. };
  8238. var pointerlockerror = {
  8239. eventInterface: "Event",
  8240. bubbles: true,
  8241. cancelable: false
  8242. };
  8243. var pointermove = {
  8244. eventInterface: "PointerEvent",
  8245. bubbles: true,
  8246. cancelable: true
  8247. };
  8248. var pointerout = {
  8249. eventInterface: "PointerEvent",
  8250. bubbles: true,
  8251. cancelable: true
  8252. };
  8253. var pointerover = {
  8254. eventInterface: "PointerEvent",
  8255. bubbles: true,
  8256. cancelable: true
  8257. };
  8258. var pointerup = {
  8259. eventInterface: "PointerEvent",
  8260. bubbles: true,
  8261. cancelable: true
  8262. };
  8263. var play = {
  8264. eventInterface: "Event",
  8265. bubbles: false,
  8266. cancelable: false
  8267. };
  8268. var playing = {
  8269. eventInterface: "Event",
  8270. bubbles: false,
  8271. cancelable: false
  8272. };
  8273. var popstate = {
  8274. eventInterface: "PopStateEvent",
  8275. bubbles: true,
  8276. cancelable: false
  8277. };
  8278. var progress = {
  8279. eventInterface: "ProgressEvent",
  8280. bubbles: false,
  8281. cancelable: false
  8282. };
  8283. var push = {
  8284. eventInterface: "PushEvent",
  8285. bubbles: false,
  8286. cancelable: false
  8287. };
  8288. var pushsubscriptionchange = {
  8289. eventInterface: "PushEvent",
  8290. bubbles: false,
  8291. cancelable: false
  8292. };
  8293. var ratechange = {
  8294. eventInterface: "Event",
  8295. bubbles: false,
  8296. cancelable: false
  8297. };
  8298. var readystatechange = {
  8299. eventInterface: "Event",
  8300. bubbles: false,
  8301. cancelable: false
  8302. };
  8303. var repeatEvent = {
  8304. eventInterface: "TimeEvent",
  8305. bubbles: false,
  8306. cancelable: false
  8307. };
  8308. var reset = {
  8309. eventInterface: "Event",
  8310. bubbles: true,
  8311. cancelable: true
  8312. };
  8313. var resize = {
  8314. eventInterface: "UIEvent",
  8315. bubbles: false,
  8316. cancelable: false
  8317. };
  8318. var resourcetimingbufferfull = {
  8319. eventInterface: "Performance",
  8320. bubbles: true,
  8321. cancelable: true
  8322. };
  8323. var result = {
  8324. eventInterface: "SpeechRecognitionEvent",
  8325. bubbles: false,
  8326. cancelable: false
  8327. };
  8328. var resume = {
  8329. eventInterface: "SpeechSynthesisEvent",
  8330. bubbles: false,
  8331. cancelable: false
  8332. };
  8333. var scroll = {
  8334. eventInterface: "UIEvent",
  8335. bubbles: false,
  8336. cancelable: false
  8337. };
  8338. var seeked = {
  8339. eventInterface: "Event",
  8340. bubbles: false,
  8341. cancelable: false
  8342. };
  8343. var seeking = {
  8344. eventInterface: "Event",
  8345. bubbles: false,
  8346. cancelable: false
  8347. };
  8348. var select = {
  8349. eventInterface: "UIEvent",
  8350. bubbles: true,
  8351. cancelable: false
  8352. };
  8353. var selectstart = {
  8354. eventInterface: "Event",
  8355. bubbles: true,
  8356. cancelable: true
  8357. };
  8358. var selectionchange = {
  8359. eventInterface: "Event",
  8360. bubbles: false,
  8361. cancelable: false
  8362. };
  8363. var show = {
  8364. eventInterface: "MouseEvent",
  8365. bubbles: false,
  8366. cancelable: false
  8367. };
  8368. var slotchange = {
  8369. eventInterface: "Event",
  8370. bubbles: true,
  8371. cancelable: false
  8372. };
  8373. var soundend = {
  8374. eventInterface: "Event",
  8375. bubbles: false,
  8376. cancelable: false
  8377. };
  8378. var soundstart = {
  8379. eventInterface: "Event",
  8380. bubbles: false,
  8381. cancelable: false
  8382. };
  8383. var speechend = {
  8384. eventInterface: "Event",
  8385. bubbles: false,
  8386. cancelable: false
  8387. };
  8388. var speechstart = {
  8389. eventInterface: "Event",
  8390. bubbles: false,
  8391. cancelable: false
  8392. };
  8393. var stalled = {
  8394. eventInterface: "Event",
  8395. bubbles: false,
  8396. cancelable: false
  8397. };
  8398. var start = {
  8399. eventInterface: "SpeechSynthesisEvent",
  8400. bubbles: false,
  8401. cancelable: false
  8402. };
  8403. var storage = {
  8404. eventInterface: "StorageEvent",
  8405. bubbles: false,
  8406. cancelable: false
  8407. };
  8408. var submit = {
  8409. eventInterface: "Event",
  8410. bubbles: true,
  8411. cancelable: true
  8412. };
  8413. var success = {
  8414. eventInterface: "Event",
  8415. bubbles: false,
  8416. cancelable: false
  8417. };
  8418. var suspend = {
  8419. eventInterface: "Event",
  8420. bubbles: false,
  8421. cancelable: false
  8422. };
  8423. var SVGAbort = {
  8424. eventInterface: "SVGEvent",
  8425. bubbles: true,
  8426. cancelable: false
  8427. };
  8428. var SVGError = {
  8429. eventInterface: "SVGEvent",
  8430. bubbles: true,
  8431. cancelable: false
  8432. };
  8433. var SVGLoad = {
  8434. eventInterface: "SVGEvent",
  8435. bubbles: false,
  8436. cancelable: false
  8437. };
  8438. var SVGResize = {
  8439. eventInterface: "SVGEvent",
  8440. bubbles: true,
  8441. cancelable: false
  8442. };
  8443. var SVGScroll = {
  8444. eventInterface: "SVGEvent",
  8445. bubbles: true,
  8446. cancelable: false
  8447. };
  8448. var SVGUnload = {
  8449. eventInterface: "SVGEvent",
  8450. bubbles: false,
  8451. cancelable: false
  8452. };
  8453. var SVGZoom = {
  8454. eventInterface: "SVGZoomEvent",
  8455. bubbles: true,
  8456. cancelable: false
  8457. };
  8458. var timeout = {
  8459. eventInterface: "ProgressEvent",
  8460. bubbles: false,
  8461. cancelable: false
  8462. };
  8463. var timeupdate = {
  8464. eventInterface: "Event",
  8465. bubbles: false,
  8466. cancelable: false
  8467. };
  8468. var touchcancel = {
  8469. eventInterface: "TouchEvent",
  8470. bubbles: true,
  8471. cancelable: false
  8472. };
  8473. var touchend = {
  8474. eventInterface: "TouchEvent",
  8475. bubbles: true,
  8476. cancelable: true
  8477. };
  8478. var touchmove = {
  8479. eventInterface: "TouchEvent",
  8480. bubbles: true,
  8481. cancelable: true
  8482. };
  8483. var touchstart = {
  8484. eventInterface: "TouchEvent",
  8485. bubbles: true,
  8486. cancelable: true
  8487. };
  8488. var transitionend = {
  8489. eventInterface: "TransitionEvent",
  8490. bubbles: true,
  8491. cancelable: true
  8492. };
  8493. var unload = {
  8494. eventInterface: "UIEvent",
  8495. bubbles: false
  8496. };
  8497. var updateready = {
  8498. eventInterface: "Event",
  8499. bubbles: false,
  8500. cancelable: false
  8501. };
  8502. var userproximity = {
  8503. eventInterface: "UserProximityEvent",
  8504. bubbles: false,
  8505. cancelable: false
  8506. };
  8507. var voiceschanged = {
  8508. eventInterface: "Event",
  8509. bubbles: false,
  8510. cancelable: false
  8511. };
  8512. var visibilitychange = {
  8513. eventInterface: "Event",
  8514. bubbles: true,
  8515. cancelable: false
  8516. };
  8517. var volumechange = {
  8518. eventInterface: "Event",
  8519. bubbles: false,
  8520. cancelable: false
  8521. };
  8522. var waiting = {
  8523. eventInterface: "Event",
  8524. bubbles: false,
  8525. cancelable: false
  8526. };
  8527. var wheel = {
  8528. eventInterface: "WheelEvent",
  8529. bubbles: true,
  8530. cancelable: true
  8531. };
  8532. var domEventTypes = {
  8533. abort: abort,
  8534. afterprint: afterprint,
  8535. animationend: animationend,
  8536. animationiteration: animationiteration,
  8537. animationstart: animationstart,
  8538. appinstalled: appinstalled,
  8539. audioprocess: audioprocess,
  8540. audioend: audioend,
  8541. audiostart: audiostart,
  8542. beforeprint: beforeprint,
  8543. beforeunload: beforeunload,
  8544. beginEvent: beginEvent,
  8545. blur: blur,
  8546. boundary: boundary,
  8547. cached: cached,
  8548. canplay: canplay,
  8549. canplaythrough: canplaythrough,
  8550. change: change,
  8551. chargingchange: chargingchange,
  8552. chargingtimechange: chargingtimechange,
  8553. checking: checking,
  8554. click: click,
  8555. close: close,
  8556. complete: complete,
  8557. compositionend: compositionend,
  8558. compositionstart: compositionstart,
  8559. compositionupdate: compositionupdate,
  8560. contextmenu: contextmenu,
  8561. copy: copy,
  8562. cut: cut,
  8563. dblclick: dblclick,
  8564. devicechange: devicechange,
  8565. devicelight: devicelight,
  8566. devicemotion: devicemotion,
  8567. deviceorientation: deviceorientation,
  8568. deviceproximity: deviceproximity,
  8569. dischargingtimechange: dischargingtimechange,
  8570. DOMActivate: DOMActivate,
  8571. DOMAttributeNameChanged: DOMAttributeNameChanged,
  8572. DOMAttrModified: DOMAttrModified,
  8573. DOMCharacterDataModified: DOMCharacterDataModified,
  8574. DOMContentLoaded: DOMContentLoaded,
  8575. DOMElementNameChanged: DOMElementNameChanged,
  8576. DOMFocusIn: DOMFocusIn,
  8577. DOMFocusOut: DOMFocusOut,
  8578. DOMNodeInserted: DOMNodeInserted,
  8579. DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
  8580. DOMNodeRemoved: DOMNodeRemoved,
  8581. DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
  8582. DOMSubtreeModified: DOMSubtreeModified,
  8583. downloading: downloading,
  8584. drag: drag,
  8585. dragend: dragend,
  8586. dragenter: dragenter,
  8587. dragleave: dragleave,
  8588. dragover: dragover,
  8589. dragstart: dragstart,
  8590. drop: drop,
  8591. durationchange: durationchange,
  8592. emptied: emptied,
  8593. end: end,
  8594. ended: ended,
  8595. endEvent: endEvent,
  8596. error: error,
  8597. focus: focus,
  8598. focusin: focusin,
  8599. focusout: focusout,
  8600. fullscreenchange: fullscreenchange,
  8601. fullscreenerror: fullscreenerror,
  8602. gamepadconnected: gamepadconnected,
  8603. gamepaddisconnected: gamepaddisconnected,
  8604. gotpointercapture: gotpointercapture,
  8605. hashchange: hashchange,
  8606. lostpointercapture: lostpointercapture,
  8607. input: input,
  8608. invalid: invalid,
  8609. keydown: keydown,
  8610. keypress: keypress,
  8611. keyup: keyup,
  8612. languagechange: languagechange,
  8613. levelchange: levelchange,
  8614. load: load,
  8615. loadeddata: loadeddata,
  8616. loadedmetadata: loadedmetadata,
  8617. loadend: loadend,
  8618. loadstart: loadstart,
  8619. mark: mark,
  8620. message: message,
  8621. messageerror: messageerror,
  8622. mousedown: mousedown,
  8623. mouseenter: mouseenter,
  8624. mouseleave: mouseleave,
  8625. mousemove: mousemove,
  8626. mouseout: mouseout,
  8627. mouseover: mouseover,
  8628. mouseup: mouseup,
  8629. nomatch: nomatch,
  8630. notificationclick: notificationclick,
  8631. noupdate: noupdate,
  8632. obsolete: obsolete,
  8633. offline: offline,
  8634. online: online,
  8635. open: open,
  8636. orientationchange: orientationchange,
  8637. pagehide: pagehide,
  8638. pageshow: pageshow,
  8639. paste: paste,
  8640. pause: pause,
  8641. pointercancel: pointercancel,
  8642. pointerdown: pointerdown,
  8643. pointerenter: pointerenter,
  8644. pointerleave: pointerleave,
  8645. pointerlockchange: pointerlockchange,
  8646. pointerlockerror: pointerlockerror,
  8647. pointermove: pointermove,
  8648. pointerout: pointerout,
  8649. pointerover: pointerover,
  8650. pointerup: pointerup,
  8651. play: play,
  8652. playing: playing,
  8653. popstate: popstate,
  8654. progress: progress,
  8655. push: push,
  8656. pushsubscriptionchange: pushsubscriptionchange,
  8657. ratechange: ratechange,
  8658. readystatechange: readystatechange,
  8659. repeatEvent: repeatEvent,
  8660. reset: reset,
  8661. resize: resize,
  8662. resourcetimingbufferfull: resourcetimingbufferfull,
  8663. result: result,
  8664. resume: resume,
  8665. scroll: scroll,
  8666. seeked: seeked,
  8667. seeking: seeking,
  8668. select: select,
  8669. selectstart: selectstart,
  8670. selectionchange: selectionchange,
  8671. show: show,
  8672. slotchange: slotchange,
  8673. soundend: soundend,
  8674. soundstart: soundstart,
  8675. speechend: speechend,
  8676. speechstart: speechstart,
  8677. stalled: stalled,
  8678. start: start,
  8679. storage: storage,
  8680. submit: submit,
  8681. success: success,
  8682. suspend: suspend,
  8683. SVGAbort: SVGAbort,
  8684. SVGError: SVGError,
  8685. SVGLoad: SVGLoad,
  8686. SVGResize: SVGResize,
  8687. SVGScroll: SVGScroll,
  8688. SVGUnload: SVGUnload,
  8689. SVGZoom: SVGZoom,
  8690. timeout: timeout,
  8691. timeupdate: timeupdate,
  8692. touchcancel: touchcancel,
  8693. touchend: touchend,
  8694. touchmove: touchmove,
  8695. touchstart: touchstart,
  8696. transitionend: transitionend,
  8697. unload: unload,
  8698. updateready: updateready,
  8699. userproximity: userproximity,
  8700. voiceschanged: voiceschanged,
  8701. visibilitychange: visibilitychange,
  8702. volumechange: volumechange,
  8703. waiting: waiting,
  8704. wheel: wheel
  8705. };
  8706. var domEventTypes$1 = /*#__PURE__*/Object.freeze({
  8707. __proto__: null,
  8708. abort: abort,
  8709. afterprint: afterprint,
  8710. animationend: animationend,
  8711. animationiteration: animationiteration,
  8712. animationstart: animationstart,
  8713. appinstalled: appinstalled,
  8714. audioprocess: audioprocess,
  8715. audioend: audioend,
  8716. audiostart: audiostart,
  8717. beforeprint: beforeprint,
  8718. beforeunload: beforeunload,
  8719. beginEvent: beginEvent,
  8720. blur: blur,
  8721. boundary: boundary,
  8722. cached: cached,
  8723. canplay: canplay,
  8724. canplaythrough: canplaythrough,
  8725. change: change,
  8726. chargingchange: chargingchange,
  8727. chargingtimechange: chargingtimechange,
  8728. checking: checking,
  8729. click: click,
  8730. close: close,
  8731. complete: complete,
  8732. compositionend: compositionend,
  8733. compositionstart: compositionstart,
  8734. compositionupdate: compositionupdate,
  8735. contextmenu: contextmenu,
  8736. copy: copy,
  8737. cut: cut,
  8738. dblclick: dblclick,
  8739. devicechange: devicechange,
  8740. devicelight: devicelight,
  8741. devicemotion: devicemotion,
  8742. deviceorientation: deviceorientation,
  8743. deviceproximity: deviceproximity,
  8744. dischargingtimechange: dischargingtimechange,
  8745. DOMActivate: DOMActivate,
  8746. DOMAttributeNameChanged: DOMAttributeNameChanged,
  8747. DOMAttrModified: DOMAttrModified,
  8748. DOMCharacterDataModified: DOMCharacterDataModified,
  8749. DOMContentLoaded: DOMContentLoaded,
  8750. DOMElementNameChanged: DOMElementNameChanged,
  8751. DOMFocusIn: DOMFocusIn,
  8752. DOMFocusOut: DOMFocusOut,
  8753. DOMNodeInserted: DOMNodeInserted,
  8754. DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
  8755. DOMNodeRemoved: DOMNodeRemoved,
  8756. DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
  8757. DOMSubtreeModified: DOMSubtreeModified,
  8758. downloading: downloading,
  8759. drag: drag,
  8760. dragend: dragend,
  8761. dragenter: dragenter,
  8762. dragleave: dragleave,
  8763. dragover: dragover,
  8764. dragstart: dragstart,
  8765. drop: drop,
  8766. durationchange: durationchange,
  8767. emptied: emptied,
  8768. end: end,
  8769. ended: ended,
  8770. endEvent: endEvent,
  8771. error: error,
  8772. focus: focus,
  8773. focusin: focusin,
  8774. focusout: focusout,
  8775. fullscreenchange: fullscreenchange,
  8776. fullscreenerror: fullscreenerror,
  8777. gamepadconnected: gamepadconnected,
  8778. gamepaddisconnected: gamepaddisconnected,
  8779. gotpointercapture: gotpointercapture,
  8780. hashchange: hashchange,
  8781. lostpointercapture: lostpointercapture,
  8782. input: input,
  8783. invalid: invalid,
  8784. keydown: keydown,
  8785. keypress: keypress,
  8786. keyup: keyup,
  8787. languagechange: languagechange,
  8788. levelchange: levelchange,
  8789. load: load,
  8790. loadeddata: loadeddata,
  8791. loadedmetadata: loadedmetadata,
  8792. loadend: loadend,
  8793. loadstart: loadstart,
  8794. mark: mark,
  8795. message: message,
  8796. messageerror: messageerror,
  8797. mousedown: mousedown,
  8798. mouseenter: mouseenter,
  8799. mouseleave: mouseleave,
  8800. mousemove: mousemove,
  8801. mouseout: mouseout,
  8802. mouseover: mouseover,
  8803. mouseup: mouseup,
  8804. nomatch: nomatch,
  8805. notificationclick: notificationclick,
  8806. noupdate: noupdate,
  8807. obsolete: obsolete,
  8808. offline: offline,
  8809. online: online,
  8810. open: open,
  8811. orientationchange: orientationchange,
  8812. pagehide: pagehide,
  8813. pageshow: pageshow,
  8814. paste: paste,
  8815. pause: pause,
  8816. pointercancel: pointercancel,
  8817. pointerdown: pointerdown,
  8818. pointerenter: pointerenter,
  8819. pointerleave: pointerleave,
  8820. pointerlockchange: pointerlockchange,
  8821. pointerlockerror: pointerlockerror,
  8822. pointermove: pointermove,
  8823. pointerout: pointerout,
  8824. pointerover: pointerover,
  8825. pointerup: pointerup,
  8826. play: play,
  8827. playing: playing,
  8828. popstate: popstate,
  8829. progress: progress,
  8830. push: push,
  8831. pushsubscriptionchange: pushsubscriptionchange,
  8832. ratechange: ratechange,
  8833. readystatechange: readystatechange,
  8834. repeatEvent: repeatEvent,
  8835. reset: reset,
  8836. resize: resize,
  8837. resourcetimingbufferfull: resourcetimingbufferfull,
  8838. result: result,
  8839. resume: resume,
  8840. scroll: scroll,
  8841. seeked: seeked,
  8842. seeking: seeking,
  8843. select: select,
  8844. selectstart: selectstart,
  8845. selectionchange: selectionchange,
  8846. show: show,
  8847. slotchange: slotchange,
  8848. soundend: soundend,
  8849. soundstart: soundstart,
  8850. speechend: speechend,
  8851. speechstart: speechstart,
  8852. stalled: stalled,
  8853. start: start,
  8854. storage: storage,
  8855. submit: submit,
  8856. success: success,
  8857. suspend: suspend,
  8858. SVGAbort: SVGAbort,
  8859. SVGError: SVGError,
  8860. SVGLoad: SVGLoad,
  8861. SVGResize: SVGResize,
  8862. SVGScroll: SVGScroll,
  8863. SVGUnload: SVGUnload,
  8864. SVGZoom: SVGZoom,
  8865. timeout: timeout,
  8866. timeupdate: timeupdate,
  8867. touchcancel: touchcancel,
  8868. touchend: touchend,
  8869. touchmove: touchmove,
  8870. touchstart: touchstart,
  8871. transitionend: transitionend,
  8872. unload: unload,
  8873. updateready: updateready,
  8874. userproximity: userproximity,
  8875. voiceschanged: voiceschanged,
  8876. visibilitychange: visibilitychange,
  8877. volumechange: volumechange,
  8878. waiting: waiting,
  8879. wheel: wheel,
  8880. 'default': domEventTypes
  8881. });
  8882. var require$$0 = getCjsExportFromNamespace(domEventTypes$1);
  8883. var domEventTypes$2 = require$$0;
  8884. var defaultEventType = {
  8885. eventInterface: 'Event',
  8886. cancelable: true,
  8887. bubbles: true
  8888. };
  8889. var modifiers = {
  8890. enter: 13,
  8891. tab: 9,
  8892. delete: 46,
  8893. esc: 27,
  8894. space: 32,
  8895. up: 38,
  8896. down: 40,
  8897. left: 37,
  8898. right: 39,
  8899. end: 35,
  8900. home: 36,
  8901. backspace: 8,
  8902. insert: 45,
  8903. pageup: 33,
  8904. pagedown: 34
  8905. };
  8906. // get from https://github.com/ashubham/w3c-keys/blob/master/index.ts
  8907. var w3cKeys = {
  8908. enter: 'Enter',
  8909. tab: 'Tab',
  8910. delete: 'Delete',
  8911. esc: 'Esc',
  8912. escape: 'Escape',
  8913. space: ' ',
  8914. up: 'Up',
  8915. left: 'Left',
  8916. right: 'Right',
  8917. down: 'Down',
  8918. end: 'End',
  8919. home: 'Home',
  8920. backspace: 'Backspace',
  8921. insert: 'Insert',
  8922. pageup: 'PageUp',
  8923. pagedown: 'PageDown'
  8924. };
  8925. var codeToKeyNameMap = Object.entries(modifiers).reduce(
  8926. function (acc, ref) {
  8927. var obj;
  8928. var key = ref[0];
  8929. var value = ref[1];
  8930. return Object.assign(acc, ( obj = {}, obj[value] = w3cKeys[key], obj ));
  8931. },
  8932. {}
  8933. );
  8934. function getOptions(eventParams) {
  8935. var modifier = eventParams.modifier;
  8936. var meta = eventParams.meta;
  8937. var options = eventParams.options;
  8938. var keyCode = modifiers[modifier] || options.keyCode || options.code;
  8939. var key = codeToKeyNameMap[keyCode];
  8940. return Object.assign({}, options, // What the user passed in as the second argument to #trigger
  8941. {bubbles: meta.bubbles,
  8942. cancelable: meta.cancelable,
  8943. // Any derived options should go here
  8944. keyCode: keyCode,
  8945. code: keyCode,
  8946. key: key || options.key})
  8947. }
  8948. function createEvent(eventParams) {
  8949. var eventType = eventParams.eventType;
  8950. var meta = eventParams.meta; if ( meta === void 0 ) meta = {};
  8951. var SupportedEventInterface =
  8952. typeof window[meta.eventInterface] === 'function'
  8953. ? window[meta.eventInterface]
  8954. : window.Event;
  8955. var event = new SupportedEventInterface(
  8956. eventType,
  8957. // event properties can only be added when the event is instantiated
  8958. // custom properties must be added after the event has been instantiated
  8959. getOptions(eventParams)
  8960. );
  8961. return event
  8962. }
  8963. function createOldEvent(eventParams) {
  8964. var eventType = eventParams.eventType;
  8965. var modifier = eventParams.modifier;
  8966. var meta = eventParams.meta;
  8967. var bubbles = meta.bubbles;
  8968. var cancelable = meta.cancelable;
  8969. var event = document.createEvent('Event');
  8970. event.initEvent(eventType, bubbles, cancelable);
  8971. event.keyCode = modifiers[modifier];
  8972. return event
  8973. }
  8974. function createDOMEvent(type, options) {
  8975. var ref = type.split('.');
  8976. var eventType = ref[0];
  8977. var modifier = ref[1];
  8978. var meta = domEventTypes$2[eventType] || defaultEventType;
  8979. var eventParams = { eventType: eventType, modifier: modifier, meta: meta, options: options };
  8980. // Fallback for IE10,11 - https://stackoverflow.com/questions/26596123
  8981. var event =
  8982. typeof window.Event === 'function'
  8983. ? createEvent(eventParams)
  8984. : createOldEvent(eventParams);
  8985. var eventPrototype = Object.getPrototypeOf(event);
  8986. Object.keys(options || {}).forEach(function (key) {
  8987. var propertyDescriptor = Object.getOwnPropertyDescriptor(
  8988. eventPrototype,
  8989. key
  8990. );
  8991. var canSetProperty = !(
  8992. propertyDescriptor && propertyDescriptor.setter === undefined
  8993. );
  8994. if (canSetProperty) {
  8995. event[key] = options[key];
  8996. }
  8997. });
  8998. return event
  8999. }
  9000. //
  9001. var Wrapper = function Wrapper(
  9002. node,
  9003. options,
  9004. isVueWrapper
  9005. ) {
  9006. var vnode = node instanceof Element ? null : node;
  9007. var element = node instanceof Element ? node : node.elm;
  9008. // Prevent redefine by VueWrapper
  9009. if (!isVueWrapper) {
  9010. // $FlowIgnore : issue with defineProperty
  9011. Object.defineProperty(this, 'rootNode', {
  9012. get: function () { return vnode || element; },
  9013. set: function () { return throwError('wrapper.rootNode is read-only'); }
  9014. });
  9015. // $FlowIgnore
  9016. Object.defineProperty(this, 'vnode', {
  9017. get: function () { return vnode; },
  9018. set: function () { return throwError('wrapper.vnode is read-only'); }
  9019. });
  9020. // $FlowIgnore
  9021. Object.defineProperty(this, 'element', {
  9022. get: function () { return element; },
  9023. set: function () { return throwError('wrapper.element is read-only'); }
  9024. });
  9025. // $FlowIgnore
  9026. Object.defineProperty(this, 'vm', {
  9027. get: function () { return undefined; },
  9028. set: function () { return throwError('wrapper.vm is read-only'); }
  9029. });
  9030. }
  9031. var frozenOptions = Object.freeze(options);
  9032. // $FlowIgnore
  9033. Object.defineProperty(this, 'options', {
  9034. get: function () { return frozenOptions; },
  9035. set: function () { return throwError('wrapper.options is read-only'); }
  9036. });
  9037. if (
  9038. this.vnode &&
  9039. (this.vnode[FUNCTIONAL_OPTIONS] || this.vnode.functionalContext)
  9040. ) {
  9041. this.isFunctionalComponent = true;
  9042. }
  9043. };
  9044. /**
  9045. * Prints warning if component is destroyed
  9046. */
  9047. Wrapper.prototype.__warnIfDestroyed = function __warnIfDestroyed () {
  9048. if (!this.exists()) {
  9049. warn('Operations on destroyed component are discouraged');
  9050. }
  9051. };
  9052. Wrapper.prototype.at = function at () {
  9053. this.__warnIfDestroyed();
  9054. throwError('at() must be called on a WrapperArray');
  9055. };
  9056. /**
  9057. * Returns an Object containing all the attribute/value pairs on the element.
  9058. */
  9059. Wrapper.prototype.attributes = function attributes (key) {
  9060. this.__warnIfDestroyed();
  9061. var attributes = this.element.attributes;
  9062. var attributeMap = {};
  9063. for (var i = 0; i < attributes.length; i++) {
  9064. var att = attributes.item(i);
  9065. attributeMap[att.localName] = att.value;
  9066. }
  9067. return key ? attributeMap[key] : attributeMap
  9068. };
  9069. /**
  9070. * Returns an Array containing all the classes on the element
  9071. */
  9072. Wrapper.prototype.classes = function classes (className) {
  9073. var this$1 = this;
  9074. this.__warnIfDestroyed();
  9075. var classAttribute = this.element.getAttribute('class');
  9076. var classes = classAttribute ? classAttribute.split(' ') : [];
  9077. // Handle converting cssmodules identifiers back to the original class name
  9078. if (this.vm && this.vm.$style) {
  9079. var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
  9080. function (acc, key) {
  9081. // $FlowIgnore
  9082. var moduleIdent = this$1.vm.$style[key];
  9083. if (moduleIdent) {
  9084. acc[moduleIdent.split(' ')[0]] = key;
  9085. }
  9086. return acc
  9087. },
  9088. {}
  9089. );
  9090. classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
  9091. }
  9092. return className ? !!(classes.indexOf(className) > -1) : classes
  9093. };
  9094. /**
  9095. * Checks if wrapper contains provided selector.
  9096. * @deprecated
  9097. */
  9098. Wrapper.prototype.contains = function contains (rawSelector) {
  9099. warnDeprecated(
  9100. 'contains',
  9101. 'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
  9102. );
  9103. this.__warnIfDestroyed();
  9104. var selector = getSelector(rawSelector, 'contains');
  9105. var nodes = find(this.rootNode, this.vm, selector);
  9106. return nodes.length > 0
  9107. };
  9108. /**
  9109. * Calls destroy on vm
  9110. */
  9111. Wrapper.prototype.destroy = function destroy () {
  9112. if (!this.vm && !this.isFunctionalComponent) {
  9113. throwError(
  9114. "wrapper.destroy() can only be called on a Vue instance or " +
  9115. "functional component."
  9116. );
  9117. }
  9118. if (this.element.parentNode) {
  9119. this.element.parentNode.removeChild(this.element);
  9120. }
  9121. if (this.vm) {
  9122. // $FlowIgnore
  9123. this.vm.$destroy();
  9124. throwIfInstancesThrew(this.vm);
  9125. }
  9126. };
  9127. /**
  9128. * Returns an object containing custom events emitted by the Wrapper vm
  9129. */
  9130. Wrapper.prototype.emitted = function emitted (
  9131. event
  9132. ) {
  9133. if (!this._emitted && !this.vm) {
  9134. throwError("wrapper.emitted() can only be called on a Vue instance");
  9135. }
  9136. if (event) {
  9137. return this._emitted[event]
  9138. }
  9139. return this._emitted
  9140. };
  9141. /**
  9142. * Returns an Array containing custom events emitted by the Wrapper vm
  9143. * @deprecated
  9144. */
  9145. Wrapper.prototype.emittedByOrder = function emittedByOrder () {
  9146. warnDeprecated('emittedByOrder', 'Use `wrapper.emitted` instead');
  9147. if (!this._emittedByOrder && !this.vm) {
  9148. throwError(
  9149. "wrapper.emittedByOrder() can only be called on a Vue instance"
  9150. );
  9151. }
  9152. return this._emittedByOrder
  9153. };
  9154. /**
  9155. * Utility to check wrapper exists.
  9156. */
  9157. Wrapper.prototype.exists = function exists () {
  9158. if (this.vm) {
  9159. return !!this.vm && !this.vm._isDestroyed
  9160. }
  9161. return true
  9162. };
  9163. Wrapper.prototype.filter = function filter () {
  9164. throwError('filter() must be called on a WrapperArray');
  9165. };
  9166. /**
  9167. * Gets first node in tree of the current wrapper that
  9168. * matches the provided selector.
  9169. */
  9170. Wrapper.prototype.get = function get (rawSelector) {
  9171. this.__warnIfDestroyed();
  9172. var found = this.find(rawSelector);
  9173. if (found instanceof ErrorWrapper) {
  9174. throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
  9175. }
  9176. return found
  9177. };
  9178. /**
  9179. * Gets first node in tree of the current wrapper that
  9180. * matches the provided selector.
  9181. */
  9182. Wrapper.prototype.getComponent = function getComponent (rawSelector) {
  9183. this.__warnIfDestroyed();
  9184. var found = this.findComponent(rawSelector);
  9185. if (found instanceof ErrorWrapper) {
  9186. throw new Error(("Unable to get " + rawSelector + " within: " + (this.html())))
  9187. }
  9188. return found
  9189. };
  9190. /**
  9191. * Finds first DOM node in tree of the current wrapper that
  9192. * matches the provided selector.
  9193. */
  9194. Wrapper.prototype.find = function find (rawSelector) {
  9195. this.__warnIfDestroyed();
  9196. var selector = getSelector(rawSelector, 'find');
  9197. if (selector.type !== DOM_SELECTOR) {
  9198. warnDeprecated(
  9199. 'finding components with `find` or `get`',
  9200. 'Use `findComponent` and `getComponent` instead'
  9201. );
  9202. }
  9203. return this.__find(rawSelector, selector)
  9204. };
  9205. /**
  9206. * Finds first component in tree of the current wrapper that
  9207. * matches the provided selector.
  9208. */
  9209. Wrapper.prototype.findComponent = function findComponent (rawSelector) {
  9210. this.__warnIfDestroyed();
  9211. var selector = getSelector(rawSelector, 'findComponent');
  9212. return this.__find(rawSelector, selector)
  9213. };
  9214. Wrapper.prototype.__find = function __find (rawSelector, selector) {
  9215. var node = find(this.rootNode, this.vm, selector)[0];
  9216. if (!node) {
  9217. return new ErrorWrapper(rawSelector)
  9218. }
  9219. var wrapper = createWrapper(node, this.options);
  9220. wrapper.selector = rawSelector;
  9221. return wrapper
  9222. };
  9223. /**
  9224. * Finds DOM elements in tree of the current wrapper that matches
  9225. * the provided selector.
  9226. */
  9227. Wrapper.prototype.findAll = function findAll (rawSelector) {
  9228. this.__warnIfDestroyed();
  9229. var selector = getSelector(rawSelector, 'findAll');
  9230. if (selector.type !== DOM_SELECTOR) {
  9231. warnDeprecated(
  9232. 'finding components with `findAll`',
  9233. 'Use `findAllComponents` instead'
  9234. );
  9235. }
  9236. return this.__findAll(rawSelector, selector)
  9237. };
  9238. /**
  9239. * Finds components in tree of the current wrapper that matches
  9240. * the provided selector.
  9241. */
  9242. Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
  9243. this.__warnIfDestroyed();
  9244. var selector = getSelector(rawSelector, 'findAll');
  9245. return this.__findAll(rawSelector, selector, isVueWrapper)
  9246. };
  9247. Wrapper.prototype.__findAll = function __findAll (
  9248. rawSelector,
  9249. selector,
  9250. filterFn
  9251. ) {
  9252. var this$1 = this;
  9253. if ( filterFn === void 0 ) filterFn = function () { return true; };
  9254. var nodes = find(this.rootNode, this.vm, selector);
  9255. var wrappers = nodes
  9256. .map(function (node) {
  9257. // Using CSS Selector, returns a VueWrapper instance if the root element
  9258. // binds a Vue instance.
  9259. var wrapper = createWrapper(node, this$1.options);
  9260. wrapper.selector = rawSelector;
  9261. return wrapper
  9262. })
  9263. .filter(filterFn);
  9264. var wrapperArray = new WrapperArray(wrappers);
  9265. wrapperArray.selector = rawSelector;
  9266. return wrapperArray
  9267. };
  9268. /**
  9269. * Returns HTML of element as a string
  9270. */
  9271. Wrapper.prototype.html = function html () {
  9272. this.__warnIfDestroyed();
  9273. return pretty(this.element.outerHTML)
  9274. };
  9275. /**
  9276. * Checks if node matches selector or component definition
  9277. */
  9278. Wrapper.prototype.is = function is (rawSelector) {
  9279. this.__warnIfDestroyed();
  9280. var selector = getSelector(rawSelector, 'is');
  9281. if (selector.type === DOM_SELECTOR) {
  9282. warnDeprecated(
  9283. 'checking tag name with `is`',
  9284. 'Use `element.tagName` instead'
  9285. );
  9286. }
  9287. if (selector.type === REF_SELECTOR) {
  9288. throwError('$ref selectors can not be used with wrapper.is()');
  9289. }
  9290. return matches(this.rootNode, selector)
  9291. };
  9292. /**
  9293. * Checks if node is empty
  9294. * @deprecated
  9295. */
  9296. Wrapper.prototype.isEmpty = function isEmpty () {
  9297. warnDeprecated(
  9298. 'isEmpty',
  9299. 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
  9300. 'When using with findComponent, access the DOM element with findComponent(Comp).element'
  9301. );
  9302. this.__warnIfDestroyed();
  9303. if (!this.vnode) {
  9304. return this.element.innerHTML === ''
  9305. }
  9306. var nodes = [];
  9307. var node = this.vnode;
  9308. var i = 0;
  9309. while (node) {
  9310. if (node.child) {
  9311. nodes.push(node.child._vnode);
  9312. }
  9313. node.children &&
  9314. node.children.forEach(function (n) {
  9315. nodes.push(n);
  9316. });
  9317. node = nodes[i++];
  9318. }
  9319. return nodes.every(function (n) { return n.isComment || n.child; })
  9320. };
  9321. /**
  9322. * Checks if node is visible
  9323. */
  9324. Wrapper.prototype.isVisible = function isVisible () {
  9325. this.__warnIfDestroyed();
  9326. return isElementVisible(this.element)
  9327. };
  9328. /**
  9329. * Checks if wrapper is a vue instance
  9330. * @deprecated
  9331. */
  9332. Wrapper.prototype.isVueInstance = function isVueInstance () {
  9333. warnDeprecated("isVueInstance");
  9334. this.__warnIfDestroyed();
  9335. return !!this.vm
  9336. };
  9337. /**
  9338. * Returns name of component, or tag name if node is not a Vue component
  9339. * @deprecated
  9340. */
  9341. Wrapper.prototype.name = function name () {
  9342. warnDeprecated("name");
  9343. this.__warnIfDestroyed();
  9344. if (this.vm) {
  9345. return (
  9346. this.vm.$options.name ||
  9347. // compat for Vue < 2.3
  9348. (this.vm.$options.extendOptions && this.vm.$options.extendOptions.name)
  9349. )
  9350. }
  9351. if (!this.vnode) {
  9352. return this.element.tagName
  9353. }
  9354. return this.vnode.tag
  9355. };
  9356. /**
  9357. * Prints a simple overview of the wrapper current state
  9358. * with useful information for debugging
  9359. * @deprecated
  9360. */
  9361. Wrapper.prototype.overview = function overview () {
  9362. var this$1 = this;
  9363. warnDeprecated("overview");
  9364. this.__warnIfDestroyed();
  9365. if (!this.vm) {
  9366. throwError("wrapper.overview() can only be called on a Vue instance");
  9367. }
  9368. var identation = 4;
  9369. var formatJSON = function (json, replacer) {
  9370. if ( replacer === void 0 ) replacer = null;
  9371. return JSON.stringify(json, replacer, identation).replace(/"/g, '');
  9372. };
  9373. var visibility = this.isVisible() ? 'Visible' : 'Not visible';
  9374. var html = this.html()
  9375. ? this.html().replace(/^(?!\s*$)/gm, ' '.repeat(identation)) + '\n'
  9376. : '';
  9377. // $FlowIgnore
  9378. var data = formatJSON(this.vm.$data);
  9379. /* eslint-disable operator-linebreak */
  9380. // $FlowIgnore
  9381. var computed = this.vm._computedWatchers
  9382. ? formatJSON.apply(
  9383. // $FlowIgnore
  9384. void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
  9385. var obj;
  9386. return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
  9387. })
  9388. )
  9389. : // $FlowIgnore
  9390. this.vm.$options.computed
  9391. ? formatJSON.apply(
  9392. // $FlowIgnore
  9393. void 0, Object.entries(this.vm.$options.computed).map(function (ref) {
  9394. var obj;
  9395. var key = ref[0];
  9396. var value = ref[1];
  9397. return (( obj = {}, obj[key] = value(), obj ));
  9398. })
  9399. )
  9400. : '{}';
  9401. /* eslint-enable operator-linebreak */
  9402. var emittedJSONReplacer = function (key, value) { return value instanceof Array
  9403. ? value.map(function (calledWith, index) {
  9404. var callParams = calledWith.map(function (param) { return typeof param === 'object'
  9405. ? JSON.stringify(param)
  9406. .replace(/"/g, '')
  9407. .replace(/,/g, ', ')
  9408. : param; }
  9409. );
  9410. return (index + ": [ " + (callParams.join(', ')) + " ]")
  9411. })
  9412. : value; };
  9413. var emitted = formatJSON(this.emitted(), emittedJSONReplacer);
  9414. console.log(
  9415. '\n' +
  9416. "Wrapper (" + visibility + "):\n\n" +
  9417. "Html:\n" + html + "\n" +
  9418. "Data: " + data + "\n\n" +
  9419. "Computed: " + computed + "\n\n" +
  9420. "Emitted: " + emitted + "\n"
  9421. );
  9422. };
  9423. /**
  9424. * Returns an Object containing the prop name/value pairs on the element
  9425. */
  9426. Wrapper.prototype.props = function props (key) {
  9427. var this$1 = this;
  9428. if (this.isFunctionalComponent) {
  9429. throwError(
  9430. "wrapper.props() cannot be called on a mounted functional component."
  9431. );
  9432. }
  9433. if (!this.vm) {
  9434. throwError('wrapper.props() must be called on a Vue instance');
  9435. }
  9436. this.__warnIfDestroyed();
  9437. var props = {};
  9438. var keys = this.vm && this.vm.$options._propKeys;
  9439. if (keys) {
  9440. (keys || {}).forEach(function (key) {
  9441. if (this$1.vm) {
  9442. props[key] = this$1.vm[key];
  9443. }
  9444. });
  9445. }
  9446. if (key) {
  9447. return props[key]
  9448. }
  9449. return props
  9450. };
  9451. /**
  9452. * Checks radio button or checkbox element
  9453. * @deprecated
  9454. */
  9455. Wrapper.prototype.setChecked = function setChecked (checked) {
  9456. if ( checked === void 0 ) checked = true;
  9457. this.__warnIfDestroyed();
  9458. if (typeof checked !== 'boolean') {
  9459. throwError('wrapper.setChecked() must be passed a boolean');
  9460. }
  9461. var tagName = this.element.tagName;
  9462. // $FlowIgnore
  9463. var type = this.attributes().type;
  9464. var event = getCheckedEvent();
  9465. if (tagName === 'INPUT' && type === 'checkbox') {
  9466. // $FlowIgnore
  9467. if (this.element.checked === checked) {
  9468. return nextTick()
  9469. }
  9470. if (event !== 'click' || isPhantomJS) {
  9471. // $FlowIgnore
  9472. this.element.checked = checked;
  9473. }
  9474. return this.trigger(event)
  9475. }
  9476. if (tagName === 'INPUT' && type === 'radio') {
  9477. if (!checked) {
  9478. throwError(
  9479. "wrapper.setChecked() cannot be called with parameter false on a " +
  9480. "<input type=\"radio\" /> element."
  9481. );
  9482. }
  9483. // $FlowIgnore
  9484. if (this.element.checked === checked) {
  9485. return nextTick()
  9486. }
  9487. if (event !== 'click' || isPhantomJS) {
  9488. // $FlowIgnore
  9489. this.element.selected = true;
  9490. }
  9491. return this.trigger(event)
  9492. }
  9493. throwError("wrapper.setChecked() cannot be called on this element");
  9494. return nextTick()
  9495. };
  9496. /**
  9497. * Selects <option></option> element
  9498. * @deprecated
  9499. */
  9500. Wrapper.prototype.setSelected = function setSelected () {
  9501. this.__warnIfDestroyed();
  9502. var tagName = this.element.tagName;
  9503. if (tagName === 'SELECT') {
  9504. throwError(
  9505. "wrapper.setSelected() cannot be called on select. Call it on one of " +
  9506. "its options"
  9507. );
  9508. }
  9509. if (tagName !== 'OPTION') {
  9510. throwError("wrapper.setSelected() cannot be called on this element");
  9511. }
  9512. // $FlowIgnore
  9513. if (this.element.selected) {
  9514. return nextTick()
  9515. }
  9516. // $FlowIgnore
  9517. this.element.selected = true;
  9518. // $FlowIgnore
  9519. var parentElement = this.element.parentElement;
  9520. // $FlowIgnore
  9521. if (parentElement.tagName === 'OPTGROUP') {
  9522. // $FlowIgnore
  9523. parentElement = parentElement.parentElement;
  9524. }
  9525. // $FlowIgnore
  9526. return createWrapper(parentElement, this.options).trigger('change')
  9527. };
  9528. /**
  9529. * Sets vm data
  9530. */
  9531. Wrapper.prototype.setData = function setData (data) {
  9532. if (this.isFunctionalComponent) {
  9533. throwError("wrapper.setData() cannot be called on a functional component");
  9534. }
  9535. if (!this.vm) {
  9536. throwError("wrapper.setData() can only be called on a Vue instance");
  9537. }
  9538. this.__warnIfDestroyed();
  9539. recursivelySetData(this.vm, this.vm, data);
  9540. return nextTick()
  9541. };
  9542. /**
  9543. * Sets vm methods
  9544. * @deprecated
  9545. */
  9546. Wrapper.prototype.setMethods = function setMethods (methods) {
  9547. var this$1 = this;
  9548. warnDeprecated(
  9549. "setMethods",
  9550. "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"
  9551. );
  9552. if (!this.vm) {
  9553. throwError("wrapper.setMethods() can only be called on a Vue instance");
  9554. }
  9555. this.__warnIfDestroyed();
  9556. Object.keys(methods).forEach(function (key) {
  9557. // $FlowIgnore : Problem with possibly null this.vm
  9558. this$1.vm[key] = methods[key];
  9559. // $FlowIgnore : Problem with possibly null this.vm
  9560. this$1.vm.$options.methods[key] = methods[key];
  9561. });
  9562. if (this.vnode) {
  9563. var context = this.vnode.context;
  9564. if (context.$options.render) { context._update(context._render()); }
  9565. }
  9566. };
  9567. /**
  9568. * Sets vm props
  9569. */
  9570. Wrapper.prototype.setProps = function setProps (data) {
  9571. var this$1 = this;
  9572. // Validate the setProps method call
  9573. if (this.isFunctionalComponent) {
  9574. throwError(
  9575. "wrapper.setProps() cannot be called on a functional component"
  9576. );
  9577. }
  9578. if (!this.vm) {
  9579. throwError("wrapper.setProps() can only be called on a Vue instance");
  9580. }
  9581. // $FlowIgnore : Problem with possibly null this.vm
  9582. if (!this.vm.$parent.$options.$_isWrapperParent) {
  9583. throwError(
  9584. "wrapper.setProps() can only be called for top-level component"
  9585. );
  9586. }
  9587. this.__warnIfDestroyed();
  9588. Object.keys(data).forEach(function (key) {
  9589. // Don't let people set entire objects, because reactivity won't work
  9590. if (
  9591. typeof data[key] === 'object' &&
  9592. data[key] !== null &&
  9593. // $FlowIgnore : Problem with possibly null this.vm
  9594. data[key] === this$1.vm[key]
  9595. ) {
  9596. throwError(
  9597. "wrapper.setProps() called with the same object of the existing " +
  9598. key + " property. You must call wrapper.setProps() with a new " +
  9599. "object to trigger reactivity"
  9600. );
  9601. }
  9602. if (
  9603. VUE_VERSION <= 2.3 &&
  9604. (!this$1.vm ||
  9605. !this$1.vm.$options._propKeys ||
  9606. !this$1.vm.$options._propKeys.some(function (prop) { return prop === key; }))
  9607. ) {
  9608. throwError(
  9609. "wrapper.setProps() called with " + key + " property which " +
  9610. "is not defined on the component"
  9611. );
  9612. }
  9613. // $FlowIgnore : Problem with possibly null this.vm
  9614. var parent = this$1.vm.$parent;
  9615. parent.$set(parent.vueTestUtils_childProps, key, data[key]);
  9616. });
  9617. return nextTick()
  9618. };
  9619. /**
  9620. * Sets element value and triggers input event
  9621. */
  9622. Wrapper.prototype.setValue = function setValue (value) {
  9623. var tagName = this.element.tagName;
  9624. // $FlowIgnore
  9625. var type = this.attributes().type;
  9626. this.__warnIfDestroyed();
  9627. if (tagName === 'OPTION') {
  9628. throwError(
  9629. "wrapper.setValue() cannot be called on an <option> element. Use " +
  9630. "wrapper.setSelected() instead"
  9631. );
  9632. } else if (tagName === 'INPUT' && type === 'checkbox') {
  9633. throwError(
  9634. "wrapper.setValue() cannot be called on a <input type=\"checkbox\" /> " +
  9635. "element. Use wrapper.setChecked() instead"
  9636. );
  9637. } else if (tagName === 'INPUT' && type === 'radio') {
  9638. throwError(
  9639. "wrapper.setValue() cannot be called on a <input type=\"radio\" /> " +
  9640. "element. Use wrapper.setChecked() instead"
  9641. );
  9642. } else if (tagName === 'SELECT') {
  9643. if (Array.isArray(value)) {
  9644. // $FlowIgnore
  9645. var options = this.element.options;
  9646. for (var i = 0; i < options.length; i++) {
  9647. var option = options[i];
  9648. option.selected = value.indexOf(option.value) >= 0;
  9649. }
  9650. } else {
  9651. // $FlowIgnore
  9652. this.element.value = value;
  9653. }
  9654. this.trigger('change');
  9655. return nextTick()
  9656. } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
  9657. // $FlowIgnore
  9658. this.element.value = value;
  9659. this.trigger('input');
  9660. // for v-model.lazy, we need to trigger a change event, too.
  9661. // $FlowIgnore
  9662. if (this.element._vModifiers && this.element._vModifiers.lazy) {
  9663. this.trigger('change');
  9664. }
  9665. return nextTick()
  9666. }
  9667. throwError("wrapper.setValue() cannot be called on this element");
  9668. return nextTick()
  9669. };
  9670. /**
  9671. * Return text of wrapper element
  9672. */
  9673. Wrapper.prototype.text = function text () {
  9674. this.__warnIfDestroyed();
  9675. return this.element.textContent.trim()
  9676. };
  9677. /**
  9678. * Simulates event triggering
  9679. */
  9680. Wrapper.prototype.__simulateTrigger = function __simulateTrigger (type, options) {
  9681. var this$1 = this;
  9682. var regularEventTrigger = function (type, options) {
  9683. var event = createDOMEvent(type, options);
  9684. return this$1.element.dispatchEvent(event)
  9685. };
  9686. var focusEventTrigger = function (type, options) {
  9687. if (this$1.element instanceof HTMLElement) {
  9688. return this$1.element.focus()
  9689. }
  9690. regularEventTrigger(type, options);
  9691. };
  9692. var triggerProcedureMap = {
  9693. focus: focusEventTrigger,
  9694. __default: regularEventTrigger
  9695. };
  9696. var triggerFn = triggerProcedureMap[type] || triggerProcedureMap.__default;
  9697. return triggerFn(type, options)
  9698. };
  9699. /**
  9700. * Dispatches a DOM event on wrapper
  9701. */
  9702. Wrapper.prototype.trigger = function trigger (type, options) {
  9703. if ( options === void 0 ) options = {};
  9704. this.__warnIfDestroyed();
  9705. if (typeof type !== 'string') {
  9706. throwError('wrapper.trigger() must be passed a string');
  9707. }
  9708. if (options.target) {
  9709. throwError(
  9710. "you cannot set the target value of an event. See the notes section " +
  9711. "of the docs for more details—" +
  9712. "https://vue-test-utils.vuejs.org/api/wrapper/trigger.html"
  9713. );
  9714. }
  9715. /**
  9716. * Avoids firing events on specific disabled elements
  9717. * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
  9718. */
  9719. var supportedTags = [
  9720. 'BUTTON',
  9721. 'COMMAND',
  9722. 'FIELDSET',
  9723. 'KEYGEN',
  9724. 'OPTGROUP',
  9725. 'OPTION',
  9726. 'SELECT',
  9727. 'TEXTAREA',
  9728. 'INPUT'
  9729. ];
  9730. var tagName = this.element.tagName;
  9731. if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
  9732. return nextTick()
  9733. }
  9734. this.__simulateTrigger(type, options);
  9735. return nextTick()
  9736. };
  9737. //
  9738. var VueWrapper = /*@__PURE__*/(function (Wrapper) {
  9739. function VueWrapper(vm, options) {
  9740. var this$1 = this;
  9741. Wrapper.call(this, vm._vnode, options, true);
  9742. // $FlowIgnore : issue with defineProperty
  9743. Object.defineProperty(this, 'rootNode', {
  9744. get: function () { return vm.$vnode || { child: this$1.vm }; },
  9745. set: function () { return throwError('wrapper.vnode is read-only'); }
  9746. });
  9747. // $FlowIgnore : issue with defineProperty
  9748. Object.defineProperty(this, 'vnode', {
  9749. get: function () { return vm._vnode; },
  9750. set: function () { return throwError('wrapper.vnode is read-only'); }
  9751. });
  9752. // $FlowIgnore
  9753. Object.defineProperty(this, 'element', {
  9754. get: function () { return vm.$el; },
  9755. set: function () { return throwError('wrapper.element is read-only'); }
  9756. });
  9757. // $FlowIgnore
  9758. Object.defineProperty(this, 'vm', {
  9759. get: function () { return vm; },
  9760. set: function () { return throwError('wrapper.vm is read-only'); }
  9761. });
  9762. this.isFunctionalComponent = vm.$options._isFunctionalContainer;
  9763. this._emitted = vm.__emitted;
  9764. this._emittedByOrder = vm.__emittedByOrder;
  9765. }
  9766. if ( Wrapper ) VueWrapper.__proto__ = Wrapper;
  9767. VueWrapper.prototype = Object.create( Wrapper && Wrapper.prototype );
  9768. VueWrapper.prototype.constructor = VueWrapper;
  9769. return VueWrapper;
  9770. }(Wrapper));
  9771. //
  9772. var isEnabled = false;
  9773. var wrapperInstances = [];
  9774. function resetAutoDestroyState() {
  9775. isEnabled = false;
  9776. wrapperInstances.length = 0;
  9777. }
  9778. function enableAutoDestroy(hook) {
  9779. if (isEnabled) {
  9780. throwError('enableAutoDestroy cannot be called more than once');
  9781. }
  9782. isEnabled = true;
  9783. hook(function () {
  9784. wrapperInstances.forEach(function (wrapper) {
  9785. // skip child wrappers created by wrapper.find()
  9786. if (wrapper.vm || wrapper.isFunctionalComponent) {
  9787. wrapper.destroy();
  9788. }
  9789. });
  9790. wrapperInstances.length = 0;
  9791. });
  9792. }
  9793. function trackInstance(wrapper) {
  9794. if (!isEnabled) { return }
  9795. wrapperInstances.push(wrapper);
  9796. }
  9797. //
  9798. function createWrapper(
  9799. node,
  9800. options
  9801. ) {
  9802. if ( options === void 0 ) options = {};
  9803. var componentInstance = node.child;
  9804. if (componentInstance) {
  9805. var wrapper$1 = new VueWrapper(componentInstance, options);
  9806. trackInstance(wrapper$1);
  9807. return wrapper$1
  9808. }
  9809. var wrapper =
  9810. node instanceof Vue__default['default']
  9811. ? new VueWrapper(node, options)
  9812. : new Wrapper(node, options);
  9813. trackInstance(wrapper);
  9814. return wrapper
  9815. }
  9816. /**
  9817. * Removes all key-value entries from the list cache.
  9818. *
  9819. * @private
  9820. * @name clear
  9821. * @memberOf ListCache
  9822. */
  9823. function listCacheClear() {
  9824. this.__data__ = [];
  9825. this.size = 0;
  9826. }
  9827. var _listCacheClear = listCacheClear;
  9828. /**
  9829. * Performs a
  9830. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9831. * comparison between two values to determine if they are equivalent.
  9832. *
  9833. * @static
  9834. * @memberOf _
  9835. * @since 4.0.0
  9836. * @category Lang
  9837. * @param {*} value The value to compare.
  9838. * @param {*} other The other value to compare.
  9839. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  9840. * @example
  9841. *
  9842. * var object = { 'a': 1 };
  9843. * var other = { 'a': 1 };
  9844. *
  9845. * _.eq(object, object);
  9846. * // => true
  9847. *
  9848. * _.eq(object, other);
  9849. * // => false
  9850. *
  9851. * _.eq('a', 'a');
  9852. * // => true
  9853. *
  9854. * _.eq('a', Object('a'));
  9855. * // => false
  9856. *
  9857. * _.eq(NaN, NaN);
  9858. * // => true
  9859. */
  9860. function eq(value, other) {
  9861. return value === other || (value !== value && other !== other);
  9862. }
  9863. var eq_1 = eq;
  9864. /**
  9865. * Gets the index at which the `key` is found in `array` of key-value pairs.
  9866. *
  9867. * @private
  9868. * @param {Array} array The array to inspect.
  9869. * @param {*} key The key to search for.
  9870. * @returns {number} Returns the index of the matched value, else `-1`.
  9871. */
  9872. function assocIndexOf(array, key) {
  9873. var length = array.length;
  9874. while (length--) {
  9875. if (eq_1(array[length][0], key)) {
  9876. return length;
  9877. }
  9878. }
  9879. return -1;
  9880. }
  9881. var _assocIndexOf = assocIndexOf;
  9882. /** Used for built-in method references. */
  9883. var arrayProto = Array.prototype;
  9884. /** Built-in value references. */
  9885. var splice = arrayProto.splice;
  9886. /**
  9887. * Removes `key` and its value from the list cache.
  9888. *
  9889. * @private
  9890. * @name delete
  9891. * @memberOf ListCache
  9892. * @param {string} key The key of the value to remove.
  9893. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  9894. */
  9895. function listCacheDelete(key) {
  9896. var data = this.__data__,
  9897. index = _assocIndexOf(data, key);
  9898. if (index < 0) {
  9899. return false;
  9900. }
  9901. var lastIndex = data.length - 1;
  9902. if (index == lastIndex) {
  9903. data.pop();
  9904. } else {
  9905. splice.call(data, index, 1);
  9906. }
  9907. --this.size;
  9908. return true;
  9909. }
  9910. var _listCacheDelete = listCacheDelete;
  9911. /**
  9912. * Gets the list cache value for `key`.
  9913. *
  9914. * @private
  9915. * @name get
  9916. * @memberOf ListCache
  9917. * @param {string} key The key of the value to get.
  9918. * @returns {*} Returns the entry value.
  9919. */
  9920. function listCacheGet(key) {
  9921. var data = this.__data__,
  9922. index = _assocIndexOf(data, key);
  9923. return index < 0 ? undefined : data[index][1];
  9924. }
  9925. var _listCacheGet = listCacheGet;
  9926. /**
  9927. * Checks if a list cache value for `key` exists.
  9928. *
  9929. * @private
  9930. * @name has
  9931. * @memberOf ListCache
  9932. * @param {string} key The key of the entry to check.
  9933. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  9934. */
  9935. function listCacheHas(key) {
  9936. return _assocIndexOf(this.__data__, key) > -1;
  9937. }
  9938. var _listCacheHas = listCacheHas;
  9939. /**
  9940. * Sets the list cache `key` to `value`.
  9941. *
  9942. * @private
  9943. * @name set
  9944. * @memberOf ListCache
  9945. * @param {string} key The key of the value to set.
  9946. * @param {*} value The value to set.
  9947. * @returns {Object} Returns the list cache instance.
  9948. */
  9949. function listCacheSet(key, value) {
  9950. var data = this.__data__,
  9951. index = _assocIndexOf(data, key);
  9952. if (index < 0) {
  9953. ++this.size;
  9954. data.push([key, value]);
  9955. } else {
  9956. data[index][1] = value;
  9957. }
  9958. return this;
  9959. }
  9960. var _listCacheSet = listCacheSet;
  9961. /**
  9962. * Creates an list cache object.
  9963. *
  9964. * @private
  9965. * @constructor
  9966. * @param {Array} [entries] The key-value pairs to cache.
  9967. */
  9968. function ListCache(entries) {
  9969. var index = -1,
  9970. length = entries == null ? 0 : entries.length;
  9971. this.clear();
  9972. while (++index < length) {
  9973. var entry = entries[index];
  9974. this.set(entry[0], entry[1]);
  9975. }
  9976. }
  9977. // Add methods to `ListCache`.
  9978. ListCache.prototype.clear = _listCacheClear;
  9979. ListCache.prototype['delete'] = _listCacheDelete;
  9980. ListCache.prototype.get = _listCacheGet;
  9981. ListCache.prototype.has = _listCacheHas;
  9982. ListCache.prototype.set = _listCacheSet;
  9983. var _ListCache = ListCache;
  9984. /**
  9985. * Removes all key-value entries from the stack.
  9986. *
  9987. * @private
  9988. * @name clear
  9989. * @memberOf Stack
  9990. */
  9991. function stackClear() {
  9992. this.__data__ = new _ListCache;
  9993. this.size = 0;
  9994. }
  9995. var _stackClear = stackClear;
  9996. /**
  9997. * Removes `key` and its value from the stack.
  9998. *
  9999. * @private
  10000. * @name delete
  10001. * @memberOf Stack
  10002. * @param {string} key The key of the value to remove.
  10003. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10004. */
  10005. function stackDelete(key) {
  10006. var data = this.__data__,
  10007. result = data['delete'](key);
  10008. this.size = data.size;
  10009. return result;
  10010. }
  10011. var _stackDelete = stackDelete;
  10012. /**
  10013. * Gets the stack value for `key`.
  10014. *
  10015. * @private
  10016. * @name get
  10017. * @memberOf Stack
  10018. * @param {string} key The key of the value to get.
  10019. * @returns {*} Returns the entry value.
  10020. */
  10021. function stackGet(key) {
  10022. return this.__data__.get(key);
  10023. }
  10024. var _stackGet = stackGet;
  10025. /**
  10026. * Checks if a stack value for `key` exists.
  10027. *
  10028. * @private
  10029. * @name has
  10030. * @memberOf Stack
  10031. * @param {string} key The key of the entry to check.
  10032. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10033. */
  10034. function stackHas(key) {
  10035. return this.__data__.has(key);
  10036. }
  10037. var _stackHas = stackHas;
  10038. /** Detect free variable `global` from Node.js. */
  10039. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  10040. var _freeGlobal = freeGlobal;
  10041. /** Detect free variable `self`. */
  10042. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  10043. /** Used as a reference to the global object. */
  10044. var root = _freeGlobal || freeSelf || Function('return this')();
  10045. var _root = root;
  10046. /** Built-in value references. */
  10047. var Symbol = _root.Symbol;
  10048. var _Symbol = Symbol;
  10049. /** Used for built-in method references. */
  10050. var objectProto = Object.prototype;
  10051. /** Used to check objects for own properties. */
  10052. var hasOwnProperty$1 = objectProto.hasOwnProperty;
  10053. /**
  10054. * Used to resolve the
  10055. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  10056. * of values.
  10057. */
  10058. var nativeObjectToString = objectProto.toString;
  10059. /** Built-in value references. */
  10060. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  10061. /**
  10062. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  10063. *
  10064. * @private
  10065. * @param {*} value The value to query.
  10066. * @returns {string} Returns the raw `toStringTag`.
  10067. */
  10068. function getRawTag(value) {
  10069. var isOwn = hasOwnProperty$1.call(value, symToStringTag),
  10070. tag = value[symToStringTag];
  10071. try {
  10072. value[symToStringTag] = undefined;
  10073. var unmasked = true;
  10074. } catch (e) {}
  10075. var result = nativeObjectToString.call(value);
  10076. if (unmasked) {
  10077. if (isOwn) {
  10078. value[symToStringTag] = tag;
  10079. } else {
  10080. delete value[symToStringTag];
  10081. }
  10082. }
  10083. return result;
  10084. }
  10085. var _getRawTag = getRawTag;
  10086. /** Used for built-in method references. */
  10087. var objectProto$1 = Object.prototype;
  10088. /**
  10089. * Used to resolve the
  10090. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  10091. * of values.
  10092. */
  10093. var nativeObjectToString$1 = objectProto$1.toString;
  10094. /**
  10095. * Converts `value` to a string using `Object.prototype.toString`.
  10096. *
  10097. * @private
  10098. * @param {*} value The value to convert.
  10099. * @returns {string} Returns the converted string.
  10100. */
  10101. function objectToString(value) {
  10102. return nativeObjectToString$1.call(value);
  10103. }
  10104. var _objectToString = objectToString;
  10105. /** `Object#toString` result references. */
  10106. var nullTag = '[object Null]',
  10107. undefinedTag = '[object Undefined]';
  10108. /** Built-in value references. */
  10109. var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
  10110. /**
  10111. * The base implementation of `getTag` without fallbacks for buggy environments.
  10112. *
  10113. * @private
  10114. * @param {*} value The value to query.
  10115. * @returns {string} Returns the `toStringTag`.
  10116. */
  10117. function baseGetTag(value) {
  10118. if (value == null) {
  10119. return value === undefined ? undefinedTag : nullTag;
  10120. }
  10121. return (symToStringTag$1 && symToStringTag$1 in Object(value))
  10122. ? _getRawTag(value)
  10123. : _objectToString(value);
  10124. }
  10125. var _baseGetTag = baseGetTag;
  10126. /**
  10127. * Checks if `value` is the
  10128. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  10129. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  10130. *
  10131. * @static
  10132. * @memberOf _
  10133. * @since 0.1.0
  10134. * @category Lang
  10135. * @param {*} value The value to check.
  10136. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  10137. * @example
  10138. *
  10139. * _.isObject({});
  10140. * // => true
  10141. *
  10142. * _.isObject([1, 2, 3]);
  10143. * // => true
  10144. *
  10145. * _.isObject(_.noop);
  10146. * // => true
  10147. *
  10148. * _.isObject(null);
  10149. * // => false
  10150. */
  10151. function isObject(value) {
  10152. var type = typeof value;
  10153. return value != null && (type == 'object' || type == 'function');
  10154. }
  10155. var isObject_1 = isObject;
  10156. /** `Object#toString` result references. */
  10157. var asyncTag = '[object AsyncFunction]',
  10158. funcTag = '[object Function]',
  10159. genTag = '[object GeneratorFunction]',
  10160. proxyTag = '[object Proxy]';
  10161. /**
  10162. * Checks if `value` is classified as a `Function` object.
  10163. *
  10164. * @static
  10165. * @memberOf _
  10166. * @since 0.1.0
  10167. * @category Lang
  10168. * @param {*} value The value to check.
  10169. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  10170. * @example
  10171. *
  10172. * _.isFunction(_);
  10173. * // => true
  10174. *
  10175. * _.isFunction(/abc/);
  10176. * // => false
  10177. */
  10178. function isFunction(value) {
  10179. if (!isObject_1(value)) {
  10180. return false;
  10181. }
  10182. // The use of `Object#toString` avoids issues with the `typeof` operator
  10183. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  10184. var tag = _baseGetTag(value);
  10185. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  10186. }
  10187. var isFunction_1 = isFunction;
  10188. /** Used to detect overreaching core-js shims. */
  10189. var coreJsData = _root['__core-js_shared__'];
  10190. var _coreJsData = coreJsData;
  10191. /** Used to detect methods masquerading as native. */
  10192. var maskSrcKey = (function() {
  10193. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  10194. return uid ? ('Symbol(src)_1.' + uid) : '';
  10195. }());
  10196. /**
  10197. * Checks if `func` has its source masked.
  10198. *
  10199. * @private
  10200. * @param {Function} func The function to check.
  10201. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  10202. */
  10203. function isMasked(func) {
  10204. return !!maskSrcKey && (maskSrcKey in func);
  10205. }
  10206. var _isMasked = isMasked;
  10207. /** Used for built-in method references. */
  10208. var funcProto = Function.prototype;
  10209. /** Used to resolve the decompiled source of functions. */
  10210. var funcToString = funcProto.toString;
  10211. /**
  10212. * Converts `func` to its source code.
  10213. *
  10214. * @private
  10215. * @param {Function} func The function to convert.
  10216. * @returns {string} Returns the source code.
  10217. */
  10218. function toSource(func) {
  10219. if (func != null) {
  10220. try {
  10221. return funcToString.call(func);
  10222. } catch (e) {}
  10223. try {
  10224. return (func + '');
  10225. } catch (e$1) {}
  10226. }
  10227. return '';
  10228. }
  10229. var _toSource = toSource;
  10230. /**
  10231. * Used to match `RegExp`
  10232. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  10233. */
  10234. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  10235. /** Used to detect host constructors (Safari). */
  10236. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  10237. /** Used for built-in method references. */
  10238. var funcProto$1 = Function.prototype,
  10239. objectProto$2 = Object.prototype;
  10240. /** Used to resolve the decompiled source of functions. */
  10241. var funcToString$1 = funcProto$1.toString;
  10242. /** Used to check objects for own properties. */
  10243. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  10244. /** Used to detect if a method is native. */
  10245. var reIsNative = RegExp('^' +
  10246. funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  10247. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  10248. );
  10249. /**
  10250. * The base implementation of `_.isNative` without bad shim checks.
  10251. *
  10252. * @private
  10253. * @param {*} value The value to check.
  10254. * @returns {boolean} Returns `true` if `value` is a native function,
  10255. * else `false`.
  10256. */
  10257. function baseIsNative(value) {
  10258. if (!isObject_1(value) || _isMasked(value)) {
  10259. return false;
  10260. }
  10261. var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
  10262. return pattern.test(_toSource(value));
  10263. }
  10264. var _baseIsNative = baseIsNative;
  10265. /**
  10266. * Gets the value at `key` of `object`.
  10267. *
  10268. * @private
  10269. * @param {Object} [object] The object to query.
  10270. * @param {string} key The key of the property to get.
  10271. * @returns {*} Returns the property value.
  10272. */
  10273. function getValue(object, key) {
  10274. return object == null ? undefined : object[key];
  10275. }
  10276. var _getValue = getValue;
  10277. /**
  10278. * Gets the native function at `key` of `object`.
  10279. *
  10280. * @private
  10281. * @param {Object} object The object to query.
  10282. * @param {string} key The key of the method to get.
  10283. * @returns {*} Returns the function if it's native, else `undefined`.
  10284. */
  10285. function getNative(object, key) {
  10286. var value = _getValue(object, key);
  10287. return _baseIsNative(value) ? value : undefined;
  10288. }
  10289. var _getNative = getNative;
  10290. /* Built-in method references that are verified to be native. */
  10291. var Map = _getNative(_root, 'Map');
  10292. var _Map = Map;
  10293. /* Built-in method references that are verified to be native. */
  10294. var nativeCreate = _getNative(Object, 'create');
  10295. var _nativeCreate = nativeCreate;
  10296. /**
  10297. * Removes all key-value entries from the hash.
  10298. *
  10299. * @private
  10300. * @name clear
  10301. * @memberOf Hash
  10302. */
  10303. function hashClear() {
  10304. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  10305. this.size = 0;
  10306. }
  10307. var _hashClear = hashClear;
  10308. /**
  10309. * Removes `key` and its value from the hash.
  10310. *
  10311. * @private
  10312. * @name delete
  10313. * @memberOf Hash
  10314. * @param {Object} hash The hash to modify.
  10315. * @param {string} key The key of the value to remove.
  10316. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10317. */
  10318. function hashDelete(key) {
  10319. var result = this.has(key) && delete this.__data__[key];
  10320. this.size -= result ? 1 : 0;
  10321. return result;
  10322. }
  10323. var _hashDelete = hashDelete;
  10324. /** Used to stand-in for `undefined` hash values. */
  10325. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  10326. /** Used for built-in method references. */
  10327. var objectProto$3 = Object.prototype;
  10328. /** Used to check objects for own properties. */
  10329. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  10330. /**
  10331. * Gets the hash value for `key`.
  10332. *
  10333. * @private
  10334. * @name get
  10335. * @memberOf Hash
  10336. * @param {string} key The key of the value to get.
  10337. * @returns {*} Returns the entry value.
  10338. */
  10339. function hashGet(key) {
  10340. var data = this.__data__;
  10341. if (_nativeCreate) {
  10342. var result = data[key];
  10343. return result === HASH_UNDEFINED ? undefined : result;
  10344. }
  10345. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  10346. }
  10347. var _hashGet = hashGet;
  10348. /** Used for built-in method references. */
  10349. var objectProto$4 = Object.prototype;
  10350. /** Used to check objects for own properties. */
  10351. var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  10352. /**
  10353. * Checks if a hash value for `key` exists.
  10354. *
  10355. * @private
  10356. * @name has
  10357. * @memberOf Hash
  10358. * @param {string} key The key of the entry to check.
  10359. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10360. */
  10361. function hashHas(key) {
  10362. var data = this.__data__;
  10363. return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
  10364. }
  10365. var _hashHas = hashHas;
  10366. /** Used to stand-in for `undefined` hash values. */
  10367. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  10368. /**
  10369. * Sets the hash `key` to `value`.
  10370. *
  10371. * @private
  10372. * @name set
  10373. * @memberOf Hash
  10374. * @param {string} key The key of the value to set.
  10375. * @param {*} value The value to set.
  10376. * @returns {Object} Returns the hash instance.
  10377. */
  10378. function hashSet(key, value) {
  10379. var data = this.__data__;
  10380. this.size += this.has(key) ? 0 : 1;
  10381. data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  10382. return this;
  10383. }
  10384. var _hashSet = hashSet;
  10385. /**
  10386. * Creates a hash object.
  10387. *
  10388. * @private
  10389. * @constructor
  10390. * @param {Array} [entries] The key-value pairs to cache.
  10391. */
  10392. function Hash(entries) {
  10393. var index = -1,
  10394. length = entries == null ? 0 : entries.length;
  10395. this.clear();
  10396. while (++index < length) {
  10397. var entry = entries[index];
  10398. this.set(entry[0], entry[1]);
  10399. }
  10400. }
  10401. // Add methods to `Hash`.
  10402. Hash.prototype.clear = _hashClear;
  10403. Hash.prototype['delete'] = _hashDelete;
  10404. Hash.prototype.get = _hashGet;
  10405. Hash.prototype.has = _hashHas;
  10406. Hash.prototype.set = _hashSet;
  10407. var _Hash = Hash;
  10408. /**
  10409. * Removes all key-value entries from the map.
  10410. *
  10411. * @private
  10412. * @name clear
  10413. * @memberOf MapCache
  10414. */
  10415. function mapCacheClear() {
  10416. this.size = 0;
  10417. this.__data__ = {
  10418. 'hash': new _Hash,
  10419. 'map': new (_Map || _ListCache),
  10420. 'string': new _Hash
  10421. };
  10422. }
  10423. var _mapCacheClear = mapCacheClear;
  10424. /**
  10425. * Checks if `value` is suitable for use as unique object key.
  10426. *
  10427. * @private
  10428. * @param {*} value The value to check.
  10429. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10430. */
  10431. function isKeyable(value) {
  10432. var type = typeof value;
  10433. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  10434. ? (value !== '__proto__')
  10435. : (value === null);
  10436. }
  10437. var _isKeyable = isKeyable;
  10438. /**
  10439. * Gets the data for `map`.
  10440. *
  10441. * @private
  10442. * @param {Object} map The map to query.
  10443. * @param {string} key The reference key.
  10444. * @returns {*} Returns the map data.
  10445. */
  10446. function getMapData(map, key) {
  10447. var data = map.__data__;
  10448. return _isKeyable(key)
  10449. ? data[typeof key == 'string' ? 'string' : 'hash']
  10450. : data.map;
  10451. }
  10452. var _getMapData = getMapData;
  10453. /**
  10454. * Removes `key` and its value from the map.
  10455. *
  10456. * @private
  10457. * @name delete
  10458. * @memberOf MapCache
  10459. * @param {string} key The key of the value to remove.
  10460. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10461. */
  10462. function mapCacheDelete(key) {
  10463. var result = _getMapData(this, key)['delete'](key);
  10464. this.size -= result ? 1 : 0;
  10465. return result;
  10466. }
  10467. var _mapCacheDelete = mapCacheDelete;
  10468. /**
  10469. * Gets the map value for `key`.
  10470. *
  10471. * @private
  10472. * @name get
  10473. * @memberOf MapCache
  10474. * @param {string} key The key of the value to get.
  10475. * @returns {*} Returns the entry value.
  10476. */
  10477. function mapCacheGet(key) {
  10478. return _getMapData(this, key).get(key);
  10479. }
  10480. var _mapCacheGet = mapCacheGet;
  10481. /**
  10482. * Checks if a map value for `key` exists.
  10483. *
  10484. * @private
  10485. * @name has
  10486. * @memberOf MapCache
  10487. * @param {string} key The key of the entry to check.
  10488. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10489. */
  10490. function mapCacheHas(key) {
  10491. return _getMapData(this, key).has(key);
  10492. }
  10493. var _mapCacheHas = mapCacheHas;
  10494. /**
  10495. * Sets the map `key` to `value`.
  10496. *
  10497. * @private
  10498. * @name set
  10499. * @memberOf MapCache
  10500. * @param {string} key The key of the value to set.
  10501. * @param {*} value The value to set.
  10502. * @returns {Object} Returns the map cache instance.
  10503. */
  10504. function mapCacheSet(key, value) {
  10505. var data = _getMapData(this, key),
  10506. size = data.size;
  10507. data.set(key, value);
  10508. this.size += data.size == size ? 0 : 1;
  10509. return this;
  10510. }
  10511. var _mapCacheSet = mapCacheSet;
  10512. /**
  10513. * Creates a map cache object to store key-value pairs.
  10514. *
  10515. * @private
  10516. * @constructor
  10517. * @param {Array} [entries] The key-value pairs to cache.
  10518. */
  10519. function MapCache(entries) {
  10520. var index = -1,
  10521. length = entries == null ? 0 : entries.length;
  10522. this.clear();
  10523. while (++index < length) {
  10524. var entry = entries[index];
  10525. this.set(entry[0], entry[1]);
  10526. }
  10527. }
  10528. // Add methods to `MapCache`.
  10529. MapCache.prototype.clear = _mapCacheClear;
  10530. MapCache.prototype['delete'] = _mapCacheDelete;
  10531. MapCache.prototype.get = _mapCacheGet;
  10532. MapCache.prototype.has = _mapCacheHas;
  10533. MapCache.prototype.set = _mapCacheSet;
  10534. var _MapCache = MapCache;
  10535. /** Used as the size to enable large array optimizations. */
  10536. var LARGE_ARRAY_SIZE = 200;
  10537. /**
  10538. * Sets the stack `key` to `value`.
  10539. *
  10540. * @private
  10541. * @name set
  10542. * @memberOf Stack
  10543. * @param {string} key The key of the value to set.
  10544. * @param {*} value The value to set.
  10545. * @returns {Object} Returns the stack cache instance.
  10546. */
  10547. function stackSet(key, value) {
  10548. var data = this.__data__;
  10549. if (data instanceof _ListCache) {
  10550. var pairs = data.__data__;
  10551. if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  10552. pairs.push([key, value]);
  10553. this.size = ++data.size;
  10554. return this;
  10555. }
  10556. data = this.__data__ = new _MapCache(pairs);
  10557. }
  10558. data.set(key, value);
  10559. this.size = data.size;
  10560. return this;
  10561. }
  10562. var _stackSet = stackSet;
  10563. /**
  10564. * Creates a stack cache object to store key-value pairs.
  10565. *
  10566. * @private
  10567. * @constructor
  10568. * @param {Array} [entries] The key-value pairs to cache.
  10569. */
  10570. function Stack(entries) {
  10571. var data = this.__data__ = new _ListCache(entries);
  10572. this.size = data.size;
  10573. }
  10574. // Add methods to `Stack`.
  10575. Stack.prototype.clear = _stackClear;
  10576. Stack.prototype['delete'] = _stackDelete;
  10577. Stack.prototype.get = _stackGet;
  10578. Stack.prototype.has = _stackHas;
  10579. Stack.prototype.set = _stackSet;
  10580. var _Stack = Stack;
  10581. /**
  10582. * A specialized version of `_.forEach` for arrays without support for
  10583. * iteratee shorthands.
  10584. *
  10585. * @private
  10586. * @param {Array} [array] The array to iterate over.
  10587. * @param {Function} iteratee The function invoked per iteration.
  10588. * @returns {Array} Returns `array`.
  10589. */
  10590. function arrayEach(array, iteratee) {
  10591. var index = -1,
  10592. length = array == null ? 0 : array.length;
  10593. while (++index < length) {
  10594. if (iteratee(array[index], index, array) === false) {
  10595. break;
  10596. }
  10597. }
  10598. return array;
  10599. }
  10600. var _arrayEach = arrayEach;
  10601. var defineProperty = (function() {
  10602. try {
  10603. var func = _getNative(Object, 'defineProperty');
  10604. func({}, '', {});
  10605. return func;
  10606. } catch (e) {}
  10607. }());
  10608. var _defineProperty = defineProperty;
  10609. /**
  10610. * The base implementation of `assignValue` and `assignMergeValue` without
  10611. * value checks.
  10612. *
  10613. * @private
  10614. * @param {Object} object The object to modify.
  10615. * @param {string} key The key of the property to assign.
  10616. * @param {*} value The value to assign.
  10617. */
  10618. function baseAssignValue(object, key, value) {
  10619. if (key == '__proto__' && _defineProperty) {
  10620. _defineProperty(object, key, {
  10621. 'configurable': true,
  10622. 'enumerable': true,
  10623. 'value': value,
  10624. 'writable': true
  10625. });
  10626. } else {
  10627. object[key] = value;
  10628. }
  10629. }
  10630. var _baseAssignValue = baseAssignValue;
  10631. /** Used for built-in method references. */
  10632. var objectProto$5 = Object.prototype;
  10633. /** Used to check objects for own properties. */
  10634. var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
  10635. /**
  10636. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  10637. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10638. * for equality comparisons.
  10639. *
  10640. * @private
  10641. * @param {Object} object The object to modify.
  10642. * @param {string} key The key of the property to assign.
  10643. * @param {*} value The value to assign.
  10644. */
  10645. function assignValue(object, key, value) {
  10646. var objValue = object[key];
  10647. if (!(hasOwnProperty$5.call(object, key) && eq_1(objValue, value)) ||
  10648. (value === undefined && !(key in object))) {
  10649. _baseAssignValue(object, key, value);
  10650. }
  10651. }
  10652. var _assignValue = assignValue;
  10653. /**
  10654. * Copies properties of `source` to `object`.
  10655. *
  10656. * @private
  10657. * @param {Object} source The object to copy properties from.
  10658. * @param {Array} props The property identifiers to copy.
  10659. * @param {Object} [object={}] The object to copy properties to.
  10660. * @param {Function} [customizer] The function to customize copied values.
  10661. * @returns {Object} Returns `object`.
  10662. */
  10663. function copyObject(source, props, object, customizer) {
  10664. var isNew = !object;
  10665. object || (object = {});
  10666. var index = -1,
  10667. length = props.length;
  10668. while (++index < length) {
  10669. var key = props[index];
  10670. var newValue = customizer
  10671. ? customizer(object[key], source[key], key, object, source)
  10672. : undefined;
  10673. if (newValue === undefined) {
  10674. newValue = source[key];
  10675. }
  10676. if (isNew) {
  10677. _baseAssignValue(object, key, newValue);
  10678. } else {
  10679. _assignValue(object, key, newValue);
  10680. }
  10681. }
  10682. return object;
  10683. }
  10684. var _copyObject = copyObject;
  10685. /**
  10686. * The base implementation of `_.times` without support for iteratee shorthands
  10687. * or max array length checks.
  10688. *
  10689. * @private
  10690. * @param {number} n The number of times to invoke `iteratee`.
  10691. * @param {Function} iteratee The function invoked per iteration.
  10692. * @returns {Array} Returns the array of results.
  10693. */
  10694. function baseTimes(n, iteratee) {
  10695. var index = -1,
  10696. result = Array(n);
  10697. while (++index < n) {
  10698. result[index] = iteratee(index);
  10699. }
  10700. return result;
  10701. }
  10702. var _baseTimes = baseTimes;
  10703. /**
  10704. * Checks if `value` is object-like. A value is object-like if it's not `null`
  10705. * and has a `typeof` result of "object".
  10706. *
  10707. * @static
  10708. * @memberOf _
  10709. * @since 4.0.0
  10710. * @category Lang
  10711. * @param {*} value The value to check.
  10712. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  10713. * @example
  10714. *
  10715. * _.isObjectLike({});
  10716. * // => true
  10717. *
  10718. * _.isObjectLike([1, 2, 3]);
  10719. * // => true
  10720. *
  10721. * _.isObjectLike(_.noop);
  10722. * // => false
  10723. *
  10724. * _.isObjectLike(null);
  10725. * // => false
  10726. */
  10727. function isObjectLike(value) {
  10728. return value != null && typeof value == 'object';
  10729. }
  10730. var isObjectLike_1 = isObjectLike;
  10731. /** `Object#toString` result references. */
  10732. var argsTag = '[object Arguments]';
  10733. /**
  10734. * The base implementation of `_.isArguments`.
  10735. *
  10736. * @private
  10737. * @param {*} value The value to check.
  10738. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10739. */
  10740. function baseIsArguments(value) {
  10741. return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
  10742. }
  10743. var _baseIsArguments = baseIsArguments;
  10744. /** Used for built-in method references. */
  10745. var objectProto$6 = Object.prototype;
  10746. /** Used to check objects for own properties. */
  10747. var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
  10748. /** Built-in value references. */
  10749. var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
  10750. /**
  10751. * Checks if `value` is likely an `arguments` object.
  10752. *
  10753. * @static
  10754. * @memberOf _
  10755. * @since 0.1.0
  10756. * @category Lang
  10757. * @param {*} value The value to check.
  10758. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10759. * else `false`.
  10760. * @example
  10761. *
  10762. * _.isArguments(function() { return arguments; }());
  10763. * // => true
  10764. *
  10765. * _.isArguments([1, 2, 3]);
  10766. * // => false
  10767. */
  10768. var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
  10769. return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') &&
  10770. !propertyIsEnumerable.call(value, 'callee');
  10771. };
  10772. var isArguments_1 = isArguments;
  10773. /**
  10774. * Checks if `value` is classified as an `Array` object.
  10775. *
  10776. * @static
  10777. * @memberOf _
  10778. * @since 0.1.0
  10779. * @category Lang
  10780. * @param {*} value The value to check.
  10781. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  10782. * @example
  10783. *
  10784. * _.isArray([1, 2, 3]);
  10785. * // => true
  10786. *
  10787. * _.isArray(document.body.children);
  10788. * // => false
  10789. *
  10790. * _.isArray('abc');
  10791. * // => false
  10792. *
  10793. * _.isArray(_.noop);
  10794. * // => false
  10795. */
  10796. var isArray = Array.isArray;
  10797. var isArray_1 = isArray;
  10798. /**
  10799. * This method returns `false`.
  10800. *
  10801. * @static
  10802. * @memberOf _
  10803. * @since 4.13.0
  10804. * @category Util
  10805. * @returns {boolean} Returns `false`.
  10806. * @example
  10807. *
  10808. * _.times(2, _.stubFalse);
  10809. * // => [false, false]
  10810. */
  10811. function stubFalse() {
  10812. return false;
  10813. }
  10814. var stubFalse_1 = stubFalse;
  10815. var isBuffer_1$1 = createCommonjsModule(function (module, exports) {
  10816. /** Detect free variable `exports`. */
  10817. var freeExports = exports && !exports.nodeType && exports;
  10818. /** Detect free variable `module`. */
  10819. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  10820. /** Detect the popular CommonJS extension `module.exports`. */
  10821. var moduleExports = freeModule && freeModule.exports === freeExports;
  10822. /** Built-in value references. */
  10823. var Buffer = moduleExports ? _root.Buffer : undefined;
  10824. /* Built-in method references for those with the same name as other `lodash` methods. */
  10825. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  10826. /**
  10827. * Checks if `value` is a buffer.
  10828. *
  10829. * @static
  10830. * @memberOf _
  10831. * @since 4.3.0
  10832. * @category Lang
  10833. * @param {*} value The value to check.
  10834. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  10835. * @example
  10836. *
  10837. * _.isBuffer(new Buffer(2));
  10838. * // => true
  10839. *
  10840. * _.isBuffer(new Uint8Array(2));
  10841. * // => false
  10842. */
  10843. var isBuffer = nativeIsBuffer || stubFalse_1;
  10844. module.exports = isBuffer;
  10845. });
  10846. /** Used as references for various `Number` constants. */
  10847. var MAX_SAFE_INTEGER = 9007199254740991;
  10848. /** Used to detect unsigned integer values. */
  10849. var reIsUint = /^(?:0|[1-9]\d*)$/;
  10850. /**
  10851. * Checks if `value` is a valid array-like index.
  10852. *
  10853. * @private
  10854. * @param {*} value The value to check.
  10855. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  10856. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  10857. */
  10858. function isIndex(value, length) {
  10859. var type = typeof value;
  10860. length = length == null ? MAX_SAFE_INTEGER : length;
  10861. return !!length &&
  10862. (type == 'number' ||
  10863. (type != 'symbol' && reIsUint.test(value))) &&
  10864. (value > -1 && value % 1 == 0 && value < length);
  10865. }
  10866. var _isIndex = isIndex;
  10867. /** Used as references for various `Number` constants. */
  10868. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  10869. /**
  10870. * Checks if `value` is a valid array-like length.
  10871. *
  10872. * **Note:** This method is loosely based on
  10873. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  10874. *
  10875. * @static
  10876. * @memberOf _
  10877. * @since 4.0.0
  10878. * @category Lang
  10879. * @param {*} value The value to check.
  10880. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  10881. * @example
  10882. *
  10883. * _.isLength(3);
  10884. * // => true
  10885. *
  10886. * _.isLength(Number.MIN_VALUE);
  10887. * // => false
  10888. *
  10889. * _.isLength(Infinity);
  10890. * // => false
  10891. *
  10892. * _.isLength('3');
  10893. * // => false
  10894. */
  10895. function isLength(value) {
  10896. return typeof value == 'number' &&
  10897. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
  10898. }
  10899. var isLength_1 = isLength;
  10900. /** `Object#toString` result references. */
  10901. var argsTag$1 = '[object Arguments]',
  10902. arrayTag = '[object Array]',
  10903. boolTag = '[object Boolean]',
  10904. dateTag = '[object Date]',
  10905. errorTag = '[object Error]',
  10906. funcTag$1 = '[object Function]',
  10907. mapTag = '[object Map]',
  10908. numberTag = '[object Number]',
  10909. objectTag = '[object Object]',
  10910. regexpTag = '[object RegExp]',
  10911. setTag = '[object Set]',
  10912. stringTag = '[object String]',
  10913. weakMapTag = '[object WeakMap]';
  10914. var arrayBufferTag = '[object ArrayBuffer]',
  10915. dataViewTag = '[object DataView]',
  10916. float32Tag = '[object Float32Array]',
  10917. float64Tag = '[object Float64Array]',
  10918. int8Tag = '[object Int8Array]',
  10919. int16Tag = '[object Int16Array]',
  10920. int32Tag = '[object Int32Array]',
  10921. uint8Tag = '[object Uint8Array]',
  10922. uint8ClampedTag = '[object Uint8ClampedArray]',
  10923. uint16Tag = '[object Uint16Array]',
  10924. uint32Tag = '[object Uint32Array]';
  10925. /** Used to identify `toStringTag` values of typed arrays. */
  10926. var typedArrayTags = {};
  10927. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  10928. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  10929. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  10930. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  10931. typedArrayTags[uint32Tag] = true;
  10932. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
  10933. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  10934. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  10935. typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
  10936. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  10937. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  10938. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  10939. typedArrayTags[weakMapTag] = false;
  10940. /**
  10941. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  10942. *
  10943. * @private
  10944. * @param {*} value The value to check.
  10945. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10946. */
  10947. function baseIsTypedArray(value) {
  10948. return isObjectLike_1(value) &&
  10949. isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
  10950. }
  10951. var _baseIsTypedArray = baseIsTypedArray;
  10952. /**
  10953. * The base implementation of `_.unary` without support for storing metadata.
  10954. *
  10955. * @private
  10956. * @param {Function} func The function to cap arguments for.
  10957. * @returns {Function} Returns the new capped function.
  10958. */
  10959. function baseUnary(func) {
  10960. return function(value) {
  10961. return func(value);
  10962. };
  10963. }
  10964. var _baseUnary = baseUnary;
  10965. var _nodeUtil = createCommonjsModule(function (module, exports) {
  10966. /** Detect free variable `exports`. */
  10967. var freeExports = exports && !exports.nodeType && exports;
  10968. /** Detect free variable `module`. */
  10969. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  10970. /** Detect the popular CommonJS extension `module.exports`. */
  10971. var moduleExports = freeModule && freeModule.exports === freeExports;
  10972. /** Detect free variable `process` from Node.js. */
  10973. var freeProcess = moduleExports && _freeGlobal.process;
  10974. /** Used to access faster Node.js helpers. */
  10975. var nodeUtil = (function() {
  10976. try {
  10977. // Use `util.types` for Node.js 10+.
  10978. var types = freeModule && freeModule.require && freeModule.require('util').types;
  10979. if (types) {
  10980. return types;
  10981. }
  10982. // Legacy `process.binding('util')` for Node.js < 10.
  10983. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  10984. } catch (e) {}
  10985. }());
  10986. module.exports = nodeUtil;
  10987. });
  10988. /* Node.js helper references. */
  10989. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  10990. /**
  10991. * Checks if `value` is classified as a typed array.
  10992. *
  10993. * @static
  10994. * @memberOf _
  10995. * @since 3.0.0
  10996. * @category Lang
  10997. * @param {*} value The value to check.
  10998. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10999. * @example
  11000. *
  11001. * _.isTypedArray(new Uint8Array);
  11002. * // => true
  11003. *
  11004. * _.isTypedArray([]);
  11005. * // => false
  11006. */
  11007. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  11008. var isTypedArray_1 = isTypedArray;
  11009. /** Used for built-in method references. */
  11010. var objectProto$7 = Object.prototype;
  11011. /** Used to check objects for own properties. */
  11012. var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
  11013. /**
  11014. * Creates an array of the enumerable property names of the array-like `value`.
  11015. *
  11016. * @private
  11017. * @param {*} value The value to query.
  11018. * @param {boolean} inherited Specify returning inherited property names.
  11019. * @returns {Array} Returns the array of property names.
  11020. */
  11021. function arrayLikeKeys(value, inherited) {
  11022. var isArr = isArray_1(value),
  11023. isArg = !isArr && isArguments_1(value),
  11024. isBuff = !isArr && !isArg && isBuffer_1$1(value),
  11025. isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
  11026. skipIndexes = isArr || isArg || isBuff || isType,
  11027. result = skipIndexes ? _baseTimes(value.length, String) : [],
  11028. length = result.length;
  11029. for (var key in value) {
  11030. if ((inherited || hasOwnProperty$7.call(value, key)) &&
  11031. !(skipIndexes && (
  11032. // Safari 9 has enumerable `arguments.length` in strict mode.
  11033. key == 'length' ||
  11034. // Node.js 0.10 has enumerable non-index properties on buffers.
  11035. (isBuff && (key == 'offset' || key == 'parent')) ||
  11036. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  11037. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  11038. // Skip index properties.
  11039. _isIndex(key, length)
  11040. ))) {
  11041. result.push(key);
  11042. }
  11043. }
  11044. return result;
  11045. }
  11046. var _arrayLikeKeys = arrayLikeKeys;
  11047. /** Used for built-in method references. */
  11048. var objectProto$8 = Object.prototype;
  11049. /**
  11050. * Checks if `value` is likely a prototype object.
  11051. *
  11052. * @private
  11053. * @param {*} value The value to check.
  11054. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  11055. */
  11056. function isPrototype(value) {
  11057. var Ctor = value && value.constructor,
  11058. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
  11059. return value === proto;
  11060. }
  11061. var _isPrototype = isPrototype;
  11062. /**
  11063. * Creates a unary function that invokes `func` with its argument transformed.
  11064. *
  11065. * @private
  11066. * @param {Function} func The function to wrap.
  11067. * @param {Function} transform The argument transform.
  11068. * @returns {Function} Returns the new function.
  11069. */
  11070. function overArg(func, transform) {
  11071. return function(arg) {
  11072. return func(transform(arg));
  11073. };
  11074. }
  11075. var _overArg = overArg;
  11076. /* Built-in method references for those with the same name as other `lodash` methods. */
  11077. var nativeKeys = _overArg(Object.keys, Object);
  11078. var _nativeKeys = nativeKeys;
  11079. /** Used for built-in method references. */
  11080. var objectProto$9 = Object.prototype;
  11081. /** Used to check objects for own properties. */
  11082. var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
  11083. /**
  11084. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  11085. *
  11086. * @private
  11087. * @param {Object} object The object to query.
  11088. * @returns {Array} Returns the array of property names.
  11089. */
  11090. function baseKeys(object) {
  11091. if (!_isPrototype(object)) {
  11092. return _nativeKeys(object);
  11093. }
  11094. var result = [];
  11095. for (var key in Object(object)) {
  11096. if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
  11097. result.push(key);
  11098. }
  11099. }
  11100. return result;
  11101. }
  11102. var _baseKeys = baseKeys;
  11103. /**
  11104. * Checks if `value` is array-like. A value is considered array-like if it's
  11105. * not a function and has a `value.length` that's an integer greater than or
  11106. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11107. *
  11108. * @static
  11109. * @memberOf _
  11110. * @since 4.0.0
  11111. * @category Lang
  11112. * @param {*} value The value to check.
  11113. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11114. * @example
  11115. *
  11116. * _.isArrayLike([1, 2, 3]);
  11117. * // => true
  11118. *
  11119. * _.isArrayLike(document.body.children);
  11120. * // => true
  11121. *
  11122. * _.isArrayLike('abc');
  11123. * // => true
  11124. *
  11125. * _.isArrayLike(_.noop);
  11126. * // => false
  11127. */
  11128. function isArrayLike(value) {
  11129. return value != null && isLength_1(value.length) && !isFunction_1(value);
  11130. }
  11131. var isArrayLike_1 = isArrayLike;
  11132. /**
  11133. * Creates an array of the own enumerable property names of `object`.
  11134. *
  11135. * **Note:** Non-object values are coerced to objects. See the
  11136. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11137. * for more details.
  11138. *
  11139. * @static
  11140. * @since 0.1.0
  11141. * @memberOf _
  11142. * @category Object
  11143. * @param {Object} object The object to query.
  11144. * @returns {Array} Returns the array of property names.
  11145. * @example
  11146. *
  11147. * function Foo() {
  11148. * this.a = 1;
  11149. * this.b = 2;
  11150. * }
  11151. *
  11152. * Foo.prototype.c = 3;
  11153. *
  11154. * _.keys(new Foo);
  11155. * // => ['a', 'b'] (iteration order is not guaranteed)
  11156. *
  11157. * _.keys('hi');
  11158. * // => ['0', '1']
  11159. */
  11160. function keys$1(object) {
  11161. return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  11162. }
  11163. var keys_1 = keys$1;
  11164. /**
  11165. * The base implementation of `_.assign` without support for multiple sources
  11166. * or `customizer` functions.
  11167. *
  11168. * @private
  11169. * @param {Object} object The destination object.
  11170. * @param {Object} source The source object.
  11171. * @returns {Object} Returns `object`.
  11172. */
  11173. function baseAssign(object, source) {
  11174. return object && _copyObject(source, keys_1(source), object);
  11175. }
  11176. var _baseAssign = baseAssign;
  11177. /**
  11178. * This function is like
  11179. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11180. * except that it includes inherited enumerable properties.
  11181. *
  11182. * @private
  11183. * @param {Object} object The object to query.
  11184. * @returns {Array} Returns the array of property names.
  11185. */
  11186. function nativeKeysIn(object) {
  11187. var result = [];
  11188. if (object != null) {
  11189. for (var key in Object(object)) {
  11190. result.push(key);
  11191. }
  11192. }
  11193. return result;
  11194. }
  11195. var _nativeKeysIn = nativeKeysIn;
  11196. /** Used for built-in method references. */
  11197. var objectProto$a = Object.prototype;
  11198. /** Used to check objects for own properties. */
  11199. var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
  11200. /**
  11201. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  11202. *
  11203. * @private
  11204. * @param {Object} object The object to query.
  11205. * @returns {Array} Returns the array of property names.
  11206. */
  11207. function baseKeysIn(object) {
  11208. if (!isObject_1(object)) {
  11209. return _nativeKeysIn(object);
  11210. }
  11211. var isProto = _isPrototype(object),
  11212. result = [];
  11213. for (var key in object) {
  11214. if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
  11215. result.push(key);
  11216. }
  11217. }
  11218. return result;
  11219. }
  11220. var _baseKeysIn = baseKeysIn;
  11221. /**
  11222. * Creates an array of the own and inherited enumerable property names of `object`.
  11223. *
  11224. * **Note:** Non-object values are coerced to objects.
  11225. *
  11226. * @static
  11227. * @memberOf _
  11228. * @since 3.0.0
  11229. * @category Object
  11230. * @param {Object} object The object to query.
  11231. * @returns {Array} Returns the array of property names.
  11232. * @example
  11233. *
  11234. * function Foo() {
  11235. * this.a = 1;
  11236. * this.b = 2;
  11237. * }
  11238. *
  11239. * Foo.prototype.c = 3;
  11240. *
  11241. * _.keysIn(new Foo);
  11242. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  11243. */
  11244. function keysIn(object) {
  11245. return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
  11246. }
  11247. var keysIn_1 = keysIn;
  11248. /**
  11249. * The base implementation of `_.assignIn` without support for multiple sources
  11250. * or `customizer` functions.
  11251. *
  11252. * @private
  11253. * @param {Object} object The destination object.
  11254. * @param {Object} source The source object.
  11255. * @returns {Object} Returns `object`.
  11256. */
  11257. function baseAssignIn(object, source) {
  11258. return object && _copyObject(source, keysIn_1(source), object);
  11259. }
  11260. var _baseAssignIn = baseAssignIn;
  11261. var _cloneBuffer = createCommonjsModule(function (module, exports) {
  11262. /** Detect free variable `exports`. */
  11263. var freeExports = exports && !exports.nodeType && exports;
  11264. /** Detect free variable `module`. */
  11265. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  11266. /** Detect the popular CommonJS extension `module.exports`. */
  11267. var moduleExports = freeModule && freeModule.exports === freeExports;
  11268. /** Built-in value references. */
  11269. var Buffer = moduleExports ? _root.Buffer : undefined,
  11270. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  11271. /**
  11272. * Creates a clone of `buffer`.
  11273. *
  11274. * @private
  11275. * @param {Buffer} buffer The buffer to clone.
  11276. * @param {boolean} [isDeep] Specify a deep clone.
  11277. * @returns {Buffer} Returns the cloned buffer.
  11278. */
  11279. function cloneBuffer(buffer, isDeep) {
  11280. if (isDeep) {
  11281. return buffer.slice();
  11282. }
  11283. var length = buffer.length,
  11284. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  11285. buffer.copy(result);
  11286. return result;
  11287. }
  11288. module.exports = cloneBuffer;
  11289. });
  11290. /**
  11291. * Copies the values of `source` to `array`.
  11292. *
  11293. * @private
  11294. * @param {Array} source The array to copy values from.
  11295. * @param {Array} [array=[]] The array to copy values to.
  11296. * @returns {Array} Returns `array`.
  11297. */
  11298. function copyArray(source, array) {
  11299. var index = -1,
  11300. length = source.length;
  11301. array || (array = Array(length));
  11302. while (++index < length) {
  11303. array[index] = source[index];
  11304. }
  11305. return array;
  11306. }
  11307. var _copyArray = copyArray;
  11308. /**
  11309. * A specialized version of `_.filter` for arrays without support for
  11310. * iteratee shorthands.
  11311. *
  11312. * @private
  11313. * @param {Array} [array] The array to iterate over.
  11314. * @param {Function} predicate The function invoked per iteration.
  11315. * @returns {Array} Returns the new filtered array.
  11316. */
  11317. function arrayFilter(array, predicate) {
  11318. var index = -1,
  11319. length = array == null ? 0 : array.length,
  11320. resIndex = 0,
  11321. result = [];
  11322. while (++index < length) {
  11323. var value = array[index];
  11324. if (predicate(value, index, array)) {
  11325. result[resIndex++] = value;
  11326. }
  11327. }
  11328. return result;
  11329. }
  11330. var _arrayFilter = arrayFilter;
  11331. /**
  11332. * This method returns a new empty array.
  11333. *
  11334. * @static
  11335. * @memberOf _
  11336. * @since 4.13.0
  11337. * @category Util
  11338. * @returns {Array} Returns the new empty array.
  11339. * @example
  11340. *
  11341. * var arrays = _.times(2, _.stubArray);
  11342. *
  11343. * console.log(arrays);
  11344. * // => [[], []]
  11345. *
  11346. * console.log(arrays[0] === arrays[1]);
  11347. * // => false
  11348. */
  11349. function stubArray() {
  11350. return [];
  11351. }
  11352. var stubArray_1 = stubArray;
  11353. /** Used for built-in method references. */
  11354. var objectProto$b = Object.prototype;
  11355. /** Built-in value references. */
  11356. var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
  11357. /* Built-in method references for those with the same name as other `lodash` methods. */
  11358. var nativeGetSymbols = Object.getOwnPropertySymbols;
  11359. /**
  11360. * Creates an array of the own enumerable symbols of `object`.
  11361. *
  11362. * @private
  11363. * @param {Object} object The object to query.
  11364. * @returns {Array} Returns the array of symbols.
  11365. */
  11366. var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
  11367. if (object == null) {
  11368. return [];
  11369. }
  11370. object = Object(object);
  11371. return _arrayFilter(nativeGetSymbols(object), function(symbol) {
  11372. return propertyIsEnumerable$1.call(object, symbol);
  11373. });
  11374. };
  11375. var _getSymbols = getSymbols;
  11376. /**
  11377. * Copies own symbols of `source` to `object`.
  11378. *
  11379. * @private
  11380. * @param {Object} source The object to copy symbols from.
  11381. * @param {Object} [object={}] The object to copy symbols to.
  11382. * @returns {Object} Returns `object`.
  11383. */
  11384. function copySymbols(source, object) {
  11385. return _copyObject(source, _getSymbols(source), object);
  11386. }
  11387. var _copySymbols = copySymbols;
  11388. /**
  11389. * Appends the elements of `values` to `array`.
  11390. *
  11391. * @private
  11392. * @param {Array} array The array to modify.
  11393. * @param {Array} values The values to append.
  11394. * @returns {Array} Returns `array`.
  11395. */
  11396. function arrayPush(array, values) {
  11397. var index = -1,
  11398. length = values.length,
  11399. offset = array.length;
  11400. while (++index < length) {
  11401. array[offset + index] = values[index];
  11402. }
  11403. return array;
  11404. }
  11405. var _arrayPush = arrayPush;
  11406. /** Built-in value references. */
  11407. var getPrototype = _overArg(Object.getPrototypeOf, Object);
  11408. var _getPrototype = getPrototype;
  11409. /* Built-in method references for those with the same name as other `lodash` methods. */
  11410. var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
  11411. /**
  11412. * Creates an array of the own and inherited enumerable symbols of `object`.
  11413. *
  11414. * @private
  11415. * @param {Object} object The object to query.
  11416. * @returns {Array} Returns the array of symbols.
  11417. */
  11418. var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
  11419. var result = [];
  11420. while (object) {
  11421. _arrayPush(result, _getSymbols(object));
  11422. object = _getPrototype(object);
  11423. }
  11424. return result;
  11425. };
  11426. var _getSymbolsIn = getSymbolsIn;
  11427. /**
  11428. * Copies own and inherited symbols of `source` to `object`.
  11429. *
  11430. * @private
  11431. * @param {Object} source The object to copy symbols from.
  11432. * @param {Object} [object={}] The object to copy symbols to.
  11433. * @returns {Object} Returns `object`.
  11434. */
  11435. function copySymbolsIn(source, object) {
  11436. return _copyObject(source, _getSymbolsIn(source), object);
  11437. }
  11438. var _copySymbolsIn = copySymbolsIn;
  11439. /**
  11440. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  11441. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  11442. * symbols of `object`.
  11443. *
  11444. * @private
  11445. * @param {Object} object The object to query.
  11446. * @param {Function} keysFunc The function to get the keys of `object`.
  11447. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  11448. * @returns {Array} Returns the array of property names and symbols.
  11449. */
  11450. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  11451. var result = keysFunc(object);
  11452. return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
  11453. }
  11454. var _baseGetAllKeys = baseGetAllKeys;
  11455. /**
  11456. * Creates an array of own enumerable property names and symbols of `object`.
  11457. *
  11458. * @private
  11459. * @param {Object} object The object to query.
  11460. * @returns {Array} Returns the array of property names and symbols.
  11461. */
  11462. function getAllKeys(object) {
  11463. return _baseGetAllKeys(object, keys_1, _getSymbols);
  11464. }
  11465. var _getAllKeys = getAllKeys;
  11466. /**
  11467. * Creates an array of own and inherited enumerable property names and
  11468. * symbols of `object`.
  11469. *
  11470. * @private
  11471. * @param {Object} object The object to query.
  11472. * @returns {Array} Returns the array of property names and symbols.
  11473. */
  11474. function getAllKeysIn(object) {
  11475. return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
  11476. }
  11477. var _getAllKeysIn = getAllKeysIn;
  11478. /* Built-in method references that are verified to be native. */
  11479. var DataView = _getNative(_root, 'DataView');
  11480. var _DataView = DataView;
  11481. /* Built-in method references that are verified to be native. */
  11482. var Promise$1 = _getNative(_root, 'Promise');
  11483. var _Promise = Promise$1;
  11484. /* Built-in method references that are verified to be native. */
  11485. var Set$1 = _getNative(_root, 'Set');
  11486. var _Set = Set$1;
  11487. /* Built-in method references that are verified to be native. */
  11488. var WeakMap = _getNative(_root, 'WeakMap');
  11489. var _WeakMap = WeakMap;
  11490. /** `Object#toString` result references. */
  11491. var mapTag$1 = '[object Map]',
  11492. objectTag$1 = '[object Object]',
  11493. promiseTag = '[object Promise]',
  11494. setTag$1 = '[object Set]',
  11495. weakMapTag$1 = '[object WeakMap]';
  11496. var dataViewTag$1 = '[object DataView]';
  11497. /** Used to detect maps, sets, and weakmaps. */
  11498. var dataViewCtorString = _toSource(_DataView),
  11499. mapCtorString = _toSource(_Map),
  11500. promiseCtorString = _toSource(_Promise),
  11501. setCtorString = _toSource(_Set),
  11502. weakMapCtorString = _toSource(_WeakMap);
  11503. /**
  11504. * Gets the `toStringTag` of `value`.
  11505. *
  11506. * @private
  11507. * @param {*} value The value to query.
  11508. * @returns {string} Returns the `toStringTag`.
  11509. */
  11510. var getTag = _baseGetTag;
  11511. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  11512. if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
  11513. (_Map && getTag(new _Map) != mapTag$1) ||
  11514. (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
  11515. (_Set && getTag(new _Set) != setTag$1) ||
  11516. (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
  11517. getTag = function(value) {
  11518. var result = _baseGetTag(value),
  11519. Ctor = result == objectTag$1 ? value.constructor : undefined,
  11520. ctorString = Ctor ? _toSource(Ctor) : '';
  11521. if (ctorString) {
  11522. switch (ctorString) {
  11523. case dataViewCtorString: return dataViewTag$1;
  11524. case mapCtorString: return mapTag$1;
  11525. case promiseCtorString: return promiseTag;
  11526. case setCtorString: return setTag$1;
  11527. case weakMapCtorString: return weakMapTag$1;
  11528. }
  11529. }
  11530. return result;
  11531. };
  11532. }
  11533. var _getTag = getTag;
  11534. /** Used for built-in method references. */
  11535. var objectProto$c = Object.prototype;
  11536. /** Used to check objects for own properties. */
  11537. var hasOwnProperty$a = objectProto$c.hasOwnProperty;
  11538. /**
  11539. * Initializes an array clone.
  11540. *
  11541. * @private
  11542. * @param {Array} array The array to clone.
  11543. * @returns {Array} Returns the initialized clone.
  11544. */
  11545. function initCloneArray(array) {
  11546. var length = array.length,
  11547. result = new array.constructor(length);
  11548. // Add properties assigned by `RegExp#exec`.
  11549. if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
  11550. result.index = array.index;
  11551. result.input = array.input;
  11552. }
  11553. return result;
  11554. }
  11555. var _initCloneArray = initCloneArray;
  11556. /** Built-in value references. */
  11557. var Uint8Array = _root.Uint8Array;
  11558. var _Uint8Array = Uint8Array;
  11559. /**
  11560. * Creates a clone of `arrayBuffer`.
  11561. *
  11562. * @private
  11563. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  11564. * @returns {ArrayBuffer} Returns the cloned array buffer.
  11565. */
  11566. function cloneArrayBuffer(arrayBuffer) {
  11567. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  11568. new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  11569. return result;
  11570. }
  11571. var _cloneArrayBuffer = cloneArrayBuffer;
  11572. /**
  11573. * Creates a clone of `dataView`.
  11574. *
  11575. * @private
  11576. * @param {Object} dataView The data view to clone.
  11577. * @param {boolean} [isDeep] Specify a deep clone.
  11578. * @returns {Object} Returns the cloned data view.
  11579. */
  11580. function cloneDataView(dataView, isDeep) {
  11581. var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  11582. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  11583. }
  11584. var _cloneDataView = cloneDataView;
  11585. /** Used to match `RegExp` flags from their coerced string values. */
  11586. var reFlags = /\w*$/;
  11587. /**
  11588. * Creates a clone of `regexp`.
  11589. *
  11590. * @private
  11591. * @param {Object} regexp The regexp to clone.
  11592. * @returns {Object} Returns the cloned regexp.
  11593. */
  11594. function cloneRegExp(regexp) {
  11595. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  11596. result.lastIndex = regexp.lastIndex;
  11597. return result;
  11598. }
  11599. var _cloneRegExp = cloneRegExp;
  11600. /** Used to convert symbols to primitives and strings. */
  11601. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  11602. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  11603. /**
  11604. * Creates a clone of the `symbol` object.
  11605. *
  11606. * @private
  11607. * @param {Object} symbol The symbol object to clone.
  11608. * @returns {Object} Returns the cloned symbol object.
  11609. */
  11610. function cloneSymbol(symbol) {
  11611. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  11612. }
  11613. var _cloneSymbol = cloneSymbol;
  11614. /**
  11615. * Creates a clone of `typedArray`.
  11616. *
  11617. * @private
  11618. * @param {Object} typedArray The typed array to clone.
  11619. * @param {boolean} [isDeep] Specify a deep clone.
  11620. * @returns {Object} Returns the cloned typed array.
  11621. */
  11622. function cloneTypedArray(typedArray, isDeep) {
  11623. var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  11624. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  11625. }
  11626. var _cloneTypedArray = cloneTypedArray;
  11627. /** `Object#toString` result references. */
  11628. var boolTag$1 = '[object Boolean]',
  11629. dateTag$1 = '[object Date]',
  11630. mapTag$2 = '[object Map]',
  11631. numberTag$1 = '[object Number]',
  11632. regexpTag$1 = '[object RegExp]',
  11633. setTag$2 = '[object Set]',
  11634. stringTag$1 = '[object String]',
  11635. symbolTag = '[object Symbol]';
  11636. var arrayBufferTag$1 = '[object ArrayBuffer]',
  11637. dataViewTag$2 = '[object DataView]',
  11638. float32Tag$1 = '[object Float32Array]',
  11639. float64Tag$1 = '[object Float64Array]',
  11640. int8Tag$1 = '[object Int8Array]',
  11641. int16Tag$1 = '[object Int16Array]',
  11642. int32Tag$1 = '[object Int32Array]',
  11643. uint8Tag$1 = '[object Uint8Array]',
  11644. uint8ClampedTag$1 = '[object Uint8ClampedArray]',
  11645. uint16Tag$1 = '[object Uint16Array]',
  11646. uint32Tag$1 = '[object Uint32Array]';
  11647. /**
  11648. * Initializes an object clone based on its `toStringTag`.
  11649. *
  11650. * **Note:** This function only supports cloning values with tags of
  11651. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  11652. *
  11653. * @private
  11654. * @param {Object} object The object to clone.
  11655. * @param {string} tag The `toStringTag` of the object to clone.
  11656. * @param {boolean} [isDeep] Specify a deep clone.
  11657. * @returns {Object} Returns the initialized clone.
  11658. */
  11659. function initCloneByTag(object, tag, isDeep) {
  11660. var Ctor = object.constructor;
  11661. switch (tag) {
  11662. case arrayBufferTag$1:
  11663. return _cloneArrayBuffer(object);
  11664. case boolTag$1:
  11665. case dateTag$1:
  11666. return new Ctor(+object);
  11667. case dataViewTag$2:
  11668. return _cloneDataView(object, isDeep);
  11669. case float32Tag$1: case float64Tag$1:
  11670. case int8Tag$1: case int16Tag$1: case int32Tag$1:
  11671. case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
  11672. return _cloneTypedArray(object, isDeep);
  11673. case mapTag$2:
  11674. return new Ctor;
  11675. case numberTag$1:
  11676. case stringTag$1:
  11677. return new Ctor(object);
  11678. case regexpTag$1:
  11679. return _cloneRegExp(object);
  11680. case setTag$2:
  11681. return new Ctor;
  11682. case symbolTag:
  11683. return _cloneSymbol(object);
  11684. }
  11685. }
  11686. var _initCloneByTag = initCloneByTag;
  11687. /** Built-in value references. */
  11688. var objectCreate = Object.create;
  11689. /**
  11690. * The base implementation of `_.create` without support for assigning
  11691. * properties to the created object.
  11692. *
  11693. * @private
  11694. * @param {Object} proto The object to inherit from.
  11695. * @returns {Object} Returns the new object.
  11696. */
  11697. var baseCreate = (function() {
  11698. function object() {}
  11699. return function(proto) {
  11700. if (!isObject_1(proto)) {
  11701. return {};
  11702. }
  11703. if (objectCreate) {
  11704. return objectCreate(proto);
  11705. }
  11706. object.prototype = proto;
  11707. var result = new object;
  11708. object.prototype = undefined;
  11709. return result;
  11710. };
  11711. }());
  11712. var _baseCreate = baseCreate;
  11713. /**
  11714. * Initializes an object clone.
  11715. *
  11716. * @private
  11717. * @param {Object} object The object to clone.
  11718. * @returns {Object} Returns the initialized clone.
  11719. */
  11720. function initCloneObject(object) {
  11721. return (typeof object.constructor == 'function' && !_isPrototype(object))
  11722. ? _baseCreate(_getPrototype(object))
  11723. : {};
  11724. }
  11725. var _initCloneObject = initCloneObject;
  11726. /** `Object#toString` result references. */
  11727. var mapTag$3 = '[object Map]';
  11728. /**
  11729. * The base implementation of `_.isMap` without Node.js optimizations.
  11730. *
  11731. * @private
  11732. * @param {*} value The value to check.
  11733. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11734. */
  11735. function baseIsMap(value) {
  11736. return isObjectLike_1(value) && _getTag(value) == mapTag$3;
  11737. }
  11738. var _baseIsMap = baseIsMap;
  11739. /* Node.js helper references. */
  11740. var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
  11741. /**
  11742. * Checks if `value` is classified as a `Map` object.
  11743. *
  11744. * @static
  11745. * @memberOf _
  11746. * @since 4.3.0
  11747. * @category Lang
  11748. * @param {*} value The value to check.
  11749. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11750. * @example
  11751. *
  11752. * _.isMap(new Map);
  11753. * // => true
  11754. *
  11755. * _.isMap(new WeakMap);
  11756. * // => false
  11757. */
  11758. var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
  11759. var isMap_1 = isMap;
  11760. /** `Object#toString` result references. */
  11761. var setTag$3 = '[object Set]';
  11762. /**
  11763. * The base implementation of `_.isSet` without Node.js optimizations.
  11764. *
  11765. * @private
  11766. * @param {*} value The value to check.
  11767. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  11768. */
  11769. function baseIsSet(value) {
  11770. return isObjectLike_1(value) && _getTag(value) == setTag$3;
  11771. }
  11772. var _baseIsSet = baseIsSet;
  11773. /* Node.js helper references. */
  11774. var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
  11775. /**
  11776. * Checks if `value` is classified as a `Set` object.
  11777. *
  11778. * @static
  11779. * @memberOf _
  11780. * @since 4.3.0
  11781. * @category Lang
  11782. * @param {*} value The value to check.
  11783. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  11784. * @example
  11785. *
  11786. * _.isSet(new Set);
  11787. * // => true
  11788. *
  11789. * _.isSet(new WeakSet);
  11790. * // => false
  11791. */
  11792. var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
  11793. var isSet_1 = isSet;
  11794. /** Used to compose bitmasks for cloning. */
  11795. var CLONE_DEEP_FLAG = 1,
  11796. CLONE_FLAT_FLAG = 2,
  11797. CLONE_SYMBOLS_FLAG = 4;
  11798. /** `Object#toString` result references. */
  11799. var argsTag$2 = '[object Arguments]',
  11800. arrayTag$1 = '[object Array]',
  11801. boolTag$2 = '[object Boolean]',
  11802. dateTag$2 = '[object Date]',
  11803. errorTag$1 = '[object Error]',
  11804. funcTag$2 = '[object Function]',
  11805. genTag$1 = '[object GeneratorFunction]',
  11806. mapTag$4 = '[object Map]',
  11807. numberTag$2 = '[object Number]',
  11808. objectTag$2 = '[object Object]',
  11809. regexpTag$2 = '[object RegExp]',
  11810. setTag$4 = '[object Set]',
  11811. stringTag$2 = '[object String]',
  11812. symbolTag$1 = '[object Symbol]',
  11813. weakMapTag$2 = '[object WeakMap]';
  11814. var arrayBufferTag$2 = '[object ArrayBuffer]',
  11815. dataViewTag$3 = '[object DataView]',
  11816. float32Tag$2 = '[object Float32Array]',
  11817. float64Tag$2 = '[object Float64Array]',
  11818. int8Tag$2 = '[object Int8Array]',
  11819. int16Tag$2 = '[object Int16Array]',
  11820. int32Tag$2 = '[object Int32Array]',
  11821. uint8Tag$2 = '[object Uint8Array]',
  11822. uint8ClampedTag$2 = '[object Uint8ClampedArray]',
  11823. uint16Tag$2 = '[object Uint16Array]',
  11824. uint32Tag$2 = '[object Uint32Array]';
  11825. /** Used to identify `toStringTag` values supported by `_.clone`. */
  11826. var cloneableTags = {};
  11827. cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
  11828. cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
  11829. cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
  11830. cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
  11831. cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
  11832. cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
  11833. cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
  11834. cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
  11835. cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
  11836. cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
  11837. cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
  11838. cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
  11839. cloneableTags[weakMapTag$2] = false;
  11840. /**
  11841. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  11842. * traversed objects.
  11843. *
  11844. * @private
  11845. * @param {*} value The value to clone.
  11846. * @param {boolean} bitmask The bitmask flags.
  11847. * 1 - Deep clone
  11848. * 2 - Flatten inherited properties
  11849. * 4 - Clone symbols
  11850. * @param {Function} [customizer] The function to customize cloning.
  11851. * @param {string} [key] The key of `value`.
  11852. * @param {Object} [object] The parent object of `value`.
  11853. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  11854. * @returns {*} Returns the cloned value.
  11855. */
  11856. function baseClone(value, bitmask, customizer, key, object, stack) {
  11857. var result,
  11858. isDeep = bitmask & CLONE_DEEP_FLAG,
  11859. isFlat = bitmask & CLONE_FLAT_FLAG,
  11860. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  11861. if (customizer) {
  11862. result = object ? customizer(value, key, object, stack) : customizer(value);
  11863. }
  11864. if (result !== undefined) {
  11865. return result;
  11866. }
  11867. if (!isObject_1(value)) {
  11868. return value;
  11869. }
  11870. var isArr = isArray_1(value);
  11871. if (isArr) {
  11872. result = _initCloneArray(value);
  11873. if (!isDeep) {
  11874. return _copyArray(value, result);
  11875. }
  11876. } else {
  11877. var tag = _getTag(value),
  11878. isFunc = tag == funcTag$2 || tag == genTag$1;
  11879. if (isBuffer_1$1(value)) {
  11880. return _cloneBuffer(value, isDeep);
  11881. }
  11882. if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
  11883. result = (isFlat || isFunc) ? {} : _initCloneObject(value);
  11884. if (!isDeep) {
  11885. return isFlat
  11886. ? _copySymbolsIn(value, _baseAssignIn(result, value))
  11887. : _copySymbols(value, _baseAssign(result, value));
  11888. }
  11889. } else {
  11890. if (!cloneableTags[tag]) {
  11891. return object ? value : {};
  11892. }
  11893. result = _initCloneByTag(value, tag, isDeep);
  11894. }
  11895. }
  11896. // Check for circular references and return its corresponding clone.
  11897. stack || (stack = new _Stack);
  11898. var stacked = stack.get(value);
  11899. if (stacked) {
  11900. return stacked;
  11901. }
  11902. stack.set(value, result);
  11903. if (isSet_1(value)) {
  11904. value.forEach(function(subValue) {
  11905. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  11906. });
  11907. } else if (isMap_1(value)) {
  11908. value.forEach(function(subValue, key) {
  11909. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  11910. });
  11911. }
  11912. var keysFunc = isFull
  11913. ? (isFlat ? _getAllKeysIn : _getAllKeys)
  11914. : (isFlat ? keysIn_1 : keys_1);
  11915. var props = isArr ? undefined : keysFunc(value);
  11916. _arrayEach(props || value, function(subValue, key) {
  11917. if (props) {
  11918. key = subValue;
  11919. subValue = value[key];
  11920. }
  11921. // Recursively populate clone (susceptible to call stack limits).
  11922. _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  11923. });
  11924. return result;
  11925. }
  11926. var _baseClone = baseClone;
  11927. /** Used to compose bitmasks for cloning. */
  11928. var CLONE_DEEP_FLAG$1 = 1,
  11929. CLONE_SYMBOLS_FLAG$1 = 4;
  11930. /**
  11931. * This method is like `_.clone` except that it recursively clones `value`.
  11932. *
  11933. * @static
  11934. * @memberOf _
  11935. * @since 1.0.0
  11936. * @category Lang
  11937. * @param {*} value The value to recursively clone.
  11938. * @returns {*} Returns the deep cloned value.
  11939. * @see _.clone
  11940. * @example
  11941. *
  11942. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11943. *
  11944. * var deep = _.cloneDeep(objects);
  11945. * console.log(deep[0] === objects[0]);
  11946. * // => false
  11947. */
  11948. function cloneDeep(value) {
  11949. return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
  11950. }
  11951. var cloneDeep_1 = cloneDeep;
  11952. //
  11953. /**
  11954. * Used internally by vue-server-test-utils and test-utils to propagate/create vue instances.
  11955. * This method is wrapped by createLocalVue in test-utils to provide a different public API signature
  11956. * @param {Component} _Vue
  11957. * @param {VueConfig} config
  11958. * @returns {Component}
  11959. */
  11960. function _createLocalVue(
  11961. _Vue,
  11962. config
  11963. ) {
  11964. if ( _Vue === void 0 ) _Vue = Vue__default['default'];
  11965. if ( config === void 0 ) config = {};
  11966. var instance = _Vue.extend();
  11967. // clone global APIs
  11968. Object.keys(_Vue).forEach(function (key) {
  11969. if (!instance.hasOwnProperty(key)) {
  11970. var original = _Vue[key];
  11971. // cloneDeep can fail when cloning Vue instances
  11972. // cloneDeep checks that the instance has a Symbol
  11973. // which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
  11974. try {
  11975. instance[key] =
  11976. typeof original === 'object' ? cloneDeep_1(original) : original;
  11977. } catch (e) {
  11978. instance[key] = original;
  11979. }
  11980. }
  11981. });
  11982. // config is not enumerable
  11983. instance.config = cloneDeep_1(Vue__default['default'].config);
  11984. // if a user defined errorHandler is defined by a localVue instance via createLocalVue, register it
  11985. instance.config.errorHandler = config.errorHandler;
  11986. // option merge strategies need to be exposed by reference
  11987. // so that merge strats registered by plugins can work properly
  11988. instance.config.optionMergeStrategies = Vue__default['default'].config.optionMergeStrategies;
  11989. // make sure all extends are based on this instance.
  11990. // this is important so that global components registered by plugins,
  11991. // e.g. router-link are created using the correct base constructor
  11992. instance.options._base = instance;
  11993. // compat for vue-router < 2.7.1 where it does not allow multiple installs
  11994. if (instance._installedPlugins && instance._installedPlugins.length) {
  11995. instance._installedPlugins.length = 0;
  11996. }
  11997. var use = instance.use;
  11998. instance.use = function (plugin) {
  11999. var rest = [], len = arguments.length - 1;
  12000. while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
  12001. if (plugin.installed === true) {
  12002. plugin.installed = false;
  12003. }
  12004. if (plugin.install && plugin.install.installed === true) {
  12005. plugin.install.installed = false;
  12006. }
  12007. use.call.apply(use, [ instance, plugin ].concat( rest ));
  12008. };
  12009. return instance
  12010. }
  12011. //
  12012. function isValidSlot(slot) {
  12013. return isVueComponent(slot) || typeof slot === 'string'
  12014. }
  12015. function requiresTemplateCompiler(slot) {
  12016. if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) {
  12017. throwError(
  12018. "vueTemplateCompiler is undefined, you must pass " +
  12019. "precompiled components if vue-template-compiler is " +
  12020. "undefined"
  12021. );
  12022. }
  12023. }
  12024. function validateSlots(slots) {
  12025. Object.keys(slots).forEach(function (key) {
  12026. var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
  12027. slot.forEach(function (slotValue) {
  12028. if (!isValidSlot(slotValue)) {
  12029. throwError(
  12030. "slots[key] must be a Component, string or an array " +
  12031. "of Components"
  12032. );
  12033. }
  12034. requiresTemplateCompiler(slotValue);
  12035. });
  12036. });
  12037. }
  12038. function vueExtendUnsupportedOption(option) {
  12039. return (
  12040. "options." + option + " is not supported for " +
  12041. "components created with Vue.extend in Vue < 2.3. " +
  12042. "You can set " + option + " to false to mount the component."
  12043. )
  12044. }
  12045. // these options aren't supported if Vue is version < 2.3
  12046. // for components using Vue.extend. This is due to a bug
  12047. // that means the mixins we use to add properties are not applied
  12048. // correctly
  12049. var UNSUPPORTED_VERSION_OPTIONS = ['mocks', 'stubs', 'localVue'];
  12050. function validateOptions(options, component) {
  12051. if (
  12052. options.attachTo &&
  12053. !isHTMLElement(options.attachTo) &&
  12054. !isDomSelector(options.attachTo)
  12055. ) {
  12056. throwError(
  12057. "options.attachTo should be a valid HTMLElement or CSS selector string"
  12058. );
  12059. }
  12060. if ('attachToDocument' in options) {
  12061. warnDeprecated(
  12062. "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
  12063. );
  12064. }
  12065. if (options.parentComponent && !isPlainObject(options.parentComponent)) {
  12066. throwError(
  12067. "options.parentComponent should be a valid Vue component options object"
  12068. );
  12069. }
  12070. if (!isFunctionalComponent(component) && options.context) {
  12071. throwError(
  12072. "mount.context can only be used when mounting a functional component"
  12073. );
  12074. }
  12075. if (options.context && !isPlainObject(options.context)) {
  12076. throwError('mount.context must be an object');
  12077. }
  12078. if (VUE_VERSION < 2.3 && isConstructor(component)) {
  12079. UNSUPPORTED_VERSION_OPTIONS.forEach(function (option) {
  12080. if (options[option]) {
  12081. throwError(vueExtendUnsupportedOption(option));
  12082. }
  12083. });
  12084. }
  12085. if (options.slots) {
  12086. compileTemplateForSlots(options.slots);
  12087. // validate slots outside of the createSlots function so
  12088. // that we can throw an error without it being caught by
  12089. // the Vue error handler
  12090. // $FlowIgnore
  12091. validateSlots(options.slots);
  12092. }
  12093. }
  12094. Vue__default['default'].config.productionTip = false;
  12095. Vue__default['default'].config.devtools = false;
  12096. function mount(component, options) {
  12097. if ( options === void 0 ) options = {};
  12098. warnIfNoWindow();
  12099. polyfill();
  12100. addGlobalErrorHandler(Vue__default['default']);
  12101. var _Vue = _createLocalVue(
  12102. options.localVue,
  12103. options.localVue ? options.localVue.config : undefined
  12104. );
  12105. var mergedOptions = mergeOptions(options, config);
  12106. validateOptions(mergedOptions, component);
  12107. var parentVm = createInstance(component, mergedOptions, _Vue);
  12108. var el =
  12109. options.attachToDocument || options.attachTo instanceof HTMLBodyElement
  12110. ? createElement()
  12111. : options.attachTo;
  12112. var vm = parentVm.$mount(el);
  12113. component._Ctor = {};
  12114. throwIfInstancesThrew(vm);
  12115. var wrapperOptions = {
  12116. attachedToDocument: !!el
  12117. };
  12118. var root = parentVm.$options._isFunctionalContainer
  12119. ? vm._vnode
  12120. : vm.$children[0];
  12121. return createWrapper(root, wrapperOptions)
  12122. }
  12123. //
  12124. function shallowMount(
  12125. component,
  12126. options
  12127. ) {
  12128. if ( options === void 0 ) options = {};
  12129. return mount(component, Object.assign({}, options,
  12130. {shouldProxy: true}))
  12131. }
  12132. //
  12133. /**
  12134. * Returns a local vue instance to add components, mixins and install plugins without polluting the global Vue class
  12135. * @param {VueConfig} config
  12136. * @returns {Component}
  12137. */
  12138. function createLocalVue(config) {
  12139. if ( config === void 0 ) config = {};
  12140. return _createLocalVue(undefined, config)
  12141. }
  12142. //
  12143. var toTypes = [String, Object];
  12144. var eventTypes = [String, Array];
  12145. var RouterLinkStub = {
  12146. name: 'RouterLinkStub',
  12147. props: {
  12148. to: {
  12149. type: toTypes,
  12150. required: true
  12151. },
  12152. tag: {
  12153. type: String,
  12154. default: 'a'
  12155. },
  12156. exact: Boolean,
  12157. exactPath: Boolean,
  12158. append: Boolean,
  12159. replace: Boolean,
  12160. activeClass: String,
  12161. exactActiveClass: String,
  12162. exactPathActiveClass: String,
  12163. event: {
  12164. type: eventTypes,
  12165. default: 'click'
  12166. }
  12167. },
  12168. render: function render(h) {
  12169. return h(this.tag, undefined, this.$slots.default)
  12170. }
  12171. };
  12172. function shallow(component, options) {
  12173. warn(
  12174. "shallow has been renamed to shallowMount. shallow " +
  12175. "will be removed in 1.0.0, use shallowMount instead"
  12176. );
  12177. return shallowMount(component, options)
  12178. }
  12179. exports.ErrorWrapper = ErrorWrapper;
  12180. exports.RouterLinkStub = RouterLinkStub;
  12181. exports.Wrapper = Wrapper;
  12182. exports.WrapperArray = WrapperArray;
  12183. exports.config = config;
  12184. exports.createLocalVue = createLocalVue;
  12185. exports.createWrapper = createWrapper;
  12186. exports.enableAutoDestroy = enableAutoDestroy;
  12187. exports.mount = mount;
  12188. exports.resetAutoDestroyState = resetAutoDestroyState;
  12189. exports.shallow = shallow;
  12190. exports.shallowMount = shallowMount;