vue.runtime.common.dev.js 283 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715
  1. /*!
  2. * Vue.js v2.7.14
  3. * (c) 2014-2022 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. const emptyObject = Object.freeze({});
  8. const isArray = Array.isArray;
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef(v) {
  12. return v === undefined || v === null;
  13. }
  14. function isDef(v) {
  15. return v !== undefined && v !== null;
  16. }
  17. function isTrue(v) {
  18. return v === true;
  19. }
  20. function isFalse(v) {
  21. return v === false;
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive(value) {
  27. return (typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean');
  32. }
  33. function isFunction(value) {
  34. return typeof value === 'function';
  35. }
  36. /**
  37. * Quick object check - this is primarily used to tell
  38. * objects from primitive values when we know the value
  39. * is a JSON-compliant type.
  40. */
  41. function isObject(obj) {
  42. return obj !== null && typeof obj === 'object';
  43. }
  44. /**
  45. * Get the raw type string of a value, e.g., [object Object].
  46. */
  47. const _toString = Object.prototype.toString;
  48. function toRawType(value) {
  49. return _toString.call(value).slice(8, -1);
  50. }
  51. /**
  52. * Strict object type check. Only returns true
  53. * for plain JavaScript objects.
  54. */
  55. function isPlainObject(obj) {
  56. return _toString.call(obj) === '[object Object]';
  57. }
  58. function isRegExp(v) {
  59. return _toString.call(v) === '[object RegExp]';
  60. }
  61. /**
  62. * Check if val is a valid array index.
  63. */
  64. function isValidArrayIndex(val) {
  65. const n = parseFloat(String(val));
  66. return n >= 0 && Math.floor(n) === n && isFinite(val);
  67. }
  68. function isPromise(val) {
  69. return (isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function');
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString(val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val);
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber(val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n;
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap(str, expectsLowerCase) {
  96. const map = Object.create(null);
  97. const list = str.split(',');
  98. for (let i = 0; i < list.length; i++) {
  99. map[list[i]] = true;
  100. }
  101. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  102. }
  103. /**
  104. * Check if a tag is a built-in tag.
  105. */
  106. const isBuiltInTag = makeMap('slot,component', true);
  107. /**
  108. * Check if an attribute is a reserved attribute.
  109. */
  110. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  111. /**
  112. * Remove an item from an array.
  113. */
  114. function remove$2(arr, item) {
  115. const len = arr.length;
  116. if (len) {
  117. // fast path for the only / last item
  118. if (item === arr[len - 1]) {
  119. arr.length = len - 1;
  120. return;
  121. }
  122. const index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1);
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. const hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn(obj, key) {
  133. return hasOwnProperty.call(obj, key);
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached(fn) {
  139. const cache = Object.create(null);
  140. return function cachedFn(str) {
  141. const hit = cache[str];
  142. return hit || (cache[str] = fn(str));
  143. };
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. const camelizeRE = /-(\w)/g;
  149. const camelize = cached((str) => {
  150. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. const capitalize = cached((str) => {
  156. return str.charAt(0).toUpperCase() + str.slice(1);
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. const hyphenateRE = /\B([A-Z])/g;
  162. const hyphenate = cached((str) => {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase();
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind(fn, ctx) {
  174. function boundFn(a) {
  175. const l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx);
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn;
  184. }
  185. function nativeBind(fn, ctx) {
  186. return fn.bind(ctx);
  187. }
  188. // @ts-expect-error bind cannot be `undefined`
  189. const bind = Function.prototype.bind ? nativeBind : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray(list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret;
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend(to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to;
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject(arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res;
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop(a, b, c) { }
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Check if two values are loosely equal - that is,
  241. * if they are plain objects, do they have the same shape?
  242. */
  243. function looseEqual(a, b) {
  244. if (a === b)
  245. return true;
  246. const isObjectA = isObject(a);
  247. const isObjectB = isObject(b);
  248. if (isObjectA && isObjectB) {
  249. try {
  250. const isArrayA = Array.isArray(a);
  251. const isArrayB = Array.isArray(b);
  252. if (isArrayA && isArrayB) {
  253. return (a.length === b.length &&
  254. a.every((e, i) => {
  255. return looseEqual(e, b[i]);
  256. }));
  257. }
  258. else if (a instanceof Date && b instanceof Date) {
  259. return a.getTime() === b.getTime();
  260. }
  261. else if (!isArrayA && !isArrayB) {
  262. const keysA = Object.keys(a);
  263. const keysB = Object.keys(b);
  264. return (keysA.length === keysB.length &&
  265. keysA.every(key => {
  266. return looseEqual(a[key], b[key]);
  267. }));
  268. }
  269. else {
  270. /* istanbul ignore next */
  271. return false;
  272. }
  273. }
  274. catch (e) {
  275. /* istanbul ignore next */
  276. return false;
  277. }
  278. }
  279. else if (!isObjectA && !isObjectB) {
  280. return String(a) === String(b);
  281. }
  282. else {
  283. return false;
  284. }
  285. }
  286. /**
  287. * Return the first index at which a loosely equal value can be
  288. * found in the array (if value is a plain object, the array must
  289. * contain an object of the same shape), or -1 if it is not present.
  290. */
  291. function looseIndexOf(arr, val) {
  292. for (let i = 0; i < arr.length; i++) {
  293. if (looseEqual(arr[i], val))
  294. return i;
  295. }
  296. return -1;
  297. }
  298. /**
  299. * Ensure a function is called only once.
  300. */
  301. function once(fn) {
  302. let called = false;
  303. return function () {
  304. if (!called) {
  305. called = true;
  306. fn.apply(this, arguments);
  307. }
  308. };
  309. }
  310. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  311. function hasChanged(x, y) {
  312. if (x === y) {
  313. return x === 0 && 1 / x !== 1 / y;
  314. }
  315. else {
  316. return x === x || y === y;
  317. }
  318. }
  319. const SSR_ATTR = 'data-server-rendered';
  320. const ASSET_TYPES = ['component', 'directive', 'filter'];
  321. const LIFECYCLE_HOOKS = [
  322. 'beforeCreate',
  323. 'created',
  324. 'beforeMount',
  325. 'mounted',
  326. 'beforeUpdate',
  327. 'updated',
  328. 'beforeDestroy',
  329. 'destroyed',
  330. 'activated',
  331. 'deactivated',
  332. 'errorCaptured',
  333. 'serverPrefetch',
  334. 'renderTracked',
  335. 'renderTriggered'
  336. ];
  337. var config = {
  338. /**
  339. * Option merge strategies (used in core/util/options)
  340. */
  341. // $flow-disable-line
  342. optionMergeStrategies: Object.create(null),
  343. /**
  344. * Whether to suppress warnings.
  345. */
  346. silent: false,
  347. /**
  348. * Show production mode tip message on boot?
  349. */
  350. productionTip: true,
  351. /**
  352. * Whether to enable devtools
  353. */
  354. devtools: true,
  355. /**
  356. * Whether to record perf
  357. */
  358. performance: false,
  359. /**
  360. * Error handler for watcher errors
  361. */
  362. errorHandler: null,
  363. /**
  364. * Warn handler for watcher warns
  365. */
  366. warnHandler: null,
  367. /**
  368. * Ignore certain custom elements
  369. */
  370. ignoredElements: [],
  371. /**
  372. * Custom user key aliases for v-on
  373. */
  374. // $flow-disable-line
  375. keyCodes: Object.create(null),
  376. /**
  377. * Check if a tag is reserved so that it cannot be registered as a
  378. * component. This is platform-dependent and may be overwritten.
  379. */
  380. isReservedTag: no,
  381. /**
  382. * Check if an attribute is reserved so that it cannot be used as a component
  383. * prop. This is platform-dependent and may be overwritten.
  384. */
  385. isReservedAttr: no,
  386. /**
  387. * Check if a tag is an unknown element.
  388. * Platform-dependent.
  389. */
  390. isUnknownElement: no,
  391. /**
  392. * Get the namespace of an element
  393. */
  394. getTagNamespace: noop,
  395. /**
  396. * Parse the real tag name for the specific platform.
  397. */
  398. parsePlatformTagName: identity,
  399. /**
  400. * Check if an attribute must be bound using property, e.g. value
  401. * Platform-dependent.
  402. */
  403. mustUseProp: no,
  404. /**
  405. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  406. * This will significantly reduce performance if set to false.
  407. */
  408. async: true,
  409. /**
  410. * Exposed for legacy reasons
  411. */
  412. _lifecycleHooks: LIFECYCLE_HOOKS
  413. };
  414. /**
  415. * unicode letters used for parsing html tags, component names and property paths.
  416. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  417. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  418. */
  419. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  420. /**
  421. * Check if a string starts with $ or _
  422. */
  423. function isReserved(str) {
  424. const c = (str + '').charCodeAt(0);
  425. return c === 0x24 || c === 0x5f;
  426. }
  427. /**
  428. * Define a property.
  429. */
  430. function def(obj, key, val, enumerable) {
  431. Object.defineProperty(obj, key, {
  432. value: val,
  433. enumerable: !!enumerable,
  434. writable: true,
  435. configurable: true
  436. });
  437. }
  438. /**
  439. * Parse simple path.
  440. */
  441. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  442. function parsePath(path) {
  443. if (bailRE.test(path)) {
  444. return;
  445. }
  446. const segments = path.split('.');
  447. return function (obj) {
  448. for (let i = 0; i < segments.length; i++) {
  449. if (!obj)
  450. return;
  451. obj = obj[segments[i]];
  452. }
  453. return obj;
  454. };
  455. }
  456. // can we use __proto__?
  457. const hasProto = '__proto__' in {};
  458. // Browser environment sniffing
  459. const inBrowser = typeof window !== 'undefined';
  460. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  461. const isIE = UA && /msie|trident/.test(UA);
  462. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  463. const isEdge = UA && UA.indexOf('edge/') > 0;
  464. UA && UA.indexOf('android') > 0;
  465. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  466. UA && /chrome\/\d+/.test(UA) && !isEdge;
  467. UA && /phantomjs/.test(UA);
  468. const isFF = UA && UA.match(/firefox\/(\d+)/);
  469. // Firefox has a "watch" function on Object.prototype...
  470. // @ts-expect-error firebox support
  471. const nativeWatch = {}.watch;
  472. let supportsPassive = false;
  473. if (inBrowser) {
  474. try {
  475. const opts = {};
  476. Object.defineProperty(opts, 'passive', {
  477. get() {
  478. /* istanbul ignore next */
  479. supportsPassive = true;
  480. }
  481. }); // https://github.com/facebook/flow/issues/285
  482. window.addEventListener('test-passive', null, opts);
  483. }
  484. catch (e) { }
  485. }
  486. // this needs to be lazy-evaled because vue may be required before
  487. // vue-server-renderer can set VUE_ENV
  488. let _isServer;
  489. const isServerRendering = () => {
  490. if (_isServer === undefined) {
  491. /* istanbul ignore if */
  492. if (!inBrowser && typeof global !== 'undefined') {
  493. // detect presence of vue-server-renderer and avoid
  494. // Webpack shimming the process
  495. _isServer =
  496. global['process'] && global['process'].env.VUE_ENV === 'server';
  497. }
  498. else {
  499. _isServer = false;
  500. }
  501. }
  502. return _isServer;
  503. };
  504. // detect devtools
  505. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  506. /* istanbul ignore next */
  507. function isNative(Ctor) {
  508. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  509. }
  510. const hasSymbol = typeof Symbol !== 'undefined' &&
  511. isNative(Symbol) &&
  512. typeof Reflect !== 'undefined' &&
  513. isNative(Reflect.ownKeys);
  514. let _Set; // $flow-disable-line
  515. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  516. // use native Set when available.
  517. _Set = Set;
  518. }
  519. else {
  520. // a non-standard Set polyfill that only works with primitive keys.
  521. _Set = class Set {
  522. constructor() {
  523. this.set = Object.create(null);
  524. }
  525. has(key) {
  526. return this.set[key] === true;
  527. }
  528. add(key) {
  529. this.set[key] = true;
  530. }
  531. clear() {
  532. this.set = Object.create(null);
  533. }
  534. };
  535. }
  536. let currentInstance = null;
  537. /**
  538. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  539. * relies on it). Do not use this internally, just use `currentInstance`.
  540. *
  541. * @internal this function needs manual type declaration because it relies
  542. * on previously manually authored types from Vue 2
  543. */
  544. function getCurrentInstance() {
  545. return currentInstance && { proxy: currentInstance };
  546. }
  547. /**
  548. * @internal
  549. */
  550. function setCurrentInstance(vm = null) {
  551. if (!vm)
  552. currentInstance && currentInstance._scope.off();
  553. currentInstance = vm;
  554. vm && vm._scope.on();
  555. }
  556. /**
  557. * @internal
  558. */
  559. class VNode {
  560. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  561. this.tag = tag;
  562. this.data = data;
  563. this.children = children;
  564. this.text = text;
  565. this.elm = elm;
  566. this.ns = undefined;
  567. this.context = context;
  568. this.fnContext = undefined;
  569. this.fnOptions = undefined;
  570. this.fnScopeId = undefined;
  571. this.key = data && data.key;
  572. this.componentOptions = componentOptions;
  573. this.componentInstance = undefined;
  574. this.parent = undefined;
  575. this.raw = false;
  576. this.isStatic = false;
  577. this.isRootInsert = true;
  578. this.isComment = false;
  579. this.isCloned = false;
  580. this.isOnce = false;
  581. this.asyncFactory = asyncFactory;
  582. this.asyncMeta = undefined;
  583. this.isAsyncPlaceholder = false;
  584. }
  585. // DEPRECATED: alias for componentInstance for backwards compat.
  586. /* istanbul ignore next */
  587. get child() {
  588. return this.componentInstance;
  589. }
  590. }
  591. const createEmptyVNode = (text = '') => {
  592. const node = new VNode();
  593. node.text = text;
  594. node.isComment = true;
  595. return node;
  596. };
  597. function createTextVNode(val) {
  598. return new VNode(undefined, undefined, undefined, String(val));
  599. }
  600. // optimized shallow clone
  601. // used for static nodes and slot nodes because they may be reused across
  602. // multiple renders, cloning them avoids errors when DOM manipulations rely
  603. // on their elm reference.
  604. function cloneVNode(vnode) {
  605. const cloned = new VNode(vnode.tag, vnode.data,
  606. // #7975
  607. // clone children array to avoid mutating original in case of cloning
  608. // a child.
  609. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  610. cloned.ns = vnode.ns;
  611. cloned.isStatic = vnode.isStatic;
  612. cloned.key = vnode.key;
  613. cloned.isComment = vnode.isComment;
  614. cloned.fnContext = vnode.fnContext;
  615. cloned.fnOptions = vnode.fnOptions;
  616. cloned.fnScopeId = vnode.fnScopeId;
  617. cloned.asyncMeta = vnode.asyncMeta;
  618. cloned.isCloned = true;
  619. return cloned;
  620. }
  621. let uid$2 = 0;
  622. const pendingCleanupDeps = [];
  623. const cleanupDeps = () => {
  624. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  625. const dep = pendingCleanupDeps[i];
  626. dep.subs = dep.subs.filter(s => s);
  627. dep._pending = false;
  628. }
  629. pendingCleanupDeps.length = 0;
  630. };
  631. /**
  632. * A dep is an observable that can have multiple
  633. * directives subscribing to it.
  634. * @internal
  635. */
  636. class Dep {
  637. constructor() {
  638. // pending subs cleanup
  639. this._pending = false;
  640. this.id = uid$2++;
  641. this.subs = [];
  642. }
  643. addSub(sub) {
  644. this.subs.push(sub);
  645. }
  646. removeSub(sub) {
  647. // #12696 deps with massive amount of subscribers are extremely slow to
  648. // clean up in Chromium
  649. // to workaround this, we unset the sub for now, and clear them on
  650. // next scheduler flush.
  651. this.subs[this.subs.indexOf(sub)] = null;
  652. if (!this._pending) {
  653. this._pending = true;
  654. pendingCleanupDeps.push(this);
  655. }
  656. }
  657. depend(info) {
  658. if (Dep.target) {
  659. Dep.target.addDep(this);
  660. if (info && Dep.target.onTrack) {
  661. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  662. }
  663. }
  664. }
  665. notify(info) {
  666. // stabilize the subscriber list first
  667. const subs = this.subs.filter(s => s);
  668. if (!config.async) {
  669. // subs aren't sorted in scheduler if not running async
  670. // we need to sort them now to make sure they fire in correct
  671. // order
  672. subs.sort((a, b) => a.id - b.id);
  673. }
  674. for (let i = 0, l = subs.length; i < l; i++) {
  675. const sub = subs[i];
  676. if (info) {
  677. sub.onTrigger &&
  678. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  679. }
  680. sub.update();
  681. }
  682. }
  683. }
  684. // The current target watcher being evaluated.
  685. // This is globally unique because only one watcher
  686. // can be evaluated at a time.
  687. Dep.target = null;
  688. const targetStack = [];
  689. function pushTarget(target) {
  690. targetStack.push(target);
  691. Dep.target = target;
  692. }
  693. function popTarget() {
  694. targetStack.pop();
  695. Dep.target = targetStack[targetStack.length - 1];
  696. }
  697. /*
  698. * not type checking this file because flow doesn't play well with
  699. * dynamically accessing methods on Array prototype
  700. */
  701. const arrayProto = Array.prototype;
  702. const arrayMethods = Object.create(arrayProto);
  703. const methodsToPatch = [
  704. 'push',
  705. 'pop',
  706. 'shift',
  707. 'unshift',
  708. 'splice',
  709. 'sort',
  710. 'reverse'
  711. ];
  712. /**
  713. * Intercept mutating methods and emit events
  714. */
  715. methodsToPatch.forEach(function (method) {
  716. // cache original method
  717. const original = arrayProto[method];
  718. def(arrayMethods, method, function mutator(...args) {
  719. const result = original.apply(this, args);
  720. const ob = this.__ob__;
  721. let inserted;
  722. switch (method) {
  723. case 'push':
  724. case 'unshift':
  725. inserted = args;
  726. break;
  727. case 'splice':
  728. inserted = args.slice(2);
  729. break;
  730. }
  731. if (inserted)
  732. ob.observeArray(inserted);
  733. // notify change
  734. {
  735. ob.dep.notify({
  736. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  737. target: this,
  738. key: method
  739. });
  740. }
  741. return result;
  742. });
  743. });
  744. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  745. const NO_INIITIAL_VALUE = {};
  746. /**
  747. * In some cases we may want to disable observation inside a component's
  748. * update computation.
  749. */
  750. let shouldObserve = true;
  751. function toggleObserving(value) {
  752. shouldObserve = value;
  753. }
  754. // ssr mock dep
  755. const mockDep = {
  756. notify: noop,
  757. depend: noop,
  758. addSub: noop,
  759. removeSub: noop
  760. };
  761. /**
  762. * Observer class that is attached to each observed
  763. * object. Once attached, the observer converts the target
  764. * object's property keys into getter/setters that
  765. * collect dependencies and dispatch updates.
  766. */
  767. class Observer {
  768. constructor(value, shallow = false, mock = false) {
  769. this.value = value;
  770. this.shallow = shallow;
  771. this.mock = mock;
  772. // this.value = value
  773. this.dep = mock ? mockDep : new Dep();
  774. this.vmCount = 0;
  775. def(value, '__ob__', this);
  776. if (isArray(value)) {
  777. if (!mock) {
  778. if (hasProto) {
  779. value.__proto__ = arrayMethods;
  780. /* eslint-enable no-proto */
  781. }
  782. else {
  783. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  784. const key = arrayKeys[i];
  785. def(value, key, arrayMethods[key]);
  786. }
  787. }
  788. }
  789. if (!shallow) {
  790. this.observeArray(value);
  791. }
  792. }
  793. else {
  794. /**
  795. * Walk through all properties and convert them into
  796. * getter/setters. This method should only be called when
  797. * value type is Object.
  798. */
  799. const keys = Object.keys(value);
  800. for (let i = 0; i < keys.length; i++) {
  801. const key = keys[i];
  802. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  803. }
  804. }
  805. }
  806. /**
  807. * Observe a list of Array items.
  808. */
  809. observeArray(value) {
  810. for (let i = 0, l = value.length; i < l; i++) {
  811. observe(value[i], false, this.mock);
  812. }
  813. }
  814. }
  815. // helpers
  816. /**
  817. * Attempt to create an observer instance for a value,
  818. * returns the new observer if successfully observed,
  819. * or the existing observer if the value already has one.
  820. */
  821. function observe(value, shallow, ssrMockReactivity) {
  822. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  823. return value.__ob__;
  824. }
  825. if (shouldObserve &&
  826. (ssrMockReactivity || !isServerRendering()) &&
  827. (isArray(value) || isPlainObject(value)) &&
  828. Object.isExtensible(value) &&
  829. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  830. !isRef(value) &&
  831. !(value instanceof VNode)) {
  832. return new Observer(value, shallow, ssrMockReactivity);
  833. }
  834. }
  835. /**
  836. * Define a reactive property on an Object.
  837. */
  838. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  839. const dep = new Dep();
  840. const property = Object.getOwnPropertyDescriptor(obj, key);
  841. if (property && property.configurable === false) {
  842. return;
  843. }
  844. // cater for pre-defined getter/setters
  845. const getter = property && property.get;
  846. const setter = property && property.set;
  847. if ((!getter || setter) &&
  848. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  849. val = obj[key];
  850. }
  851. let childOb = !shallow && observe(val, false, mock);
  852. Object.defineProperty(obj, key, {
  853. enumerable: true,
  854. configurable: true,
  855. get: function reactiveGetter() {
  856. const value = getter ? getter.call(obj) : val;
  857. if (Dep.target) {
  858. {
  859. dep.depend({
  860. target: obj,
  861. type: "get" /* TrackOpTypes.GET */,
  862. key
  863. });
  864. }
  865. if (childOb) {
  866. childOb.dep.depend();
  867. if (isArray(value)) {
  868. dependArray(value);
  869. }
  870. }
  871. }
  872. return isRef(value) && !shallow ? value.value : value;
  873. },
  874. set: function reactiveSetter(newVal) {
  875. const value = getter ? getter.call(obj) : val;
  876. if (!hasChanged(value, newVal)) {
  877. return;
  878. }
  879. if (customSetter) {
  880. customSetter();
  881. }
  882. if (setter) {
  883. setter.call(obj, newVal);
  884. }
  885. else if (getter) {
  886. // #7981: for accessor properties without setter
  887. return;
  888. }
  889. else if (!shallow && isRef(value) && !isRef(newVal)) {
  890. value.value = newVal;
  891. return;
  892. }
  893. else {
  894. val = newVal;
  895. }
  896. childOb = !shallow && observe(newVal, false, mock);
  897. {
  898. dep.notify({
  899. type: "set" /* TriggerOpTypes.SET */,
  900. target: obj,
  901. key,
  902. newValue: newVal,
  903. oldValue: value
  904. });
  905. }
  906. }
  907. });
  908. return dep;
  909. }
  910. function set(target, key, val) {
  911. if ((isUndef(target) || isPrimitive(target))) {
  912. warn(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  913. }
  914. if (isReadonly(target)) {
  915. warn(`Set operation on key "${key}" failed: target is readonly.`);
  916. return;
  917. }
  918. const ob = target.__ob__;
  919. if (isArray(target) && isValidArrayIndex(key)) {
  920. target.length = Math.max(target.length, key);
  921. target.splice(key, 1, val);
  922. // when mocking for SSR, array methods are not hijacked
  923. if (ob && !ob.shallow && ob.mock) {
  924. observe(val, false, true);
  925. }
  926. return val;
  927. }
  928. if (key in target && !(key in Object.prototype)) {
  929. target[key] = val;
  930. return val;
  931. }
  932. if (target._isVue || (ob && ob.vmCount)) {
  933. warn('Avoid adding reactive properties to a Vue instance or its root $data ' +
  934. 'at runtime - declare it upfront in the data option.');
  935. return val;
  936. }
  937. if (!ob) {
  938. target[key] = val;
  939. return val;
  940. }
  941. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  942. {
  943. ob.dep.notify({
  944. type: "add" /* TriggerOpTypes.ADD */,
  945. target: target,
  946. key,
  947. newValue: val,
  948. oldValue: undefined
  949. });
  950. }
  951. return val;
  952. }
  953. function del(target, key) {
  954. if ((isUndef(target) || isPrimitive(target))) {
  955. warn(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  956. }
  957. if (isArray(target) && isValidArrayIndex(key)) {
  958. target.splice(key, 1);
  959. return;
  960. }
  961. const ob = target.__ob__;
  962. if (target._isVue || (ob && ob.vmCount)) {
  963. warn('Avoid deleting properties on a Vue instance or its root $data ' +
  964. '- just set it to null.');
  965. return;
  966. }
  967. if (isReadonly(target)) {
  968. warn(`Delete operation on key "${key}" failed: target is readonly.`);
  969. return;
  970. }
  971. if (!hasOwn(target, key)) {
  972. return;
  973. }
  974. delete target[key];
  975. if (!ob) {
  976. return;
  977. }
  978. {
  979. ob.dep.notify({
  980. type: "delete" /* TriggerOpTypes.DELETE */,
  981. target: target,
  982. key
  983. });
  984. }
  985. }
  986. /**
  987. * Collect dependencies on array elements when the array is touched, since
  988. * we cannot intercept array element access like property getters.
  989. */
  990. function dependArray(value) {
  991. for (let e, i = 0, l = value.length; i < l; i++) {
  992. e = value[i];
  993. if (e && e.__ob__) {
  994. e.__ob__.dep.depend();
  995. }
  996. if (isArray(e)) {
  997. dependArray(e);
  998. }
  999. }
  1000. }
  1001. function reactive(target) {
  1002. makeReactive(target, false);
  1003. return target;
  1004. }
  1005. /**
  1006. * Return a shallowly-reactive copy of the original object, where only the root
  1007. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1008. * root level).
  1009. */
  1010. function shallowReactive(target) {
  1011. makeReactive(target, true);
  1012. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1013. return target;
  1014. }
  1015. function makeReactive(target, shallow) {
  1016. // if trying to observe a readonly proxy, return the readonly version.
  1017. if (!isReadonly(target)) {
  1018. {
  1019. if (isArray(target)) {
  1020. warn(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`);
  1021. }
  1022. const existingOb = target && target.__ob__;
  1023. if (existingOb && existingOb.shallow !== shallow) {
  1024. warn(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1025. }
  1026. }
  1027. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1028. if (!ob) {
  1029. if (target == null || isPrimitive(target)) {
  1030. warn(`value cannot be made reactive: ${String(target)}`);
  1031. }
  1032. if (isCollectionType(target)) {
  1033. warn(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1034. }
  1035. }
  1036. }
  1037. }
  1038. function isReactive(value) {
  1039. if (isReadonly(value)) {
  1040. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1041. }
  1042. return !!(value && value.__ob__);
  1043. }
  1044. function isShallow(value) {
  1045. return !!(value && value.__v_isShallow);
  1046. }
  1047. function isReadonly(value) {
  1048. return !!(value && value.__v_isReadonly);
  1049. }
  1050. function isProxy(value) {
  1051. return isReactive(value) || isReadonly(value);
  1052. }
  1053. function toRaw(observed) {
  1054. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1055. return raw ? toRaw(raw) : observed;
  1056. }
  1057. function markRaw(value) {
  1058. // non-extensible objects won't be observed anyway
  1059. if (Object.isExtensible(value)) {
  1060. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1061. }
  1062. return value;
  1063. }
  1064. /**
  1065. * @internal
  1066. */
  1067. function isCollectionType(value) {
  1068. const type = toRawType(value);
  1069. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1070. }
  1071. /**
  1072. * @internal
  1073. */
  1074. const RefFlag = `__v_isRef`;
  1075. function isRef(r) {
  1076. return !!(r && r.__v_isRef === true);
  1077. }
  1078. function ref$1(value) {
  1079. return createRef(value, false);
  1080. }
  1081. function shallowRef(value) {
  1082. return createRef(value, true);
  1083. }
  1084. function createRef(rawValue, shallow) {
  1085. if (isRef(rawValue)) {
  1086. return rawValue;
  1087. }
  1088. const ref = {};
  1089. def(ref, RefFlag, true);
  1090. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1091. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1092. return ref;
  1093. }
  1094. function triggerRef(ref) {
  1095. if (!ref.dep) {
  1096. warn(`received object is not a triggerable ref.`);
  1097. }
  1098. {
  1099. ref.dep &&
  1100. ref.dep.notify({
  1101. type: "set" /* TriggerOpTypes.SET */,
  1102. target: ref,
  1103. key: 'value'
  1104. });
  1105. }
  1106. }
  1107. function unref(ref) {
  1108. return isRef(ref) ? ref.value : ref;
  1109. }
  1110. function proxyRefs(objectWithRefs) {
  1111. if (isReactive(objectWithRefs)) {
  1112. return objectWithRefs;
  1113. }
  1114. const proxy = {};
  1115. const keys = Object.keys(objectWithRefs);
  1116. for (let i = 0; i < keys.length; i++) {
  1117. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1118. }
  1119. return proxy;
  1120. }
  1121. function proxyWithRefUnwrap(target, source, key) {
  1122. Object.defineProperty(target, key, {
  1123. enumerable: true,
  1124. configurable: true,
  1125. get: () => {
  1126. const val = source[key];
  1127. if (isRef(val)) {
  1128. return val.value;
  1129. }
  1130. else {
  1131. const ob = val && val.__ob__;
  1132. if (ob)
  1133. ob.dep.depend();
  1134. return val;
  1135. }
  1136. },
  1137. set: value => {
  1138. const oldValue = source[key];
  1139. if (isRef(oldValue) && !isRef(value)) {
  1140. oldValue.value = value;
  1141. }
  1142. else {
  1143. source[key] = value;
  1144. }
  1145. }
  1146. });
  1147. }
  1148. function customRef(factory) {
  1149. const dep = new Dep();
  1150. const { get, set } = factory(() => {
  1151. {
  1152. dep.depend({
  1153. target: ref,
  1154. type: "get" /* TrackOpTypes.GET */,
  1155. key: 'value'
  1156. });
  1157. }
  1158. }, () => {
  1159. {
  1160. dep.notify({
  1161. target: ref,
  1162. type: "set" /* TriggerOpTypes.SET */,
  1163. key: 'value'
  1164. });
  1165. }
  1166. });
  1167. const ref = {
  1168. get value() {
  1169. return get();
  1170. },
  1171. set value(newVal) {
  1172. set(newVal);
  1173. }
  1174. };
  1175. def(ref, RefFlag, true);
  1176. return ref;
  1177. }
  1178. function toRefs(object) {
  1179. if (!isReactive(object)) {
  1180. warn(`toRefs() expects a reactive object but received a plain one.`);
  1181. }
  1182. const ret = isArray(object) ? new Array(object.length) : {};
  1183. for (const key in object) {
  1184. ret[key] = toRef(object, key);
  1185. }
  1186. return ret;
  1187. }
  1188. function toRef(object, key, defaultValue) {
  1189. const val = object[key];
  1190. if (isRef(val)) {
  1191. return val;
  1192. }
  1193. const ref = {
  1194. get value() {
  1195. const val = object[key];
  1196. return val === undefined ? defaultValue : val;
  1197. },
  1198. set value(newVal) {
  1199. object[key] = newVal;
  1200. }
  1201. };
  1202. def(ref, RefFlag, true);
  1203. return ref;
  1204. }
  1205. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1206. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1207. function readonly(target) {
  1208. return createReadonly(target, false);
  1209. }
  1210. function createReadonly(target, shallow) {
  1211. if (!isPlainObject(target)) {
  1212. {
  1213. if (isArray(target)) {
  1214. warn(`Vue 2 does not support readonly arrays.`);
  1215. }
  1216. else if (isCollectionType(target)) {
  1217. warn(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1218. }
  1219. else {
  1220. warn(`value cannot be made readonly: ${typeof target}`);
  1221. }
  1222. }
  1223. return target;
  1224. }
  1225. if (!Object.isExtensible(target)) {
  1226. warn(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1227. }
  1228. // already a readonly object
  1229. if (isReadonly(target)) {
  1230. return target;
  1231. }
  1232. // already has a readonly proxy
  1233. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1234. const existingProxy = target[existingFlag];
  1235. if (existingProxy) {
  1236. return existingProxy;
  1237. }
  1238. const proxy = Object.create(Object.getPrototypeOf(target));
  1239. def(target, existingFlag, proxy);
  1240. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1241. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1242. if (isRef(target)) {
  1243. def(proxy, RefFlag, true);
  1244. }
  1245. if (shallow || isShallow(target)) {
  1246. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1247. }
  1248. const keys = Object.keys(target);
  1249. for (let i = 0; i < keys.length; i++) {
  1250. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1251. }
  1252. return proxy;
  1253. }
  1254. function defineReadonlyProperty(proxy, target, key, shallow) {
  1255. Object.defineProperty(proxy, key, {
  1256. enumerable: true,
  1257. configurable: true,
  1258. get() {
  1259. const val = target[key];
  1260. return shallow || !isPlainObject(val) ? val : readonly(val);
  1261. },
  1262. set() {
  1263. warn(`Set operation on key "${key}" failed: target is readonly.`);
  1264. }
  1265. });
  1266. }
  1267. /**
  1268. * Returns a reactive-copy of the original object, where only the root level
  1269. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1270. * returned properties.
  1271. * This is used for creating the props proxy object for stateful components.
  1272. */
  1273. function shallowReadonly(target) {
  1274. return createReadonly(target, true);
  1275. }
  1276. function computed(getterOrOptions, debugOptions) {
  1277. let getter;
  1278. let setter;
  1279. const onlyGetter = isFunction(getterOrOptions);
  1280. if (onlyGetter) {
  1281. getter = getterOrOptions;
  1282. setter = () => {
  1283. warn('Write operation failed: computed value is readonly');
  1284. }
  1285. ;
  1286. }
  1287. else {
  1288. getter = getterOrOptions.get;
  1289. setter = getterOrOptions.set;
  1290. }
  1291. const watcher = isServerRendering()
  1292. ? null
  1293. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1294. if (watcher && debugOptions) {
  1295. watcher.onTrack = debugOptions.onTrack;
  1296. watcher.onTrigger = debugOptions.onTrigger;
  1297. }
  1298. const ref = {
  1299. // some libs rely on the presence effect for checking computed refs
  1300. // from normal refs, but the implementation doesn't matter
  1301. effect: watcher,
  1302. get value() {
  1303. if (watcher) {
  1304. if (watcher.dirty) {
  1305. watcher.evaluate();
  1306. }
  1307. if (Dep.target) {
  1308. if (Dep.target.onTrack) {
  1309. Dep.target.onTrack({
  1310. effect: Dep.target,
  1311. target: ref,
  1312. type: "get" /* TrackOpTypes.GET */,
  1313. key: 'value'
  1314. });
  1315. }
  1316. watcher.depend();
  1317. }
  1318. return watcher.value;
  1319. }
  1320. else {
  1321. return getter();
  1322. }
  1323. },
  1324. set value(newVal) {
  1325. setter(newVal);
  1326. }
  1327. };
  1328. def(ref, RefFlag, true);
  1329. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1330. return ref;
  1331. }
  1332. const WATCHER = `watcher`;
  1333. const WATCHER_CB = `${WATCHER} callback`;
  1334. const WATCHER_GETTER = `${WATCHER} getter`;
  1335. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  1336. // Simple effect.
  1337. function watchEffect(effect, options) {
  1338. return doWatch(effect, null, options);
  1339. }
  1340. function watchPostEffect(effect, options) {
  1341. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  1342. }
  1343. function watchSyncEffect(effect, options) {
  1344. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  1345. }
  1346. // initial value for watchers to trigger on undefined initial values
  1347. const INITIAL_WATCHER_VALUE = {};
  1348. // implementation
  1349. function watch(source, cb, options) {
  1350. if (typeof cb !== 'function') {
  1351. warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  1352. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  1353. `supports \`watch(source, cb, options?) signature.`);
  1354. }
  1355. return doWatch(source, cb, options);
  1356. }
  1357. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  1358. if (!cb) {
  1359. if (immediate !== undefined) {
  1360. warn(`watch() "immediate" option is only respected when using the ` +
  1361. `watch(source, callback, options?) signature.`);
  1362. }
  1363. if (deep !== undefined) {
  1364. warn(`watch() "deep" option is only respected when using the ` +
  1365. `watch(source, callback, options?) signature.`);
  1366. }
  1367. }
  1368. const warnInvalidSource = (s) => {
  1369. warn(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  1370. `function, a ref, a reactive object, or an array of these types.`);
  1371. };
  1372. const instance = currentInstance;
  1373. const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
  1374. let getter;
  1375. let forceTrigger = false;
  1376. let isMultiSource = false;
  1377. if (isRef(source)) {
  1378. getter = () => source.value;
  1379. forceTrigger = isShallow(source);
  1380. }
  1381. else if (isReactive(source)) {
  1382. getter = () => {
  1383. source.__ob__.dep.depend();
  1384. return source;
  1385. };
  1386. deep = true;
  1387. }
  1388. else if (isArray(source)) {
  1389. isMultiSource = true;
  1390. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  1391. getter = () => source.map(s => {
  1392. if (isRef(s)) {
  1393. return s.value;
  1394. }
  1395. else if (isReactive(s)) {
  1396. return traverse(s);
  1397. }
  1398. else if (isFunction(s)) {
  1399. return call(s, WATCHER_GETTER);
  1400. }
  1401. else {
  1402. warnInvalidSource(s);
  1403. }
  1404. });
  1405. }
  1406. else if (isFunction(source)) {
  1407. if (cb) {
  1408. // getter with cb
  1409. getter = () => call(source, WATCHER_GETTER);
  1410. }
  1411. else {
  1412. // no cb -> simple effect
  1413. getter = () => {
  1414. if (instance && instance._isDestroyed) {
  1415. return;
  1416. }
  1417. if (cleanup) {
  1418. cleanup();
  1419. }
  1420. return call(source, WATCHER, [onCleanup]);
  1421. };
  1422. }
  1423. }
  1424. else {
  1425. getter = noop;
  1426. warnInvalidSource(source);
  1427. }
  1428. if (cb && deep) {
  1429. const baseGetter = getter;
  1430. getter = () => traverse(baseGetter());
  1431. }
  1432. let cleanup;
  1433. let onCleanup = (fn) => {
  1434. cleanup = watcher.onStop = () => {
  1435. call(fn, WATCHER_CLEANUP);
  1436. };
  1437. };
  1438. // in SSR there is no need to setup an actual effect, and it should be noop
  1439. // unless it's eager
  1440. if (isServerRendering()) {
  1441. // we will also not call the invalidate callback (+ runner is not set up)
  1442. onCleanup = noop;
  1443. if (!cb) {
  1444. getter();
  1445. }
  1446. else if (immediate) {
  1447. call(cb, WATCHER_CB, [
  1448. getter(),
  1449. isMultiSource ? [] : undefined,
  1450. onCleanup
  1451. ]);
  1452. }
  1453. return noop;
  1454. }
  1455. const watcher = new Watcher(currentInstance, getter, noop, {
  1456. lazy: true
  1457. });
  1458. watcher.noRecurse = !cb;
  1459. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  1460. // overwrite default run
  1461. watcher.run = () => {
  1462. if (!watcher.active) {
  1463. return;
  1464. }
  1465. if (cb) {
  1466. // watch(source, cb)
  1467. const newValue = watcher.get();
  1468. if (deep ||
  1469. forceTrigger ||
  1470. (isMultiSource
  1471. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  1472. : hasChanged(newValue, oldValue))) {
  1473. // cleanup before running cb again
  1474. if (cleanup) {
  1475. cleanup();
  1476. }
  1477. call(cb, WATCHER_CB, [
  1478. newValue,
  1479. // pass undefined as the old value when it's changed for the first time
  1480. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  1481. onCleanup
  1482. ]);
  1483. oldValue = newValue;
  1484. }
  1485. }
  1486. else {
  1487. // watchEffect
  1488. watcher.get();
  1489. }
  1490. };
  1491. if (flush === 'sync') {
  1492. watcher.update = watcher.run;
  1493. }
  1494. else if (flush === 'post') {
  1495. watcher.post = true;
  1496. watcher.update = () => queueWatcher(watcher);
  1497. }
  1498. else {
  1499. // pre
  1500. watcher.update = () => {
  1501. if (instance && instance === currentInstance && !instance._isMounted) {
  1502. // pre-watcher triggered before
  1503. const buffer = instance._preWatchers || (instance._preWatchers = []);
  1504. if (buffer.indexOf(watcher) < 0)
  1505. buffer.push(watcher);
  1506. }
  1507. else {
  1508. queueWatcher(watcher);
  1509. }
  1510. };
  1511. }
  1512. {
  1513. watcher.onTrack = onTrack;
  1514. watcher.onTrigger = onTrigger;
  1515. }
  1516. // initial run
  1517. if (cb) {
  1518. if (immediate) {
  1519. watcher.run();
  1520. }
  1521. else {
  1522. oldValue = watcher.get();
  1523. }
  1524. }
  1525. else if (flush === 'post' && instance) {
  1526. instance.$once('hook:mounted', () => watcher.get());
  1527. }
  1528. else {
  1529. watcher.get();
  1530. }
  1531. return () => {
  1532. watcher.teardown();
  1533. };
  1534. }
  1535. let activeEffectScope;
  1536. class EffectScope {
  1537. constructor(detached = false) {
  1538. this.detached = detached;
  1539. /**
  1540. * @internal
  1541. */
  1542. this.active = true;
  1543. /**
  1544. * @internal
  1545. */
  1546. this.effects = [];
  1547. /**
  1548. * @internal
  1549. */
  1550. this.cleanups = [];
  1551. this.parent = activeEffectScope;
  1552. if (!detached && activeEffectScope) {
  1553. this.index =
  1554. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  1555. }
  1556. }
  1557. run(fn) {
  1558. if (this.active) {
  1559. const currentEffectScope = activeEffectScope;
  1560. try {
  1561. activeEffectScope = this;
  1562. return fn();
  1563. }
  1564. finally {
  1565. activeEffectScope = currentEffectScope;
  1566. }
  1567. }
  1568. else {
  1569. warn(`cannot run an inactive effect scope.`);
  1570. }
  1571. }
  1572. /**
  1573. * This should only be called on non-detached scopes
  1574. * @internal
  1575. */
  1576. on() {
  1577. activeEffectScope = this;
  1578. }
  1579. /**
  1580. * This should only be called on non-detached scopes
  1581. * @internal
  1582. */
  1583. off() {
  1584. activeEffectScope = this.parent;
  1585. }
  1586. stop(fromParent) {
  1587. if (this.active) {
  1588. let i, l;
  1589. for (i = 0, l = this.effects.length; i < l; i++) {
  1590. this.effects[i].teardown();
  1591. }
  1592. for (i = 0, l = this.cleanups.length; i < l; i++) {
  1593. this.cleanups[i]();
  1594. }
  1595. if (this.scopes) {
  1596. for (i = 0, l = this.scopes.length; i < l; i++) {
  1597. this.scopes[i].stop(true);
  1598. }
  1599. }
  1600. // nested scope, dereference from parent to avoid memory leaks
  1601. if (!this.detached && this.parent && !fromParent) {
  1602. // optimized O(1) removal
  1603. const last = this.parent.scopes.pop();
  1604. if (last && last !== this) {
  1605. this.parent.scopes[this.index] = last;
  1606. last.index = this.index;
  1607. }
  1608. }
  1609. this.parent = undefined;
  1610. this.active = false;
  1611. }
  1612. }
  1613. }
  1614. function effectScope(detached) {
  1615. return new EffectScope(detached);
  1616. }
  1617. /**
  1618. * @internal
  1619. */
  1620. function recordEffectScope(effect, scope = activeEffectScope) {
  1621. if (scope && scope.active) {
  1622. scope.effects.push(effect);
  1623. }
  1624. }
  1625. function getCurrentScope() {
  1626. return activeEffectScope;
  1627. }
  1628. function onScopeDispose(fn) {
  1629. if (activeEffectScope) {
  1630. activeEffectScope.cleanups.push(fn);
  1631. }
  1632. else {
  1633. warn(`onScopeDispose() is called when there is no active effect scope` +
  1634. ` to be associated with.`);
  1635. }
  1636. }
  1637. function provide(key, value) {
  1638. if (!currentInstance) {
  1639. {
  1640. warn(`provide() can only be used inside setup().`);
  1641. }
  1642. }
  1643. else {
  1644. // TS doesn't allow symbol as index type
  1645. resolveProvided(currentInstance)[key] = value;
  1646. }
  1647. }
  1648. function resolveProvided(vm) {
  1649. // by default an instance inherits its parent's provides object
  1650. // but when it needs to provide values of its own, it creates its
  1651. // own provides object using parent provides object as prototype.
  1652. // this way in `inject` we can simply look up injections from direct
  1653. // parent and let the prototype chain do the work.
  1654. const existing = vm._provided;
  1655. const parentProvides = vm.$parent && vm.$parent._provided;
  1656. if (parentProvides === existing) {
  1657. return (vm._provided = Object.create(parentProvides));
  1658. }
  1659. else {
  1660. return existing;
  1661. }
  1662. }
  1663. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  1664. // fallback to `currentRenderingInstance` so that this can be called in
  1665. // a functional component
  1666. const instance = currentInstance;
  1667. if (instance) {
  1668. // #2400
  1669. // to support `app.use` plugins,
  1670. // fallback to appContext's `provides` if the instance is at root
  1671. const provides = instance.$parent && instance.$parent._provided;
  1672. if (provides && key in provides) {
  1673. // TS doesn't allow symbol as index type
  1674. return provides[key];
  1675. }
  1676. else if (arguments.length > 1) {
  1677. return treatDefaultAsFactory && isFunction(defaultValue)
  1678. ? defaultValue.call(instance)
  1679. : defaultValue;
  1680. }
  1681. else {
  1682. warn(`injection "${String(key)}" not found.`);
  1683. }
  1684. }
  1685. else {
  1686. warn(`inject() can only be used inside setup() or functional components.`);
  1687. }
  1688. }
  1689. const normalizeEvent = cached((name) => {
  1690. const passive = name.charAt(0) === '&';
  1691. name = passive ? name.slice(1) : name;
  1692. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1693. name = once ? name.slice(1) : name;
  1694. const capture = name.charAt(0) === '!';
  1695. name = capture ? name.slice(1) : name;
  1696. return {
  1697. name,
  1698. once,
  1699. capture,
  1700. passive
  1701. };
  1702. });
  1703. function createFnInvoker(fns, vm) {
  1704. function invoker() {
  1705. const fns = invoker.fns;
  1706. if (isArray(fns)) {
  1707. const cloned = fns.slice();
  1708. for (let i = 0; i < cloned.length; i++) {
  1709. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1710. }
  1711. }
  1712. else {
  1713. // return handler return value for single handlers
  1714. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1715. }
  1716. }
  1717. invoker.fns = fns;
  1718. return invoker;
  1719. }
  1720. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1721. let name, cur, old, event;
  1722. for (name in on) {
  1723. cur = on[name];
  1724. old = oldOn[name];
  1725. event = normalizeEvent(name);
  1726. if (isUndef(cur)) {
  1727. warn(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1728. }
  1729. else if (isUndef(old)) {
  1730. if (isUndef(cur.fns)) {
  1731. cur = on[name] = createFnInvoker(cur, vm);
  1732. }
  1733. if (isTrue(event.once)) {
  1734. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1735. }
  1736. add(event.name, cur, event.capture, event.passive, event.params);
  1737. }
  1738. else if (cur !== old) {
  1739. old.fns = cur;
  1740. on[name] = old;
  1741. }
  1742. }
  1743. for (name in oldOn) {
  1744. if (isUndef(on[name])) {
  1745. event = normalizeEvent(name);
  1746. remove(event.name, oldOn[name], event.capture);
  1747. }
  1748. }
  1749. }
  1750. function mergeVNodeHook(def, hookKey, hook) {
  1751. if (def instanceof VNode) {
  1752. def = def.data.hook || (def.data.hook = {});
  1753. }
  1754. let invoker;
  1755. const oldHook = def[hookKey];
  1756. function wrappedHook() {
  1757. hook.apply(this, arguments);
  1758. // important: remove merged hook to ensure it's called only once
  1759. // and prevent memory leak
  1760. remove$2(invoker.fns, wrappedHook);
  1761. }
  1762. if (isUndef(oldHook)) {
  1763. // no existing hook
  1764. invoker = createFnInvoker([wrappedHook]);
  1765. }
  1766. else {
  1767. /* istanbul ignore if */
  1768. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1769. // already a merged invoker
  1770. invoker = oldHook;
  1771. invoker.fns.push(wrappedHook);
  1772. }
  1773. else {
  1774. // existing plain hook
  1775. invoker = createFnInvoker([oldHook, wrappedHook]);
  1776. }
  1777. }
  1778. invoker.merged = true;
  1779. def[hookKey] = invoker;
  1780. }
  1781. function extractPropsFromVNodeData(data, Ctor, tag) {
  1782. // we are only extracting raw values here.
  1783. // validation and default values are handled in the child
  1784. // component itself.
  1785. const propOptions = Ctor.options.props;
  1786. if (isUndef(propOptions)) {
  1787. return;
  1788. }
  1789. const res = {};
  1790. const { attrs, props } = data;
  1791. if (isDef(attrs) || isDef(props)) {
  1792. for (const key in propOptions) {
  1793. const altKey = hyphenate(key);
  1794. {
  1795. const keyInLowerCase = key.toLowerCase();
  1796. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1797. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1798. `${formatComponentName(
  1799. // @ts-expect-error tag is string
  1800. tag || Ctor)}, but the declared prop name is` +
  1801. ` "${key}". ` +
  1802. `Note that HTML attributes are case-insensitive and camelCased ` +
  1803. `props need to use their kebab-case equivalents when using in-DOM ` +
  1804. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1805. }
  1806. }
  1807. checkProp(res, props, key, altKey, true) ||
  1808. checkProp(res, attrs, key, altKey, false);
  1809. }
  1810. }
  1811. return res;
  1812. }
  1813. function checkProp(res, hash, key, altKey, preserve) {
  1814. if (isDef(hash)) {
  1815. if (hasOwn(hash, key)) {
  1816. res[key] = hash[key];
  1817. if (!preserve) {
  1818. delete hash[key];
  1819. }
  1820. return true;
  1821. }
  1822. else if (hasOwn(hash, altKey)) {
  1823. res[key] = hash[altKey];
  1824. if (!preserve) {
  1825. delete hash[altKey];
  1826. }
  1827. return true;
  1828. }
  1829. }
  1830. return false;
  1831. }
  1832. // The template compiler attempts to minimize the need for normalization by
  1833. // statically analyzing the template at compile time.
  1834. //
  1835. // For plain HTML markup, normalization can be completely skipped because the
  1836. // generated render function is guaranteed to return Array<VNode>. There are
  1837. // two cases where extra normalization is needed:
  1838. // 1. When the children contains components - because a functional component
  1839. // may return an Array instead of a single root. In this case, just a simple
  1840. // normalization is needed - if any child is an Array, we flatten the whole
  1841. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1842. // because functional components already normalize their own children.
  1843. function simpleNormalizeChildren(children) {
  1844. for (let i = 0; i < children.length; i++) {
  1845. if (isArray(children[i])) {
  1846. return Array.prototype.concat.apply([], children);
  1847. }
  1848. }
  1849. return children;
  1850. }
  1851. // 2. When the children contains constructs that always generated nested Arrays,
  1852. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1853. // with hand-written render functions / JSX. In such cases a full normalization
  1854. // is needed to cater to all possible types of children values.
  1855. function normalizeChildren(children) {
  1856. return isPrimitive(children)
  1857. ? [createTextVNode(children)]
  1858. : isArray(children)
  1859. ? normalizeArrayChildren(children)
  1860. : undefined;
  1861. }
  1862. function isTextNode(node) {
  1863. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1864. }
  1865. function normalizeArrayChildren(children, nestedIndex) {
  1866. const res = [];
  1867. let i, c, lastIndex, last;
  1868. for (i = 0; i < children.length; i++) {
  1869. c = children[i];
  1870. if (isUndef(c) || typeof c === 'boolean')
  1871. continue;
  1872. lastIndex = res.length - 1;
  1873. last = res[lastIndex];
  1874. // nested
  1875. if (isArray(c)) {
  1876. if (c.length > 0) {
  1877. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1878. // merge adjacent text nodes
  1879. if (isTextNode(c[0]) && isTextNode(last)) {
  1880. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1881. c.shift();
  1882. }
  1883. res.push.apply(res, c);
  1884. }
  1885. }
  1886. else if (isPrimitive(c)) {
  1887. if (isTextNode(last)) {
  1888. // merge adjacent text nodes
  1889. // this is necessary for SSR hydration because text nodes are
  1890. // essentially merged when rendered to HTML strings
  1891. res[lastIndex] = createTextVNode(last.text + c);
  1892. }
  1893. else if (c !== '') {
  1894. // convert primitive to vnode
  1895. res.push(createTextVNode(c));
  1896. }
  1897. }
  1898. else {
  1899. if (isTextNode(c) && isTextNode(last)) {
  1900. // merge adjacent text nodes
  1901. res[lastIndex] = createTextVNode(last.text + c.text);
  1902. }
  1903. else {
  1904. // default key for nested array children (likely generated by v-for)
  1905. if (isTrue(children._isVList) &&
  1906. isDef(c.tag) &&
  1907. isUndef(c.key) &&
  1908. isDef(nestedIndex)) {
  1909. c.key = `__vlist${nestedIndex}_${i}__`;
  1910. }
  1911. res.push(c);
  1912. }
  1913. }
  1914. }
  1915. return res;
  1916. }
  1917. /**
  1918. * Runtime helper for rendering v-for lists.
  1919. */
  1920. function renderList(val, render) {
  1921. let ret = null, i, l, keys, key;
  1922. if (isArray(val) || typeof val === 'string') {
  1923. ret = new Array(val.length);
  1924. for (i = 0, l = val.length; i < l; i++) {
  1925. ret[i] = render(val[i], i);
  1926. }
  1927. }
  1928. else if (typeof val === 'number') {
  1929. ret = new Array(val);
  1930. for (i = 0; i < val; i++) {
  1931. ret[i] = render(i + 1, i);
  1932. }
  1933. }
  1934. else if (isObject(val)) {
  1935. if (hasSymbol && val[Symbol.iterator]) {
  1936. ret = [];
  1937. const iterator = val[Symbol.iterator]();
  1938. let result = iterator.next();
  1939. while (!result.done) {
  1940. ret.push(render(result.value, ret.length));
  1941. result = iterator.next();
  1942. }
  1943. }
  1944. else {
  1945. keys = Object.keys(val);
  1946. ret = new Array(keys.length);
  1947. for (i = 0, l = keys.length; i < l; i++) {
  1948. key = keys[i];
  1949. ret[i] = render(val[key], key, i);
  1950. }
  1951. }
  1952. }
  1953. if (!isDef(ret)) {
  1954. ret = [];
  1955. }
  1956. ret._isVList = true;
  1957. return ret;
  1958. }
  1959. /**
  1960. * Runtime helper for rendering <slot>
  1961. */
  1962. function renderSlot(name, fallbackRender, props, bindObject) {
  1963. const scopedSlotFn = this.$scopedSlots[name];
  1964. let nodes;
  1965. if (scopedSlotFn) {
  1966. // scoped slot
  1967. props = props || {};
  1968. if (bindObject) {
  1969. if (!isObject(bindObject)) {
  1970. warn('slot v-bind without argument expects an Object', this);
  1971. }
  1972. props = extend(extend({}, bindObject), props);
  1973. }
  1974. nodes =
  1975. scopedSlotFn(props) ||
  1976. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1977. }
  1978. else {
  1979. nodes =
  1980. this.$slots[name] ||
  1981. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1982. }
  1983. const target = props && props.slot;
  1984. if (target) {
  1985. return this.$createElement('template', { slot: target }, nodes);
  1986. }
  1987. else {
  1988. return nodes;
  1989. }
  1990. }
  1991. /**
  1992. * Runtime helper for resolving filters
  1993. */
  1994. function resolveFilter(id) {
  1995. return resolveAsset(this.$options, 'filters', id, true) || identity;
  1996. }
  1997. function isKeyNotMatch(expect, actual) {
  1998. if (isArray(expect)) {
  1999. return expect.indexOf(actual) === -1;
  2000. }
  2001. else {
  2002. return expect !== actual;
  2003. }
  2004. }
  2005. /**
  2006. * Runtime helper for checking keyCodes from config.
  2007. * exposed as Vue.prototype._k
  2008. * passing in eventKeyName as last argument separately for backwards compat
  2009. */
  2010. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  2011. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2012. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2013. return isKeyNotMatch(builtInKeyName, eventKeyName);
  2014. }
  2015. else if (mappedKeyCode) {
  2016. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  2017. }
  2018. else if (eventKeyName) {
  2019. return hyphenate(eventKeyName) !== key;
  2020. }
  2021. return eventKeyCode === undefined;
  2022. }
  2023. /**
  2024. * Runtime helper for merging v-bind="object" into a VNode's data.
  2025. */
  2026. function bindObjectProps(data, tag, value, asProp, isSync) {
  2027. if (value) {
  2028. if (!isObject(value)) {
  2029. warn('v-bind without argument expects an Object or Array value', this);
  2030. }
  2031. else {
  2032. if (isArray(value)) {
  2033. value = toObject(value);
  2034. }
  2035. let hash;
  2036. for (const key in value) {
  2037. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  2038. hash = data;
  2039. }
  2040. else {
  2041. const type = data.attrs && data.attrs.type;
  2042. hash =
  2043. asProp || config.mustUseProp(tag, type, key)
  2044. ? data.domProps || (data.domProps = {})
  2045. : data.attrs || (data.attrs = {});
  2046. }
  2047. const camelizedKey = camelize(key);
  2048. const hyphenatedKey = hyphenate(key);
  2049. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2050. hash[key] = value[key];
  2051. if (isSync) {
  2052. const on = data.on || (data.on = {});
  2053. on[`update:${key}`] = function ($event) {
  2054. value[key] = $event;
  2055. };
  2056. }
  2057. }
  2058. }
  2059. }
  2060. }
  2061. return data;
  2062. }
  2063. /**
  2064. * Runtime helper for rendering static trees.
  2065. */
  2066. function renderStatic(index, isInFor) {
  2067. const cached = this._staticTrees || (this._staticTrees = []);
  2068. let tree = cached[index];
  2069. // if has already-rendered static tree and not inside v-for,
  2070. // we can reuse the same tree.
  2071. if (tree && !isInFor) {
  2072. return tree;
  2073. }
  2074. // otherwise, render a fresh tree.
  2075. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  2076. );
  2077. markStatic(tree, `__static__${index}`, false);
  2078. return tree;
  2079. }
  2080. /**
  2081. * Runtime helper for v-once.
  2082. * Effectively it means marking the node as static with a unique key.
  2083. */
  2084. function markOnce(tree, index, key) {
  2085. markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  2086. return tree;
  2087. }
  2088. function markStatic(tree, key, isOnce) {
  2089. if (isArray(tree)) {
  2090. for (let i = 0; i < tree.length; i++) {
  2091. if (tree[i] && typeof tree[i] !== 'string') {
  2092. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  2093. }
  2094. }
  2095. }
  2096. else {
  2097. markStaticNode(tree, key, isOnce);
  2098. }
  2099. }
  2100. function markStaticNode(node, key, isOnce) {
  2101. node.isStatic = true;
  2102. node.key = key;
  2103. node.isOnce = isOnce;
  2104. }
  2105. function bindObjectListeners(data, value) {
  2106. if (value) {
  2107. if (!isPlainObject(value)) {
  2108. warn('v-on without argument expects an Object value', this);
  2109. }
  2110. else {
  2111. const on = (data.on = data.on ? extend({}, data.on) : {});
  2112. for (const key in value) {
  2113. const existing = on[key];
  2114. const ours = value[key];
  2115. on[key] = existing ? [].concat(existing, ours) : ours;
  2116. }
  2117. }
  2118. }
  2119. return data;
  2120. }
  2121. function resolveScopedSlots(fns, res,
  2122. // the following are added in 2.6
  2123. hasDynamicKeys, contentHashKey) {
  2124. res = res || { $stable: !hasDynamicKeys };
  2125. for (let i = 0; i < fns.length; i++) {
  2126. const slot = fns[i];
  2127. if (isArray(slot)) {
  2128. resolveScopedSlots(slot, res, hasDynamicKeys);
  2129. }
  2130. else if (slot) {
  2131. // marker for reverse proxying v-slot without scope on this.$slots
  2132. // @ts-expect-error
  2133. if (slot.proxy) {
  2134. // @ts-expect-error
  2135. slot.fn.proxy = true;
  2136. }
  2137. res[slot.key] = slot.fn;
  2138. }
  2139. }
  2140. if (contentHashKey) {
  2141. res.$key = contentHashKey;
  2142. }
  2143. return res;
  2144. }
  2145. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2146. function bindDynamicKeys(baseObj, values) {
  2147. for (let i = 0; i < values.length; i += 2) {
  2148. const key = values[i];
  2149. if (typeof key === 'string' && key) {
  2150. baseObj[values[i]] = values[i + 1];
  2151. }
  2152. else if (key !== '' && key !== null) {
  2153. // null is a special value for explicitly removing a binding
  2154. warn(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2155. }
  2156. }
  2157. return baseObj;
  2158. }
  2159. // helper to dynamically append modifier runtime markers to event names.
  2160. // ensure only append when value is already string, otherwise it will be cast
  2161. // to string and cause the type check to miss.
  2162. function prependModifier(value, symbol) {
  2163. return typeof value === 'string' ? symbol + value : value;
  2164. }
  2165. function installRenderHelpers(target) {
  2166. target._o = markOnce;
  2167. target._n = toNumber;
  2168. target._s = toString;
  2169. target._l = renderList;
  2170. target._t = renderSlot;
  2171. target._q = looseEqual;
  2172. target._i = looseIndexOf;
  2173. target._m = renderStatic;
  2174. target._f = resolveFilter;
  2175. target._k = checkKeyCodes;
  2176. target._b = bindObjectProps;
  2177. target._v = createTextVNode;
  2178. target._e = createEmptyVNode;
  2179. target._u = resolveScopedSlots;
  2180. target._g = bindObjectListeners;
  2181. target._d = bindDynamicKeys;
  2182. target._p = prependModifier;
  2183. }
  2184. /**
  2185. * Runtime helper for resolving raw children VNodes into a slot object.
  2186. */
  2187. function resolveSlots(children, context) {
  2188. if (!children || !children.length) {
  2189. return {};
  2190. }
  2191. const slots = {};
  2192. for (let i = 0, l = children.length; i < l; i++) {
  2193. const child = children[i];
  2194. const data = child.data;
  2195. // remove slot attribute if the node is resolved as a Vue slot node
  2196. if (data && data.attrs && data.attrs.slot) {
  2197. delete data.attrs.slot;
  2198. }
  2199. // named slots should only be respected if the vnode was rendered in the
  2200. // same context.
  2201. if ((child.context === context || child.fnContext === context) &&
  2202. data &&
  2203. data.slot != null) {
  2204. const name = data.slot;
  2205. const slot = slots[name] || (slots[name] = []);
  2206. if (child.tag === 'template') {
  2207. slot.push.apply(slot, child.children || []);
  2208. }
  2209. else {
  2210. slot.push(child);
  2211. }
  2212. }
  2213. else {
  2214. (slots.default || (slots.default = [])).push(child);
  2215. }
  2216. }
  2217. // ignore slots that contains only whitespace
  2218. for (const name in slots) {
  2219. if (slots[name].every(isWhitespace)) {
  2220. delete slots[name];
  2221. }
  2222. }
  2223. return slots;
  2224. }
  2225. function isWhitespace(node) {
  2226. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2227. }
  2228. function isAsyncPlaceholder(node) {
  2229. // @ts-expect-error not really boolean type
  2230. return node.isComment && node.asyncFactory;
  2231. }
  2232. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2233. let res;
  2234. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2235. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2236. const key = scopedSlots && scopedSlots.$key;
  2237. if (!scopedSlots) {
  2238. res = {};
  2239. }
  2240. else if (scopedSlots._normalized) {
  2241. // fast path 1: child component re-render only, parent did not change
  2242. return scopedSlots._normalized;
  2243. }
  2244. else if (isStable &&
  2245. prevScopedSlots &&
  2246. prevScopedSlots !== emptyObject &&
  2247. key === prevScopedSlots.$key &&
  2248. !hasNormalSlots &&
  2249. !prevScopedSlots.$hasNormal) {
  2250. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2251. // only need to normalize once
  2252. return prevScopedSlots;
  2253. }
  2254. else {
  2255. res = {};
  2256. for (const key in scopedSlots) {
  2257. if (scopedSlots[key] && key[0] !== '$') {
  2258. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2259. }
  2260. }
  2261. }
  2262. // expose normal slots on scopedSlots
  2263. for (const key in normalSlots) {
  2264. if (!(key in res)) {
  2265. res[key] = proxyNormalSlot(normalSlots, key);
  2266. }
  2267. }
  2268. // avoriaz seems to mock a non-extensible $scopedSlots object
  2269. // and when that is passed down this would cause an error
  2270. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2271. scopedSlots._normalized = res;
  2272. }
  2273. def(res, '$stable', isStable);
  2274. def(res, '$key', key);
  2275. def(res, '$hasNormal', hasNormalSlots);
  2276. return res;
  2277. }
  2278. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2279. const normalized = function () {
  2280. const cur = currentInstance;
  2281. setCurrentInstance(vm);
  2282. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2283. res =
  2284. res && typeof res === 'object' && !isArray(res)
  2285. ? [res] // single vnode
  2286. : normalizeChildren(res);
  2287. const vnode = res && res[0];
  2288. setCurrentInstance(cur);
  2289. return res &&
  2290. (!vnode ||
  2291. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2292. ? undefined
  2293. : res;
  2294. };
  2295. // this is a slot using the new v-slot syntax without scope. although it is
  2296. // compiled as a scoped slot, render fn users would expect it to be present
  2297. // on this.$slots because the usage is semantically a normal slot.
  2298. if (fn.proxy) {
  2299. Object.defineProperty(normalSlots, key, {
  2300. get: normalized,
  2301. enumerable: true,
  2302. configurable: true
  2303. });
  2304. }
  2305. return normalized;
  2306. }
  2307. function proxyNormalSlot(slots, key) {
  2308. return () => slots[key];
  2309. }
  2310. function initSetup(vm) {
  2311. const options = vm.$options;
  2312. const setup = options.setup;
  2313. if (setup) {
  2314. const ctx = (vm._setupContext = createSetupContext(vm));
  2315. setCurrentInstance(vm);
  2316. pushTarget();
  2317. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2318. popTarget();
  2319. setCurrentInstance();
  2320. if (isFunction(setupResult)) {
  2321. // render function
  2322. // @ts-ignore
  2323. options.render = setupResult;
  2324. }
  2325. else if (isObject(setupResult)) {
  2326. // bindings
  2327. if (setupResult instanceof VNode) {
  2328. warn(`setup() should not return VNodes directly - ` +
  2329. `return a render function instead.`);
  2330. }
  2331. vm._setupState = setupResult;
  2332. // __sfc indicates compiled bindings from <script setup>
  2333. if (!setupResult.__sfc) {
  2334. for (const key in setupResult) {
  2335. if (!isReserved(key)) {
  2336. proxyWithRefUnwrap(vm, setupResult, key);
  2337. }
  2338. else {
  2339. warn(`Avoid using variables that start with _ or $ in setup().`);
  2340. }
  2341. }
  2342. }
  2343. else {
  2344. // exposed for compiled render fn
  2345. const proxy = (vm._setupProxy = {});
  2346. for (const key in setupResult) {
  2347. if (key !== '__sfc') {
  2348. proxyWithRefUnwrap(proxy, setupResult, key);
  2349. }
  2350. }
  2351. }
  2352. }
  2353. else if (setupResult !== undefined) {
  2354. warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2355. }
  2356. }
  2357. }
  2358. function createSetupContext(vm) {
  2359. let exposeCalled = false;
  2360. return {
  2361. get attrs() {
  2362. if (!vm._attrsProxy) {
  2363. const proxy = (vm._attrsProxy = {});
  2364. def(proxy, '_v_attr_proxy', true);
  2365. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2366. }
  2367. return vm._attrsProxy;
  2368. },
  2369. get listeners() {
  2370. if (!vm._listenersProxy) {
  2371. const proxy = (vm._listenersProxy = {});
  2372. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2373. }
  2374. return vm._listenersProxy;
  2375. },
  2376. get slots() {
  2377. return initSlotsProxy(vm);
  2378. },
  2379. emit: bind(vm.$emit, vm),
  2380. expose(exposed) {
  2381. {
  2382. if (exposeCalled) {
  2383. warn(`expose() should be called only once per setup().`, vm);
  2384. }
  2385. exposeCalled = true;
  2386. }
  2387. if (exposed) {
  2388. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2389. }
  2390. }
  2391. };
  2392. }
  2393. function syncSetupProxy(to, from, prev, instance, type) {
  2394. let changed = false;
  2395. for (const key in from) {
  2396. if (!(key in to)) {
  2397. changed = true;
  2398. defineProxyAttr(to, key, instance, type);
  2399. }
  2400. else if (from[key] !== prev[key]) {
  2401. changed = true;
  2402. }
  2403. }
  2404. for (const key in to) {
  2405. if (!(key in from)) {
  2406. changed = true;
  2407. delete to[key];
  2408. }
  2409. }
  2410. return changed;
  2411. }
  2412. function defineProxyAttr(proxy, key, instance, type) {
  2413. Object.defineProperty(proxy, key, {
  2414. enumerable: true,
  2415. configurable: true,
  2416. get() {
  2417. return instance[type][key];
  2418. }
  2419. });
  2420. }
  2421. function initSlotsProxy(vm) {
  2422. if (!vm._slotsProxy) {
  2423. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2424. }
  2425. return vm._slotsProxy;
  2426. }
  2427. function syncSetupSlots(to, from) {
  2428. for (const key in from) {
  2429. to[key] = from[key];
  2430. }
  2431. for (const key in to) {
  2432. if (!(key in from)) {
  2433. delete to[key];
  2434. }
  2435. }
  2436. }
  2437. /**
  2438. * @internal use manual type def because public setup context type relies on
  2439. * legacy VNode types
  2440. */
  2441. function useSlots() {
  2442. return getContext().slots;
  2443. }
  2444. /**
  2445. * @internal use manual type def because public setup context type relies on
  2446. * legacy VNode types
  2447. */
  2448. function useAttrs() {
  2449. return getContext().attrs;
  2450. }
  2451. /**
  2452. * Vue 2 only
  2453. * @internal use manual type def because public setup context type relies on
  2454. * legacy VNode types
  2455. */
  2456. function useListeners() {
  2457. return getContext().listeners;
  2458. }
  2459. function getContext() {
  2460. if (!currentInstance) {
  2461. warn(`useContext() called without active instance.`);
  2462. }
  2463. const vm = currentInstance;
  2464. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2465. }
  2466. /**
  2467. * Runtime helper for merging default declarations. Imported by compiled code
  2468. * only.
  2469. * @internal
  2470. */
  2471. function mergeDefaults(raw, defaults) {
  2472. const props = isArray(raw)
  2473. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2474. : raw;
  2475. for (const key in defaults) {
  2476. const opt = props[key];
  2477. if (opt) {
  2478. if (isArray(opt) || isFunction(opt)) {
  2479. props[key] = { type: opt, default: defaults[key] };
  2480. }
  2481. else {
  2482. opt.default = defaults[key];
  2483. }
  2484. }
  2485. else if (opt === null) {
  2486. props[key] = { default: defaults[key] };
  2487. }
  2488. else {
  2489. warn(`props default key "${key}" has no corresponding declaration.`);
  2490. }
  2491. }
  2492. return props;
  2493. }
  2494. function initRender(vm) {
  2495. vm._vnode = null; // the root of the child tree
  2496. vm._staticTrees = null; // v-once cached trees
  2497. const options = vm.$options;
  2498. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2499. const renderContext = parentVnode && parentVnode.context;
  2500. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2501. vm.$scopedSlots = parentVnode
  2502. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2503. : emptyObject;
  2504. // bind the createElement fn to this instance
  2505. // so that we get proper render context inside it.
  2506. // args order: tag, data, children, normalizationType, alwaysNormalize
  2507. // internal version is used by render functions compiled from templates
  2508. // @ts-expect-error
  2509. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2510. // normalization is always applied for the public version, used in
  2511. // user-written render functions.
  2512. // @ts-expect-error
  2513. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2514. // $attrs & $listeners are exposed for easier HOC creation.
  2515. // they need to be reactive so that HOCs using them are always updated
  2516. const parentData = parentVnode && parentVnode.data;
  2517. /* istanbul ignore else */
  2518. {
  2519. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2520. !isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
  2521. }, true);
  2522. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2523. !isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
  2524. }, true);
  2525. }
  2526. }
  2527. let currentRenderingInstance = null;
  2528. function renderMixin(Vue) {
  2529. // install runtime convenience helpers
  2530. installRenderHelpers(Vue.prototype);
  2531. Vue.prototype.$nextTick = function (fn) {
  2532. return nextTick(fn, this);
  2533. };
  2534. Vue.prototype._render = function () {
  2535. const vm = this;
  2536. const { render, _parentVnode } = vm.$options;
  2537. if (_parentVnode && vm._isMounted) {
  2538. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2539. if (vm._slotsProxy) {
  2540. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2541. }
  2542. }
  2543. // set parent vnode. this allows render functions to have access
  2544. // to the data on the placeholder node.
  2545. vm.$vnode = _parentVnode;
  2546. // render self
  2547. let vnode;
  2548. try {
  2549. // There's no need to maintain a stack because all render fns are called
  2550. // separately from one another. Nested component's render fns are called
  2551. // when parent component is patched.
  2552. setCurrentInstance(vm);
  2553. currentRenderingInstance = vm;
  2554. vnode = render.call(vm._renderProxy, vm.$createElement);
  2555. }
  2556. catch (e) {
  2557. handleError(e, vm, `render`);
  2558. // return error render result,
  2559. // or previous vnode to prevent render error causing blank component
  2560. /* istanbul ignore else */
  2561. if (vm.$options.renderError) {
  2562. try {
  2563. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2564. }
  2565. catch (e) {
  2566. handleError(e, vm, `renderError`);
  2567. vnode = vm._vnode;
  2568. }
  2569. }
  2570. else {
  2571. vnode = vm._vnode;
  2572. }
  2573. }
  2574. finally {
  2575. currentRenderingInstance = null;
  2576. setCurrentInstance();
  2577. }
  2578. // if the returned array contains only a single node, allow it
  2579. if (isArray(vnode) && vnode.length === 1) {
  2580. vnode = vnode[0];
  2581. }
  2582. // return empty vnode in case the render function errored out
  2583. if (!(vnode instanceof VNode)) {
  2584. if (isArray(vnode)) {
  2585. warn('Multiple root nodes returned from render function. Render function ' +
  2586. 'should return a single root node.', vm);
  2587. }
  2588. vnode = createEmptyVNode();
  2589. }
  2590. // set parent
  2591. vnode.parent = _parentVnode;
  2592. return vnode;
  2593. };
  2594. }
  2595. function ensureCtor(comp, base) {
  2596. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2597. comp = comp.default;
  2598. }
  2599. return isObject(comp) ? base.extend(comp) : comp;
  2600. }
  2601. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2602. const node = createEmptyVNode();
  2603. node.asyncFactory = factory;
  2604. node.asyncMeta = { data, context, children, tag };
  2605. return node;
  2606. }
  2607. function resolveAsyncComponent(factory, baseCtor) {
  2608. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2609. return factory.errorComp;
  2610. }
  2611. if (isDef(factory.resolved)) {
  2612. return factory.resolved;
  2613. }
  2614. const owner = currentRenderingInstance;
  2615. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2616. // already pending
  2617. factory.owners.push(owner);
  2618. }
  2619. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2620. return factory.loadingComp;
  2621. }
  2622. if (owner && !isDef(factory.owners)) {
  2623. const owners = (factory.owners = [owner]);
  2624. let sync = true;
  2625. let timerLoading = null;
  2626. let timerTimeout = null;
  2627. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2628. const forceRender = (renderCompleted) => {
  2629. for (let i = 0, l = owners.length; i < l; i++) {
  2630. owners[i].$forceUpdate();
  2631. }
  2632. if (renderCompleted) {
  2633. owners.length = 0;
  2634. if (timerLoading !== null) {
  2635. clearTimeout(timerLoading);
  2636. timerLoading = null;
  2637. }
  2638. if (timerTimeout !== null) {
  2639. clearTimeout(timerTimeout);
  2640. timerTimeout = null;
  2641. }
  2642. }
  2643. };
  2644. const resolve = once((res) => {
  2645. // cache resolved
  2646. factory.resolved = ensureCtor(res, baseCtor);
  2647. // invoke callbacks only if this is not a synchronous resolve
  2648. // (async resolves are shimmed as synchronous during SSR)
  2649. if (!sync) {
  2650. forceRender(true);
  2651. }
  2652. else {
  2653. owners.length = 0;
  2654. }
  2655. });
  2656. const reject = once(reason => {
  2657. warn(`Failed to resolve async component: ${String(factory)}` +
  2658. (reason ? `\nReason: ${reason}` : ''));
  2659. if (isDef(factory.errorComp)) {
  2660. factory.error = true;
  2661. forceRender(true);
  2662. }
  2663. });
  2664. const res = factory(resolve, reject);
  2665. if (isObject(res)) {
  2666. if (isPromise(res)) {
  2667. // () => Promise
  2668. if (isUndef(factory.resolved)) {
  2669. res.then(resolve, reject);
  2670. }
  2671. }
  2672. else if (isPromise(res.component)) {
  2673. res.component.then(resolve, reject);
  2674. if (isDef(res.error)) {
  2675. factory.errorComp = ensureCtor(res.error, baseCtor);
  2676. }
  2677. if (isDef(res.loading)) {
  2678. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2679. if (res.delay === 0) {
  2680. factory.loading = true;
  2681. }
  2682. else {
  2683. // @ts-expect-error NodeJS timeout type
  2684. timerLoading = setTimeout(() => {
  2685. timerLoading = null;
  2686. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2687. factory.loading = true;
  2688. forceRender(false);
  2689. }
  2690. }, res.delay || 200);
  2691. }
  2692. }
  2693. if (isDef(res.timeout)) {
  2694. // @ts-expect-error NodeJS timeout type
  2695. timerTimeout = setTimeout(() => {
  2696. timerTimeout = null;
  2697. if (isUndef(factory.resolved)) {
  2698. reject(`timeout (${res.timeout}ms)` );
  2699. }
  2700. }, res.timeout);
  2701. }
  2702. }
  2703. }
  2704. sync = false;
  2705. // return in case resolved synchronously
  2706. return factory.loading ? factory.loadingComp : factory.resolved;
  2707. }
  2708. }
  2709. function getFirstComponentChild(children) {
  2710. if (isArray(children)) {
  2711. for (let i = 0; i < children.length; i++) {
  2712. const c = children[i];
  2713. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2714. return c;
  2715. }
  2716. }
  2717. }
  2718. }
  2719. const SIMPLE_NORMALIZE = 1;
  2720. const ALWAYS_NORMALIZE = 2;
  2721. // wrapper function for providing a more flexible interface
  2722. // without getting yelled at by flow
  2723. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  2724. if (isArray(data) || isPrimitive(data)) {
  2725. normalizationType = children;
  2726. children = data;
  2727. data = undefined;
  2728. }
  2729. if (isTrue(alwaysNormalize)) {
  2730. normalizationType = ALWAYS_NORMALIZE;
  2731. }
  2732. return _createElement(context, tag, data, children, normalizationType);
  2733. }
  2734. function _createElement(context, tag, data, children, normalizationType) {
  2735. if (isDef(data) && isDef(data.__ob__)) {
  2736. warn(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  2737. return createEmptyVNode();
  2738. }
  2739. // object syntax in v-bind
  2740. if (isDef(data) && isDef(data.is)) {
  2741. tag = data.is;
  2742. }
  2743. if (!tag) {
  2744. // in case of component :is set to falsy value
  2745. return createEmptyVNode();
  2746. }
  2747. // warn against non-primitive key
  2748. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  2749. warn('Avoid using non-primitive value as key, ' +
  2750. 'use string/number value instead.', context);
  2751. }
  2752. // support single function children as default scoped slot
  2753. if (isArray(children) && isFunction(children[0])) {
  2754. data = data || {};
  2755. data.scopedSlots = { default: children[0] };
  2756. children.length = 0;
  2757. }
  2758. if (normalizationType === ALWAYS_NORMALIZE) {
  2759. children = normalizeChildren(children);
  2760. }
  2761. else if (normalizationType === SIMPLE_NORMALIZE) {
  2762. children = simpleNormalizeChildren(children);
  2763. }
  2764. let vnode, ns;
  2765. if (typeof tag === 'string') {
  2766. let Ctor;
  2767. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  2768. if (config.isReservedTag(tag)) {
  2769. // platform built-in elements
  2770. if (isDef(data) &&
  2771. isDef(data.nativeOn) &&
  2772. data.tag !== 'component') {
  2773. warn(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  2774. }
  2775. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  2776. }
  2777. else if ((!data || !data.pre) &&
  2778. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  2779. // component
  2780. vnode = createComponent(Ctor, data, context, children, tag);
  2781. }
  2782. else {
  2783. // unknown or unlisted namespaced elements
  2784. // check at runtime because it may get assigned a namespace when its
  2785. // parent normalizes children
  2786. vnode = new VNode(tag, data, children, undefined, undefined, context);
  2787. }
  2788. }
  2789. else {
  2790. // direct component options / constructor
  2791. vnode = createComponent(tag, data, context, children);
  2792. }
  2793. if (isArray(vnode)) {
  2794. return vnode;
  2795. }
  2796. else if (isDef(vnode)) {
  2797. if (isDef(ns))
  2798. applyNS(vnode, ns);
  2799. if (isDef(data))
  2800. registerDeepBindings(data);
  2801. return vnode;
  2802. }
  2803. else {
  2804. return createEmptyVNode();
  2805. }
  2806. }
  2807. function applyNS(vnode, ns, force) {
  2808. vnode.ns = ns;
  2809. if (vnode.tag === 'foreignObject') {
  2810. // use default namespace inside foreignObject
  2811. ns = undefined;
  2812. force = true;
  2813. }
  2814. if (isDef(vnode.children)) {
  2815. for (let i = 0, l = vnode.children.length; i < l; i++) {
  2816. const child = vnode.children[i];
  2817. if (isDef(child.tag) &&
  2818. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  2819. applyNS(child, ns, force);
  2820. }
  2821. }
  2822. }
  2823. }
  2824. // ref #5318
  2825. // necessary to ensure parent re-render when deep bindings like :style and
  2826. // :class are used on slot nodes
  2827. function registerDeepBindings(data) {
  2828. if (isObject(data.style)) {
  2829. traverse(data.style);
  2830. }
  2831. if (isObject(data.class)) {
  2832. traverse(data.class);
  2833. }
  2834. }
  2835. /**
  2836. * @internal this function needs manual public type declaration because it relies
  2837. * on previously manually authored types from Vue 2
  2838. */
  2839. function h(type, props, children) {
  2840. if (!currentInstance) {
  2841. warn(`globally imported h() can only be invoked when there is an active ` +
  2842. `component instance, e.g. synchronously in a component's render or setup function.`);
  2843. }
  2844. return createElement$1(currentInstance, type, props, children, 2, true);
  2845. }
  2846. function handleError(err, vm, info) {
  2847. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  2848. // See: https://github.com/vuejs/vuex/issues/1505
  2849. pushTarget();
  2850. try {
  2851. if (vm) {
  2852. let cur = vm;
  2853. while ((cur = cur.$parent)) {
  2854. const hooks = cur.$options.errorCaptured;
  2855. if (hooks) {
  2856. for (let i = 0; i < hooks.length; i++) {
  2857. try {
  2858. const capture = hooks[i].call(cur, err, vm, info) === false;
  2859. if (capture)
  2860. return;
  2861. }
  2862. catch (e) {
  2863. globalHandleError(e, cur, 'errorCaptured hook');
  2864. }
  2865. }
  2866. }
  2867. }
  2868. }
  2869. globalHandleError(err, vm, info);
  2870. }
  2871. finally {
  2872. popTarget();
  2873. }
  2874. }
  2875. function invokeWithErrorHandling(handler, context, args, vm, info) {
  2876. let res;
  2877. try {
  2878. res = args ? handler.apply(context, args) : handler.call(context);
  2879. if (res && !res._isVue && isPromise(res) && !res._handled) {
  2880. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  2881. res._handled = true;
  2882. }
  2883. }
  2884. catch (e) {
  2885. handleError(e, vm, info);
  2886. }
  2887. return res;
  2888. }
  2889. function globalHandleError(err, vm, info) {
  2890. if (config.errorHandler) {
  2891. try {
  2892. return config.errorHandler.call(null, err, vm, info);
  2893. }
  2894. catch (e) {
  2895. // if the user intentionally throws the original error in the handler,
  2896. // do not log it twice
  2897. if (e !== err) {
  2898. logError(e, null, 'config.errorHandler');
  2899. }
  2900. }
  2901. }
  2902. logError(err, vm, info);
  2903. }
  2904. function logError(err, vm, info) {
  2905. {
  2906. warn(`Error in ${info}: "${err.toString()}"`, vm);
  2907. }
  2908. /* istanbul ignore else */
  2909. if (inBrowser && typeof console !== 'undefined') {
  2910. console.error(err);
  2911. }
  2912. else {
  2913. throw err;
  2914. }
  2915. }
  2916. /* globals MutationObserver */
  2917. let isUsingMicroTask = false;
  2918. const callbacks = [];
  2919. let pending = false;
  2920. function flushCallbacks() {
  2921. pending = false;
  2922. const copies = callbacks.slice(0);
  2923. callbacks.length = 0;
  2924. for (let i = 0; i < copies.length; i++) {
  2925. copies[i]();
  2926. }
  2927. }
  2928. // Here we have async deferring wrappers using microtasks.
  2929. // In 2.5 we used (macro) tasks (in combination with microtasks).
  2930. // However, it has subtle problems when state is changed right before repaint
  2931. // (e.g. #6813, out-in transitions).
  2932. // Also, using (macro) tasks in event handler would cause some weird behaviors
  2933. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  2934. // So we now use microtasks everywhere, again.
  2935. // A major drawback of this tradeoff is that there are some scenarios
  2936. // where microtasks have too high a priority and fire in between supposedly
  2937. // sequential events (e.g. #4521, #6690, which have workarounds)
  2938. // or even between bubbling of the same event (#6566).
  2939. let timerFunc;
  2940. // The nextTick behavior leverages the microtask queue, which can be accessed
  2941. // via either native Promise.then or MutationObserver.
  2942. // MutationObserver has wider support, however it is seriously bugged in
  2943. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  2944. // completely stops working after triggering a few times... so, if native
  2945. // Promise is available, we will use it:
  2946. /* istanbul ignore next, $flow-disable-line */
  2947. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  2948. const p = Promise.resolve();
  2949. timerFunc = () => {
  2950. p.then(flushCallbacks);
  2951. // In problematic UIWebViews, Promise.then doesn't completely break, but
  2952. // it can get stuck in a weird state where callbacks are pushed into the
  2953. // microtask queue but the queue isn't being flushed, until the browser
  2954. // needs to do some other work, e.g. handle a timer. Therefore we can
  2955. // "force" the microtask queue to be flushed by adding an empty timer.
  2956. if (isIOS)
  2957. setTimeout(noop);
  2958. };
  2959. isUsingMicroTask = true;
  2960. }
  2961. else if (!isIE &&
  2962. typeof MutationObserver !== 'undefined' &&
  2963. (isNative(MutationObserver) ||
  2964. // PhantomJS and iOS 7.x
  2965. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  2966. // Use MutationObserver where native Promise is not available,
  2967. // e.g. PhantomJS, iOS7, Android 4.4
  2968. // (#6466 MutationObserver is unreliable in IE11)
  2969. let counter = 1;
  2970. const observer = new MutationObserver(flushCallbacks);
  2971. const textNode = document.createTextNode(String(counter));
  2972. observer.observe(textNode, {
  2973. characterData: true
  2974. });
  2975. timerFunc = () => {
  2976. counter = (counter + 1) % 2;
  2977. textNode.data = String(counter);
  2978. };
  2979. isUsingMicroTask = true;
  2980. }
  2981. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  2982. // Fallback to setImmediate.
  2983. // Technically it leverages the (macro) task queue,
  2984. // but it is still a better choice than setTimeout.
  2985. timerFunc = () => {
  2986. setImmediate(flushCallbacks);
  2987. };
  2988. }
  2989. else {
  2990. // Fallback to setTimeout.
  2991. timerFunc = () => {
  2992. setTimeout(flushCallbacks, 0);
  2993. };
  2994. }
  2995. /**
  2996. * @internal
  2997. */
  2998. function nextTick(cb, ctx) {
  2999. let _resolve;
  3000. callbacks.push(() => {
  3001. if (cb) {
  3002. try {
  3003. cb.call(ctx);
  3004. }
  3005. catch (e) {
  3006. handleError(e, ctx, 'nextTick');
  3007. }
  3008. }
  3009. else if (_resolve) {
  3010. _resolve(ctx);
  3011. }
  3012. });
  3013. if (!pending) {
  3014. pending = true;
  3015. timerFunc();
  3016. }
  3017. // $flow-disable-line
  3018. if (!cb && typeof Promise !== 'undefined') {
  3019. return new Promise(resolve => {
  3020. _resolve = resolve;
  3021. });
  3022. }
  3023. }
  3024. function useCssModule(name = '$style') {
  3025. /* istanbul ignore else */
  3026. {
  3027. if (!currentInstance) {
  3028. warn(`useCssModule must be called inside setup()`);
  3029. return emptyObject;
  3030. }
  3031. const mod = currentInstance[name];
  3032. if (!mod) {
  3033. warn(`Current instance does not have CSS module named "${name}".`);
  3034. return emptyObject;
  3035. }
  3036. return mod;
  3037. }
  3038. }
  3039. /**
  3040. * Runtime helper for SFC's CSS variable injection feature.
  3041. * @private
  3042. */
  3043. function useCssVars(getter) {
  3044. if (!inBrowser && !false)
  3045. return;
  3046. const instance = currentInstance;
  3047. if (!instance) {
  3048. warn(`useCssVars is called without current active component instance.`);
  3049. return;
  3050. }
  3051. watchPostEffect(() => {
  3052. const el = instance.$el;
  3053. const vars = getter(instance, instance._setupProxy);
  3054. if (el && el.nodeType === 1) {
  3055. const style = el.style;
  3056. for (const key in vars) {
  3057. style.setProperty(`--${key}`, vars[key]);
  3058. }
  3059. }
  3060. });
  3061. }
  3062. /**
  3063. * v3-compatible async component API.
  3064. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3065. * because it relies on existing manual types
  3066. */
  3067. function defineAsyncComponent(source) {
  3068. if (isFunction(source)) {
  3069. source = { loader: source };
  3070. }
  3071. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3072. suspensible = false, // in Vue 3 default is true
  3073. onError: userOnError } = source;
  3074. if (suspensible) {
  3075. warn(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
  3076. }
  3077. let pendingRequest = null;
  3078. let retries = 0;
  3079. const retry = () => {
  3080. retries++;
  3081. pendingRequest = null;
  3082. return load();
  3083. };
  3084. const load = () => {
  3085. let thisRequest;
  3086. return (pendingRequest ||
  3087. (thisRequest = pendingRequest =
  3088. loader()
  3089. .catch(err => {
  3090. err = err instanceof Error ? err : new Error(String(err));
  3091. if (userOnError) {
  3092. return new Promise((resolve, reject) => {
  3093. const userRetry = () => resolve(retry());
  3094. const userFail = () => reject(err);
  3095. userOnError(err, userRetry, userFail, retries + 1);
  3096. });
  3097. }
  3098. else {
  3099. throw err;
  3100. }
  3101. })
  3102. .then((comp) => {
  3103. if (thisRequest !== pendingRequest && pendingRequest) {
  3104. return pendingRequest;
  3105. }
  3106. if (!comp) {
  3107. warn(`Async component loader resolved to undefined. ` +
  3108. `If you are using retry(), make sure to return its return value.`);
  3109. }
  3110. // interop module default
  3111. if (comp &&
  3112. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3113. comp = comp.default;
  3114. }
  3115. if (comp && !isObject(comp) && !isFunction(comp)) {
  3116. throw new Error(`Invalid async component load result: ${comp}`);
  3117. }
  3118. return comp;
  3119. })));
  3120. };
  3121. return () => {
  3122. const component = load();
  3123. return {
  3124. component,
  3125. delay,
  3126. timeout,
  3127. error: errorComponent,
  3128. loading: loadingComponent
  3129. };
  3130. };
  3131. }
  3132. function createLifeCycle(hookName) {
  3133. return (fn, target = currentInstance) => {
  3134. if (!target) {
  3135. warn(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3136. `associated with. ` +
  3137. `Lifecycle injection APIs can only be used during execution of setup().`);
  3138. return;
  3139. }
  3140. return injectHook(target, hookName, fn);
  3141. };
  3142. }
  3143. function formatName(name) {
  3144. if (name === 'beforeDestroy') {
  3145. name = 'beforeUnmount';
  3146. }
  3147. else if (name === 'destroyed') {
  3148. name = 'unmounted';
  3149. }
  3150. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3151. }
  3152. function injectHook(instance, hookName, fn) {
  3153. const options = instance.$options;
  3154. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3155. }
  3156. const onBeforeMount = createLifeCycle('beforeMount');
  3157. const onMounted = createLifeCycle('mounted');
  3158. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3159. const onUpdated = createLifeCycle('updated');
  3160. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3161. const onUnmounted = createLifeCycle('destroyed');
  3162. const onActivated = createLifeCycle('activated');
  3163. const onDeactivated = createLifeCycle('deactivated');
  3164. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3165. const onRenderTracked = createLifeCycle('renderTracked');
  3166. const onRenderTriggered = createLifeCycle('renderTriggered');
  3167. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3168. function onErrorCaptured(hook, target = currentInstance) {
  3169. injectErrorCapturedHook(hook, target);
  3170. }
  3171. /**
  3172. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3173. */
  3174. const version = '2.7.14';
  3175. /**
  3176. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3177. */
  3178. function defineComponent(options) {
  3179. return options;
  3180. }
  3181. var vca = /*#__PURE__*/Object.freeze({
  3182. __proto__: null,
  3183. version: version,
  3184. defineComponent: defineComponent,
  3185. ref: ref$1,
  3186. shallowRef: shallowRef,
  3187. isRef: isRef,
  3188. toRef: toRef,
  3189. toRefs: toRefs,
  3190. unref: unref,
  3191. proxyRefs: proxyRefs,
  3192. customRef: customRef,
  3193. triggerRef: triggerRef,
  3194. reactive: reactive,
  3195. isReactive: isReactive,
  3196. isReadonly: isReadonly,
  3197. isShallow: isShallow,
  3198. isProxy: isProxy,
  3199. shallowReactive: shallowReactive,
  3200. markRaw: markRaw,
  3201. toRaw: toRaw,
  3202. readonly: readonly,
  3203. shallowReadonly: shallowReadonly,
  3204. computed: computed,
  3205. watch: watch,
  3206. watchEffect: watchEffect,
  3207. watchPostEffect: watchPostEffect,
  3208. watchSyncEffect: watchSyncEffect,
  3209. EffectScope: EffectScope,
  3210. effectScope: effectScope,
  3211. onScopeDispose: onScopeDispose,
  3212. getCurrentScope: getCurrentScope,
  3213. provide: provide,
  3214. inject: inject,
  3215. h: h,
  3216. getCurrentInstance: getCurrentInstance,
  3217. useSlots: useSlots,
  3218. useAttrs: useAttrs,
  3219. useListeners: useListeners,
  3220. mergeDefaults: mergeDefaults,
  3221. nextTick: nextTick,
  3222. set: set,
  3223. del: del,
  3224. useCssModule: useCssModule,
  3225. useCssVars: useCssVars,
  3226. defineAsyncComponent: defineAsyncComponent,
  3227. onBeforeMount: onBeforeMount,
  3228. onMounted: onMounted,
  3229. onBeforeUpdate: onBeforeUpdate,
  3230. onUpdated: onUpdated,
  3231. onBeforeUnmount: onBeforeUnmount,
  3232. onUnmounted: onUnmounted,
  3233. onActivated: onActivated,
  3234. onDeactivated: onDeactivated,
  3235. onServerPrefetch: onServerPrefetch,
  3236. onRenderTracked: onRenderTracked,
  3237. onRenderTriggered: onRenderTriggered,
  3238. onErrorCaptured: onErrorCaptured
  3239. });
  3240. const seenObjects = new _Set();
  3241. /**
  3242. * Recursively traverse an object to evoke all converted
  3243. * getters, so that every nested property inside the object
  3244. * is collected as a "deep" dependency.
  3245. */
  3246. function traverse(val) {
  3247. _traverse(val, seenObjects);
  3248. seenObjects.clear();
  3249. return val;
  3250. }
  3251. function _traverse(val, seen) {
  3252. let i, keys;
  3253. const isA = isArray(val);
  3254. if ((!isA && !isObject(val)) ||
  3255. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3256. Object.isFrozen(val) ||
  3257. val instanceof VNode) {
  3258. return;
  3259. }
  3260. if (val.__ob__) {
  3261. const depId = val.__ob__.dep.id;
  3262. if (seen.has(depId)) {
  3263. return;
  3264. }
  3265. seen.add(depId);
  3266. }
  3267. if (isA) {
  3268. i = val.length;
  3269. while (i--)
  3270. _traverse(val[i], seen);
  3271. }
  3272. else if (isRef(val)) {
  3273. _traverse(val.value, seen);
  3274. }
  3275. else {
  3276. keys = Object.keys(val);
  3277. i = keys.length;
  3278. while (i--)
  3279. _traverse(val[keys[i]], seen);
  3280. }
  3281. }
  3282. let uid$1 = 0;
  3283. /**
  3284. * A watcher parses an expression, collects dependencies,
  3285. * and fires callback when the expression value changes.
  3286. * This is used for both the $watch() api and directives.
  3287. * @internal
  3288. */
  3289. class Watcher {
  3290. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3291. recordEffectScope(this,
  3292. // if the active effect scope is manually created (not a component scope),
  3293. // prioritize it
  3294. activeEffectScope && !activeEffectScope._vm
  3295. ? activeEffectScope
  3296. : vm
  3297. ? vm._scope
  3298. : undefined);
  3299. if ((this.vm = vm) && isRenderWatcher) {
  3300. vm._watcher = this;
  3301. }
  3302. // options
  3303. if (options) {
  3304. this.deep = !!options.deep;
  3305. this.user = !!options.user;
  3306. this.lazy = !!options.lazy;
  3307. this.sync = !!options.sync;
  3308. this.before = options.before;
  3309. {
  3310. this.onTrack = options.onTrack;
  3311. this.onTrigger = options.onTrigger;
  3312. }
  3313. }
  3314. else {
  3315. this.deep = this.user = this.lazy = this.sync = false;
  3316. }
  3317. this.cb = cb;
  3318. this.id = ++uid$1; // uid for batching
  3319. this.active = true;
  3320. this.post = false;
  3321. this.dirty = this.lazy; // for lazy watchers
  3322. this.deps = [];
  3323. this.newDeps = [];
  3324. this.depIds = new _Set();
  3325. this.newDepIds = new _Set();
  3326. this.expression = expOrFn.toString() ;
  3327. // parse expression for getter
  3328. if (isFunction(expOrFn)) {
  3329. this.getter = expOrFn;
  3330. }
  3331. else {
  3332. this.getter = parsePath(expOrFn);
  3333. if (!this.getter) {
  3334. this.getter = noop;
  3335. warn(`Failed watching path: "${expOrFn}" ` +
  3336. 'Watcher only accepts simple dot-delimited paths. ' +
  3337. 'For full control, use a function instead.', vm);
  3338. }
  3339. }
  3340. this.value = this.lazy ? undefined : this.get();
  3341. }
  3342. /**
  3343. * Evaluate the getter, and re-collect dependencies.
  3344. */
  3345. get() {
  3346. pushTarget(this);
  3347. let value;
  3348. const vm = this.vm;
  3349. try {
  3350. value = this.getter.call(vm, vm);
  3351. }
  3352. catch (e) {
  3353. if (this.user) {
  3354. handleError(e, vm, `getter for watcher "${this.expression}"`);
  3355. }
  3356. else {
  3357. throw e;
  3358. }
  3359. }
  3360. finally {
  3361. // "touch" every property so they are all tracked as
  3362. // dependencies for deep watching
  3363. if (this.deep) {
  3364. traverse(value);
  3365. }
  3366. popTarget();
  3367. this.cleanupDeps();
  3368. }
  3369. return value;
  3370. }
  3371. /**
  3372. * Add a dependency to this directive.
  3373. */
  3374. addDep(dep) {
  3375. const id = dep.id;
  3376. if (!this.newDepIds.has(id)) {
  3377. this.newDepIds.add(id);
  3378. this.newDeps.push(dep);
  3379. if (!this.depIds.has(id)) {
  3380. dep.addSub(this);
  3381. }
  3382. }
  3383. }
  3384. /**
  3385. * Clean up for dependency collection.
  3386. */
  3387. cleanupDeps() {
  3388. let i = this.deps.length;
  3389. while (i--) {
  3390. const dep = this.deps[i];
  3391. if (!this.newDepIds.has(dep.id)) {
  3392. dep.removeSub(this);
  3393. }
  3394. }
  3395. let tmp = this.depIds;
  3396. this.depIds = this.newDepIds;
  3397. this.newDepIds = tmp;
  3398. this.newDepIds.clear();
  3399. tmp = this.deps;
  3400. this.deps = this.newDeps;
  3401. this.newDeps = tmp;
  3402. this.newDeps.length = 0;
  3403. }
  3404. /**
  3405. * Subscriber interface.
  3406. * Will be called when a dependency changes.
  3407. */
  3408. update() {
  3409. /* istanbul ignore else */
  3410. if (this.lazy) {
  3411. this.dirty = true;
  3412. }
  3413. else if (this.sync) {
  3414. this.run();
  3415. }
  3416. else {
  3417. queueWatcher(this);
  3418. }
  3419. }
  3420. /**
  3421. * Scheduler job interface.
  3422. * Will be called by the scheduler.
  3423. */
  3424. run() {
  3425. if (this.active) {
  3426. const value = this.get();
  3427. if (value !== this.value ||
  3428. // Deep watchers and watchers on Object/Arrays should fire even
  3429. // when the value is the same, because the value may
  3430. // have mutated.
  3431. isObject(value) ||
  3432. this.deep) {
  3433. // set new value
  3434. const oldValue = this.value;
  3435. this.value = value;
  3436. if (this.user) {
  3437. const info = `callback for watcher "${this.expression}"`;
  3438. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  3439. }
  3440. else {
  3441. this.cb.call(this.vm, value, oldValue);
  3442. }
  3443. }
  3444. }
  3445. }
  3446. /**
  3447. * Evaluate the value of the watcher.
  3448. * This only gets called for lazy watchers.
  3449. */
  3450. evaluate() {
  3451. this.value = this.get();
  3452. this.dirty = false;
  3453. }
  3454. /**
  3455. * Depend on all deps collected by this watcher.
  3456. */
  3457. depend() {
  3458. let i = this.deps.length;
  3459. while (i--) {
  3460. this.deps[i].depend();
  3461. }
  3462. }
  3463. /**
  3464. * Remove self from all dependencies' subscriber list.
  3465. */
  3466. teardown() {
  3467. if (this.vm && !this.vm._isBeingDestroyed) {
  3468. remove$2(this.vm._scope.effects, this);
  3469. }
  3470. if (this.active) {
  3471. let i = this.deps.length;
  3472. while (i--) {
  3473. this.deps[i].removeSub(this);
  3474. }
  3475. this.active = false;
  3476. if (this.onStop) {
  3477. this.onStop();
  3478. }
  3479. }
  3480. }
  3481. }
  3482. let mark;
  3483. let measure;
  3484. {
  3485. const perf = inBrowser && window.performance;
  3486. /* istanbul ignore if */
  3487. if (perf &&
  3488. // @ts-ignore
  3489. perf.mark &&
  3490. // @ts-ignore
  3491. perf.measure &&
  3492. // @ts-ignore
  3493. perf.clearMarks &&
  3494. // @ts-ignore
  3495. perf.clearMeasures) {
  3496. mark = tag => perf.mark(tag);
  3497. measure = (name, startTag, endTag) => {
  3498. perf.measure(name, startTag, endTag);
  3499. perf.clearMarks(startTag);
  3500. perf.clearMarks(endTag);
  3501. // perf.clearMeasures(name)
  3502. };
  3503. }
  3504. }
  3505. function initEvents(vm) {
  3506. vm._events = Object.create(null);
  3507. vm._hasHookEvent = false;
  3508. // init parent attached events
  3509. const listeners = vm.$options._parentListeners;
  3510. if (listeners) {
  3511. updateComponentListeners(vm, listeners);
  3512. }
  3513. }
  3514. let target$1;
  3515. function add$1(event, fn) {
  3516. target$1.$on(event, fn);
  3517. }
  3518. function remove$1(event, fn) {
  3519. target$1.$off(event, fn);
  3520. }
  3521. function createOnceHandler$1(event, fn) {
  3522. const _target = target$1;
  3523. return function onceHandler() {
  3524. const res = fn.apply(null, arguments);
  3525. if (res !== null) {
  3526. _target.$off(event, onceHandler);
  3527. }
  3528. };
  3529. }
  3530. function updateComponentListeners(vm, listeners, oldListeners) {
  3531. target$1 = vm;
  3532. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  3533. target$1 = undefined;
  3534. }
  3535. function eventsMixin(Vue) {
  3536. const hookRE = /^hook:/;
  3537. Vue.prototype.$on = function (event, fn) {
  3538. const vm = this;
  3539. if (isArray(event)) {
  3540. for (let i = 0, l = event.length; i < l; i++) {
  3541. vm.$on(event[i], fn);
  3542. }
  3543. }
  3544. else {
  3545. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3546. // optimize hook:event cost by using a boolean flag marked at registration
  3547. // instead of a hash lookup
  3548. if (hookRE.test(event)) {
  3549. vm._hasHookEvent = true;
  3550. }
  3551. }
  3552. return vm;
  3553. };
  3554. Vue.prototype.$once = function (event, fn) {
  3555. const vm = this;
  3556. function on() {
  3557. vm.$off(event, on);
  3558. fn.apply(vm, arguments);
  3559. }
  3560. on.fn = fn;
  3561. vm.$on(event, on);
  3562. return vm;
  3563. };
  3564. Vue.prototype.$off = function (event, fn) {
  3565. const vm = this;
  3566. // all
  3567. if (!arguments.length) {
  3568. vm._events = Object.create(null);
  3569. return vm;
  3570. }
  3571. // array of events
  3572. if (isArray(event)) {
  3573. for (let i = 0, l = event.length; i < l; i++) {
  3574. vm.$off(event[i], fn);
  3575. }
  3576. return vm;
  3577. }
  3578. // specific event
  3579. const cbs = vm._events[event];
  3580. if (!cbs) {
  3581. return vm;
  3582. }
  3583. if (!fn) {
  3584. vm._events[event] = null;
  3585. return vm;
  3586. }
  3587. // specific handler
  3588. let cb;
  3589. let i = cbs.length;
  3590. while (i--) {
  3591. cb = cbs[i];
  3592. if (cb === fn || cb.fn === fn) {
  3593. cbs.splice(i, 1);
  3594. break;
  3595. }
  3596. }
  3597. return vm;
  3598. };
  3599. Vue.prototype.$emit = function (event) {
  3600. const vm = this;
  3601. {
  3602. const lowerCaseEvent = event.toLowerCase();
  3603. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3604. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  3605. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  3606. `Note that HTML attributes are case-insensitive and you cannot use ` +
  3607. `v-on to listen to camelCase events when using in-DOM templates. ` +
  3608. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  3609. }
  3610. }
  3611. let cbs = vm._events[event];
  3612. if (cbs) {
  3613. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3614. const args = toArray(arguments, 1);
  3615. const info = `event handler for "${event}"`;
  3616. for (let i = 0, l = cbs.length; i < l; i++) {
  3617. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3618. }
  3619. }
  3620. return vm;
  3621. };
  3622. }
  3623. let activeInstance = null;
  3624. let isUpdatingChildComponent = false;
  3625. function setActiveInstance(vm) {
  3626. const prevActiveInstance = activeInstance;
  3627. activeInstance = vm;
  3628. return () => {
  3629. activeInstance = prevActiveInstance;
  3630. };
  3631. }
  3632. function initLifecycle(vm) {
  3633. const options = vm.$options;
  3634. // locate first non-abstract parent
  3635. let parent = options.parent;
  3636. if (parent && !options.abstract) {
  3637. while (parent.$options.abstract && parent.$parent) {
  3638. parent = parent.$parent;
  3639. }
  3640. parent.$children.push(vm);
  3641. }
  3642. vm.$parent = parent;
  3643. vm.$root = parent ? parent.$root : vm;
  3644. vm.$children = [];
  3645. vm.$refs = {};
  3646. vm._provided = parent ? parent._provided : Object.create(null);
  3647. vm._watcher = null;
  3648. vm._inactive = null;
  3649. vm._directInactive = false;
  3650. vm._isMounted = false;
  3651. vm._isDestroyed = false;
  3652. vm._isBeingDestroyed = false;
  3653. }
  3654. function lifecycleMixin(Vue) {
  3655. Vue.prototype._update = function (vnode, hydrating) {
  3656. const vm = this;
  3657. const prevEl = vm.$el;
  3658. const prevVnode = vm._vnode;
  3659. const restoreActiveInstance = setActiveInstance(vm);
  3660. vm._vnode = vnode;
  3661. // Vue.prototype.__patch__ is injected in entry points
  3662. // based on the rendering backend used.
  3663. if (!prevVnode) {
  3664. // initial render
  3665. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3666. }
  3667. else {
  3668. // updates
  3669. vm.$el = vm.__patch__(prevVnode, vnode);
  3670. }
  3671. restoreActiveInstance();
  3672. // update __vue__ reference
  3673. if (prevEl) {
  3674. prevEl.__vue__ = null;
  3675. }
  3676. if (vm.$el) {
  3677. vm.$el.__vue__ = vm;
  3678. }
  3679. // if parent is an HOC, update its $el as well
  3680. let wrapper = vm;
  3681. while (wrapper &&
  3682. wrapper.$vnode &&
  3683. wrapper.$parent &&
  3684. wrapper.$vnode === wrapper.$parent._vnode) {
  3685. wrapper.$parent.$el = wrapper.$el;
  3686. wrapper = wrapper.$parent;
  3687. }
  3688. // updated hook is called by the scheduler to ensure that children are
  3689. // updated in a parent's updated hook.
  3690. };
  3691. Vue.prototype.$forceUpdate = function () {
  3692. const vm = this;
  3693. if (vm._watcher) {
  3694. vm._watcher.update();
  3695. }
  3696. };
  3697. Vue.prototype.$destroy = function () {
  3698. const vm = this;
  3699. if (vm._isBeingDestroyed) {
  3700. return;
  3701. }
  3702. callHook$1(vm, 'beforeDestroy');
  3703. vm._isBeingDestroyed = true;
  3704. // remove self from parent
  3705. const parent = vm.$parent;
  3706. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3707. remove$2(parent.$children, vm);
  3708. }
  3709. // teardown scope. this includes both the render watcher and other
  3710. // watchers created
  3711. vm._scope.stop();
  3712. // remove reference from data ob
  3713. // frozen object may not have observer.
  3714. if (vm._data.__ob__) {
  3715. vm._data.__ob__.vmCount--;
  3716. }
  3717. // call the last hook...
  3718. vm._isDestroyed = true;
  3719. // invoke destroy hooks on current rendered tree
  3720. vm.__patch__(vm._vnode, null);
  3721. // fire destroyed hook
  3722. callHook$1(vm, 'destroyed');
  3723. // turn off all instance listeners.
  3724. vm.$off();
  3725. // remove __vue__ reference
  3726. if (vm.$el) {
  3727. vm.$el.__vue__ = null;
  3728. }
  3729. // release circular reference (#6759)
  3730. if (vm.$vnode) {
  3731. vm.$vnode.parent = null;
  3732. }
  3733. };
  3734. }
  3735. function mountComponent(vm, el, hydrating) {
  3736. vm.$el = el;
  3737. if (!vm.$options.render) {
  3738. // @ts-expect-error invalid type
  3739. vm.$options.render = createEmptyVNode;
  3740. {
  3741. /* istanbul ignore if */
  3742. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3743. vm.$options.el ||
  3744. el) {
  3745. warn('You are using the runtime-only build of Vue where the template ' +
  3746. 'compiler is not available. Either pre-compile the templates into ' +
  3747. 'render functions, or use the compiler-included build.', vm);
  3748. }
  3749. else {
  3750. warn('Failed to mount component: template or render function not defined.', vm);
  3751. }
  3752. }
  3753. }
  3754. callHook$1(vm, 'beforeMount');
  3755. let updateComponent;
  3756. /* istanbul ignore if */
  3757. if (config.performance && mark) {
  3758. updateComponent = () => {
  3759. const name = vm._name;
  3760. const id = vm._uid;
  3761. const startTag = `vue-perf-start:${id}`;
  3762. const endTag = `vue-perf-end:${id}`;
  3763. mark(startTag);
  3764. const vnode = vm._render();
  3765. mark(endTag);
  3766. measure(`vue ${name} render`, startTag, endTag);
  3767. mark(startTag);
  3768. vm._update(vnode, hydrating);
  3769. mark(endTag);
  3770. measure(`vue ${name} patch`, startTag, endTag);
  3771. };
  3772. }
  3773. else {
  3774. updateComponent = () => {
  3775. vm._update(vm._render(), hydrating);
  3776. };
  3777. }
  3778. const watcherOptions = {
  3779. before() {
  3780. if (vm._isMounted && !vm._isDestroyed) {
  3781. callHook$1(vm, 'beforeUpdate');
  3782. }
  3783. }
  3784. };
  3785. {
  3786. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  3787. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  3788. }
  3789. // we set this to vm._watcher inside the watcher's constructor
  3790. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3791. // component's mounted hook), which relies on vm._watcher being already defined
  3792. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  3793. hydrating = false;
  3794. // flush buffer for flush: "pre" watchers queued in setup()
  3795. const preWatchers = vm._preWatchers;
  3796. if (preWatchers) {
  3797. for (let i = 0; i < preWatchers.length; i++) {
  3798. preWatchers[i].run();
  3799. }
  3800. }
  3801. // manually mounted instance, call mounted on self
  3802. // mounted is called for render-created child components in its inserted hook
  3803. if (vm.$vnode == null) {
  3804. vm._isMounted = true;
  3805. callHook$1(vm, 'mounted');
  3806. }
  3807. return vm;
  3808. }
  3809. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  3810. {
  3811. isUpdatingChildComponent = true;
  3812. }
  3813. // determine whether component has slot children
  3814. // we need to do this before overwriting $options._renderChildren.
  3815. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3816. // dynamic slot names). Static scoped slots compiled from template has the
  3817. // "$stable" marker.
  3818. const newScopedSlots = parentVnode.data.scopedSlots;
  3819. const oldScopedSlots = vm.$scopedSlots;
  3820. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  3821. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3822. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3823. (!newScopedSlots && vm.$scopedSlots.$key));
  3824. // Any static slot children from the parent may have changed during parent's
  3825. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3826. // update is necessary to ensure correctness.
  3827. let needsForceUpdate = !!(renderChildren || // has new static slots
  3828. vm.$options._renderChildren || // has old static slots
  3829. hasDynamicScopedSlot);
  3830. const prevVNode = vm.$vnode;
  3831. vm.$options._parentVnode = parentVnode;
  3832. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3833. if (vm._vnode) {
  3834. // update child tree's parent
  3835. vm._vnode.parent = parentVnode;
  3836. }
  3837. vm.$options._renderChildren = renderChildren;
  3838. // update $attrs and $listeners hash
  3839. // these are also reactive so they may trigger child update if the child
  3840. // used them during render
  3841. const attrs = parentVnode.data.attrs || emptyObject;
  3842. if (vm._attrsProxy) {
  3843. // force update if attrs are accessed and has changed since it may be
  3844. // passed to a child component.
  3845. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  3846. needsForceUpdate = true;
  3847. }
  3848. }
  3849. vm.$attrs = attrs;
  3850. // update listeners
  3851. listeners = listeners || emptyObject;
  3852. const prevListeners = vm.$options._parentListeners;
  3853. if (vm._listenersProxy) {
  3854. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  3855. }
  3856. vm.$listeners = vm.$options._parentListeners = listeners;
  3857. updateComponentListeners(vm, listeners, prevListeners);
  3858. // update props
  3859. if (propsData && vm.$options.props) {
  3860. toggleObserving(false);
  3861. const props = vm._props;
  3862. const propKeys = vm.$options._propKeys || [];
  3863. for (let i = 0; i < propKeys.length; i++) {
  3864. const key = propKeys[i];
  3865. const propOptions = vm.$options.props; // wtf flow?
  3866. props[key] = validateProp(key, propOptions, propsData, vm);
  3867. }
  3868. toggleObserving(true);
  3869. // keep a copy of raw propsData
  3870. vm.$options.propsData = propsData;
  3871. }
  3872. // resolve slots + force update if has children
  3873. if (needsForceUpdate) {
  3874. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3875. vm.$forceUpdate();
  3876. }
  3877. {
  3878. isUpdatingChildComponent = false;
  3879. }
  3880. }
  3881. function isInInactiveTree(vm) {
  3882. while (vm && (vm = vm.$parent)) {
  3883. if (vm._inactive)
  3884. return true;
  3885. }
  3886. return false;
  3887. }
  3888. function activateChildComponent(vm, direct) {
  3889. if (direct) {
  3890. vm._directInactive = false;
  3891. if (isInInactiveTree(vm)) {
  3892. return;
  3893. }
  3894. }
  3895. else if (vm._directInactive) {
  3896. return;
  3897. }
  3898. if (vm._inactive || vm._inactive === null) {
  3899. vm._inactive = false;
  3900. for (let i = 0; i < vm.$children.length; i++) {
  3901. activateChildComponent(vm.$children[i]);
  3902. }
  3903. callHook$1(vm, 'activated');
  3904. }
  3905. }
  3906. function deactivateChildComponent(vm, direct) {
  3907. if (direct) {
  3908. vm._directInactive = true;
  3909. if (isInInactiveTree(vm)) {
  3910. return;
  3911. }
  3912. }
  3913. if (!vm._inactive) {
  3914. vm._inactive = true;
  3915. for (let i = 0; i < vm.$children.length; i++) {
  3916. deactivateChildComponent(vm.$children[i]);
  3917. }
  3918. callHook$1(vm, 'deactivated');
  3919. }
  3920. }
  3921. function callHook$1(vm, hook, args, setContext = true) {
  3922. // #7573 disable dep collection when invoking lifecycle hooks
  3923. pushTarget();
  3924. const prev = currentInstance;
  3925. setContext && setCurrentInstance(vm);
  3926. const handlers = vm.$options[hook];
  3927. const info = `${hook} hook`;
  3928. if (handlers) {
  3929. for (let i = 0, j = handlers.length; i < j; i++) {
  3930. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3931. }
  3932. }
  3933. if (vm._hasHookEvent) {
  3934. vm.$emit('hook:' + hook);
  3935. }
  3936. setContext && setCurrentInstance(prev);
  3937. popTarget();
  3938. }
  3939. const MAX_UPDATE_COUNT = 100;
  3940. const queue = [];
  3941. const activatedChildren = [];
  3942. let has = {};
  3943. let circular = {};
  3944. let waiting = false;
  3945. let flushing = false;
  3946. let index = 0;
  3947. /**
  3948. * Reset the scheduler's state.
  3949. */
  3950. function resetSchedulerState() {
  3951. index = queue.length = activatedChildren.length = 0;
  3952. has = {};
  3953. {
  3954. circular = {};
  3955. }
  3956. waiting = flushing = false;
  3957. }
  3958. // Async edge case #6566 requires saving the timestamp when event listeners are
  3959. // attached. However, calling performance.now() has a perf overhead especially
  3960. // if the page has thousands of event listeners. Instead, we take a timestamp
  3961. // every time the scheduler flushes and use that for all event listeners
  3962. // attached during that flush.
  3963. let currentFlushTimestamp = 0;
  3964. // Async edge case fix requires storing an event listener's attach timestamp.
  3965. let getNow = Date.now;
  3966. // Determine what event timestamp the browser is using. Annoyingly, the
  3967. // timestamp can either be hi-res (relative to page load) or low-res
  3968. // (relative to UNIX epoch), so in order to compare time we have to use the
  3969. // same timestamp type when saving the flush timestamp.
  3970. // All IE versions use low-res event timestamps, and have problematic clock
  3971. // implementations (#9632)
  3972. if (inBrowser && !isIE) {
  3973. const performance = window.performance;
  3974. if (performance &&
  3975. typeof performance.now === 'function' &&
  3976. getNow() > document.createEvent('Event').timeStamp) {
  3977. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3978. // smaller than it, it means the event is using a hi-res timestamp,
  3979. // and we need to use the hi-res version for event listener timestamps as
  3980. // well.
  3981. getNow = () => performance.now();
  3982. }
  3983. }
  3984. const sortCompareFn = (a, b) => {
  3985. if (a.post) {
  3986. if (!b.post)
  3987. return 1;
  3988. }
  3989. else if (b.post) {
  3990. return -1;
  3991. }
  3992. return a.id - b.id;
  3993. };
  3994. /**
  3995. * Flush both queues and run the watchers.
  3996. */
  3997. function flushSchedulerQueue() {
  3998. currentFlushTimestamp = getNow();
  3999. flushing = true;
  4000. let watcher, id;
  4001. // Sort queue before flush.
  4002. // This ensures that:
  4003. // 1. Components are updated from parent to child. (because parent is always
  4004. // created before the child)
  4005. // 2. A component's user watchers are run before its render watcher (because
  4006. // user watchers are created before the render watcher)
  4007. // 3. If a component is destroyed during a parent component's watcher run,
  4008. // its watchers can be skipped.
  4009. queue.sort(sortCompareFn);
  4010. // do not cache length because more watchers might be pushed
  4011. // as we run existing watchers
  4012. for (index = 0; index < queue.length; index++) {
  4013. watcher = queue[index];
  4014. if (watcher.before) {
  4015. watcher.before();
  4016. }
  4017. id = watcher.id;
  4018. has[id] = null;
  4019. watcher.run();
  4020. // in dev build, check and stop circular updates.
  4021. if (has[id] != null) {
  4022. circular[id] = (circular[id] || 0) + 1;
  4023. if (circular[id] > MAX_UPDATE_COUNT) {
  4024. warn('You may have an infinite update loop ' +
  4025. (watcher.user
  4026. ? `in watcher with expression "${watcher.expression}"`
  4027. : `in a component render function.`), watcher.vm);
  4028. break;
  4029. }
  4030. }
  4031. }
  4032. // keep copies of post queues before resetting state
  4033. const activatedQueue = activatedChildren.slice();
  4034. const updatedQueue = queue.slice();
  4035. resetSchedulerState();
  4036. // call component updated and activated hooks
  4037. callActivatedHooks(activatedQueue);
  4038. callUpdatedHooks(updatedQueue);
  4039. cleanupDeps();
  4040. // devtool hook
  4041. /* istanbul ignore if */
  4042. if (devtools && config.devtools) {
  4043. devtools.emit('flush');
  4044. }
  4045. }
  4046. function callUpdatedHooks(queue) {
  4047. let i = queue.length;
  4048. while (i--) {
  4049. const watcher = queue[i];
  4050. const vm = watcher.vm;
  4051. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  4052. callHook$1(vm, 'updated');
  4053. }
  4054. }
  4055. }
  4056. /**
  4057. * Queue a kept-alive component that was activated during patch.
  4058. * The queue will be processed after the entire tree has been patched.
  4059. */
  4060. function queueActivatedComponent(vm) {
  4061. // setting _inactive to false here so that a render function can
  4062. // rely on checking whether it's in an inactive tree (e.g. router-view)
  4063. vm._inactive = false;
  4064. activatedChildren.push(vm);
  4065. }
  4066. function callActivatedHooks(queue) {
  4067. for (let i = 0; i < queue.length; i++) {
  4068. queue[i]._inactive = true;
  4069. activateChildComponent(queue[i], true /* true */);
  4070. }
  4071. }
  4072. /**
  4073. * Push a watcher into the watcher queue.
  4074. * Jobs with duplicate IDs will be skipped unless it's
  4075. * pushed when the queue is being flushed.
  4076. */
  4077. function queueWatcher(watcher) {
  4078. const id = watcher.id;
  4079. if (has[id] != null) {
  4080. return;
  4081. }
  4082. if (watcher === Dep.target && watcher.noRecurse) {
  4083. return;
  4084. }
  4085. has[id] = true;
  4086. if (!flushing) {
  4087. queue.push(watcher);
  4088. }
  4089. else {
  4090. // if already flushing, splice the watcher based on its id
  4091. // if already past its id, it will be run next immediately.
  4092. let i = queue.length - 1;
  4093. while (i > index && queue[i].id > watcher.id) {
  4094. i--;
  4095. }
  4096. queue.splice(i + 1, 0, watcher);
  4097. }
  4098. // queue the flush
  4099. if (!waiting) {
  4100. waiting = true;
  4101. if (!config.async) {
  4102. flushSchedulerQueue();
  4103. return;
  4104. }
  4105. nextTick(flushSchedulerQueue);
  4106. }
  4107. }
  4108. function initProvide(vm) {
  4109. const provideOption = vm.$options.provide;
  4110. if (provideOption) {
  4111. const provided = isFunction(provideOption)
  4112. ? provideOption.call(vm)
  4113. : provideOption;
  4114. if (!isObject(provided)) {
  4115. return;
  4116. }
  4117. const source = resolveProvided(vm);
  4118. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4119. // iterate the keys ourselves.
  4120. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4121. for (let i = 0; i < keys.length; i++) {
  4122. const key = keys[i];
  4123. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4124. }
  4125. }
  4126. }
  4127. function initInjections(vm) {
  4128. const result = resolveInject(vm.$options.inject, vm);
  4129. if (result) {
  4130. toggleObserving(false);
  4131. Object.keys(result).forEach(key => {
  4132. /* istanbul ignore else */
  4133. {
  4134. defineReactive(vm, key, result[key], () => {
  4135. warn(`Avoid mutating an injected value directly since the changes will be ` +
  4136. `overwritten whenever the provided component re-renders. ` +
  4137. `injection being mutated: "${key}"`, vm);
  4138. });
  4139. }
  4140. });
  4141. toggleObserving(true);
  4142. }
  4143. }
  4144. function resolveInject(inject, vm) {
  4145. if (inject) {
  4146. // inject is :any because flow is not smart enough to figure out cached
  4147. const result = Object.create(null);
  4148. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4149. for (let i = 0; i < keys.length; i++) {
  4150. const key = keys[i];
  4151. // #6574 in case the inject object is observed...
  4152. if (key === '__ob__')
  4153. continue;
  4154. const provideKey = inject[key].from;
  4155. if (provideKey in vm._provided) {
  4156. result[key] = vm._provided[provideKey];
  4157. }
  4158. else if ('default' in inject[key]) {
  4159. const provideDefault = inject[key].default;
  4160. result[key] = isFunction(provideDefault)
  4161. ? provideDefault.call(vm)
  4162. : provideDefault;
  4163. }
  4164. else {
  4165. warn(`Injection "${key}" not found`, vm);
  4166. }
  4167. }
  4168. return result;
  4169. }
  4170. }
  4171. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4172. const options = Ctor.options;
  4173. // ensure the createElement function in functional components
  4174. // gets a unique context - this is necessary for correct named slot check
  4175. let contextVm;
  4176. if (hasOwn(parent, '_uid')) {
  4177. contextVm = Object.create(parent);
  4178. contextVm._original = parent;
  4179. }
  4180. else {
  4181. // the context vm passed in is a functional context as well.
  4182. // in this case we want to make sure we are able to get a hold to the
  4183. // real context instance.
  4184. contextVm = parent;
  4185. // @ts-ignore
  4186. parent = parent._original;
  4187. }
  4188. const isCompiled = isTrue(options._compiled);
  4189. const needNormalization = !isCompiled;
  4190. this.data = data;
  4191. this.props = props;
  4192. this.children = children;
  4193. this.parent = parent;
  4194. this.listeners = data.on || emptyObject;
  4195. this.injections = resolveInject(options.inject, parent);
  4196. this.slots = () => {
  4197. if (!this.$slots) {
  4198. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4199. }
  4200. return this.$slots;
  4201. };
  4202. Object.defineProperty(this, 'scopedSlots', {
  4203. enumerable: true,
  4204. get() {
  4205. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4206. }
  4207. });
  4208. // support for compiled functional template
  4209. if (isCompiled) {
  4210. // exposing $options for renderStatic()
  4211. this.$options = options;
  4212. // pre-resolve slots for renderSlot()
  4213. this.$slots = this.slots();
  4214. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4215. }
  4216. if (options._scopeId) {
  4217. this._c = (a, b, c, d) => {
  4218. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4219. if (vnode && !isArray(vnode)) {
  4220. vnode.fnScopeId = options._scopeId;
  4221. vnode.fnContext = parent;
  4222. }
  4223. return vnode;
  4224. };
  4225. }
  4226. else {
  4227. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4228. }
  4229. }
  4230. installRenderHelpers(FunctionalRenderContext.prototype);
  4231. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4232. const options = Ctor.options;
  4233. const props = {};
  4234. const propOptions = options.props;
  4235. if (isDef(propOptions)) {
  4236. for (const key in propOptions) {
  4237. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4238. }
  4239. }
  4240. else {
  4241. if (isDef(data.attrs))
  4242. mergeProps(props, data.attrs);
  4243. if (isDef(data.props))
  4244. mergeProps(props, data.props);
  4245. }
  4246. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4247. const vnode = options.render.call(null, renderContext._c, renderContext);
  4248. if (vnode instanceof VNode) {
  4249. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4250. }
  4251. else if (isArray(vnode)) {
  4252. const vnodes = normalizeChildren(vnode) || [];
  4253. const res = new Array(vnodes.length);
  4254. for (let i = 0; i < vnodes.length; i++) {
  4255. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4256. }
  4257. return res;
  4258. }
  4259. }
  4260. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4261. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4262. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4263. // that should not be matched to match.
  4264. const clone = cloneVNode(vnode);
  4265. clone.fnContext = contextVm;
  4266. clone.fnOptions = options;
  4267. {
  4268. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4269. renderContext;
  4270. }
  4271. if (data.slot) {
  4272. (clone.data || (clone.data = {})).slot = data.slot;
  4273. }
  4274. return clone;
  4275. }
  4276. function mergeProps(to, from) {
  4277. for (const key in from) {
  4278. to[camelize(key)] = from[key];
  4279. }
  4280. }
  4281. function getComponentName(options) {
  4282. return options.name || options.__name || options._componentTag;
  4283. }
  4284. // inline hooks to be invoked on component VNodes during patch
  4285. const componentVNodeHooks = {
  4286. init(vnode, hydrating) {
  4287. if (vnode.componentInstance &&
  4288. !vnode.componentInstance._isDestroyed &&
  4289. vnode.data.keepAlive) {
  4290. // kept-alive components, treat as a patch
  4291. const mountedNode = vnode; // work around flow
  4292. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4293. }
  4294. else {
  4295. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4296. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4297. }
  4298. },
  4299. prepatch(oldVnode, vnode) {
  4300. const options = vnode.componentOptions;
  4301. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4302. updateChildComponent(child, options.propsData, // updated props
  4303. options.listeners, // updated listeners
  4304. vnode, // new parent vnode
  4305. options.children // new children
  4306. );
  4307. },
  4308. insert(vnode) {
  4309. const { context, componentInstance } = vnode;
  4310. if (!componentInstance._isMounted) {
  4311. componentInstance._isMounted = true;
  4312. callHook$1(componentInstance, 'mounted');
  4313. }
  4314. if (vnode.data.keepAlive) {
  4315. if (context._isMounted) {
  4316. // vue-router#1212
  4317. // During updates, a kept-alive component's child components may
  4318. // change, so directly walking the tree here may call activated hooks
  4319. // on incorrect children. Instead we push them into a queue which will
  4320. // be processed after the whole patch process ended.
  4321. queueActivatedComponent(componentInstance);
  4322. }
  4323. else {
  4324. activateChildComponent(componentInstance, true /* direct */);
  4325. }
  4326. }
  4327. },
  4328. destroy(vnode) {
  4329. const { componentInstance } = vnode;
  4330. if (!componentInstance._isDestroyed) {
  4331. if (!vnode.data.keepAlive) {
  4332. componentInstance.$destroy();
  4333. }
  4334. else {
  4335. deactivateChildComponent(componentInstance, true /* direct */);
  4336. }
  4337. }
  4338. }
  4339. };
  4340. const hooksToMerge = Object.keys(componentVNodeHooks);
  4341. function createComponent(Ctor, data, context, children, tag) {
  4342. if (isUndef(Ctor)) {
  4343. return;
  4344. }
  4345. const baseCtor = context.$options._base;
  4346. // plain options object: turn it into a constructor
  4347. if (isObject(Ctor)) {
  4348. Ctor = baseCtor.extend(Ctor);
  4349. }
  4350. // if at this stage it's not a constructor or an async component factory,
  4351. // reject.
  4352. if (typeof Ctor !== 'function') {
  4353. {
  4354. warn(`Invalid Component definition: ${String(Ctor)}`, context);
  4355. }
  4356. return;
  4357. }
  4358. // async component
  4359. let asyncFactory;
  4360. // @ts-expect-error
  4361. if (isUndef(Ctor.cid)) {
  4362. asyncFactory = Ctor;
  4363. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4364. if (Ctor === undefined) {
  4365. // return a placeholder node for async component, which is rendered
  4366. // as a comment node but preserves all the raw information for the node.
  4367. // the information will be used for async server-rendering and hydration.
  4368. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4369. }
  4370. }
  4371. data = data || {};
  4372. // resolve constructor options in case global mixins are applied after
  4373. // component constructor creation
  4374. resolveConstructorOptions(Ctor);
  4375. // transform component v-model data into props & events
  4376. if (isDef(data.model)) {
  4377. // @ts-expect-error
  4378. transformModel(Ctor.options, data);
  4379. }
  4380. // extract props
  4381. // @ts-expect-error
  4382. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4383. // functional component
  4384. // @ts-expect-error
  4385. if (isTrue(Ctor.options.functional)) {
  4386. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4387. }
  4388. // extract listeners, since these needs to be treated as
  4389. // child component listeners instead of DOM listeners
  4390. const listeners = data.on;
  4391. // replace with listeners with .native modifier
  4392. // so it gets processed during parent component patch.
  4393. data.on = data.nativeOn;
  4394. // @ts-expect-error
  4395. if (isTrue(Ctor.options.abstract)) {
  4396. // abstract components do not keep anything
  4397. // other than props & listeners & slot
  4398. // work around flow
  4399. const slot = data.slot;
  4400. data = {};
  4401. if (slot) {
  4402. data.slot = slot;
  4403. }
  4404. }
  4405. // install component management hooks onto the placeholder node
  4406. installComponentHooks(data);
  4407. // return a placeholder vnode
  4408. // @ts-expect-error
  4409. const name = getComponentName(Ctor.options) || tag;
  4410. const vnode = new VNode(
  4411. // @ts-expect-error
  4412. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4413. // @ts-expect-error
  4414. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4415. return vnode;
  4416. }
  4417. function createComponentInstanceForVnode(
  4418. // we know it's MountedComponentVNode but flow doesn't
  4419. vnode,
  4420. // activeInstance in lifecycle state
  4421. parent) {
  4422. const options = {
  4423. _isComponent: true,
  4424. _parentVnode: vnode,
  4425. parent
  4426. };
  4427. // check inline-template render functions
  4428. const inlineTemplate = vnode.data.inlineTemplate;
  4429. if (isDef(inlineTemplate)) {
  4430. options.render = inlineTemplate.render;
  4431. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4432. }
  4433. return new vnode.componentOptions.Ctor(options);
  4434. }
  4435. function installComponentHooks(data) {
  4436. const hooks = data.hook || (data.hook = {});
  4437. for (let i = 0; i < hooksToMerge.length; i++) {
  4438. const key = hooksToMerge[i];
  4439. const existing = hooks[key];
  4440. const toMerge = componentVNodeHooks[key];
  4441. // @ts-expect-error
  4442. if (existing !== toMerge && !(existing && existing._merged)) {
  4443. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4444. }
  4445. }
  4446. }
  4447. function mergeHook(f1, f2) {
  4448. const merged = (a, b) => {
  4449. // flow complains about extra args which is why we use any
  4450. f1(a, b);
  4451. f2(a, b);
  4452. };
  4453. merged._merged = true;
  4454. return merged;
  4455. }
  4456. // transform component v-model info (value and callback) into
  4457. // prop and event handler respectively.
  4458. function transformModel(options, data) {
  4459. const prop = (options.model && options.model.prop) || 'value';
  4460. const event = (options.model && options.model.event) || 'input';
  4461. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4462. const on = data.on || (data.on = {});
  4463. const existing = on[event];
  4464. const callback = data.model.callback;
  4465. if (isDef(existing)) {
  4466. if (isArray(existing)
  4467. ? existing.indexOf(callback) === -1
  4468. : existing !== callback) {
  4469. on[event] = [callback].concat(existing);
  4470. }
  4471. }
  4472. else {
  4473. on[event] = callback;
  4474. }
  4475. }
  4476. let warn = noop;
  4477. let tip = noop;
  4478. let generateComponentTrace; // work around flow check
  4479. let formatComponentName;
  4480. {
  4481. const hasConsole = typeof console !== 'undefined';
  4482. const classifyRE = /(?:^|[-_])(\w)/g;
  4483. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4484. warn = (msg, vm = currentInstance) => {
  4485. const trace = vm ? generateComponentTrace(vm) : '';
  4486. if (config.warnHandler) {
  4487. config.warnHandler.call(null, msg, vm, trace);
  4488. }
  4489. else if (hasConsole && !config.silent) {
  4490. console.error(`[Vue warn]: ${msg}${trace}`);
  4491. }
  4492. };
  4493. tip = (msg, vm) => {
  4494. if (hasConsole && !config.silent) {
  4495. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4496. }
  4497. };
  4498. formatComponentName = (vm, includeFile) => {
  4499. if (vm.$root === vm) {
  4500. return '<Root>';
  4501. }
  4502. const options = isFunction(vm) && vm.cid != null
  4503. ? vm.options
  4504. : vm._isVue
  4505. ? vm.$options || vm.constructor.options
  4506. : vm;
  4507. let name = getComponentName(options);
  4508. const file = options.__file;
  4509. if (!name && file) {
  4510. const match = file.match(/([^/\\]+)\.vue$/);
  4511. name = match && match[1];
  4512. }
  4513. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4514. (file && includeFile !== false ? ` at ${file}` : ''));
  4515. };
  4516. const repeat = (str, n) => {
  4517. let res = '';
  4518. while (n) {
  4519. if (n % 2 === 1)
  4520. res += str;
  4521. if (n > 1)
  4522. str += str;
  4523. n >>= 1;
  4524. }
  4525. return res;
  4526. };
  4527. generateComponentTrace = (vm) => {
  4528. if (vm._isVue && vm.$parent) {
  4529. const tree = [];
  4530. let currentRecursiveSequence = 0;
  4531. while (vm) {
  4532. if (tree.length > 0) {
  4533. const last = tree[tree.length - 1];
  4534. if (last.constructor === vm.constructor) {
  4535. currentRecursiveSequence++;
  4536. vm = vm.$parent;
  4537. continue;
  4538. }
  4539. else if (currentRecursiveSequence > 0) {
  4540. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4541. currentRecursiveSequence = 0;
  4542. }
  4543. }
  4544. tree.push(vm);
  4545. vm = vm.$parent;
  4546. }
  4547. return ('\n\nfound in\n\n' +
  4548. tree
  4549. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4550. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4551. : formatComponentName(vm)}`)
  4552. .join('\n'));
  4553. }
  4554. else {
  4555. return `\n\n(found in ${formatComponentName(vm)})`;
  4556. }
  4557. };
  4558. }
  4559. /**
  4560. * Option overwriting strategies are functions that handle
  4561. * how to merge a parent option value and a child option
  4562. * value into the final value.
  4563. */
  4564. const strats = config.optionMergeStrategies;
  4565. /**
  4566. * Options with restrictions
  4567. */
  4568. {
  4569. strats.el = strats.propsData = function (parent, child, vm, key) {
  4570. if (!vm) {
  4571. warn(`option "${key}" can only be used during instance ` +
  4572. 'creation with the `new` keyword.');
  4573. }
  4574. return defaultStrat(parent, child);
  4575. };
  4576. }
  4577. /**
  4578. * Helper that recursively merges two data objects together.
  4579. */
  4580. function mergeData(to, from, recursive = true) {
  4581. if (!from)
  4582. return to;
  4583. let key, toVal, fromVal;
  4584. const keys = hasSymbol
  4585. ? Reflect.ownKeys(from)
  4586. : Object.keys(from);
  4587. for (let i = 0; i < keys.length; i++) {
  4588. key = keys[i];
  4589. // in case the object is already observed...
  4590. if (key === '__ob__')
  4591. continue;
  4592. toVal = to[key];
  4593. fromVal = from[key];
  4594. if (!recursive || !hasOwn(to, key)) {
  4595. set(to, key, fromVal);
  4596. }
  4597. else if (toVal !== fromVal &&
  4598. isPlainObject(toVal) &&
  4599. isPlainObject(fromVal)) {
  4600. mergeData(toVal, fromVal);
  4601. }
  4602. }
  4603. return to;
  4604. }
  4605. /**
  4606. * Data
  4607. */
  4608. function mergeDataOrFn(parentVal, childVal, vm) {
  4609. if (!vm) {
  4610. // in a Vue.extend merge, both should be functions
  4611. if (!childVal) {
  4612. return parentVal;
  4613. }
  4614. if (!parentVal) {
  4615. return childVal;
  4616. }
  4617. // when parentVal & childVal are both present,
  4618. // we need to return a function that returns the
  4619. // merged result of both functions... no need to
  4620. // check if parentVal is a function here because
  4621. // it has to be a function to pass previous merges.
  4622. return function mergedDataFn() {
  4623. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  4624. };
  4625. }
  4626. else {
  4627. return function mergedInstanceDataFn() {
  4628. // instance merge
  4629. const instanceData = isFunction(childVal)
  4630. ? childVal.call(vm, vm)
  4631. : childVal;
  4632. const defaultData = isFunction(parentVal)
  4633. ? parentVal.call(vm, vm)
  4634. : parentVal;
  4635. if (instanceData) {
  4636. return mergeData(instanceData, defaultData);
  4637. }
  4638. else {
  4639. return defaultData;
  4640. }
  4641. };
  4642. }
  4643. }
  4644. strats.data = function (parentVal, childVal, vm) {
  4645. if (!vm) {
  4646. if (childVal && typeof childVal !== 'function') {
  4647. warn('The "data" option should be a function ' +
  4648. 'that returns a per-instance value in component ' +
  4649. 'definitions.', vm);
  4650. return parentVal;
  4651. }
  4652. return mergeDataOrFn(parentVal, childVal);
  4653. }
  4654. return mergeDataOrFn(parentVal, childVal, vm);
  4655. };
  4656. /**
  4657. * Hooks and props are merged as arrays.
  4658. */
  4659. function mergeLifecycleHook(parentVal, childVal) {
  4660. const res = childVal
  4661. ? parentVal
  4662. ? parentVal.concat(childVal)
  4663. : isArray(childVal)
  4664. ? childVal
  4665. : [childVal]
  4666. : parentVal;
  4667. return res ? dedupeHooks(res) : res;
  4668. }
  4669. function dedupeHooks(hooks) {
  4670. const res = [];
  4671. for (let i = 0; i < hooks.length; i++) {
  4672. if (res.indexOf(hooks[i]) === -1) {
  4673. res.push(hooks[i]);
  4674. }
  4675. }
  4676. return res;
  4677. }
  4678. LIFECYCLE_HOOKS.forEach(hook => {
  4679. strats[hook] = mergeLifecycleHook;
  4680. });
  4681. /**
  4682. * Assets
  4683. *
  4684. * When a vm is present (instance creation), we need to do
  4685. * a three-way merge between constructor options, instance
  4686. * options and parent options.
  4687. */
  4688. function mergeAssets(parentVal, childVal, vm, key) {
  4689. const res = Object.create(parentVal || null);
  4690. if (childVal) {
  4691. assertObjectType(key, childVal, vm);
  4692. return extend(res, childVal);
  4693. }
  4694. else {
  4695. return res;
  4696. }
  4697. }
  4698. ASSET_TYPES.forEach(function (type) {
  4699. strats[type + 's'] = mergeAssets;
  4700. });
  4701. /**
  4702. * Watchers.
  4703. *
  4704. * Watchers hashes should not overwrite one
  4705. * another, so we merge them as arrays.
  4706. */
  4707. strats.watch = function (parentVal, childVal, vm, key) {
  4708. // work around Firefox's Object.prototype.watch...
  4709. //@ts-expect-error work around
  4710. if (parentVal === nativeWatch)
  4711. parentVal = undefined;
  4712. //@ts-expect-error work around
  4713. if (childVal === nativeWatch)
  4714. childVal = undefined;
  4715. /* istanbul ignore if */
  4716. if (!childVal)
  4717. return Object.create(parentVal || null);
  4718. {
  4719. assertObjectType(key, childVal, vm);
  4720. }
  4721. if (!parentVal)
  4722. return childVal;
  4723. const ret = {};
  4724. extend(ret, parentVal);
  4725. for (const key in childVal) {
  4726. let parent = ret[key];
  4727. const child = childVal[key];
  4728. if (parent && !isArray(parent)) {
  4729. parent = [parent];
  4730. }
  4731. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  4732. }
  4733. return ret;
  4734. };
  4735. /**
  4736. * Other object hashes.
  4737. */
  4738. strats.props =
  4739. strats.methods =
  4740. strats.inject =
  4741. strats.computed =
  4742. function (parentVal, childVal, vm, key) {
  4743. if (childVal && true) {
  4744. assertObjectType(key, childVal, vm);
  4745. }
  4746. if (!parentVal)
  4747. return childVal;
  4748. const ret = Object.create(null);
  4749. extend(ret, parentVal);
  4750. if (childVal)
  4751. extend(ret, childVal);
  4752. return ret;
  4753. };
  4754. strats.provide = function (parentVal, childVal) {
  4755. if (!parentVal)
  4756. return childVal;
  4757. return function () {
  4758. const ret = Object.create(null);
  4759. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  4760. if (childVal) {
  4761. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  4762. );
  4763. }
  4764. return ret;
  4765. };
  4766. };
  4767. /**
  4768. * Default strategy.
  4769. */
  4770. const defaultStrat = function (parentVal, childVal) {
  4771. return childVal === undefined ? parentVal : childVal;
  4772. };
  4773. /**
  4774. * Validate component names
  4775. */
  4776. function checkComponents(options) {
  4777. for (const key in options.components) {
  4778. validateComponentName(key);
  4779. }
  4780. }
  4781. function validateComponentName(name) {
  4782. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  4783. warn('Invalid component name: "' +
  4784. name +
  4785. '". Component names ' +
  4786. 'should conform to valid custom element name in html5 specification.');
  4787. }
  4788. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  4789. warn('Do not use built-in or reserved HTML elements as component ' +
  4790. 'id: ' +
  4791. name);
  4792. }
  4793. }
  4794. /**
  4795. * Ensure all props option syntax are normalized into the
  4796. * Object-based format.
  4797. */
  4798. function normalizeProps(options, vm) {
  4799. const props = options.props;
  4800. if (!props)
  4801. return;
  4802. const res = {};
  4803. let i, val, name;
  4804. if (isArray(props)) {
  4805. i = props.length;
  4806. while (i--) {
  4807. val = props[i];
  4808. if (typeof val === 'string') {
  4809. name = camelize(val);
  4810. res[name] = { type: null };
  4811. }
  4812. else {
  4813. warn('props must be strings when using array syntax.');
  4814. }
  4815. }
  4816. }
  4817. else if (isPlainObject(props)) {
  4818. for (const key in props) {
  4819. val = props[key];
  4820. name = camelize(key);
  4821. res[name] = isPlainObject(val) ? val : { type: val };
  4822. }
  4823. }
  4824. else {
  4825. warn(`Invalid value for option "props": expected an Array or an Object, ` +
  4826. `but got ${toRawType(props)}.`, vm);
  4827. }
  4828. options.props = res;
  4829. }
  4830. /**
  4831. * Normalize all injections into Object-based format
  4832. */
  4833. function normalizeInject(options, vm) {
  4834. const inject = options.inject;
  4835. if (!inject)
  4836. return;
  4837. const normalized = (options.inject = {});
  4838. if (isArray(inject)) {
  4839. for (let i = 0; i < inject.length; i++) {
  4840. normalized[inject[i]] = { from: inject[i] };
  4841. }
  4842. }
  4843. else if (isPlainObject(inject)) {
  4844. for (const key in inject) {
  4845. const val = inject[key];
  4846. normalized[key] = isPlainObject(val)
  4847. ? extend({ from: key }, val)
  4848. : { from: val };
  4849. }
  4850. }
  4851. else {
  4852. warn(`Invalid value for option "inject": expected an Array or an Object, ` +
  4853. `but got ${toRawType(inject)}.`, vm);
  4854. }
  4855. }
  4856. /**
  4857. * Normalize raw function directives into object format.
  4858. */
  4859. function normalizeDirectives$1(options) {
  4860. const dirs = options.directives;
  4861. if (dirs) {
  4862. for (const key in dirs) {
  4863. const def = dirs[key];
  4864. if (isFunction(def)) {
  4865. dirs[key] = { bind: def, update: def };
  4866. }
  4867. }
  4868. }
  4869. }
  4870. function assertObjectType(name, value, vm) {
  4871. if (!isPlainObject(value)) {
  4872. warn(`Invalid value for option "${name}": expected an Object, ` +
  4873. `but got ${toRawType(value)}.`, vm);
  4874. }
  4875. }
  4876. /**
  4877. * Merge two option objects into a new one.
  4878. * Core utility used in both instantiation and inheritance.
  4879. */
  4880. function mergeOptions(parent, child, vm) {
  4881. {
  4882. checkComponents(child);
  4883. }
  4884. if (isFunction(child)) {
  4885. // @ts-expect-error
  4886. child = child.options;
  4887. }
  4888. normalizeProps(child, vm);
  4889. normalizeInject(child, vm);
  4890. normalizeDirectives$1(child);
  4891. // Apply extends and mixins on the child options,
  4892. // but only if it is a raw options object that isn't
  4893. // the result of another mergeOptions call.
  4894. // Only merged options has the _base property.
  4895. if (!child._base) {
  4896. if (child.extends) {
  4897. parent = mergeOptions(parent, child.extends, vm);
  4898. }
  4899. if (child.mixins) {
  4900. for (let i = 0, l = child.mixins.length; i < l; i++) {
  4901. parent = mergeOptions(parent, child.mixins[i], vm);
  4902. }
  4903. }
  4904. }
  4905. const options = {};
  4906. let key;
  4907. for (key in parent) {
  4908. mergeField(key);
  4909. }
  4910. for (key in child) {
  4911. if (!hasOwn(parent, key)) {
  4912. mergeField(key);
  4913. }
  4914. }
  4915. function mergeField(key) {
  4916. const strat = strats[key] || defaultStrat;
  4917. options[key] = strat(parent[key], child[key], vm, key);
  4918. }
  4919. return options;
  4920. }
  4921. /**
  4922. * Resolve an asset.
  4923. * This function is used because child instances need access
  4924. * to assets defined in its ancestor chain.
  4925. */
  4926. function resolveAsset(options, type, id, warnMissing) {
  4927. /* istanbul ignore if */
  4928. if (typeof id !== 'string') {
  4929. return;
  4930. }
  4931. const assets = options[type];
  4932. // check local registration variations first
  4933. if (hasOwn(assets, id))
  4934. return assets[id];
  4935. const camelizedId = camelize(id);
  4936. if (hasOwn(assets, camelizedId))
  4937. return assets[camelizedId];
  4938. const PascalCaseId = capitalize(camelizedId);
  4939. if (hasOwn(assets, PascalCaseId))
  4940. return assets[PascalCaseId];
  4941. // fallback to prototype chain
  4942. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  4943. if (warnMissing && !res) {
  4944. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  4945. }
  4946. return res;
  4947. }
  4948. function validateProp(key, propOptions, propsData, vm) {
  4949. const prop = propOptions[key];
  4950. const absent = !hasOwn(propsData, key);
  4951. let value = propsData[key];
  4952. // boolean casting
  4953. const booleanIndex = getTypeIndex(Boolean, prop.type);
  4954. if (booleanIndex > -1) {
  4955. if (absent && !hasOwn(prop, 'default')) {
  4956. value = false;
  4957. }
  4958. else if (value === '' || value === hyphenate(key)) {
  4959. // only cast empty string / same name to boolean if
  4960. // boolean has higher priority
  4961. const stringIndex = getTypeIndex(String, prop.type);
  4962. if (stringIndex < 0 || booleanIndex < stringIndex) {
  4963. value = true;
  4964. }
  4965. }
  4966. }
  4967. // check default value
  4968. if (value === undefined) {
  4969. value = getPropDefaultValue(vm, prop, key);
  4970. // since the default value is a fresh copy,
  4971. // make sure to observe it.
  4972. const prevShouldObserve = shouldObserve;
  4973. toggleObserving(true);
  4974. observe(value);
  4975. toggleObserving(prevShouldObserve);
  4976. }
  4977. {
  4978. assertProp(prop, key, value, vm, absent);
  4979. }
  4980. return value;
  4981. }
  4982. /**
  4983. * Get the default value of a prop.
  4984. */
  4985. function getPropDefaultValue(vm, prop, key) {
  4986. // no default, return undefined
  4987. if (!hasOwn(prop, 'default')) {
  4988. return undefined;
  4989. }
  4990. const def = prop.default;
  4991. // warn against non-factory defaults for Object & Array
  4992. if (isObject(def)) {
  4993. warn('Invalid default value for prop "' +
  4994. key +
  4995. '": ' +
  4996. 'Props with type Object/Array must use a factory function ' +
  4997. 'to return the default value.', vm);
  4998. }
  4999. // the raw prop value was also undefined from previous render,
  5000. // return previous default value to avoid unnecessary watcher trigger
  5001. if (vm &&
  5002. vm.$options.propsData &&
  5003. vm.$options.propsData[key] === undefined &&
  5004. vm._props[key] !== undefined) {
  5005. return vm._props[key];
  5006. }
  5007. // call factory function for non-Function types
  5008. // a value is Function if its prototype is function even across different execution context
  5009. return isFunction(def) && getType(prop.type) !== 'Function'
  5010. ? def.call(vm)
  5011. : def;
  5012. }
  5013. /**
  5014. * Assert whether a prop is valid.
  5015. */
  5016. function assertProp(prop, name, value, vm, absent) {
  5017. if (prop.required && absent) {
  5018. warn('Missing required prop: "' + name + '"', vm);
  5019. return;
  5020. }
  5021. if (value == null && !prop.required) {
  5022. return;
  5023. }
  5024. let type = prop.type;
  5025. let valid = !type || type === true;
  5026. const expectedTypes = [];
  5027. if (type) {
  5028. if (!isArray(type)) {
  5029. type = [type];
  5030. }
  5031. for (let i = 0; i < type.length && !valid; i++) {
  5032. const assertedType = assertType(value, type[i], vm);
  5033. expectedTypes.push(assertedType.expectedType || '');
  5034. valid = assertedType.valid;
  5035. }
  5036. }
  5037. const haveExpectedTypes = expectedTypes.some(t => t);
  5038. if (!valid && haveExpectedTypes) {
  5039. warn(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5040. return;
  5041. }
  5042. const validator = prop.validator;
  5043. if (validator) {
  5044. if (!validator(value)) {
  5045. warn('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5046. }
  5047. }
  5048. }
  5049. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5050. function assertType(value, type, vm) {
  5051. let valid;
  5052. const expectedType = getType(type);
  5053. if (simpleCheckRE.test(expectedType)) {
  5054. const t = typeof value;
  5055. valid = t === expectedType.toLowerCase();
  5056. // for primitive wrapper objects
  5057. if (!valid && t === 'object') {
  5058. valid = value instanceof type;
  5059. }
  5060. }
  5061. else if (expectedType === 'Object') {
  5062. valid = isPlainObject(value);
  5063. }
  5064. else if (expectedType === 'Array') {
  5065. valid = isArray(value);
  5066. }
  5067. else {
  5068. try {
  5069. valid = value instanceof type;
  5070. }
  5071. catch (e) {
  5072. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5073. valid = false;
  5074. }
  5075. }
  5076. return {
  5077. valid,
  5078. expectedType
  5079. };
  5080. }
  5081. const functionTypeCheckRE = /^\s*function (\w+)/;
  5082. /**
  5083. * Use function string name to check built-in types,
  5084. * because a simple equality check will fail when running
  5085. * across different vms / iframes.
  5086. */
  5087. function getType(fn) {
  5088. const match = fn && fn.toString().match(functionTypeCheckRE);
  5089. return match ? match[1] : '';
  5090. }
  5091. function isSameType(a, b) {
  5092. return getType(a) === getType(b);
  5093. }
  5094. function getTypeIndex(type, expectedTypes) {
  5095. if (!isArray(expectedTypes)) {
  5096. return isSameType(expectedTypes, type) ? 0 : -1;
  5097. }
  5098. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5099. if (isSameType(expectedTypes[i], type)) {
  5100. return i;
  5101. }
  5102. }
  5103. return -1;
  5104. }
  5105. function getInvalidTypeMessage(name, value, expectedTypes) {
  5106. let message = `Invalid prop: type check failed for prop "${name}".` +
  5107. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5108. const expectedType = expectedTypes[0];
  5109. const receivedType = toRawType(value);
  5110. // check if we need to specify expected value
  5111. if (expectedTypes.length === 1 &&
  5112. isExplicable(expectedType) &&
  5113. isExplicable(typeof value) &&
  5114. !isBoolean(expectedType, receivedType)) {
  5115. message += ` with value ${styleValue(value, expectedType)}`;
  5116. }
  5117. message += `, got ${receivedType} `;
  5118. // check if we need to specify received value
  5119. if (isExplicable(receivedType)) {
  5120. message += `with value ${styleValue(value, receivedType)}.`;
  5121. }
  5122. return message;
  5123. }
  5124. function styleValue(value, type) {
  5125. if (type === 'String') {
  5126. return `"${value}"`;
  5127. }
  5128. else if (type === 'Number') {
  5129. return `${Number(value)}`;
  5130. }
  5131. else {
  5132. return `${value}`;
  5133. }
  5134. }
  5135. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5136. function isExplicable(value) {
  5137. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5138. }
  5139. function isBoolean(...args) {
  5140. return args.some(elem => elem.toLowerCase() === 'boolean');
  5141. }
  5142. /* not type checking this file because flow doesn't play well with Proxy */
  5143. let initProxy;
  5144. {
  5145. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  5146. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  5147. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  5148. 'require' // for Webpack/Browserify
  5149. );
  5150. const warnNonPresent = (target, key) => {
  5151. warn(`Property or method "${key}" is not defined on the instance but ` +
  5152. 'referenced during render. Make sure that this property is reactive, ' +
  5153. 'either in the data option, or for class-based components, by ' +
  5154. 'initializing the property. ' +
  5155. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  5156. };
  5157. const warnReservedPrefix = (target, key) => {
  5158. warn(`Property "${key}" must be accessed with "$data.${key}" because ` +
  5159. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  5160. 'prevent conflicts with Vue internals. ' +
  5161. 'See: https://v2.vuejs.org/v2/api/#data', target);
  5162. };
  5163. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  5164. if (hasProxy) {
  5165. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  5166. config.keyCodes = new Proxy(config.keyCodes, {
  5167. set(target, key, value) {
  5168. if (isBuiltInModifier(key)) {
  5169. warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  5170. return false;
  5171. }
  5172. else {
  5173. target[key] = value;
  5174. return true;
  5175. }
  5176. }
  5177. });
  5178. }
  5179. const hasHandler = {
  5180. has(target, key) {
  5181. const has = key in target;
  5182. const isAllowed = allowedGlobals(key) ||
  5183. (typeof key === 'string' &&
  5184. key.charAt(0) === '_' &&
  5185. !(key in target.$data));
  5186. if (!has && !isAllowed) {
  5187. if (key in target.$data)
  5188. warnReservedPrefix(target, key);
  5189. else
  5190. warnNonPresent(target, key);
  5191. }
  5192. return has || !isAllowed;
  5193. }
  5194. };
  5195. const getHandler = {
  5196. get(target, key) {
  5197. if (typeof key === 'string' && !(key in target)) {
  5198. if (key in target.$data)
  5199. warnReservedPrefix(target, key);
  5200. else
  5201. warnNonPresent(target, key);
  5202. }
  5203. return target[key];
  5204. }
  5205. };
  5206. initProxy = function initProxy(vm) {
  5207. if (hasProxy) {
  5208. // determine which proxy handler to use
  5209. const options = vm.$options;
  5210. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  5211. vm._renderProxy = new Proxy(vm, handlers);
  5212. }
  5213. else {
  5214. vm._renderProxy = vm;
  5215. }
  5216. };
  5217. }
  5218. const sharedPropertyDefinition = {
  5219. enumerable: true,
  5220. configurable: true,
  5221. get: noop,
  5222. set: noop
  5223. };
  5224. function proxy(target, sourceKey, key) {
  5225. sharedPropertyDefinition.get = function proxyGetter() {
  5226. return this[sourceKey][key];
  5227. };
  5228. sharedPropertyDefinition.set = function proxySetter(val) {
  5229. this[sourceKey][key] = val;
  5230. };
  5231. Object.defineProperty(target, key, sharedPropertyDefinition);
  5232. }
  5233. function initState(vm) {
  5234. const opts = vm.$options;
  5235. if (opts.props)
  5236. initProps$1(vm, opts.props);
  5237. // Composition API
  5238. initSetup(vm);
  5239. if (opts.methods)
  5240. initMethods(vm, opts.methods);
  5241. if (opts.data) {
  5242. initData(vm);
  5243. }
  5244. else {
  5245. const ob = observe((vm._data = {}));
  5246. ob && ob.vmCount++;
  5247. }
  5248. if (opts.computed)
  5249. initComputed$1(vm, opts.computed);
  5250. if (opts.watch && opts.watch !== nativeWatch) {
  5251. initWatch(vm, opts.watch);
  5252. }
  5253. }
  5254. function initProps$1(vm, propsOptions) {
  5255. const propsData = vm.$options.propsData || {};
  5256. const props = (vm._props = shallowReactive({}));
  5257. // cache prop keys so that future props updates can iterate using Array
  5258. // instead of dynamic object key enumeration.
  5259. const keys = (vm.$options._propKeys = []);
  5260. const isRoot = !vm.$parent;
  5261. // root instance props should be converted
  5262. if (!isRoot) {
  5263. toggleObserving(false);
  5264. }
  5265. for (const key in propsOptions) {
  5266. keys.push(key);
  5267. const value = validateProp(key, propsOptions, propsData, vm);
  5268. /* istanbul ignore else */
  5269. {
  5270. const hyphenatedKey = hyphenate(key);
  5271. if (isReservedAttribute(hyphenatedKey) ||
  5272. config.isReservedAttr(hyphenatedKey)) {
  5273. warn(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  5274. }
  5275. defineReactive(props, key, value, () => {
  5276. if (!isRoot && !isUpdatingChildComponent) {
  5277. warn(`Avoid mutating a prop directly since the value will be ` +
  5278. `overwritten whenever the parent component re-renders. ` +
  5279. `Instead, use a data or computed property based on the prop's ` +
  5280. `value. Prop being mutated: "${key}"`, vm);
  5281. }
  5282. });
  5283. }
  5284. // static props are already proxied on the component's prototype
  5285. // during Vue.extend(). We only need to proxy props defined at
  5286. // instantiation here.
  5287. if (!(key in vm)) {
  5288. proxy(vm, `_props`, key);
  5289. }
  5290. }
  5291. toggleObserving(true);
  5292. }
  5293. function initData(vm) {
  5294. let data = vm.$options.data;
  5295. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  5296. if (!isPlainObject(data)) {
  5297. data = {};
  5298. warn('data functions should return an object:\n' +
  5299. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  5300. }
  5301. // proxy data on instance
  5302. const keys = Object.keys(data);
  5303. const props = vm.$options.props;
  5304. const methods = vm.$options.methods;
  5305. let i = keys.length;
  5306. while (i--) {
  5307. const key = keys[i];
  5308. {
  5309. if (methods && hasOwn(methods, key)) {
  5310. warn(`Method "${key}" has already been defined as a data property.`, vm);
  5311. }
  5312. }
  5313. if (props && hasOwn(props, key)) {
  5314. warn(`The data property "${key}" is already declared as a prop. ` +
  5315. `Use prop default value instead.`, vm);
  5316. }
  5317. else if (!isReserved(key)) {
  5318. proxy(vm, `_data`, key);
  5319. }
  5320. }
  5321. // observe data
  5322. const ob = observe(data);
  5323. ob && ob.vmCount++;
  5324. }
  5325. function getData(data, vm) {
  5326. // #7573 disable dep collection when invoking data getters
  5327. pushTarget();
  5328. try {
  5329. return data.call(vm, vm);
  5330. }
  5331. catch (e) {
  5332. handleError(e, vm, `data()`);
  5333. return {};
  5334. }
  5335. finally {
  5336. popTarget();
  5337. }
  5338. }
  5339. const computedWatcherOptions = { lazy: true };
  5340. function initComputed$1(vm, computed) {
  5341. // $flow-disable-line
  5342. const watchers = (vm._computedWatchers = Object.create(null));
  5343. // computed properties are just getters during SSR
  5344. const isSSR = isServerRendering();
  5345. for (const key in computed) {
  5346. const userDef = computed[key];
  5347. const getter = isFunction(userDef) ? userDef : userDef.get;
  5348. if (getter == null) {
  5349. warn(`Getter is missing for computed property "${key}".`, vm);
  5350. }
  5351. if (!isSSR) {
  5352. // create internal watcher for the computed property.
  5353. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  5354. }
  5355. // component-defined computed properties are already defined on the
  5356. // component prototype. We only need to define computed properties defined
  5357. // at instantiation here.
  5358. if (!(key in vm)) {
  5359. defineComputed(vm, key, userDef);
  5360. }
  5361. else {
  5362. if (key in vm.$data) {
  5363. warn(`The computed property "${key}" is already defined in data.`, vm);
  5364. }
  5365. else if (vm.$options.props && key in vm.$options.props) {
  5366. warn(`The computed property "${key}" is already defined as a prop.`, vm);
  5367. }
  5368. else if (vm.$options.methods && key in vm.$options.methods) {
  5369. warn(`The computed property "${key}" is already defined as a method.`, vm);
  5370. }
  5371. }
  5372. }
  5373. }
  5374. function defineComputed(target, key, userDef) {
  5375. const shouldCache = !isServerRendering();
  5376. if (isFunction(userDef)) {
  5377. sharedPropertyDefinition.get = shouldCache
  5378. ? createComputedGetter(key)
  5379. : createGetterInvoker(userDef);
  5380. sharedPropertyDefinition.set = noop;
  5381. }
  5382. else {
  5383. sharedPropertyDefinition.get = userDef.get
  5384. ? shouldCache && userDef.cache !== false
  5385. ? createComputedGetter(key)
  5386. : createGetterInvoker(userDef.get)
  5387. : noop;
  5388. sharedPropertyDefinition.set = userDef.set || noop;
  5389. }
  5390. if (sharedPropertyDefinition.set === noop) {
  5391. sharedPropertyDefinition.set = function () {
  5392. warn(`Computed property "${key}" was assigned to but it has no setter.`, this);
  5393. };
  5394. }
  5395. Object.defineProperty(target, key, sharedPropertyDefinition);
  5396. }
  5397. function createComputedGetter(key) {
  5398. return function computedGetter() {
  5399. const watcher = this._computedWatchers && this._computedWatchers[key];
  5400. if (watcher) {
  5401. if (watcher.dirty) {
  5402. watcher.evaluate();
  5403. }
  5404. if (Dep.target) {
  5405. if (Dep.target.onTrack) {
  5406. Dep.target.onTrack({
  5407. effect: Dep.target,
  5408. target: this,
  5409. type: "get" /* TrackOpTypes.GET */,
  5410. key
  5411. });
  5412. }
  5413. watcher.depend();
  5414. }
  5415. return watcher.value;
  5416. }
  5417. };
  5418. }
  5419. function createGetterInvoker(fn) {
  5420. return function computedGetter() {
  5421. return fn.call(this, this);
  5422. };
  5423. }
  5424. function initMethods(vm, methods) {
  5425. const props = vm.$options.props;
  5426. for (const key in methods) {
  5427. {
  5428. if (typeof methods[key] !== 'function') {
  5429. warn(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  5430. `Did you reference the function correctly?`, vm);
  5431. }
  5432. if (props && hasOwn(props, key)) {
  5433. warn(`Method "${key}" has already been defined as a prop.`, vm);
  5434. }
  5435. if (key in vm && isReserved(key)) {
  5436. warn(`Method "${key}" conflicts with an existing Vue instance method. ` +
  5437. `Avoid defining component methods that start with _ or $.`);
  5438. }
  5439. }
  5440. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  5441. }
  5442. }
  5443. function initWatch(vm, watch) {
  5444. for (const key in watch) {
  5445. const handler = watch[key];
  5446. if (isArray(handler)) {
  5447. for (let i = 0; i < handler.length; i++) {
  5448. createWatcher(vm, key, handler[i]);
  5449. }
  5450. }
  5451. else {
  5452. createWatcher(vm, key, handler);
  5453. }
  5454. }
  5455. }
  5456. function createWatcher(vm, expOrFn, handler, options) {
  5457. if (isPlainObject(handler)) {
  5458. options = handler;
  5459. handler = handler.handler;
  5460. }
  5461. if (typeof handler === 'string') {
  5462. handler = vm[handler];
  5463. }
  5464. return vm.$watch(expOrFn, handler, options);
  5465. }
  5466. function stateMixin(Vue) {
  5467. // flow somehow has problems with directly declared definition object
  5468. // when using Object.defineProperty, so we have to procedurally build up
  5469. // the object here.
  5470. const dataDef = {};
  5471. dataDef.get = function () {
  5472. return this._data;
  5473. };
  5474. const propsDef = {};
  5475. propsDef.get = function () {
  5476. return this._props;
  5477. };
  5478. {
  5479. dataDef.set = function () {
  5480. warn('Avoid replacing instance root $data. ' +
  5481. 'Use nested data properties instead.', this);
  5482. };
  5483. propsDef.set = function () {
  5484. warn(`$props is readonly.`, this);
  5485. };
  5486. }
  5487. Object.defineProperty(Vue.prototype, '$data', dataDef);
  5488. Object.defineProperty(Vue.prototype, '$props', propsDef);
  5489. Vue.prototype.$set = set;
  5490. Vue.prototype.$delete = del;
  5491. Vue.prototype.$watch = function (expOrFn, cb, options) {
  5492. const vm = this;
  5493. if (isPlainObject(cb)) {
  5494. return createWatcher(vm, expOrFn, cb, options);
  5495. }
  5496. options = options || {};
  5497. options.user = true;
  5498. const watcher = new Watcher(vm, expOrFn, cb, options);
  5499. if (options.immediate) {
  5500. const info = `callback for immediate watcher "${watcher.expression}"`;
  5501. pushTarget();
  5502. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  5503. popTarget();
  5504. }
  5505. return function unwatchFn() {
  5506. watcher.teardown();
  5507. };
  5508. };
  5509. }
  5510. let uid = 0;
  5511. function initMixin$1(Vue) {
  5512. Vue.prototype._init = function (options) {
  5513. const vm = this;
  5514. // a uid
  5515. vm._uid = uid++;
  5516. let startTag, endTag;
  5517. /* istanbul ignore if */
  5518. if (config.performance && mark) {
  5519. startTag = `vue-perf-start:${vm._uid}`;
  5520. endTag = `vue-perf-end:${vm._uid}`;
  5521. mark(startTag);
  5522. }
  5523. // a flag to mark this as a Vue instance without having to do instanceof
  5524. // check
  5525. vm._isVue = true;
  5526. // avoid instances from being observed
  5527. vm.__v_skip = true;
  5528. // effect scope
  5529. vm._scope = new EffectScope(true /* detached */);
  5530. vm._scope._vm = true;
  5531. // merge options
  5532. if (options && options._isComponent) {
  5533. // optimize internal component instantiation
  5534. // since dynamic options merging is pretty slow, and none of the
  5535. // internal component options needs special treatment.
  5536. initInternalComponent(vm, options);
  5537. }
  5538. else {
  5539. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  5540. }
  5541. /* istanbul ignore else */
  5542. {
  5543. initProxy(vm);
  5544. }
  5545. // expose real self
  5546. vm._self = vm;
  5547. initLifecycle(vm);
  5548. initEvents(vm);
  5549. initRender(vm);
  5550. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  5551. initInjections(vm); // resolve injections before data/props
  5552. initState(vm);
  5553. initProvide(vm); // resolve provide after data/props
  5554. callHook$1(vm, 'created');
  5555. /* istanbul ignore if */
  5556. if (config.performance && mark) {
  5557. vm._name = formatComponentName(vm, false);
  5558. mark(endTag);
  5559. measure(`vue ${vm._name} init`, startTag, endTag);
  5560. }
  5561. if (vm.$options.el) {
  5562. vm.$mount(vm.$options.el);
  5563. }
  5564. };
  5565. }
  5566. function initInternalComponent(vm, options) {
  5567. const opts = (vm.$options = Object.create(vm.constructor.options));
  5568. // doing this because it's faster than dynamic enumeration.
  5569. const parentVnode = options._parentVnode;
  5570. opts.parent = options.parent;
  5571. opts._parentVnode = parentVnode;
  5572. const vnodeComponentOptions = parentVnode.componentOptions;
  5573. opts.propsData = vnodeComponentOptions.propsData;
  5574. opts._parentListeners = vnodeComponentOptions.listeners;
  5575. opts._renderChildren = vnodeComponentOptions.children;
  5576. opts._componentTag = vnodeComponentOptions.tag;
  5577. if (options.render) {
  5578. opts.render = options.render;
  5579. opts.staticRenderFns = options.staticRenderFns;
  5580. }
  5581. }
  5582. function resolveConstructorOptions(Ctor) {
  5583. let options = Ctor.options;
  5584. if (Ctor.super) {
  5585. const superOptions = resolveConstructorOptions(Ctor.super);
  5586. const cachedSuperOptions = Ctor.superOptions;
  5587. if (superOptions !== cachedSuperOptions) {
  5588. // super option changed,
  5589. // need to resolve new options.
  5590. Ctor.superOptions = superOptions;
  5591. // check if there are any late-modified/attached options (#4976)
  5592. const modifiedOptions = resolveModifiedOptions(Ctor);
  5593. // update base extend options
  5594. if (modifiedOptions) {
  5595. extend(Ctor.extendOptions, modifiedOptions);
  5596. }
  5597. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  5598. if (options.name) {
  5599. options.components[options.name] = Ctor;
  5600. }
  5601. }
  5602. }
  5603. return options;
  5604. }
  5605. function resolveModifiedOptions(Ctor) {
  5606. let modified;
  5607. const latest = Ctor.options;
  5608. const sealed = Ctor.sealedOptions;
  5609. for (const key in latest) {
  5610. if (latest[key] !== sealed[key]) {
  5611. if (!modified)
  5612. modified = {};
  5613. modified[key] = latest[key];
  5614. }
  5615. }
  5616. return modified;
  5617. }
  5618. function Vue(options) {
  5619. if (!(this instanceof Vue)) {
  5620. warn('Vue is a constructor and should be called with the `new` keyword');
  5621. }
  5622. this._init(options);
  5623. }
  5624. //@ts-expect-error Vue has function type
  5625. initMixin$1(Vue);
  5626. //@ts-expect-error Vue has function type
  5627. stateMixin(Vue);
  5628. //@ts-expect-error Vue has function type
  5629. eventsMixin(Vue);
  5630. //@ts-expect-error Vue has function type
  5631. lifecycleMixin(Vue);
  5632. //@ts-expect-error Vue has function type
  5633. renderMixin(Vue);
  5634. function initUse(Vue) {
  5635. Vue.use = function (plugin) {
  5636. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5637. if (installedPlugins.indexOf(plugin) > -1) {
  5638. return this;
  5639. }
  5640. // additional parameters
  5641. const args = toArray(arguments, 1);
  5642. args.unshift(this);
  5643. if (isFunction(plugin.install)) {
  5644. plugin.install.apply(plugin, args);
  5645. }
  5646. else if (isFunction(plugin)) {
  5647. plugin.apply(null, args);
  5648. }
  5649. installedPlugins.push(plugin);
  5650. return this;
  5651. };
  5652. }
  5653. function initMixin(Vue) {
  5654. Vue.mixin = function (mixin) {
  5655. this.options = mergeOptions(this.options, mixin);
  5656. return this;
  5657. };
  5658. }
  5659. function initExtend(Vue) {
  5660. /**
  5661. * Each instance constructor, including Vue, has a unique
  5662. * cid. This enables us to create wrapped "child
  5663. * constructors" for prototypal inheritance and cache them.
  5664. */
  5665. Vue.cid = 0;
  5666. let cid = 1;
  5667. /**
  5668. * Class inheritance
  5669. */
  5670. Vue.extend = function (extendOptions) {
  5671. extendOptions = extendOptions || {};
  5672. const Super = this;
  5673. const SuperId = Super.cid;
  5674. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5675. if (cachedCtors[SuperId]) {
  5676. return cachedCtors[SuperId];
  5677. }
  5678. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5679. if (name) {
  5680. validateComponentName(name);
  5681. }
  5682. const Sub = function VueComponent(options) {
  5683. this._init(options);
  5684. };
  5685. Sub.prototype = Object.create(Super.prototype);
  5686. Sub.prototype.constructor = Sub;
  5687. Sub.cid = cid++;
  5688. Sub.options = mergeOptions(Super.options, extendOptions);
  5689. Sub['super'] = Super;
  5690. // For props and computed properties, we define the proxy getters on
  5691. // the Vue instances at extension time, on the extended prototype. This
  5692. // avoids Object.defineProperty calls for each instance created.
  5693. if (Sub.options.props) {
  5694. initProps(Sub);
  5695. }
  5696. if (Sub.options.computed) {
  5697. initComputed(Sub);
  5698. }
  5699. // allow further extension/mixin/plugin usage
  5700. Sub.extend = Super.extend;
  5701. Sub.mixin = Super.mixin;
  5702. Sub.use = Super.use;
  5703. // create asset registers, so extended classes
  5704. // can have their private assets too.
  5705. ASSET_TYPES.forEach(function (type) {
  5706. Sub[type] = Super[type];
  5707. });
  5708. // enable recursive self-lookup
  5709. if (name) {
  5710. Sub.options.components[name] = Sub;
  5711. }
  5712. // keep a reference to the super options at extension time.
  5713. // later at instantiation we can check if Super's options have
  5714. // been updated.
  5715. Sub.superOptions = Super.options;
  5716. Sub.extendOptions = extendOptions;
  5717. Sub.sealedOptions = extend({}, Sub.options);
  5718. // cache constructor
  5719. cachedCtors[SuperId] = Sub;
  5720. return Sub;
  5721. };
  5722. }
  5723. function initProps(Comp) {
  5724. const props = Comp.options.props;
  5725. for (const key in props) {
  5726. proxy(Comp.prototype, `_props`, key);
  5727. }
  5728. }
  5729. function initComputed(Comp) {
  5730. const computed = Comp.options.computed;
  5731. for (const key in computed) {
  5732. defineComputed(Comp.prototype, key, computed[key]);
  5733. }
  5734. }
  5735. function initAssetRegisters(Vue) {
  5736. /**
  5737. * Create asset registration methods.
  5738. */
  5739. ASSET_TYPES.forEach(type => {
  5740. // @ts-expect-error function is not exact same type
  5741. Vue[type] = function (id, definition) {
  5742. if (!definition) {
  5743. return this.options[type + 's'][id];
  5744. }
  5745. else {
  5746. /* istanbul ignore if */
  5747. if (type === 'component') {
  5748. validateComponentName(id);
  5749. }
  5750. if (type === 'component' && isPlainObject(definition)) {
  5751. // @ts-expect-error
  5752. definition.name = definition.name || id;
  5753. definition = this.options._base.extend(definition);
  5754. }
  5755. if (type === 'directive' && isFunction(definition)) {
  5756. definition = { bind: definition, update: definition };
  5757. }
  5758. this.options[type + 's'][id] = definition;
  5759. return definition;
  5760. }
  5761. };
  5762. });
  5763. }
  5764. function _getComponentName(opts) {
  5765. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5766. }
  5767. function matches(pattern, name) {
  5768. if (isArray(pattern)) {
  5769. return pattern.indexOf(name) > -1;
  5770. }
  5771. else if (typeof pattern === 'string') {
  5772. return pattern.split(',').indexOf(name) > -1;
  5773. }
  5774. else if (isRegExp(pattern)) {
  5775. return pattern.test(name);
  5776. }
  5777. /* istanbul ignore next */
  5778. return false;
  5779. }
  5780. function pruneCache(keepAliveInstance, filter) {
  5781. const { cache, keys, _vnode } = keepAliveInstance;
  5782. for (const key in cache) {
  5783. const entry = cache[key];
  5784. if (entry) {
  5785. const name = entry.name;
  5786. if (name && !filter(name)) {
  5787. pruneCacheEntry(cache, key, keys, _vnode);
  5788. }
  5789. }
  5790. }
  5791. }
  5792. function pruneCacheEntry(cache, key, keys, current) {
  5793. const entry = cache[key];
  5794. if (entry && (!current || entry.tag !== current.tag)) {
  5795. // @ts-expect-error can be undefined
  5796. entry.componentInstance.$destroy();
  5797. }
  5798. cache[key] = null;
  5799. remove$2(keys, key);
  5800. }
  5801. const patternTypes = [String, RegExp, Array];
  5802. // TODO defineComponent
  5803. var KeepAlive = {
  5804. name: 'keep-alive',
  5805. abstract: true,
  5806. props: {
  5807. include: patternTypes,
  5808. exclude: patternTypes,
  5809. max: [String, Number]
  5810. },
  5811. methods: {
  5812. cacheVNode() {
  5813. const { cache, keys, vnodeToCache, keyToCache } = this;
  5814. if (vnodeToCache) {
  5815. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5816. cache[keyToCache] = {
  5817. name: _getComponentName(componentOptions),
  5818. tag,
  5819. componentInstance
  5820. };
  5821. keys.push(keyToCache);
  5822. // prune oldest entry
  5823. if (this.max && keys.length > parseInt(this.max)) {
  5824. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5825. }
  5826. this.vnodeToCache = null;
  5827. }
  5828. }
  5829. },
  5830. created() {
  5831. this.cache = Object.create(null);
  5832. this.keys = [];
  5833. },
  5834. destroyed() {
  5835. for (const key in this.cache) {
  5836. pruneCacheEntry(this.cache, key, this.keys);
  5837. }
  5838. },
  5839. mounted() {
  5840. this.cacheVNode();
  5841. this.$watch('include', val => {
  5842. pruneCache(this, name => matches(val, name));
  5843. });
  5844. this.$watch('exclude', val => {
  5845. pruneCache(this, name => !matches(val, name));
  5846. });
  5847. },
  5848. updated() {
  5849. this.cacheVNode();
  5850. },
  5851. render() {
  5852. const slot = this.$slots.default;
  5853. const vnode = getFirstComponentChild(slot);
  5854. const componentOptions = vnode && vnode.componentOptions;
  5855. if (componentOptions) {
  5856. // check pattern
  5857. const name = _getComponentName(componentOptions);
  5858. const { include, exclude } = this;
  5859. if (
  5860. // not included
  5861. (include && (!name || !matches(include, name))) ||
  5862. // excluded
  5863. (exclude && name && matches(exclude, name))) {
  5864. return vnode;
  5865. }
  5866. const { cache, keys } = this;
  5867. const key = vnode.key == null
  5868. ? // same constructor may get registered as different local components
  5869. // so cid alone is not enough (#3269)
  5870. componentOptions.Ctor.cid +
  5871. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5872. : vnode.key;
  5873. if (cache[key]) {
  5874. vnode.componentInstance = cache[key].componentInstance;
  5875. // make current key freshest
  5876. remove$2(keys, key);
  5877. keys.push(key);
  5878. }
  5879. else {
  5880. // delay setting the cache until update
  5881. this.vnodeToCache = vnode;
  5882. this.keyToCache = key;
  5883. }
  5884. // @ts-expect-error can vnode.data can be undefined
  5885. vnode.data.keepAlive = true;
  5886. }
  5887. return vnode || (slot && slot[0]);
  5888. }
  5889. };
  5890. var builtInComponents = {
  5891. KeepAlive
  5892. };
  5893. function initGlobalAPI(Vue) {
  5894. // config
  5895. const configDef = {};
  5896. configDef.get = () => config;
  5897. {
  5898. configDef.set = () => {
  5899. warn('Do not replace the Vue.config object, set individual fields instead.');
  5900. };
  5901. }
  5902. Object.defineProperty(Vue, 'config', configDef);
  5903. // exposed util methods.
  5904. // NOTE: these are not considered part of the public API - avoid relying on
  5905. // them unless you are aware of the risk.
  5906. Vue.util = {
  5907. warn,
  5908. extend,
  5909. mergeOptions,
  5910. defineReactive
  5911. };
  5912. Vue.set = set;
  5913. Vue.delete = del;
  5914. Vue.nextTick = nextTick;
  5915. // 2.6 explicit observable API
  5916. Vue.observable = (obj) => {
  5917. observe(obj);
  5918. return obj;
  5919. };
  5920. Vue.options = Object.create(null);
  5921. ASSET_TYPES.forEach(type => {
  5922. Vue.options[type + 's'] = Object.create(null);
  5923. });
  5924. // this is used to identify the "base" constructor to extend all plain-object
  5925. // components with in Weex's multi-instance scenarios.
  5926. Vue.options._base = Vue;
  5927. extend(Vue.options.components, builtInComponents);
  5928. initUse(Vue);
  5929. initMixin(Vue);
  5930. initExtend(Vue);
  5931. initAssetRegisters(Vue);
  5932. }
  5933. initGlobalAPI(Vue);
  5934. Object.defineProperty(Vue.prototype, '$isServer', {
  5935. get: isServerRendering
  5936. });
  5937. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5938. get() {
  5939. /* istanbul ignore next */
  5940. return this.$vnode && this.$vnode.ssrContext;
  5941. }
  5942. });
  5943. // expose FunctionalRenderContext for ssr runtime helper installation
  5944. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5945. value: FunctionalRenderContext
  5946. });
  5947. Vue.version = version;
  5948. // these are reserved for web because they are directly compiled away
  5949. // during template compilation
  5950. const isReservedAttr = makeMap('style,class');
  5951. // attributes that should be using props for binding
  5952. const acceptValue = makeMap('input,textarea,option,select,progress');
  5953. const mustUseProp = (tag, type, attr) => {
  5954. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5955. (attr === 'selected' && tag === 'option') ||
  5956. (attr === 'checked' && tag === 'input') ||
  5957. (attr === 'muted' && tag === 'video'));
  5958. };
  5959. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5960. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5961. const convertEnumeratedValue = (key, value) => {
  5962. return isFalsyAttrValue(value) || value === 'false'
  5963. ? 'false'
  5964. : // allow arbitrary string value for contenteditable
  5965. key === 'contenteditable' && isValidContentEditableValue(value)
  5966. ? value
  5967. : 'true';
  5968. };
  5969. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5970. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5971. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5972. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5973. 'required,reversed,scoped,seamless,selected,sortable,' +
  5974. 'truespeed,typemustmatch,visible');
  5975. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5976. const isXlink = (name) => {
  5977. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5978. };
  5979. const getXlinkProp = (name) => {
  5980. return isXlink(name) ? name.slice(6, name.length) : '';
  5981. };
  5982. const isFalsyAttrValue = (val) => {
  5983. return val == null || val === false;
  5984. };
  5985. function genClassForVnode(vnode) {
  5986. let data = vnode.data;
  5987. let parentNode = vnode;
  5988. let childNode = vnode;
  5989. while (isDef(childNode.componentInstance)) {
  5990. childNode = childNode.componentInstance._vnode;
  5991. if (childNode && childNode.data) {
  5992. data = mergeClassData(childNode.data, data);
  5993. }
  5994. }
  5995. // @ts-expect-error parentNode.parent not VNodeWithData
  5996. while (isDef((parentNode = parentNode.parent))) {
  5997. if (parentNode && parentNode.data) {
  5998. data = mergeClassData(data, parentNode.data);
  5999. }
  6000. }
  6001. return renderClass(data.staticClass, data.class);
  6002. }
  6003. function mergeClassData(child, parent) {
  6004. return {
  6005. staticClass: concat(child.staticClass, parent.staticClass),
  6006. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6007. };
  6008. }
  6009. function renderClass(staticClass, dynamicClass) {
  6010. if (isDef(staticClass) || isDef(dynamicClass)) {
  6011. return concat(staticClass, stringifyClass(dynamicClass));
  6012. }
  6013. /* istanbul ignore next */
  6014. return '';
  6015. }
  6016. function concat(a, b) {
  6017. return a ? (b ? a + ' ' + b : a) : b || '';
  6018. }
  6019. function stringifyClass(value) {
  6020. if (Array.isArray(value)) {
  6021. return stringifyArray(value);
  6022. }
  6023. if (isObject(value)) {
  6024. return stringifyObject(value);
  6025. }
  6026. if (typeof value === 'string') {
  6027. return value;
  6028. }
  6029. /* istanbul ignore next */
  6030. return '';
  6031. }
  6032. function stringifyArray(value) {
  6033. let res = '';
  6034. let stringified;
  6035. for (let i = 0, l = value.length; i < l; i++) {
  6036. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6037. if (res)
  6038. res += ' ';
  6039. res += stringified;
  6040. }
  6041. }
  6042. return res;
  6043. }
  6044. function stringifyObject(value) {
  6045. let res = '';
  6046. for (const key in value) {
  6047. if (value[key]) {
  6048. if (res)
  6049. res += ' ';
  6050. res += key;
  6051. }
  6052. }
  6053. return res;
  6054. }
  6055. const namespaceMap = {
  6056. svg: 'http://www.w3.org/2000/svg',
  6057. math: 'http://www.w3.org/1998/Math/MathML'
  6058. };
  6059. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6060. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6061. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6062. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6063. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6064. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6065. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6066. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6067. 'output,progress,select,textarea,' +
  6068. 'details,dialog,menu,menuitem,summary,' +
  6069. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6070. // this map is intentionally selective, only covering SVG elements that may
  6071. // contain child elements.
  6072. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6073. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6074. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6075. const isReservedTag = (tag) => {
  6076. return isHTMLTag(tag) || isSVG(tag);
  6077. };
  6078. function getTagNamespace(tag) {
  6079. if (isSVG(tag)) {
  6080. return 'svg';
  6081. }
  6082. // basic support for MathML
  6083. // note it doesn't support other MathML elements being component roots
  6084. if (tag === 'math') {
  6085. return 'math';
  6086. }
  6087. }
  6088. const unknownElementCache = Object.create(null);
  6089. function isUnknownElement(tag) {
  6090. /* istanbul ignore if */
  6091. if (!inBrowser) {
  6092. return true;
  6093. }
  6094. if (isReservedTag(tag)) {
  6095. return false;
  6096. }
  6097. tag = tag.toLowerCase();
  6098. /* istanbul ignore if */
  6099. if (unknownElementCache[tag] != null) {
  6100. return unknownElementCache[tag];
  6101. }
  6102. const el = document.createElement(tag);
  6103. if (tag.indexOf('-') > -1) {
  6104. // http://stackoverflow.com/a/28210364/1070244
  6105. return (unknownElementCache[tag] =
  6106. el.constructor === window.HTMLUnknownElement ||
  6107. el.constructor === window.HTMLElement);
  6108. }
  6109. else {
  6110. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6111. }
  6112. }
  6113. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6114. /**
  6115. * Query an element selector if it's not an element already.
  6116. */
  6117. function query(el) {
  6118. if (typeof el === 'string') {
  6119. const selected = document.querySelector(el);
  6120. if (!selected) {
  6121. warn('Cannot find element: ' + el);
  6122. return document.createElement('div');
  6123. }
  6124. return selected;
  6125. }
  6126. else {
  6127. return el;
  6128. }
  6129. }
  6130. function createElement(tagName, vnode) {
  6131. const elm = document.createElement(tagName);
  6132. if (tagName !== 'select') {
  6133. return elm;
  6134. }
  6135. // false or null will remove the attribute but undefined will not
  6136. if (vnode.data &&
  6137. vnode.data.attrs &&
  6138. vnode.data.attrs.multiple !== undefined) {
  6139. elm.setAttribute('multiple', 'multiple');
  6140. }
  6141. return elm;
  6142. }
  6143. function createElementNS(namespace, tagName) {
  6144. return document.createElementNS(namespaceMap[namespace], tagName);
  6145. }
  6146. function createTextNode(text) {
  6147. return document.createTextNode(text);
  6148. }
  6149. function createComment(text) {
  6150. return document.createComment(text);
  6151. }
  6152. function insertBefore(parentNode, newNode, referenceNode) {
  6153. parentNode.insertBefore(newNode, referenceNode);
  6154. }
  6155. function removeChild(node, child) {
  6156. node.removeChild(child);
  6157. }
  6158. function appendChild(node, child) {
  6159. node.appendChild(child);
  6160. }
  6161. function parentNode(node) {
  6162. return node.parentNode;
  6163. }
  6164. function nextSibling(node) {
  6165. return node.nextSibling;
  6166. }
  6167. function tagName(node) {
  6168. return node.tagName;
  6169. }
  6170. function setTextContent(node, text) {
  6171. node.textContent = text;
  6172. }
  6173. function setStyleScope(node, scopeId) {
  6174. node.setAttribute(scopeId, '');
  6175. }
  6176. var nodeOps = /*#__PURE__*/Object.freeze({
  6177. __proto__: null,
  6178. createElement: createElement,
  6179. createElementNS: createElementNS,
  6180. createTextNode: createTextNode,
  6181. createComment: createComment,
  6182. insertBefore: insertBefore,
  6183. removeChild: removeChild,
  6184. appendChild: appendChild,
  6185. parentNode: parentNode,
  6186. nextSibling: nextSibling,
  6187. tagName: tagName,
  6188. setTextContent: setTextContent,
  6189. setStyleScope: setStyleScope
  6190. });
  6191. var ref = {
  6192. create(_, vnode) {
  6193. registerRef(vnode);
  6194. },
  6195. update(oldVnode, vnode) {
  6196. if (oldVnode.data.ref !== vnode.data.ref) {
  6197. registerRef(oldVnode, true);
  6198. registerRef(vnode);
  6199. }
  6200. },
  6201. destroy(vnode) {
  6202. registerRef(vnode, true);
  6203. }
  6204. };
  6205. function registerRef(vnode, isRemoval) {
  6206. const ref = vnode.data.ref;
  6207. if (!isDef(ref))
  6208. return;
  6209. const vm = vnode.context;
  6210. const refValue = vnode.componentInstance || vnode.elm;
  6211. const value = isRemoval ? null : refValue;
  6212. const $refsValue = isRemoval ? undefined : refValue;
  6213. if (isFunction(ref)) {
  6214. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6215. return;
  6216. }
  6217. const isFor = vnode.data.refInFor;
  6218. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6219. const _isRef = isRef(ref);
  6220. const refs = vm.$refs;
  6221. if (_isString || _isRef) {
  6222. if (isFor) {
  6223. const existing = _isString ? refs[ref] : ref.value;
  6224. if (isRemoval) {
  6225. isArray(existing) && remove$2(existing, refValue);
  6226. }
  6227. else {
  6228. if (!isArray(existing)) {
  6229. if (_isString) {
  6230. refs[ref] = [refValue];
  6231. setSetupRef(vm, ref, refs[ref]);
  6232. }
  6233. else {
  6234. ref.value = [refValue];
  6235. }
  6236. }
  6237. else if (!existing.includes(refValue)) {
  6238. existing.push(refValue);
  6239. }
  6240. }
  6241. }
  6242. else if (_isString) {
  6243. if (isRemoval && refs[ref] !== refValue) {
  6244. return;
  6245. }
  6246. refs[ref] = $refsValue;
  6247. setSetupRef(vm, ref, value);
  6248. }
  6249. else if (_isRef) {
  6250. if (isRemoval && ref.value !== refValue) {
  6251. return;
  6252. }
  6253. ref.value = value;
  6254. }
  6255. else {
  6256. warn(`Invalid template ref type: ${typeof ref}`);
  6257. }
  6258. }
  6259. }
  6260. function setSetupRef({ _setupState }, key, val) {
  6261. if (_setupState && hasOwn(_setupState, key)) {
  6262. if (isRef(_setupState[key])) {
  6263. _setupState[key].value = val;
  6264. }
  6265. else {
  6266. _setupState[key] = val;
  6267. }
  6268. }
  6269. }
  6270. /**
  6271. * Virtual DOM patching algorithm based on Snabbdom by
  6272. * Simon Friis Vindum (@paldepind)
  6273. * Licensed under the MIT License
  6274. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6275. *
  6276. * modified by Evan You (@yyx990803)
  6277. *
  6278. * Not type-checking this because this file is perf-critical and the cost
  6279. * of making flow understand it is not worth it.
  6280. */
  6281. const emptyNode = new VNode('', {}, []);
  6282. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6283. function sameVnode(a, b) {
  6284. return (a.key === b.key &&
  6285. a.asyncFactory === b.asyncFactory &&
  6286. ((a.tag === b.tag &&
  6287. a.isComment === b.isComment &&
  6288. isDef(a.data) === isDef(b.data) &&
  6289. sameInputType(a, b)) ||
  6290. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6291. }
  6292. function sameInputType(a, b) {
  6293. if (a.tag !== 'input')
  6294. return true;
  6295. let i;
  6296. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6297. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6298. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6299. }
  6300. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6301. let i, key;
  6302. const map = {};
  6303. for (i = beginIdx; i <= endIdx; ++i) {
  6304. key = children[i].key;
  6305. if (isDef(key))
  6306. map[key] = i;
  6307. }
  6308. return map;
  6309. }
  6310. function createPatchFunction(backend) {
  6311. let i, j;
  6312. const cbs = {};
  6313. const { modules, nodeOps } = backend;
  6314. for (i = 0; i < hooks.length; ++i) {
  6315. cbs[hooks[i]] = [];
  6316. for (j = 0; j < modules.length; ++j) {
  6317. if (isDef(modules[j][hooks[i]])) {
  6318. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6319. }
  6320. }
  6321. }
  6322. function emptyNodeAt(elm) {
  6323. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6324. }
  6325. function createRmCb(childElm, listeners) {
  6326. function remove() {
  6327. if (--remove.listeners === 0) {
  6328. removeNode(childElm);
  6329. }
  6330. }
  6331. remove.listeners = listeners;
  6332. return remove;
  6333. }
  6334. function removeNode(el) {
  6335. const parent = nodeOps.parentNode(el);
  6336. // element may have already been removed due to v-html / v-text
  6337. if (isDef(parent)) {
  6338. nodeOps.removeChild(parent, el);
  6339. }
  6340. }
  6341. function isUnknownElement(vnode, inVPre) {
  6342. return (!inVPre &&
  6343. !vnode.ns &&
  6344. !(config.ignoredElements.length &&
  6345. config.ignoredElements.some(ignore => {
  6346. return isRegExp(ignore)
  6347. ? ignore.test(vnode.tag)
  6348. : ignore === vnode.tag;
  6349. })) &&
  6350. config.isUnknownElement(vnode.tag));
  6351. }
  6352. let creatingElmInVPre = 0;
  6353. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6354. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6355. // This vnode was used in a previous render!
  6356. // now it's used as a new node, overwriting its elm would cause
  6357. // potential patch errors down the road when it's used as an insertion
  6358. // reference node. Instead, we clone the node on-demand before creating
  6359. // associated DOM element for it.
  6360. vnode = ownerArray[index] = cloneVNode(vnode);
  6361. }
  6362. vnode.isRootInsert = !nested; // for transition enter check
  6363. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6364. return;
  6365. }
  6366. const data = vnode.data;
  6367. const children = vnode.children;
  6368. const tag = vnode.tag;
  6369. if (isDef(tag)) {
  6370. {
  6371. if (data && data.pre) {
  6372. creatingElmInVPre++;
  6373. }
  6374. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6375. warn('Unknown custom element: <' +
  6376. tag +
  6377. '> - did you ' +
  6378. 'register the component correctly? For recursive components, ' +
  6379. 'make sure to provide the "name" option.', vnode.context);
  6380. }
  6381. }
  6382. vnode.elm = vnode.ns
  6383. ? nodeOps.createElementNS(vnode.ns, tag)
  6384. : nodeOps.createElement(tag, vnode);
  6385. setScope(vnode);
  6386. createChildren(vnode, children, insertedVnodeQueue);
  6387. if (isDef(data)) {
  6388. invokeCreateHooks(vnode, insertedVnodeQueue);
  6389. }
  6390. insert(parentElm, vnode.elm, refElm);
  6391. if (data && data.pre) {
  6392. creatingElmInVPre--;
  6393. }
  6394. }
  6395. else if (isTrue(vnode.isComment)) {
  6396. vnode.elm = nodeOps.createComment(vnode.text);
  6397. insert(parentElm, vnode.elm, refElm);
  6398. }
  6399. else {
  6400. vnode.elm = nodeOps.createTextNode(vnode.text);
  6401. insert(parentElm, vnode.elm, refElm);
  6402. }
  6403. }
  6404. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6405. let i = vnode.data;
  6406. if (isDef(i)) {
  6407. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6408. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6409. i(vnode, false /* hydrating */);
  6410. }
  6411. // after calling the init hook, if the vnode is a child component
  6412. // it should've created a child instance and mounted it. the child
  6413. // component also has set the placeholder vnode's elm.
  6414. // in that case we can just return the element and be done.
  6415. if (isDef(vnode.componentInstance)) {
  6416. initComponent(vnode, insertedVnodeQueue);
  6417. insert(parentElm, vnode.elm, refElm);
  6418. if (isTrue(isReactivated)) {
  6419. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6420. }
  6421. return true;
  6422. }
  6423. }
  6424. }
  6425. function initComponent(vnode, insertedVnodeQueue) {
  6426. if (isDef(vnode.data.pendingInsert)) {
  6427. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6428. vnode.data.pendingInsert = null;
  6429. }
  6430. vnode.elm = vnode.componentInstance.$el;
  6431. if (isPatchable(vnode)) {
  6432. invokeCreateHooks(vnode, insertedVnodeQueue);
  6433. setScope(vnode);
  6434. }
  6435. else {
  6436. // empty component root.
  6437. // skip all element-related modules except for ref (#3455)
  6438. registerRef(vnode);
  6439. // make sure to invoke the insert hook
  6440. insertedVnodeQueue.push(vnode);
  6441. }
  6442. }
  6443. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6444. let i;
  6445. // hack for #4339: a reactivated component with inner transition
  6446. // does not trigger because the inner node's created hooks are not called
  6447. // again. It's not ideal to involve module-specific logic in here but
  6448. // there doesn't seem to be a better way to do it.
  6449. let innerNode = vnode;
  6450. while (innerNode.componentInstance) {
  6451. innerNode = innerNode.componentInstance._vnode;
  6452. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6453. for (i = 0; i < cbs.activate.length; ++i) {
  6454. cbs.activate[i](emptyNode, innerNode);
  6455. }
  6456. insertedVnodeQueue.push(innerNode);
  6457. break;
  6458. }
  6459. }
  6460. // unlike a newly created component,
  6461. // a reactivated keep-alive component doesn't insert itself
  6462. insert(parentElm, vnode.elm, refElm);
  6463. }
  6464. function insert(parent, elm, ref) {
  6465. if (isDef(parent)) {
  6466. if (isDef(ref)) {
  6467. if (nodeOps.parentNode(ref) === parent) {
  6468. nodeOps.insertBefore(parent, elm, ref);
  6469. }
  6470. }
  6471. else {
  6472. nodeOps.appendChild(parent, elm);
  6473. }
  6474. }
  6475. }
  6476. function createChildren(vnode, children, insertedVnodeQueue) {
  6477. if (isArray(children)) {
  6478. {
  6479. checkDuplicateKeys(children);
  6480. }
  6481. for (let i = 0; i < children.length; ++i) {
  6482. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6483. }
  6484. }
  6485. else if (isPrimitive(vnode.text)) {
  6486. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6487. }
  6488. }
  6489. function isPatchable(vnode) {
  6490. while (vnode.componentInstance) {
  6491. vnode = vnode.componentInstance._vnode;
  6492. }
  6493. return isDef(vnode.tag);
  6494. }
  6495. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6496. for (let i = 0; i < cbs.create.length; ++i) {
  6497. cbs.create[i](emptyNode, vnode);
  6498. }
  6499. i = vnode.data.hook; // Reuse variable
  6500. if (isDef(i)) {
  6501. if (isDef(i.create))
  6502. i.create(emptyNode, vnode);
  6503. if (isDef(i.insert))
  6504. insertedVnodeQueue.push(vnode);
  6505. }
  6506. }
  6507. // set scope id attribute for scoped CSS.
  6508. // this is implemented as a special case to avoid the overhead
  6509. // of going through the normal attribute patching process.
  6510. function setScope(vnode) {
  6511. let i;
  6512. if (isDef((i = vnode.fnScopeId))) {
  6513. nodeOps.setStyleScope(vnode.elm, i);
  6514. }
  6515. else {
  6516. let ancestor = vnode;
  6517. while (ancestor) {
  6518. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6519. nodeOps.setStyleScope(vnode.elm, i);
  6520. }
  6521. ancestor = ancestor.parent;
  6522. }
  6523. }
  6524. // for slot content they should also get the scopeId from the host instance.
  6525. if (isDef((i = activeInstance)) &&
  6526. i !== vnode.context &&
  6527. i !== vnode.fnContext &&
  6528. isDef((i = i.$options._scopeId))) {
  6529. nodeOps.setStyleScope(vnode.elm, i);
  6530. }
  6531. }
  6532. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6533. for (; startIdx <= endIdx; ++startIdx) {
  6534. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6535. }
  6536. }
  6537. function invokeDestroyHook(vnode) {
  6538. let i, j;
  6539. const data = vnode.data;
  6540. if (isDef(data)) {
  6541. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6542. i(vnode);
  6543. for (i = 0; i < cbs.destroy.length; ++i)
  6544. cbs.destroy[i](vnode);
  6545. }
  6546. if (isDef((i = vnode.children))) {
  6547. for (j = 0; j < vnode.children.length; ++j) {
  6548. invokeDestroyHook(vnode.children[j]);
  6549. }
  6550. }
  6551. }
  6552. function removeVnodes(vnodes, startIdx, endIdx) {
  6553. for (; startIdx <= endIdx; ++startIdx) {
  6554. const ch = vnodes[startIdx];
  6555. if (isDef(ch)) {
  6556. if (isDef(ch.tag)) {
  6557. removeAndInvokeRemoveHook(ch);
  6558. invokeDestroyHook(ch);
  6559. }
  6560. else {
  6561. // Text node
  6562. removeNode(ch.elm);
  6563. }
  6564. }
  6565. }
  6566. }
  6567. function removeAndInvokeRemoveHook(vnode, rm) {
  6568. if (isDef(rm) || isDef(vnode.data)) {
  6569. let i;
  6570. const listeners = cbs.remove.length + 1;
  6571. if (isDef(rm)) {
  6572. // we have a recursively passed down rm callback
  6573. // increase the listeners count
  6574. rm.listeners += listeners;
  6575. }
  6576. else {
  6577. // directly removing
  6578. rm = createRmCb(vnode.elm, listeners);
  6579. }
  6580. // recursively invoke hooks on child component root node
  6581. if (isDef((i = vnode.componentInstance)) &&
  6582. isDef((i = i._vnode)) &&
  6583. isDef(i.data)) {
  6584. removeAndInvokeRemoveHook(i, rm);
  6585. }
  6586. for (i = 0; i < cbs.remove.length; ++i) {
  6587. cbs.remove[i](vnode, rm);
  6588. }
  6589. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6590. i(vnode, rm);
  6591. }
  6592. else {
  6593. rm();
  6594. }
  6595. }
  6596. else {
  6597. removeNode(vnode.elm);
  6598. }
  6599. }
  6600. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6601. let oldStartIdx = 0;
  6602. let newStartIdx = 0;
  6603. let oldEndIdx = oldCh.length - 1;
  6604. let oldStartVnode = oldCh[0];
  6605. let oldEndVnode = oldCh[oldEndIdx];
  6606. let newEndIdx = newCh.length - 1;
  6607. let newStartVnode = newCh[0];
  6608. let newEndVnode = newCh[newEndIdx];
  6609. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6610. // removeOnly is a special flag used only by <transition-group>
  6611. // to ensure removed elements stay in correct relative positions
  6612. // during leaving transitions
  6613. const canMove = !removeOnly;
  6614. {
  6615. checkDuplicateKeys(newCh);
  6616. }
  6617. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6618. if (isUndef(oldStartVnode)) {
  6619. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6620. }
  6621. else if (isUndef(oldEndVnode)) {
  6622. oldEndVnode = oldCh[--oldEndIdx];
  6623. }
  6624. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6625. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6626. oldStartVnode = oldCh[++oldStartIdx];
  6627. newStartVnode = newCh[++newStartIdx];
  6628. }
  6629. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6630. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6631. oldEndVnode = oldCh[--oldEndIdx];
  6632. newEndVnode = newCh[--newEndIdx];
  6633. }
  6634. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6635. // Vnode moved right
  6636. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6637. canMove &&
  6638. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6639. oldStartVnode = oldCh[++oldStartIdx];
  6640. newEndVnode = newCh[--newEndIdx];
  6641. }
  6642. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6643. // Vnode moved left
  6644. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6645. canMove &&
  6646. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6647. oldEndVnode = oldCh[--oldEndIdx];
  6648. newStartVnode = newCh[++newStartIdx];
  6649. }
  6650. else {
  6651. if (isUndef(oldKeyToIdx))
  6652. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6653. idxInOld = isDef(newStartVnode.key)
  6654. ? oldKeyToIdx[newStartVnode.key]
  6655. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6656. if (isUndef(idxInOld)) {
  6657. // New element
  6658. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6659. }
  6660. else {
  6661. vnodeToMove = oldCh[idxInOld];
  6662. if (sameVnode(vnodeToMove, newStartVnode)) {
  6663. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6664. oldCh[idxInOld] = undefined;
  6665. canMove &&
  6666. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6667. }
  6668. else {
  6669. // same key but different element. treat as new element
  6670. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6671. }
  6672. }
  6673. newStartVnode = newCh[++newStartIdx];
  6674. }
  6675. }
  6676. if (oldStartIdx > oldEndIdx) {
  6677. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6678. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6679. }
  6680. else if (newStartIdx > newEndIdx) {
  6681. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6682. }
  6683. }
  6684. function checkDuplicateKeys(children) {
  6685. const seenKeys = {};
  6686. for (let i = 0; i < children.length; i++) {
  6687. const vnode = children[i];
  6688. const key = vnode.key;
  6689. if (isDef(key)) {
  6690. if (seenKeys[key]) {
  6691. warn(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6692. }
  6693. else {
  6694. seenKeys[key] = true;
  6695. }
  6696. }
  6697. }
  6698. }
  6699. function findIdxInOld(node, oldCh, start, end) {
  6700. for (let i = start; i < end; i++) {
  6701. const c = oldCh[i];
  6702. if (isDef(c) && sameVnode(node, c))
  6703. return i;
  6704. }
  6705. }
  6706. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6707. if (oldVnode === vnode) {
  6708. return;
  6709. }
  6710. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6711. // clone reused vnode
  6712. vnode = ownerArray[index] = cloneVNode(vnode);
  6713. }
  6714. const elm = (vnode.elm = oldVnode.elm);
  6715. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6716. if (isDef(vnode.asyncFactory.resolved)) {
  6717. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6718. }
  6719. else {
  6720. vnode.isAsyncPlaceholder = true;
  6721. }
  6722. return;
  6723. }
  6724. // reuse element for static trees.
  6725. // note we only do this if the vnode is cloned -
  6726. // if the new node is not cloned it means the render functions have been
  6727. // reset by the hot-reload-api and we need to do a proper re-render.
  6728. if (isTrue(vnode.isStatic) &&
  6729. isTrue(oldVnode.isStatic) &&
  6730. vnode.key === oldVnode.key &&
  6731. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6732. vnode.componentInstance = oldVnode.componentInstance;
  6733. return;
  6734. }
  6735. let i;
  6736. const data = vnode.data;
  6737. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6738. i(oldVnode, vnode);
  6739. }
  6740. const oldCh = oldVnode.children;
  6741. const ch = vnode.children;
  6742. if (isDef(data) && isPatchable(vnode)) {
  6743. for (i = 0; i < cbs.update.length; ++i)
  6744. cbs.update[i](oldVnode, vnode);
  6745. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6746. i(oldVnode, vnode);
  6747. }
  6748. if (isUndef(vnode.text)) {
  6749. if (isDef(oldCh) && isDef(ch)) {
  6750. if (oldCh !== ch)
  6751. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6752. }
  6753. else if (isDef(ch)) {
  6754. {
  6755. checkDuplicateKeys(ch);
  6756. }
  6757. if (isDef(oldVnode.text))
  6758. nodeOps.setTextContent(elm, '');
  6759. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6760. }
  6761. else if (isDef(oldCh)) {
  6762. removeVnodes(oldCh, 0, oldCh.length - 1);
  6763. }
  6764. else if (isDef(oldVnode.text)) {
  6765. nodeOps.setTextContent(elm, '');
  6766. }
  6767. }
  6768. else if (oldVnode.text !== vnode.text) {
  6769. nodeOps.setTextContent(elm, vnode.text);
  6770. }
  6771. if (isDef(data)) {
  6772. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6773. i(oldVnode, vnode);
  6774. }
  6775. }
  6776. function invokeInsertHook(vnode, queue, initial) {
  6777. // delay insert hooks for component root nodes, invoke them after the
  6778. // element is really inserted
  6779. if (isTrue(initial) && isDef(vnode.parent)) {
  6780. vnode.parent.data.pendingInsert = queue;
  6781. }
  6782. else {
  6783. for (let i = 0; i < queue.length; ++i) {
  6784. queue[i].data.hook.insert(queue[i]);
  6785. }
  6786. }
  6787. }
  6788. let hydrationBailed = false;
  6789. // list of modules that can skip create hook during hydration because they
  6790. // are already rendered on the client or has no need for initialization
  6791. // Note: style is excluded because it relies on initial clone for future
  6792. // deep updates (#7063).
  6793. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6794. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6795. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6796. let i;
  6797. const { tag, data, children } = vnode;
  6798. inVPre = inVPre || (data && data.pre);
  6799. vnode.elm = elm;
  6800. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6801. vnode.isAsyncPlaceholder = true;
  6802. return true;
  6803. }
  6804. // assert node match
  6805. {
  6806. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6807. return false;
  6808. }
  6809. }
  6810. if (isDef(data)) {
  6811. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6812. i(vnode, true /* hydrating */);
  6813. if (isDef((i = vnode.componentInstance))) {
  6814. // child component. it should have hydrated its own tree.
  6815. initComponent(vnode, insertedVnodeQueue);
  6816. return true;
  6817. }
  6818. }
  6819. if (isDef(tag)) {
  6820. if (isDef(children)) {
  6821. // empty element, allow client to pick up and populate children
  6822. if (!elm.hasChildNodes()) {
  6823. createChildren(vnode, children, insertedVnodeQueue);
  6824. }
  6825. else {
  6826. // v-html and domProps: innerHTML
  6827. if (isDef((i = data)) &&
  6828. isDef((i = i.domProps)) &&
  6829. isDef((i = i.innerHTML))) {
  6830. if (i !== elm.innerHTML) {
  6831. /* istanbul ignore if */
  6832. if (typeof console !== 'undefined' &&
  6833. !hydrationBailed) {
  6834. hydrationBailed = true;
  6835. console.warn('Parent: ', elm);
  6836. console.warn('server innerHTML: ', i);
  6837. console.warn('client innerHTML: ', elm.innerHTML);
  6838. }
  6839. return false;
  6840. }
  6841. }
  6842. else {
  6843. // iterate and compare children lists
  6844. let childrenMatch = true;
  6845. let childNode = elm.firstChild;
  6846. for (let i = 0; i < children.length; i++) {
  6847. if (!childNode ||
  6848. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6849. childrenMatch = false;
  6850. break;
  6851. }
  6852. childNode = childNode.nextSibling;
  6853. }
  6854. // if childNode is not null, it means the actual childNodes list is
  6855. // longer than the virtual children list.
  6856. if (!childrenMatch || childNode) {
  6857. /* istanbul ignore if */
  6858. if (typeof console !== 'undefined' &&
  6859. !hydrationBailed) {
  6860. hydrationBailed = true;
  6861. console.warn('Parent: ', elm);
  6862. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6863. }
  6864. return false;
  6865. }
  6866. }
  6867. }
  6868. }
  6869. if (isDef(data)) {
  6870. let fullInvoke = false;
  6871. for (const key in data) {
  6872. if (!isRenderedModule(key)) {
  6873. fullInvoke = true;
  6874. invokeCreateHooks(vnode, insertedVnodeQueue);
  6875. break;
  6876. }
  6877. }
  6878. if (!fullInvoke && data['class']) {
  6879. // ensure collecting deps for deep class bindings for future updates
  6880. traverse(data['class']);
  6881. }
  6882. }
  6883. }
  6884. else if (elm.data !== vnode.text) {
  6885. elm.data = vnode.text;
  6886. }
  6887. return true;
  6888. }
  6889. function assertNodeMatch(node, vnode, inVPre) {
  6890. if (isDef(vnode.tag)) {
  6891. return (vnode.tag.indexOf('vue-component') === 0 ||
  6892. (!isUnknownElement(vnode, inVPre) &&
  6893. vnode.tag.toLowerCase() ===
  6894. (node.tagName && node.tagName.toLowerCase())));
  6895. }
  6896. else {
  6897. return node.nodeType === (vnode.isComment ? 8 : 3);
  6898. }
  6899. }
  6900. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6901. if (isUndef(vnode)) {
  6902. if (isDef(oldVnode))
  6903. invokeDestroyHook(oldVnode);
  6904. return;
  6905. }
  6906. let isInitialPatch = false;
  6907. const insertedVnodeQueue = [];
  6908. if (isUndef(oldVnode)) {
  6909. // empty mount (likely as component), create new root element
  6910. isInitialPatch = true;
  6911. createElm(vnode, insertedVnodeQueue);
  6912. }
  6913. else {
  6914. const isRealElement = isDef(oldVnode.nodeType);
  6915. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6916. // patch existing root node
  6917. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6918. }
  6919. else {
  6920. if (isRealElement) {
  6921. // mounting to a real element
  6922. // check if this is server-rendered content and if we can perform
  6923. // a successful hydration.
  6924. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6925. oldVnode.removeAttribute(SSR_ATTR);
  6926. hydrating = true;
  6927. }
  6928. if (isTrue(hydrating)) {
  6929. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6930. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6931. return oldVnode;
  6932. }
  6933. else {
  6934. warn('The client-side rendered virtual DOM tree is not matching ' +
  6935. 'server-rendered content. This is likely caused by incorrect ' +
  6936. 'HTML markup, for example nesting block-level elements inside ' +
  6937. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6938. 'full client-side render.');
  6939. }
  6940. }
  6941. // either not server-rendered, or hydration failed.
  6942. // create an empty node and replace it
  6943. oldVnode = emptyNodeAt(oldVnode);
  6944. }
  6945. // replacing existing element
  6946. const oldElm = oldVnode.elm;
  6947. const parentElm = nodeOps.parentNode(oldElm);
  6948. // create new node
  6949. createElm(vnode, insertedVnodeQueue,
  6950. // extremely rare edge case: do not insert if old element is in a
  6951. // leaving transition. Only happens when combining transition +
  6952. // keep-alive + HOCs. (#4590)
  6953. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6954. // update parent placeholder node element, recursively
  6955. if (isDef(vnode.parent)) {
  6956. let ancestor = vnode.parent;
  6957. const patchable = isPatchable(vnode);
  6958. while (ancestor) {
  6959. for (let i = 0; i < cbs.destroy.length; ++i) {
  6960. cbs.destroy[i](ancestor);
  6961. }
  6962. ancestor.elm = vnode.elm;
  6963. if (patchable) {
  6964. for (let i = 0; i < cbs.create.length; ++i) {
  6965. cbs.create[i](emptyNode, ancestor);
  6966. }
  6967. // #6513
  6968. // invoke insert hooks that may have been merged by create hooks.
  6969. // e.g. for directives that uses the "inserted" hook.
  6970. const insert = ancestor.data.hook.insert;
  6971. if (insert.merged) {
  6972. // start at index 1 to avoid re-invoking component mounted hook
  6973. for (let i = 1; i < insert.fns.length; i++) {
  6974. insert.fns[i]();
  6975. }
  6976. }
  6977. }
  6978. else {
  6979. registerRef(ancestor);
  6980. }
  6981. ancestor = ancestor.parent;
  6982. }
  6983. }
  6984. // destroy old node
  6985. if (isDef(parentElm)) {
  6986. removeVnodes([oldVnode], 0, 0);
  6987. }
  6988. else if (isDef(oldVnode.tag)) {
  6989. invokeDestroyHook(oldVnode);
  6990. }
  6991. }
  6992. }
  6993. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  6994. return vnode.elm;
  6995. };
  6996. }
  6997. var directives = {
  6998. create: updateDirectives,
  6999. update: updateDirectives,
  7000. destroy: function unbindDirectives(vnode) {
  7001. // @ts-expect-error emptyNode is not VNodeWithData
  7002. updateDirectives(vnode, emptyNode);
  7003. }
  7004. };
  7005. function updateDirectives(oldVnode, vnode) {
  7006. if (oldVnode.data.directives || vnode.data.directives) {
  7007. _update(oldVnode, vnode);
  7008. }
  7009. }
  7010. function _update(oldVnode, vnode) {
  7011. const isCreate = oldVnode === emptyNode;
  7012. const isDestroy = vnode === emptyNode;
  7013. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7014. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7015. const dirsWithInsert = [];
  7016. const dirsWithPostpatch = [];
  7017. let key, oldDir, dir;
  7018. for (key in newDirs) {
  7019. oldDir = oldDirs[key];
  7020. dir = newDirs[key];
  7021. if (!oldDir) {
  7022. // new directive, bind
  7023. callHook(dir, 'bind', vnode, oldVnode);
  7024. if (dir.def && dir.def.inserted) {
  7025. dirsWithInsert.push(dir);
  7026. }
  7027. }
  7028. else {
  7029. // existing directive, update
  7030. dir.oldValue = oldDir.value;
  7031. dir.oldArg = oldDir.arg;
  7032. callHook(dir, 'update', vnode, oldVnode);
  7033. if (dir.def && dir.def.componentUpdated) {
  7034. dirsWithPostpatch.push(dir);
  7035. }
  7036. }
  7037. }
  7038. if (dirsWithInsert.length) {
  7039. const callInsert = () => {
  7040. for (let i = 0; i < dirsWithInsert.length; i++) {
  7041. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7042. }
  7043. };
  7044. if (isCreate) {
  7045. mergeVNodeHook(vnode, 'insert', callInsert);
  7046. }
  7047. else {
  7048. callInsert();
  7049. }
  7050. }
  7051. if (dirsWithPostpatch.length) {
  7052. mergeVNodeHook(vnode, 'postpatch', () => {
  7053. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7054. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7055. }
  7056. });
  7057. }
  7058. if (!isCreate) {
  7059. for (key in oldDirs) {
  7060. if (!newDirs[key]) {
  7061. // no longer present, unbind
  7062. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7063. }
  7064. }
  7065. }
  7066. }
  7067. const emptyModifiers = Object.create(null);
  7068. function normalizeDirectives(dirs, vm) {
  7069. const res = Object.create(null);
  7070. if (!dirs) {
  7071. // $flow-disable-line
  7072. return res;
  7073. }
  7074. let i, dir;
  7075. for (i = 0; i < dirs.length; i++) {
  7076. dir = dirs[i];
  7077. if (!dir.modifiers) {
  7078. // $flow-disable-line
  7079. dir.modifiers = emptyModifiers;
  7080. }
  7081. res[getRawDirName(dir)] = dir;
  7082. if (vm._setupState && vm._setupState.__sfc) {
  7083. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7084. if (typeof setupDef === 'function') {
  7085. dir.def = {
  7086. bind: setupDef,
  7087. update: setupDef,
  7088. };
  7089. }
  7090. else {
  7091. dir.def = setupDef;
  7092. }
  7093. }
  7094. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7095. }
  7096. // $flow-disable-line
  7097. return res;
  7098. }
  7099. function getRawDirName(dir) {
  7100. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7101. }
  7102. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7103. const fn = dir.def && dir.def[hook];
  7104. if (fn) {
  7105. try {
  7106. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7107. }
  7108. catch (e) {
  7109. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7110. }
  7111. }
  7112. }
  7113. var baseModules = [ref, directives];
  7114. function updateAttrs(oldVnode, vnode) {
  7115. const opts = vnode.componentOptions;
  7116. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7117. return;
  7118. }
  7119. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7120. return;
  7121. }
  7122. let key, cur, old;
  7123. const elm = vnode.elm;
  7124. const oldAttrs = oldVnode.data.attrs || {};
  7125. let attrs = vnode.data.attrs || {};
  7126. // clone observed objects, as the user probably wants to mutate it
  7127. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7128. attrs = vnode.data.attrs = extend({}, attrs);
  7129. }
  7130. for (key in attrs) {
  7131. cur = attrs[key];
  7132. old = oldAttrs[key];
  7133. if (old !== cur) {
  7134. setAttr(elm, key, cur, vnode.data.pre);
  7135. }
  7136. }
  7137. // #4391: in IE9, setting type can reset value for input[type=radio]
  7138. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7139. /* istanbul ignore if */
  7140. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7141. setAttr(elm, 'value', attrs.value);
  7142. }
  7143. for (key in oldAttrs) {
  7144. if (isUndef(attrs[key])) {
  7145. if (isXlink(key)) {
  7146. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7147. }
  7148. else if (!isEnumeratedAttr(key)) {
  7149. elm.removeAttribute(key);
  7150. }
  7151. }
  7152. }
  7153. }
  7154. function setAttr(el, key, value, isInPre) {
  7155. if (isInPre || el.tagName.indexOf('-') > -1) {
  7156. baseSetAttr(el, key, value);
  7157. }
  7158. else if (isBooleanAttr(key)) {
  7159. // set attribute for blank value
  7160. // e.g. <option disabled>Select one</option>
  7161. if (isFalsyAttrValue(value)) {
  7162. el.removeAttribute(key);
  7163. }
  7164. else {
  7165. // technically allowfullscreen is a boolean attribute for <iframe>,
  7166. // but Flash expects a value of "true" when used on <embed> tag
  7167. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7168. el.setAttribute(key, value);
  7169. }
  7170. }
  7171. else if (isEnumeratedAttr(key)) {
  7172. el.setAttribute(key, convertEnumeratedValue(key, value));
  7173. }
  7174. else if (isXlink(key)) {
  7175. if (isFalsyAttrValue(value)) {
  7176. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7177. }
  7178. else {
  7179. el.setAttributeNS(xlinkNS, key, value);
  7180. }
  7181. }
  7182. else {
  7183. baseSetAttr(el, key, value);
  7184. }
  7185. }
  7186. function baseSetAttr(el, key, value) {
  7187. if (isFalsyAttrValue(value)) {
  7188. el.removeAttribute(key);
  7189. }
  7190. else {
  7191. // #7138: IE10 & 11 fires input event when setting placeholder on
  7192. // <textarea>... block the first input event and remove the blocker
  7193. // immediately.
  7194. /* istanbul ignore if */
  7195. if (isIE &&
  7196. !isIE9 &&
  7197. el.tagName === 'TEXTAREA' &&
  7198. key === 'placeholder' &&
  7199. value !== '' &&
  7200. !el.__ieph) {
  7201. const blocker = e => {
  7202. e.stopImmediatePropagation();
  7203. el.removeEventListener('input', blocker);
  7204. };
  7205. el.addEventListener('input', blocker);
  7206. // $flow-disable-line
  7207. el.__ieph = true; /* IE placeholder patched */
  7208. }
  7209. el.setAttribute(key, value);
  7210. }
  7211. }
  7212. var attrs = {
  7213. create: updateAttrs,
  7214. update: updateAttrs
  7215. };
  7216. function updateClass(oldVnode, vnode) {
  7217. const el = vnode.elm;
  7218. const data = vnode.data;
  7219. const oldData = oldVnode.data;
  7220. if (isUndef(data.staticClass) &&
  7221. isUndef(data.class) &&
  7222. (isUndef(oldData) ||
  7223. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7224. return;
  7225. }
  7226. let cls = genClassForVnode(vnode);
  7227. // handle transition classes
  7228. const transitionClass = el._transitionClasses;
  7229. if (isDef(transitionClass)) {
  7230. cls = concat(cls, stringifyClass(transitionClass));
  7231. }
  7232. // set the class
  7233. if (cls !== el._prevClass) {
  7234. el.setAttribute('class', cls);
  7235. el._prevClass = cls;
  7236. }
  7237. }
  7238. var klass = {
  7239. create: updateClass,
  7240. update: updateClass
  7241. };
  7242. // in some cases, the event used has to be determined at runtime
  7243. // so we used some reserved tokens during compile.
  7244. const RANGE_TOKEN = '__r';
  7245. const CHECKBOX_RADIO_TOKEN = '__c';
  7246. // normalize v-model event tokens that can only be determined at runtime.
  7247. // it's important to place the event as the first in the array because
  7248. // the whole point is ensuring the v-model callback gets called before
  7249. // user-attached handlers.
  7250. function normalizeEvents(on) {
  7251. /* istanbul ignore if */
  7252. if (isDef(on[RANGE_TOKEN])) {
  7253. // IE input[type=range] only supports `change` event
  7254. const event = isIE ? 'change' : 'input';
  7255. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7256. delete on[RANGE_TOKEN];
  7257. }
  7258. // This was originally intended to fix #4521 but no longer necessary
  7259. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7260. /* istanbul ignore if */
  7261. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7262. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7263. delete on[CHECKBOX_RADIO_TOKEN];
  7264. }
  7265. }
  7266. let target;
  7267. function createOnceHandler(event, handler, capture) {
  7268. const _target = target; // save current target element in closure
  7269. return function onceHandler() {
  7270. const res = handler.apply(null, arguments);
  7271. if (res !== null) {
  7272. remove(event, onceHandler, capture, _target);
  7273. }
  7274. };
  7275. }
  7276. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7277. // implementation and does not fire microtasks in between event propagation, so
  7278. // safe to exclude.
  7279. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7280. function add(name, handler, capture, passive) {
  7281. // async edge case #6566: inner click event triggers patch, event handler
  7282. // attached to outer element during patch, and triggered again. This
  7283. // happens because browsers fire microtask ticks between event propagation.
  7284. // the solution is simple: we save the timestamp when a handler is attached,
  7285. // and the handler would only fire if the event passed to it was fired
  7286. // AFTER it was attached.
  7287. if (useMicrotaskFix) {
  7288. const attachedTimestamp = currentFlushTimestamp;
  7289. const original = handler;
  7290. //@ts-expect-error
  7291. handler = original._wrapper = function (e) {
  7292. if (
  7293. // no bubbling, should always fire.
  7294. // this is just a safety net in case event.timeStamp is unreliable in
  7295. // certain weird environments...
  7296. e.target === e.currentTarget ||
  7297. // event is fired after handler attachment
  7298. e.timeStamp >= attachedTimestamp ||
  7299. // bail for environments that have buggy event.timeStamp implementations
  7300. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7301. // #9681 QtWebEngine event.timeStamp is negative value
  7302. e.timeStamp <= 0 ||
  7303. // #9448 bail if event is fired in another document in a multi-page
  7304. // electron/nw.js app, since event.timeStamp will be using a different
  7305. // starting reference
  7306. e.target.ownerDocument !== document) {
  7307. return original.apply(this, arguments);
  7308. }
  7309. };
  7310. }
  7311. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7312. }
  7313. function remove(name, handler, capture, _target) {
  7314. (_target || target).removeEventListener(name,
  7315. //@ts-expect-error
  7316. handler._wrapper || handler, capture);
  7317. }
  7318. function updateDOMListeners(oldVnode, vnode) {
  7319. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7320. return;
  7321. }
  7322. const on = vnode.data.on || {};
  7323. const oldOn = oldVnode.data.on || {};
  7324. // vnode is empty when removing all listeners,
  7325. // and use old vnode dom element
  7326. target = vnode.elm || oldVnode.elm;
  7327. normalizeEvents(on);
  7328. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7329. target = undefined;
  7330. }
  7331. var events = {
  7332. create: updateDOMListeners,
  7333. update: updateDOMListeners,
  7334. // @ts-expect-error emptyNode has actually data
  7335. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7336. };
  7337. let svgContainer;
  7338. function updateDOMProps(oldVnode, vnode) {
  7339. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7340. return;
  7341. }
  7342. let key, cur;
  7343. const elm = vnode.elm;
  7344. const oldProps = oldVnode.data.domProps || {};
  7345. let props = vnode.data.domProps || {};
  7346. // clone observed objects, as the user probably wants to mutate it
  7347. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7348. props = vnode.data.domProps = extend({}, props);
  7349. }
  7350. for (key in oldProps) {
  7351. if (!(key in props)) {
  7352. elm[key] = '';
  7353. }
  7354. }
  7355. for (key in props) {
  7356. cur = props[key];
  7357. // ignore children if the node has textContent or innerHTML,
  7358. // as these will throw away existing DOM nodes and cause removal errors
  7359. // on subsequent patches (#3360)
  7360. if (key === 'textContent' || key === 'innerHTML') {
  7361. if (vnode.children)
  7362. vnode.children.length = 0;
  7363. if (cur === oldProps[key])
  7364. continue;
  7365. // #6601 work around Chrome version <= 55 bug where single textNode
  7366. // replaced by innerHTML/textContent retains its parentNode property
  7367. if (elm.childNodes.length === 1) {
  7368. elm.removeChild(elm.childNodes[0]);
  7369. }
  7370. }
  7371. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7372. // store value as _value as well since
  7373. // non-string values will be stringified
  7374. elm._value = cur;
  7375. // avoid resetting cursor position when value is the same
  7376. const strCur = isUndef(cur) ? '' : String(cur);
  7377. if (shouldUpdateValue(elm, strCur)) {
  7378. elm.value = strCur;
  7379. }
  7380. }
  7381. else if (key === 'innerHTML' &&
  7382. isSVG(elm.tagName) &&
  7383. isUndef(elm.innerHTML)) {
  7384. // IE doesn't support innerHTML for SVG elements
  7385. svgContainer = svgContainer || document.createElement('div');
  7386. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7387. const svg = svgContainer.firstChild;
  7388. while (elm.firstChild) {
  7389. elm.removeChild(elm.firstChild);
  7390. }
  7391. while (svg.firstChild) {
  7392. elm.appendChild(svg.firstChild);
  7393. }
  7394. }
  7395. else if (
  7396. // skip the update if old and new VDOM state is the same.
  7397. // `value` is handled separately because the DOM value may be temporarily
  7398. // out of sync with VDOM state due to focus, composition and modifiers.
  7399. // This #4521 by skipping the unnecessary `checked` update.
  7400. cur !== oldProps[key]) {
  7401. // some property updates can throw
  7402. // e.g. `value` on <progress> w/ non-finite value
  7403. try {
  7404. elm[key] = cur;
  7405. }
  7406. catch (e) { }
  7407. }
  7408. }
  7409. }
  7410. function shouldUpdateValue(elm, checkVal) {
  7411. return (
  7412. //@ts-expect-error
  7413. !elm.composing &&
  7414. (elm.tagName === 'OPTION' ||
  7415. isNotInFocusAndDirty(elm, checkVal) ||
  7416. isDirtyWithModifiers(elm, checkVal)));
  7417. }
  7418. function isNotInFocusAndDirty(elm, checkVal) {
  7419. // return true when textbox (.number and .trim) loses focus and its value is
  7420. // not equal to the updated value
  7421. let notInFocus = true;
  7422. // #6157
  7423. // work around IE bug when accessing document.activeElement in an iframe
  7424. try {
  7425. notInFocus = document.activeElement !== elm;
  7426. }
  7427. catch (e) { }
  7428. return notInFocus && elm.value !== checkVal;
  7429. }
  7430. function isDirtyWithModifiers(elm, newVal) {
  7431. const value = elm.value;
  7432. const modifiers = elm._vModifiers; // injected by v-model runtime
  7433. if (isDef(modifiers)) {
  7434. if (modifiers.number) {
  7435. return toNumber(value) !== toNumber(newVal);
  7436. }
  7437. if (modifiers.trim) {
  7438. return value.trim() !== newVal.trim();
  7439. }
  7440. }
  7441. return value !== newVal;
  7442. }
  7443. var domProps = {
  7444. create: updateDOMProps,
  7445. update: updateDOMProps
  7446. };
  7447. const parseStyleText = cached(function (cssText) {
  7448. const res = {};
  7449. const listDelimiter = /;(?![^(]*\))/g;
  7450. const propertyDelimiter = /:(.+)/;
  7451. cssText.split(listDelimiter).forEach(function (item) {
  7452. if (item) {
  7453. const tmp = item.split(propertyDelimiter);
  7454. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7455. }
  7456. });
  7457. return res;
  7458. });
  7459. // merge static and dynamic style data on the same vnode
  7460. function normalizeStyleData(data) {
  7461. const style = normalizeStyleBinding(data.style);
  7462. // static style is pre-processed into an object during compilation
  7463. // and is always a fresh object, so it's safe to merge into it
  7464. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7465. }
  7466. // normalize possible array / string values into Object
  7467. function normalizeStyleBinding(bindingStyle) {
  7468. if (Array.isArray(bindingStyle)) {
  7469. return toObject(bindingStyle);
  7470. }
  7471. if (typeof bindingStyle === 'string') {
  7472. return parseStyleText(bindingStyle);
  7473. }
  7474. return bindingStyle;
  7475. }
  7476. /**
  7477. * parent component style should be after child's
  7478. * so that parent component's style could override it
  7479. */
  7480. function getStyle(vnode, checkChild) {
  7481. const res = {};
  7482. let styleData;
  7483. if (checkChild) {
  7484. let childNode = vnode;
  7485. while (childNode.componentInstance) {
  7486. childNode = childNode.componentInstance._vnode;
  7487. if (childNode &&
  7488. childNode.data &&
  7489. (styleData = normalizeStyleData(childNode.data))) {
  7490. extend(res, styleData);
  7491. }
  7492. }
  7493. }
  7494. if ((styleData = normalizeStyleData(vnode.data))) {
  7495. extend(res, styleData);
  7496. }
  7497. let parentNode = vnode;
  7498. // @ts-expect-error parentNode.parent not VNodeWithData
  7499. while ((parentNode = parentNode.parent)) {
  7500. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7501. extend(res, styleData);
  7502. }
  7503. }
  7504. return res;
  7505. }
  7506. const cssVarRE = /^--/;
  7507. const importantRE = /\s*!important$/;
  7508. const setProp = (el, name, val) => {
  7509. /* istanbul ignore if */
  7510. if (cssVarRE.test(name)) {
  7511. el.style.setProperty(name, val);
  7512. }
  7513. else if (importantRE.test(val)) {
  7514. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7515. }
  7516. else {
  7517. const normalizedName = normalize(name);
  7518. if (Array.isArray(val)) {
  7519. // Support values array created by autoprefixer, e.g.
  7520. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7521. // Set them one by one, and the browser will only set those it can recognize
  7522. for (let i = 0, len = val.length; i < len; i++) {
  7523. el.style[normalizedName] = val[i];
  7524. }
  7525. }
  7526. else {
  7527. el.style[normalizedName] = val;
  7528. }
  7529. }
  7530. };
  7531. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7532. let emptyStyle;
  7533. const normalize = cached(function (prop) {
  7534. emptyStyle = emptyStyle || document.createElement('div').style;
  7535. prop = camelize(prop);
  7536. if (prop !== 'filter' && prop in emptyStyle) {
  7537. return prop;
  7538. }
  7539. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7540. for (let i = 0; i < vendorNames.length; i++) {
  7541. const name = vendorNames[i] + capName;
  7542. if (name in emptyStyle) {
  7543. return name;
  7544. }
  7545. }
  7546. });
  7547. function updateStyle(oldVnode, vnode) {
  7548. const data = vnode.data;
  7549. const oldData = oldVnode.data;
  7550. if (isUndef(data.staticStyle) &&
  7551. isUndef(data.style) &&
  7552. isUndef(oldData.staticStyle) &&
  7553. isUndef(oldData.style)) {
  7554. return;
  7555. }
  7556. let cur, name;
  7557. const el = vnode.elm;
  7558. const oldStaticStyle = oldData.staticStyle;
  7559. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7560. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7561. const oldStyle = oldStaticStyle || oldStyleBinding;
  7562. const style = normalizeStyleBinding(vnode.data.style) || {};
  7563. // store normalized style under a different key for next diff
  7564. // make sure to clone it if it's reactive, since the user likely wants
  7565. // to mutate it.
  7566. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  7567. const newStyle = getStyle(vnode, true);
  7568. for (name in oldStyle) {
  7569. if (isUndef(newStyle[name])) {
  7570. setProp(el, name, '');
  7571. }
  7572. }
  7573. for (name in newStyle) {
  7574. cur = newStyle[name];
  7575. if (cur !== oldStyle[name]) {
  7576. // ie9 setting to null has no effect, must use empty string
  7577. setProp(el, name, cur == null ? '' : cur);
  7578. }
  7579. }
  7580. }
  7581. var style = {
  7582. create: updateStyle,
  7583. update: updateStyle
  7584. };
  7585. const whitespaceRE = /\s+/;
  7586. /**
  7587. * Add class with compatibility for SVG since classList is not supported on
  7588. * SVG elements in IE
  7589. */
  7590. function addClass(el, cls) {
  7591. /* istanbul ignore if */
  7592. if (!cls || !(cls = cls.trim())) {
  7593. return;
  7594. }
  7595. /* istanbul ignore else */
  7596. if (el.classList) {
  7597. if (cls.indexOf(' ') > -1) {
  7598. cls.split(whitespaceRE).forEach(c => el.classList.add(c));
  7599. }
  7600. else {
  7601. el.classList.add(cls);
  7602. }
  7603. }
  7604. else {
  7605. const cur = ` ${el.getAttribute('class') || ''} `;
  7606. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7607. el.setAttribute('class', (cur + cls).trim());
  7608. }
  7609. }
  7610. }
  7611. /**
  7612. * Remove class with compatibility for SVG since classList is not supported on
  7613. * SVG elements in IE
  7614. */
  7615. function removeClass(el, cls) {
  7616. /* istanbul ignore if */
  7617. if (!cls || !(cls = cls.trim())) {
  7618. return;
  7619. }
  7620. /* istanbul ignore else */
  7621. if (el.classList) {
  7622. if (cls.indexOf(' ') > -1) {
  7623. cls.split(whitespaceRE).forEach(c => el.classList.remove(c));
  7624. }
  7625. else {
  7626. el.classList.remove(cls);
  7627. }
  7628. if (!el.classList.length) {
  7629. el.removeAttribute('class');
  7630. }
  7631. }
  7632. else {
  7633. let cur = ` ${el.getAttribute('class') || ''} `;
  7634. const tar = ' ' + cls + ' ';
  7635. while (cur.indexOf(tar) >= 0) {
  7636. cur = cur.replace(tar, ' ');
  7637. }
  7638. cur = cur.trim();
  7639. if (cur) {
  7640. el.setAttribute('class', cur);
  7641. }
  7642. else {
  7643. el.removeAttribute('class');
  7644. }
  7645. }
  7646. }
  7647. function resolveTransition(def) {
  7648. if (!def) {
  7649. return;
  7650. }
  7651. /* istanbul ignore else */
  7652. if (typeof def === 'object') {
  7653. const res = {};
  7654. if (def.css !== false) {
  7655. extend(res, autoCssTransition(def.name || 'v'));
  7656. }
  7657. extend(res, def);
  7658. return res;
  7659. }
  7660. else if (typeof def === 'string') {
  7661. return autoCssTransition(def);
  7662. }
  7663. }
  7664. const autoCssTransition = cached(name => {
  7665. return {
  7666. enterClass: `${name}-enter`,
  7667. enterToClass: `${name}-enter-to`,
  7668. enterActiveClass: `${name}-enter-active`,
  7669. leaveClass: `${name}-leave`,
  7670. leaveToClass: `${name}-leave-to`,
  7671. leaveActiveClass: `${name}-leave-active`
  7672. };
  7673. });
  7674. const hasTransition = inBrowser && !isIE9;
  7675. const TRANSITION = 'transition';
  7676. const ANIMATION = 'animation';
  7677. // Transition property/event sniffing
  7678. let transitionProp = 'transition';
  7679. let transitionEndEvent = 'transitionend';
  7680. let animationProp = 'animation';
  7681. let animationEndEvent = 'animationend';
  7682. if (hasTransition) {
  7683. /* istanbul ignore if */
  7684. if (window.ontransitionend === undefined &&
  7685. window.onwebkittransitionend !== undefined) {
  7686. transitionProp = 'WebkitTransition';
  7687. transitionEndEvent = 'webkitTransitionEnd';
  7688. }
  7689. if (window.onanimationend === undefined &&
  7690. window.onwebkitanimationend !== undefined) {
  7691. animationProp = 'WebkitAnimation';
  7692. animationEndEvent = 'webkitAnimationEnd';
  7693. }
  7694. }
  7695. // binding to window is necessary to make hot reload work in IE in strict mode
  7696. const raf = inBrowser
  7697. ? window.requestAnimationFrame
  7698. ? window.requestAnimationFrame.bind(window)
  7699. : setTimeout
  7700. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  7701. function nextFrame(fn) {
  7702. raf(() => {
  7703. // @ts-expect-error
  7704. raf(fn);
  7705. });
  7706. }
  7707. function addTransitionClass(el, cls) {
  7708. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7709. if (transitionClasses.indexOf(cls) < 0) {
  7710. transitionClasses.push(cls);
  7711. addClass(el, cls);
  7712. }
  7713. }
  7714. function removeTransitionClass(el, cls) {
  7715. if (el._transitionClasses) {
  7716. remove$2(el._transitionClasses, cls);
  7717. }
  7718. removeClass(el, cls);
  7719. }
  7720. function whenTransitionEnds(el, expectedType, cb) {
  7721. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  7722. if (!type)
  7723. return cb();
  7724. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7725. let ended = 0;
  7726. const end = () => {
  7727. el.removeEventListener(event, onEnd);
  7728. cb();
  7729. };
  7730. const onEnd = e => {
  7731. if (e.target === el) {
  7732. if (++ended >= propCount) {
  7733. end();
  7734. }
  7735. }
  7736. };
  7737. setTimeout(() => {
  7738. if (ended < propCount) {
  7739. end();
  7740. }
  7741. }, timeout + 1);
  7742. el.addEventListener(event, onEnd);
  7743. }
  7744. const transformRE = /\b(transform|all)(,|$)/;
  7745. function getTransitionInfo(el, expectedType) {
  7746. const styles = window.getComputedStyle(el);
  7747. // JSDOM may return undefined for transition properties
  7748. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7749. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7750. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7751. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7752. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7753. const animationTimeout = getTimeout(animationDelays, animationDurations);
  7754. let type;
  7755. let timeout = 0;
  7756. let propCount = 0;
  7757. /* istanbul ignore if */
  7758. if (expectedType === TRANSITION) {
  7759. if (transitionTimeout > 0) {
  7760. type = TRANSITION;
  7761. timeout = transitionTimeout;
  7762. propCount = transitionDurations.length;
  7763. }
  7764. }
  7765. else if (expectedType === ANIMATION) {
  7766. if (animationTimeout > 0) {
  7767. type = ANIMATION;
  7768. timeout = animationTimeout;
  7769. propCount = animationDurations.length;
  7770. }
  7771. }
  7772. else {
  7773. timeout = Math.max(transitionTimeout, animationTimeout);
  7774. type =
  7775. timeout > 0
  7776. ? transitionTimeout > animationTimeout
  7777. ? TRANSITION
  7778. : ANIMATION
  7779. : null;
  7780. propCount = type
  7781. ? type === TRANSITION
  7782. ? transitionDurations.length
  7783. : animationDurations.length
  7784. : 0;
  7785. }
  7786. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  7787. return {
  7788. type,
  7789. timeout,
  7790. propCount,
  7791. hasTransform
  7792. };
  7793. }
  7794. function getTimeout(delays, durations) {
  7795. /* istanbul ignore next */
  7796. while (delays.length < durations.length) {
  7797. delays = delays.concat(delays);
  7798. }
  7799. return Math.max.apply(null, durations.map((d, i) => {
  7800. return toMs(d) + toMs(delays[i]);
  7801. }));
  7802. }
  7803. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7804. // in a locale-dependent way, using a comma instead of a dot.
  7805. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7806. // as a floor function) causing unexpected behaviors
  7807. function toMs(s) {
  7808. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  7809. }
  7810. function enter(vnode, toggleDisplay) {
  7811. const el = vnode.elm;
  7812. // call leave callback now
  7813. if (isDef(el._leaveCb)) {
  7814. el._leaveCb.cancelled = true;
  7815. el._leaveCb();
  7816. }
  7817. const data = resolveTransition(vnode.data.transition);
  7818. if (isUndef(data)) {
  7819. return;
  7820. }
  7821. /* istanbul ignore if */
  7822. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7823. return;
  7824. }
  7825. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  7826. // activeInstance will always be the <transition> component managing this
  7827. // transition. One edge case to check is when the <transition> is placed
  7828. // as the root node of a child component. In that case we need to check
  7829. // <transition>'s parent for appear check.
  7830. let context = activeInstance;
  7831. let transitionNode = activeInstance.$vnode;
  7832. while (transitionNode && transitionNode.parent) {
  7833. context = transitionNode.context;
  7834. transitionNode = transitionNode.parent;
  7835. }
  7836. const isAppear = !context._isMounted || !vnode.isRootInsert;
  7837. if (isAppear && !appear && appear !== '') {
  7838. return;
  7839. }
  7840. const startClass = isAppear && appearClass ? appearClass : enterClass;
  7841. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  7842. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  7843. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  7844. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  7845. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  7846. const enterCancelledHook = isAppear
  7847. ? appearCancelled || enterCancelled
  7848. : enterCancelled;
  7849. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  7850. if (explicitEnterDuration != null) {
  7851. checkDuration(explicitEnterDuration, 'enter', vnode);
  7852. }
  7853. const expectsCSS = css !== false && !isIE9;
  7854. const userWantsControl = getHookArgumentsLength(enterHook);
  7855. const cb = (el._enterCb = once(() => {
  7856. if (expectsCSS) {
  7857. removeTransitionClass(el, toClass);
  7858. removeTransitionClass(el, activeClass);
  7859. }
  7860. // @ts-expect-error
  7861. if (cb.cancelled) {
  7862. if (expectsCSS) {
  7863. removeTransitionClass(el, startClass);
  7864. }
  7865. enterCancelledHook && enterCancelledHook(el);
  7866. }
  7867. else {
  7868. afterEnterHook && afterEnterHook(el);
  7869. }
  7870. el._enterCb = null;
  7871. }));
  7872. if (!vnode.data.show) {
  7873. // remove pending leave element on enter by injecting an insert hook
  7874. mergeVNodeHook(vnode, 'insert', () => {
  7875. const parent = el.parentNode;
  7876. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7877. if (pendingNode &&
  7878. pendingNode.tag === vnode.tag &&
  7879. pendingNode.elm._leaveCb) {
  7880. pendingNode.elm._leaveCb();
  7881. }
  7882. enterHook && enterHook(el, cb);
  7883. });
  7884. }
  7885. // start enter transition
  7886. beforeEnterHook && beforeEnterHook(el);
  7887. if (expectsCSS) {
  7888. addTransitionClass(el, startClass);
  7889. addTransitionClass(el, activeClass);
  7890. nextFrame(() => {
  7891. removeTransitionClass(el, startClass);
  7892. // @ts-expect-error
  7893. if (!cb.cancelled) {
  7894. addTransitionClass(el, toClass);
  7895. if (!userWantsControl) {
  7896. if (isValidDuration(explicitEnterDuration)) {
  7897. setTimeout(cb, explicitEnterDuration);
  7898. }
  7899. else {
  7900. whenTransitionEnds(el, type, cb);
  7901. }
  7902. }
  7903. }
  7904. });
  7905. }
  7906. if (vnode.data.show) {
  7907. toggleDisplay && toggleDisplay();
  7908. enterHook && enterHook(el, cb);
  7909. }
  7910. if (!expectsCSS && !userWantsControl) {
  7911. cb();
  7912. }
  7913. }
  7914. function leave(vnode, rm) {
  7915. const el = vnode.elm;
  7916. // call enter callback now
  7917. if (isDef(el._enterCb)) {
  7918. el._enterCb.cancelled = true;
  7919. el._enterCb();
  7920. }
  7921. const data = resolveTransition(vnode.data.transition);
  7922. if (isUndef(data) || el.nodeType !== 1) {
  7923. return rm();
  7924. }
  7925. /* istanbul ignore if */
  7926. if (isDef(el._leaveCb)) {
  7927. return;
  7928. }
  7929. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  7930. const expectsCSS = css !== false && !isIE9;
  7931. const userWantsControl = getHookArgumentsLength(leave);
  7932. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  7933. if (isDef(explicitLeaveDuration)) {
  7934. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7935. }
  7936. const cb = (el._leaveCb = once(() => {
  7937. if (el.parentNode && el.parentNode._pending) {
  7938. el.parentNode._pending[vnode.key] = null;
  7939. }
  7940. if (expectsCSS) {
  7941. removeTransitionClass(el, leaveToClass);
  7942. removeTransitionClass(el, leaveActiveClass);
  7943. }
  7944. // @ts-expect-error
  7945. if (cb.cancelled) {
  7946. if (expectsCSS) {
  7947. removeTransitionClass(el, leaveClass);
  7948. }
  7949. leaveCancelled && leaveCancelled(el);
  7950. }
  7951. else {
  7952. rm();
  7953. afterLeave && afterLeave(el);
  7954. }
  7955. el._leaveCb = null;
  7956. }));
  7957. if (delayLeave) {
  7958. delayLeave(performLeave);
  7959. }
  7960. else {
  7961. performLeave();
  7962. }
  7963. function performLeave() {
  7964. // the delayed leave may have already been cancelled
  7965. // @ts-expect-error
  7966. if (cb.cancelled) {
  7967. return;
  7968. }
  7969. // record leaving element
  7970. if (!vnode.data.show && el.parentNode) {
  7971. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  7972. vnode;
  7973. }
  7974. beforeLeave && beforeLeave(el);
  7975. if (expectsCSS) {
  7976. addTransitionClass(el, leaveClass);
  7977. addTransitionClass(el, leaveActiveClass);
  7978. nextFrame(() => {
  7979. removeTransitionClass(el, leaveClass);
  7980. // @ts-expect-error
  7981. if (!cb.cancelled) {
  7982. addTransitionClass(el, leaveToClass);
  7983. if (!userWantsControl) {
  7984. if (isValidDuration(explicitLeaveDuration)) {
  7985. setTimeout(cb, explicitLeaveDuration);
  7986. }
  7987. else {
  7988. whenTransitionEnds(el, type, cb);
  7989. }
  7990. }
  7991. }
  7992. });
  7993. }
  7994. leave && leave(el, cb);
  7995. if (!expectsCSS && !userWantsControl) {
  7996. cb();
  7997. }
  7998. }
  7999. }
  8000. // only used in dev mode
  8001. function checkDuration(val, name, vnode) {
  8002. if (typeof val !== 'number') {
  8003. warn(`<transition> explicit ${name} duration is not a valid number - ` +
  8004. `got ${JSON.stringify(val)}.`, vnode.context);
  8005. }
  8006. else if (isNaN(val)) {
  8007. warn(`<transition> explicit ${name} duration is NaN - ` +
  8008. 'the duration expression might be incorrect.', vnode.context);
  8009. }
  8010. }
  8011. function isValidDuration(val) {
  8012. return typeof val === 'number' && !isNaN(val);
  8013. }
  8014. /**
  8015. * Normalize a transition hook's argument length. The hook may be:
  8016. * - a merged hook (invoker) with the original in .fns
  8017. * - a wrapped component method (check ._length)
  8018. * - a plain function (.length)
  8019. */
  8020. function getHookArgumentsLength(fn) {
  8021. if (isUndef(fn)) {
  8022. return false;
  8023. }
  8024. // @ts-expect-error
  8025. const invokerFns = fn.fns;
  8026. if (isDef(invokerFns)) {
  8027. // invoker
  8028. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8029. }
  8030. else {
  8031. // @ts-expect-error
  8032. return (fn._length || fn.length) > 1;
  8033. }
  8034. }
  8035. function _enter(_, vnode) {
  8036. if (vnode.data.show !== true) {
  8037. enter(vnode);
  8038. }
  8039. }
  8040. var transition = inBrowser
  8041. ? {
  8042. create: _enter,
  8043. activate: _enter,
  8044. remove(vnode, rm) {
  8045. /* istanbul ignore else */
  8046. if (vnode.data.show !== true) {
  8047. // @ts-expect-error
  8048. leave(vnode, rm);
  8049. }
  8050. else {
  8051. rm();
  8052. }
  8053. }
  8054. }
  8055. : {};
  8056. var platformModules = [attrs, klass, events, domProps, style, transition];
  8057. // the directive module should be applied last, after all
  8058. // built-in modules have been applied.
  8059. const modules = platformModules.concat(baseModules);
  8060. const patch = createPatchFunction({ nodeOps, modules });
  8061. /**
  8062. * Not type checking this file because flow doesn't like attaching
  8063. * properties to Elements.
  8064. */
  8065. /* istanbul ignore if */
  8066. if (isIE9) {
  8067. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8068. document.addEventListener('selectionchange', () => {
  8069. const el = document.activeElement;
  8070. // @ts-expect-error
  8071. if (el && el.vmodel) {
  8072. trigger(el, 'input');
  8073. }
  8074. });
  8075. }
  8076. const directive = {
  8077. inserted(el, binding, vnode, oldVnode) {
  8078. if (vnode.tag === 'select') {
  8079. // #6903
  8080. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8081. mergeVNodeHook(vnode, 'postpatch', () => {
  8082. directive.componentUpdated(el, binding, vnode);
  8083. });
  8084. }
  8085. else {
  8086. setSelected(el, binding, vnode.context);
  8087. }
  8088. el._vOptions = [].map.call(el.options, getValue);
  8089. }
  8090. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8091. el._vModifiers = binding.modifiers;
  8092. if (!binding.modifiers.lazy) {
  8093. el.addEventListener('compositionstart', onCompositionStart);
  8094. el.addEventListener('compositionend', onCompositionEnd);
  8095. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8096. // switching focus before confirming composition choice
  8097. // this also fixes the issue where some browsers e.g. iOS Chrome
  8098. // fires "change" instead of "input" on autocomplete.
  8099. el.addEventListener('change', onCompositionEnd);
  8100. /* istanbul ignore if */
  8101. if (isIE9) {
  8102. el.vmodel = true;
  8103. }
  8104. }
  8105. }
  8106. },
  8107. componentUpdated(el, binding, vnode) {
  8108. if (vnode.tag === 'select') {
  8109. setSelected(el, binding, vnode.context);
  8110. // in case the options rendered by v-for have changed,
  8111. // it's possible that the value is out-of-sync with the rendered options.
  8112. // detect such cases and filter out values that no longer has a matching
  8113. // option in the DOM.
  8114. const prevOptions = el._vOptions;
  8115. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8116. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8117. // trigger change event if
  8118. // no matching option found for at least one value
  8119. const needReset = el.multiple
  8120. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8121. : binding.value !== binding.oldValue &&
  8122. hasNoMatchingOption(binding.value, curOptions);
  8123. if (needReset) {
  8124. trigger(el, 'change');
  8125. }
  8126. }
  8127. }
  8128. }
  8129. };
  8130. function setSelected(el, binding, vm) {
  8131. actuallySetSelected(el, binding, vm);
  8132. /* istanbul ignore if */
  8133. if (isIE || isEdge) {
  8134. setTimeout(() => {
  8135. actuallySetSelected(el, binding, vm);
  8136. }, 0);
  8137. }
  8138. }
  8139. function actuallySetSelected(el, binding, vm) {
  8140. const value = binding.value;
  8141. const isMultiple = el.multiple;
  8142. if (isMultiple && !Array.isArray(value)) {
  8143. warn(`<select multiple v-model="${binding.expression}"> ` +
  8144. `expects an Array value for its binding, but got ${Object.prototype.toString
  8145. .call(value)
  8146. .slice(8, -1)}`, vm);
  8147. return;
  8148. }
  8149. let selected, option;
  8150. for (let i = 0, l = el.options.length; i < l; i++) {
  8151. option = el.options[i];
  8152. if (isMultiple) {
  8153. selected = looseIndexOf(value, getValue(option)) > -1;
  8154. if (option.selected !== selected) {
  8155. option.selected = selected;
  8156. }
  8157. }
  8158. else {
  8159. if (looseEqual(getValue(option), value)) {
  8160. if (el.selectedIndex !== i) {
  8161. el.selectedIndex = i;
  8162. }
  8163. return;
  8164. }
  8165. }
  8166. }
  8167. if (!isMultiple) {
  8168. el.selectedIndex = -1;
  8169. }
  8170. }
  8171. function hasNoMatchingOption(value, options) {
  8172. return options.every(o => !looseEqual(o, value));
  8173. }
  8174. function getValue(option) {
  8175. return '_value' in option ? option._value : option.value;
  8176. }
  8177. function onCompositionStart(e) {
  8178. e.target.composing = true;
  8179. }
  8180. function onCompositionEnd(e) {
  8181. // prevent triggering an input event for no reason
  8182. if (!e.target.composing)
  8183. return;
  8184. e.target.composing = false;
  8185. trigger(e.target, 'input');
  8186. }
  8187. function trigger(el, type) {
  8188. const e = document.createEvent('HTMLEvents');
  8189. e.initEvent(type, true, true);
  8190. el.dispatchEvent(e);
  8191. }
  8192. // recursively search for possible transition defined inside the component root
  8193. function locateNode(vnode) {
  8194. // @ts-expect-error
  8195. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8196. ? locateNode(vnode.componentInstance._vnode)
  8197. : vnode;
  8198. }
  8199. var show = {
  8200. bind(el, { value }, vnode) {
  8201. vnode = locateNode(vnode);
  8202. const transition = vnode.data && vnode.data.transition;
  8203. const originalDisplay = (el.__vOriginalDisplay =
  8204. el.style.display === 'none' ? '' : el.style.display);
  8205. if (value && transition) {
  8206. vnode.data.show = true;
  8207. enter(vnode, () => {
  8208. el.style.display = originalDisplay;
  8209. });
  8210. }
  8211. else {
  8212. el.style.display = value ? originalDisplay : 'none';
  8213. }
  8214. },
  8215. update(el, { value, oldValue }, vnode) {
  8216. /* istanbul ignore if */
  8217. if (!value === !oldValue)
  8218. return;
  8219. vnode = locateNode(vnode);
  8220. const transition = vnode.data && vnode.data.transition;
  8221. if (transition) {
  8222. vnode.data.show = true;
  8223. if (value) {
  8224. enter(vnode, () => {
  8225. el.style.display = el.__vOriginalDisplay;
  8226. });
  8227. }
  8228. else {
  8229. leave(vnode, () => {
  8230. el.style.display = 'none';
  8231. });
  8232. }
  8233. }
  8234. else {
  8235. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8236. }
  8237. },
  8238. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8239. if (!isDestroy) {
  8240. el.style.display = el.__vOriginalDisplay;
  8241. }
  8242. }
  8243. };
  8244. var platformDirectives = {
  8245. model: directive,
  8246. show
  8247. };
  8248. // Provides transition support for a single element/component.
  8249. const transitionProps = {
  8250. name: String,
  8251. appear: Boolean,
  8252. css: Boolean,
  8253. mode: String,
  8254. type: String,
  8255. enterClass: String,
  8256. leaveClass: String,
  8257. enterToClass: String,
  8258. leaveToClass: String,
  8259. enterActiveClass: String,
  8260. leaveActiveClass: String,
  8261. appearClass: String,
  8262. appearActiveClass: String,
  8263. appearToClass: String,
  8264. duration: [Number, String, Object]
  8265. };
  8266. // in case the child is also an abstract component, e.g. <keep-alive>
  8267. // we want to recursively retrieve the real component to be rendered
  8268. function getRealChild(vnode) {
  8269. const compOptions = vnode && vnode.componentOptions;
  8270. if (compOptions && compOptions.Ctor.options.abstract) {
  8271. return getRealChild(getFirstComponentChild(compOptions.children));
  8272. }
  8273. else {
  8274. return vnode;
  8275. }
  8276. }
  8277. function extractTransitionData(comp) {
  8278. const data = {};
  8279. const options = comp.$options;
  8280. // props
  8281. for (const key in options.propsData) {
  8282. data[key] = comp[key];
  8283. }
  8284. // events.
  8285. // extract listeners and pass them directly to the transition methods
  8286. const listeners = options._parentListeners;
  8287. for (const key in listeners) {
  8288. data[camelize(key)] = listeners[key];
  8289. }
  8290. return data;
  8291. }
  8292. function placeholder(h, rawChild) {
  8293. // @ts-expect-error
  8294. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8295. return h('keep-alive', {
  8296. props: rawChild.componentOptions.propsData
  8297. });
  8298. }
  8299. }
  8300. function hasParentTransition(vnode) {
  8301. while ((vnode = vnode.parent)) {
  8302. if (vnode.data.transition) {
  8303. return true;
  8304. }
  8305. }
  8306. }
  8307. function isSameChild(child, oldChild) {
  8308. return oldChild.key === child.key && oldChild.tag === child.tag;
  8309. }
  8310. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8311. const isVShowDirective = d => d.name === 'show';
  8312. var Transition = {
  8313. name: 'transition',
  8314. props: transitionProps,
  8315. abstract: true,
  8316. render(h) {
  8317. let children = this.$slots.default;
  8318. if (!children) {
  8319. return;
  8320. }
  8321. // filter out text nodes (possible whitespaces)
  8322. children = children.filter(isNotTextNode);
  8323. /* istanbul ignore if */
  8324. if (!children.length) {
  8325. return;
  8326. }
  8327. // warn multiple elements
  8328. if (children.length > 1) {
  8329. warn('<transition> can only be used on a single element. Use ' +
  8330. '<transition-group> for lists.', this.$parent);
  8331. }
  8332. const mode = this.mode;
  8333. // warn invalid mode
  8334. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8335. warn('invalid <transition> mode: ' + mode, this.$parent);
  8336. }
  8337. const rawChild = children[0];
  8338. // if this is a component root node and the component's
  8339. // parent container node also has transition, skip.
  8340. if (hasParentTransition(this.$vnode)) {
  8341. return rawChild;
  8342. }
  8343. // apply transition data to child
  8344. // use getRealChild() to ignore abstract components e.g. keep-alive
  8345. const child = getRealChild(rawChild);
  8346. /* istanbul ignore if */
  8347. if (!child) {
  8348. return rawChild;
  8349. }
  8350. if (this._leaving) {
  8351. return placeholder(h, rawChild);
  8352. }
  8353. // ensure a key that is unique to the vnode type and to this transition
  8354. // component instance. This key will be used to remove pending leaving nodes
  8355. // during entering.
  8356. const id = `__transition-${this._uid}-`;
  8357. child.key =
  8358. child.key == null
  8359. ? child.isComment
  8360. ? id + 'comment'
  8361. : id + child.tag
  8362. : isPrimitive(child.key)
  8363. ? String(child.key).indexOf(id) === 0
  8364. ? child.key
  8365. : id + child.key
  8366. : child.key;
  8367. const data = ((child.data || (child.data = {})).transition =
  8368. extractTransitionData(this));
  8369. const oldRawChild = this._vnode;
  8370. const oldChild = getRealChild(oldRawChild);
  8371. // mark v-show
  8372. // so that the transition module can hand over the control to the directive
  8373. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8374. child.data.show = true;
  8375. }
  8376. if (oldChild &&
  8377. oldChild.data &&
  8378. !isSameChild(child, oldChild) &&
  8379. !isAsyncPlaceholder(oldChild) &&
  8380. // #6687 component root is a comment node
  8381. !(oldChild.componentInstance &&
  8382. oldChild.componentInstance._vnode.isComment)) {
  8383. // replace old child transition data with fresh one
  8384. // important for dynamic transitions!
  8385. const oldData = (oldChild.data.transition = extend({}, data));
  8386. // handle transition mode
  8387. if (mode === 'out-in') {
  8388. // return placeholder node and queue update when leave finishes
  8389. this._leaving = true;
  8390. mergeVNodeHook(oldData, 'afterLeave', () => {
  8391. this._leaving = false;
  8392. this.$forceUpdate();
  8393. });
  8394. return placeholder(h, rawChild);
  8395. }
  8396. else if (mode === 'in-out') {
  8397. if (isAsyncPlaceholder(child)) {
  8398. return oldRawChild;
  8399. }
  8400. let delayedLeave;
  8401. const performLeave = () => {
  8402. delayedLeave();
  8403. };
  8404. mergeVNodeHook(data, 'afterEnter', performLeave);
  8405. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8406. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8407. delayedLeave = leave;
  8408. });
  8409. }
  8410. }
  8411. return rawChild;
  8412. }
  8413. };
  8414. // Provides transition support for list items.
  8415. const props = extend({
  8416. tag: String,
  8417. moveClass: String
  8418. }, transitionProps);
  8419. delete props.mode;
  8420. var TransitionGroup = {
  8421. props,
  8422. beforeMount() {
  8423. const update = this._update;
  8424. this._update = (vnode, hydrating) => {
  8425. const restoreActiveInstance = setActiveInstance(this);
  8426. // force removing pass
  8427. this.__patch__(this._vnode, this.kept, false, // hydrating
  8428. true // removeOnly (!important, avoids unnecessary moves)
  8429. );
  8430. this._vnode = this.kept;
  8431. restoreActiveInstance();
  8432. update.call(this, vnode, hydrating);
  8433. };
  8434. },
  8435. render(h) {
  8436. const tag = this.tag || this.$vnode.data.tag || 'span';
  8437. const map = Object.create(null);
  8438. const prevChildren = (this.prevChildren = this.children);
  8439. const rawChildren = this.$slots.default || [];
  8440. const children = (this.children = []);
  8441. const transitionData = extractTransitionData(this);
  8442. for (let i = 0; i < rawChildren.length; i++) {
  8443. const c = rawChildren[i];
  8444. if (c.tag) {
  8445. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8446. children.push(c);
  8447. map[c.key] = c;
  8448. (c.data || (c.data = {})).transition = transitionData;
  8449. }
  8450. else {
  8451. const opts = c.componentOptions;
  8452. const name = opts
  8453. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8454. : c.tag;
  8455. warn(`<transition-group> children must be keyed: <${name}>`);
  8456. }
  8457. }
  8458. }
  8459. if (prevChildren) {
  8460. const kept = [];
  8461. const removed = [];
  8462. for (let i = 0; i < prevChildren.length; i++) {
  8463. const c = prevChildren[i];
  8464. c.data.transition = transitionData;
  8465. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8466. c.data.pos = c.elm.getBoundingClientRect();
  8467. if (map[c.key]) {
  8468. kept.push(c);
  8469. }
  8470. else {
  8471. removed.push(c);
  8472. }
  8473. }
  8474. this.kept = h(tag, null, kept);
  8475. this.removed = removed;
  8476. }
  8477. return h(tag, null, children);
  8478. },
  8479. updated() {
  8480. const children = this.prevChildren;
  8481. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  8482. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8483. return;
  8484. }
  8485. // we divide the work into three loops to avoid mixing DOM reads and writes
  8486. // in each iteration - which helps prevent layout thrashing.
  8487. children.forEach(callPendingCbs);
  8488. children.forEach(recordPosition);
  8489. children.forEach(applyTranslation);
  8490. // force reflow to put everything in position
  8491. // assign to this to avoid being removed in tree-shaking
  8492. // $flow-disable-line
  8493. this._reflow = document.body.offsetHeight;
  8494. children.forEach((c) => {
  8495. if (c.data.moved) {
  8496. const el = c.elm;
  8497. const s = el.style;
  8498. addTransitionClass(el, moveClass);
  8499. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8500. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  8501. if (e && e.target !== el) {
  8502. return;
  8503. }
  8504. if (!e || /transform$/.test(e.propertyName)) {
  8505. el.removeEventListener(transitionEndEvent, cb);
  8506. el._moveCb = null;
  8507. removeTransitionClass(el, moveClass);
  8508. }
  8509. }));
  8510. }
  8511. });
  8512. },
  8513. methods: {
  8514. hasMove(el, moveClass) {
  8515. /* istanbul ignore if */
  8516. if (!hasTransition) {
  8517. return false;
  8518. }
  8519. /* istanbul ignore if */
  8520. if (this._hasMove) {
  8521. return this._hasMove;
  8522. }
  8523. // Detect whether an element with the move class applied has
  8524. // CSS transitions. Since the element may be inside an entering
  8525. // transition at this very moment, we make a clone of it and remove
  8526. // all other transition classes applied to ensure only the move class
  8527. // is applied.
  8528. const clone = el.cloneNode();
  8529. if (el._transitionClasses) {
  8530. el._transitionClasses.forEach((cls) => {
  8531. removeClass(clone, cls);
  8532. });
  8533. }
  8534. addClass(clone, moveClass);
  8535. clone.style.display = 'none';
  8536. this.$el.appendChild(clone);
  8537. const info = getTransitionInfo(clone);
  8538. this.$el.removeChild(clone);
  8539. return (this._hasMove = info.hasTransform);
  8540. }
  8541. }
  8542. };
  8543. function callPendingCbs(c) {
  8544. /* istanbul ignore if */
  8545. if (c.elm._moveCb) {
  8546. c.elm._moveCb();
  8547. }
  8548. /* istanbul ignore if */
  8549. if (c.elm._enterCb) {
  8550. c.elm._enterCb();
  8551. }
  8552. }
  8553. function recordPosition(c) {
  8554. c.data.newPos = c.elm.getBoundingClientRect();
  8555. }
  8556. function applyTranslation(c) {
  8557. const oldPos = c.data.pos;
  8558. const newPos = c.data.newPos;
  8559. const dx = oldPos.left - newPos.left;
  8560. const dy = oldPos.top - newPos.top;
  8561. if (dx || dy) {
  8562. c.data.moved = true;
  8563. const s = c.elm.style;
  8564. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  8565. s.transitionDuration = '0s';
  8566. }
  8567. }
  8568. var platformComponents = {
  8569. Transition,
  8570. TransitionGroup
  8571. };
  8572. // install platform specific utils
  8573. Vue.config.mustUseProp = mustUseProp;
  8574. Vue.config.isReservedTag = isReservedTag;
  8575. Vue.config.isReservedAttr = isReservedAttr;
  8576. Vue.config.getTagNamespace = getTagNamespace;
  8577. Vue.config.isUnknownElement = isUnknownElement;
  8578. // install platform runtime directives & components
  8579. extend(Vue.options.directives, platformDirectives);
  8580. extend(Vue.options.components, platformComponents);
  8581. // install platform patch function
  8582. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8583. // public mount method
  8584. Vue.prototype.$mount = function (el, hydrating) {
  8585. el = el && inBrowser ? query(el) : undefined;
  8586. return mountComponent(this, el, hydrating);
  8587. };
  8588. // devtools global hook
  8589. /* istanbul ignore next */
  8590. if (inBrowser) {
  8591. setTimeout(() => {
  8592. if (config.devtools) {
  8593. if (devtools) {
  8594. devtools.emit('init', Vue);
  8595. }
  8596. else {
  8597. // @ts-expect-error
  8598. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  8599. 'https://github.com/vuejs/vue-devtools');
  8600. }
  8601. }
  8602. if (config.productionTip !== false &&
  8603. typeof console !== 'undefined') {
  8604. // @ts-expect-error
  8605. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  8606. `Make sure to turn on production mode when deploying for production.\n` +
  8607. `See more tips at https://vuejs.org/guide/deployment.html`);
  8608. }
  8609. }, 0);
  8610. }
  8611. extend(Vue, vca);
  8612. module.exports = Vue;