vue.runtime.global.js 413 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929
  1. var Vue = (function (exports) {
  2. 'use strict';
  3. /**
  4. * Make a map and return a function for checking if a key
  5. * is in that map.
  6. * IMPORTANT: all calls of this function must be prefixed with
  7. * \/\*#\_\_PURE\_\_\*\/
  8. * So that rollup can tree-shake them if necessary.
  9. */
  10. function makeMap(str, expectsLowerCase) {
  11. const map = Object.create(null);
  12. const list = str.split(',');
  13. for (let i = 0; i < list.length; i++) {
  14. map[list[i]] = true;
  15. }
  16. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  17. }
  18. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  19. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  20. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  21. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  22. /**
  23. * On the client we only need to offer special cases for boolean attributes that
  24. * have different names from their corresponding dom properties:
  25. * - itemscope -> N/A
  26. * - allowfullscreen -> allowFullscreen
  27. * - formnovalidate -> formNoValidate
  28. * - ismap -> isMap
  29. * - nomodule -> noModule
  30. * - novalidate -> noValidate
  31. * - readonly -> readOnly
  32. */
  33. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  34. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  35. /**
  36. * Boolean attributes should be included if the value is truthy or ''.
  37. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  38. */
  39. function includeBooleanAttr(value) {
  40. return !!value || value === '';
  41. }
  42. function normalizeStyle(value) {
  43. if (isArray(value)) {
  44. const res = {};
  45. for (let i = 0; i < value.length; i++) {
  46. const item = value[i];
  47. const normalized = isString(item)
  48. ? parseStringStyle(item)
  49. : normalizeStyle(item);
  50. if (normalized) {
  51. for (const key in normalized) {
  52. res[key] = normalized[key];
  53. }
  54. }
  55. }
  56. return res;
  57. }
  58. else if (isString(value)) {
  59. return value;
  60. }
  61. else if (isObject(value)) {
  62. return value;
  63. }
  64. }
  65. const listDelimiterRE = /;(?![^(]*\))/g;
  66. const propertyDelimiterRE = /:(.+)/;
  67. function parseStringStyle(cssText) {
  68. const ret = {};
  69. cssText.split(listDelimiterRE).forEach(item => {
  70. if (item) {
  71. const tmp = item.split(propertyDelimiterRE);
  72. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  73. }
  74. });
  75. return ret;
  76. }
  77. function normalizeClass(value) {
  78. let res = '';
  79. if (isString(value)) {
  80. res = value;
  81. }
  82. else if (isArray(value)) {
  83. for (let i = 0; i < value.length; i++) {
  84. const normalized = normalizeClass(value[i]);
  85. if (normalized) {
  86. res += normalized + ' ';
  87. }
  88. }
  89. }
  90. else if (isObject(value)) {
  91. for (const name in value) {
  92. if (value[name]) {
  93. res += name + ' ';
  94. }
  95. }
  96. }
  97. return res.trim();
  98. }
  99. function normalizeProps(props) {
  100. if (!props)
  101. return null;
  102. let { class: klass, style } = props;
  103. if (klass && !isString(klass)) {
  104. props.class = normalizeClass(klass);
  105. }
  106. if (style) {
  107. props.style = normalizeStyle(style);
  108. }
  109. return props;
  110. }
  111. // These tag configs are shared between compiler-dom and runtime-dom, so they
  112. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  113. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  114. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  115. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  116. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  117. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  118. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  119. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  120. 'option,output,progress,select,textarea,details,dialog,menu,' +
  121. 'summary,template,blockquote,iframe,tfoot';
  122. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  123. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  124. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  125. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  126. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  127. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  128. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  129. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  130. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  131. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  132. 'text,textPath,title,tspan,unknown,use,view';
  133. /**
  134. * Compiler only.
  135. * Do NOT use in runtime code paths unless behind `true` flag.
  136. */
  137. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  138. /**
  139. * Compiler only.
  140. * Do NOT use in runtime code paths unless behind `true` flag.
  141. */
  142. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  143. function looseCompareArrays(a, b) {
  144. if (a.length !== b.length)
  145. return false;
  146. let equal = true;
  147. for (let i = 0; equal && i < a.length; i++) {
  148. equal = looseEqual(a[i], b[i]);
  149. }
  150. return equal;
  151. }
  152. function looseEqual(a, b) {
  153. if (a === b)
  154. return true;
  155. let aValidType = isDate(a);
  156. let bValidType = isDate(b);
  157. if (aValidType || bValidType) {
  158. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  159. }
  160. aValidType = isArray(a);
  161. bValidType = isArray(b);
  162. if (aValidType || bValidType) {
  163. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  164. }
  165. aValidType = isObject(a);
  166. bValidType = isObject(b);
  167. if (aValidType || bValidType) {
  168. /* istanbul ignore if: this if will probably never be called */
  169. if (!aValidType || !bValidType) {
  170. return false;
  171. }
  172. const aKeysCount = Object.keys(a).length;
  173. const bKeysCount = Object.keys(b).length;
  174. if (aKeysCount !== bKeysCount) {
  175. return false;
  176. }
  177. for (const key in a) {
  178. const aHasKey = a.hasOwnProperty(key);
  179. const bHasKey = b.hasOwnProperty(key);
  180. if ((aHasKey && !bHasKey) ||
  181. (!aHasKey && bHasKey) ||
  182. !looseEqual(a[key], b[key])) {
  183. return false;
  184. }
  185. }
  186. }
  187. return String(a) === String(b);
  188. }
  189. function looseIndexOf(arr, val) {
  190. return arr.findIndex(item => looseEqual(item, val));
  191. }
  192. /**
  193. * For converting {{ interpolation }} values to displayed strings.
  194. * @private
  195. */
  196. const toDisplayString = (val) => {
  197. return isString(val)
  198. ? val
  199. : val == null
  200. ? ''
  201. : isArray(val) ||
  202. (isObject(val) &&
  203. (val.toString === objectToString || !isFunction(val.toString)))
  204. ? JSON.stringify(val, replacer, 2)
  205. : String(val);
  206. };
  207. const replacer = (_key, val) => {
  208. // can't use isRef here since @vue/shared has no deps
  209. if (val && val.__v_isRef) {
  210. return replacer(_key, val.value);
  211. }
  212. else if (isMap(val)) {
  213. return {
  214. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  215. entries[`${key} =>`] = val;
  216. return entries;
  217. }, {})
  218. };
  219. }
  220. else if (isSet(val)) {
  221. return {
  222. [`Set(${val.size})`]: [...val.values()]
  223. };
  224. }
  225. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  226. return String(val);
  227. }
  228. return val;
  229. };
  230. const EMPTY_OBJ = Object.freeze({})
  231. ;
  232. const EMPTY_ARR = Object.freeze([]) ;
  233. const NOOP = () => { };
  234. /**
  235. * Always return false.
  236. */
  237. const NO = () => false;
  238. const onRE = /^on[^a-z]/;
  239. const isOn = (key) => onRE.test(key);
  240. const isModelListener = (key) => key.startsWith('onUpdate:');
  241. const extend = Object.assign;
  242. const remove = (arr, el) => {
  243. const i = arr.indexOf(el);
  244. if (i > -1) {
  245. arr.splice(i, 1);
  246. }
  247. };
  248. const hasOwnProperty = Object.prototype.hasOwnProperty;
  249. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  250. const isArray = Array.isArray;
  251. const isMap = (val) => toTypeString(val) === '[object Map]';
  252. const isSet = (val) => toTypeString(val) === '[object Set]';
  253. const isDate = (val) => val instanceof Date;
  254. const isFunction = (val) => typeof val === 'function';
  255. const isString = (val) => typeof val === 'string';
  256. const isSymbol = (val) => typeof val === 'symbol';
  257. const isObject = (val) => val !== null && typeof val === 'object';
  258. const isPromise = (val) => {
  259. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  260. };
  261. const objectToString = Object.prototype.toString;
  262. const toTypeString = (value) => objectToString.call(value);
  263. const toRawType = (value) => {
  264. // extract "RawType" from strings like "[object RawType]"
  265. return toTypeString(value).slice(8, -1);
  266. };
  267. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  268. const isIntegerKey = (key) => isString(key) &&
  269. key !== 'NaN' &&
  270. key[0] !== '-' &&
  271. '' + parseInt(key, 10) === key;
  272. const isReservedProp = /*#__PURE__*/ makeMap(
  273. // the leading comma is intentional so empty string "" is also included
  274. ',key,ref,ref_for,ref_key,' +
  275. 'onVnodeBeforeMount,onVnodeMounted,' +
  276. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  277. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  278. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
  279. const cacheStringFunction = (fn) => {
  280. const cache = Object.create(null);
  281. return ((str) => {
  282. const hit = cache[str];
  283. return hit || (cache[str] = fn(str));
  284. });
  285. };
  286. const camelizeRE = /-(\w)/g;
  287. /**
  288. * @private
  289. */
  290. const camelize = cacheStringFunction((str) => {
  291. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  292. });
  293. const hyphenateRE = /\B([A-Z])/g;
  294. /**
  295. * @private
  296. */
  297. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  298. /**
  299. * @private
  300. */
  301. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  302. /**
  303. * @private
  304. */
  305. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  306. // compare whether a value has changed, accounting for NaN.
  307. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  308. const invokeArrayFns = (fns, arg) => {
  309. for (let i = 0; i < fns.length; i++) {
  310. fns[i](arg);
  311. }
  312. };
  313. const def = (obj, key, value) => {
  314. Object.defineProperty(obj, key, {
  315. configurable: true,
  316. enumerable: false,
  317. value
  318. });
  319. };
  320. const toNumber = (val) => {
  321. const n = parseFloat(val);
  322. return isNaN(n) ? val : n;
  323. };
  324. let _globalThis;
  325. const getGlobalThis = () => {
  326. return (_globalThis ||
  327. (_globalThis =
  328. typeof globalThis !== 'undefined'
  329. ? globalThis
  330. : typeof self !== 'undefined'
  331. ? self
  332. : typeof window !== 'undefined'
  333. ? window
  334. : typeof global !== 'undefined'
  335. ? global
  336. : {}));
  337. };
  338. function warn(msg, ...args) {
  339. console.warn(`[Vue warn] ${msg}`, ...args);
  340. }
  341. let activeEffectScope;
  342. class EffectScope {
  343. constructor(detached = false) {
  344. /**
  345. * @internal
  346. */
  347. this.active = true;
  348. /**
  349. * @internal
  350. */
  351. this.effects = [];
  352. /**
  353. * @internal
  354. */
  355. this.cleanups = [];
  356. if (!detached && activeEffectScope) {
  357. this.parent = activeEffectScope;
  358. this.index =
  359. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  360. }
  361. }
  362. run(fn) {
  363. if (this.active) {
  364. const currentEffectScope = activeEffectScope;
  365. try {
  366. activeEffectScope = this;
  367. return fn();
  368. }
  369. finally {
  370. activeEffectScope = currentEffectScope;
  371. }
  372. }
  373. else {
  374. warn(`cannot run an inactive effect scope.`);
  375. }
  376. }
  377. /**
  378. * This should only be called on non-detached scopes
  379. * @internal
  380. */
  381. on() {
  382. activeEffectScope = this;
  383. }
  384. /**
  385. * This should only be called on non-detached scopes
  386. * @internal
  387. */
  388. off() {
  389. activeEffectScope = this.parent;
  390. }
  391. stop(fromParent) {
  392. if (this.active) {
  393. let i, l;
  394. for (i = 0, l = this.effects.length; i < l; i++) {
  395. this.effects[i].stop();
  396. }
  397. for (i = 0, l = this.cleanups.length; i < l; i++) {
  398. this.cleanups[i]();
  399. }
  400. if (this.scopes) {
  401. for (i = 0, l = this.scopes.length; i < l; i++) {
  402. this.scopes[i].stop(true);
  403. }
  404. }
  405. // nested scope, dereference from parent to avoid memory leaks
  406. if (this.parent && !fromParent) {
  407. // optimized O(1) removal
  408. const last = this.parent.scopes.pop();
  409. if (last && last !== this) {
  410. this.parent.scopes[this.index] = last;
  411. last.index = this.index;
  412. }
  413. }
  414. this.active = false;
  415. }
  416. }
  417. }
  418. function effectScope(detached) {
  419. return new EffectScope(detached);
  420. }
  421. function recordEffectScope(effect, scope = activeEffectScope) {
  422. if (scope && scope.active) {
  423. scope.effects.push(effect);
  424. }
  425. }
  426. function getCurrentScope() {
  427. return activeEffectScope;
  428. }
  429. function onScopeDispose(fn) {
  430. if (activeEffectScope) {
  431. activeEffectScope.cleanups.push(fn);
  432. }
  433. else {
  434. warn(`onScopeDispose() is called when there is no active effect scope` +
  435. ` to be associated with.`);
  436. }
  437. }
  438. const createDep = (effects) => {
  439. const dep = new Set(effects);
  440. dep.w = 0;
  441. dep.n = 0;
  442. return dep;
  443. };
  444. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  445. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  446. const initDepMarkers = ({ deps }) => {
  447. if (deps.length) {
  448. for (let i = 0; i < deps.length; i++) {
  449. deps[i].w |= trackOpBit; // set was tracked
  450. }
  451. }
  452. };
  453. const finalizeDepMarkers = (effect) => {
  454. const { deps } = effect;
  455. if (deps.length) {
  456. let ptr = 0;
  457. for (let i = 0; i < deps.length; i++) {
  458. const dep = deps[i];
  459. if (wasTracked(dep) && !newTracked(dep)) {
  460. dep.delete(effect);
  461. }
  462. else {
  463. deps[ptr++] = dep;
  464. }
  465. // clear bits
  466. dep.w &= ~trackOpBit;
  467. dep.n &= ~trackOpBit;
  468. }
  469. deps.length = ptr;
  470. }
  471. };
  472. const targetMap = new WeakMap();
  473. // The number of effects currently being tracked recursively.
  474. let effectTrackDepth = 0;
  475. let trackOpBit = 1;
  476. /**
  477. * The bitwise track markers support at most 30 levels of recursion.
  478. * This value is chosen to enable modern JS engines to use a SMI on all platforms.
  479. * When recursion depth is greater, fall back to using a full cleanup.
  480. */
  481. const maxMarkerBits = 30;
  482. let activeEffect;
  483. const ITERATE_KEY = Symbol('iterate' );
  484. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
  485. class ReactiveEffect {
  486. constructor(fn, scheduler = null, scope) {
  487. this.fn = fn;
  488. this.scheduler = scheduler;
  489. this.active = true;
  490. this.deps = [];
  491. this.parent = undefined;
  492. recordEffectScope(this, scope);
  493. }
  494. run() {
  495. if (!this.active) {
  496. return this.fn();
  497. }
  498. let parent = activeEffect;
  499. let lastShouldTrack = shouldTrack;
  500. while (parent) {
  501. if (parent === this) {
  502. return;
  503. }
  504. parent = parent.parent;
  505. }
  506. try {
  507. this.parent = activeEffect;
  508. activeEffect = this;
  509. shouldTrack = true;
  510. trackOpBit = 1 << ++effectTrackDepth;
  511. if (effectTrackDepth <= maxMarkerBits) {
  512. initDepMarkers(this);
  513. }
  514. else {
  515. cleanupEffect(this);
  516. }
  517. return this.fn();
  518. }
  519. finally {
  520. if (effectTrackDepth <= maxMarkerBits) {
  521. finalizeDepMarkers(this);
  522. }
  523. trackOpBit = 1 << --effectTrackDepth;
  524. activeEffect = this.parent;
  525. shouldTrack = lastShouldTrack;
  526. this.parent = undefined;
  527. if (this.deferStop) {
  528. this.stop();
  529. }
  530. }
  531. }
  532. stop() {
  533. // stopped while running itself - defer the cleanup
  534. if (activeEffect === this) {
  535. this.deferStop = true;
  536. }
  537. else if (this.active) {
  538. cleanupEffect(this);
  539. if (this.onStop) {
  540. this.onStop();
  541. }
  542. this.active = false;
  543. }
  544. }
  545. }
  546. function cleanupEffect(effect) {
  547. const { deps } = effect;
  548. if (deps.length) {
  549. for (let i = 0; i < deps.length; i++) {
  550. deps[i].delete(effect);
  551. }
  552. deps.length = 0;
  553. }
  554. }
  555. function effect(fn, options) {
  556. if (fn.effect) {
  557. fn = fn.effect.fn;
  558. }
  559. const _effect = new ReactiveEffect(fn);
  560. if (options) {
  561. extend(_effect, options);
  562. if (options.scope)
  563. recordEffectScope(_effect, options.scope);
  564. }
  565. if (!options || !options.lazy) {
  566. _effect.run();
  567. }
  568. const runner = _effect.run.bind(_effect);
  569. runner.effect = _effect;
  570. return runner;
  571. }
  572. function stop(runner) {
  573. runner.effect.stop();
  574. }
  575. let shouldTrack = true;
  576. const trackStack = [];
  577. function pauseTracking() {
  578. trackStack.push(shouldTrack);
  579. shouldTrack = false;
  580. }
  581. function resetTracking() {
  582. const last = trackStack.pop();
  583. shouldTrack = last === undefined ? true : last;
  584. }
  585. function track(target, type, key) {
  586. if (shouldTrack && activeEffect) {
  587. let depsMap = targetMap.get(target);
  588. if (!depsMap) {
  589. targetMap.set(target, (depsMap = new Map()));
  590. }
  591. let dep = depsMap.get(key);
  592. if (!dep) {
  593. depsMap.set(key, (dep = createDep()));
  594. }
  595. const eventInfo = { effect: activeEffect, target, type, key }
  596. ;
  597. trackEffects(dep, eventInfo);
  598. }
  599. }
  600. function trackEffects(dep, debuggerEventExtraInfo) {
  601. let shouldTrack = false;
  602. if (effectTrackDepth <= maxMarkerBits) {
  603. if (!newTracked(dep)) {
  604. dep.n |= trackOpBit; // set newly tracked
  605. shouldTrack = !wasTracked(dep);
  606. }
  607. }
  608. else {
  609. // Full cleanup mode.
  610. shouldTrack = !dep.has(activeEffect);
  611. }
  612. if (shouldTrack) {
  613. dep.add(activeEffect);
  614. activeEffect.deps.push(dep);
  615. if (activeEffect.onTrack) {
  616. activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
  617. }
  618. }
  619. }
  620. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  621. const depsMap = targetMap.get(target);
  622. if (!depsMap) {
  623. // never been tracked
  624. return;
  625. }
  626. let deps = [];
  627. if (type === "clear" /* CLEAR */) {
  628. // collection being cleared
  629. // trigger all effects for target
  630. deps = [...depsMap.values()];
  631. }
  632. else if (key === 'length' && isArray(target)) {
  633. depsMap.forEach((dep, key) => {
  634. if (key === 'length' || key >= newValue) {
  635. deps.push(dep);
  636. }
  637. });
  638. }
  639. else {
  640. // schedule runs for SET | ADD | DELETE
  641. if (key !== void 0) {
  642. deps.push(depsMap.get(key));
  643. }
  644. // also run for iteration key on ADD | DELETE | Map.SET
  645. switch (type) {
  646. case "add" /* ADD */:
  647. if (!isArray(target)) {
  648. deps.push(depsMap.get(ITERATE_KEY));
  649. if (isMap(target)) {
  650. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  651. }
  652. }
  653. else if (isIntegerKey(key)) {
  654. // new index added to array -> length changes
  655. deps.push(depsMap.get('length'));
  656. }
  657. break;
  658. case "delete" /* DELETE */:
  659. if (!isArray(target)) {
  660. deps.push(depsMap.get(ITERATE_KEY));
  661. if (isMap(target)) {
  662. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  663. }
  664. }
  665. break;
  666. case "set" /* SET */:
  667. if (isMap(target)) {
  668. deps.push(depsMap.get(ITERATE_KEY));
  669. }
  670. break;
  671. }
  672. }
  673. const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
  674. ;
  675. if (deps.length === 1) {
  676. if (deps[0]) {
  677. {
  678. triggerEffects(deps[0], eventInfo);
  679. }
  680. }
  681. }
  682. else {
  683. const effects = [];
  684. for (const dep of deps) {
  685. if (dep) {
  686. effects.push(...dep);
  687. }
  688. }
  689. {
  690. triggerEffects(createDep(effects), eventInfo);
  691. }
  692. }
  693. }
  694. function triggerEffects(dep, debuggerEventExtraInfo) {
  695. // spread into array for stabilization
  696. for (const effect of isArray(dep) ? dep : [...dep]) {
  697. if (effect !== activeEffect || effect.allowRecurse) {
  698. if (effect.onTrigger) {
  699. effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
  700. }
  701. if (effect.scheduler) {
  702. effect.scheduler();
  703. }
  704. else {
  705. effect.run();
  706. }
  707. }
  708. }
  709. }
  710. const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
  711. const builtInSymbols = new Set(
  712. /*#__PURE__*/
  713. Object.getOwnPropertyNames(Symbol)
  714. .map(key => Symbol[key])
  715. .filter(isSymbol));
  716. const get = /*#__PURE__*/ createGetter();
  717. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  718. const readonlyGet = /*#__PURE__*/ createGetter(true);
  719. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  720. const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
  721. function createArrayInstrumentations() {
  722. const instrumentations = {};
  723. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  724. instrumentations[key] = function (...args) {
  725. const arr = toRaw(this);
  726. for (let i = 0, l = this.length; i < l; i++) {
  727. track(arr, "get" /* GET */, i + '');
  728. }
  729. // we run the method using the original args first (which may be reactive)
  730. const res = arr[key](...args);
  731. if (res === -1 || res === false) {
  732. // if that didn't work, run it again using raw values.
  733. return arr[key](...args.map(toRaw));
  734. }
  735. else {
  736. return res;
  737. }
  738. };
  739. });
  740. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  741. instrumentations[key] = function (...args) {
  742. pauseTracking();
  743. const res = toRaw(this)[key].apply(this, args);
  744. resetTracking();
  745. return res;
  746. };
  747. });
  748. return instrumentations;
  749. }
  750. function createGetter(isReadonly = false, shallow = false) {
  751. return function get(target, key, receiver) {
  752. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  753. return !isReadonly;
  754. }
  755. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  756. return isReadonly;
  757. }
  758. else if (key === "__v_isShallow" /* IS_SHALLOW */) {
  759. return shallow;
  760. }
  761. else if (key === "__v_raw" /* RAW */ &&
  762. receiver ===
  763. (isReadonly
  764. ? shallow
  765. ? shallowReadonlyMap
  766. : readonlyMap
  767. : shallow
  768. ? shallowReactiveMap
  769. : reactiveMap).get(target)) {
  770. return target;
  771. }
  772. const targetIsArray = isArray(target);
  773. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  774. return Reflect.get(arrayInstrumentations, key, receiver);
  775. }
  776. const res = Reflect.get(target, key, receiver);
  777. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  778. return res;
  779. }
  780. if (!isReadonly) {
  781. track(target, "get" /* GET */, key);
  782. }
  783. if (shallow) {
  784. return res;
  785. }
  786. if (isRef(res)) {
  787. // ref unwrapping - does not apply for Array + integer key.
  788. const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
  789. return shouldUnwrap ? res.value : res;
  790. }
  791. if (isObject(res)) {
  792. // Convert returned value into a proxy as well. we do the isObject check
  793. // here to avoid invalid value warning. Also need to lazy access readonly
  794. // and reactive here to avoid circular dependency.
  795. return isReadonly ? readonly(res) : reactive(res);
  796. }
  797. return res;
  798. };
  799. }
  800. const set = /*#__PURE__*/ createSetter();
  801. const shallowSet = /*#__PURE__*/ createSetter(true);
  802. function createSetter(shallow = false) {
  803. return function set(target, key, value, receiver) {
  804. let oldValue = target[key];
  805. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  806. return false;
  807. }
  808. if (!shallow && !isReadonly(value)) {
  809. if (!isShallow(value)) {
  810. value = toRaw(value);
  811. oldValue = toRaw(oldValue);
  812. }
  813. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  814. oldValue.value = value;
  815. return true;
  816. }
  817. }
  818. const hadKey = isArray(target) && isIntegerKey(key)
  819. ? Number(key) < target.length
  820. : hasOwn(target, key);
  821. const result = Reflect.set(target, key, value, receiver);
  822. // don't trigger if target is something up in the prototype chain of original
  823. if (target === toRaw(receiver)) {
  824. if (!hadKey) {
  825. trigger(target, "add" /* ADD */, key, value);
  826. }
  827. else if (hasChanged(value, oldValue)) {
  828. trigger(target, "set" /* SET */, key, value, oldValue);
  829. }
  830. }
  831. return result;
  832. };
  833. }
  834. function deleteProperty(target, key) {
  835. const hadKey = hasOwn(target, key);
  836. const oldValue = target[key];
  837. const result = Reflect.deleteProperty(target, key);
  838. if (result && hadKey) {
  839. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  840. }
  841. return result;
  842. }
  843. function has(target, key) {
  844. const result = Reflect.has(target, key);
  845. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  846. track(target, "has" /* HAS */, key);
  847. }
  848. return result;
  849. }
  850. function ownKeys(target) {
  851. track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
  852. return Reflect.ownKeys(target);
  853. }
  854. const mutableHandlers = {
  855. get,
  856. set,
  857. deleteProperty,
  858. has,
  859. ownKeys
  860. };
  861. const readonlyHandlers = {
  862. get: readonlyGet,
  863. set(target, key) {
  864. {
  865. warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  866. }
  867. return true;
  868. },
  869. deleteProperty(target, key) {
  870. {
  871. warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  872. }
  873. return true;
  874. }
  875. };
  876. const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
  877. get: shallowGet,
  878. set: shallowSet
  879. });
  880. // Props handlers are special in the sense that it should not unwrap top-level
  881. // refs (in order to allow refs to be explicitly passed down), but should
  882. // retain the reactivity of the normal readonly object.
  883. const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
  884. get: shallowReadonlyGet
  885. });
  886. const toShallow = (value) => value;
  887. const getProto = (v) => Reflect.getPrototypeOf(v);
  888. function get$1(target, key, isReadonly = false, isShallow = false) {
  889. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  890. // of the value
  891. target = target["__v_raw" /* RAW */];
  892. const rawTarget = toRaw(target);
  893. const rawKey = toRaw(key);
  894. if (key !== rawKey) {
  895. !isReadonly && track(rawTarget, "get" /* GET */, key);
  896. }
  897. !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
  898. const { has } = getProto(rawTarget);
  899. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  900. if (has.call(rawTarget, key)) {
  901. return wrap(target.get(key));
  902. }
  903. else if (has.call(rawTarget, rawKey)) {
  904. return wrap(target.get(rawKey));
  905. }
  906. else if (target !== rawTarget) {
  907. // #3602 readonly(reactive(Map))
  908. // ensure that the nested reactive `Map` can do tracking for itself
  909. target.get(key);
  910. }
  911. }
  912. function has$1(key, isReadonly = false) {
  913. const target = this["__v_raw" /* RAW */];
  914. const rawTarget = toRaw(target);
  915. const rawKey = toRaw(key);
  916. if (key !== rawKey) {
  917. !isReadonly && track(rawTarget, "has" /* HAS */, key);
  918. }
  919. !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
  920. return key === rawKey
  921. ? target.has(key)
  922. : target.has(key) || target.has(rawKey);
  923. }
  924. function size(target, isReadonly = false) {
  925. target = target["__v_raw" /* RAW */];
  926. !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
  927. return Reflect.get(target, 'size', target);
  928. }
  929. function add(value) {
  930. value = toRaw(value);
  931. const target = toRaw(this);
  932. const proto = getProto(target);
  933. const hadKey = proto.has.call(target, value);
  934. if (!hadKey) {
  935. target.add(value);
  936. trigger(target, "add" /* ADD */, value, value);
  937. }
  938. return this;
  939. }
  940. function set$1(key, value) {
  941. value = toRaw(value);
  942. const target = toRaw(this);
  943. const { has, get } = getProto(target);
  944. let hadKey = has.call(target, key);
  945. if (!hadKey) {
  946. key = toRaw(key);
  947. hadKey = has.call(target, key);
  948. }
  949. else {
  950. checkIdentityKeys(target, has, key);
  951. }
  952. const oldValue = get.call(target, key);
  953. target.set(key, value);
  954. if (!hadKey) {
  955. trigger(target, "add" /* ADD */, key, value);
  956. }
  957. else if (hasChanged(value, oldValue)) {
  958. trigger(target, "set" /* SET */, key, value, oldValue);
  959. }
  960. return this;
  961. }
  962. function deleteEntry(key) {
  963. const target = toRaw(this);
  964. const { has, get } = getProto(target);
  965. let hadKey = has.call(target, key);
  966. if (!hadKey) {
  967. key = toRaw(key);
  968. hadKey = has.call(target, key);
  969. }
  970. else {
  971. checkIdentityKeys(target, has, key);
  972. }
  973. const oldValue = get ? get.call(target, key) : undefined;
  974. // forward the operation before queueing reactions
  975. const result = target.delete(key);
  976. if (hadKey) {
  977. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  978. }
  979. return result;
  980. }
  981. function clear() {
  982. const target = toRaw(this);
  983. const hadItems = target.size !== 0;
  984. const oldTarget = isMap(target)
  985. ? new Map(target)
  986. : new Set(target)
  987. ;
  988. // forward the operation before queueing reactions
  989. const result = target.clear();
  990. if (hadItems) {
  991. trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
  992. }
  993. return result;
  994. }
  995. function createForEach(isReadonly, isShallow) {
  996. return function forEach(callback, thisArg) {
  997. const observed = this;
  998. const target = observed["__v_raw" /* RAW */];
  999. const rawTarget = toRaw(target);
  1000. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1001. !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
  1002. return target.forEach((value, key) => {
  1003. // important: make sure the callback is
  1004. // 1. invoked with the reactive map as `this` and 3rd arg
  1005. // 2. the value received should be a corresponding reactive/readonly.
  1006. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1007. });
  1008. };
  1009. }
  1010. function createIterableMethod(method, isReadonly, isShallow) {
  1011. return function (...args) {
  1012. const target = this["__v_raw" /* RAW */];
  1013. const rawTarget = toRaw(target);
  1014. const targetIsMap = isMap(rawTarget);
  1015. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  1016. const isKeyOnly = method === 'keys' && targetIsMap;
  1017. const innerIterator = target[method](...args);
  1018. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1019. !isReadonly &&
  1020. track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  1021. // return a wrapped iterator which returns observed versions of the
  1022. // values emitted from the real iterator
  1023. return {
  1024. // iterator protocol
  1025. next() {
  1026. const { value, done } = innerIterator.next();
  1027. return done
  1028. ? { value, done }
  1029. : {
  1030. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1031. done
  1032. };
  1033. },
  1034. // iterable protocol
  1035. [Symbol.iterator]() {
  1036. return this;
  1037. }
  1038. };
  1039. };
  1040. }
  1041. function createReadonlyMethod(type) {
  1042. return function (...args) {
  1043. {
  1044. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1045. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1046. }
  1047. return type === "delete" /* DELETE */ ? false : this;
  1048. };
  1049. }
  1050. function createInstrumentations() {
  1051. const mutableInstrumentations = {
  1052. get(key) {
  1053. return get$1(this, key);
  1054. },
  1055. get size() {
  1056. return size(this);
  1057. },
  1058. has: has$1,
  1059. add,
  1060. set: set$1,
  1061. delete: deleteEntry,
  1062. clear,
  1063. forEach: createForEach(false, false)
  1064. };
  1065. const shallowInstrumentations = {
  1066. get(key) {
  1067. return get$1(this, key, false, true);
  1068. },
  1069. get size() {
  1070. return size(this);
  1071. },
  1072. has: has$1,
  1073. add,
  1074. set: set$1,
  1075. delete: deleteEntry,
  1076. clear,
  1077. forEach: createForEach(false, true)
  1078. };
  1079. const readonlyInstrumentations = {
  1080. get(key) {
  1081. return get$1(this, key, true);
  1082. },
  1083. get size() {
  1084. return size(this, true);
  1085. },
  1086. has(key) {
  1087. return has$1.call(this, key, true);
  1088. },
  1089. add: createReadonlyMethod("add" /* ADD */),
  1090. set: createReadonlyMethod("set" /* SET */),
  1091. delete: createReadonlyMethod("delete" /* DELETE */),
  1092. clear: createReadonlyMethod("clear" /* CLEAR */),
  1093. forEach: createForEach(true, false)
  1094. };
  1095. const shallowReadonlyInstrumentations = {
  1096. get(key) {
  1097. return get$1(this, key, true, true);
  1098. },
  1099. get size() {
  1100. return size(this, true);
  1101. },
  1102. has(key) {
  1103. return has$1.call(this, key, true);
  1104. },
  1105. add: createReadonlyMethod("add" /* ADD */),
  1106. set: createReadonlyMethod("set" /* SET */),
  1107. delete: createReadonlyMethod("delete" /* DELETE */),
  1108. clear: createReadonlyMethod("clear" /* CLEAR */),
  1109. forEach: createForEach(true, true)
  1110. };
  1111. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  1112. iteratorMethods.forEach(method => {
  1113. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  1114. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  1115. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  1116. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  1117. });
  1118. return [
  1119. mutableInstrumentations,
  1120. readonlyInstrumentations,
  1121. shallowInstrumentations,
  1122. shallowReadonlyInstrumentations
  1123. ];
  1124. }
  1125. const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
  1126. function createInstrumentationGetter(isReadonly, shallow) {
  1127. const instrumentations = shallow
  1128. ? isReadonly
  1129. ? shallowReadonlyInstrumentations
  1130. : shallowInstrumentations
  1131. : isReadonly
  1132. ? readonlyInstrumentations
  1133. : mutableInstrumentations;
  1134. return (target, key, receiver) => {
  1135. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  1136. return !isReadonly;
  1137. }
  1138. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  1139. return isReadonly;
  1140. }
  1141. else if (key === "__v_raw" /* RAW */) {
  1142. return target;
  1143. }
  1144. return Reflect.get(hasOwn(instrumentations, key) && key in target
  1145. ? instrumentations
  1146. : target, key, receiver);
  1147. };
  1148. }
  1149. const mutableCollectionHandlers = {
  1150. get: /*#__PURE__*/ createInstrumentationGetter(false, false)
  1151. };
  1152. const shallowCollectionHandlers = {
  1153. get: /*#__PURE__*/ createInstrumentationGetter(false, true)
  1154. };
  1155. const readonlyCollectionHandlers = {
  1156. get: /*#__PURE__*/ createInstrumentationGetter(true, false)
  1157. };
  1158. const shallowReadonlyCollectionHandlers = {
  1159. get: /*#__PURE__*/ createInstrumentationGetter(true, true)
  1160. };
  1161. function checkIdentityKeys(target, has, key) {
  1162. const rawKey = toRaw(key);
  1163. if (rawKey !== key && has.call(target, rawKey)) {
  1164. const type = toRawType(target);
  1165. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  1166. `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
  1167. `which can lead to inconsistencies. ` +
  1168. `Avoid differentiating between the raw and reactive versions ` +
  1169. `of an object and only use the reactive version if possible.`);
  1170. }
  1171. }
  1172. const reactiveMap = new WeakMap();
  1173. const shallowReactiveMap = new WeakMap();
  1174. const readonlyMap = new WeakMap();
  1175. const shallowReadonlyMap = new WeakMap();
  1176. function targetTypeMap(rawType) {
  1177. switch (rawType) {
  1178. case 'Object':
  1179. case 'Array':
  1180. return 1 /* COMMON */;
  1181. case 'Map':
  1182. case 'Set':
  1183. case 'WeakMap':
  1184. case 'WeakSet':
  1185. return 2 /* COLLECTION */;
  1186. default:
  1187. return 0 /* INVALID */;
  1188. }
  1189. }
  1190. function getTargetType(value) {
  1191. return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
  1192. ? 0 /* INVALID */
  1193. : targetTypeMap(toRawType(value));
  1194. }
  1195. function reactive(target) {
  1196. // if trying to observe a readonly proxy, return the readonly version.
  1197. if (isReadonly(target)) {
  1198. return target;
  1199. }
  1200. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  1201. }
  1202. /**
  1203. * Return a shallowly-reactive copy of the original object, where only the root
  1204. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1205. * root level).
  1206. */
  1207. function shallowReactive(target) {
  1208. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
  1209. }
  1210. /**
  1211. * Creates a readonly copy of the original object. Note the returned copy is not
  1212. * made reactive, but `readonly` can be called on an already reactive object.
  1213. */
  1214. function readonly(target) {
  1215. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  1216. }
  1217. /**
  1218. * Returns a reactive-copy of the original object, where only the root level
  1219. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1220. * returned properties.
  1221. * This is used for creating the props proxy object for stateful components.
  1222. */
  1223. function shallowReadonly(target) {
  1224. return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  1225. }
  1226. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  1227. if (!isObject(target)) {
  1228. {
  1229. console.warn(`value cannot be made reactive: ${String(target)}`);
  1230. }
  1231. return target;
  1232. }
  1233. // target is already a Proxy, return it.
  1234. // exception: calling readonly() on a reactive object
  1235. if (target["__v_raw" /* RAW */] &&
  1236. !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
  1237. return target;
  1238. }
  1239. // target already has corresponding Proxy
  1240. const existingProxy = proxyMap.get(target);
  1241. if (existingProxy) {
  1242. return existingProxy;
  1243. }
  1244. // only a whitelist of value types can be observed.
  1245. const targetType = getTargetType(target);
  1246. if (targetType === 0 /* INVALID */) {
  1247. return target;
  1248. }
  1249. const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
  1250. proxyMap.set(target, proxy);
  1251. return proxy;
  1252. }
  1253. function isReactive(value) {
  1254. if (isReadonly(value)) {
  1255. return isReactive(value["__v_raw" /* RAW */]);
  1256. }
  1257. return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
  1258. }
  1259. function isReadonly(value) {
  1260. return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
  1261. }
  1262. function isShallow(value) {
  1263. return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
  1264. }
  1265. function isProxy(value) {
  1266. return isReactive(value) || isReadonly(value);
  1267. }
  1268. function toRaw(observed) {
  1269. const raw = observed && observed["__v_raw" /* RAW */];
  1270. return raw ? toRaw(raw) : observed;
  1271. }
  1272. function markRaw(value) {
  1273. def(value, "__v_skip" /* SKIP */, true);
  1274. return value;
  1275. }
  1276. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1277. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1278. function trackRefValue(ref) {
  1279. if (shouldTrack && activeEffect) {
  1280. ref = toRaw(ref);
  1281. {
  1282. trackEffects(ref.dep || (ref.dep = createDep()), {
  1283. target: ref,
  1284. type: "get" /* GET */,
  1285. key: 'value'
  1286. });
  1287. }
  1288. }
  1289. }
  1290. function triggerRefValue(ref, newVal) {
  1291. ref = toRaw(ref);
  1292. if (ref.dep) {
  1293. {
  1294. triggerEffects(ref.dep, {
  1295. target: ref,
  1296. type: "set" /* SET */,
  1297. key: 'value',
  1298. newValue: newVal
  1299. });
  1300. }
  1301. }
  1302. }
  1303. function isRef(r) {
  1304. return !!(r && r.__v_isRef === true);
  1305. }
  1306. function ref(value) {
  1307. return createRef(value, false);
  1308. }
  1309. function shallowRef(value) {
  1310. return createRef(value, true);
  1311. }
  1312. function createRef(rawValue, shallow) {
  1313. if (isRef(rawValue)) {
  1314. return rawValue;
  1315. }
  1316. return new RefImpl(rawValue, shallow);
  1317. }
  1318. class RefImpl {
  1319. constructor(value, __v_isShallow) {
  1320. this.__v_isShallow = __v_isShallow;
  1321. this.dep = undefined;
  1322. this.__v_isRef = true;
  1323. this._rawValue = __v_isShallow ? value : toRaw(value);
  1324. this._value = __v_isShallow ? value : toReactive(value);
  1325. }
  1326. get value() {
  1327. trackRefValue(this);
  1328. return this._value;
  1329. }
  1330. set value(newVal) {
  1331. newVal = this.__v_isShallow ? newVal : toRaw(newVal);
  1332. if (hasChanged(newVal, this._rawValue)) {
  1333. this._rawValue = newVal;
  1334. this._value = this.__v_isShallow ? newVal : toReactive(newVal);
  1335. triggerRefValue(this, newVal);
  1336. }
  1337. }
  1338. }
  1339. function triggerRef(ref) {
  1340. triggerRefValue(ref, ref.value );
  1341. }
  1342. function unref(ref) {
  1343. return isRef(ref) ? ref.value : ref;
  1344. }
  1345. const shallowUnwrapHandlers = {
  1346. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1347. set: (target, key, value, receiver) => {
  1348. const oldValue = target[key];
  1349. if (isRef(oldValue) && !isRef(value)) {
  1350. oldValue.value = value;
  1351. return true;
  1352. }
  1353. else {
  1354. return Reflect.set(target, key, value, receiver);
  1355. }
  1356. }
  1357. };
  1358. function proxyRefs(objectWithRefs) {
  1359. return isReactive(objectWithRefs)
  1360. ? objectWithRefs
  1361. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1362. }
  1363. class CustomRefImpl {
  1364. constructor(factory) {
  1365. this.dep = undefined;
  1366. this.__v_isRef = true;
  1367. const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
  1368. this._get = get;
  1369. this._set = set;
  1370. }
  1371. get value() {
  1372. return this._get();
  1373. }
  1374. set value(newVal) {
  1375. this._set(newVal);
  1376. }
  1377. }
  1378. function customRef(factory) {
  1379. return new CustomRefImpl(factory);
  1380. }
  1381. function toRefs(object) {
  1382. if (!isProxy(object)) {
  1383. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1384. }
  1385. const ret = isArray(object) ? new Array(object.length) : {};
  1386. for (const key in object) {
  1387. ret[key] = toRef(object, key);
  1388. }
  1389. return ret;
  1390. }
  1391. class ObjectRefImpl {
  1392. constructor(_object, _key, _defaultValue) {
  1393. this._object = _object;
  1394. this._key = _key;
  1395. this._defaultValue = _defaultValue;
  1396. this.__v_isRef = true;
  1397. }
  1398. get value() {
  1399. const val = this._object[this._key];
  1400. return val === undefined ? this._defaultValue : val;
  1401. }
  1402. set value(newVal) {
  1403. this._object[this._key] = newVal;
  1404. }
  1405. }
  1406. function toRef(object, key, defaultValue) {
  1407. const val = object[key];
  1408. return isRef(val)
  1409. ? val
  1410. : new ObjectRefImpl(object, key, defaultValue);
  1411. }
  1412. class ComputedRefImpl {
  1413. constructor(getter, _setter, isReadonly, isSSR) {
  1414. this._setter = _setter;
  1415. this.dep = undefined;
  1416. this.__v_isRef = true;
  1417. this._dirty = true;
  1418. this.effect = new ReactiveEffect(getter, () => {
  1419. if (!this._dirty) {
  1420. this._dirty = true;
  1421. triggerRefValue(this);
  1422. }
  1423. });
  1424. this.effect.computed = this;
  1425. this.effect.active = this._cacheable = !isSSR;
  1426. this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
  1427. }
  1428. get value() {
  1429. // the computed ref may get wrapped by other proxies e.g. readonly() #3376
  1430. const self = toRaw(this);
  1431. trackRefValue(self);
  1432. if (self._dirty || !self._cacheable) {
  1433. self._dirty = false;
  1434. self._value = self.effect.run();
  1435. }
  1436. return self._value;
  1437. }
  1438. set value(newValue) {
  1439. this._setter(newValue);
  1440. }
  1441. }
  1442. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1443. let getter;
  1444. let setter;
  1445. const onlyGetter = isFunction(getterOrOptions);
  1446. if (onlyGetter) {
  1447. getter = getterOrOptions;
  1448. setter = () => {
  1449. console.warn('Write operation failed: computed value is readonly');
  1450. }
  1451. ;
  1452. }
  1453. else {
  1454. getter = getterOrOptions.get;
  1455. setter = getterOrOptions.set;
  1456. }
  1457. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1458. if (debugOptions && !isSSR) {
  1459. cRef.effect.onTrack = debugOptions.onTrack;
  1460. cRef.effect.onTrigger = debugOptions.onTrigger;
  1461. }
  1462. return cRef;
  1463. }
  1464. const stack = [];
  1465. function pushWarningContext(vnode) {
  1466. stack.push(vnode);
  1467. }
  1468. function popWarningContext() {
  1469. stack.pop();
  1470. }
  1471. function warn$1(msg, ...args) {
  1472. // avoid props formatting or warn handler tracking deps that might be mutated
  1473. // during patch, leading to infinite recursion.
  1474. pauseTracking();
  1475. const instance = stack.length ? stack[stack.length - 1].component : null;
  1476. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1477. const trace = getComponentTrace();
  1478. if (appWarnHandler) {
  1479. callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
  1480. msg + args.join(''),
  1481. instance && instance.proxy,
  1482. trace
  1483. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  1484. .join('\n'),
  1485. trace
  1486. ]);
  1487. }
  1488. else {
  1489. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1490. /* istanbul ignore if */
  1491. if (trace.length &&
  1492. // avoid spamming console during tests
  1493. !false) {
  1494. warnArgs.push(`\n`, ...formatTrace(trace));
  1495. }
  1496. console.warn(...warnArgs);
  1497. }
  1498. resetTracking();
  1499. }
  1500. function getComponentTrace() {
  1501. let currentVNode = stack[stack.length - 1];
  1502. if (!currentVNode) {
  1503. return [];
  1504. }
  1505. // we can't just use the stack because it will be incomplete during updates
  1506. // that did not start from the root. Re-construct the parent chain using
  1507. // instance parent pointers.
  1508. const normalizedStack = [];
  1509. while (currentVNode) {
  1510. const last = normalizedStack[0];
  1511. if (last && last.vnode === currentVNode) {
  1512. last.recurseCount++;
  1513. }
  1514. else {
  1515. normalizedStack.push({
  1516. vnode: currentVNode,
  1517. recurseCount: 0
  1518. });
  1519. }
  1520. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1521. currentVNode = parentInstance && parentInstance.vnode;
  1522. }
  1523. return normalizedStack;
  1524. }
  1525. /* istanbul ignore next */
  1526. function formatTrace(trace) {
  1527. const logs = [];
  1528. trace.forEach((entry, i) => {
  1529. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  1530. });
  1531. return logs;
  1532. }
  1533. function formatTraceEntry({ vnode, recurseCount }) {
  1534. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1535. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1536. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  1537. const close = `>` + postfix;
  1538. return vnode.props
  1539. ? [open, ...formatProps(vnode.props), close]
  1540. : [open + close];
  1541. }
  1542. /* istanbul ignore next */
  1543. function formatProps(props) {
  1544. const res = [];
  1545. const keys = Object.keys(props);
  1546. keys.slice(0, 3).forEach(key => {
  1547. res.push(...formatProp(key, props[key]));
  1548. });
  1549. if (keys.length > 3) {
  1550. res.push(` ...`);
  1551. }
  1552. return res;
  1553. }
  1554. /* istanbul ignore next */
  1555. function formatProp(key, value, raw) {
  1556. if (isString(value)) {
  1557. value = JSON.stringify(value);
  1558. return raw ? value : [`${key}=${value}`];
  1559. }
  1560. else if (typeof value === 'number' ||
  1561. typeof value === 'boolean' ||
  1562. value == null) {
  1563. return raw ? value : [`${key}=${value}`];
  1564. }
  1565. else if (isRef(value)) {
  1566. value = formatProp(key, toRaw(value.value), true);
  1567. return raw ? value : [`${key}=Ref<`, value, `>`];
  1568. }
  1569. else if (isFunction(value)) {
  1570. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1571. }
  1572. else {
  1573. value = toRaw(value);
  1574. return raw ? value : [`${key}=`, value];
  1575. }
  1576. }
  1577. const ErrorTypeStrings = {
  1578. ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
  1579. ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
  1580. ["c" /* CREATED */]: 'created hook',
  1581. ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
  1582. ["m" /* MOUNTED */]: 'mounted hook',
  1583. ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
  1584. ["u" /* UPDATED */]: 'updated',
  1585. ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  1586. ["um" /* UNMOUNTED */]: 'unmounted hook',
  1587. ["a" /* ACTIVATED */]: 'activated hook',
  1588. ["da" /* DEACTIVATED */]: 'deactivated hook',
  1589. ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
  1590. ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
  1591. ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
  1592. [0 /* SETUP_FUNCTION */]: 'setup function',
  1593. [1 /* RENDER_FUNCTION */]: 'render function',
  1594. [2 /* WATCH_GETTER */]: 'watcher getter',
  1595. [3 /* WATCH_CALLBACK */]: 'watcher callback',
  1596. [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
  1597. [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
  1598. [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
  1599. [7 /* VNODE_HOOK */]: 'vnode hook',
  1600. [8 /* DIRECTIVE_HOOK */]: 'directive hook',
  1601. [9 /* TRANSITION_HOOK */]: 'transition hook',
  1602. [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
  1603. [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
  1604. [12 /* FUNCTION_REF */]: 'ref function',
  1605. [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
  1606. [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  1607. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
  1608. };
  1609. function callWithErrorHandling(fn, instance, type, args) {
  1610. let res;
  1611. try {
  1612. res = args ? fn(...args) : fn();
  1613. }
  1614. catch (err) {
  1615. handleError(err, instance, type);
  1616. }
  1617. return res;
  1618. }
  1619. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1620. if (isFunction(fn)) {
  1621. const res = callWithErrorHandling(fn, instance, type, args);
  1622. if (res && isPromise(res)) {
  1623. res.catch(err => {
  1624. handleError(err, instance, type);
  1625. });
  1626. }
  1627. return res;
  1628. }
  1629. const values = [];
  1630. for (let i = 0; i < fn.length; i++) {
  1631. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1632. }
  1633. return values;
  1634. }
  1635. function handleError(err, instance, type, throwInDev = true) {
  1636. const contextVNode = instance ? instance.vnode : null;
  1637. if (instance) {
  1638. let cur = instance.parent;
  1639. // the exposed instance is the render proxy to keep it consistent with 2.x
  1640. const exposedInstance = instance.proxy;
  1641. // in production the hook receives only the error code
  1642. const errorInfo = ErrorTypeStrings[type] ;
  1643. while (cur) {
  1644. const errorCapturedHooks = cur.ec;
  1645. if (errorCapturedHooks) {
  1646. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1647. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1648. return;
  1649. }
  1650. }
  1651. }
  1652. cur = cur.parent;
  1653. }
  1654. // app-level handling
  1655. const appErrorHandler = instance.appContext.config.errorHandler;
  1656. if (appErrorHandler) {
  1657. callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  1658. return;
  1659. }
  1660. }
  1661. logError(err, type, contextVNode, throwInDev);
  1662. }
  1663. function logError(err, type, contextVNode, throwInDev = true) {
  1664. {
  1665. const info = ErrorTypeStrings[type];
  1666. if (contextVNode) {
  1667. pushWarningContext(contextVNode);
  1668. }
  1669. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1670. if (contextVNode) {
  1671. popWarningContext();
  1672. }
  1673. // crash in dev by default so it's more noticeable
  1674. if (throwInDev) {
  1675. throw err;
  1676. }
  1677. else {
  1678. console.error(err);
  1679. }
  1680. }
  1681. }
  1682. let isFlushing = false;
  1683. let isFlushPending = false;
  1684. const queue = [];
  1685. let flushIndex = 0;
  1686. const pendingPreFlushCbs = [];
  1687. let activePreFlushCbs = null;
  1688. let preFlushIndex = 0;
  1689. const pendingPostFlushCbs = [];
  1690. let activePostFlushCbs = null;
  1691. let postFlushIndex = 0;
  1692. const resolvedPromise = /*#__PURE__*/ Promise.resolve();
  1693. let currentFlushPromise = null;
  1694. let currentPreFlushParentJob = null;
  1695. const RECURSION_LIMIT = 100;
  1696. function nextTick(fn) {
  1697. const p = currentFlushPromise || resolvedPromise;
  1698. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1699. }
  1700. // #2768
  1701. // Use binary-search to find a suitable position in the queue,
  1702. // so that the queue maintains the increasing order of job's id,
  1703. // which can prevent the job from being skipped and also can avoid repeated patching.
  1704. function findInsertionIndex(id) {
  1705. // the start index should be `flushIndex + 1`
  1706. let start = flushIndex + 1;
  1707. let end = queue.length;
  1708. while (start < end) {
  1709. const middle = (start + end) >>> 1;
  1710. const middleJobId = getId(queue[middle]);
  1711. middleJobId < id ? (start = middle + 1) : (end = middle);
  1712. }
  1713. return start;
  1714. }
  1715. function queueJob(job) {
  1716. // the dedupe search uses the startIndex argument of Array.includes()
  1717. // by default the search index includes the current job that is being run
  1718. // so it cannot recursively trigger itself again.
  1719. // if the job is a watch() callback, the search will start with a +1 index to
  1720. // allow it recursively trigger itself - it is the user's responsibility to
  1721. // ensure it doesn't end up in an infinite loop.
  1722. if ((!queue.length ||
  1723. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
  1724. job !== currentPreFlushParentJob) {
  1725. if (job.id == null) {
  1726. queue.push(job);
  1727. }
  1728. else {
  1729. queue.splice(findInsertionIndex(job.id), 0, job);
  1730. }
  1731. queueFlush();
  1732. }
  1733. }
  1734. function queueFlush() {
  1735. if (!isFlushing && !isFlushPending) {
  1736. isFlushPending = true;
  1737. currentFlushPromise = resolvedPromise.then(flushJobs);
  1738. }
  1739. }
  1740. function invalidateJob(job) {
  1741. const i = queue.indexOf(job);
  1742. if (i > flushIndex) {
  1743. queue.splice(i, 1);
  1744. }
  1745. }
  1746. function queueCb(cb, activeQueue, pendingQueue, index) {
  1747. if (!isArray(cb)) {
  1748. if (!activeQueue ||
  1749. !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
  1750. pendingQueue.push(cb);
  1751. }
  1752. }
  1753. else {
  1754. // if cb is an array, it is a component lifecycle hook which can only be
  1755. // triggered by a job, which is already deduped in the main queue, so
  1756. // we can skip duplicate check here to improve perf
  1757. pendingQueue.push(...cb);
  1758. }
  1759. queueFlush();
  1760. }
  1761. function queuePreFlushCb(cb) {
  1762. queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  1763. }
  1764. function queuePostFlushCb(cb) {
  1765. queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  1766. }
  1767. function flushPreFlushCbs(seen, parentJob = null) {
  1768. if (pendingPreFlushCbs.length) {
  1769. currentPreFlushParentJob = parentJob;
  1770. activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
  1771. pendingPreFlushCbs.length = 0;
  1772. {
  1773. seen = seen || new Map();
  1774. }
  1775. for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
  1776. if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
  1777. continue;
  1778. }
  1779. activePreFlushCbs[preFlushIndex]();
  1780. }
  1781. activePreFlushCbs = null;
  1782. preFlushIndex = 0;
  1783. currentPreFlushParentJob = null;
  1784. // recursively flush until it drains
  1785. flushPreFlushCbs(seen, parentJob);
  1786. }
  1787. }
  1788. function flushPostFlushCbs(seen) {
  1789. if (pendingPostFlushCbs.length) {
  1790. const deduped = [...new Set(pendingPostFlushCbs)];
  1791. pendingPostFlushCbs.length = 0;
  1792. // #1947 already has active queue, nested flushPostFlushCbs call
  1793. if (activePostFlushCbs) {
  1794. activePostFlushCbs.push(...deduped);
  1795. return;
  1796. }
  1797. activePostFlushCbs = deduped;
  1798. {
  1799. seen = seen || new Map();
  1800. }
  1801. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1802. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1803. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1804. continue;
  1805. }
  1806. activePostFlushCbs[postFlushIndex]();
  1807. }
  1808. activePostFlushCbs = null;
  1809. postFlushIndex = 0;
  1810. }
  1811. }
  1812. const getId = (job) => job.id == null ? Infinity : job.id;
  1813. function flushJobs(seen) {
  1814. isFlushPending = false;
  1815. isFlushing = true;
  1816. {
  1817. seen = seen || new Map();
  1818. }
  1819. flushPreFlushCbs(seen);
  1820. // Sort queue before flush.
  1821. // This ensures that:
  1822. // 1. Components are updated from parent to child. (because parent is always
  1823. // created before the child so its render effect will have smaller
  1824. // priority number)
  1825. // 2. If a component is unmounted during a parent component's update,
  1826. // its update can be skipped.
  1827. queue.sort((a, b) => getId(a) - getId(b));
  1828. // conditional usage of checkRecursiveUpdate must be determined out of
  1829. // try ... catch block since Rollup by default de-optimizes treeshaking
  1830. // inside try-catch. This can leave all warning code unshaked. Although
  1831. // they would get eventually shaken by a minifier like terser, some minifiers
  1832. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  1833. const check = (job) => checkRecursiveUpdates(seen, job)
  1834. ;
  1835. try {
  1836. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1837. const job = queue[flushIndex];
  1838. if (job && job.active !== false) {
  1839. if (true && check(job)) {
  1840. continue;
  1841. }
  1842. // console.log(`running:`, job.id)
  1843. callWithErrorHandling(job, null, 14 /* SCHEDULER */);
  1844. }
  1845. }
  1846. }
  1847. finally {
  1848. flushIndex = 0;
  1849. queue.length = 0;
  1850. flushPostFlushCbs(seen);
  1851. isFlushing = false;
  1852. currentFlushPromise = null;
  1853. // some postFlushCb queued jobs!
  1854. // keep flushing until it drains.
  1855. if (queue.length ||
  1856. pendingPreFlushCbs.length ||
  1857. pendingPostFlushCbs.length) {
  1858. flushJobs(seen);
  1859. }
  1860. }
  1861. }
  1862. function checkRecursiveUpdates(seen, fn) {
  1863. if (!seen.has(fn)) {
  1864. seen.set(fn, 1);
  1865. }
  1866. else {
  1867. const count = seen.get(fn);
  1868. if (count > RECURSION_LIMIT) {
  1869. const instance = fn.ownerInstance;
  1870. const componentName = instance && getComponentName(instance.type);
  1871. warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
  1872. `This means you have a reactive effect that is mutating its own ` +
  1873. `dependencies and thus recursively triggering itself. Possible sources ` +
  1874. `include component template, render function, updated hook or ` +
  1875. `watcher source function.`);
  1876. return true;
  1877. }
  1878. else {
  1879. seen.set(fn, count + 1);
  1880. }
  1881. }
  1882. }
  1883. /* eslint-disable no-restricted-globals */
  1884. let isHmrUpdating = false;
  1885. const hmrDirtyComponents = new Set();
  1886. // Expose the HMR runtime on the global object
  1887. // This makes it entirely tree-shakable without polluting the exports and makes
  1888. // it easier to be used in toolings like vue-loader
  1889. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1890. // to be set so that its instances can be registered / removed.
  1891. {
  1892. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1893. createRecord: tryWrap(createRecord),
  1894. rerender: tryWrap(rerender),
  1895. reload: tryWrap(reload)
  1896. };
  1897. }
  1898. const map = new Map();
  1899. function registerHMR(instance) {
  1900. const id = instance.type.__hmrId;
  1901. let record = map.get(id);
  1902. if (!record) {
  1903. createRecord(id, instance.type);
  1904. record = map.get(id);
  1905. }
  1906. record.instances.add(instance);
  1907. }
  1908. function unregisterHMR(instance) {
  1909. map.get(instance.type.__hmrId).instances.delete(instance);
  1910. }
  1911. function createRecord(id, initialDef) {
  1912. if (map.has(id)) {
  1913. return false;
  1914. }
  1915. map.set(id, {
  1916. initialDef: normalizeClassComponent(initialDef),
  1917. instances: new Set()
  1918. });
  1919. return true;
  1920. }
  1921. function normalizeClassComponent(component) {
  1922. return isClassComponent(component) ? component.__vccOpts : component;
  1923. }
  1924. function rerender(id, newRender) {
  1925. const record = map.get(id);
  1926. if (!record) {
  1927. return;
  1928. }
  1929. // update initial record (for not-yet-rendered component)
  1930. record.initialDef.render = newRender;
  1931. [...record.instances].forEach(instance => {
  1932. if (newRender) {
  1933. instance.render = newRender;
  1934. normalizeClassComponent(instance.type).render = newRender;
  1935. }
  1936. instance.renderCache = [];
  1937. // this flag forces child components with slot content to update
  1938. isHmrUpdating = true;
  1939. instance.update();
  1940. isHmrUpdating = false;
  1941. });
  1942. }
  1943. function reload(id, newComp) {
  1944. const record = map.get(id);
  1945. if (!record)
  1946. return;
  1947. newComp = normalizeClassComponent(newComp);
  1948. // update initial def (for not-yet-rendered components)
  1949. updateComponentDef(record.initialDef, newComp);
  1950. // create a snapshot which avoids the set being mutated during updates
  1951. const instances = [...record.instances];
  1952. for (const instance of instances) {
  1953. const oldComp = normalizeClassComponent(instance.type);
  1954. if (!hmrDirtyComponents.has(oldComp)) {
  1955. // 1. Update existing comp definition to match new one
  1956. if (oldComp !== record.initialDef) {
  1957. updateComponentDef(oldComp, newComp);
  1958. }
  1959. // 2. mark definition dirty. This forces the renderer to replace the
  1960. // component on patch.
  1961. hmrDirtyComponents.add(oldComp);
  1962. }
  1963. // 3. invalidate options resolution cache
  1964. instance.appContext.optionsCache.delete(instance.type);
  1965. // 4. actually update
  1966. if (instance.ceReload) {
  1967. // custom element
  1968. hmrDirtyComponents.add(oldComp);
  1969. instance.ceReload(newComp.styles);
  1970. hmrDirtyComponents.delete(oldComp);
  1971. }
  1972. else if (instance.parent) {
  1973. // 4. Force the parent instance to re-render. This will cause all updated
  1974. // components to be unmounted and re-mounted. Queue the update so that we
  1975. // don't end up forcing the same parent to re-render multiple times.
  1976. queueJob(instance.parent.update);
  1977. // instance is the inner component of an async custom element
  1978. // invoke to reset styles
  1979. if (instance.parent.type.__asyncLoader &&
  1980. instance.parent.ceReload) {
  1981. instance.parent.ceReload(newComp.styles);
  1982. }
  1983. }
  1984. else if (instance.appContext.reload) {
  1985. // root instance mounted via createApp() has a reload method
  1986. instance.appContext.reload();
  1987. }
  1988. else if (typeof window !== 'undefined') {
  1989. // root instance inside tree created via raw render(). Force reload.
  1990. window.location.reload();
  1991. }
  1992. else {
  1993. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  1994. }
  1995. }
  1996. // 5. make sure to cleanup dirty hmr components after update
  1997. queuePostFlushCb(() => {
  1998. for (const instance of instances) {
  1999. hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
  2000. }
  2001. });
  2002. }
  2003. function updateComponentDef(oldComp, newComp) {
  2004. extend(oldComp, newComp);
  2005. for (const key in oldComp) {
  2006. if (key !== '__file' && !(key in newComp)) {
  2007. delete oldComp[key];
  2008. }
  2009. }
  2010. }
  2011. function tryWrap(fn) {
  2012. return (id, arg) => {
  2013. try {
  2014. return fn(id, arg);
  2015. }
  2016. catch (e) {
  2017. console.error(e);
  2018. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  2019. `Full reload required.`);
  2020. }
  2021. };
  2022. }
  2023. let buffer = [];
  2024. let devtoolsNotInstalled = false;
  2025. function emit(event, ...args) {
  2026. if (exports.devtools) {
  2027. exports.devtools.emit(event, ...args);
  2028. }
  2029. else if (!devtoolsNotInstalled) {
  2030. buffer.push({ event, args });
  2031. }
  2032. }
  2033. function setDevtoolsHook(hook, target) {
  2034. var _a, _b;
  2035. exports.devtools = hook;
  2036. if (exports.devtools) {
  2037. exports.devtools.enabled = true;
  2038. buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
  2039. buffer = [];
  2040. }
  2041. else if (
  2042. // handle late devtools injection - only do this if we are in an actual
  2043. // browser environment to avoid the timer handle stalling test runner exit
  2044. // (#4815)
  2045. // eslint-disable-next-line no-restricted-globals
  2046. typeof window !== 'undefined' &&
  2047. // some envs mock window but not fully
  2048. window.HTMLElement &&
  2049. // also exclude jsdom
  2050. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  2051. const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
  2052. target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
  2053. replay.push((newHook) => {
  2054. setDevtoolsHook(newHook, target);
  2055. });
  2056. // clear buffer after 3s - the user probably doesn't have devtools installed
  2057. // at all, and keeping the buffer will cause memory leaks (#4738)
  2058. setTimeout(() => {
  2059. if (!exports.devtools) {
  2060. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2061. devtoolsNotInstalled = true;
  2062. buffer = [];
  2063. }
  2064. }, 3000);
  2065. }
  2066. else {
  2067. // non-browser env, assume not installed
  2068. devtoolsNotInstalled = true;
  2069. buffer = [];
  2070. }
  2071. }
  2072. function devtoolsInitApp(app, version) {
  2073. emit("app:init" /* APP_INIT */, app, version, {
  2074. Fragment,
  2075. Text,
  2076. Comment,
  2077. Static
  2078. });
  2079. }
  2080. function devtoolsUnmountApp(app) {
  2081. emit("app:unmount" /* APP_UNMOUNT */, app);
  2082. }
  2083. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  2084. const devtoolsComponentUpdated =
  2085. /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2086. const devtoolsComponentRemoved =
  2087. /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
  2088. function createDevtoolsComponentHook(hook) {
  2089. return (component) => {
  2090. emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  2091. };
  2092. }
  2093. const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
  2094. const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
  2095. function createDevtoolsPerformanceHook(hook) {
  2096. return (component, type, time) => {
  2097. emit(hook, component.appContext.app, component.uid, component, type, time);
  2098. };
  2099. }
  2100. function devtoolsComponentEmit(component, event, params) {
  2101. emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
  2102. }
  2103. function emit$1(instance, event, ...rawArgs) {
  2104. if (instance.isUnmounted)
  2105. return;
  2106. const props = instance.vnode.props || EMPTY_OBJ;
  2107. {
  2108. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  2109. if (emitsOptions) {
  2110. if (!(event in emitsOptions) &&
  2111. !(false )) {
  2112. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2113. warn$1(`Component emitted event "${event}" but it is neither declared in ` +
  2114. `the emits option nor as an "${toHandlerKey(event)}" prop.`);
  2115. }
  2116. }
  2117. else {
  2118. const validator = emitsOptions[event];
  2119. if (isFunction(validator)) {
  2120. const isValid = validator(...rawArgs);
  2121. if (!isValid) {
  2122. warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
  2123. }
  2124. }
  2125. }
  2126. }
  2127. }
  2128. let args = rawArgs;
  2129. const isModelListener = event.startsWith('update:');
  2130. // for v-model update:xxx events, apply modifiers on args
  2131. const modelArg = isModelListener && event.slice(7);
  2132. if (modelArg && modelArg in props) {
  2133. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  2134. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2135. if (trim) {
  2136. args = rawArgs.map(a => a.trim());
  2137. }
  2138. else if (number) {
  2139. args = rawArgs.map(toNumber);
  2140. }
  2141. }
  2142. {
  2143. devtoolsComponentEmit(instance, event, args);
  2144. }
  2145. {
  2146. const lowerCaseEvent = event.toLowerCase();
  2147. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2148. warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
  2149. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  2150. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2151. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2152. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2153. }
  2154. }
  2155. let handlerName;
  2156. let handler = props[(handlerName = toHandlerKey(event))] ||
  2157. // also try camelCase event handler (#2249)
  2158. props[(handlerName = toHandlerKey(camelize(event)))];
  2159. // for v-model update:xxx events, also trigger kebab-case equivalent
  2160. // for props passed via kebab-case
  2161. if (!handler && isModelListener) {
  2162. handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
  2163. }
  2164. if (handler) {
  2165. callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  2166. }
  2167. const onceHandler = props[handlerName + `Once`];
  2168. if (onceHandler) {
  2169. if (!instance.emitted) {
  2170. instance.emitted = {};
  2171. }
  2172. else if (instance.emitted[handlerName]) {
  2173. return;
  2174. }
  2175. instance.emitted[handlerName] = true;
  2176. callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  2177. }
  2178. }
  2179. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2180. const cache = appContext.emitsCache;
  2181. const cached = cache.get(comp);
  2182. if (cached !== undefined) {
  2183. return cached;
  2184. }
  2185. const raw = comp.emits;
  2186. let normalized = {};
  2187. // apply mixin/extends props
  2188. let hasExtends = false;
  2189. if (!isFunction(comp)) {
  2190. const extendEmits = (raw) => {
  2191. const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  2192. if (normalizedFromExtend) {
  2193. hasExtends = true;
  2194. extend(normalized, normalizedFromExtend);
  2195. }
  2196. };
  2197. if (!asMixin && appContext.mixins.length) {
  2198. appContext.mixins.forEach(extendEmits);
  2199. }
  2200. if (comp.extends) {
  2201. extendEmits(comp.extends);
  2202. }
  2203. if (comp.mixins) {
  2204. comp.mixins.forEach(extendEmits);
  2205. }
  2206. }
  2207. if (!raw && !hasExtends) {
  2208. cache.set(comp, null);
  2209. return null;
  2210. }
  2211. if (isArray(raw)) {
  2212. raw.forEach(key => (normalized[key] = null));
  2213. }
  2214. else {
  2215. extend(normalized, raw);
  2216. }
  2217. cache.set(comp, normalized);
  2218. return normalized;
  2219. }
  2220. // Check if an incoming prop key is a declared emit event listener.
  2221. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  2222. // both considered matched listeners.
  2223. function isEmitListener(options, key) {
  2224. if (!options || !isOn(key)) {
  2225. return false;
  2226. }
  2227. key = key.slice(2).replace(/Once$/, '');
  2228. return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  2229. hasOwn(options, hyphenate(key)) ||
  2230. hasOwn(options, key));
  2231. }
  2232. /**
  2233. * mark the current rendering instance for asset resolution (e.g.
  2234. * resolveComponent, resolveDirective) during render
  2235. */
  2236. let currentRenderingInstance = null;
  2237. let currentScopeId = null;
  2238. /**
  2239. * Note: rendering calls maybe nested. The function returns the parent rendering
  2240. * instance if present, which should be restored after the render is done:
  2241. *
  2242. * ```js
  2243. * const prev = setCurrentRenderingInstance(i)
  2244. * // ...render
  2245. * setCurrentRenderingInstance(prev)
  2246. * ```
  2247. */
  2248. function setCurrentRenderingInstance(instance) {
  2249. const prev = currentRenderingInstance;
  2250. currentRenderingInstance = instance;
  2251. currentScopeId = (instance && instance.type.__scopeId) || null;
  2252. return prev;
  2253. }
  2254. /**
  2255. * Set scope id when creating hoisted vnodes.
  2256. * @private compiler helper
  2257. */
  2258. function pushScopeId(id) {
  2259. currentScopeId = id;
  2260. }
  2261. /**
  2262. * Technically we no longer need this after 3.0.8 but we need to keep the same
  2263. * API for backwards compat w/ code generated by compilers.
  2264. * @private
  2265. */
  2266. function popScopeId() {
  2267. currentScopeId = null;
  2268. }
  2269. /**
  2270. * Only for backwards compat
  2271. * @private
  2272. */
  2273. const withScopeId = (_id) => withCtx;
  2274. /**
  2275. * Wrap a slot function to memoize current rendering instance
  2276. * @private compiler helper
  2277. */
  2278. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
  2279. ) {
  2280. if (!ctx)
  2281. return fn;
  2282. // already normalized
  2283. if (fn._n) {
  2284. return fn;
  2285. }
  2286. const renderFnWithContext = (...args) => {
  2287. // If a user calls a compiled slot inside a template expression (#1745), it
  2288. // can mess up block tracking, so by default we disable block tracking and
  2289. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  2290. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  2291. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  2292. if (renderFnWithContext._d) {
  2293. setBlockTracking(-1);
  2294. }
  2295. const prevInstance = setCurrentRenderingInstance(ctx);
  2296. const res = fn(...args);
  2297. setCurrentRenderingInstance(prevInstance);
  2298. if (renderFnWithContext._d) {
  2299. setBlockTracking(1);
  2300. }
  2301. {
  2302. devtoolsComponentUpdated(ctx);
  2303. }
  2304. return res;
  2305. };
  2306. // mark normalized to avoid duplicated wrapping
  2307. renderFnWithContext._n = true;
  2308. // mark this as compiled by default
  2309. // this is used in vnode.ts -> normalizeChildren() to set the slot
  2310. // rendering flag.
  2311. renderFnWithContext._c = true;
  2312. // disable block tracking by default
  2313. renderFnWithContext._d = true;
  2314. return renderFnWithContext;
  2315. }
  2316. /**
  2317. * dev only flag to track whether $attrs was used during render.
  2318. * If $attrs was used during render then the warning for failed attrs
  2319. * fallthrough can be suppressed.
  2320. */
  2321. let accessedAttrs = false;
  2322. function markAttrsAccessed() {
  2323. accessedAttrs = true;
  2324. }
  2325. function renderComponentRoot(instance) {
  2326. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
  2327. let result;
  2328. let fallthroughAttrs;
  2329. const prev = setCurrentRenderingInstance(instance);
  2330. {
  2331. accessedAttrs = false;
  2332. }
  2333. try {
  2334. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  2335. // withProxy is a proxy with a different `has` trap only for
  2336. // runtime-compiled render functions using `with` block.
  2337. const proxyToUse = withProxy || proxy;
  2338. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  2339. fallthroughAttrs = attrs;
  2340. }
  2341. else {
  2342. // functional
  2343. const render = Component;
  2344. // in dev, mark attrs accessed if optional props (attrs === props)
  2345. if (true && attrs === props) {
  2346. markAttrsAccessed();
  2347. }
  2348. result = normalizeVNode(render.length > 1
  2349. ? render(props, true
  2350. ? {
  2351. get attrs() {
  2352. markAttrsAccessed();
  2353. return attrs;
  2354. },
  2355. slots,
  2356. emit
  2357. }
  2358. : { attrs, slots, emit })
  2359. : render(props, null /* we know it doesn't need it */));
  2360. fallthroughAttrs = Component.props
  2361. ? attrs
  2362. : getFunctionalFallthrough(attrs);
  2363. }
  2364. }
  2365. catch (err) {
  2366. blockStack.length = 0;
  2367. handleError(err, instance, 1 /* RENDER_FUNCTION */);
  2368. result = createVNode(Comment);
  2369. }
  2370. // attr merging
  2371. // in dev mode, comments are preserved, and it's possible for a template
  2372. // to have comments along side the root element which makes it a fragment
  2373. let root = result;
  2374. let setRoot = undefined;
  2375. if (result.patchFlag > 0 &&
  2376. result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  2377. [root, setRoot] = getChildRoot(result);
  2378. }
  2379. if (fallthroughAttrs && inheritAttrs !== false) {
  2380. const keys = Object.keys(fallthroughAttrs);
  2381. const { shapeFlag } = root;
  2382. if (keys.length) {
  2383. if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
  2384. if (propsOptions && keys.some(isModelListener)) {
  2385. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  2386. // prop, it indicates this component expects to handle v-model and
  2387. // it should not fallthrough.
  2388. // related: #1543, #1643, #1989
  2389. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  2390. }
  2391. root = cloneVNode(root, fallthroughAttrs);
  2392. }
  2393. else if (!accessedAttrs && root.type !== Comment) {
  2394. const allAttrs = Object.keys(attrs);
  2395. const eventAttrs = [];
  2396. const extraAttrs = [];
  2397. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2398. const key = allAttrs[i];
  2399. if (isOn(key)) {
  2400. // ignore v-model handlers when they fail to fallthrough
  2401. if (!isModelListener(key)) {
  2402. // remove `on`, lowercase first letter to reflect event casing
  2403. // accurately
  2404. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2405. }
  2406. }
  2407. else {
  2408. extraAttrs.push(key);
  2409. }
  2410. }
  2411. if (extraAttrs.length) {
  2412. warn$1(`Extraneous non-props attributes (` +
  2413. `${extraAttrs.join(', ')}) ` +
  2414. `were passed to component but could not be automatically inherited ` +
  2415. `because component renders fragment or text root nodes.`);
  2416. }
  2417. if (eventAttrs.length) {
  2418. warn$1(`Extraneous non-emits event listeners (` +
  2419. `${eventAttrs.join(', ')}) ` +
  2420. `were passed to component but could not be automatically inherited ` +
  2421. `because component renders fragment or text root nodes. ` +
  2422. `If the listener is intended to be a component custom event listener only, ` +
  2423. `declare it using the "emits" option.`);
  2424. }
  2425. }
  2426. }
  2427. }
  2428. // inherit directives
  2429. if (vnode.dirs) {
  2430. if (!isElementRoot(root)) {
  2431. warn$1(`Runtime directive used on component with non-element root node. ` +
  2432. `The directives will not function as intended.`);
  2433. }
  2434. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2435. }
  2436. // inherit transition data
  2437. if (vnode.transition) {
  2438. if (!isElementRoot(root)) {
  2439. warn$1(`Component inside <Transition> renders non-element root node ` +
  2440. `that cannot be animated.`);
  2441. }
  2442. root.transition = vnode.transition;
  2443. }
  2444. if (setRoot) {
  2445. setRoot(root);
  2446. }
  2447. else {
  2448. result = root;
  2449. }
  2450. setCurrentRenderingInstance(prev);
  2451. return result;
  2452. }
  2453. /**
  2454. * dev only
  2455. * In dev mode, template root level comments are rendered, which turns the
  2456. * template into a fragment root, but we need to locate the single element
  2457. * root for attrs and scope id processing.
  2458. */
  2459. const getChildRoot = (vnode) => {
  2460. const rawChildren = vnode.children;
  2461. const dynamicChildren = vnode.dynamicChildren;
  2462. const childRoot = filterSingleRoot(rawChildren);
  2463. if (!childRoot) {
  2464. return [vnode, undefined];
  2465. }
  2466. const index = rawChildren.indexOf(childRoot);
  2467. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2468. const setRoot = (updatedRoot) => {
  2469. rawChildren[index] = updatedRoot;
  2470. if (dynamicChildren) {
  2471. if (dynamicIndex > -1) {
  2472. dynamicChildren[dynamicIndex] = updatedRoot;
  2473. }
  2474. else if (updatedRoot.patchFlag > 0) {
  2475. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2476. }
  2477. }
  2478. };
  2479. return [normalizeVNode(childRoot), setRoot];
  2480. };
  2481. function filterSingleRoot(children) {
  2482. let singleRoot;
  2483. for (let i = 0; i < children.length; i++) {
  2484. const child = children[i];
  2485. if (isVNode(child)) {
  2486. // ignore user comment
  2487. if (child.type !== Comment || child.children === 'v-if') {
  2488. if (singleRoot) {
  2489. // has more than 1 non-comment child, return now
  2490. return;
  2491. }
  2492. else {
  2493. singleRoot = child;
  2494. }
  2495. }
  2496. }
  2497. else {
  2498. return;
  2499. }
  2500. }
  2501. return singleRoot;
  2502. }
  2503. const getFunctionalFallthrough = (attrs) => {
  2504. let res;
  2505. for (const key in attrs) {
  2506. if (key === 'class' || key === 'style' || isOn(key)) {
  2507. (res || (res = {}))[key] = attrs[key];
  2508. }
  2509. }
  2510. return res;
  2511. };
  2512. const filterModelListeners = (attrs, props) => {
  2513. const res = {};
  2514. for (const key in attrs) {
  2515. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2516. res[key] = attrs[key];
  2517. }
  2518. }
  2519. return res;
  2520. };
  2521. const isElementRoot = (vnode) => {
  2522. return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
  2523. vnode.type === Comment // potential v-if branch switch
  2524. );
  2525. };
  2526. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2527. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2528. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2529. const emits = component.emitsOptions;
  2530. // Parent component's render function was hot-updated. Since this may have
  2531. // caused the child component's slots content to have changed, we need to
  2532. // force the child to update as well.
  2533. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2534. return true;
  2535. }
  2536. // force child update for runtime directive or transition on component vnode.
  2537. if (nextVNode.dirs || nextVNode.transition) {
  2538. return true;
  2539. }
  2540. if (optimized && patchFlag >= 0) {
  2541. if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  2542. // slot content that references values that might have changed,
  2543. // e.g. in a v-for
  2544. return true;
  2545. }
  2546. if (patchFlag & 16 /* FULL_PROPS */) {
  2547. if (!prevProps) {
  2548. return !!nextProps;
  2549. }
  2550. // presence of this flag indicates props are always non-null
  2551. return hasPropsChanged(prevProps, nextProps, emits);
  2552. }
  2553. else if (patchFlag & 8 /* PROPS */) {
  2554. const dynamicProps = nextVNode.dynamicProps;
  2555. for (let i = 0; i < dynamicProps.length; i++) {
  2556. const key = dynamicProps[i];
  2557. if (nextProps[key] !== prevProps[key] &&
  2558. !isEmitListener(emits, key)) {
  2559. return true;
  2560. }
  2561. }
  2562. }
  2563. }
  2564. else {
  2565. // this path is only taken by manually written render functions
  2566. // so presence of any children leads to a forced update
  2567. if (prevChildren || nextChildren) {
  2568. if (!nextChildren || !nextChildren.$stable) {
  2569. return true;
  2570. }
  2571. }
  2572. if (prevProps === nextProps) {
  2573. return false;
  2574. }
  2575. if (!prevProps) {
  2576. return !!nextProps;
  2577. }
  2578. if (!nextProps) {
  2579. return true;
  2580. }
  2581. return hasPropsChanged(prevProps, nextProps, emits);
  2582. }
  2583. return false;
  2584. }
  2585. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2586. const nextKeys = Object.keys(nextProps);
  2587. if (nextKeys.length !== Object.keys(prevProps).length) {
  2588. return true;
  2589. }
  2590. for (let i = 0; i < nextKeys.length; i++) {
  2591. const key = nextKeys[i];
  2592. if (nextProps[key] !== prevProps[key] &&
  2593. !isEmitListener(emitsOptions, key)) {
  2594. return true;
  2595. }
  2596. }
  2597. return false;
  2598. }
  2599. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2600. ) {
  2601. while (parent && parent.subTree === vnode) {
  2602. (vnode = parent.vnode).el = el;
  2603. parent = parent.parent;
  2604. }
  2605. }
  2606. const isSuspense = (type) => type.__isSuspense;
  2607. // Suspense exposes a component-like API, and is treated like a component
  2608. // in the compiler, but internally it's a special built-in type that hooks
  2609. // directly into the renderer.
  2610. const SuspenseImpl = {
  2611. name: 'Suspense',
  2612. // In order to make Suspense tree-shakable, we need to avoid importing it
  2613. // directly in the renderer. The renderer checks for the __isSuspense flag
  2614. // on a vnode's type and calls the `process` method, passing in renderer
  2615. // internals.
  2616. __isSuspense: true,
  2617. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  2618. // platform-specific impl passed from renderer
  2619. rendererInternals) {
  2620. if (n1 == null) {
  2621. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  2622. }
  2623. else {
  2624. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  2625. }
  2626. },
  2627. hydrate: hydrateSuspense,
  2628. create: createSuspenseBoundary,
  2629. normalize: normalizeSuspenseChildren
  2630. };
  2631. // Force-casted public typing for h and TSX props inference
  2632. const Suspense = (SuspenseImpl );
  2633. function triggerEvent(vnode, name) {
  2634. const eventListener = vnode.props && vnode.props[name];
  2635. if (isFunction(eventListener)) {
  2636. eventListener();
  2637. }
  2638. }
  2639. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2640. const { p: patch, o: { createElement } } = rendererInternals;
  2641. const hiddenContainer = createElement('div');
  2642. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
  2643. // start mounting the content subtree in an off-dom container
  2644. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  2645. // now check if we have encountered any async deps
  2646. if (suspense.deps > 0) {
  2647. // has async
  2648. // invoke @fallback event
  2649. triggerEvent(vnode, 'onPending');
  2650. triggerEvent(vnode, 'onFallback');
  2651. // mount the fallback tree
  2652. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2653. isSVG, slotScopeIds);
  2654. setActiveBranch(suspense, vnode.ssFallback);
  2655. }
  2656. else {
  2657. // Suspense has no async deps. Just resolve.
  2658. suspense.resolve();
  2659. }
  2660. }
  2661. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2662. const suspense = (n2.suspense = n1.suspense);
  2663. suspense.vnode = n2;
  2664. n2.el = n1.el;
  2665. const newBranch = n2.ssContent;
  2666. const newFallback = n2.ssFallback;
  2667. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2668. if (pendingBranch) {
  2669. suspense.pendingBranch = newBranch;
  2670. if (isSameVNodeType(newBranch, pendingBranch)) {
  2671. // same root type but content may have changed.
  2672. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2673. if (suspense.deps <= 0) {
  2674. suspense.resolve();
  2675. }
  2676. else if (isInFallback) {
  2677. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2678. isSVG, slotScopeIds, optimized);
  2679. setActiveBranch(suspense, newFallback);
  2680. }
  2681. }
  2682. else {
  2683. // toggled before pending tree is resolved
  2684. suspense.pendingId++;
  2685. if (isHydrating) {
  2686. // if toggled before hydration is finished, the current DOM tree is
  2687. // no longer valid. set it as the active branch so it will be unmounted
  2688. // when resolved
  2689. suspense.isHydrating = false;
  2690. suspense.activeBranch = pendingBranch;
  2691. }
  2692. else {
  2693. unmount(pendingBranch, parentComponent, suspense);
  2694. }
  2695. // increment pending ID. this is used to invalidate async callbacks
  2696. // reset suspense state
  2697. suspense.deps = 0;
  2698. // discard effects from pending branch
  2699. suspense.effects.length = 0;
  2700. // discard previous container
  2701. suspense.hiddenContainer = createElement('div');
  2702. if (isInFallback) {
  2703. // already in fallback state
  2704. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2705. if (suspense.deps <= 0) {
  2706. suspense.resolve();
  2707. }
  2708. else {
  2709. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2710. isSVG, slotScopeIds, optimized);
  2711. setActiveBranch(suspense, newFallback);
  2712. }
  2713. }
  2714. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2715. // toggled "back" to current active branch
  2716. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2717. // force resolve
  2718. suspense.resolve(true);
  2719. }
  2720. else {
  2721. // switched to a 3rd branch
  2722. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2723. if (suspense.deps <= 0) {
  2724. suspense.resolve();
  2725. }
  2726. }
  2727. }
  2728. }
  2729. else {
  2730. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2731. // root did not change, just normal patch
  2732. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2733. setActiveBranch(suspense, newBranch);
  2734. }
  2735. else {
  2736. // root node toggled
  2737. // invoke @pending event
  2738. triggerEvent(n2, 'onPending');
  2739. // mount pending branch in off-dom container
  2740. suspense.pendingBranch = newBranch;
  2741. suspense.pendingId++;
  2742. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2743. if (suspense.deps <= 0) {
  2744. // incoming branch has no async deps, resolve now.
  2745. suspense.resolve();
  2746. }
  2747. else {
  2748. const { timeout, pendingId } = suspense;
  2749. if (timeout > 0) {
  2750. setTimeout(() => {
  2751. if (suspense.pendingId === pendingId) {
  2752. suspense.fallback(newFallback);
  2753. }
  2754. }, timeout);
  2755. }
  2756. else if (timeout === 0) {
  2757. suspense.fallback(newFallback);
  2758. }
  2759. }
  2760. }
  2761. }
  2762. }
  2763. let hasWarned = false;
  2764. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2765. /* istanbul ignore if */
  2766. if (!hasWarned) {
  2767. hasWarned = true;
  2768. // @ts-ignore `console.info` cannot be null error
  2769. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2770. }
  2771. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2772. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2773. const suspense = {
  2774. vnode,
  2775. parent,
  2776. parentComponent,
  2777. isSVG,
  2778. container,
  2779. hiddenContainer,
  2780. anchor,
  2781. deps: 0,
  2782. pendingId: 0,
  2783. timeout: typeof timeout === 'number' ? timeout : -1,
  2784. activeBranch: null,
  2785. pendingBranch: null,
  2786. isInFallback: true,
  2787. isHydrating,
  2788. isUnmounted: false,
  2789. effects: [],
  2790. resolve(resume = false) {
  2791. {
  2792. if (!resume && !suspense.pendingBranch) {
  2793. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2794. }
  2795. if (suspense.isUnmounted) {
  2796. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2797. }
  2798. }
  2799. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2800. if (suspense.isHydrating) {
  2801. suspense.isHydrating = false;
  2802. }
  2803. else if (!resume) {
  2804. const delayEnter = activeBranch &&
  2805. pendingBranch.transition &&
  2806. pendingBranch.transition.mode === 'out-in';
  2807. if (delayEnter) {
  2808. activeBranch.transition.afterLeave = () => {
  2809. if (pendingId === suspense.pendingId) {
  2810. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2811. }
  2812. };
  2813. }
  2814. // this is initial anchor on mount
  2815. let { anchor } = suspense;
  2816. // unmount current active tree
  2817. if (activeBranch) {
  2818. // if the fallback tree was mounted, it may have been moved
  2819. // as part of a parent suspense. get the latest anchor for insertion
  2820. anchor = next(activeBranch);
  2821. unmount(activeBranch, parentComponent, suspense, true);
  2822. }
  2823. if (!delayEnter) {
  2824. // move content from off-dom container to actual container
  2825. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2826. }
  2827. }
  2828. setActiveBranch(suspense, pendingBranch);
  2829. suspense.pendingBranch = null;
  2830. suspense.isInFallback = false;
  2831. // flush buffered effects
  2832. // check if there is a pending parent suspense
  2833. let parent = suspense.parent;
  2834. let hasUnresolvedAncestor = false;
  2835. while (parent) {
  2836. if (parent.pendingBranch) {
  2837. // found a pending parent suspense, merge buffered post jobs
  2838. // into that parent
  2839. parent.effects.push(...effects);
  2840. hasUnresolvedAncestor = true;
  2841. break;
  2842. }
  2843. parent = parent.parent;
  2844. }
  2845. // no pending parent suspense, flush all jobs
  2846. if (!hasUnresolvedAncestor) {
  2847. queuePostFlushCb(effects);
  2848. }
  2849. suspense.effects = [];
  2850. // invoke @resolve event
  2851. triggerEvent(vnode, 'onResolve');
  2852. },
  2853. fallback(fallbackVNode) {
  2854. if (!suspense.pendingBranch) {
  2855. return;
  2856. }
  2857. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  2858. // invoke @fallback event
  2859. triggerEvent(vnode, 'onFallback');
  2860. const anchor = next(activeBranch);
  2861. const mountFallback = () => {
  2862. if (!suspense.isInFallback) {
  2863. return;
  2864. }
  2865. // mount the fallback tree
  2866. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2867. isSVG, slotScopeIds, optimized);
  2868. setActiveBranch(suspense, fallbackVNode);
  2869. };
  2870. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2871. if (delayEnter) {
  2872. activeBranch.transition.afterLeave = mountFallback;
  2873. }
  2874. suspense.isInFallback = true;
  2875. // unmount current active branch
  2876. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2877. true // shouldRemove
  2878. );
  2879. if (!delayEnter) {
  2880. mountFallback();
  2881. }
  2882. },
  2883. move(container, anchor, type) {
  2884. suspense.activeBranch &&
  2885. move(suspense.activeBranch, container, anchor, type);
  2886. suspense.container = container;
  2887. },
  2888. next() {
  2889. return suspense.activeBranch && next(suspense.activeBranch);
  2890. },
  2891. registerDep(instance, setupRenderEffect) {
  2892. const isInPendingSuspense = !!suspense.pendingBranch;
  2893. if (isInPendingSuspense) {
  2894. suspense.deps++;
  2895. }
  2896. const hydratedEl = instance.vnode.el;
  2897. instance
  2898. .asyncDep.catch(err => {
  2899. handleError(err, instance, 0 /* SETUP_FUNCTION */);
  2900. })
  2901. .then(asyncSetupResult => {
  2902. // retry when the setup() promise resolves.
  2903. // component may have been unmounted before resolve.
  2904. if (instance.isUnmounted ||
  2905. suspense.isUnmounted ||
  2906. suspense.pendingId !== instance.suspenseId) {
  2907. return;
  2908. }
  2909. // retry from this component
  2910. instance.asyncResolved = true;
  2911. const { vnode } = instance;
  2912. {
  2913. pushWarningContext(vnode);
  2914. }
  2915. handleSetupResult(instance, asyncSetupResult, false);
  2916. if (hydratedEl) {
  2917. // vnode may have been replaced if an update happened before the
  2918. // async dep is resolved.
  2919. vnode.el = hydratedEl;
  2920. }
  2921. const placeholder = !hydratedEl && instance.subTree.el;
  2922. setupRenderEffect(instance, vnode,
  2923. // component may have been moved before resolve.
  2924. // if this is not a hydration, instance.subTree will be the comment
  2925. // placeholder.
  2926. parentNode(hydratedEl || instance.subTree.el),
  2927. // anchor will not be used if this is hydration, so only need to
  2928. // consider the comment placeholder case.
  2929. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2930. if (placeholder) {
  2931. remove(placeholder);
  2932. }
  2933. updateHOCHostEl(instance, vnode.el);
  2934. {
  2935. popWarningContext();
  2936. }
  2937. // only decrease deps count if suspense is not already resolved
  2938. if (isInPendingSuspense && --suspense.deps === 0) {
  2939. suspense.resolve();
  2940. }
  2941. });
  2942. },
  2943. unmount(parentSuspense, doRemove) {
  2944. suspense.isUnmounted = true;
  2945. if (suspense.activeBranch) {
  2946. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2947. }
  2948. if (suspense.pendingBranch) {
  2949. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2950. }
  2951. }
  2952. };
  2953. return suspense;
  2954. }
  2955. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2956. /* eslint-disable no-restricted-globals */
  2957. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
  2958. // there are two possible scenarios for server-rendered suspense:
  2959. // - success: ssr content should be fully resolved
  2960. // - failure: ssr content should be the fallback branch.
  2961. // however, on the client we don't really know if it has failed or not
  2962. // attempt to hydrate the DOM assuming it has succeeded, but we still
  2963. // need to construct a suspense boundary first
  2964. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
  2965. if (suspense.deps === 0) {
  2966. suspense.resolve();
  2967. }
  2968. return result;
  2969. /* eslint-enable no-restricted-globals */
  2970. }
  2971. function normalizeSuspenseChildren(vnode) {
  2972. const { shapeFlag, children } = vnode;
  2973. const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
  2974. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  2975. vnode.ssFallback = isSlotChildren
  2976. ? normalizeSuspenseSlot(children.fallback)
  2977. : createVNode(Comment);
  2978. }
  2979. function normalizeSuspenseSlot(s) {
  2980. let block;
  2981. if (isFunction(s)) {
  2982. const trackBlock = isBlockTreeEnabled && s._c;
  2983. if (trackBlock) {
  2984. // disableTracking: false
  2985. // allow block tracking for compiled slots
  2986. // (see ./componentRenderContext.ts)
  2987. s._d = false;
  2988. openBlock();
  2989. }
  2990. s = s();
  2991. if (trackBlock) {
  2992. s._d = true;
  2993. block = currentBlock;
  2994. closeBlock();
  2995. }
  2996. }
  2997. if (isArray(s)) {
  2998. const singleChild = filterSingleRoot(s);
  2999. if (!singleChild) {
  3000. warn$1(`<Suspense> slots expect a single root node.`);
  3001. }
  3002. s = singleChild;
  3003. }
  3004. s = normalizeVNode(s);
  3005. if (block && !s.dynamicChildren) {
  3006. s.dynamicChildren = block.filter(c => c !== s);
  3007. }
  3008. return s;
  3009. }
  3010. function queueEffectWithSuspense(fn, suspense) {
  3011. if (suspense && suspense.pendingBranch) {
  3012. if (isArray(fn)) {
  3013. suspense.effects.push(...fn);
  3014. }
  3015. else {
  3016. suspense.effects.push(fn);
  3017. }
  3018. }
  3019. else {
  3020. queuePostFlushCb(fn);
  3021. }
  3022. }
  3023. function setActiveBranch(suspense, branch) {
  3024. suspense.activeBranch = branch;
  3025. const { vnode, parentComponent } = suspense;
  3026. const el = (vnode.el = branch.el);
  3027. // in case suspense is the root node of a component,
  3028. // recursively update the HOC el
  3029. if (parentComponent && parentComponent.subTree === vnode) {
  3030. parentComponent.vnode.el = el;
  3031. updateHOCHostEl(parentComponent, el);
  3032. }
  3033. }
  3034. function provide(key, value) {
  3035. if (!currentInstance) {
  3036. {
  3037. warn$1(`provide() can only be used inside setup().`);
  3038. }
  3039. }
  3040. else {
  3041. let provides = currentInstance.provides;
  3042. // by default an instance inherits its parent's provides object
  3043. // but when it needs to provide values of its own, it creates its
  3044. // own provides object using parent provides object as prototype.
  3045. // this way in `inject` we can simply look up injections from direct
  3046. // parent and let the prototype chain do the work.
  3047. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  3048. if (parentProvides === provides) {
  3049. provides = currentInstance.provides = Object.create(parentProvides);
  3050. }
  3051. // TS doesn't allow symbol as index type
  3052. provides[key] = value;
  3053. }
  3054. }
  3055. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3056. // fallback to `currentRenderingInstance` so that this can be called in
  3057. // a functional component
  3058. const instance = currentInstance || currentRenderingInstance;
  3059. if (instance) {
  3060. // #2400
  3061. // to support `app.use` plugins,
  3062. // fallback to appContext's `provides` if the instance is at root
  3063. const provides = instance.parent == null
  3064. ? instance.vnode.appContext && instance.vnode.appContext.provides
  3065. : instance.parent.provides;
  3066. if (provides && key in provides) {
  3067. // TS doesn't allow symbol as index type
  3068. return provides[key];
  3069. }
  3070. else if (arguments.length > 1) {
  3071. return treatDefaultAsFactory && isFunction(defaultValue)
  3072. ? defaultValue.call(instance.proxy)
  3073. : defaultValue;
  3074. }
  3075. else {
  3076. warn$1(`injection "${String(key)}" not found.`);
  3077. }
  3078. }
  3079. else {
  3080. warn$1(`inject() can only be used inside setup() or functional components.`);
  3081. }
  3082. }
  3083. // Simple effect.
  3084. function watchEffect(effect, options) {
  3085. return doWatch(effect, null, options);
  3086. }
  3087. function watchPostEffect(effect, options) {
  3088. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3089. }
  3090. function watchSyncEffect(effect, options) {
  3091. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3092. }
  3093. // initial value for watchers to trigger on undefined initial values
  3094. const INITIAL_WATCHER_VALUE = {};
  3095. // implementation
  3096. function watch(source, cb, options) {
  3097. if (!isFunction(cb)) {
  3098. warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3099. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3100. `supports \`watch(source, cb, options?) signature.`);
  3101. }
  3102. return doWatch(source, cb, options);
  3103. }
  3104. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3105. if (!cb) {
  3106. if (immediate !== undefined) {
  3107. warn$1(`watch() "immediate" option is only respected when using the ` +
  3108. `watch(source, callback, options?) signature.`);
  3109. }
  3110. if (deep !== undefined) {
  3111. warn$1(`watch() "deep" option is only respected when using the ` +
  3112. `watch(source, callback, options?) signature.`);
  3113. }
  3114. }
  3115. const warnInvalidSource = (s) => {
  3116. warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  3117. `a reactive object, or an array of these types.`);
  3118. };
  3119. const instance = currentInstance;
  3120. let getter;
  3121. let forceTrigger = false;
  3122. let isMultiSource = false;
  3123. if (isRef(source)) {
  3124. getter = () => source.value;
  3125. forceTrigger = isShallow(source);
  3126. }
  3127. else if (isReactive(source)) {
  3128. getter = () => source;
  3129. deep = true;
  3130. }
  3131. else if (isArray(source)) {
  3132. isMultiSource = true;
  3133. forceTrigger = source.some(isReactive);
  3134. getter = () => source.map(s => {
  3135. if (isRef(s)) {
  3136. return s.value;
  3137. }
  3138. else if (isReactive(s)) {
  3139. return traverse(s);
  3140. }
  3141. else if (isFunction(s)) {
  3142. return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
  3143. }
  3144. else {
  3145. warnInvalidSource(s);
  3146. }
  3147. });
  3148. }
  3149. else if (isFunction(source)) {
  3150. if (cb) {
  3151. // getter with cb
  3152. getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
  3153. }
  3154. else {
  3155. // no cb -> simple effect
  3156. getter = () => {
  3157. if (instance && instance.isUnmounted) {
  3158. return;
  3159. }
  3160. if (cleanup) {
  3161. cleanup();
  3162. }
  3163. return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onCleanup]);
  3164. };
  3165. }
  3166. }
  3167. else {
  3168. getter = NOOP;
  3169. warnInvalidSource(source);
  3170. }
  3171. if (cb && deep) {
  3172. const baseGetter = getter;
  3173. getter = () => traverse(baseGetter());
  3174. }
  3175. let cleanup;
  3176. let onCleanup = (fn) => {
  3177. cleanup = effect.onStop = () => {
  3178. callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
  3179. };
  3180. };
  3181. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3182. const job = () => {
  3183. if (!effect.active) {
  3184. return;
  3185. }
  3186. if (cb) {
  3187. // watch(source, cb)
  3188. const newValue = effect.run();
  3189. if (deep ||
  3190. forceTrigger ||
  3191. (isMultiSource
  3192. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3193. : hasChanged(newValue, oldValue)) ||
  3194. (false )) {
  3195. // cleanup before running cb again
  3196. if (cleanup) {
  3197. cleanup();
  3198. }
  3199. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  3200. newValue,
  3201. // pass undefined as the old value when it's changed for the first time
  3202. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3203. onCleanup
  3204. ]);
  3205. oldValue = newValue;
  3206. }
  3207. }
  3208. else {
  3209. // watchEffect
  3210. effect.run();
  3211. }
  3212. };
  3213. // important: mark the job as a watcher callback so that scheduler knows
  3214. // it is allowed to self-trigger (#1727)
  3215. job.allowRecurse = !!cb;
  3216. let scheduler;
  3217. if (flush === 'sync') {
  3218. scheduler = job; // the scheduler function gets called directly
  3219. }
  3220. else if (flush === 'post') {
  3221. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3222. }
  3223. else {
  3224. // default: 'pre'
  3225. scheduler = () => {
  3226. if (!instance || instance.isMounted) {
  3227. queuePreFlushCb(job);
  3228. }
  3229. else {
  3230. // with 'pre' option, the first call must happen before
  3231. // the component is mounted so it is called synchronously.
  3232. job();
  3233. }
  3234. };
  3235. }
  3236. const effect = new ReactiveEffect(getter, scheduler);
  3237. {
  3238. effect.onTrack = onTrack;
  3239. effect.onTrigger = onTrigger;
  3240. }
  3241. // initial run
  3242. if (cb) {
  3243. if (immediate) {
  3244. job();
  3245. }
  3246. else {
  3247. oldValue = effect.run();
  3248. }
  3249. }
  3250. else if (flush === 'post') {
  3251. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  3252. }
  3253. else {
  3254. effect.run();
  3255. }
  3256. return () => {
  3257. effect.stop();
  3258. if (instance && instance.scope) {
  3259. remove(instance.scope.effects, effect);
  3260. }
  3261. };
  3262. }
  3263. // this.$watch
  3264. function instanceWatch(source, value, options) {
  3265. const publicThis = this.proxy;
  3266. const getter = isString(source)
  3267. ? source.includes('.')
  3268. ? createPathGetter(publicThis, source)
  3269. : () => publicThis[source]
  3270. : source.bind(publicThis, publicThis);
  3271. let cb;
  3272. if (isFunction(value)) {
  3273. cb = value;
  3274. }
  3275. else {
  3276. cb = value.handler;
  3277. options = value;
  3278. }
  3279. const cur = currentInstance;
  3280. setCurrentInstance(this);
  3281. const res = doWatch(getter, cb.bind(publicThis), options);
  3282. if (cur) {
  3283. setCurrentInstance(cur);
  3284. }
  3285. else {
  3286. unsetCurrentInstance();
  3287. }
  3288. return res;
  3289. }
  3290. function createPathGetter(ctx, path) {
  3291. const segments = path.split('.');
  3292. return () => {
  3293. let cur = ctx;
  3294. for (let i = 0; i < segments.length && cur; i++) {
  3295. cur = cur[segments[i]];
  3296. }
  3297. return cur;
  3298. };
  3299. }
  3300. function traverse(value, seen) {
  3301. if (!isObject(value) || value["__v_skip" /* SKIP */]) {
  3302. return value;
  3303. }
  3304. seen = seen || new Set();
  3305. if (seen.has(value)) {
  3306. return value;
  3307. }
  3308. seen.add(value);
  3309. if (isRef(value)) {
  3310. traverse(value.value, seen);
  3311. }
  3312. else if (isArray(value)) {
  3313. for (let i = 0; i < value.length; i++) {
  3314. traverse(value[i], seen);
  3315. }
  3316. }
  3317. else if (isSet(value) || isMap(value)) {
  3318. value.forEach((v) => {
  3319. traverse(v, seen);
  3320. });
  3321. }
  3322. else if (isPlainObject(value)) {
  3323. for (const key in value) {
  3324. traverse(value[key], seen);
  3325. }
  3326. }
  3327. return value;
  3328. }
  3329. function useTransitionState() {
  3330. const state = {
  3331. isMounted: false,
  3332. isLeaving: false,
  3333. isUnmounting: false,
  3334. leavingVNodes: new Map()
  3335. };
  3336. onMounted(() => {
  3337. state.isMounted = true;
  3338. });
  3339. onBeforeUnmount(() => {
  3340. state.isUnmounting = true;
  3341. });
  3342. return state;
  3343. }
  3344. const TransitionHookValidator = [Function, Array];
  3345. const BaseTransitionImpl = {
  3346. name: `BaseTransition`,
  3347. props: {
  3348. mode: String,
  3349. appear: Boolean,
  3350. persisted: Boolean,
  3351. // enter
  3352. onBeforeEnter: TransitionHookValidator,
  3353. onEnter: TransitionHookValidator,
  3354. onAfterEnter: TransitionHookValidator,
  3355. onEnterCancelled: TransitionHookValidator,
  3356. // leave
  3357. onBeforeLeave: TransitionHookValidator,
  3358. onLeave: TransitionHookValidator,
  3359. onAfterLeave: TransitionHookValidator,
  3360. onLeaveCancelled: TransitionHookValidator,
  3361. // appear
  3362. onBeforeAppear: TransitionHookValidator,
  3363. onAppear: TransitionHookValidator,
  3364. onAfterAppear: TransitionHookValidator,
  3365. onAppearCancelled: TransitionHookValidator
  3366. },
  3367. setup(props, { slots }) {
  3368. const instance = getCurrentInstance();
  3369. const state = useTransitionState();
  3370. let prevTransitionKey;
  3371. return () => {
  3372. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3373. if (!children || !children.length) {
  3374. return;
  3375. }
  3376. let child = children[0];
  3377. if (children.length > 1) {
  3378. let hasFound = false;
  3379. // locate first non-comment child
  3380. for (const c of children) {
  3381. if (c.type !== Comment) {
  3382. if (hasFound) {
  3383. // warn more than one non-comment child
  3384. warn$1('<transition> can only be used on a single element or component. ' +
  3385. 'Use <transition-group> for lists.');
  3386. break;
  3387. }
  3388. child = c;
  3389. hasFound = true;
  3390. }
  3391. }
  3392. }
  3393. // there's no need to track reactivity for these props so use the raw
  3394. // props for a bit better perf
  3395. const rawProps = toRaw(props);
  3396. const { mode } = rawProps;
  3397. // check mode
  3398. if (mode &&
  3399. mode !== 'in-out' &&
  3400. mode !== 'out-in' &&
  3401. mode !== 'default') {
  3402. warn$1(`invalid <transition> mode: ${mode}`);
  3403. }
  3404. if (state.isLeaving) {
  3405. return emptyPlaceholder(child);
  3406. }
  3407. // in the case of <transition><keep-alive/></transition>, we need to
  3408. // compare the type of the kept-alive children.
  3409. const innerChild = getKeepAliveChild(child);
  3410. if (!innerChild) {
  3411. return emptyPlaceholder(child);
  3412. }
  3413. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  3414. setTransitionHooks(innerChild, enterHooks);
  3415. const oldChild = instance.subTree;
  3416. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3417. let transitionKeyChanged = false;
  3418. const { getTransitionKey } = innerChild.type;
  3419. if (getTransitionKey) {
  3420. const key = getTransitionKey();
  3421. if (prevTransitionKey === undefined) {
  3422. prevTransitionKey = key;
  3423. }
  3424. else if (key !== prevTransitionKey) {
  3425. prevTransitionKey = key;
  3426. transitionKeyChanged = true;
  3427. }
  3428. }
  3429. // handle mode
  3430. if (oldInnerChild &&
  3431. oldInnerChild.type !== Comment &&
  3432. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3433. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  3434. // update old tree's hooks in case of dynamic transition
  3435. setTransitionHooks(oldInnerChild, leavingHooks);
  3436. // switching between different views
  3437. if (mode === 'out-in') {
  3438. state.isLeaving = true;
  3439. // return placeholder node and queue update when leave finishes
  3440. leavingHooks.afterLeave = () => {
  3441. state.isLeaving = false;
  3442. instance.update();
  3443. };
  3444. return emptyPlaceholder(child);
  3445. }
  3446. else if (mode === 'in-out' && innerChild.type !== Comment) {
  3447. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3448. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  3449. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3450. // early removal callback
  3451. el._leaveCb = () => {
  3452. earlyRemove();
  3453. el._leaveCb = undefined;
  3454. delete enterHooks.delayedLeave;
  3455. };
  3456. enterHooks.delayedLeave = delayedLeave;
  3457. };
  3458. }
  3459. }
  3460. return child;
  3461. };
  3462. }
  3463. };
  3464. // export the public type for h/tsx inference
  3465. // also to avoid inline import() in generated d.ts files
  3466. const BaseTransition = BaseTransitionImpl;
  3467. function getLeavingNodesForType(state, vnode) {
  3468. const { leavingVNodes } = state;
  3469. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3470. if (!leavingVNodesCache) {
  3471. leavingVNodesCache = Object.create(null);
  3472. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3473. }
  3474. return leavingVNodesCache;
  3475. }
  3476. // The transition hooks are attached to the vnode as vnode.transition
  3477. // and will be called at appropriate timing in the renderer.
  3478. function resolveTransitionHooks(vnode, props, state, instance) {
  3479. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  3480. const key = String(vnode.key);
  3481. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3482. const callHook = (hook, args) => {
  3483. hook &&
  3484. callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
  3485. };
  3486. const hooks = {
  3487. mode,
  3488. persisted,
  3489. beforeEnter(el) {
  3490. let hook = onBeforeEnter;
  3491. if (!state.isMounted) {
  3492. if (appear) {
  3493. hook = onBeforeAppear || onBeforeEnter;
  3494. }
  3495. else {
  3496. return;
  3497. }
  3498. }
  3499. // for same element (v-show)
  3500. if (el._leaveCb) {
  3501. el._leaveCb(true /* cancelled */);
  3502. }
  3503. // for toggled element with same key (v-if)
  3504. const leavingVNode = leavingVNodesCache[key];
  3505. if (leavingVNode &&
  3506. isSameVNodeType(vnode, leavingVNode) &&
  3507. leavingVNode.el._leaveCb) {
  3508. // force early removal (not cancelled)
  3509. leavingVNode.el._leaveCb();
  3510. }
  3511. callHook(hook, [el]);
  3512. },
  3513. enter(el) {
  3514. let hook = onEnter;
  3515. let afterHook = onAfterEnter;
  3516. let cancelHook = onEnterCancelled;
  3517. if (!state.isMounted) {
  3518. if (appear) {
  3519. hook = onAppear || onEnter;
  3520. afterHook = onAfterAppear || onAfterEnter;
  3521. cancelHook = onAppearCancelled || onEnterCancelled;
  3522. }
  3523. else {
  3524. return;
  3525. }
  3526. }
  3527. let called = false;
  3528. const done = (el._enterCb = (cancelled) => {
  3529. if (called)
  3530. return;
  3531. called = true;
  3532. if (cancelled) {
  3533. callHook(cancelHook, [el]);
  3534. }
  3535. else {
  3536. callHook(afterHook, [el]);
  3537. }
  3538. if (hooks.delayedLeave) {
  3539. hooks.delayedLeave();
  3540. }
  3541. el._enterCb = undefined;
  3542. });
  3543. if (hook) {
  3544. hook(el, done);
  3545. if (hook.length <= 1) {
  3546. done();
  3547. }
  3548. }
  3549. else {
  3550. done();
  3551. }
  3552. },
  3553. leave(el, remove) {
  3554. const key = String(vnode.key);
  3555. if (el._enterCb) {
  3556. el._enterCb(true /* cancelled */);
  3557. }
  3558. if (state.isUnmounting) {
  3559. return remove();
  3560. }
  3561. callHook(onBeforeLeave, [el]);
  3562. let called = false;
  3563. const done = (el._leaveCb = (cancelled) => {
  3564. if (called)
  3565. return;
  3566. called = true;
  3567. remove();
  3568. if (cancelled) {
  3569. callHook(onLeaveCancelled, [el]);
  3570. }
  3571. else {
  3572. callHook(onAfterLeave, [el]);
  3573. }
  3574. el._leaveCb = undefined;
  3575. if (leavingVNodesCache[key] === vnode) {
  3576. delete leavingVNodesCache[key];
  3577. }
  3578. });
  3579. leavingVNodesCache[key] = vnode;
  3580. if (onLeave) {
  3581. onLeave(el, done);
  3582. if (onLeave.length <= 1) {
  3583. done();
  3584. }
  3585. }
  3586. else {
  3587. done();
  3588. }
  3589. },
  3590. clone(vnode) {
  3591. return resolveTransitionHooks(vnode, props, state, instance);
  3592. }
  3593. };
  3594. return hooks;
  3595. }
  3596. // the placeholder really only handles one special case: KeepAlive
  3597. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  3598. // placeholder with empty content to avoid the KeepAlive instance from being
  3599. // unmounted.
  3600. function emptyPlaceholder(vnode) {
  3601. if (isKeepAlive(vnode)) {
  3602. vnode = cloneVNode(vnode);
  3603. vnode.children = null;
  3604. return vnode;
  3605. }
  3606. }
  3607. function getKeepAliveChild(vnode) {
  3608. return isKeepAlive(vnode)
  3609. ? vnode.children
  3610. ? vnode.children[0]
  3611. : undefined
  3612. : vnode;
  3613. }
  3614. function setTransitionHooks(vnode, hooks) {
  3615. if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
  3616. setTransitionHooks(vnode.component.subTree, hooks);
  3617. }
  3618. else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  3619. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3620. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3621. }
  3622. else {
  3623. vnode.transition = hooks;
  3624. }
  3625. }
  3626. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3627. let ret = [];
  3628. let keyedFragmentCount = 0;
  3629. for (let i = 0; i < children.length; i++) {
  3630. let child = children[i];
  3631. // #5360 inherit parent key in case of <template v-for>
  3632. const key = parentKey == null
  3633. ? child.key
  3634. : String(parentKey) + String(child.key != null ? child.key : i);
  3635. // handle fragment children case, e.g. v-for
  3636. if (child.type === Fragment) {
  3637. if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
  3638. keyedFragmentCount++;
  3639. ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
  3640. }
  3641. // comment placeholders should be skipped, e.g. v-if
  3642. else if (keepComment || child.type !== Comment) {
  3643. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3644. }
  3645. }
  3646. // #1126 if a transition children list contains multiple sub fragments, these
  3647. // fragments will be merged into a flat children array. Since each v-for
  3648. // fragment may contain different static bindings inside, we need to de-op
  3649. // these children to force full diffs to ensure correct behavior.
  3650. if (keyedFragmentCount > 1) {
  3651. for (let i = 0; i < ret.length; i++) {
  3652. ret[i].patchFlag = -2 /* BAIL */;
  3653. }
  3654. }
  3655. return ret;
  3656. }
  3657. // implementation, close to no-op
  3658. function defineComponent(options) {
  3659. return isFunction(options) ? { setup: options, name: options.name } : options;
  3660. }
  3661. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3662. function defineAsyncComponent(source) {
  3663. if (isFunction(source)) {
  3664. source = { loader: source };
  3665. }
  3666. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3667. suspensible = true, onError: userOnError } = source;
  3668. let pendingRequest = null;
  3669. let resolvedComp;
  3670. let retries = 0;
  3671. const retry = () => {
  3672. retries++;
  3673. pendingRequest = null;
  3674. return load();
  3675. };
  3676. const load = () => {
  3677. let thisRequest;
  3678. return (pendingRequest ||
  3679. (thisRequest = pendingRequest =
  3680. loader()
  3681. .catch(err => {
  3682. err = err instanceof Error ? err : new Error(String(err));
  3683. if (userOnError) {
  3684. return new Promise((resolve, reject) => {
  3685. const userRetry = () => resolve(retry());
  3686. const userFail = () => reject(err);
  3687. userOnError(err, userRetry, userFail, retries + 1);
  3688. });
  3689. }
  3690. else {
  3691. throw err;
  3692. }
  3693. })
  3694. .then((comp) => {
  3695. if (thisRequest !== pendingRequest && pendingRequest) {
  3696. return pendingRequest;
  3697. }
  3698. if (!comp) {
  3699. warn$1(`Async component loader resolved to undefined. ` +
  3700. `If you are using retry(), make sure to return its return value.`);
  3701. }
  3702. // interop module default
  3703. if (comp &&
  3704. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3705. comp = comp.default;
  3706. }
  3707. if (comp && !isObject(comp) && !isFunction(comp)) {
  3708. throw new Error(`Invalid async component load result: ${comp}`);
  3709. }
  3710. resolvedComp = comp;
  3711. return comp;
  3712. })));
  3713. };
  3714. return defineComponent({
  3715. name: 'AsyncComponentWrapper',
  3716. __asyncLoader: load,
  3717. get __asyncResolved() {
  3718. return resolvedComp;
  3719. },
  3720. setup() {
  3721. const instance = currentInstance;
  3722. // already resolved
  3723. if (resolvedComp) {
  3724. return () => createInnerComp(resolvedComp, instance);
  3725. }
  3726. const onError = (err) => {
  3727. pendingRequest = null;
  3728. handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3729. };
  3730. // suspense-controlled or SSR.
  3731. if ((suspensible && instance.suspense) ||
  3732. (false )) {
  3733. return load()
  3734. .then(comp => {
  3735. return () => createInnerComp(comp, instance);
  3736. })
  3737. .catch(err => {
  3738. onError(err);
  3739. return () => errorComponent
  3740. ? createVNode(errorComponent, {
  3741. error: err
  3742. })
  3743. : null;
  3744. });
  3745. }
  3746. const loaded = ref(false);
  3747. const error = ref();
  3748. const delayed = ref(!!delay);
  3749. if (delay) {
  3750. setTimeout(() => {
  3751. delayed.value = false;
  3752. }, delay);
  3753. }
  3754. if (timeout != null) {
  3755. setTimeout(() => {
  3756. if (!loaded.value && !error.value) {
  3757. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3758. onError(err);
  3759. error.value = err;
  3760. }
  3761. }, timeout);
  3762. }
  3763. load()
  3764. .then(() => {
  3765. loaded.value = true;
  3766. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3767. // parent is keep-alive, force update so the loaded component's
  3768. // name is taken into account
  3769. queueJob(instance.parent.update);
  3770. }
  3771. })
  3772. .catch(err => {
  3773. onError(err);
  3774. error.value = err;
  3775. });
  3776. return () => {
  3777. if (loaded.value && resolvedComp) {
  3778. return createInnerComp(resolvedComp, instance);
  3779. }
  3780. else if (error.value && errorComponent) {
  3781. return createVNode(errorComponent, {
  3782. error: error.value
  3783. });
  3784. }
  3785. else if (loadingComponent && !delayed.value) {
  3786. return createVNode(loadingComponent);
  3787. }
  3788. };
  3789. }
  3790. });
  3791. }
  3792. function createInnerComp(comp, { vnode: { ref, props, children } }) {
  3793. const vnode = createVNode(comp, props, children);
  3794. // ensure inner component inherits the async wrapper's ref owner
  3795. vnode.ref = ref;
  3796. return vnode;
  3797. }
  3798. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3799. const KeepAliveImpl = {
  3800. name: `KeepAlive`,
  3801. // Marker for special handling inside the renderer. We are not using a ===
  3802. // check directly on KeepAlive in the renderer, because importing it directly
  3803. // would prevent it from being tree-shaken.
  3804. __isKeepAlive: true,
  3805. props: {
  3806. include: [String, RegExp, Array],
  3807. exclude: [String, RegExp, Array],
  3808. max: [String, Number]
  3809. },
  3810. setup(props, { slots }) {
  3811. const instance = getCurrentInstance();
  3812. // KeepAlive communicates with the instantiated renderer via the
  3813. // ctx where the renderer passes in its internals,
  3814. // and the KeepAlive instance exposes activate/deactivate implementations.
  3815. // The whole point of this is to avoid importing KeepAlive directly in the
  3816. // renderer to facilitate tree-shaking.
  3817. const sharedContext = instance.ctx;
  3818. // if the internal renderer is not registered, it indicates that this is server-side rendering,
  3819. // for KeepAlive, we just need to render its children
  3820. if (!sharedContext.renderer) {
  3821. return slots.default;
  3822. }
  3823. const cache = new Map();
  3824. const keys = new Set();
  3825. let current = null;
  3826. {
  3827. instance.__v_cache = cache;
  3828. }
  3829. const parentSuspense = instance.suspense;
  3830. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  3831. const storageContainer = createElement('div');
  3832. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3833. const instance = vnode.component;
  3834. move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
  3835. // in case props have changed
  3836. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  3837. queuePostRenderEffect(() => {
  3838. instance.isDeactivated = false;
  3839. if (instance.a) {
  3840. invokeArrayFns(instance.a);
  3841. }
  3842. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3843. if (vnodeHook) {
  3844. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3845. }
  3846. }, parentSuspense);
  3847. {
  3848. // Update components tree
  3849. devtoolsComponentAdded(instance);
  3850. }
  3851. };
  3852. sharedContext.deactivate = (vnode) => {
  3853. const instance = vnode.component;
  3854. move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
  3855. queuePostRenderEffect(() => {
  3856. if (instance.da) {
  3857. invokeArrayFns(instance.da);
  3858. }
  3859. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3860. if (vnodeHook) {
  3861. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3862. }
  3863. instance.isDeactivated = true;
  3864. }, parentSuspense);
  3865. {
  3866. // Update components tree
  3867. devtoolsComponentAdded(instance);
  3868. }
  3869. };
  3870. function unmount(vnode) {
  3871. // reset the shapeFlag so it can be properly unmounted
  3872. resetShapeFlag(vnode);
  3873. _unmount(vnode, instance, parentSuspense, true);
  3874. }
  3875. function pruneCache(filter) {
  3876. cache.forEach((vnode, key) => {
  3877. const name = getComponentName(vnode.type);
  3878. if (name && (!filter || !filter(name))) {
  3879. pruneCacheEntry(key);
  3880. }
  3881. });
  3882. }
  3883. function pruneCacheEntry(key) {
  3884. const cached = cache.get(key);
  3885. if (!current || cached.type !== current.type) {
  3886. unmount(cached);
  3887. }
  3888. else if (current) {
  3889. // current active instance should no longer be kept-alive.
  3890. // we can't unmount it now but it might be later, so reset its flag now.
  3891. resetShapeFlag(current);
  3892. }
  3893. cache.delete(key);
  3894. keys.delete(key);
  3895. }
  3896. // prune cache on include/exclude prop change
  3897. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  3898. include && pruneCache(name => matches(include, name));
  3899. exclude && pruneCache(name => !matches(exclude, name));
  3900. },
  3901. // prune post-render after `current` has been updated
  3902. { flush: 'post', deep: true });
  3903. // cache sub tree after render
  3904. let pendingCacheKey = null;
  3905. const cacheSubtree = () => {
  3906. // fix #1621, the pendingCacheKey could be 0
  3907. if (pendingCacheKey != null) {
  3908. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3909. }
  3910. };
  3911. onMounted(cacheSubtree);
  3912. onUpdated(cacheSubtree);
  3913. onBeforeUnmount(() => {
  3914. cache.forEach(cached => {
  3915. const { subTree, suspense } = instance;
  3916. const vnode = getInnerChild(subTree);
  3917. if (cached.type === vnode.type) {
  3918. // current instance will be unmounted as part of keep-alive's unmount
  3919. resetShapeFlag(vnode);
  3920. // but invoke its deactivated hook here
  3921. const da = vnode.component.da;
  3922. da && queuePostRenderEffect(da, suspense);
  3923. return;
  3924. }
  3925. unmount(cached);
  3926. });
  3927. });
  3928. return () => {
  3929. pendingCacheKey = null;
  3930. if (!slots.default) {
  3931. return null;
  3932. }
  3933. const children = slots.default();
  3934. const rawVNode = children[0];
  3935. if (children.length > 1) {
  3936. {
  3937. warn$1(`KeepAlive should contain exactly one component child.`);
  3938. }
  3939. current = null;
  3940. return children;
  3941. }
  3942. else if (!isVNode(rawVNode) ||
  3943. (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
  3944. !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
  3945. current = null;
  3946. return rawVNode;
  3947. }
  3948. let vnode = getInnerChild(rawVNode);
  3949. const comp = vnode.type;
  3950. // for async components, name check should be based in its loaded
  3951. // inner component if available
  3952. const name = getComponentName(isAsyncWrapper(vnode)
  3953. ? vnode.type.__asyncResolved || {}
  3954. : comp);
  3955. const { include, exclude, max } = props;
  3956. if ((include && (!name || !matches(include, name))) ||
  3957. (exclude && name && matches(exclude, name))) {
  3958. current = vnode;
  3959. return rawVNode;
  3960. }
  3961. const key = vnode.key == null ? comp : vnode.key;
  3962. const cachedVNode = cache.get(key);
  3963. // clone vnode if it's reused because we are going to mutate it
  3964. if (vnode.el) {
  3965. vnode = cloneVNode(vnode);
  3966. if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
  3967. rawVNode.ssContent = vnode;
  3968. }
  3969. }
  3970. // #1513 it's possible for the returned vnode to be cloned due to attr
  3971. // fallthrough or scopeId, so the vnode here may not be the final vnode
  3972. // that is mounted. Instead of caching it directly, we store the pending
  3973. // key and cache `instance.subTree` (the normalized vnode) in
  3974. // beforeMount/beforeUpdate hooks.
  3975. pendingCacheKey = key;
  3976. if (cachedVNode) {
  3977. // copy over mounted state
  3978. vnode.el = cachedVNode.el;
  3979. vnode.component = cachedVNode.component;
  3980. if (vnode.transition) {
  3981. // recursively update transition hooks on subTree
  3982. setTransitionHooks(vnode, vnode.transition);
  3983. }
  3984. // avoid vnode being mounted as fresh
  3985. vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
  3986. // make this key the freshest
  3987. keys.delete(key);
  3988. keys.add(key);
  3989. }
  3990. else {
  3991. keys.add(key);
  3992. // prune oldest entry
  3993. if (max && keys.size > parseInt(max, 10)) {
  3994. pruneCacheEntry(keys.values().next().value);
  3995. }
  3996. }
  3997. // avoid vnode being unmounted
  3998. vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  3999. current = vnode;
  4000. return rawVNode;
  4001. };
  4002. }
  4003. };
  4004. // export the public type for h/tsx inference
  4005. // also to avoid inline import() in generated d.ts files
  4006. const KeepAlive = KeepAliveImpl;
  4007. function matches(pattern, name) {
  4008. if (isArray(pattern)) {
  4009. return pattern.some((p) => matches(p, name));
  4010. }
  4011. else if (isString(pattern)) {
  4012. return pattern.split(',').includes(name);
  4013. }
  4014. else if (pattern.test) {
  4015. return pattern.test(name);
  4016. }
  4017. /* istanbul ignore next */
  4018. return false;
  4019. }
  4020. function onActivated(hook, target) {
  4021. registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
  4022. }
  4023. function onDeactivated(hook, target) {
  4024. registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
  4025. }
  4026. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4027. // cache the deactivate branch check wrapper for injected hooks so the same
  4028. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  4029. // deactivation check".
  4030. const wrappedHook = hook.__wdc ||
  4031. (hook.__wdc = () => {
  4032. // only fire the hook if the target instance is NOT in a deactivated branch.
  4033. let current = target;
  4034. while (current) {
  4035. if (current.isDeactivated) {
  4036. return;
  4037. }
  4038. current = current.parent;
  4039. }
  4040. return hook();
  4041. });
  4042. injectHook(type, wrappedHook, target);
  4043. // In addition to registering it on the target instance, we walk up the parent
  4044. // chain and register it on all ancestor instances that are keep-alive roots.
  4045. // This avoids the need to walk the entire component tree when invoking these
  4046. // hooks, and more importantly, avoids the need to track child components in
  4047. // arrays.
  4048. if (target) {
  4049. let current = target.parent;
  4050. while (current && current.parent) {
  4051. if (isKeepAlive(current.parent.vnode)) {
  4052. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4053. }
  4054. current = current.parent;
  4055. }
  4056. }
  4057. }
  4058. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4059. // injectHook wraps the original for error handling, so make sure to remove
  4060. // the wrapped version.
  4061. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  4062. onUnmounted(() => {
  4063. remove(keepAliveRoot[type], injected);
  4064. }, target);
  4065. }
  4066. function resetShapeFlag(vnode) {
  4067. let shapeFlag = vnode.shapeFlag;
  4068. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  4069. shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4070. }
  4071. if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  4072. shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
  4073. }
  4074. vnode.shapeFlag = shapeFlag;
  4075. }
  4076. function getInnerChild(vnode) {
  4077. return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
  4078. }
  4079. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4080. if (target) {
  4081. const hooks = target[type] || (target[type] = []);
  4082. // cache the error handling wrapper for injected hooks so the same hook
  4083. // can be properly deduped by the scheduler. "__weh" stands for "with error
  4084. // handling".
  4085. const wrappedHook = hook.__weh ||
  4086. (hook.__weh = (...args) => {
  4087. if (target.isUnmounted) {
  4088. return;
  4089. }
  4090. // disable tracking inside all lifecycle hooks
  4091. // since they can potentially be called inside effects.
  4092. pauseTracking();
  4093. // Set currentInstance during hook invocation.
  4094. // This assumes the hook does not synchronously trigger other hooks, which
  4095. // can only be false when the user does something really funky.
  4096. setCurrentInstance(target);
  4097. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4098. unsetCurrentInstance();
  4099. resetTracking();
  4100. return res;
  4101. });
  4102. if (prepend) {
  4103. hooks.unshift(wrappedHook);
  4104. }
  4105. else {
  4106. hooks.push(wrappedHook);
  4107. }
  4108. return wrappedHook;
  4109. }
  4110. else {
  4111. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  4112. warn$1(`${apiName} is called when there is no active component instance to be ` +
  4113. `associated with. ` +
  4114. `Lifecycle injection APIs can only be used during execution of setup().` +
  4115. (` If you are using async setup(), make sure to register lifecycle ` +
  4116. `hooks before the first await statement.`
  4117. ));
  4118. }
  4119. }
  4120. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  4121. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4122. (!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&
  4123. injectHook(lifecycle, hook, target);
  4124. const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
  4125. const onMounted = createHook("m" /* MOUNTED */);
  4126. const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
  4127. const onUpdated = createHook("u" /* UPDATED */);
  4128. const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
  4129. const onUnmounted = createHook("um" /* UNMOUNTED */);
  4130. const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);
  4131. const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
  4132. const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
  4133. function onErrorCaptured(hook, target = currentInstance) {
  4134. injectHook("ec" /* ERROR_CAPTURED */, hook, target);
  4135. }
  4136. function createDuplicateChecker() {
  4137. const cache = Object.create(null);
  4138. return (type, key) => {
  4139. if (cache[key]) {
  4140. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4141. }
  4142. else {
  4143. cache[key] = type;
  4144. }
  4145. };
  4146. }
  4147. let shouldCacheAccess = true;
  4148. function applyOptions(instance) {
  4149. const options = resolveMergedOptions(instance);
  4150. const publicThis = instance.proxy;
  4151. const ctx = instance.ctx;
  4152. // do not cache property access on public proxy during state initialization
  4153. shouldCacheAccess = false;
  4154. // call beforeCreate first before accessing other options since
  4155. // the hook may mutate resolved options (#2791)
  4156. if (options.beforeCreate) {
  4157. callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
  4158. }
  4159. const {
  4160. // state
  4161. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  4162. // lifecycle
  4163. created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
  4164. // public API
  4165. expose, inheritAttrs,
  4166. // assets
  4167. components, directives, filters } = options;
  4168. const checkDuplicateProperties = createDuplicateChecker() ;
  4169. {
  4170. const [propsOptions] = instance.propsOptions;
  4171. if (propsOptions) {
  4172. for (const key in propsOptions) {
  4173. checkDuplicateProperties("Props" /* PROPS */, key);
  4174. }
  4175. }
  4176. }
  4177. // options initialization order (to be consistent with Vue 2):
  4178. // - props (already done outside of this function)
  4179. // - inject
  4180. // - methods
  4181. // - data (deferred since it relies on `this` access)
  4182. // - computed
  4183. // - watch (deferred since it relies on `this` access)
  4184. if (injectOptions) {
  4185. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  4186. }
  4187. if (methods) {
  4188. for (const key in methods) {
  4189. const methodHandler = methods[key];
  4190. if (isFunction(methodHandler)) {
  4191. // In dev mode, we use the `createRenderContext` function to define
  4192. // methods to the proxy target, and those are read-only but
  4193. // reconfigurable, so it needs to be redefined here
  4194. {
  4195. Object.defineProperty(ctx, key, {
  4196. value: methodHandler.bind(publicThis),
  4197. configurable: true,
  4198. enumerable: true,
  4199. writable: true
  4200. });
  4201. }
  4202. {
  4203. checkDuplicateProperties("Methods" /* METHODS */, key);
  4204. }
  4205. }
  4206. else {
  4207. warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  4208. `Did you reference the function correctly?`);
  4209. }
  4210. }
  4211. }
  4212. if (dataOptions) {
  4213. if (!isFunction(dataOptions)) {
  4214. warn$1(`The data option must be a function. ` +
  4215. `Plain object usage is no longer supported.`);
  4216. }
  4217. const data = dataOptions.call(publicThis, publicThis);
  4218. if (isPromise(data)) {
  4219. warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
  4220. `intend to perform data fetching before component renders, use ` +
  4221. `async setup() + <Suspense>.`);
  4222. }
  4223. if (!isObject(data)) {
  4224. warn$1(`data() should return an object.`);
  4225. }
  4226. else {
  4227. instance.data = reactive(data);
  4228. {
  4229. for (const key in data) {
  4230. checkDuplicateProperties("Data" /* DATA */, key);
  4231. // expose data on ctx during dev
  4232. if (key[0] !== '$' && key[0] !== '_') {
  4233. Object.defineProperty(ctx, key, {
  4234. configurable: true,
  4235. enumerable: true,
  4236. get: () => data[key],
  4237. set: NOOP
  4238. });
  4239. }
  4240. }
  4241. }
  4242. }
  4243. }
  4244. // state initialization complete at this point - start caching access
  4245. shouldCacheAccess = true;
  4246. if (computedOptions) {
  4247. for (const key in computedOptions) {
  4248. const opt = computedOptions[key];
  4249. const get = isFunction(opt)
  4250. ? opt.bind(publicThis, publicThis)
  4251. : isFunction(opt.get)
  4252. ? opt.get.bind(publicThis, publicThis)
  4253. : NOOP;
  4254. if (get === NOOP) {
  4255. warn$1(`Computed property "${key}" has no getter.`);
  4256. }
  4257. const set = !isFunction(opt) && isFunction(opt.set)
  4258. ? opt.set.bind(publicThis)
  4259. : () => {
  4260. warn$1(`Write operation failed: computed property "${key}" is readonly.`);
  4261. }
  4262. ;
  4263. const c = computed$1({
  4264. get,
  4265. set
  4266. });
  4267. Object.defineProperty(ctx, key, {
  4268. enumerable: true,
  4269. configurable: true,
  4270. get: () => c.value,
  4271. set: v => (c.value = v)
  4272. });
  4273. {
  4274. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  4275. }
  4276. }
  4277. }
  4278. if (watchOptions) {
  4279. for (const key in watchOptions) {
  4280. createWatcher(watchOptions[key], ctx, publicThis, key);
  4281. }
  4282. }
  4283. if (provideOptions) {
  4284. const provides = isFunction(provideOptions)
  4285. ? provideOptions.call(publicThis)
  4286. : provideOptions;
  4287. Reflect.ownKeys(provides).forEach(key => {
  4288. provide(key, provides[key]);
  4289. });
  4290. }
  4291. if (created) {
  4292. callHook(created, instance, "c" /* CREATED */);
  4293. }
  4294. function registerLifecycleHook(register, hook) {
  4295. if (isArray(hook)) {
  4296. hook.forEach(_hook => register(_hook.bind(publicThis)));
  4297. }
  4298. else if (hook) {
  4299. register(hook.bind(publicThis));
  4300. }
  4301. }
  4302. registerLifecycleHook(onBeforeMount, beforeMount);
  4303. registerLifecycleHook(onMounted, mounted);
  4304. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4305. registerLifecycleHook(onUpdated, updated);
  4306. registerLifecycleHook(onActivated, activated);
  4307. registerLifecycleHook(onDeactivated, deactivated);
  4308. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4309. registerLifecycleHook(onRenderTracked, renderTracked);
  4310. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4311. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4312. registerLifecycleHook(onUnmounted, unmounted);
  4313. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4314. if (isArray(expose)) {
  4315. if (expose.length) {
  4316. const exposed = instance.exposed || (instance.exposed = {});
  4317. expose.forEach(key => {
  4318. Object.defineProperty(exposed, key, {
  4319. get: () => publicThis[key],
  4320. set: val => (publicThis[key] = val)
  4321. });
  4322. });
  4323. }
  4324. else if (!instance.exposed) {
  4325. instance.exposed = {};
  4326. }
  4327. }
  4328. // options that are handled when creating the instance but also need to be
  4329. // applied from mixins
  4330. if (render && instance.render === NOOP) {
  4331. instance.render = render;
  4332. }
  4333. if (inheritAttrs != null) {
  4334. instance.inheritAttrs = inheritAttrs;
  4335. }
  4336. // asset options.
  4337. if (components)
  4338. instance.components = components;
  4339. if (directives)
  4340. instance.directives = directives;
  4341. }
  4342. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
  4343. if (isArray(injectOptions)) {
  4344. injectOptions = normalizeInject(injectOptions);
  4345. }
  4346. for (const key in injectOptions) {
  4347. const opt = injectOptions[key];
  4348. let injected;
  4349. if (isObject(opt)) {
  4350. if ('default' in opt) {
  4351. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  4352. }
  4353. else {
  4354. injected = inject(opt.from || key);
  4355. }
  4356. }
  4357. else {
  4358. injected = inject(opt);
  4359. }
  4360. if (isRef(injected)) {
  4361. // TODO remove the check in 3.3
  4362. if (unwrapRef) {
  4363. Object.defineProperty(ctx, key, {
  4364. enumerable: true,
  4365. configurable: true,
  4366. get: () => injected.value,
  4367. set: v => (injected.value = v)
  4368. });
  4369. }
  4370. else {
  4371. {
  4372. warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
  4373. `and no longer needs \`.value\` in the next minor release. ` +
  4374. `To opt-in to the new behavior now, ` +
  4375. `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
  4376. `temporary and will not be needed in the future.)`);
  4377. }
  4378. ctx[key] = injected;
  4379. }
  4380. }
  4381. else {
  4382. ctx[key] = injected;
  4383. }
  4384. {
  4385. checkDuplicateProperties("Inject" /* INJECT */, key);
  4386. }
  4387. }
  4388. }
  4389. function callHook(hook, instance, type) {
  4390. callWithAsyncErrorHandling(isArray(hook)
  4391. ? hook.map(h => h.bind(instance.proxy))
  4392. : hook.bind(instance.proxy), instance, type);
  4393. }
  4394. function createWatcher(raw, ctx, publicThis, key) {
  4395. const getter = key.includes('.')
  4396. ? createPathGetter(publicThis, key)
  4397. : () => publicThis[key];
  4398. if (isString(raw)) {
  4399. const handler = ctx[raw];
  4400. if (isFunction(handler)) {
  4401. watch(getter, handler);
  4402. }
  4403. else {
  4404. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  4405. }
  4406. }
  4407. else if (isFunction(raw)) {
  4408. watch(getter, raw.bind(publicThis));
  4409. }
  4410. else if (isObject(raw)) {
  4411. if (isArray(raw)) {
  4412. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  4413. }
  4414. else {
  4415. const handler = isFunction(raw.handler)
  4416. ? raw.handler.bind(publicThis)
  4417. : ctx[raw.handler];
  4418. if (isFunction(handler)) {
  4419. watch(getter, handler, raw);
  4420. }
  4421. else {
  4422. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  4423. }
  4424. }
  4425. }
  4426. else {
  4427. warn$1(`Invalid watch option: "${key}"`, raw);
  4428. }
  4429. }
  4430. /**
  4431. * Resolve merged options and cache it on the component.
  4432. * This is done only once per-component since the merging does not involve
  4433. * instances.
  4434. */
  4435. function resolveMergedOptions(instance) {
  4436. const base = instance.type;
  4437. const { mixins, extends: extendsOptions } = base;
  4438. const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
  4439. const cached = cache.get(base);
  4440. let resolved;
  4441. if (cached) {
  4442. resolved = cached;
  4443. }
  4444. else if (!globalMixins.length && !mixins && !extendsOptions) {
  4445. {
  4446. resolved = base;
  4447. }
  4448. }
  4449. else {
  4450. resolved = {};
  4451. if (globalMixins.length) {
  4452. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  4453. }
  4454. mergeOptions(resolved, base, optionMergeStrategies);
  4455. }
  4456. cache.set(base, resolved);
  4457. return resolved;
  4458. }
  4459. function mergeOptions(to, from, strats, asMixin = false) {
  4460. const { mixins, extends: extendsOptions } = from;
  4461. if (extendsOptions) {
  4462. mergeOptions(to, extendsOptions, strats, true);
  4463. }
  4464. if (mixins) {
  4465. mixins.forEach((m) => mergeOptions(to, m, strats, true));
  4466. }
  4467. for (const key in from) {
  4468. if (asMixin && key === 'expose') {
  4469. warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
  4470. `It should only be declared in the base component itself.`);
  4471. }
  4472. else {
  4473. const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
  4474. to[key] = strat ? strat(to[key], from[key]) : from[key];
  4475. }
  4476. }
  4477. return to;
  4478. }
  4479. const internalOptionMergeStrats = {
  4480. data: mergeDataFn,
  4481. props: mergeObjectOptions,
  4482. emits: mergeObjectOptions,
  4483. // objects
  4484. methods: mergeObjectOptions,
  4485. computed: mergeObjectOptions,
  4486. // lifecycle
  4487. beforeCreate: mergeAsArray,
  4488. created: mergeAsArray,
  4489. beforeMount: mergeAsArray,
  4490. mounted: mergeAsArray,
  4491. beforeUpdate: mergeAsArray,
  4492. updated: mergeAsArray,
  4493. beforeDestroy: mergeAsArray,
  4494. beforeUnmount: mergeAsArray,
  4495. destroyed: mergeAsArray,
  4496. unmounted: mergeAsArray,
  4497. activated: mergeAsArray,
  4498. deactivated: mergeAsArray,
  4499. errorCaptured: mergeAsArray,
  4500. serverPrefetch: mergeAsArray,
  4501. // assets
  4502. components: mergeObjectOptions,
  4503. directives: mergeObjectOptions,
  4504. // watch
  4505. watch: mergeWatchOptions,
  4506. // provide / inject
  4507. provide: mergeDataFn,
  4508. inject: mergeInject
  4509. };
  4510. function mergeDataFn(to, from) {
  4511. if (!from) {
  4512. return to;
  4513. }
  4514. if (!to) {
  4515. return from;
  4516. }
  4517. return function mergedDataFn() {
  4518. return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  4519. };
  4520. }
  4521. function mergeInject(to, from) {
  4522. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  4523. }
  4524. function normalizeInject(raw) {
  4525. if (isArray(raw)) {
  4526. const res = {};
  4527. for (let i = 0; i < raw.length; i++) {
  4528. res[raw[i]] = raw[i];
  4529. }
  4530. return res;
  4531. }
  4532. return raw;
  4533. }
  4534. function mergeAsArray(to, from) {
  4535. return to ? [...new Set([].concat(to, from))] : from;
  4536. }
  4537. function mergeObjectOptions(to, from) {
  4538. return to ? extend(extend(Object.create(null), to), from) : from;
  4539. }
  4540. function mergeWatchOptions(to, from) {
  4541. if (!to)
  4542. return from;
  4543. if (!from)
  4544. return to;
  4545. const merged = extend(Object.create(null), to);
  4546. for (const key in from) {
  4547. merged[key] = mergeAsArray(to[key], from[key]);
  4548. }
  4549. return merged;
  4550. }
  4551. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  4552. isSSR = false) {
  4553. const props = {};
  4554. const attrs = {};
  4555. def(attrs, InternalObjectKey, 1);
  4556. instance.propsDefaults = Object.create(null);
  4557. setFullProps(instance, rawProps, props, attrs);
  4558. // ensure all declared prop keys are present
  4559. for (const key in instance.propsOptions[0]) {
  4560. if (!(key in props)) {
  4561. props[key] = undefined;
  4562. }
  4563. }
  4564. // validation
  4565. {
  4566. validateProps(rawProps || {}, props, instance);
  4567. }
  4568. if (isStateful) {
  4569. // stateful
  4570. instance.props = isSSR ? props : shallowReactive(props);
  4571. }
  4572. else {
  4573. if (!instance.type.props) {
  4574. // functional w/ optional props, props === attrs
  4575. instance.props = attrs;
  4576. }
  4577. else {
  4578. // functional w/ declared props
  4579. instance.props = props;
  4580. }
  4581. }
  4582. instance.attrs = attrs;
  4583. }
  4584. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  4585. const { props, attrs, vnode: { patchFlag } } = instance;
  4586. const rawCurrentProps = toRaw(props);
  4587. const [options] = instance.propsOptions;
  4588. let hasAttrsChanged = false;
  4589. if (
  4590. // always force full diff in dev
  4591. // - #1942 if hmr is enabled with sfc component
  4592. // - vite#872 non-sfc component used by sfc component
  4593. !((instance.type.__hmrId ||
  4594. (instance.parent && instance.parent.type.__hmrId))) &&
  4595. (optimized || patchFlag > 0) &&
  4596. !(patchFlag & 16 /* FULL_PROPS */)) {
  4597. if (patchFlag & 8 /* PROPS */) {
  4598. // Compiler-generated props & no keys change, just set the updated
  4599. // the props.
  4600. const propsToUpdate = instance.vnode.dynamicProps;
  4601. for (let i = 0; i < propsToUpdate.length; i++) {
  4602. let key = propsToUpdate[i];
  4603. // skip if the prop key is a declared emit event listener
  4604. if (isEmitListener(instance.emitsOptions, key)) {
  4605. continue;
  4606. }
  4607. // PROPS flag guarantees rawProps to be non-null
  4608. const value = rawProps[key];
  4609. if (options) {
  4610. // attr / props separation was done on init and will be consistent
  4611. // in this code path, so just check if attrs have it.
  4612. if (hasOwn(attrs, key)) {
  4613. if (value !== attrs[key]) {
  4614. attrs[key] = value;
  4615. hasAttrsChanged = true;
  4616. }
  4617. }
  4618. else {
  4619. const camelizedKey = camelize(key);
  4620. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  4621. }
  4622. }
  4623. else {
  4624. if (value !== attrs[key]) {
  4625. attrs[key] = value;
  4626. hasAttrsChanged = true;
  4627. }
  4628. }
  4629. }
  4630. }
  4631. }
  4632. else {
  4633. // full props update.
  4634. if (setFullProps(instance, rawProps, props, attrs)) {
  4635. hasAttrsChanged = true;
  4636. }
  4637. // in case of dynamic props, check if we need to delete keys from
  4638. // the props object
  4639. let kebabKey;
  4640. for (const key in rawCurrentProps) {
  4641. if (!rawProps ||
  4642. // for camelCase
  4643. (!hasOwn(rawProps, key) &&
  4644. // it's possible the original props was passed in as kebab-case
  4645. // and converted to camelCase (#955)
  4646. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  4647. if (options) {
  4648. if (rawPrevProps &&
  4649. // for camelCase
  4650. (rawPrevProps[key] !== undefined ||
  4651. // for kebab-case
  4652. rawPrevProps[kebabKey] !== undefined)) {
  4653. props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
  4654. }
  4655. }
  4656. else {
  4657. delete props[key];
  4658. }
  4659. }
  4660. }
  4661. // in the case of functional component w/o props declaration, props and
  4662. // attrs point to the same object so it should already have been updated.
  4663. if (attrs !== rawCurrentProps) {
  4664. for (const key in attrs) {
  4665. if (!rawProps ||
  4666. (!hasOwn(rawProps, key) &&
  4667. (!false ))) {
  4668. delete attrs[key];
  4669. hasAttrsChanged = true;
  4670. }
  4671. }
  4672. }
  4673. }
  4674. // trigger updates for $attrs in case it's used in component slots
  4675. if (hasAttrsChanged) {
  4676. trigger(instance, "set" /* SET */, '$attrs');
  4677. }
  4678. {
  4679. validateProps(rawProps || {}, props, instance);
  4680. }
  4681. }
  4682. function setFullProps(instance, rawProps, props, attrs) {
  4683. const [options, needCastKeys] = instance.propsOptions;
  4684. let hasAttrsChanged = false;
  4685. let rawCastValues;
  4686. if (rawProps) {
  4687. for (let key in rawProps) {
  4688. // key, ref are reserved and never passed down
  4689. if (isReservedProp(key)) {
  4690. continue;
  4691. }
  4692. const value = rawProps[key];
  4693. // prop option names are camelized during normalization, so to support
  4694. // kebab -> camel conversion here we need to camelize the key.
  4695. let camelKey;
  4696. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  4697. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  4698. props[camelKey] = value;
  4699. }
  4700. else {
  4701. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  4702. }
  4703. }
  4704. else if (!isEmitListener(instance.emitsOptions, key)) {
  4705. if (!(key in attrs) || value !== attrs[key]) {
  4706. attrs[key] = value;
  4707. hasAttrsChanged = true;
  4708. }
  4709. }
  4710. }
  4711. }
  4712. if (needCastKeys) {
  4713. const rawCurrentProps = toRaw(props);
  4714. const castValues = rawCastValues || EMPTY_OBJ;
  4715. for (let i = 0; i < needCastKeys.length; i++) {
  4716. const key = needCastKeys[i];
  4717. props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
  4718. }
  4719. }
  4720. return hasAttrsChanged;
  4721. }
  4722. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  4723. const opt = options[key];
  4724. if (opt != null) {
  4725. const hasDefault = hasOwn(opt, 'default');
  4726. // default values
  4727. if (hasDefault && value === undefined) {
  4728. const defaultValue = opt.default;
  4729. if (opt.type !== Function && isFunction(defaultValue)) {
  4730. const { propsDefaults } = instance;
  4731. if (key in propsDefaults) {
  4732. value = propsDefaults[key];
  4733. }
  4734. else {
  4735. setCurrentInstance(instance);
  4736. value = propsDefaults[key] = defaultValue.call(null, props);
  4737. unsetCurrentInstance();
  4738. }
  4739. }
  4740. else {
  4741. value = defaultValue;
  4742. }
  4743. }
  4744. // boolean casting
  4745. if (opt[0 /* shouldCast */]) {
  4746. if (isAbsent && !hasDefault) {
  4747. value = false;
  4748. }
  4749. else if (opt[1 /* shouldCastTrue */] &&
  4750. (value === '' || value === hyphenate(key))) {
  4751. value = true;
  4752. }
  4753. }
  4754. }
  4755. return value;
  4756. }
  4757. function normalizePropsOptions(comp, appContext, asMixin = false) {
  4758. const cache = appContext.propsCache;
  4759. const cached = cache.get(comp);
  4760. if (cached) {
  4761. return cached;
  4762. }
  4763. const raw = comp.props;
  4764. const normalized = {};
  4765. const needCastKeys = [];
  4766. // apply mixin/extends props
  4767. let hasExtends = false;
  4768. if (!isFunction(comp)) {
  4769. const extendProps = (raw) => {
  4770. hasExtends = true;
  4771. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  4772. extend(normalized, props);
  4773. if (keys)
  4774. needCastKeys.push(...keys);
  4775. };
  4776. if (!asMixin && appContext.mixins.length) {
  4777. appContext.mixins.forEach(extendProps);
  4778. }
  4779. if (comp.extends) {
  4780. extendProps(comp.extends);
  4781. }
  4782. if (comp.mixins) {
  4783. comp.mixins.forEach(extendProps);
  4784. }
  4785. }
  4786. if (!raw && !hasExtends) {
  4787. cache.set(comp, EMPTY_ARR);
  4788. return EMPTY_ARR;
  4789. }
  4790. if (isArray(raw)) {
  4791. for (let i = 0; i < raw.length; i++) {
  4792. if (!isString(raw[i])) {
  4793. warn$1(`props must be strings when using array syntax.`, raw[i]);
  4794. }
  4795. const normalizedKey = camelize(raw[i]);
  4796. if (validatePropName(normalizedKey)) {
  4797. normalized[normalizedKey] = EMPTY_OBJ;
  4798. }
  4799. }
  4800. }
  4801. else if (raw) {
  4802. if (!isObject(raw)) {
  4803. warn$1(`invalid props options`, raw);
  4804. }
  4805. for (const key in raw) {
  4806. const normalizedKey = camelize(key);
  4807. if (validatePropName(normalizedKey)) {
  4808. const opt = raw[key];
  4809. const prop = (normalized[normalizedKey] =
  4810. isArray(opt) || isFunction(opt) ? { type: opt } : opt);
  4811. if (prop) {
  4812. const booleanIndex = getTypeIndex(Boolean, prop.type);
  4813. const stringIndex = getTypeIndex(String, prop.type);
  4814. prop[0 /* shouldCast */] = booleanIndex > -1;
  4815. prop[1 /* shouldCastTrue */] =
  4816. stringIndex < 0 || booleanIndex < stringIndex;
  4817. // if the prop needs boolean casting or default value
  4818. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  4819. needCastKeys.push(normalizedKey);
  4820. }
  4821. }
  4822. }
  4823. }
  4824. }
  4825. const res = [normalized, needCastKeys];
  4826. cache.set(comp, res);
  4827. return res;
  4828. }
  4829. function validatePropName(key) {
  4830. if (key[0] !== '$') {
  4831. return true;
  4832. }
  4833. else {
  4834. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  4835. }
  4836. return false;
  4837. }
  4838. // use function string name to check type constructors
  4839. // so that it works across vms / iframes.
  4840. function getType(ctor) {
  4841. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  4842. return match ? match[1] : ctor === null ? 'null' : '';
  4843. }
  4844. function isSameType(a, b) {
  4845. return getType(a) === getType(b);
  4846. }
  4847. function getTypeIndex(type, expectedTypes) {
  4848. if (isArray(expectedTypes)) {
  4849. return expectedTypes.findIndex(t => isSameType(t, type));
  4850. }
  4851. else if (isFunction(expectedTypes)) {
  4852. return isSameType(expectedTypes, type) ? 0 : -1;
  4853. }
  4854. return -1;
  4855. }
  4856. /**
  4857. * dev only
  4858. */
  4859. function validateProps(rawProps, props, instance) {
  4860. const resolvedValues = toRaw(props);
  4861. const options = instance.propsOptions[0];
  4862. for (const key in options) {
  4863. let opt = options[key];
  4864. if (opt == null)
  4865. continue;
  4866. validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
  4867. }
  4868. }
  4869. /**
  4870. * dev only
  4871. */
  4872. function validateProp(name, value, prop, isAbsent) {
  4873. const { type, required, validator } = prop;
  4874. // required!
  4875. if (required && isAbsent) {
  4876. warn$1('Missing required prop: "' + name + '"');
  4877. return;
  4878. }
  4879. // missing but optional
  4880. if (value == null && !prop.required) {
  4881. return;
  4882. }
  4883. // type check
  4884. if (type != null && type !== true) {
  4885. let isValid = false;
  4886. const types = isArray(type) ? type : [type];
  4887. const expectedTypes = [];
  4888. // value is valid as long as one of the specified types match
  4889. for (let i = 0; i < types.length && !isValid; i++) {
  4890. const { valid, expectedType } = assertType(value, types[i]);
  4891. expectedTypes.push(expectedType || '');
  4892. isValid = valid;
  4893. }
  4894. if (!isValid) {
  4895. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  4896. return;
  4897. }
  4898. }
  4899. // custom validator
  4900. if (validator && !validator(value)) {
  4901. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  4902. }
  4903. }
  4904. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  4905. /**
  4906. * dev only
  4907. */
  4908. function assertType(value, type) {
  4909. let valid;
  4910. const expectedType = getType(type);
  4911. if (isSimpleType(expectedType)) {
  4912. const t = typeof value;
  4913. valid = t === expectedType.toLowerCase();
  4914. // for primitive wrapper objects
  4915. if (!valid && t === 'object') {
  4916. valid = value instanceof type;
  4917. }
  4918. }
  4919. else if (expectedType === 'Object') {
  4920. valid = isObject(value);
  4921. }
  4922. else if (expectedType === 'Array') {
  4923. valid = isArray(value);
  4924. }
  4925. else if (expectedType === 'null') {
  4926. valid = value === null;
  4927. }
  4928. else {
  4929. valid = value instanceof type;
  4930. }
  4931. return {
  4932. valid,
  4933. expectedType
  4934. };
  4935. }
  4936. /**
  4937. * dev only
  4938. */
  4939. function getInvalidTypeMessage(name, value, expectedTypes) {
  4940. let message = `Invalid prop: type check failed for prop "${name}".` +
  4941. ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
  4942. const expectedType = expectedTypes[0];
  4943. const receivedType = toRawType(value);
  4944. const expectedValue = styleValue(value, expectedType);
  4945. const receivedValue = styleValue(value, receivedType);
  4946. // check if we need to specify expected value
  4947. if (expectedTypes.length === 1 &&
  4948. isExplicable(expectedType) &&
  4949. !isBoolean(expectedType, receivedType)) {
  4950. message += ` with value ${expectedValue}`;
  4951. }
  4952. message += `, got ${receivedType} `;
  4953. // check if we need to specify received value
  4954. if (isExplicable(receivedType)) {
  4955. message += `with value ${receivedValue}.`;
  4956. }
  4957. return message;
  4958. }
  4959. /**
  4960. * dev only
  4961. */
  4962. function styleValue(value, type) {
  4963. if (type === 'String') {
  4964. return `"${value}"`;
  4965. }
  4966. else if (type === 'Number') {
  4967. return `${Number(value)}`;
  4968. }
  4969. else {
  4970. return `${value}`;
  4971. }
  4972. }
  4973. /**
  4974. * dev only
  4975. */
  4976. function isExplicable(type) {
  4977. const explicitTypes = ['string', 'number', 'boolean'];
  4978. return explicitTypes.some(elem => type.toLowerCase() === elem);
  4979. }
  4980. /**
  4981. * dev only
  4982. */
  4983. function isBoolean(...args) {
  4984. return args.some(elem => elem.toLowerCase() === 'boolean');
  4985. }
  4986. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  4987. const normalizeSlotValue = (value) => isArray(value)
  4988. ? value.map(normalizeVNode)
  4989. : [normalizeVNode(value)];
  4990. const normalizeSlot = (key, rawSlot, ctx) => {
  4991. const normalized = withCtx((...args) => {
  4992. if (currentInstance) {
  4993. warn$1(`Slot "${key}" invoked outside of the render function: ` +
  4994. `this will not track dependencies used in the slot. ` +
  4995. `Invoke the slot function inside the render function instead.`);
  4996. }
  4997. return normalizeSlotValue(rawSlot(...args));
  4998. }, ctx);
  4999. normalized._c = false;
  5000. return normalized;
  5001. };
  5002. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5003. const ctx = rawSlots._ctx;
  5004. for (const key in rawSlots) {
  5005. if (isInternalKey(key))
  5006. continue;
  5007. const value = rawSlots[key];
  5008. if (isFunction(value)) {
  5009. slots[key] = normalizeSlot(key, value, ctx);
  5010. }
  5011. else if (value != null) {
  5012. {
  5013. warn$1(`Non-function value encountered for slot "${key}". ` +
  5014. `Prefer function slots for better performance.`);
  5015. }
  5016. const normalized = normalizeSlotValue(value);
  5017. slots[key] = () => normalized;
  5018. }
  5019. }
  5020. };
  5021. const normalizeVNodeSlots = (instance, children) => {
  5022. if (!isKeepAlive(instance.vnode) &&
  5023. !(false )) {
  5024. warn$1(`Non-function value encountered for default slot. ` +
  5025. `Prefer function slots for better performance.`);
  5026. }
  5027. const normalized = normalizeSlotValue(children);
  5028. instance.slots.default = () => normalized;
  5029. };
  5030. const initSlots = (instance, children) => {
  5031. if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  5032. const type = children._;
  5033. if (type) {
  5034. // users can get the shallow readonly version of the slots object through `this.$slots`,
  5035. // we should avoid the proxy object polluting the slots of the internal instance
  5036. instance.slots = toRaw(children);
  5037. // make compiler marker non-enumerable
  5038. def(children, '_', type);
  5039. }
  5040. else {
  5041. normalizeObjectSlots(children, (instance.slots = {}));
  5042. }
  5043. }
  5044. else {
  5045. instance.slots = {};
  5046. if (children) {
  5047. normalizeVNodeSlots(instance, children);
  5048. }
  5049. }
  5050. def(instance.slots, InternalObjectKey, 1);
  5051. };
  5052. const updateSlots = (instance, children, optimized) => {
  5053. const { vnode, slots } = instance;
  5054. let needDeletionCheck = true;
  5055. let deletionComparisonTarget = EMPTY_OBJ;
  5056. if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  5057. const type = children._;
  5058. if (type) {
  5059. // compiled slots.
  5060. if (isHmrUpdating) {
  5061. // Parent was HMR updated so slot content may have changed.
  5062. // force update slots and mark instance for hmr as well
  5063. extend(slots, children);
  5064. }
  5065. else if (optimized && type === 1 /* STABLE */) {
  5066. // compiled AND stable.
  5067. // no need to update, and skip stale slots removal.
  5068. needDeletionCheck = false;
  5069. }
  5070. else {
  5071. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  5072. // normalization.
  5073. extend(slots, children);
  5074. // #2893
  5075. // when rendering the optimized slots by manually written render function,
  5076. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  5077. // i.e. let the `renderSlot` create the bailed Fragment
  5078. if (!optimized && type === 1 /* STABLE */) {
  5079. delete slots._;
  5080. }
  5081. }
  5082. }
  5083. else {
  5084. needDeletionCheck = !children.$stable;
  5085. normalizeObjectSlots(children, slots);
  5086. }
  5087. deletionComparisonTarget = children;
  5088. }
  5089. else if (children) {
  5090. // non slot object children (direct value) passed to a component
  5091. normalizeVNodeSlots(instance, children);
  5092. deletionComparisonTarget = { default: 1 };
  5093. }
  5094. // delete stale slots
  5095. if (needDeletionCheck) {
  5096. for (const key in slots) {
  5097. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5098. delete slots[key];
  5099. }
  5100. }
  5101. }
  5102. };
  5103. /**
  5104. Runtime helper for applying directives to a vnode. Example usage:
  5105. const comp = resolveComponent('comp')
  5106. const foo = resolveDirective('foo')
  5107. const bar = resolveDirective('bar')
  5108. return withDirectives(h(comp), [
  5109. [foo, this.x],
  5110. [bar, this.y]
  5111. ])
  5112. */
  5113. function validateDirectiveName(name) {
  5114. if (isBuiltInDirective(name)) {
  5115. warn$1('Do not use built-in directive ids as custom directive id: ' + name);
  5116. }
  5117. }
  5118. /**
  5119. * Adds directives to a VNode.
  5120. */
  5121. function withDirectives(vnode, directives) {
  5122. const internalInstance = currentRenderingInstance;
  5123. if (internalInstance === null) {
  5124. warn$1(`withDirectives can only be used inside render functions.`);
  5125. return vnode;
  5126. }
  5127. const instance = getExposeProxy(internalInstance) ||
  5128. internalInstance.proxy;
  5129. const bindings = vnode.dirs || (vnode.dirs = []);
  5130. for (let i = 0; i < directives.length; i++) {
  5131. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  5132. if (isFunction(dir)) {
  5133. dir = {
  5134. mounted: dir,
  5135. updated: dir
  5136. };
  5137. }
  5138. if (dir.deep) {
  5139. traverse(value);
  5140. }
  5141. bindings.push({
  5142. dir,
  5143. instance,
  5144. value,
  5145. oldValue: void 0,
  5146. arg,
  5147. modifiers
  5148. });
  5149. }
  5150. return vnode;
  5151. }
  5152. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  5153. const bindings = vnode.dirs;
  5154. const oldBindings = prevVNode && prevVNode.dirs;
  5155. for (let i = 0; i < bindings.length; i++) {
  5156. const binding = bindings[i];
  5157. if (oldBindings) {
  5158. binding.oldValue = oldBindings[i].value;
  5159. }
  5160. let hook = binding.dir[name];
  5161. if (hook) {
  5162. // disable tracking inside all lifecycle hooks
  5163. // since they can potentially be called inside effects.
  5164. pauseTracking();
  5165. callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
  5166. vnode.el,
  5167. binding,
  5168. vnode,
  5169. prevVNode
  5170. ]);
  5171. resetTracking();
  5172. }
  5173. }
  5174. }
  5175. function createAppContext() {
  5176. return {
  5177. app: null,
  5178. config: {
  5179. isNativeTag: NO,
  5180. performance: false,
  5181. globalProperties: {},
  5182. optionMergeStrategies: {},
  5183. errorHandler: undefined,
  5184. warnHandler: undefined,
  5185. compilerOptions: {}
  5186. },
  5187. mixins: [],
  5188. components: {},
  5189. directives: {},
  5190. provides: Object.create(null),
  5191. optionsCache: new WeakMap(),
  5192. propsCache: new WeakMap(),
  5193. emitsCache: new WeakMap()
  5194. };
  5195. }
  5196. let uid = 0;
  5197. function createAppAPI(render, hydrate) {
  5198. return function createApp(rootComponent, rootProps = null) {
  5199. if (!isFunction(rootComponent)) {
  5200. rootComponent = Object.assign({}, rootComponent);
  5201. }
  5202. if (rootProps != null && !isObject(rootProps)) {
  5203. warn$1(`root props passed to app.mount() must be an object.`);
  5204. rootProps = null;
  5205. }
  5206. const context = createAppContext();
  5207. const installedPlugins = new Set();
  5208. let isMounted = false;
  5209. const app = (context.app = {
  5210. _uid: uid++,
  5211. _component: rootComponent,
  5212. _props: rootProps,
  5213. _container: null,
  5214. _context: context,
  5215. _instance: null,
  5216. version,
  5217. get config() {
  5218. return context.config;
  5219. },
  5220. set config(v) {
  5221. {
  5222. warn$1(`app.config cannot be replaced. Modify individual options instead.`);
  5223. }
  5224. },
  5225. use(plugin, ...options) {
  5226. if (installedPlugins.has(plugin)) {
  5227. warn$1(`Plugin has already been applied to target app.`);
  5228. }
  5229. else if (plugin && isFunction(plugin.install)) {
  5230. installedPlugins.add(plugin);
  5231. plugin.install(app, ...options);
  5232. }
  5233. else if (isFunction(plugin)) {
  5234. installedPlugins.add(plugin);
  5235. plugin(app, ...options);
  5236. }
  5237. else {
  5238. warn$1(`A plugin must either be a function or an object with an "install" ` +
  5239. `function.`);
  5240. }
  5241. return app;
  5242. },
  5243. mixin(mixin) {
  5244. {
  5245. if (!context.mixins.includes(mixin)) {
  5246. context.mixins.push(mixin);
  5247. }
  5248. else {
  5249. warn$1('Mixin has already been applied to target app' +
  5250. (mixin.name ? `: ${mixin.name}` : ''));
  5251. }
  5252. }
  5253. return app;
  5254. },
  5255. component(name, component) {
  5256. {
  5257. validateComponentName(name, context.config);
  5258. }
  5259. if (!component) {
  5260. return context.components[name];
  5261. }
  5262. if (context.components[name]) {
  5263. warn$1(`Component "${name}" has already been registered in target app.`);
  5264. }
  5265. context.components[name] = component;
  5266. return app;
  5267. },
  5268. directive(name, directive) {
  5269. {
  5270. validateDirectiveName(name);
  5271. }
  5272. if (!directive) {
  5273. return context.directives[name];
  5274. }
  5275. if (context.directives[name]) {
  5276. warn$1(`Directive "${name}" has already been registered in target app.`);
  5277. }
  5278. context.directives[name] = directive;
  5279. return app;
  5280. },
  5281. mount(rootContainer, isHydrate, isSVG) {
  5282. if (!isMounted) {
  5283. const vnode = createVNode(rootComponent, rootProps);
  5284. // store app context on the root VNode.
  5285. // this will be set on the root instance on initial mount.
  5286. vnode.appContext = context;
  5287. // HMR root reload
  5288. {
  5289. context.reload = () => {
  5290. render(cloneVNode(vnode), rootContainer, isSVG);
  5291. };
  5292. }
  5293. if (isHydrate && hydrate) {
  5294. hydrate(vnode, rootContainer);
  5295. }
  5296. else {
  5297. render(vnode, rootContainer, isSVG);
  5298. }
  5299. isMounted = true;
  5300. app._container = rootContainer;
  5301. rootContainer.__vue_app__ = app;
  5302. {
  5303. app._instance = vnode.component;
  5304. devtoolsInitApp(app, version);
  5305. }
  5306. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5307. }
  5308. else {
  5309. warn$1(`App has already been mounted.\n` +
  5310. `If you want to remount the same app, move your app creation logic ` +
  5311. `into a factory function and create fresh app instances for each ` +
  5312. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  5313. }
  5314. },
  5315. unmount() {
  5316. if (isMounted) {
  5317. render(null, app._container);
  5318. {
  5319. app._instance = null;
  5320. devtoolsUnmountApp(app);
  5321. }
  5322. delete app._container.__vue_app__;
  5323. }
  5324. else {
  5325. warn$1(`Cannot unmount an app that is not mounted.`);
  5326. }
  5327. },
  5328. provide(key, value) {
  5329. if (key in context.provides) {
  5330. warn$1(`App already provides property with key "${String(key)}". ` +
  5331. `It will be overwritten with the new value.`);
  5332. }
  5333. // TypeScript doesn't allow symbols as index type
  5334. // https://github.com/Microsoft/TypeScript/issues/24587
  5335. context.provides[key] = value;
  5336. return app;
  5337. }
  5338. });
  5339. return app;
  5340. };
  5341. }
  5342. /**
  5343. * Function for handling a template ref
  5344. */
  5345. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5346. if (isArray(rawRef)) {
  5347. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  5348. return;
  5349. }
  5350. if (isAsyncWrapper(vnode) && !isUnmount) {
  5351. // when mounting async components, nothing needs to be done,
  5352. // because the template ref is forwarded to inner component
  5353. return;
  5354. }
  5355. const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
  5356. ? getExposeProxy(vnode.component) || vnode.component.proxy
  5357. : vnode.el;
  5358. const value = isUnmount ? null : refValue;
  5359. const { i: owner, r: ref } = rawRef;
  5360. if (!owner) {
  5361. warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  5362. `A vnode with ref must be created inside the render function.`);
  5363. return;
  5364. }
  5365. const oldRef = oldRawRef && oldRawRef.r;
  5366. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  5367. const setupState = owner.setupState;
  5368. // dynamic ref changed. unset old ref
  5369. if (oldRef != null && oldRef !== ref) {
  5370. if (isString(oldRef)) {
  5371. refs[oldRef] = null;
  5372. if (hasOwn(setupState, oldRef)) {
  5373. setupState[oldRef] = null;
  5374. }
  5375. }
  5376. else if (isRef(oldRef)) {
  5377. oldRef.value = null;
  5378. }
  5379. }
  5380. if (isFunction(ref)) {
  5381. callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
  5382. }
  5383. else {
  5384. const _isString = isString(ref);
  5385. const _isRef = isRef(ref);
  5386. if (_isString || _isRef) {
  5387. const doSet = () => {
  5388. if (rawRef.f) {
  5389. const existing = _isString ? refs[ref] : ref.value;
  5390. if (isUnmount) {
  5391. isArray(existing) && remove(existing, refValue);
  5392. }
  5393. else {
  5394. if (!isArray(existing)) {
  5395. if (_isString) {
  5396. refs[ref] = [refValue];
  5397. if (hasOwn(setupState, ref)) {
  5398. setupState[ref] = refs[ref];
  5399. }
  5400. }
  5401. else {
  5402. ref.value = [refValue];
  5403. if (rawRef.k)
  5404. refs[rawRef.k] = ref.value;
  5405. }
  5406. }
  5407. else if (!existing.includes(refValue)) {
  5408. existing.push(refValue);
  5409. }
  5410. }
  5411. }
  5412. else if (_isString) {
  5413. refs[ref] = value;
  5414. if (hasOwn(setupState, ref)) {
  5415. setupState[ref] = value;
  5416. }
  5417. }
  5418. else if (isRef(ref)) {
  5419. ref.value = value;
  5420. if (rawRef.k)
  5421. refs[rawRef.k] = value;
  5422. }
  5423. else {
  5424. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5425. }
  5426. };
  5427. if (value) {
  5428. doSet.id = -1;
  5429. queuePostRenderEffect(doSet, parentSuspense);
  5430. }
  5431. else {
  5432. doSet();
  5433. }
  5434. }
  5435. else {
  5436. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5437. }
  5438. }
  5439. }
  5440. let hasMismatch = false;
  5441. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  5442. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  5443. // Note: hydration is DOM-specific
  5444. // But we have to place it in core due to tight coupling with core - splitting
  5445. // it out creates a ton of unnecessary complexity.
  5446. // Hydration also depends on some renderer internal logic which needs to be
  5447. // passed in via arguments.
  5448. function createHydrationFunctions(rendererInternals) {
  5449. const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  5450. const hydrate = (vnode, container) => {
  5451. if (!container.hasChildNodes()) {
  5452. warn$1(`Attempting to hydrate existing markup but container is empty. ` +
  5453. `Performing full mount instead.`);
  5454. patch(null, vnode, container);
  5455. flushPostFlushCbs();
  5456. return;
  5457. }
  5458. hasMismatch = false;
  5459. hydrateNode(container.firstChild, vnode, null, null, null);
  5460. flushPostFlushCbs();
  5461. if (hasMismatch && !false) {
  5462. // this error should show up in production
  5463. console.error(`Hydration completed but contains mismatches.`);
  5464. }
  5465. };
  5466. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5467. const isFragmentStart = isComment(node) && node.data === '[';
  5468. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  5469. const { type, ref, shapeFlag } = vnode;
  5470. const domType = node.nodeType;
  5471. vnode.el = node;
  5472. let nextNode = null;
  5473. switch (type) {
  5474. case Text:
  5475. if (domType !== 3 /* TEXT */) {
  5476. nextNode = onMismatch();
  5477. }
  5478. else {
  5479. if (node.data !== vnode.children) {
  5480. hasMismatch = true;
  5481. warn$1(`Hydration text mismatch:` +
  5482. `\n- Client: ${JSON.stringify(node.data)}` +
  5483. `\n- Server: ${JSON.stringify(vnode.children)}`);
  5484. node.data = vnode.children;
  5485. }
  5486. nextNode = nextSibling(node);
  5487. }
  5488. break;
  5489. case Comment:
  5490. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  5491. nextNode = onMismatch();
  5492. }
  5493. else {
  5494. nextNode = nextSibling(node);
  5495. }
  5496. break;
  5497. case Static:
  5498. if (domType !== 1 /* ELEMENT */) {
  5499. nextNode = onMismatch();
  5500. }
  5501. else {
  5502. // determine anchor, adopt content
  5503. nextNode = node;
  5504. // if the static vnode has its content stripped during build,
  5505. // adopt it from the server-rendered HTML.
  5506. const needToAdoptContent = !vnode.children.length;
  5507. for (let i = 0; i < vnode.staticCount; i++) {
  5508. if (needToAdoptContent)
  5509. vnode.children += nextNode.outerHTML;
  5510. if (i === vnode.staticCount - 1) {
  5511. vnode.anchor = nextNode;
  5512. }
  5513. nextNode = nextSibling(nextNode);
  5514. }
  5515. return nextNode;
  5516. }
  5517. break;
  5518. case Fragment:
  5519. if (!isFragmentStart) {
  5520. nextNode = onMismatch();
  5521. }
  5522. else {
  5523. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  5524. }
  5525. break;
  5526. default:
  5527. if (shapeFlag & 1 /* ELEMENT */) {
  5528. if (domType !== 1 /* ELEMENT */ ||
  5529. vnode.type.toLowerCase() !==
  5530. node.tagName.toLowerCase()) {
  5531. nextNode = onMismatch();
  5532. }
  5533. else {
  5534. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  5535. }
  5536. }
  5537. else if (shapeFlag & 6 /* COMPONENT */) {
  5538. // when setting up the render effect, if the initial vnode already
  5539. // has .el set, the component will perform hydration instead of mount
  5540. // on its sub-tree.
  5541. vnode.slotScopeIds = slotScopeIds;
  5542. const container = parentNode(node);
  5543. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  5544. // component may be async, so in the case of fragments we cannot rely
  5545. // on component's rendered output to determine the end of the fragment
  5546. // instead, we do a lookahead to find the end anchor node.
  5547. nextNode = isFragmentStart
  5548. ? locateClosingAsyncAnchor(node)
  5549. : nextSibling(node);
  5550. // #3787
  5551. // if component is async, it may get moved / unmounted before its
  5552. // inner component is loaded, so we need to give it a placeholder
  5553. // vnode that matches its adopted DOM.
  5554. if (isAsyncWrapper(vnode)) {
  5555. let subTree;
  5556. if (isFragmentStart) {
  5557. subTree = createVNode(Fragment);
  5558. subTree.anchor = nextNode
  5559. ? nextNode.previousSibling
  5560. : container.lastChild;
  5561. }
  5562. else {
  5563. subTree =
  5564. node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  5565. }
  5566. subTree.el = node;
  5567. vnode.component.subTree = subTree;
  5568. }
  5569. }
  5570. else if (shapeFlag & 64 /* TELEPORT */) {
  5571. if (domType !== 8 /* COMMENT */) {
  5572. nextNode = onMismatch();
  5573. }
  5574. else {
  5575. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  5576. }
  5577. }
  5578. else if (shapeFlag & 128 /* SUSPENSE */) {
  5579. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  5580. }
  5581. else {
  5582. warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
  5583. }
  5584. }
  5585. if (ref != null) {
  5586. setRef(ref, null, parentSuspense, vnode);
  5587. }
  5588. return nextNode;
  5589. };
  5590. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  5591. optimized = optimized || !!vnode.dynamicChildren;
  5592. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  5593. // #4006 for form elements with non-string v-model value bindings
  5594. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  5595. const forcePatchValue = (type === 'input' && dirs) || type === 'option';
  5596. // skip props & children if this is hoisted static nodes
  5597. // #5405 in dev, always hydrate children for HMR
  5598. {
  5599. if (dirs) {
  5600. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  5601. }
  5602. // props
  5603. if (props) {
  5604. if (forcePatchValue ||
  5605. !optimized ||
  5606. patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
  5607. for (const key in props) {
  5608. if ((forcePatchValue && key.endsWith('value')) ||
  5609. (isOn(key) && !isReservedProp(key))) {
  5610. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  5611. }
  5612. }
  5613. }
  5614. else if (props.onClick) {
  5615. // Fast path for click listeners (which is most often) to avoid
  5616. // iterating through props.
  5617. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  5618. }
  5619. }
  5620. // vnode / directive hooks
  5621. let vnodeHooks;
  5622. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  5623. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  5624. }
  5625. if (dirs) {
  5626. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  5627. }
  5628. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  5629. queueEffectWithSuspense(() => {
  5630. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  5631. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  5632. }, parentSuspense);
  5633. }
  5634. // children
  5635. if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
  5636. // skip if element has innerHTML / textContent
  5637. !(props && (props.innerHTML || props.textContent))) {
  5638. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  5639. let hasWarned = false;
  5640. while (next) {
  5641. hasMismatch = true;
  5642. if (!hasWarned) {
  5643. warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
  5644. `server rendered element contains more child nodes than client vdom.`);
  5645. hasWarned = true;
  5646. }
  5647. // The SSRed DOM contains more nodes than it should. Remove them.
  5648. const cur = next;
  5649. next = next.nextSibling;
  5650. remove(cur);
  5651. }
  5652. }
  5653. else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  5654. if (el.textContent !== vnode.children) {
  5655. hasMismatch = true;
  5656. warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
  5657. `- Client: ${el.textContent}\n` +
  5658. `- Server: ${vnode.children}`);
  5659. el.textContent = vnode.children;
  5660. }
  5661. }
  5662. }
  5663. return el.nextSibling;
  5664. };
  5665. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  5666. optimized = optimized || !!parentVNode.dynamicChildren;
  5667. const children = parentVNode.children;
  5668. const l = children.length;
  5669. let hasWarned = false;
  5670. for (let i = 0; i < l; i++) {
  5671. const vnode = optimized
  5672. ? children[i]
  5673. : (children[i] = normalizeVNode(children[i]));
  5674. if (node) {
  5675. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  5676. }
  5677. else if (vnode.type === Text && !vnode.children) {
  5678. continue;
  5679. }
  5680. else {
  5681. hasMismatch = true;
  5682. if (!hasWarned) {
  5683. warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  5684. `server rendered element contains fewer child nodes than client vdom.`);
  5685. hasWarned = true;
  5686. }
  5687. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  5688. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  5689. }
  5690. }
  5691. return node;
  5692. };
  5693. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  5694. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  5695. if (fragmentSlotScopeIds) {
  5696. slotScopeIds = slotScopeIds
  5697. ? slotScopeIds.concat(fragmentSlotScopeIds)
  5698. : fragmentSlotScopeIds;
  5699. }
  5700. const container = parentNode(node);
  5701. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  5702. if (next && isComment(next) && next.data === ']') {
  5703. return nextSibling((vnode.anchor = next));
  5704. }
  5705. else {
  5706. // fragment didn't hydrate successfully, since we didn't get a end anchor
  5707. // back. This should have led to node/children mismatch warnings.
  5708. hasMismatch = true;
  5709. // since the anchor is missing, we need to create one and insert it
  5710. insert((vnode.anchor = createComment(`]`)), container, next);
  5711. return next;
  5712. }
  5713. };
  5714. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  5715. hasMismatch = true;
  5716. warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
  5717. ? `(text)`
  5718. : isComment(node) && node.data === '['
  5719. ? `(start of fragment)`
  5720. : ``);
  5721. vnode.el = null;
  5722. if (isFragment) {
  5723. // remove excessive fragment nodes
  5724. const end = locateClosingAsyncAnchor(node);
  5725. while (true) {
  5726. const next = nextSibling(node);
  5727. if (next && next !== end) {
  5728. remove(next);
  5729. }
  5730. else {
  5731. break;
  5732. }
  5733. }
  5734. }
  5735. const next = nextSibling(node);
  5736. const container = parentNode(node);
  5737. remove(node);
  5738. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  5739. return next;
  5740. };
  5741. const locateClosingAsyncAnchor = (node) => {
  5742. let match = 0;
  5743. while (node) {
  5744. node = nextSibling(node);
  5745. if (node && isComment(node)) {
  5746. if (node.data === '[')
  5747. match++;
  5748. if (node.data === ']') {
  5749. if (match === 0) {
  5750. return nextSibling(node);
  5751. }
  5752. else {
  5753. match--;
  5754. }
  5755. }
  5756. }
  5757. }
  5758. return node;
  5759. };
  5760. return [hydrate, hydrateNode];
  5761. }
  5762. /* eslint-disable no-restricted-globals */
  5763. let supported;
  5764. let perf;
  5765. function startMeasure(instance, type) {
  5766. if (instance.appContext.config.performance && isSupported()) {
  5767. perf.mark(`vue-${type}-${instance.uid}`);
  5768. }
  5769. {
  5770. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  5771. }
  5772. }
  5773. function endMeasure(instance, type) {
  5774. if (instance.appContext.config.performance && isSupported()) {
  5775. const startTag = `vue-${type}-${instance.uid}`;
  5776. const endTag = startTag + `:end`;
  5777. perf.mark(endTag);
  5778. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  5779. perf.clearMarks(startTag);
  5780. perf.clearMarks(endTag);
  5781. }
  5782. {
  5783. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  5784. }
  5785. }
  5786. function isSupported() {
  5787. if (supported !== undefined) {
  5788. return supported;
  5789. }
  5790. if (typeof window !== 'undefined' && window.performance) {
  5791. supported = true;
  5792. perf = window.performance;
  5793. }
  5794. else {
  5795. supported = false;
  5796. }
  5797. return supported;
  5798. }
  5799. const queuePostRenderEffect = queueEffectWithSuspense
  5800. ;
  5801. /**
  5802. * The createRenderer function accepts two generic arguments:
  5803. * HostNode and HostElement, corresponding to Node and Element types in the
  5804. * host environment. For example, for runtime-dom, HostNode would be the DOM
  5805. * `Node` interface and HostElement would be the DOM `Element` interface.
  5806. *
  5807. * Custom renderers can pass in the platform specific types like this:
  5808. *
  5809. * ``` js
  5810. * const { render, createApp } = createRenderer<Node, Element>({
  5811. * patchProp,
  5812. * ...nodeOps
  5813. * })
  5814. * ```
  5815. */
  5816. function createRenderer(options) {
  5817. return baseCreateRenderer(options);
  5818. }
  5819. // Separate API for creating hydration-enabled renderer.
  5820. // Hydration logic is only used when calling this function, making it
  5821. // tree-shakable.
  5822. function createHydrationRenderer(options) {
  5823. return baseCreateRenderer(options, createHydrationFunctions);
  5824. }
  5825. // implementation
  5826. function baseCreateRenderer(options, createHydrationFns) {
  5827. const target = getGlobalThis();
  5828. target.__VUE__ = true;
  5829. {
  5830. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  5831. }
  5832. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
  5833. // Note: functions inside this closure should use `const xxx = () => {}`
  5834. // style in order to prevent being inlined by minifiers.
  5835. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  5836. if (n1 === n2) {
  5837. return;
  5838. }
  5839. // patching & not same type, unmount old tree
  5840. if (n1 && !isSameVNodeType(n1, n2)) {
  5841. anchor = getNextHostNode(n1);
  5842. unmount(n1, parentComponent, parentSuspense, true);
  5843. n1 = null;
  5844. }
  5845. if (n2.patchFlag === -2 /* BAIL */) {
  5846. optimized = false;
  5847. n2.dynamicChildren = null;
  5848. }
  5849. const { type, ref, shapeFlag } = n2;
  5850. switch (type) {
  5851. case Text:
  5852. processText(n1, n2, container, anchor);
  5853. break;
  5854. case Comment:
  5855. processCommentNode(n1, n2, container, anchor);
  5856. break;
  5857. case Static:
  5858. if (n1 == null) {
  5859. mountStaticNode(n2, container, anchor, isSVG);
  5860. }
  5861. else {
  5862. patchStaticNode(n1, n2, container, isSVG);
  5863. }
  5864. break;
  5865. case Fragment:
  5866. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5867. break;
  5868. default:
  5869. if (shapeFlag & 1 /* ELEMENT */) {
  5870. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5871. }
  5872. else if (shapeFlag & 6 /* COMPONENT */) {
  5873. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5874. }
  5875. else if (shapeFlag & 64 /* TELEPORT */) {
  5876. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  5877. }
  5878. else if (shapeFlag & 128 /* SUSPENSE */) {
  5879. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  5880. }
  5881. else {
  5882. warn$1('Invalid VNode type:', type, `(${typeof type})`);
  5883. }
  5884. }
  5885. // set ref
  5886. if (ref != null && parentComponent) {
  5887. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  5888. }
  5889. };
  5890. const processText = (n1, n2, container, anchor) => {
  5891. if (n1 == null) {
  5892. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  5893. }
  5894. else {
  5895. const el = (n2.el = n1.el);
  5896. if (n2.children !== n1.children) {
  5897. hostSetText(el, n2.children);
  5898. }
  5899. }
  5900. };
  5901. const processCommentNode = (n1, n2, container, anchor) => {
  5902. if (n1 == null) {
  5903. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  5904. }
  5905. else {
  5906. // there's no support for dynamic comments
  5907. n2.el = n1.el;
  5908. }
  5909. };
  5910. const mountStaticNode = (n2, container, anchor, isSVG) => {
  5911. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
  5912. };
  5913. /**
  5914. * Dev / HMR only
  5915. */
  5916. const patchStaticNode = (n1, n2, container, isSVG) => {
  5917. // static nodes are only patched during dev for HMR
  5918. if (n2.children !== n1.children) {
  5919. const anchor = hostNextSibling(n1.anchor);
  5920. // remove existing
  5921. removeStaticNode(n1);
  5922. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  5923. }
  5924. else {
  5925. n2.el = n1.el;
  5926. n2.anchor = n1.anchor;
  5927. }
  5928. };
  5929. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  5930. let next;
  5931. while (el && el !== anchor) {
  5932. next = hostNextSibling(el);
  5933. hostInsert(el, container, nextSibling);
  5934. el = next;
  5935. }
  5936. hostInsert(anchor, container, nextSibling);
  5937. };
  5938. const removeStaticNode = ({ el, anchor }) => {
  5939. let next;
  5940. while (el && el !== anchor) {
  5941. next = hostNextSibling(el);
  5942. hostRemove(el);
  5943. el = next;
  5944. }
  5945. hostRemove(anchor);
  5946. };
  5947. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5948. isSVG = isSVG || n2.type === 'svg';
  5949. if (n1 == null) {
  5950. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5951. }
  5952. else {
  5953. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5954. }
  5955. };
  5956. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5957. let el;
  5958. let vnodeHook;
  5959. const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
  5960. {
  5961. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  5962. // mount children first, since some props may rely on child content
  5963. // being already rendered, e.g. `<select value>`
  5964. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  5965. hostSetElementText(el, vnode.children);
  5966. }
  5967. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5968. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  5969. }
  5970. if (dirs) {
  5971. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  5972. }
  5973. // props
  5974. if (props) {
  5975. for (const key in props) {
  5976. if (key !== 'value' && !isReservedProp(key)) {
  5977. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5978. }
  5979. }
  5980. /**
  5981. * Special case for setting value on DOM elements:
  5982. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  5983. * - it needs to be forced (#1471)
  5984. * #2353 proposes adding another renderer option to configure this, but
  5985. * the properties affects are so finite it is worth special casing it
  5986. * here to reduce the complexity. (Special casing it also should not
  5987. * affect non-DOM renderers)
  5988. */
  5989. if ('value' in props) {
  5990. hostPatchProp(el, 'value', null, props.value);
  5991. }
  5992. if ((vnodeHook = props.onVnodeBeforeMount)) {
  5993. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  5994. }
  5995. }
  5996. // scopeId
  5997. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  5998. }
  5999. {
  6000. Object.defineProperty(el, '__vnode', {
  6001. value: vnode,
  6002. enumerable: false
  6003. });
  6004. Object.defineProperty(el, '__vueParentComponent', {
  6005. value: parentComponent,
  6006. enumerable: false
  6007. });
  6008. }
  6009. if (dirs) {
  6010. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6011. }
  6012. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  6013. // #1689 For inside suspense + suspense resolved case, just call it
  6014. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  6015. transition &&
  6016. !transition.persisted;
  6017. if (needCallTransitionHooks) {
  6018. transition.beforeEnter(el);
  6019. }
  6020. hostInsert(el, container, anchor);
  6021. if ((vnodeHook = props && props.onVnodeMounted) ||
  6022. needCallTransitionHooks ||
  6023. dirs) {
  6024. queuePostRenderEffect(() => {
  6025. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6026. needCallTransitionHooks && transition.enter(el);
  6027. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6028. }, parentSuspense);
  6029. }
  6030. };
  6031. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6032. if (scopeId) {
  6033. hostSetScopeId(el, scopeId);
  6034. }
  6035. if (slotScopeIds) {
  6036. for (let i = 0; i < slotScopeIds.length; i++) {
  6037. hostSetScopeId(el, slotScopeIds[i]);
  6038. }
  6039. }
  6040. if (parentComponent) {
  6041. let subTree = parentComponent.subTree;
  6042. if (subTree.patchFlag > 0 &&
  6043. subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  6044. subTree =
  6045. filterSingleRoot(subTree.children) || subTree;
  6046. }
  6047. if (vnode === subTree) {
  6048. const parentVNode = parentComponent.vnode;
  6049. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  6050. }
  6051. }
  6052. };
  6053. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6054. for (let i = start; i < children.length; i++) {
  6055. const child = (children[i] = optimized
  6056. ? cloneIfMounted(children[i])
  6057. : normalizeVNode(children[i]));
  6058. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6059. }
  6060. };
  6061. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6062. const el = (n2.el = n1.el);
  6063. let { patchFlag, dynamicChildren, dirs } = n2;
  6064. // #1426 take the old vnode's patch flag into account since user may clone a
  6065. // compiler-generated vnode, which de-opts to FULL_PROPS
  6066. patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
  6067. const oldProps = n1.props || EMPTY_OBJ;
  6068. const newProps = n2.props || EMPTY_OBJ;
  6069. let vnodeHook;
  6070. // disable recurse in beforeUpdate hooks
  6071. parentComponent && toggleRecurse(parentComponent, false);
  6072. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  6073. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6074. }
  6075. if (dirs) {
  6076. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  6077. }
  6078. parentComponent && toggleRecurse(parentComponent, true);
  6079. if (isHmrUpdating) {
  6080. // HMR updated, force full diff
  6081. patchFlag = 0;
  6082. optimized = false;
  6083. dynamicChildren = null;
  6084. }
  6085. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  6086. if (dynamicChildren) {
  6087. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  6088. if (parentComponent && parentComponent.type.__hmrId) {
  6089. traverseStaticChildren(n1, n2);
  6090. }
  6091. }
  6092. else if (!optimized) {
  6093. // full diff
  6094. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  6095. }
  6096. if (patchFlag > 0) {
  6097. // the presence of a patchFlag means this element's render code was
  6098. // generated by the compiler and can take the fast path.
  6099. // in this path old node and new node are guaranteed to have the same shape
  6100. // (i.e. at the exact same position in the source template)
  6101. if (patchFlag & 16 /* FULL_PROPS */) {
  6102. // element props contain dynamic keys, full diff needed
  6103. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6104. }
  6105. else {
  6106. // class
  6107. // this flag is matched when the element has dynamic class bindings.
  6108. if (patchFlag & 2 /* CLASS */) {
  6109. if (oldProps.class !== newProps.class) {
  6110. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  6111. }
  6112. }
  6113. // style
  6114. // this flag is matched when the element has dynamic style bindings
  6115. if (patchFlag & 4 /* STYLE */) {
  6116. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  6117. }
  6118. // props
  6119. // This flag is matched when the element has dynamic prop/attr bindings
  6120. // other than class and style. The keys of dynamic prop/attrs are saved for
  6121. // faster iteration.
  6122. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  6123. // bail out and go through a full diff because we need to unset the old key
  6124. if (patchFlag & 8 /* PROPS */) {
  6125. // if the flag is present then dynamicProps must be non-null
  6126. const propsToUpdate = n2.dynamicProps;
  6127. for (let i = 0; i < propsToUpdate.length; i++) {
  6128. const key = propsToUpdate[i];
  6129. const prev = oldProps[key];
  6130. const next = newProps[key];
  6131. // #1471 force patch value
  6132. if (next !== prev || key === 'value') {
  6133. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  6134. }
  6135. }
  6136. }
  6137. }
  6138. // text
  6139. // This flag is matched when the element has only dynamic text children.
  6140. if (patchFlag & 1 /* TEXT */) {
  6141. if (n1.children !== n2.children) {
  6142. hostSetElementText(el, n2.children);
  6143. }
  6144. }
  6145. }
  6146. else if (!optimized && dynamicChildren == null) {
  6147. // unoptimized, full diff
  6148. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6149. }
  6150. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6151. queuePostRenderEffect(() => {
  6152. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6153. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  6154. }, parentSuspense);
  6155. }
  6156. };
  6157. // The fast path for blocks.
  6158. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6159. for (let i = 0; i < newChildren.length; i++) {
  6160. const oldVNode = oldChildren[i];
  6161. const newVNode = newChildren[i];
  6162. // Determine the container (parent element) for the patch.
  6163. const container =
  6164. // oldVNode may be an errored async setup() component inside Suspense
  6165. // which will not have a mounted element
  6166. oldVNode.el &&
  6167. // - In the case of a Fragment, we need to provide the actual parent
  6168. // of the Fragment itself so it can move its children.
  6169. (oldVNode.type === Fragment ||
  6170. // - In the case of different nodes, there is going to be a replacement
  6171. // which also requires the correct parent container
  6172. !isSameVNodeType(oldVNode, newVNode) ||
  6173. // - In the case of a component, it could contain anything.
  6174. oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
  6175. ? hostParentNode(oldVNode.el)
  6176. : // In other cases, the parent container is not actually used so we
  6177. // just pass the block element here to avoid a DOM parentNode call.
  6178. fallbackContainer;
  6179. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  6180. }
  6181. };
  6182. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6183. if (oldProps !== newProps) {
  6184. for (const key in newProps) {
  6185. // empty string is not valid prop
  6186. if (isReservedProp(key))
  6187. continue;
  6188. const next = newProps[key];
  6189. const prev = oldProps[key];
  6190. // defer patching value
  6191. if (next !== prev && key !== 'value') {
  6192. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6193. }
  6194. }
  6195. if (oldProps !== EMPTY_OBJ) {
  6196. for (const key in oldProps) {
  6197. if (!isReservedProp(key) && !(key in newProps)) {
  6198. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6199. }
  6200. }
  6201. }
  6202. if ('value' in newProps) {
  6203. hostPatchProp(el, 'value', oldProps.value, newProps.value);
  6204. }
  6205. }
  6206. };
  6207. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6208. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  6209. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  6210. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6211. if (isHmrUpdating) {
  6212. // HMR updated, force full diff
  6213. patchFlag = 0;
  6214. optimized = false;
  6215. dynamicChildren = null;
  6216. }
  6217. // check if this is a slot fragment with :slotted scope ids
  6218. if (fragmentSlotScopeIds) {
  6219. slotScopeIds = slotScopeIds
  6220. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6221. : fragmentSlotScopeIds;
  6222. }
  6223. if (n1 == null) {
  6224. hostInsert(fragmentStartAnchor, container, anchor);
  6225. hostInsert(fragmentEndAnchor, container, anchor);
  6226. // a fragment can only have array children
  6227. // since they are either generated by the compiler, or implicitly created
  6228. // from arrays.
  6229. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6230. }
  6231. else {
  6232. if (patchFlag > 0 &&
  6233. patchFlag & 64 /* STABLE_FRAGMENT */ &&
  6234. dynamicChildren &&
  6235. // #2715 the previous fragment could've been a BAILed one as a result
  6236. // of renderSlot() with no valid children
  6237. n1.dynamicChildren) {
  6238. // a stable fragment (template root or <template v-for>) doesn't need to
  6239. // patch children order, but it may contain dynamicChildren.
  6240. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  6241. if (parentComponent && parentComponent.type.__hmrId) {
  6242. traverseStaticChildren(n1, n2);
  6243. }
  6244. else if (
  6245. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  6246. // get moved around. Make sure all root level vnodes inherit el.
  6247. // #2134 or if it's a component root, it may also get moved around
  6248. // as the component is being moved.
  6249. n2.key != null ||
  6250. (parentComponent && n2 === parentComponent.subTree)) {
  6251. traverseStaticChildren(n1, n2, true /* shallow */);
  6252. }
  6253. }
  6254. else {
  6255. // keyed / unkeyed, or manual fragments.
  6256. // for keyed & unkeyed, since they are compiler generated from v-for,
  6257. // each child is guaranteed to be a block so the fragment will never
  6258. // have dynamicChildren.
  6259. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6260. }
  6261. }
  6262. };
  6263. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6264. n2.slotScopeIds = slotScopeIds;
  6265. if (n1 == null) {
  6266. if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  6267. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  6268. }
  6269. else {
  6270. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  6271. }
  6272. }
  6273. else {
  6274. updateComponent(n1, n2, optimized);
  6275. }
  6276. };
  6277. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  6278. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  6279. if (instance.type.__hmrId) {
  6280. registerHMR(instance);
  6281. }
  6282. {
  6283. pushWarningContext(initialVNode);
  6284. startMeasure(instance, `mount`);
  6285. }
  6286. // inject renderer internals for keepAlive
  6287. if (isKeepAlive(initialVNode)) {
  6288. instance.ctx.renderer = internals;
  6289. }
  6290. // resolve props and slots for setup context
  6291. {
  6292. {
  6293. startMeasure(instance, `init`);
  6294. }
  6295. setupComponent(instance);
  6296. {
  6297. endMeasure(instance, `init`);
  6298. }
  6299. }
  6300. // setup() is async. This component relies on async logic to be resolved
  6301. // before proceeding
  6302. if (instance.asyncDep) {
  6303. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  6304. // Give it a placeholder if this is not hydration
  6305. // TODO handle self-defined fallback
  6306. if (!initialVNode.el) {
  6307. const placeholder = (instance.subTree = createVNode(Comment));
  6308. processCommentNode(null, placeholder, container, anchor);
  6309. }
  6310. return;
  6311. }
  6312. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  6313. {
  6314. popWarningContext();
  6315. endMeasure(instance, `mount`);
  6316. }
  6317. };
  6318. const updateComponent = (n1, n2, optimized) => {
  6319. const instance = (n2.component = n1.component);
  6320. if (shouldUpdateComponent(n1, n2, optimized)) {
  6321. if (instance.asyncDep &&
  6322. !instance.asyncResolved) {
  6323. // async & still pending - just update props and slots
  6324. // since the component's reactive effect for render isn't set-up yet
  6325. {
  6326. pushWarningContext(n2);
  6327. }
  6328. updateComponentPreRender(instance, n2, optimized);
  6329. {
  6330. popWarningContext();
  6331. }
  6332. return;
  6333. }
  6334. else {
  6335. // normal update
  6336. instance.next = n2;
  6337. // in case the child component is also queued, remove it to avoid
  6338. // double updating the same child component in the same flush.
  6339. invalidateJob(instance.update);
  6340. // instance.update is the reactive effect.
  6341. instance.update();
  6342. }
  6343. }
  6344. else {
  6345. // no update needed. just copy over properties
  6346. n2.component = n1.component;
  6347. n2.el = n1.el;
  6348. instance.vnode = n2;
  6349. }
  6350. };
  6351. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  6352. const componentUpdateFn = () => {
  6353. if (!instance.isMounted) {
  6354. let vnodeHook;
  6355. const { el, props } = initialVNode;
  6356. const { bm, m, parent } = instance;
  6357. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  6358. toggleRecurse(instance, false);
  6359. // beforeMount hook
  6360. if (bm) {
  6361. invokeArrayFns(bm);
  6362. }
  6363. // onVnodeBeforeMount
  6364. if (!isAsyncWrapperVNode &&
  6365. (vnodeHook = props && props.onVnodeBeforeMount)) {
  6366. invokeVNodeHook(vnodeHook, parent, initialVNode);
  6367. }
  6368. toggleRecurse(instance, true);
  6369. if (el && hydrateNode) {
  6370. // vnode has adopted host node - perform hydration instead of mount.
  6371. const hydrateSubTree = () => {
  6372. {
  6373. startMeasure(instance, `render`);
  6374. }
  6375. instance.subTree = renderComponentRoot(instance);
  6376. {
  6377. endMeasure(instance, `render`);
  6378. }
  6379. {
  6380. startMeasure(instance, `hydrate`);
  6381. }
  6382. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  6383. {
  6384. endMeasure(instance, `hydrate`);
  6385. }
  6386. };
  6387. if (isAsyncWrapperVNode) {
  6388. initialVNode.type.__asyncLoader().then(
  6389. // note: we are moving the render call into an async callback,
  6390. // which means it won't track dependencies - but it's ok because
  6391. // a server-rendered async wrapper is already in resolved state
  6392. // and it will never need to change.
  6393. () => !instance.isUnmounted && hydrateSubTree());
  6394. }
  6395. else {
  6396. hydrateSubTree();
  6397. }
  6398. }
  6399. else {
  6400. {
  6401. startMeasure(instance, `render`);
  6402. }
  6403. const subTree = (instance.subTree = renderComponentRoot(instance));
  6404. {
  6405. endMeasure(instance, `render`);
  6406. }
  6407. {
  6408. startMeasure(instance, `patch`);
  6409. }
  6410. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  6411. {
  6412. endMeasure(instance, `patch`);
  6413. }
  6414. initialVNode.el = subTree.el;
  6415. }
  6416. // mounted hook
  6417. if (m) {
  6418. queuePostRenderEffect(m, parentSuspense);
  6419. }
  6420. // onVnodeMounted
  6421. if (!isAsyncWrapperVNode &&
  6422. (vnodeHook = props && props.onVnodeMounted)) {
  6423. const scopedInitialVNode = initialVNode;
  6424. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  6425. }
  6426. // activated hook for keep-alive roots.
  6427. // #1742 activated hook must be accessed after first render
  6428. // since the hook may be injected by a child keep-alive
  6429. if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  6430. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  6431. }
  6432. instance.isMounted = true;
  6433. {
  6434. devtoolsComponentAdded(instance);
  6435. }
  6436. // #2458: deference mount-only object parameters to prevent memleaks
  6437. initialVNode = container = anchor = null;
  6438. }
  6439. else {
  6440. // updateComponent
  6441. // This is triggered by mutation of component's own state (next: null)
  6442. // OR parent calling processComponent (next: VNode)
  6443. let { next, bu, u, parent, vnode } = instance;
  6444. let originNext = next;
  6445. let vnodeHook;
  6446. {
  6447. pushWarningContext(next || instance.vnode);
  6448. }
  6449. // Disallow component effect recursion during pre-lifecycle hooks.
  6450. toggleRecurse(instance, false);
  6451. if (next) {
  6452. next.el = vnode.el;
  6453. updateComponentPreRender(instance, next, optimized);
  6454. }
  6455. else {
  6456. next = vnode;
  6457. }
  6458. // beforeUpdate hook
  6459. if (bu) {
  6460. invokeArrayFns(bu);
  6461. }
  6462. // onVnodeBeforeUpdate
  6463. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  6464. invokeVNodeHook(vnodeHook, parent, next, vnode);
  6465. }
  6466. toggleRecurse(instance, true);
  6467. // render
  6468. {
  6469. startMeasure(instance, `render`);
  6470. }
  6471. const nextTree = renderComponentRoot(instance);
  6472. {
  6473. endMeasure(instance, `render`);
  6474. }
  6475. const prevTree = instance.subTree;
  6476. instance.subTree = nextTree;
  6477. {
  6478. startMeasure(instance, `patch`);
  6479. }
  6480. patch(prevTree, nextTree,
  6481. // parent may have changed if it's in a teleport
  6482. hostParentNode(prevTree.el),
  6483. // anchor may have changed if it's in a fragment
  6484. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  6485. {
  6486. endMeasure(instance, `patch`);
  6487. }
  6488. next.el = nextTree.el;
  6489. if (originNext === null) {
  6490. // self-triggered update. In case of HOC, update parent component
  6491. // vnode el. HOC is indicated by parent instance's subTree pointing
  6492. // to child component's vnode
  6493. updateHOCHostEl(instance, nextTree.el);
  6494. }
  6495. // updated hook
  6496. if (u) {
  6497. queuePostRenderEffect(u, parentSuspense);
  6498. }
  6499. // onVnodeUpdated
  6500. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  6501. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
  6502. }
  6503. {
  6504. devtoolsComponentUpdated(instance);
  6505. }
  6506. {
  6507. popWarningContext();
  6508. }
  6509. }
  6510. };
  6511. // create reactive effect for rendering
  6512. const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
  6513. ));
  6514. const update = (instance.update = effect.run.bind(effect));
  6515. update.id = instance.uid;
  6516. // allowRecurse
  6517. // #1801, #2043 component render effects should allow recursive updates
  6518. toggleRecurse(instance, true);
  6519. {
  6520. effect.onTrack = instance.rtc
  6521. ? e => invokeArrayFns(instance.rtc, e)
  6522. : void 0;
  6523. effect.onTrigger = instance.rtg
  6524. ? e => invokeArrayFns(instance.rtg, e)
  6525. : void 0;
  6526. // @ts-ignore (for scheduler)
  6527. update.ownerInstance = instance;
  6528. }
  6529. update();
  6530. };
  6531. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  6532. nextVNode.component = instance;
  6533. const prevProps = instance.vnode.props;
  6534. instance.vnode = nextVNode;
  6535. instance.next = null;
  6536. updateProps(instance, nextVNode.props, prevProps, optimized);
  6537. updateSlots(instance, nextVNode.children, optimized);
  6538. pauseTracking();
  6539. // props update may have triggered pre-flush watchers.
  6540. // flush them before the render update.
  6541. flushPreFlushCbs(undefined, instance.update);
  6542. resetTracking();
  6543. };
  6544. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  6545. const c1 = n1 && n1.children;
  6546. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  6547. const c2 = n2.children;
  6548. const { patchFlag, shapeFlag } = n2;
  6549. // fast path
  6550. if (patchFlag > 0) {
  6551. if (patchFlag & 128 /* KEYED_FRAGMENT */) {
  6552. // this could be either fully-keyed or mixed (some keyed some not)
  6553. // presence of patchFlag means children are guaranteed to be arrays
  6554. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6555. return;
  6556. }
  6557. else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
  6558. // unkeyed
  6559. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6560. return;
  6561. }
  6562. }
  6563. // children has 3 possibilities: text, array or no children.
  6564. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  6565. // text children fast path
  6566. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  6567. unmountChildren(c1, parentComponent, parentSuspense);
  6568. }
  6569. if (c2 !== c1) {
  6570. hostSetElementText(container, c2);
  6571. }
  6572. }
  6573. else {
  6574. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  6575. // prev children was array
  6576. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6577. // two arrays, cannot assume anything, do full diff
  6578. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6579. }
  6580. else {
  6581. // no new children, just unmount old
  6582. unmountChildren(c1, parentComponent, parentSuspense, true);
  6583. }
  6584. }
  6585. else {
  6586. // prev children was text OR null
  6587. // new children is array OR null
  6588. if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
  6589. hostSetElementText(container, '');
  6590. }
  6591. // mount new if array
  6592. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6593. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6594. }
  6595. }
  6596. }
  6597. };
  6598. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6599. c1 = c1 || EMPTY_ARR;
  6600. c2 = c2 || EMPTY_ARR;
  6601. const oldLength = c1.length;
  6602. const newLength = c2.length;
  6603. const commonLength = Math.min(oldLength, newLength);
  6604. let i;
  6605. for (i = 0; i < commonLength; i++) {
  6606. const nextChild = (c2[i] = optimized
  6607. ? cloneIfMounted(c2[i])
  6608. : normalizeVNode(c2[i]));
  6609. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6610. }
  6611. if (oldLength > newLength) {
  6612. // remove old
  6613. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  6614. }
  6615. else {
  6616. // mount new
  6617. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  6618. }
  6619. };
  6620. // can be all-keyed or mixed
  6621. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6622. let i = 0;
  6623. const l2 = c2.length;
  6624. let e1 = c1.length - 1; // prev ending index
  6625. let e2 = l2 - 1; // next ending index
  6626. // 1. sync from start
  6627. // (a b) c
  6628. // (a b) d e
  6629. while (i <= e1 && i <= e2) {
  6630. const n1 = c1[i];
  6631. const n2 = (c2[i] = optimized
  6632. ? cloneIfMounted(c2[i])
  6633. : normalizeVNode(c2[i]));
  6634. if (isSameVNodeType(n1, n2)) {
  6635. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6636. }
  6637. else {
  6638. break;
  6639. }
  6640. i++;
  6641. }
  6642. // 2. sync from end
  6643. // a (b c)
  6644. // d e (b c)
  6645. while (i <= e1 && i <= e2) {
  6646. const n1 = c1[e1];
  6647. const n2 = (c2[e2] = optimized
  6648. ? cloneIfMounted(c2[e2])
  6649. : normalizeVNode(c2[e2]));
  6650. if (isSameVNodeType(n1, n2)) {
  6651. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6652. }
  6653. else {
  6654. break;
  6655. }
  6656. e1--;
  6657. e2--;
  6658. }
  6659. // 3. common sequence + mount
  6660. // (a b)
  6661. // (a b) c
  6662. // i = 2, e1 = 1, e2 = 2
  6663. // (a b)
  6664. // c (a b)
  6665. // i = 0, e1 = -1, e2 = 0
  6666. if (i > e1) {
  6667. if (i <= e2) {
  6668. const nextPos = e2 + 1;
  6669. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  6670. while (i <= e2) {
  6671. patch(null, (c2[i] = optimized
  6672. ? cloneIfMounted(c2[i])
  6673. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6674. i++;
  6675. }
  6676. }
  6677. }
  6678. // 4. common sequence + unmount
  6679. // (a b) c
  6680. // (a b)
  6681. // i = 2, e1 = 2, e2 = 1
  6682. // a (b c)
  6683. // (b c)
  6684. // i = 0, e1 = 0, e2 = -1
  6685. else if (i > e2) {
  6686. while (i <= e1) {
  6687. unmount(c1[i], parentComponent, parentSuspense, true);
  6688. i++;
  6689. }
  6690. }
  6691. // 5. unknown sequence
  6692. // [i ... e1 + 1]: a b [c d e] f g
  6693. // [i ... e2 + 1]: a b [e d c h] f g
  6694. // i = 2, e1 = 4, e2 = 5
  6695. else {
  6696. const s1 = i; // prev starting index
  6697. const s2 = i; // next starting index
  6698. // 5.1 build key:index map for newChildren
  6699. const keyToNewIndexMap = new Map();
  6700. for (i = s2; i <= e2; i++) {
  6701. const nextChild = (c2[i] = optimized
  6702. ? cloneIfMounted(c2[i])
  6703. : normalizeVNode(c2[i]));
  6704. if (nextChild.key != null) {
  6705. if (keyToNewIndexMap.has(nextChild.key)) {
  6706. warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  6707. }
  6708. keyToNewIndexMap.set(nextChild.key, i);
  6709. }
  6710. }
  6711. // 5.2 loop through old children left to be patched and try to patch
  6712. // matching nodes & remove nodes that are no longer present
  6713. let j;
  6714. let patched = 0;
  6715. const toBePatched = e2 - s2 + 1;
  6716. let moved = false;
  6717. // used to track whether any node has moved
  6718. let maxNewIndexSoFar = 0;
  6719. // works as Map<newIndex, oldIndex>
  6720. // Note that oldIndex is offset by +1
  6721. // and oldIndex = 0 is a special value indicating the new node has
  6722. // no corresponding old node.
  6723. // used for determining longest stable subsequence
  6724. const newIndexToOldIndexMap = new Array(toBePatched);
  6725. for (i = 0; i < toBePatched; i++)
  6726. newIndexToOldIndexMap[i] = 0;
  6727. for (i = s1; i <= e1; i++) {
  6728. const prevChild = c1[i];
  6729. if (patched >= toBePatched) {
  6730. // all new children have been patched so this can only be a removal
  6731. unmount(prevChild, parentComponent, parentSuspense, true);
  6732. continue;
  6733. }
  6734. let newIndex;
  6735. if (prevChild.key != null) {
  6736. newIndex = keyToNewIndexMap.get(prevChild.key);
  6737. }
  6738. else {
  6739. // key-less node, try to locate a key-less node of the same type
  6740. for (j = s2; j <= e2; j++) {
  6741. if (newIndexToOldIndexMap[j - s2] === 0 &&
  6742. isSameVNodeType(prevChild, c2[j])) {
  6743. newIndex = j;
  6744. break;
  6745. }
  6746. }
  6747. }
  6748. if (newIndex === undefined) {
  6749. unmount(prevChild, parentComponent, parentSuspense, true);
  6750. }
  6751. else {
  6752. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  6753. if (newIndex >= maxNewIndexSoFar) {
  6754. maxNewIndexSoFar = newIndex;
  6755. }
  6756. else {
  6757. moved = true;
  6758. }
  6759. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6760. patched++;
  6761. }
  6762. }
  6763. // 5.3 move and mount
  6764. // generate longest stable subsequence only when nodes have moved
  6765. const increasingNewIndexSequence = moved
  6766. ? getSequence(newIndexToOldIndexMap)
  6767. : EMPTY_ARR;
  6768. j = increasingNewIndexSequence.length - 1;
  6769. // looping backwards so that we can use last patched node as anchor
  6770. for (i = toBePatched - 1; i >= 0; i--) {
  6771. const nextIndex = s2 + i;
  6772. const nextChild = c2[nextIndex];
  6773. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  6774. if (newIndexToOldIndexMap[i] === 0) {
  6775. // mount new
  6776. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6777. }
  6778. else if (moved) {
  6779. // move if:
  6780. // There is no stable subsequence (e.g. a reverse)
  6781. // OR current node is not among the stable sequence
  6782. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  6783. move(nextChild, container, anchor, 2 /* REORDER */);
  6784. }
  6785. else {
  6786. j--;
  6787. }
  6788. }
  6789. }
  6790. }
  6791. };
  6792. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  6793. const { el, type, transition, children, shapeFlag } = vnode;
  6794. if (shapeFlag & 6 /* COMPONENT */) {
  6795. move(vnode.component.subTree, container, anchor, moveType);
  6796. return;
  6797. }
  6798. if (shapeFlag & 128 /* SUSPENSE */) {
  6799. vnode.suspense.move(container, anchor, moveType);
  6800. return;
  6801. }
  6802. if (shapeFlag & 64 /* TELEPORT */) {
  6803. type.move(vnode, container, anchor, internals);
  6804. return;
  6805. }
  6806. if (type === Fragment) {
  6807. hostInsert(el, container, anchor);
  6808. for (let i = 0; i < children.length; i++) {
  6809. move(children[i], container, anchor, moveType);
  6810. }
  6811. hostInsert(vnode.anchor, container, anchor);
  6812. return;
  6813. }
  6814. if (type === Static) {
  6815. moveStaticNode(vnode, container, anchor);
  6816. return;
  6817. }
  6818. // single nodes
  6819. const needTransition = moveType !== 2 /* REORDER */ &&
  6820. shapeFlag & 1 /* ELEMENT */ &&
  6821. transition;
  6822. if (needTransition) {
  6823. if (moveType === 0 /* ENTER */) {
  6824. transition.beforeEnter(el);
  6825. hostInsert(el, container, anchor);
  6826. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  6827. }
  6828. else {
  6829. const { leave, delayLeave, afterLeave } = transition;
  6830. const remove = () => hostInsert(el, container, anchor);
  6831. const performLeave = () => {
  6832. leave(el, () => {
  6833. remove();
  6834. afterLeave && afterLeave();
  6835. });
  6836. };
  6837. if (delayLeave) {
  6838. delayLeave(el, remove, performLeave);
  6839. }
  6840. else {
  6841. performLeave();
  6842. }
  6843. }
  6844. }
  6845. else {
  6846. hostInsert(el, container, anchor);
  6847. }
  6848. };
  6849. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  6850. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  6851. // unset ref
  6852. if (ref != null) {
  6853. setRef(ref, null, parentSuspense, vnode, true);
  6854. }
  6855. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  6856. parentComponent.ctx.deactivate(vnode);
  6857. return;
  6858. }
  6859. const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
  6860. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  6861. let vnodeHook;
  6862. if (shouldInvokeVnodeHook &&
  6863. (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  6864. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6865. }
  6866. if (shapeFlag & 6 /* COMPONENT */) {
  6867. unmountComponent(vnode.component, parentSuspense, doRemove);
  6868. }
  6869. else {
  6870. if (shapeFlag & 128 /* SUSPENSE */) {
  6871. vnode.suspense.unmount(parentSuspense, doRemove);
  6872. return;
  6873. }
  6874. if (shouldInvokeDirs) {
  6875. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  6876. }
  6877. if (shapeFlag & 64 /* TELEPORT */) {
  6878. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  6879. }
  6880. else if (dynamicChildren &&
  6881. // #1153: fast path should not be taken for non-stable (v-for) fragments
  6882. (type !== Fragment ||
  6883. (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
  6884. // fast path for block nodes: only need to unmount dynamic children.
  6885. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  6886. }
  6887. else if ((type === Fragment &&
  6888. patchFlag &
  6889. (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
  6890. (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
  6891. unmountChildren(children, parentComponent, parentSuspense);
  6892. }
  6893. if (doRemove) {
  6894. remove(vnode);
  6895. }
  6896. }
  6897. if ((shouldInvokeVnodeHook &&
  6898. (vnodeHook = props && props.onVnodeUnmounted)) ||
  6899. shouldInvokeDirs) {
  6900. queuePostRenderEffect(() => {
  6901. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6902. shouldInvokeDirs &&
  6903. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  6904. }, parentSuspense);
  6905. }
  6906. };
  6907. const remove = vnode => {
  6908. const { type, el, anchor, transition } = vnode;
  6909. if (type === Fragment) {
  6910. if (vnode.patchFlag > 0 &&
  6911. vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
  6912. transition &&
  6913. !transition.persisted) {
  6914. vnode.children.forEach(child => {
  6915. if (child.type === Comment) {
  6916. hostRemove(child.el);
  6917. }
  6918. else {
  6919. remove(child);
  6920. }
  6921. });
  6922. }
  6923. else {
  6924. removeFragment(el, anchor);
  6925. }
  6926. return;
  6927. }
  6928. if (type === Static) {
  6929. removeStaticNode(vnode);
  6930. return;
  6931. }
  6932. const performRemove = () => {
  6933. hostRemove(el);
  6934. if (transition && !transition.persisted && transition.afterLeave) {
  6935. transition.afterLeave();
  6936. }
  6937. };
  6938. if (vnode.shapeFlag & 1 /* ELEMENT */ &&
  6939. transition &&
  6940. !transition.persisted) {
  6941. const { leave, delayLeave } = transition;
  6942. const performLeave = () => leave(el, performRemove);
  6943. if (delayLeave) {
  6944. delayLeave(vnode.el, performRemove, performLeave);
  6945. }
  6946. else {
  6947. performLeave();
  6948. }
  6949. }
  6950. else {
  6951. performRemove();
  6952. }
  6953. };
  6954. const removeFragment = (cur, end) => {
  6955. // For fragments, directly remove all contained DOM nodes.
  6956. // (fragment child nodes cannot have transition)
  6957. let next;
  6958. while (cur !== end) {
  6959. next = hostNextSibling(cur);
  6960. hostRemove(cur);
  6961. cur = next;
  6962. }
  6963. hostRemove(end);
  6964. };
  6965. const unmountComponent = (instance, parentSuspense, doRemove) => {
  6966. if (instance.type.__hmrId) {
  6967. unregisterHMR(instance);
  6968. }
  6969. const { bum, scope, update, subTree, um } = instance;
  6970. // beforeUnmount hook
  6971. if (bum) {
  6972. invokeArrayFns(bum);
  6973. }
  6974. // stop effects in component scope
  6975. scope.stop();
  6976. // update may be null if a component is unmounted before its async
  6977. // setup has resolved.
  6978. if (update) {
  6979. // so that scheduler will no longer invoke it
  6980. update.active = false;
  6981. unmount(subTree, instance, parentSuspense, doRemove);
  6982. }
  6983. // unmounted hook
  6984. if (um) {
  6985. queuePostRenderEffect(um, parentSuspense);
  6986. }
  6987. queuePostRenderEffect(() => {
  6988. instance.isUnmounted = true;
  6989. }, parentSuspense);
  6990. // A component with async dep inside a pending suspense is unmounted before
  6991. // its async dep resolves. This should remove the dep from the suspense, and
  6992. // cause the suspense to resolve immediately if that was the last dep.
  6993. if (parentSuspense &&
  6994. parentSuspense.pendingBranch &&
  6995. !parentSuspense.isUnmounted &&
  6996. instance.asyncDep &&
  6997. !instance.asyncResolved &&
  6998. instance.suspenseId === parentSuspense.pendingId) {
  6999. parentSuspense.deps--;
  7000. if (parentSuspense.deps === 0) {
  7001. parentSuspense.resolve();
  7002. }
  7003. }
  7004. {
  7005. devtoolsComponentRemoved(instance);
  7006. }
  7007. };
  7008. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7009. for (let i = start; i < children.length; i++) {
  7010. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7011. }
  7012. };
  7013. const getNextHostNode = vnode => {
  7014. if (vnode.shapeFlag & 6 /* COMPONENT */) {
  7015. return getNextHostNode(vnode.component.subTree);
  7016. }
  7017. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  7018. return vnode.suspense.next();
  7019. }
  7020. return hostNextSibling((vnode.anchor || vnode.el));
  7021. };
  7022. const render = (vnode, container, isSVG) => {
  7023. if (vnode == null) {
  7024. if (container._vnode) {
  7025. unmount(container._vnode, null, null, true);
  7026. }
  7027. }
  7028. else {
  7029. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7030. }
  7031. flushPostFlushCbs();
  7032. container._vnode = vnode;
  7033. };
  7034. const internals = {
  7035. p: patch,
  7036. um: unmount,
  7037. m: move,
  7038. r: remove,
  7039. mt: mountComponent,
  7040. mc: mountChildren,
  7041. pc: patchChildren,
  7042. pbc: patchBlockChildren,
  7043. n: getNextHostNode,
  7044. o: options
  7045. };
  7046. let hydrate;
  7047. let hydrateNode;
  7048. if (createHydrationFns) {
  7049. [hydrate, hydrateNode] = createHydrationFns(internals);
  7050. }
  7051. return {
  7052. render,
  7053. hydrate,
  7054. createApp: createAppAPI(render, hydrate)
  7055. };
  7056. }
  7057. function toggleRecurse({ effect, update }, allowed) {
  7058. effect.allowRecurse = update.allowRecurse = allowed;
  7059. }
  7060. /**
  7061. * #1156
  7062. * When a component is HMR-enabled, we need to make sure that all static nodes
  7063. * inside a block also inherit the DOM element from the previous tree so that
  7064. * HMR updates (which are full updates) can retrieve the element for patching.
  7065. *
  7066. * #2080
  7067. * Inside keyed `template` fragment static children, if a fragment is moved,
  7068. * the children will always be moved. Therefore, in order to ensure correct move
  7069. * position, el should be inherited from previous nodes.
  7070. */
  7071. function traverseStaticChildren(n1, n2, shallow = false) {
  7072. const ch1 = n1.children;
  7073. const ch2 = n2.children;
  7074. if (isArray(ch1) && isArray(ch2)) {
  7075. for (let i = 0; i < ch1.length; i++) {
  7076. // this is only called in the optimized path so array children are
  7077. // guaranteed to be vnodes
  7078. const c1 = ch1[i];
  7079. let c2 = ch2[i];
  7080. if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
  7081. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
  7082. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7083. c2.el = c1.el;
  7084. }
  7085. if (!shallow)
  7086. traverseStaticChildren(c1, c2);
  7087. }
  7088. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  7089. // would have received .el during block patch)
  7090. if (c2.type === Comment && !c2.el) {
  7091. c2.el = c1.el;
  7092. }
  7093. }
  7094. }
  7095. }
  7096. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  7097. function getSequence(arr) {
  7098. const p = arr.slice();
  7099. const result = [0];
  7100. let i, j, u, v, c;
  7101. const len = arr.length;
  7102. for (i = 0; i < len; i++) {
  7103. const arrI = arr[i];
  7104. if (arrI !== 0) {
  7105. j = result[result.length - 1];
  7106. if (arr[j] < arrI) {
  7107. p[i] = j;
  7108. result.push(i);
  7109. continue;
  7110. }
  7111. u = 0;
  7112. v = result.length - 1;
  7113. while (u < v) {
  7114. c = (u + v) >> 1;
  7115. if (arr[result[c]] < arrI) {
  7116. u = c + 1;
  7117. }
  7118. else {
  7119. v = c;
  7120. }
  7121. }
  7122. if (arrI < arr[result[u]]) {
  7123. if (u > 0) {
  7124. p[i] = result[u - 1];
  7125. }
  7126. result[u] = i;
  7127. }
  7128. }
  7129. }
  7130. u = result.length;
  7131. v = result[u - 1];
  7132. while (u-- > 0) {
  7133. result[u] = v;
  7134. v = p[v];
  7135. }
  7136. return result;
  7137. }
  7138. const isTeleport = (type) => type.__isTeleport;
  7139. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  7140. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  7141. const resolveTarget = (props, select) => {
  7142. const targetSelector = props && props.to;
  7143. if (isString(targetSelector)) {
  7144. if (!select) {
  7145. warn$1(`Current renderer does not support string target for Teleports. ` +
  7146. `(missing querySelector renderer option)`);
  7147. return null;
  7148. }
  7149. else {
  7150. const target = select(targetSelector);
  7151. if (!target) {
  7152. warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  7153. `Note the target element must exist before the component is mounted - ` +
  7154. `i.e. the target cannot be rendered by the component itself, and ` +
  7155. `ideally should be outside of the entire Vue component tree.`);
  7156. }
  7157. return target;
  7158. }
  7159. }
  7160. else {
  7161. if (!targetSelector && !isTeleportDisabled(props)) {
  7162. warn$1(`Invalid Teleport target: ${targetSelector}`);
  7163. }
  7164. return targetSelector;
  7165. }
  7166. };
  7167. const TeleportImpl = {
  7168. __isTeleport: true,
  7169. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7170. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  7171. const disabled = isTeleportDisabled(n2.props);
  7172. let { shapeFlag, children, dynamicChildren } = n2;
  7173. // #3302
  7174. // HMR updated, force full diff
  7175. if (isHmrUpdating) {
  7176. optimized = false;
  7177. dynamicChildren = null;
  7178. }
  7179. if (n1 == null) {
  7180. // insert anchors in the main view
  7181. const placeholder = (n2.el = createComment('teleport start')
  7182. );
  7183. const mainAnchor = (n2.anchor = createComment('teleport end')
  7184. );
  7185. insert(placeholder, container, anchor);
  7186. insert(mainAnchor, container, anchor);
  7187. const target = (n2.target = resolveTarget(n2.props, querySelector));
  7188. const targetAnchor = (n2.targetAnchor = createText(''));
  7189. if (target) {
  7190. insert(targetAnchor, target);
  7191. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  7192. isSVG = isSVG || isTargetSVG(target);
  7193. }
  7194. else if (!disabled) {
  7195. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
  7196. }
  7197. const mount = (container, anchor) => {
  7198. // Teleport *always* has Array children. This is enforced in both the
  7199. // compiler and vnode children normalization.
  7200. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7201. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7202. }
  7203. };
  7204. if (disabled) {
  7205. mount(container, mainAnchor);
  7206. }
  7207. else if (target) {
  7208. mount(target, targetAnchor);
  7209. }
  7210. }
  7211. else {
  7212. // update content
  7213. n2.el = n1.el;
  7214. const mainAnchor = (n2.anchor = n1.anchor);
  7215. const target = (n2.target = n1.target);
  7216. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  7217. const wasDisabled = isTeleportDisabled(n1.props);
  7218. const currentContainer = wasDisabled ? container : target;
  7219. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7220. isSVG = isSVG || isTargetSVG(target);
  7221. if (dynamicChildren) {
  7222. // fast path when the teleport happens to be a block root
  7223. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  7224. // even in block tree mode we need to make sure all root-level nodes
  7225. // in the teleport inherit previous DOM references so that they can
  7226. // be moved in future patches.
  7227. traverseStaticChildren(n1, n2, true);
  7228. }
  7229. else if (!optimized) {
  7230. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  7231. }
  7232. if (disabled) {
  7233. if (!wasDisabled) {
  7234. // enabled -> disabled
  7235. // move into main container
  7236. moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
  7237. }
  7238. }
  7239. else {
  7240. // target changed
  7241. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7242. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  7243. if (nextTarget) {
  7244. moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
  7245. }
  7246. else {
  7247. warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
  7248. }
  7249. }
  7250. else if (wasDisabled) {
  7251. // disabled -> enabled
  7252. // move into teleport target
  7253. moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
  7254. }
  7255. }
  7256. }
  7257. },
  7258. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  7259. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  7260. if (target) {
  7261. hostRemove(targetAnchor);
  7262. }
  7263. // an unmounted teleport should always remove its children if not disabled
  7264. if (doRemove || !isTeleportDisabled(props)) {
  7265. hostRemove(anchor);
  7266. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7267. for (let i = 0; i < children.length; i++) {
  7268. const child = children[i];
  7269. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  7270. }
  7271. }
  7272. }
  7273. },
  7274. move: moveTeleport,
  7275. hydrate: hydrateTeleport
  7276. };
  7277. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
  7278. // move target anchor if this is a target change.
  7279. if (moveType === 0 /* TARGET_CHANGE */) {
  7280. insert(vnode.targetAnchor, container, parentAnchor);
  7281. }
  7282. const { el, anchor, shapeFlag, children, props } = vnode;
  7283. const isReorder = moveType === 2 /* REORDER */;
  7284. // move main view anchor if this is a re-order.
  7285. if (isReorder) {
  7286. insert(el, container, parentAnchor);
  7287. }
  7288. // if this is a re-order and teleport is enabled (content is in target)
  7289. // do not move children. So the opposite is: only move children if this
  7290. // is not a reorder, or the teleport is disabled
  7291. if (!isReorder || isTeleportDisabled(props)) {
  7292. // Teleport has either Array children or no children.
  7293. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7294. for (let i = 0; i < children.length; i++) {
  7295. move(children[i], container, parentAnchor, 2 /* REORDER */);
  7296. }
  7297. }
  7298. }
  7299. // move main view anchor if this is a re-order.
  7300. if (isReorder) {
  7301. insert(anchor, container, parentAnchor);
  7302. }
  7303. }
  7304. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  7305. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  7306. if (target) {
  7307. // if multiple teleports rendered to the same target element, we need to
  7308. // pick up from where the last teleport finished instead of the first node
  7309. const targetNode = target._lpa || target.firstChild;
  7310. if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7311. if (isTeleportDisabled(vnode.props)) {
  7312. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  7313. vnode.targetAnchor = targetNode;
  7314. }
  7315. else {
  7316. vnode.anchor = nextSibling(node);
  7317. vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  7318. }
  7319. target._lpa =
  7320. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  7321. }
  7322. }
  7323. return vnode.anchor && nextSibling(vnode.anchor);
  7324. }
  7325. // Force-casted public typing for h and TSX props inference
  7326. const Teleport = TeleportImpl;
  7327. const COMPONENTS = 'components';
  7328. const DIRECTIVES = 'directives';
  7329. /**
  7330. * @private
  7331. */
  7332. function resolveComponent(name, maybeSelfReference) {
  7333. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  7334. }
  7335. const NULL_DYNAMIC_COMPONENT = Symbol();
  7336. /**
  7337. * @private
  7338. */
  7339. function resolveDynamicComponent(component) {
  7340. if (isString(component)) {
  7341. return resolveAsset(COMPONENTS, component, false) || component;
  7342. }
  7343. else {
  7344. // invalid types will fallthrough to createVNode and raise warning
  7345. return (component || NULL_DYNAMIC_COMPONENT);
  7346. }
  7347. }
  7348. /**
  7349. * @private
  7350. */
  7351. function resolveDirective(name) {
  7352. return resolveAsset(DIRECTIVES, name);
  7353. }
  7354. // implementation
  7355. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  7356. const instance = currentRenderingInstance || currentInstance;
  7357. if (instance) {
  7358. const Component = instance.type;
  7359. // explicit self name has highest priority
  7360. if (type === COMPONENTS) {
  7361. const selfName = getComponentName(Component);
  7362. if (selfName &&
  7363. (selfName === name ||
  7364. selfName === camelize(name) ||
  7365. selfName === capitalize(camelize(name)))) {
  7366. return Component;
  7367. }
  7368. }
  7369. const res =
  7370. // local registration
  7371. // check instance[type] first which is resolved for options API
  7372. resolve(instance[type] || Component[type], name) ||
  7373. // global registration
  7374. resolve(instance.appContext[type], name);
  7375. if (!res && maybeSelfReference) {
  7376. // fallback to implicit self-reference
  7377. return Component;
  7378. }
  7379. if (warnMissing && !res) {
  7380. const extra = type === COMPONENTS
  7381. ? `\nIf this is a native custom element, make sure to exclude it from ` +
  7382. `component resolution via compilerOptions.isCustomElement.`
  7383. : ``;
  7384. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  7385. }
  7386. return res;
  7387. }
  7388. else {
  7389. warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
  7390. `can only be used in render() or setup().`);
  7391. }
  7392. }
  7393. function resolve(registry, name) {
  7394. return (registry &&
  7395. (registry[name] ||
  7396. registry[camelize(name)] ||
  7397. registry[capitalize(camelize(name))]));
  7398. }
  7399. const Fragment = Symbol('Fragment' );
  7400. const Text = Symbol('Text' );
  7401. const Comment = Symbol('Comment' );
  7402. const Static = Symbol('Static' );
  7403. // Since v-if and v-for are the two possible ways node structure can dynamically
  7404. // change, once we consider v-if branches and each v-for fragment a block, we
  7405. // can divide a template into nested blocks, and within each block the node
  7406. // structure would be stable. This allows us to skip most children diffing
  7407. // and only worry about the dynamic nodes (indicated by patch flags).
  7408. const blockStack = [];
  7409. let currentBlock = null;
  7410. /**
  7411. * Open a block.
  7412. * This must be called before `createBlock`. It cannot be part of `createBlock`
  7413. * because the children of the block are evaluated before `createBlock` itself
  7414. * is called. The generated code typically looks like this:
  7415. *
  7416. * ```js
  7417. * function render() {
  7418. * return (openBlock(),createBlock('div', null, [...]))
  7419. * }
  7420. * ```
  7421. * disableTracking is true when creating a v-for fragment block, since a v-for
  7422. * fragment always diffs its children.
  7423. *
  7424. * @private
  7425. */
  7426. function openBlock(disableTracking = false) {
  7427. blockStack.push((currentBlock = disableTracking ? null : []));
  7428. }
  7429. function closeBlock() {
  7430. blockStack.pop();
  7431. currentBlock = blockStack[blockStack.length - 1] || null;
  7432. }
  7433. // Whether we should be tracking dynamic child nodes inside a block.
  7434. // Only tracks when this value is > 0
  7435. // We are not using a simple boolean because this value may need to be
  7436. // incremented/decremented by nested usage of v-once (see below)
  7437. let isBlockTreeEnabled = 1;
  7438. /**
  7439. * Block tracking sometimes needs to be disabled, for example during the
  7440. * creation of a tree that needs to be cached by v-once. The compiler generates
  7441. * code like this:
  7442. *
  7443. * ``` js
  7444. * _cache[1] || (
  7445. * setBlockTracking(-1),
  7446. * _cache[1] = createVNode(...),
  7447. * setBlockTracking(1),
  7448. * _cache[1]
  7449. * )
  7450. * ```
  7451. *
  7452. * @private
  7453. */
  7454. function setBlockTracking(value) {
  7455. isBlockTreeEnabled += value;
  7456. }
  7457. function setupBlock(vnode) {
  7458. // save current block children on the block vnode
  7459. vnode.dynamicChildren =
  7460. isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  7461. // close block
  7462. closeBlock();
  7463. // a block is always going to be patched, so track it as a child of its
  7464. // parent block
  7465. if (isBlockTreeEnabled > 0 && currentBlock) {
  7466. currentBlock.push(vnode);
  7467. }
  7468. return vnode;
  7469. }
  7470. /**
  7471. * @private
  7472. */
  7473. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  7474. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  7475. }
  7476. /**
  7477. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  7478. * A block root keeps track of dynamic nodes within the block in the
  7479. * `dynamicChildren` array.
  7480. *
  7481. * @private
  7482. */
  7483. function createBlock(type, props, children, patchFlag, dynamicProps) {
  7484. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  7485. }
  7486. function isVNode(value) {
  7487. return value ? value.__v_isVNode === true : false;
  7488. }
  7489. function isSameVNodeType(n1, n2) {
  7490. if (n2.shapeFlag & 6 /* COMPONENT */ &&
  7491. hmrDirtyComponents.has(n2.type)) {
  7492. // HMR only: if the component has been hot-updated, force a reload.
  7493. return false;
  7494. }
  7495. return n1.type === n2.type && n1.key === n2.key;
  7496. }
  7497. let vnodeArgsTransformer;
  7498. /**
  7499. * Internal API for registering an arguments transform for createVNode
  7500. * used for creating stubs in the test-utils
  7501. * It is *internal* but needs to be exposed for test-utils to pick up proper
  7502. * typings
  7503. */
  7504. function transformVNodeArgs(transformer) {
  7505. vnodeArgsTransformer = transformer;
  7506. }
  7507. const createVNodeWithArgsTransform = (...args) => {
  7508. return _createVNode(...(vnodeArgsTransformer
  7509. ? vnodeArgsTransformer(args, currentRenderingInstance)
  7510. : args));
  7511. };
  7512. const InternalObjectKey = `__vInternal`;
  7513. const normalizeKey = ({ key }) => key != null ? key : null;
  7514. const normalizeRef = ({ ref, ref_key, ref_for }) => {
  7515. return (ref != null
  7516. ? isString(ref) || isRef(ref) || isFunction(ref)
  7517. ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
  7518. : ref
  7519. : null);
  7520. };
  7521. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
  7522. const vnode = {
  7523. __v_isVNode: true,
  7524. __v_skip: true,
  7525. type,
  7526. props,
  7527. key: props && normalizeKey(props),
  7528. ref: props && normalizeRef(props),
  7529. scopeId: currentScopeId,
  7530. slotScopeIds: null,
  7531. children,
  7532. component: null,
  7533. suspense: null,
  7534. ssContent: null,
  7535. ssFallback: null,
  7536. dirs: null,
  7537. transition: null,
  7538. el: null,
  7539. anchor: null,
  7540. target: null,
  7541. targetAnchor: null,
  7542. staticCount: 0,
  7543. shapeFlag,
  7544. patchFlag,
  7545. dynamicProps,
  7546. dynamicChildren: null,
  7547. appContext: null
  7548. };
  7549. if (needFullChildrenNormalization) {
  7550. normalizeChildren(vnode, children);
  7551. // normalize suspense children
  7552. if (shapeFlag & 128 /* SUSPENSE */) {
  7553. type.normalize(vnode);
  7554. }
  7555. }
  7556. else if (children) {
  7557. // compiled element vnode - if children is passed, only possible types are
  7558. // string or Array.
  7559. vnode.shapeFlag |= isString(children)
  7560. ? 8 /* TEXT_CHILDREN */
  7561. : 16 /* ARRAY_CHILDREN */;
  7562. }
  7563. // validate key
  7564. if (vnode.key !== vnode.key) {
  7565. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  7566. }
  7567. // track vnode for block tree
  7568. if (isBlockTreeEnabled > 0 &&
  7569. // avoid a block node from tracking itself
  7570. !isBlockNode &&
  7571. // has current parent block
  7572. currentBlock &&
  7573. // presence of a patch flag indicates this node needs patching on updates.
  7574. // component nodes also should always be patched, because even if the
  7575. // component doesn't need to update, it needs to persist the instance on to
  7576. // the next vnode so that it can be properly unmounted later.
  7577. (vnode.patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
  7578. // the EVENTS flag is only for hydration and if it is the only flag, the
  7579. // vnode should not be considered dynamic due to handler caching.
  7580. vnode.patchFlag !== 32 /* HYDRATE_EVENTS */) {
  7581. currentBlock.push(vnode);
  7582. }
  7583. return vnode;
  7584. }
  7585. const createVNode = (createVNodeWithArgsTransform );
  7586. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  7587. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  7588. if (!type) {
  7589. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  7590. }
  7591. type = Comment;
  7592. }
  7593. if (isVNode(type)) {
  7594. // createVNode receiving an existing vnode. This happens in cases like
  7595. // <component :is="vnode"/>
  7596. // #2078 make sure to merge refs during the clone instead of overwriting it
  7597. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  7598. if (children) {
  7599. normalizeChildren(cloned, children);
  7600. }
  7601. return cloned;
  7602. }
  7603. // class component normalization.
  7604. if (isClassComponent(type)) {
  7605. type = type.__vccOpts;
  7606. }
  7607. // class & style normalization.
  7608. if (props) {
  7609. // for reactive or proxy objects, we need to clone it to enable mutation.
  7610. props = guardReactiveProps(props);
  7611. let { class: klass, style } = props;
  7612. if (klass && !isString(klass)) {
  7613. props.class = normalizeClass(klass);
  7614. }
  7615. if (isObject(style)) {
  7616. // reactive state objects need to be cloned since they are likely to be
  7617. // mutated
  7618. if (isProxy(style) && !isArray(style)) {
  7619. style = extend({}, style);
  7620. }
  7621. props.style = normalizeStyle(style);
  7622. }
  7623. }
  7624. // encode the vnode type information into a bitmap
  7625. const shapeFlag = isString(type)
  7626. ? 1 /* ELEMENT */
  7627. : isSuspense(type)
  7628. ? 128 /* SUSPENSE */
  7629. : isTeleport(type)
  7630. ? 64 /* TELEPORT */
  7631. : isObject(type)
  7632. ? 4 /* STATEFUL_COMPONENT */
  7633. : isFunction(type)
  7634. ? 2 /* FUNCTIONAL_COMPONENT */
  7635. : 0;
  7636. if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
  7637. type = toRaw(type);
  7638. warn$1(`Vue received a Component which was made a reactive object. This can ` +
  7639. `lead to unnecessary performance overhead, and should be avoided by ` +
  7640. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  7641. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  7642. }
  7643. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  7644. }
  7645. function guardReactiveProps(props) {
  7646. if (!props)
  7647. return null;
  7648. return isProxy(props) || InternalObjectKey in props
  7649. ? extend({}, props)
  7650. : props;
  7651. }
  7652. function cloneVNode(vnode, extraProps, mergeRef = false) {
  7653. // This is intentionally NOT using spread or extend to avoid the runtime
  7654. // key enumeration cost.
  7655. const { props, ref, patchFlag, children } = vnode;
  7656. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  7657. const cloned = {
  7658. __v_isVNode: true,
  7659. __v_skip: true,
  7660. type: vnode.type,
  7661. props: mergedProps,
  7662. key: mergedProps && normalizeKey(mergedProps),
  7663. ref: extraProps && extraProps.ref
  7664. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  7665. // if the vnode itself already has a ref, cloneVNode will need to merge
  7666. // the refs so the single vnode can be set on multiple refs
  7667. mergeRef && ref
  7668. ? isArray(ref)
  7669. ? ref.concat(normalizeRef(extraProps))
  7670. : [ref, normalizeRef(extraProps)]
  7671. : normalizeRef(extraProps)
  7672. : ref,
  7673. scopeId: vnode.scopeId,
  7674. slotScopeIds: vnode.slotScopeIds,
  7675. children: patchFlag === -1 /* HOISTED */ && isArray(children)
  7676. ? children.map(deepCloneVNode)
  7677. : children,
  7678. target: vnode.target,
  7679. targetAnchor: vnode.targetAnchor,
  7680. staticCount: vnode.staticCount,
  7681. shapeFlag: vnode.shapeFlag,
  7682. // if the vnode is cloned with extra props, we can no longer assume its
  7683. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  7684. // note: preserve flag for fragments since they use the flag for children
  7685. // fast paths only.
  7686. patchFlag: extraProps && vnode.type !== Fragment
  7687. ? patchFlag === -1 // hoisted node
  7688. ? 16 /* FULL_PROPS */
  7689. : patchFlag | 16 /* FULL_PROPS */
  7690. : patchFlag,
  7691. dynamicProps: vnode.dynamicProps,
  7692. dynamicChildren: vnode.dynamicChildren,
  7693. appContext: vnode.appContext,
  7694. dirs: vnode.dirs,
  7695. transition: vnode.transition,
  7696. // These should technically only be non-null on mounted VNodes. However,
  7697. // they *should* be copied for kept-alive vnodes. So we just always copy
  7698. // them since them being non-null during a mount doesn't affect the logic as
  7699. // they will simply be overwritten.
  7700. component: vnode.component,
  7701. suspense: vnode.suspense,
  7702. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  7703. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  7704. el: vnode.el,
  7705. anchor: vnode.anchor
  7706. };
  7707. return cloned;
  7708. }
  7709. /**
  7710. * Dev only, for HMR of hoisted vnodes reused in v-for
  7711. * https://github.com/vitejs/vite/issues/2022
  7712. */
  7713. function deepCloneVNode(vnode) {
  7714. const cloned = cloneVNode(vnode);
  7715. if (isArray(vnode.children)) {
  7716. cloned.children = vnode.children.map(deepCloneVNode);
  7717. }
  7718. return cloned;
  7719. }
  7720. /**
  7721. * @private
  7722. */
  7723. function createTextVNode(text = ' ', flag = 0) {
  7724. return createVNode(Text, null, text, flag);
  7725. }
  7726. /**
  7727. * @private
  7728. */
  7729. function createStaticVNode(content, numberOfNodes) {
  7730. // A static vnode can contain multiple stringified elements, and the number
  7731. // of elements is necessary for hydration.
  7732. const vnode = createVNode(Static, null, content);
  7733. vnode.staticCount = numberOfNodes;
  7734. return vnode;
  7735. }
  7736. /**
  7737. * @private
  7738. */
  7739. function createCommentVNode(text = '',
  7740. // when used as the v-else branch, the comment node must be created as a
  7741. // block to ensure correct updates.
  7742. asBlock = false) {
  7743. return asBlock
  7744. ? (openBlock(), createBlock(Comment, null, text))
  7745. : createVNode(Comment, null, text);
  7746. }
  7747. function normalizeVNode(child) {
  7748. if (child == null || typeof child === 'boolean') {
  7749. // empty placeholder
  7750. return createVNode(Comment);
  7751. }
  7752. else if (isArray(child)) {
  7753. // fragment
  7754. return createVNode(Fragment, null,
  7755. // #3666, avoid reference pollution when reusing vnode
  7756. child.slice());
  7757. }
  7758. else if (typeof child === 'object') {
  7759. // already vnode, this should be the most common since compiled templates
  7760. // always produce all-vnode children arrays
  7761. return cloneIfMounted(child);
  7762. }
  7763. else {
  7764. // strings and numbers
  7765. return createVNode(Text, null, String(child));
  7766. }
  7767. }
  7768. // optimized normalization for template-compiled render fns
  7769. function cloneIfMounted(child) {
  7770. return child.el === null || child.memo ? child : cloneVNode(child);
  7771. }
  7772. function normalizeChildren(vnode, children) {
  7773. let type = 0;
  7774. const { shapeFlag } = vnode;
  7775. if (children == null) {
  7776. children = null;
  7777. }
  7778. else if (isArray(children)) {
  7779. type = 16 /* ARRAY_CHILDREN */;
  7780. }
  7781. else if (typeof children === 'object') {
  7782. if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
  7783. // Normalize slot to plain children for plain element and Teleport
  7784. const slot = children.default;
  7785. if (slot) {
  7786. // _c marker is added by withCtx() indicating this is a compiled slot
  7787. slot._c && (slot._d = false);
  7788. normalizeChildren(vnode, slot());
  7789. slot._c && (slot._d = true);
  7790. }
  7791. return;
  7792. }
  7793. else {
  7794. type = 32 /* SLOTS_CHILDREN */;
  7795. const slotFlag = children._;
  7796. if (!slotFlag && !(InternalObjectKey in children)) {
  7797. children._ctx = currentRenderingInstance;
  7798. }
  7799. else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
  7800. // a child component receives forwarded slots from the parent.
  7801. // its slot type is determined by its parent's slot type.
  7802. if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
  7803. children._ = 1 /* STABLE */;
  7804. }
  7805. else {
  7806. children._ = 2 /* DYNAMIC */;
  7807. vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  7808. }
  7809. }
  7810. }
  7811. }
  7812. else if (isFunction(children)) {
  7813. children = { default: children, _ctx: currentRenderingInstance };
  7814. type = 32 /* SLOTS_CHILDREN */;
  7815. }
  7816. else {
  7817. children = String(children);
  7818. // force teleport children to array so it can be moved around
  7819. if (shapeFlag & 64 /* TELEPORT */) {
  7820. type = 16 /* ARRAY_CHILDREN */;
  7821. children = [createTextVNode(children)];
  7822. }
  7823. else {
  7824. type = 8 /* TEXT_CHILDREN */;
  7825. }
  7826. }
  7827. vnode.children = children;
  7828. vnode.shapeFlag |= type;
  7829. }
  7830. function mergeProps(...args) {
  7831. const ret = {};
  7832. for (let i = 0; i < args.length; i++) {
  7833. const toMerge = args[i];
  7834. for (const key in toMerge) {
  7835. if (key === 'class') {
  7836. if (ret.class !== toMerge.class) {
  7837. ret.class = normalizeClass([ret.class, toMerge.class]);
  7838. }
  7839. }
  7840. else if (key === 'style') {
  7841. ret.style = normalizeStyle([ret.style, toMerge.style]);
  7842. }
  7843. else if (isOn(key)) {
  7844. const existing = ret[key];
  7845. const incoming = toMerge[key];
  7846. if (incoming &&
  7847. existing !== incoming &&
  7848. !(isArray(existing) && existing.includes(incoming))) {
  7849. ret[key] = existing
  7850. ? [].concat(existing, incoming)
  7851. : incoming;
  7852. }
  7853. }
  7854. else if (key !== '') {
  7855. ret[key] = toMerge[key];
  7856. }
  7857. }
  7858. }
  7859. return ret;
  7860. }
  7861. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  7862. callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
  7863. vnode,
  7864. prevVNode
  7865. ]);
  7866. }
  7867. /**
  7868. * Actual implementation
  7869. */
  7870. function renderList(source, renderItem, cache, index) {
  7871. let ret;
  7872. const cached = (cache && cache[index]);
  7873. if (isArray(source) || isString(source)) {
  7874. ret = new Array(source.length);
  7875. for (let i = 0, l = source.length; i < l; i++) {
  7876. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  7877. }
  7878. }
  7879. else if (typeof source === 'number') {
  7880. if (!Number.isInteger(source)) {
  7881. warn$1(`The v-for range expect an integer value but got ${source}.`);
  7882. return [];
  7883. }
  7884. ret = new Array(source);
  7885. for (let i = 0; i < source; i++) {
  7886. ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
  7887. }
  7888. }
  7889. else if (isObject(source)) {
  7890. if (source[Symbol.iterator]) {
  7891. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  7892. }
  7893. else {
  7894. const keys = Object.keys(source);
  7895. ret = new Array(keys.length);
  7896. for (let i = 0, l = keys.length; i < l; i++) {
  7897. const key = keys[i];
  7898. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  7899. }
  7900. }
  7901. }
  7902. else {
  7903. ret = [];
  7904. }
  7905. if (cache) {
  7906. cache[index] = ret;
  7907. }
  7908. return ret;
  7909. }
  7910. /**
  7911. * Compiler runtime helper for creating dynamic slots object
  7912. * @private
  7913. */
  7914. function createSlots(slots, dynamicSlots) {
  7915. for (let i = 0; i < dynamicSlots.length; i++) {
  7916. const slot = dynamicSlots[i];
  7917. // array of dynamic slot generated by <template v-for="..." #[...]>
  7918. if (isArray(slot)) {
  7919. for (let j = 0; j < slot.length; j++) {
  7920. slots[slot[j].name] = slot[j].fn;
  7921. }
  7922. }
  7923. else if (slot) {
  7924. // conditional single slot generated by <template v-if="..." #foo>
  7925. slots[slot.name] = slot.fn;
  7926. }
  7927. }
  7928. return slots;
  7929. }
  7930. /**
  7931. * Compiler runtime helper for rendering `<slot/>`
  7932. * @private
  7933. */
  7934. function renderSlot(slots, name, props = {},
  7935. // this is not a user-facing function, so the fallback is always generated by
  7936. // the compiler and guaranteed to be a function returning an array
  7937. fallback, noSlotted) {
  7938. if (currentRenderingInstance.isCE ||
  7939. (currentRenderingInstance.parent &&
  7940. isAsyncWrapper(currentRenderingInstance.parent) &&
  7941. currentRenderingInstance.parent.isCE)) {
  7942. return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
  7943. }
  7944. let slot = slots[name];
  7945. if (slot && slot.length > 1) {
  7946. warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  7947. `function. You need to mark this component with $dynamic-slots in the ` +
  7948. `parent template.`);
  7949. slot = () => [];
  7950. }
  7951. // a compiled slot disables block tracking by default to avoid manual
  7952. // invocation interfering with template-based block tracking, but in
  7953. // `renderSlot` we can be sure that it's template-based so we can force
  7954. // enable it.
  7955. if (slot && slot._c) {
  7956. slot._d = false;
  7957. }
  7958. openBlock();
  7959. const validSlotContent = slot && ensureValidVNode(slot(props));
  7960. const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
  7961. ? 64 /* STABLE_FRAGMENT */
  7962. : -2 /* BAIL */);
  7963. if (!noSlotted && rendered.scopeId) {
  7964. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  7965. }
  7966. if (slot && slot._c) {
  7967. slot._d = true;
  7968. }
  7969. return rendered;
  7970. }
  7971. function ensureValidVNode(vnodes) {
  7972. return vnodes.some(child => {
  7973. if (!isVNode(child))
  7974. return true;
  7975. if (child.type === Comment)
  7976. return false;
  7977. if (child.type === Fragment &&
  7978. !ensureValidVNode(child.children))
  7979. return false;
  7980. return true;
  7981. })
  7982. ? vnodes
  7983. : null;
  7984. }
  7985. /**
  7986. * For prefixing keys in v-on="obj" with "on"
  7987. * @private
  7988. */
  7989. function toHandlers(obj) {
  7990. const ret = {};
  7991. if (!isObject(obj)) {
  7992. warn$1(`v-on with no argument expects an object value.`);
  7993. return ret;
  7994. }
  7995. for (const key in obj) {
  7996. ret[toHandlerKey(key)] = obj[key];
  7997. }
  7998. return ret;
  7999. }
  8000. /**
  8001. * #2437 In Vue 3, functional components do not have a public instance proxy but
  8002. * they exist in the internal parent chain. For code that relies on traversing
  8003. * public $parent chains, skip functional ones and go to the parent instead.
  8004. */
  8005. const getPublicInstance = (i) => {
  8006. if (!i)
  8007. return null;
  8008. if (isStatefulComponent(i))
  8009. return getExposeProxy(i) || i.proxy;
  8010. return getPublicInstance(i.parent);
  8011. };
  8012. const publicPropertiesMap =
  8013. // Move PURE marker to new line to workaround compiler discarding it
  8014. // due to type annotation
  8015. /*#__PURE__*/ extend(Object.create(null), {
  8016. $: i => i,
  8017. $el: i => i.vnode.el,
  8018. $data: i => i.data,
  8019. $props: i => (shallowReadonly(i.props) ),
  8020. $attrs: i => (shallowReadonly(i.attrs) ),
  8021. $slots: i => (shallowReadonly(i.slots) ),
  8022. $refs: i => (shallowReadonly(i.refs) ),
  8023. $parent: i => getPublicInstance(i.parent),
  8024. $root: i => getPublicInstance(i.root),
  8025. $emit: i => i.emit,
  8026. $options: i => (resolveMergedOptions(i) ),
  8027. $forceUpdate: i => () => queueJob(i.update),
  8028. $nextTick: i => nextTick.bind(i.proxy),
  8029. $watch: i => (instanceWatch.bind(i) )
  8030. });
  8031. const PublicInstanceProxyHandlers = {
  8032. get({ _: instance }, key) {
  8033. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  8034. // for internal formatters to know that this is a Vue instance
  8035. if (key === '__isVue') {
  8036. return true;
  8037. }
  8038. // prioritize <script setup> bindings during dev.
  8039. // this allows even properties that start with _ or $ to be used - so that
  8040. // it aligns with the production behavior where the render fn is inlined and
  8041. // indeed has access to all declared variables.
  8042. if (setupState !== EMPTY_OBJ &&
  8043. setupState.__isScriptSetup &&
  8044. hasOwn(setupState, key)) {
  8045. return setupState[key];
  8046. }
  8047. // data / props / ctx
  8048. // This getter gets called for every property access on the render context
  8049. // during render and is a major hotspot. The most expensive part of this
  8050. // is the multiple hasOwn() calls. It's much faster to do a simple property
  8051. // access on a plain object, so we use an accessCache object (with null
  8052. // prototype) to memoize what access type a key corresponds to.
  8053. let normalizedProps;
  8054. if (key[0] !== '$') {
  8055. const n = accessCache[key];
  8056. if (n !== undefined) {
  8057. switch (n) {
  8058. case 1 /* SETUP */:
  8059. return setupState[key];
  8060. case 2 /* DATA */:
  8061. return data[key];
  8062. case 4 /* CONTEXT */:
  8063. return ctx[key];
  8064. case 3 /* PROPS */:
  8065. return props[key];
  8066. // default: just fallthrough
  8067. }
  8068. }
  8069. else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  8070. accessCache[key] = 1 /* SETUP */;
  8071. return setupState[key];
  8072. }
  8073. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  8074. accessCache[key] = 2 /* DATA */;
  8075. return data[key];
  8076. }
  8077. else if (
  8078. // only cache other properties when instance has declared (thus stable)
  8079. // props
  8080. (normalizedProps = instance.propsOptions[0]) &&
  8081. hasOwn(normalizedProps, key)) {
  8082. accessCache[key] = 3 /* PROPS */;
  8083. return props[key];
  8084. }
  8085. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  8086. accessCache[key] = 4 /* CONTEXT */;
  8087. return ctx[key];
  8088. }
  8089. else if (shouldCacheAccess) {
  8090. accessCache[key] = 0 /* OTHER */;
  8091. }
  8092. }
  8093. const publicGetter = publicPropertiesMap[key];
  8094. let cssModule, globalProperties;
  8095. // public $xxx properties
  8096. if (publicGetter) {
  8097. if (key === '$attrs') {
  8098. track(instance, "get" /* GET */, key);
  8099. markAttrsAccessed();
  8100. }
  8101. return publicGetter(instance);
  8102. }
  8103. else if (
  8104. // css module (injected by vue-loader)
  8105. (cssModule = type.__cssModules) &&
  8106. (cssModule = cssModule[key])) {
  8107. return cssModule;
  8108. }
  8109. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  8110. // user may set custom properties to `this` that start with `$`
  8111. accessCache[key] = 4 /* CONTEXT */;
  8112. return ctx[key];
  8113. }
  8114. else if (
  8115. // global properties
  8116. ((globalProperties = appContext.config.globalProperties),
  8117. hasOwn(globalProperties, key))) {
  8118. {
  8119. return globalProperties[key];
  8120. }
  8121. }
  8122. else if (currentRenderingInstance &&
  8123. (!isString(key) ||
  8124. // #1091 avoid internal isRef/isVNode checks on component instance leading
  8125. // to infinite warning loop
  8126. key.indexOf('__v') !== 0)) {
  8127. if (data !== EMPTY_OBJ &&
  8128. (key[0] === '$' || key[0] === '_') &&
  8129. hasOwn(data, key)) {
  8130. warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  8131. `character ("$" or "_") and is not proxied on the render context.`);
  8132. }
  8133. else if (instance === currentRenderingInstance) {
  8134. warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
  8135. `but is not defined on instance.`);
  8136. }
  8137. }
  8138. },
  8139. set({ _: instance }, key, value) {
  8140. const { data, setupState, ctx } = instance;
  8141. if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  8142. setupState[key] = value;
  8143. return true;
  8144. }
  8145. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  8146. data[key] = value;
  8147. return true;
  8148. }
  8149. else if (hasOwn(instance.props, key)) {
  8150. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
  8151. return false;
  8152. }
  8153. if (key[0] === '$' && key.slice(1) in instance) {
  8154. warn$1(`Attempting to mutate public property "${key}". ` +
  8155. `Properties starting with $ are reserved and readonly.`, instance);
  8156. return false;
  8157. }
  8158. else {
  8159. if (key in instance.appContext.config.globalProperties) {
  8160. Object.defineProperty(ctx, key, {
  8161. enumerable: true,
  8162. configurable: true,
  8163. value
  8164. });
  8165. }
  8166. else {
  8167. ctx[key] = value;
  8168. }
  8169. }
  8170. return true;
  8171. },
  8172. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  8173. let normalizedProps;
  8174. return (!!accessCache[key] ||
  8175. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  8176. (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
  8177. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  8178. hasOwn(ctx, key) ||
  8179. hasOwn(publicPropertiesMap, key) ||
  8180. hasOwn(appContext.config.globalProperties, key));
  8181. },
  8182. defineProperty(target, key, descriptor) {
  8183. if (descriptor.get != null) {
  8184. // invalidate key cache of a getter based property #5417
  8185. target._.accessCache[key] = 0;
  8186. }
  8187. else if (hasOwn(descriptor, 'value')) {
  8188. this.set(target, key, descriptor.value, null);
  8189. }
  8190. return Reflect.defineProperty(target, key, descriptor);
  8191. }
  8192. };
  8193. {
  8194. PublicInstanceProxyHandlers.ownKeys = (target) => {
  8195. warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  8196. `The keys will be empty in production mode to avoid performance overhead.`);
  8197. return Reflect.ownKeys(target);
  8198. };
  8199. }
  8200. const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
  8201. get(target, key) {
  8202. // fast path for unscopables when using `with` block
  8203. if (key === Symbol.unscopables) {
  8204. return;
  8205. }
  8206. return PublicInstanceProxyHandlers.get(target, key, target);
  8207. },
  8208. has(_, key) {
  8209. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  8210. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  8211. warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  8212. }
  8213. return has;
  8214. }
  8215. });
  8216. // dev only
  8217. // In dev mode, the proxy target exposes the same properties as seen on `this`
  8218. // for easier console inspection. In prod mode it will be an empty object so
  8219. // these properties definitions can be skipped.
  8220. function createDevRenderContext(instance) {
  8221. const target = {};
  8222. // expose internal instance for proxy handlers
  8223. Object.defineProperty(target, `_`, {
  8224. configurable: true,
  8225. enumerable: false,
  8226. get: () => instance
  8227. });
  8228. // expose public properties
  8229. Object.keys(publicPropertiesMap).forEach(key => {
  8230. Object.defineProperty(target, key, {
  8231. configurable: true,
  8232. enumerable: false,
  8233. get: () => publicPropertiesMap[key](instance),
  8234. // intercepted by the proxy so no need for implementation,
  8235. // but needed to prevent set errors
  8236. set: NOOP
  8237. });
  8238. });
  8239. return target;
  8240. }
  8241. // dev only
  8242. function exposePropsOnRenderContext(instance) {
  8243. const { ctx, propsOptions: [propsOptions] } = instance;
  8244. if (propsOptions) {
  8245. Object.keys(propsOptions).forEach(key => {
  8246. Object.defineProperty(ctx, key, {
  8247. enumerable: true,
  8248. configurable: true,
  8249. get: () => instance.props[key],
  8250. set: NOOP
  8251. });
  8252. });
  8253. }
  8254. }
  8255. // dev only
  8256. function exposeSetupStateOnRenderContext(instance) {
  8257. const { ctx, setupState } = instance;
  8258. Object.keys(toRaw(setupState)).forEach(key => {
  8259. if (!setupState.__isScriptSetup) {
  8260. if (key[0] === '$' || key[0] === '_') {
  8261. warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  8262. `which are reserved prefixes for Vue internals.`);
  8263. return;
  8264. }
  8265. Object.defineProperty(ctx, key, {
  8266. enumerable: true,
  8267. configurable: true,
  8268. get: () => setupState[key],
  8269. set: NOOP
  8270. });
  8271. }
  8272. });
  8273. }
  8274. const emptyAppContext = createAppContext();
  8275. let uid$1 = 0;
  8276. function createComponentInstance(vnode, parent, suspense) {
  8277. const type = vnode.type;
  8278. // inherit parent app context - or - if root, adopt from root vnode
  8279. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8280. const instance = {
  8281. uid: uid$1++,
  8282. vnode,
  8283. type,
  8284. parent,
  8285. appContext,
  8286. root: null,
  8287. next: null,
  8288. subTree: null,
  8289. effect: null,
  8290. update: null,
  8291. scope: new EffectScope(true /* detached */),
  8292. render: null,
  8293. proxy: null,
  8294. exposed: null,
  8295. exposeProxy: null,
  8296. withProxy: null,
  8297. provides: parent ? parent.provides : Object.create(appContext.provides),
  8298. accessCache: null,
  8299. renderCache: [],
  8300. // local resovled assets
  8301. components: null,
  8302. directives: null,
  8303. // resolved props and emits options
  8304. propsOptions: normalizePropsOptions(type, appContext),
  8305. emitsOptions: normalizeEmitsOptions(type, appContext),
  8306. // emit
  8307. emit: null,
  8308. emitted: null,
  8309. // props default value
  8310. propsDefaults: EMPTY_OBJ,
  8311. // inheritAttrs
  8312. inheritAttrs: type.inheritAttrs,
  8313. // state
  8314. ctx: EMPTY_OBJ,
  8315. data: EMPTY_OBJ,
  8316. props: EMPTY_OBJ,
  8317. attrs: EMPTY_OBJ,
  8318. slots: EMPTY_OBJ,
  8319. refs: EMPTY_OBJ,
  8320. setupState: EMPTY_OBJ,
  8321. setupContext: null,
  8322. // suspense related
  8323. suspense,
  8324. suspenseId: suspense ? suspense.pendingId : 0,
  8325. asyncDep: null,
  8326. asyncResolved: false,
  8327. // lifecycle hooks
  8328. // not using enums here because it results in computed properties
  8329. isMounted: false,
  8330. isUnmounted: false,
  8331. isDeactivated: false,
  8332. bc: null,
  8333. c: null,
  8334. bm: null,
  8335. m: null,
  8336. bu: null,
  8337. u: null,
  8338. um: null,
  8339. bum: null,
  8340. da: null,
  8341. a: null,
  8342. rtg: null,
  8343. rtc: null,
  8344. ec: null,
  8345. sp: null
  8346. };
  8347. {
  8348. instance.ctx = createDevRenderContext(instance);
  8349. }
  8350. instance.root = parent ? parent.root : instance;
  8351. instance.emit = emit$1.bind(null, instance);
  8352. // apply custom element special handling
  8353. if (vnode.ce) {
  8354. vnode.ce(instance);
  8355. }
  8356. return instance;
  8357. }
  8358. let currentInstance = null;
  8359. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8360. const setCurrentInstance = (instance) => {
  8361. currentInstance = instance;
  8362. instance.scope.on();
  8363. };
  8364. const unsetCurrentInstance = () => {
  8365. currentInstance && currentInstance.scope.off();
  8366. currentInstance = null;
  8367. };
  8368. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  8369. function validateComponentName(name, config) {
  8370. const appIsNativeTag = config.isNativeTag || NO;
  8371. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8372. warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
  8373. }
  8374. }
  8375. function isStatefulComponent(instance) {
  8376. return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
  8377. }
  8378. let isInSSRComponentSetup = false;
  8379. function setupComponent(instance, isSSR = false) {
  8380. isInSSRComponentSetup = isSSR;
  8381. const { props, children } = instance.vnode;
  8382. const isStateful = isStatefulComponent(instance);
  8383. initProps(instance, props, isStateful, isSSR);
  8384. initSlots(instance, children);
  8385. const setupResult = isStateful
  8386. ? setupStatefulComponent(instance, isSSR)
  8387. : undefined;
  8388. isInSSRComponentSetup = false;
  8389. return setupResult;
  8390. }
  8391. function setupStatefulComponent(instance, isSSR) {
  8392. var _a;
  8393. const Component = instance.type;
  8394. {
  8395. if (Component.name) {
  8396. validateComponentName(Component.name, instance.appContext.config);
  8397. }
  8398. if (Component.components) {
  8399. const names = Object.keys(Component.components);
  8400. for (let i = 0; i < names.length; i++) {
  8401. validateComponentName(names[i], instance.appContext.config);
  8402. }
  8403. }
  8404. if (Component.directives) {
  8405. const names = Object.keys(Component.directives);
  8406. for (let i = 0; i < names.length; i++) {
  8407. validateDirectiveName(names[i]);
  8408. }
  8409. }
  8410. if (Component.compilerOptions && isRuntimeOnly()) {
  8411. warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
  8412. `includes the runtime compiler. Since you are using a runtime-only ` +
  8413. `build, the options should be passed via your build tool config instead.`);
  8414. }
  8415. }
  8416. // 0. create render proxy property access cache
  8417. instance.accessCache = Object.create(null);
  8418. // 1. create public instance / render proxy
  8419. // also mark it raw so it's never observed
  8420. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8421. {
  8422. exposePropsOnRenderContext(instance);
  8423. }
  8424. // 2. call setup()
  8425. const { setup } = Component;
  8426. if (setup) {
  8427. const setupContext = (instance.setupContext =
  8428. setup.length > 1 ? createSetupContext(instance) : null);
  8429. setCurrentInstance(instance);
  8430. pauseTracking();
  8431. const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
  8432. resetTracking();
  8433. unsetCurrentInstance();
  8434. if (isPromise(setupResult)) {
  8435. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8436. if (isSSR) {
  8437. // return the promise so server-renderer can wait on it
  8438. return setupResult
  8439. .then((resolvedResult) => {
  8440. handleSetupResult(instance, resolvedResult, isSSR);
  8441. })
  8442. .catch(e => {
  8443. handleError(e, instance, 0 /* SETUP_FUNCTION */);
  8444. });
  8445. }
  8446. else {
  8447. // async setup returned Promise.
  8448. // bail here and wait for re-entry.
  8449. instance.asyncDep = setupResult;
  8450. if (!instance.suspense) {
  8451. const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
  8452. warn$1(`Component <${name}>: setup function returned a promise, but no ` +
  8453. `<Suspense> boundary was found in the parent component tree. ` +
  8454. `A component with async setup() must be nested in a <Suspense> ` +
  8455. `in order to be rendered.`);
  8456. }
  8457. }
  8458. }
  8459. else {
  8460. handleSetupResult(instance, setupResult, isSSR);
  8461. }
  8462. }
  8463. else {
  8464. finishComponentSetup(instance, isSSR);
  8465. }
  8466. }
  8467. function handleSetupResult(instance, setupResult, isSSR) {
  8468. if (isFunction(setupResult)) {
  8469. // setup returned an inline render function
  8470. {
  8471. instance.render = setupResult;
  8472. }
  8473. }
  8474. else if (isObject(setupResult)) {
  8475. if (isVNode(setupResult)) {
  8476. warn$1(`setup() should not return VNodes directly - ` +
  8477. `return a render function instead.`);
  8478. }
  8479. // setup returned bindings.
  8480. // assuming a render function compiled from template is present.
  8481. {
  8482. instance.devtoolsRawSetupState = setupResult;
  8483. }
  8484. instance.setupState = proxyRefs(setupResult);
  8485. {
  8486. exposeSetupStateOnRenderContext(instance);
  8487. }
  8488. }
  8489. else if (setupResult !== undefined) {
  8490. warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  8491. }
  8492. finishComponentSetup(instance, isSSR);
  8493. }
  8494. let compile;
  8495. let installWithProxy;
  8496. /**
  8497. * For runtime-dom to register the compiler.
  8498. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  8499. */
  8500. function registerRuntimeCompiler(_compile) {
  8501. compile = _compile;
  8502. installWithProxy = i => {
  8503. if (i.render._rc) {
  8504. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8505. }
  8506. };
  8507. }
  8508. // dev only
  8509. const isRuntimeOnly = () => !compile;
  8510. function finishComponentSetup(instance, isSSR, skipOptions) {
  8511. const Component = instance.type;
  8512. // template / render function normalization
  8513. // could be already set when returned from setup()
  8514. if (!instance.render) {
  8515. // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
  8516. // is done by server-renderer
  8517. if (!isSSR && compile && !Component.render) {
  8518. const template = Component.template;
  8519. if (template) {
  8520. {
  8521. startMeasure(instance, `compile`);
  8522. }
  8523. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8524. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8525. const finalCompilerOptions = extend(extend({
  8526. isCustomElement,
  8527. delimiters
  8528. }, compilerOptions), componentCompilerOptions);
  8529. Component.render = compile(template, finalCompilerOptions);
  8530. {
  8531. endMeasure(instance, `compile`);
  8532. }
  8533. }
  8534. }
  8535. instance.render = (Component.render || NOOP);
  8536. // for runtime-compiled render functions using `with` blocks, the render
  8537. // proxy used needs a different `has` handler which is more performant and
  8538. // also only allows a whitelist of globals to fallthrough.
  8539. if (installWithProxy) {
  8540. installWithProxy(instance);
  8541. }
  8542. }
  8543. // support for 2.x options
  8544. {
  8545. setCurrentInstance(instance);
  8546. pauseTracking();
  8547. applyOptions(instance);
  8548. resetTracking();
  8549. unsetCurrentInstance();
  8550. }
  8551. // warn missing template/render
  8552. // the runtime compilation of template in SSR is done by server-render
  8553. if (!Component.render && instance.render === NOOP && !isSSR) {
  8554. /* istanbul ignore if */
  8555. if (!compile && Component.template) {
  8556. warn$1(`Component provided template option but ` +
  8557. `runtime compilation is not supported in this build of Vue.` +
  8558. (` Use "vue.global.js" instead.`
  8559. ) /* should not happen */);
  8560. }
  8561. else {
  8562. warn$1(`Component is missing template or render function.`);
  8563. }
  8564. }
  8565. }
  8566. function createAttrsProxy(instance) {
  8567. return new Proxy(instance.attrs, {
  8568. get(target, key) {
  8569. markAttrsAccessed();
  8570. track(instance, "get" /* GET */, '$attrs');
  8571. return target[key];
  8572. },
  8573. set() {
  8574. warn$1(`setupContext.attrs is readonly.`);
  8575. return false;
  8576. },
  8577. deleteProperty() {
  8578. warn$1(`setupContext.attrs is readonly.`);
  8579. return false;
  8580. }
  8581. }
  8582. );
  8583. }
  8584. function createSetupContext(instance) {
  8585. const expose = exposed => {
  8586. if (instance.exposed) {
  8587. warn$1(`expose() should be called only once per setup().`);
  8588. }
  8589. instance.exposed = exposed || {};
  8590. };
  8591. let attrs;
  8592. {
  8593. // We use getters in dev in case libs like test-utils overwrite instance
  8594. // properties (overwrites should not be done in prod)
  8595. return Object.freeze({
  8596. get attrs() {
  8597. return attrs || (attrs = createAttrsProxy(instance));
  8598. },
  8599. get slots() {
  8600. return shallowReadonly(instance.slots);
  8601. },
  8602. get emit() {
  8603. return (event, ...args) => instance.emit(event, ...args);
  8604. },
  8605. expose
  8606. });
  8607. }
  8608. }
  8609. function getExposeProxy(instance) {
  8610. if (instance.exposed) {
  8611. return (instance.exposeProxy ||
  8612. (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8613. get(target, key) {
  8614. if (key in target) {
  8615. return target[key];
  8616. }
  8617. else if (key in publicPropertiesMap) {
  8618. return publicPropertiesMap[key](instance);
  8619. }
  8620. }
  8621. })));
  8622. }
  8623. }
  8624. const classifyRE = /(?:^|[-_])(\w)/g;
  8625. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  8626. function getComponentName(Component) {
  8627. return isFunction(Component)
  8628. ? Component.displayName || Component.name
  8629. : Component.name;
  8630. }
  8631. /* istanbul ignore next */
  8632. function formatComponentName(instance, Component, isRoot = false) {
  8633. let name = getComponentName(Component);
  8634. if (!name && Component.__file) {
  8635. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8636. if (match) {
  8637. name = match[1];
  8638. }
  8639. }
  8640. if (!name && instance && instance.parent) {
  8641. // try to infer the name based on reverse resolution
  8642. const inferFromRegistry = (registry) => {
  8643. for (const key in registry) {
  8644. if (registry[key] === Component) {
  8645. return key;
  8646. }
  8647. }
  8648. };
  8649. name =
  8650. inferFromRegistry(instance.components ||
  8651. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  8652. }
  8653. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8654. }
  8655. function isClassComponent(value) {
  8656. return isFunction(value) && '__vccOpts' in value;
  8657. }
  8658. const computed$1 = ((getterOrOptions, debugOptions) => {
  8659. // @ts-ignore
  8660. return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8661. });
  8662. // dev only
  8663. const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
  8664. `<script setup> of a single file component. Its arguments should be ` +
  8665. `compiled away and passing it at runtime has no effect.`);
  8666. // implementation
  8667. function defineProps() {
  8668. {
  8669. warnRuntimeUsage(`defineProps`);
  8670. }
  8671. return null;
  8672. }
  8673. // implementation
  8674. function defineEmits() {
  8675. {
  8676. warnRuntimeUsage(`defineEmits`);
  8677. }
  8678. return null;
  8679. }
  8680. /**
  8681. * Vue `<script setup>` compiler macro for declaring a component's exposed
  8682. * instance properties when it is accessed by a parent component via template
  8683. * refs.
  8684. *
  8685. * `<script setup>` components are closed by default - i.e. variables inside
  8686. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  8687. * via `defineExpose`.
  8688. *
  8689. * This is only usable inside `<script setup>`, is compiled away in the
  8690. * output and should **not** be actually called at runtime.
  8691. */
  8692. function defineExpose(exposed) {
  8693. {
  8694. warnRuntimeUsage(`defineExpose`);
  8695. }
  8696. }
  8697. /**
  8698. * Vue `<script setup>` compiler macro for providing props default values when
  8699. * using type-based `defineProps` declaration.
  8700. *
  8701. * Example usage:
  8702. * ```ts
  8703. * withDefaults(defineProps<{
  8704. * size?: number
  8705. * labels?: string[]
  8706. * }>(), {
  8707. * size: 3,
  8708. * labels: () => ['default label']
  8709. * })
  8710. * ```
  8711. *
  8712. * This is only usable inside `<script setup>`, is compiled away in the output
  8713. * and should **not** be actually called at runtime.
  8714. */
  8715. function withDefaults(props, defaults) {
  8716. {
  8717. warnRuntimeUsage(`withDefaults`);
  8718. }
  8719. return null;
  8720. }
  8721. function useSlots() {
  8722. return getContext().slots;
  8723. }
  8724. function useAttrs() {
  8725. return getContext().attrs;
  8726. }
  8727. function getContext() {
  8728. const i = getCurrentInstance();
  8729. if (!i) {
  8730. warn$1(`useContext() called without active instance.`);
  8731. }
  8732. return i.setupContext || (i.setupContext = createSetupContext(i));
  8733. }
  8734. /**
  8735. * Runtime helper for merging default declarations. Imported by compiled code
  8736. * only.
  8737. * @internal
  8738. */
  8739. function mergeDefaults(raw, defaults) {
  8740. const props = isArray(raw)
  8741. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  8742. : raw;
  8743. for (const key in defaults) {
  8744. const opt = props[key];
  8745. if (opt) {
  8746. if (isArray(opt) || isFunction(opt)) {
  8747. props[key] = { type: opt, default: defaults[key] };
  8748. }
  8749. else {
  8750. opt.default = defaults[key];
  8751. }
  8752. }
  8753. else if (opt === null) {
  8754. props[key] = { default: defaults[key] };
  8755. }
  8756. else {
  8757. warn$1(`props default key "${key}" has no corresponding declaration.`);
  8758. }
  8759. }
  8760. return props;
  8761. }
  8762. /**
  8763. * Used to create a proxy for the rest element when destructuring props with
  8764. * defineProps().
  8765. * @internal
  8766. */
  8767. function createPropsRestProxy(props, excludedKeys) {
  8768. const ret = {};
  8769. for (const key in props) {
  8770. if (!excludedKeys.includes(key)) {
  8771. Object.defineProperty(ret, key, {
  8772. enumerable: true,
  8773. get: () => props[key]
  8774. });
  8775. }
  8776. }
  8777. return ret;
  8778. }
  8779. /**
  8780. * `<script setup>` helper for persisting the current instance context over
  8781. * async/await flows.
  8782. *
  8783. * `@vue/compiler-sfc` converts the following:
  8784. *
  8785. * ```ts
  8786. * const x = await foo()
  8787. * ```
  8788. *
  8789. * into:
  8790. *
  8791. * ```ts
  8792. * let __temp, __restore
  8793. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  8794. * ```
  8795. * @internal
  8796. */
  8797. function withAsyncContext(getAwaitable) {
  8798. const ctx = getCurrentInstance();
  8799. if (!ctx) {
  8800. warn$1(`withAsyncContext called without active current instance. ` +
  8801. `This is likely a bug.`);
  8802. }
  8803. let awaitable = getAwaitable();
  8804. unsetCurrentInstance();
  8805. if (isPromise(awaitable)) {
  8806. awaitable = awaitable.catch(e => {
  8807. setCurrentInstance(ctx);
  8808. throw e;
  8809. });
  8810. }
  8811. return [awaitable, () => setCurrentInstance(ctx)];
  8812. }
  8813. // Actual implementation
  8814. function h(type, propsOrChildren, children) {
  8815. const l = arguments.length;
  8816. if (l === 2) {
  8817. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8818. // single vnode without props
  8819. if (isVNode(propsOrChildren)) {
  8820. return createVNode(type, null, [propsOrChildren]);
  8821. }
  8822. // props without children
  8823. return createVNode(type, propsOrChildren);
  8824. }
  8825. else {
  8826. // omit props
  8827. return createVNode(type, null, propsOrChildren);
  8828. }
  8829. }
  8830. else {
  8831. if (l > 3) {
  8832. children = Array.prototype.slice.call(arguments, 2);
  8833. }
  8834. else if (l === 3 && isVNode(children)) {
  8835. children = [children];
  8836. }
  8837. return createVNode(type, propsOrChildren, children);
  8838. }
  8839. }
  8840. const ssrContextKey = Symbol(`ssrContext` );
  8841. const useSSRContext = () => {
  8842. {
  8843. warn$1(`useSSRContext() is not supported in the global build.`);
  8844. }
  8845. };
  8846. function initCustomFormatter() {
  8847. /* eslint-disable no-restricted-globals */
  8848. if (typeof window === 'undefined') {
  8849. return;
  8850. }
  8851. const vueStyle = { style: 'color:#3ba776' };
  8852. const numberStyle = { style: 'color:#0b1bc9' };
  8853. const stringStyle = { style: 'color:#b62e24' };
  8854. const keywordStyle = { style: 'color:#9d288c' };
  8855. // custom formatter for Chrome
  8856. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  8857. const formatter = {
  8858. header(obj) {
  8859. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  8860. if (!isObject(obj)) {
  8861. return null;
  8862. }
  8863. if (obj.__isVue) {
  8864. return ['div', vueStyle, `VueInstance`];
  8865. }
  8866. else if (isRef(obj)) {
  8867. return [
  8868. 'div',
  8869. {},
  8870. ['span', vueStyle, genRefFlag(obj)],
  8871. '<',
  8872. formatValue(obj.value),
  8873. `>`
  8874. ];
  8875. }
  8876. else if (isReactive(obj)) {
  8877. return [
  8878. 'div',
  8879. {},
  8880. ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
  8881. '<',
  8882. formatValue(obj),
  8883. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8884. ];
  8885. }
  8886. else if (isReadonly(obj)) {
  8887. return [
  8888. 'div',
  8889. {},
  8890. ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
  8891. '<',
  8892. formatValue(obj),
  8893. '>'
  8894. ];
  8895. }
  8896. return null;
  8897. },
  8898. hasBody(obj) {
  8899. return obj && obj.__isVue;
  8900. },
  8901. body(obj) {
  8902. if (obj && obj.__isVue) {
  8903. return [
  8904. 'div',
  8905. {},
  8906. ...formatInstance(obj.$)
  8907. ];
  8908. }
  8909. }
  8910. };
  8911. function formatInstance(instance) {
  8912. const blocks = [];
  8913. if (instance.type.props && instance.props) {
  8914. blocks.push(createInstanceBlock('props', toRaw(instance.props)));
  8915. }
  8916. if (instance.setupState !== EMPTY_OBJ) {
  8917. blocks.push(createInstanceBlock('setup', instance.setupState));
  8918. }
  8919. if (instance.data !== EMPTY_OBJ) {
  8920. blocks.push(createInstanceBlock('data', toRaw(instance.data)));
  8921. }
  8922. const computed = extractKeys(instance, 'computed');
  8923. if (computed) {
  8924. blocks.push(createInstanceBlock('computed', computed));
  8925. }
  8926. const injected = extractKeys(instance, 'inject');
  8927. if (injected) {
  8928. blocks.push(createInstanceBlock('injected', injected));
  8929. }
  8930. blocks.push([
  8931. 'div',
  8932. {},
  8933. [
  8934. 'span',
  8935. {
  8936. style: keywordStyle.style + ';opacity:0.66'
  8937. },
  8938. '$ (internal): '
  8939. ],
  8940. ['object', { object: instance }]
  8941. ]);
  8942. return blocks;
  8943. }
  8944. function createInstanceBlock(type, target) {
  8945. target = extend({}, target);
  8946. if (!Object.keys(target).length) {
  8947. return ['span', {}];
  8948. }
  8949. return [
  8950. 'div',
  8951. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  8952. [
  8953. 'div',
  8954. {
  8955. style: 'color:#476582'
  8956. },
  8957. type
  8958. ],
  8959. [
  8960. 'div',
  8961. {
  8962. style: 'padding-left:1.25em'
  8963. },
  8964. ...Object.keys(target).map(key => {
  8965. return [
  8966. 'div',
  8967. {},
  8968. ['span', keywordStyle, key + ': '],
  8969. formatValue(target[key], false)
  8970. ];
  8971. })
  8972. ]
  8973. ];
  8974. }
  8975. function formatValue(v, asRaw = true) {
  8976. if (typeof v === 'number') {
  8977. return ['span', numberStyle, v];
  8978. }
  8979. else if (typeof v === 'string') {
  8980. return ['span', stringStyle, JSON.stringify(v)];
  8981. }
  8982. else if (typeof v === 'boolean') {
  8983. return ['span', keywordStyle, v];
  8984. }
  8985. else if (isObject(v)) {
  8986. return ['object', { object: asRaw ? toRaw(v) : v }];
  8987. }
  8988. else {
  8989. return ['span', stringStyle, String(v)];
  8990. }
  8991. }
  8992. function extractKeys(instance, type) {
  8993. const Comp = instance.type;
  8994. if (isFunction(Comp)) {
  8995. return;
  8996. }
  8997. const extracted = {};
  8998. for (const key in instance.ctx) {
  8999. if (isKeyOfType(Comp, key, type)) {
  9000. extracted[key] = instance.ctx[key];
  9001. }
  9002. }
  9003. return extracted;
  9004. }
  9005. function isKeyOfType(Comp, key, type) {
  9006. const opts = Comp[type];
  9007. if ((isArray(opts) && opts.includes(key)) ||
  9008. (isObject(opts) && key in opts)) {
  9009. return true;
  9010. }
  9011. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  9012. return true;
  9013. }
  9014. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  9015. return true;
  9016. }
  9017. }
  9018. function genRefFlag(v) {
  9019. if (isShallow(v)) {
  9020. return `ShallowRef`;
  9021. }
  9022. if (v.effect) {
  9023. return `ComputedRef`;
  9024. }
  9025. return `Ref`;
  9026. }
  9027. if (window.devtoolsFormatters) {
  9028. window.devtoolsFormatters.push(formatter);
  9029. }
  9030. else {
  9031. window.devtoolsFormatters = [formatter];
  9032. }
  9033. }
  9034. function withMemo(memo, render, cache, index) {
  9035. const cached = cache[index];
  9036. if (cached && isMemoSame(cached, memo)) {
  9037. return cached;
  9038. }
  9039. const ret = render();
  9040. // shallow clone
  9041. ret.memo = memo.slice();
  9042. return (cache[index] = ret);
  9043. }
  9044. function isMemoSame(cached, memo) {
  9045. const prev = cached.memo;
  9046. if (prev.length != memo.length) {
  9047. return false;
  9048. }
  9049. for (let i = 0; i < prev.length; i++) {
  9050. if (prev[i] !== memo[i]) {
  9051. return false;
  9052. }
  9053. }
  9054. // make sure to let parent block track it when returning cached
  9055. if (isBlockTreeEnabled > 0 && currentBlock) {
  9056. currentBlock.push(cached);
  9057. }
  9058. return true;
  9059. }
  9060. // Core API ------------------------------------------------------------------
  9061. const version = "3.2.33";
  9062. /**
  9063. * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
  9064. * @internal
  9065. */
  9066. const ssrUtils = (null);
  9067. /**
  9068. * @internal only exposed in compat builds
  9069. */
  9070. const resolveFilter = null;
  9071. /**
  9072. * @internal only exposed in compat builds.
  9073. */
  9074. const compatUtils = (null);
  9075. const svgNS = 'http://www.w3.org/2000/svg';
  9076. const doc = (typeof document !== 'undefined' ? document : null);
  9077. const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
  9078. const nodeOps = {
  9079. insert: (child, parent, anchor) => {
  9080. parent.insertBefore(child, anchor || null);
  9081. },
  9082. remove: child => {
  9083. const parent = child.parentNode;
  9084. if (parent) {
  9085. parent.removeChild(child);
  9086. }
  9087. },
  9088. createElement: (tag, isSVG, is, props) => {
  9089. const el = isSVG
  9090. ? doc.createElementNS(svgNS, tag)
  9091. : doc.createElement(tag, is ? { is } : undefined);
  9092. if (tag === 'select' && props && props.multiple != null) {
  9093. el.setAttribute('multiple', props.multiple);
  9094. }
  9095. return el;
  9096. },
  9097. createText: text => doc.createTextNode(text),
  9098. createComment: text => doc.createComment(text),
  9099. setText: (node, text) => {
  9100. node.nodeValue = text;
  9101. },
  9102. setElementText: (el, text) => {
  9103. el.textContent = text;
  9104. },
  9105. parentNode: node => node.parentNode,
  9106. nextSibling: node => node.nextSibling,
  9107. querySelector: selector => doc.querySelector(selector),
  9108. setScopeId(el, id) {
  9109. el.setAttribute(id, '');
  9110. },
  9111. cloneNode(el) {
  9112. const cloned = el.cloneNode(true);
  9113. // #3072
  9114. // - in `patchDOMProp`, we store the actual value in the `el._value` property.
  9115. // - normally, elements using `:value` bindings will not be hoisted, but if
  9116. // the bound value is a constant, e.g. `:value="true"` - they do get
  9117. // hoisted.
  9118. // - in production, hoisted nodes are cloned when subsequent inserts, but
  9119. // cloneNode() does not copy the custom property we attached.
  9120. // - This may need to account for other custom DOM properties we attach to
  9121. // elements in addition to `_value` in the future.
  9122. if (`_value` in el) {
  9123. cloned._value = el._value;
  9124. }
  9125. return cloned;
  9126. },
  9127. // __UNSAFE__
  9128. // Reason: innerHTML.
  9129. // Static content here can only come from compiled templates.
  9130. // As long as the user only uses trusted templates, this is safe.
  9131. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9132. // <parent> before | first ... last | anchor </parent>
  9133. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9134. // #5308 can only take cached path if:
  9135. // - has a single root node
  9136. // - nextSibling info is still available
  9137. if (start && (start === end || start.nextSibling)) {
  9138. // cached
  9139. while (true) {
  9140. parent.insertBefore(start.cloneNode(true), anchor);
  9141. if (start === end || !(start = start.nextSibling))
  9142. break;
  9143. }
  9144. }
  9145. else {
  9146. // fresh insert
  9147. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9148. const template = templateContainer.content;
  9149. if (isSVG) {
  9150. // remove outer svg wrapper
  9151. const wrapper = template.firstChild;
  9152. while (wrapper.firstChild) {
  9153. template.appendChild(wrapper.firstChild);
  9154. }
  9155. template.removeChild(wrapper);
  9156. }
  9157. parent.insertBefore(template, anchor);
  9158. }
  9159. return [
  9160. // first
  9161. before ? before.nextSibling : parent.firstChild,
  9162. // last
  9163. anchor ? anchor.previousSibling : parent.lastChild
  9164. ];
  9165. }
  9166. };
  9167. // compiler should normalize class + :class bindings on the same element
  9168. // into a single binding ['staticClass', dynamic]
  9169. function patchClass(el, value, isSVG) {
  9170. // directly setting className should be faster than setAttribute in theory
  9171. // if this is an element during a transition, take the temporary transition
  9172. // classes into account.
  9173. const transitionClasses = el._vtc;
  9174. if (transitionClasses) {
  9175. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
  9176. }
  9177. if (value == null) {
  9178. el.removeAttribute('class');
  9179. }
  9180. else if (isSVG) {
  9181. el.setAttribute('class', value);
  9182. }
  9183. else {
  9184. el.className = value;
  9185. }
  9186. }
  9187. function patchStyle(el, prev, next) {
  9188. const style = el.style;
  9189. const isCssString = isString(next);
  9190. if (next && !isCssString) {
  9191. for (const key in next) {
  9192. setStyle(style, key, next[key]);
  9193. }
  9194. if (prev && !isString(prev)) {
  9195. for (const key in prev) {
  9196. if (next[key] == null) {
  9197. setStyle(style, key, '');
  9198. }
  9199. }
  9200. }
  9201. }
  9202. else {
  9203. const currentDisplay = style.display;
  9204. if (isCssString) {
  9205. if (prev !== next) {
  9206. style.cssText = next;
  9207. }
  9208. }
  9209. else if (prev) {
  9210. el.removeAttribute('style');
  9211. }
  9212. // indicates that the `display` of the element is controlled by `v-show`,
  9213. // so we always keep the current `display` value regardless of the `style`
  9214. // value, thus handing over control to `v-show`.
  9215. if ('_vod' in el) {
  9216. style.display = currentDisplay;
  9217. }
  9218. }
  9219. }
  9220. const importantRE = /\s*!important$/;
  9221. function setStyle(style, name, val) {
  9222. if (isArray(val)) {
  9223. val.forEach(v => setStyle(style, name, v));
  9224. }
  9225. else {
  9226. if (val == null)
  9227. val = '';
  9228. if (name.startsWith('--')) {
  9229. // custom property definition
  9230. style.setProperty(name, val);
  9231. }
  9232. else {
  9233. const prefixed = autoPrefix(style, name);
  9234. if (importantRE.test(val)) {
  9235. // !important
  9236. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  9237. }
  9238. else {
  9239. style[prefixed] = val;
  9240. }
  9241. }
  9242. }
  9243. }
  9244. const prefixes = ['Webkit', 'Moz', 'ms'];
  9245. const prefixCache = {};
  9246. function autoPrefix(style, rawName) {
  9247. const cached = prefixCache[rawName];
  9248. if (cached) {
  9249. return cached;
  9250. }
  9251. let name = camelize(rawName);
  9252. if (name !== 'filter' && name in style) {
  9253. return (prefixCache[rawName] = name);
  9254. }
  9255. name = capitalize(name);
  9256. for (let i = 0; i < prefixes.length; i++) {
  9257. const prefixed = prefixes[i] + name;
  9258. if (prefixed in style) {
  9259. return (prefixCache[rawName] = prefixed);
  9260. }
  9261. }
  9262. return rawName;
  9263. }
  9264. const xlinkNS = 'http://www.w3.org/1999/xlink';
  9265. function patchAttr(el, key, value, isSVG, instance) {
  9266. if (isSVG && key.startsWith('xlink:')) {
  9267. if (value == null) {
  9268. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9269. }
  9270. else {
  9271. el.setAttributeNS(xlinkNS, key, value);
  9272. }
  9273. }
  9274. else {
  9275. // note we are only checking boolean attributes that don't have a
  9276. // corresponding dom prop of the same name here.
  9277. const isBoolean = isSpecialBooleanAttr(key);
  9278. if (value == null || (isBoolean && !includeBooleanAttr(value))) {
  9279. el.removeAttribute(key);
  9280. }
  9281. else {
  9282. el.setAttribute(key, isBoolean ? '' : value);
  9283. }
  9284. }
  9285. }
  9286. // __UNSAFE__
  9287. // functions. The user is responsible for using them with only trusted content.
  9288. function patchDOMProp(el, key, value,
  9289. // the following args are passed only due to potential innerHTML/textContent
  9290. // overriding existing VNodes, in which case the old tree must be properly
  9291. // unmounted.
  9292. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9293. if (key === 'innerHTML' || key === 'textContent') {
  9294. if (prevChildren) {
  9295. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9296. }
  9297. el[key] = value == null ? '' : value;
  9298. return;
  9299. }
  9300. if (key === 'value' &&
  9301. el.tagName !== 'PROGRESS' &&
  9302. // custom elements may use _value internally
  9303. !el.tagName.includes('-')) {
  9304. // store value as _value as well since
  9305. // non-string values will be stringified.
  9306. el._value = value;
  9307. const newValue = value == null ? '' : value;
  9308. if (el.value !== newValue ||
  9309. // #4956: always set for OPTION elements because its value falls back to
  9310. // textContent if no value attribute is present. And setting .value for
  9311. // OPTION has no side effect
  9312. el.tagName === 'OPTION') {
  9313. el.value = newValue;
  9314. }
  9315. if (value == null) {
  9316. el.removeAttribute(key);
  9317. }
  9318. return;
  9319. }
  9320. let needRemove = false;
  9321. if (value === '' || value == null) {
  9322. const type = typeof el[key];
  9323. if (type === 'boolean') {
  9324. // e.g. <select multiple> compiles to { multiple: '' }
  9325. value = includeBooleanAttr(value);
  9326. }
  9327. else if (value == null && type === 'string') {
  9328. // e.g. <div :id="null">
  9329. value = '';
  9330. needRemove = true;
  9331. }
  9332. else if (type === 'number') {
  9333. // e.g. <img :width="null">
  9334. // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
  9335. value = 0;
  9336. needRemove = true;
  9337. }
  9338. }
  9339. // some properties perform value validation and throw,
  9340. // some properties has getter, no setter, will error in 'use strict'
  9341. // eg. <select :type="null"></select> <select :willValidate="null"></select>
  9342. try {
  9343. el[key] = value;
  9344. }
  9345. catch (e) {
  9346. {
  9347. warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  9348. `value ${value} is invalid.`, e);
  9349. }
  9350. }
  9351. needRemove && el.removeAttribute(key);
  9352. }
  9353. // Async edge case fix requires storing an event listener's attach timestamp.
  9354. const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
  9355. let _getNow = Date.now;
  9356. let skipTimestampCheck = false;
  9357. if (typeof window !== 'undefined') {
  9358. // Determine what event timestamp the browser is using. Annoyingly, the
  9359. // timestamp can either be hi-res (relative to page load) or low-res
  9360. // (relative to UNIX epoch), so in order to compare time we have to use the
  9361. // same timestamp type when saving the flush timestamp.
  9362. if (Date.now() > document.createEvent('Event').timeStamp) {
  9363. // if the low-res timestamp which is bigger than the event timestamp
  9364. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  9365. // and we need to use the hi-res version for event listeners as well.
  9366. _getNow = () => performance.now();
  9367. }
  9368. // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
  9369. // and does not fire microtasks in between event propagation, so safe to exclude.
  9370. const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
  9371. skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
  9372. }
  9373. return [_getNow, skipTimestampCheck];
  9374. })();
  9375. // To avoid the overhead of repeatedly calling performance.now(), we cache
  9376. // and use the same timestamp for all event listeners attached in the same tick.
  9377. let cachedNow = 0;
  9378. const p = /*#__PURE__*/ Promise.resolve();
  9379. const reset = () => {
  9380. cachedNow = 0;
  9381. };
  9382. const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
  9383. function addEventListener(el, event, handler, options) {
  9384. el.addEventListener(event, handler, options);
  9385. }
  9386. function removeEventListener(el, event, handler, options) {
  9387. el.removeEventListener(event, handler, options);
  9388. }
  9389. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9390. // vei = vue event invokers
  9391. const invokers = el._vei || (el._vei = {});
  9392. const existingInvoker = invokers[rawName];
  9393. if (nextValue && existingInvoker) {
  9394. // patch
  9395. existingInvoker.value = nextValue;
  9396. }
  9397. else {
  9398. const [name, options] = parseName(rawName);
  9399. if (nextValue) {
  9400. // add
  9401. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  9402. addEventListener(el, name, invoker, options);
  9403. }
  9404. else if (existingInvoker) {
  9405. // remove
  9406. removeEventListener(el, name, existingInvoker, options);
  9407. invokers[rawName] = undefined;
  9408. }
  9409. }
  9410. }
  9411. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9412. function parseName(name) {
  9413. let options;
  9414. if (optionsModifierRE.test(name)) {
  9415. options = {};
  9416. let m;
  9417. while ((m = name.match(optionsModifierRE))) {
  9418. name = name.slice(0, name.length - m[0].length);
  9419. options[m[0].toLowerCase()] = true;
  9420. }
  9421. }
  9422. return [hyphenate(name.slice(2)), options];
  9423. }
  9424. function createInvoker(initialValue, instance) {
  9425. const invoker = (e) => {
  9426. // async edge case #6566: inner click event triggers patch, event handler
  9427. // attached to outer element during patch, and triggered again. This
  9428. // happens because browsers fire microtask ticks between event propagation.
  9429. // the solution is simple: we save the timestamp when a handler is attached,
  9430. // and the handler would only fire if the event passed to it was fired
  9431. // AFTER it was attached.
  9432. const timeStamp = e.timeStamp || _getNow();
  9433. if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
  9434. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
  9435. }
  9436. };
  9437. invoker.value = initialValue;
  9438. invoker.attached = getNow();
  9439. return invoker;
  9440. }
  9441. function patchStopImmediatePropagation(e, value) {
  9442. if (isArray(value)) {
  9443. const originalStop = e.stopImmediatePropagation;
  9444. e.stopImmediatePropagation = () => {
  9445. originalStop.call(e);
  9446. e._stopped = true;
  9447. };
  9448. return value.map(fn => (e) => !e._stopped && fn && fn(e));
  9449. }
  9450. else {
  9451. return value;
  9452. }
  9453. }
  9454. const nativeOnRE = /^on[a-z]/;
  9455. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9456. if (key === 'class') {
  9457. patchClass(el, nextValue, isSVG);
  9458. }
  9459. else if (key === 'style') {
  9460. patchStyle(el, prevValue, nextValue);
  9461. }
  9462. else if (isOn(key)) {
  9463. // ignore v-model listeners
  9464. if (!isModelListener(key)) {
  9465. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9466. }
  9467. }
  9468. else if (key[0] === '.'
  9469. ? ((key = key.slice(1)), true)
  9470. : key[0] === '^'
  9471. ? ((key = key.slice(1)), false)
  9472. : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9473. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  9474. }
  9475. else {
  9476. // special case for <input v-model type="checkbox"> with
  9477. // :true-value & :false-value
  9478. // store value as dom properties since non-string values will be
  9479. // stringified.
  9480. if (key === 'true-value') {
  9481. el._trueValue = nextValue;
  9482. }
  9483. else if (key === 'false-value') {
  9484. el._falseValue = nextValue;
  9485. }
  9486. patchAttr(el, key, nextValue, isSVG);
  9487. }
  9488. };
  9489. function shouldSetAsProp(el, key, value, isSVG) {
  9490. if (isSVG) {
  9491. // most keys must be set as attribute on svg elements to work
  9492. // ...except innerHTML & textContent
  9493. if (key === 'innerHTML' || key === 'textContent') {
  9494. return true;
  9495. }
  9496. // or native onclick with function values
  9497. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9498. return true;
  9499. }
  9500. return false;
  9501. }
  9502. // these are enumerated attrs, however their corresponding DOM properties
  9503. // are actually booleans - this leads to setting it with a string "false"
  9504. // value leading it to be coerced to `true`, so we need to always treat
  9505. // them as attributes.
  9506. // Note that `contentEditable` doesn't have this problem: its DOM
  9507. // property is also enumerated string values.
  9508. if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
  9509. return false;
  9510. }
  9511. // #1787, #2840 form property on form elements is readonly and must be set as
  9512. // attribute.
  9513. if (key === 'form') {
  9514. return false;
  9515. }
  9516. // #1526 <input list> must be set as attribute
  9517. if (key === 'list' && el.tagName === 'INPUT') {
  9518. return false;
  9519. }
  9520. // #2766 <textarea type> must be set as attribute
  9521. if (key === 'type' && el.tagName === 'TEXTAREA') {
  9522. return false;
  9523. }
  9524. // native onclick with string value, must be set as attribute
  9525. if (nativeOnRE.test(key) && isString(value)) {
  9526. return false;
  9527. }
  9528. return key in el;
  9529. }
  9530. function defineCustomElement(options, hydate) {
  9531. const Comp = defineComponent(options);
  9532. class VueCustomElement extends VueElement {
  9533. constructor(initialProps) {
  9534. super(Comp, initialProps, hydate);
  9535. }
  9536. }
  9537. VueCustomElement.def = Comp;
  9538. return VueCustomElement;
  9539. }
  9540. const defineSSRCustomElement = ((options) => {
  9541. // @ts-ignore
  9542. return defineCustomElement(options, hydrate);
  9543. });
  9544. const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
  9545. });
  9546. class VueElement extends BaseClass {
  9547. constructor(_def, _props = {}, hydrate) {
  9548. super();
  9549. this._def = _def;
  9550. this._props = _props;
  9551. /**
  9552. * @internal
  9553. */
  9554. this._instance = null;
  9555. this._connected = false;
  9556. this._resolved = false;
  9557. this._numberProps = null;
  9558. if (this.shadowRoot && hydrate) {
  9559. hydrate(this._createVNode(), this.shadowRoot);
  9560. }
  9561. else {
  9562. if (this.shadowRoot) {
  9563. warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
  9564. `defined as hydratable. Use \`defineSSRCustomElement\`.`);
  9565. }
  9566. this.attachShadow({ mode: 'open' });
  9567. }
  9568. }
  9569. connectedCallback() {
  9570. this._connected = true;
  9571. if (!this._instance) {
  9572. this._resolveDef();
  9573. }
  9574. }
  9575. disconnectedCallback() {
  9576. this._connected = false;
  9577. nextTick(() => {
  9578. if (!this._connected) {
  9579. render(null, this.shadowRoot);
  9580. this._instance = null;
  9581. }
  9582. });
  9583. }
  9584. /**
  9585. * resolve inner component definition (handle possible async component)
  9586. */
  9587. _resolveDef() {
  9588. if (this._resolved) {
  9589. return;
  9590. }
  9591. this._resolved = true;
  9592. // set initial attrs
  9593. for (let i = 0; i < this.attributes.length; i++) {
  9594. this._setAttr(this.attributes[i].name);
  9595. }
  9596. // watch future attr changes
  9597. new MutationObserver(mutations => {
  9598. for (const m of mutations) {
  9599. this._setAttr(m.attributeName);
  9600. }
  9601. }).observe(this, { attributes: true });
  9602. const resolve = (def) => {
  9603. const { props, styles } = def;
  9604. const hasOptions = !isArray(props);
  9605. const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
  9606. // cast Number-type props set before resolve
  9607. let numberProps;
  9608. if (hasOptions) {
  9609. for (const key in this._props) {
  9610. const opt = props[key];
  9611. if (opt === Number || (opt && opt.type === Number)) {
  9612. this._props[key] = toNumber(this._props[key]);
  9613. (numberProps || (numberProps = Object.create(null)))[key] = true;
  9614. }
  9615. }
  9616. }
  9617. this._numberProps = numberProps;
  9618. // check if there are props set pre-upgrade or connect
  9619. for (const key of Object.keys(this)) {
  9620. if (key[0] !== '_') {
  9621. this._setProp(key, this[key], true, false);
  9622. }
  9623. }
  9624. // defining getter/setters on prototype
  9625. for (const key of rawKeys.map(camelize)) {
  9626. Object.defineProperty(this, key, {
  9627. get() {
  9628. return this._getProp(key);
  9629. },
  9630. set(val) {
  9631. this._setProp(key, val);
  9632. }
  9633. });
  9634. }
  9635. // apply CSS
  9636. this._applyStyles(styles);
  9637. // initial render
  9638. this._update();
  9639. };
  9640. const asyncDef = this._def.__asyncLoader;
  9641. if (asyncDef) {
  9642. asyncDef().then(resolve);
  9643. }
  9644. else {
  9645. resolve(this._def);
  9646. }
  9647. }
  9648. _setAttr(key) {
  9649. let value = this.getAttribute(key);
  9650. if (this._numberProps && this._numberProps[key]) {
  9651. value = toNumber(value);
  9652. }
  9653. this._setProp(camelize(key), value, false);
  9654. }
  9655. /**
  9656. * @internal
  9657. */
  9658. _getProp(key) {
  9659. return this._props[key];
  9660. }
  9661. /**
  9662. * @internal
  9663. */
  9664. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9665. if (val !== this._props[key]) {
  9666. this._props[key] = val;
  9667. if (shouldUpdate && this._instance) {
  9668. this._update();
  9669. }
  9670. // reflect
  9671. if (shouldReflect) {
  9672. if (val === true) {
  9673. this.setAttribute(hyphenate(key), '');
  9674. }
  9675. else if (typeof val === 'string' || typeof val === 'number') {
  9676. this.setAttribute(hyphenate(key), val + '');
  9677. }
  9678. else if (!val) {
  9679. this.removeAttribute(hyphenate(key));
  9680. }
  9681. }
  9682. }
  9683. }
  9684. _update() {
  9685. render(this._createVNode(), this.shadowRoot);
  9686. }
  9687. _createVNode() {
  9688. const vnode = createVNode(this._def, extend({}, this._props));
  9689. if (!this._instance) {
  9690. vnode.ce = instance => {
  9691. this._instance = instance;
  9692. instance.isCE = true;
  9693. // HMR
  9694. {
  9695. instance.ceReload = newStyles => {
  9696. // always reset styles
  9697. if (this._styles) {
  9698. this._styles.forEach(s => this.shadowRoot.removeChild(s));
  9699. this._styles.length = 0;
  9700. }
  9701. this._applyStyles(newStyles);
  9702. // if this is an async component, ceReload is called from the inner
  9703. // component so no need to reload the async wrapper
  9704. if (!this._def.__asyncLoader) {
  9705. // reload
  9706. this._instance = null;
  9707. this._update();
  9708. }
  9709. };
  9710. }
  9711. // intercept emit
  9712. instance.emit = (event, ...args) => {
  9713. this.dispatchEvent(new CustomEvent(event, {
  9714. detail: args
  9715. }));
  9716. };
  9717. // locate nearest Vue custom element parent for provide/inject
  9718. let parent = this;
  9719. while ((parent =
  9720. parent && (parent.parentNode || parent.host))) {
  9721. if (parent instanceof VueElement) {
  9722. instance.parent = parent._instance;
  9723. break;
  9724. }
  9725. }
  9726. };
  9727. }
  9728. return vnode;
  9729. }
  9730. _applyStyles(styles) {
  9731. if (styles) {
  9732. styles.forEach(css => {
  9733. const s = document.createElement('style');
  9734. s.textContent = css;
  9735. this.shadowRoot.appendChild(s);
  9736. // record for HMR
  9737. {
  9738. (this._styles || (this._styles = [])).push(s);
  9739. }
  9740. });
  9741. }
  9742. }
  9743. }
  9744. function useCssModule(name = '$style') {
  9745. /* istanbul ignore else */
  9746. {
  9747. {
  9748. warn$1(`useCssModule() is not supported in the global build.`);
  9749. }
  9750. return EMPTY_OBJ;
  9751. }
  9752. }
  9753. /**
  9754. * Runtime helper for SFC's CSS variable injection feature.
  9755. * @private
  9756. */
  9757. function useCssVars(getter) {
  9758. const instance = getCurrentInstance();
  9759. /* istanbul ignore next */
  9760. if (!instance) {
  9761. warn$1(`useCssVars is called without current active component instance.`);
  9762. return;
  9763. }
  9764. const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
  9765. watchPostEffect(setVars);
  9766. onMounted(() => {
  9767. const ob = new MutationObserver(setVars);
  9768. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9769. onUnmounted(() => ob.disconnect());
  9770. });
  9771. }
  9772. function setVarsOnVNode(vnode, vars) {
  9773. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  9774. const suspense = vnode.suspense;
  9775. vnode = suspense.activeBranch;
  9776. if (suspense.pendingBranch && !suspense.isHydrating) {
  9777. suspense.effects.push(() => {
  9778. setVarsOnVNode(suspense.activeBranch, vars);
  9779. });
  9780. }
  9781. }
  9782. // drill down HOCs until it's a non-component vnode
  9783. while (vnode.component) {
  9784. vnode = vnode.component.subTree;
  9785. }
  9786. if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
  9787. setVarsOnNode(vnode.el, vars);
  9788. }
  9789. else if (vnode.type === Fragment) {
  9790. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  9791. }
  9792. else if (vnode.type === Static) {
  9793. let { el, anchor } = vnode;
  9794. while (el) {
  9795. setVarsOnNode(el, vars);
  9796. if (el === anchor)
  9797. break;
  9798. el = el.nextSibling;
  9799. }
  9800. }
  9801. }
  9802. function setVarsOnNode(el, vars) {
  9803. if (el.nodeType === 1) {
  9804. const style = el.style;
  9805. for (const key in vars) {
  9806. style.setProperty(`--${key}`, vars[key]);
  9807. }
  9808. }
  9809. }
  9810. const TRANSITION = 'transition';
  9811. const ANIMATION = 'animation';
  9812. // DOM Transition is a higher-order-component based on the platform-agnostic
  9813. // base Transition component, with DOM-specific logic.
  9814. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9815. Transition.displayName = 'Transition';
  9816. const DOMTransitionPropsValidators = {
  9817. name: String,
  9818. type: String,
  9819. css: {
  9820. type: Boolean,
  9821. default: true
  9822. },
  9823. duration: [String, Number, Object],
  9824. enterFromClass: String,
  9825. enterActiveClass: String,
  9826. enterToClass: String,
  9827. appearFromClass: String,
  9828. appearActiveClass: String,
  9829. appearToClass: String,
  9830. leaveFromClass: String,
  9831. leaveActiveClass: String,
  9832. leaveToClass: String
  9833. };
  9834. const TransitionPropsValidators = (Transition.props =
  9835. /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  9836. /**
  9837. * #3227 Incoming hooks may be merged into arrays when wrapping Transition
  9838. * with custom HOCs.
  9839. */
  9840. const callHook$1 = (hook, args = []) => {
  9841. if (isArray(hook)) {
  9842. hook.forEach(h => h(...args));
  9843. }
  9844. else if (hook) {
  9845. hook(...args);
  9846. }
  9847. };
  9848. /**
  9849. * Check if a hook expects a callback (2nd arg), which means the user
  9850. * intends to explicitly control the end of the transition.
  9851. */
  9852. const hasExplicitCallback = (hook) => {
  9853. return hook
  9854. ? isArray(hook)
  9855. ? hook.some(h => h.length > 1)
  9856. : hook.length > 1
  9857. : false;
  9858. };
  9859. function resolveTransitionProps(rawProps) {
  9860. const baseProps = {};
  9861. for (const key in rawProps) {
  9862. if (!(key in DOMTransitionPropsValidators)) {
  9863. baseProps[key] = rawProps[key];
  9864. }
  9865. }
  9866. if (rawProps.css === false) {
  9867. return baseProps;
  9868. }
  9869. const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
  9870. const durations = normalizeDuration(duration);
  9871. const enterDuration = durations && durations[0];
  9872. const leaveDuration = durations && durations[1];
  9873. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  9874. const finishEnter = (el, isAppear, done) => {
  9875. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9876. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9877. done && done();
  9878. };
  9879. const finishLeave = (el, done) => {
  9880. removeTransitionClass(el, leaveToClass);
  9881. removeTransitionClass(el, leaveActiveClass);
  9882. done && done();
  9883. };
  9884. const makeEnterHook = (isAppear) => {
  9885. return (el, done) => {
  9886. const hook = isAppear ? onAppear : onEnter;
  9887. const resolve = () => finishEnter(el, isAppear, done);
  9888. callHook$1(hook, [el, resolve]);
  9889. nextFrame(() => {
  9890. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9891. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9892. if (!hasExplicitCallback(hook)) {
  9893. whenTransitionEnds(el, type, enterDuration, resolve);
  9894. }
  9895. });
  9896. };
  9897. };
  9898. return extend(baseProps, {
  9899. onBeforeEnter(el) {
  9900. callHook$1(onBeforeEnter, [el]);
  9901. addTransitionClass(el, enterFromClass);
  9902. addTransitionClass(el, enterActiveClass);
  9903. },
  9904. onBeforeAppear(el) {
  9905. callHook$1(onBeforeAppear, [el]);
  9906. addTransitionClass(el, appearFromClass);
  9907. addTransitionClass(el, appearActiveClass);
  9908. },
  9909. onEnter: makeEnterHook(false),
  9910. onAppear: makeEnterHook(true),
  9911. onLeave(el, done) {
  9912. const resolve = () => finishLeave(el, done);
  9913. addTransitionClass(el, leaveFromClass);
  9914. // force reflow so *-leave-from classes immediately take effect (#2593)
  9915. forceReflow();
  9916. addTransitionClass(el, leaveActiveClass);
  9917. nextFrame(() => {
  9918. removeTransitionClass(el, leaveFromClass);
  9919. addTransitionClass(el, leaveToClass);
  9920. if (!hasExplicitCallback(onLeave)) {
  9921. whenTransitionEnds(el, type, leaveDuration, resolve);
  9922. }
  9923. });
  9924. callHook$1(onLeave, [el, resolve]);
  9925. },
  9926. onEnterCancelled(el) {
  9927. finishEnter(el, false);
  9928. callHook$1(onEnterCancelled, [el]);
  9929. },
  9930. onAppearCancelled(el) {
  9931. finishEnter(el, true);
  9932. callHook$1(onAppearCancelled, [el]);
  9933. },
  9934. onLeaveCancelled(el) {
  9935. finishLeave(el);
  9936. callHook$1(onLeaveCancelled, [el]);
  9937. }
  9938. });
  9939. }
  9940. function normalizeDuration(duration) {
  9941. if (duration == null) {
  9942. return null;
  9943. }
  9944. else if (isObject(duration)) {
  9945. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  9946. }
  9947. else {
  9948. const n = NumberOf(duration);
  9949. return [n, n];
  9950. }
  9951. }
  9952. function NumberOf(val) {
  9953. const res = toNumber(val);
  9954. validateDuration(res);
  9955. return res;
  9956. }
  9957. function validateDuration(val) {
  9958. if (typeof val !== 'number') {
  9959. warn$1(`<transition> explicit duration is not a valid number - ` +
  9960. `got ${JSON.stringify(val)}.`);
  9961. }
  9962. else if (isNaN(val)) {
  9963. warn$1(`<transition> explicit duration is NaN - ` +
  9964. 'the duration expression might be incorrect.');
  9965. }
  9966. }
  9967. function addTransitionClass(el, cls) {
  9968. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  9969. (el._vtc ||
  9970. (el._vtc = new Set())).add(cls);
  9971. }
  9972. function removeTransitionClass(el, cls) {
  9973. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  9974. const { _vtc } = el;
  9975. if (_vtc) {
  9976. _vtc.delete(cls);
  9977. if (!_vtc.size) {
  9978. el._vtc = undefined;
  9979. }
  9980. }
  9981. }
  9982. function nextFrame(cb) {
  9983. requestAnimationFrame(() => {
  9984. requestAnimationFrame(cb);
  9985. });
  9986. }
  9987. let endId = 0;
  9988. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  9989. const id = (el._endId = ++endId);
  9990. const resolveIfNotStale = () => {
  9991. if (id === el._endId) {
  9992. resolve();
  9993. }
  9994. };
  9995. if (explicitTimeout) {
  9996. return setTimeout(resolveIfNotStale, explicitTimeout);
  9997. }
  9998. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  9999. if (!type) {
  10000. return resolve();
  10001. }
  10002. const endEvent = type + 'end';
  10003. let ended = 0;
  10004. const end = () => {
  10005. el.removeEventListener(endEvent, onEnd);
  10006. resolveIfNotStale();
  10007. };
  10008. const onEnd = (e) => {
  10009. if (e.target === el && ++ended >= propCount) {
  10010. end();
  10011. }
  10012. };
  10013. setTimeout(() => {
  10014. if (ended < propCount) {
  10015. end();
  10016. }
  10017. }, timeout + 1);
  10018. el.addEventListener(endEvent, onEnd);
  10019. }
  10020. function getTransitionInfo(el, expectedType) {
  10021. const styles = window.getComputedStyle(el);
  10022. // JSDOM may return undefined for transition properties
  10023. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  10024. const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
  10025. const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
  10026. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  10027. const animationDelays = getStyleProperties(ANIMATION + 'Delay');
  10028. const animationDurations = getStyleProperties(ANIMATION + 'Duration');
  10029. const animationTimeout = getTimeout(animationDelays, animationDurations);
  10030. let type = null;
  10031. let timeout = 0;
  10032. let propCount = 0;
  10033. /* istanbul ignore if */
  10034. if (expectedType === TRANSITION) {
  10035. if (transitionTimeout > 0) {
  10036. type = TRANSITION;
  10037. timeout = transitionTimeout;
  10038. propCount = transitionDurations.length;
  10039. }
  10040. }
  10041. else if (expectedType === ANIMATION) {
  10042. if (animationTimeout > 0) {
  10043. type = ANIMATION;
  10044. timeout = animationTimeout;
  10045. propCount = animationDurations.length;
  10046. }
  10047. }
  10048. else {
  10049. timeout = Math.max(transitionTimeout, animationTimeout);
  10050. type =
  10051. timeout > 0
  10052. ? transitionTimeout > animationTimeout
  10053. ? TRANSITION
  10054. : ANIMATION
  10055. : null;
  10056. propCount = type
  10057. ? type === TRANSITION
  10058. ? transitionDurations.length
  10059. : animationDurations.length
  10060. : 0;
  10061. }
  10062. const hasTransform = type === TRANSITION &&
  10063. /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
  10064. return {
  10065. type,
  10066. timeout,
  10067. propCount,
  10068. hasTransform
  10069. };
  10070. }
  10071. function getTimeout(delays, durations) {
  10072. while (delays.length < durations.length) {
  10073. delays = delays.concat(delays);
  10074. }
  10075. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  10076. }
  10077. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  10078. // numbers in a locale-dependent way, using a comma instead of a dot.
  10079. // If comma is not replaced with a dot, the input will be rounded down
  10080. // (i.e. acting as a floor function) causing unexpected behaviors
  10081. function toMs(s) {
  10082. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  10083. }
  10084. // synchronously force layout to put elements into a certain state
  10085. function forceReflow() {
  10086. return document.body.offsetHeight;
  10087. }
  10088. const positionMap = new WeakMap();
  10089. const newPositionMap = new WeakMap();
  10090. const TransitionGroupImpl = {
  10091. name: 'TransitionGroup',
  10092. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  10093. tag: String,
  10094. moveClass: String
  10095. }),
  10096. setup(props, { slots }) {
  10097. const instance = getCurrentInstance();
  10098. const state = useTransitionState();
  10099. let prevChildren;
  10100. let children;
  10101. onUpdated(() => {
  10102. // children is guaranteed to exist after initial render
  10103. if (!prevChildren.length) {
  10104. return;
  10105. }
  10106. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  10107. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  10108. return;
  10109. }
  10110. // we divide the work into three loops to avoid mixing DOM reads and writes
  10111. // in each iteration - which helps prevent layout thrashing.
  10112. prevChildren.forEach(callPendingCbs);
  10113. prevChildren.forEach(recordPosition);
  10114. const movedChildren = prevChildren.filter(applyTranslation);
  10115. // force reflow to put everything in position
  10116. forceReflow();
  10117. movedChildren.forEach(c => {
  10118. const el = c.el;
  10119. const style = el.style;
  10120. addTransitionClass(el, moveClass);
  10121. style.transform = style.webkitTransform = style.transitionDuration = '';
  10122. const cb = (el._moveCb = (e) => {
  10123. if (e && e.target !== el) {
  10124. return;
  10125. }
  10126. if (!e || /transform$/.test(e.propertyName)) {
  10127. el.removeEventListener('transitionend', cb);
  10128. el._moveCb = null;
  10129. removeTransitionClass(el, moveClass);
  10130. }
  10131. });
  10132. el.addEventListener('transitionend', cb);
  10133. });
  10134. });
  10135. return () => {
  10136. const rawProps = toRaw(props);
  10137. const cssTransitionProps = resolveTransitionProps(rawProps);
  10138. let tag = rawProps.tag || Fragment;
  10139. prevChildren = children;
  10140. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10141. for (let i = 0; i < children.length; i++) {
  10142. const child = children[i];
  10143. if (child.key != null) {
  10144. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10145. }
  10146. else {
  10147. warn$1(`<TransitionGroup> children must be keyed.`);
  10148. }
  10149. }
  10150. if (prevChildren) {
  10151. for (let i = 0; i < prevChildren.length; i++) {
  10152. const child = prevChildren[i];
  10153. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10154. positionMap.set(child, child.el.getBoundingClientRect());
  10155. }
  10156. }
  10157. return createVNode(tag, null, children);
  10158. };
  10159. }
  10160. };
  10161. const TransitionGroup = TransitionGroupImpl;
  10162. function callPendingCbs(c) {
  10163. const el = c.el;
  10164. if (el._moveCb) {
  10165. el._moveCb();
  10166. }
  10167. if (el._enterCb) {
  10168. el._enterCb();
  10169. }
  10170. }
  10171. function recordPosition(c) {
  10172. newPositionMap.set(c, c.el.getBoundingClientRect());
  10173. }
  10174. function applyTranslation(c) {
  10175. const oldPos = positionMap.get(c);
  10176. const newPos = newPositionMap.get(c);
  10177. const dx = oldPos.left - newPos.left;
  10178. const dy = oldPos.top - newPos.top;
  10179. if (dx || dy) {
  10180. const s = c.el.style;
  10181. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10182. s.transitionDuration = '0s';
  10183. return c;
  10184. }
  10185. }
  10186. function hasCSSTransform(el, root, moveClass) {
  10187. // Detect whether an element with the move class applied has
  10188. // CSS transitions. Since the element may be inside an entering
  10189. // transition at this very moment, we make a clone of it and remove
  10190. // all other transition classes applied to ensure only the move class
  10191. // is applied.
  10192. const clone = el.cloneNode();
  10193. if (el._vtc) {
  10194. el._vtc.forEach(cls => {
  10195. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  10196. });
  10197. }
  10198. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  10199. clone.style.display = 'none';
  10200. const container = (root.nodeType === 1 ? root : root.parentNode);
  10201. container.appendChild(clone);
  10202. const { hasTransform } = getTransitionInfo(clone);
  10203. container.removeChild(clone);
  10204. return hasTransform;
  10205. }
  10206. const getModelAssigner = (vnode) => {
  10207. const fn = vnode.props['onUpdate:modelValue'];
  10208. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  10209. };
  10210. function onCompositionStart(e) {
  10211. e.target.composing = true;
  10212. }
  10213. function onCompositionEnd(e) {
  10214. const target = e.target;
  10215. if (target.composing) {
  10216. target.composing = false;
  10217. trigger$1(target, 'input');
  10218. }
  10219. }
  10220. function trigger$1(el, type) {
  10221. const e = document.createEvent('HTMLEvents');
  10222. e.initEvent(type, true, true);
  10223. el.dispatchEvent(e);
  10224. }
  10225. // We are exporting the v-model runtime directly as vnode hooks so that it can
  10226. // be tree-shaken in case v-model is never used.
  10227. const vModelText = {
  10228. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10229. el._assign = getModelAssigner(vnode);
  10230. const castToNumber = number || (vnode.props && vnode.props.type === 'number');
  10231. addEventListener(el, lazy ? 'change' : 'input', e => {
  10232. if (e.target.composing)
  10233. return;
  10234. let domValue = el.value;
  10235. if (trim) {
  10236. domValue = domValue.trim();
  10237. }
  10238. else if (castToNumber) {
  10239. domValue = toNumber(domValue);
  10240. }
  10241. el._assign(domValue);
  10242. });
  10243. if (trim) {
  10244. addEventListener(el, 'change', () => {
  10245. el.value = el.value.trim();
  10246. });
  10247. }
  10248. if (!lazy) {
  10249. addEventListener(el, 'compositionstart', onCompositionStart);
  10250. addEventListener(el, 'compositionend', onCompositionEnd);
  10251. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  10252. // switching focus before confirming composition choice
  10253. // this also fixes the issue where some browsers e.g. iOS Chrome
  10254. // fires "change" instead of "input" on autocomplete.
  10255. addEventListener(el, 'change', onCompositionEnd);
  10256. }
  10257. },
  10258. // set value on mounted so it's after min/max for type="range"
  10259. mounted(el, { value }) {
  10260. el.value = value == null ? '' : value;
  10261. },
  10262. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10263. el._assign = getModelAssigner(vnode);
  10264. // avoid clearing unresolved text. #2302
  10265. if (el.composing)
  10266. return;
  10267. if (document.activeElement === el) {
  10268. if (lazy) {
  10269. return;
  10270. }
  10271. if (trim && el.value.trim() === value) {
  10272. return;
  10273. }
  10274. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  10275. return;
  10276. }
  10277. }
  10278. const newValue = value == null ? '' : value;
  10279. if (el.value !== newValue) {
  10280. el.value = newValue;
  10281. }
  10282. }
  10283. };
  10284. const vModelCheckbox = {
  10285. // #4096 array checkboxes need to be deep traversed
  10286. deep: true,
  10287. created(el, _, vnode) {
  10288. el._assign = getModelAssigner(vnode);
  10289. addEventListener(el, 'change', () => {
  10290. const modelValue = el._modelValue;
  10291. const elementValue = getValue(el);
  10292. const checked = el.checked;
  10293. const assign = el._assign;
  10294. if (isArray(modelValue)) {
  10295. const index = looseIndexOf(modelValue, elementValue);
  10296. const found = index !== -1;
  10297. if (checked && !found) {
  10298. assign(modelValue.concat(elementValue));
  10299. }
  10300. else if (!checked && found) {
  10301. const filtered = [...modelValue];
  10302. filtered.splice(index, 1);
  10303. assign(filtered);
  10304. }
  10305. }
  10306. else if (isSet(modelValue)) {
  10307. const cloned = new Set(modelValue);
  10308. if (checked) {
  10309. cloned.add(elementValue);
  10310. }
  10311. else {
  10312. cloned.delete(elementValue);
  10313. }
  10314. assign(cloned);
  10315. }
  10316. else {
  10317. assign(getCheckboxValue(el, checked));
  10318. }
  10319. });
  10320. },
  10321. // set initial checked on mount to wait for true-value/false-value
  10322. mounted: setChecked,
  10323. beforeUpdate(el, binding, vnode) {
  10324. el._assign = getModelAssigner(vnode);
  10325. setChecked(el, binding, vnode);
  10326. }
  10327. };
  10328. function setChecked(el, { value, oldValue }, vnode) {
  10329. el._modelValue = value;
  10330. if (isArray(value)) {
  10331. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10332. }
  10333. else if (isSet(value)) {
  10334. el.checked = value.has(vnode.props.value);
  10335. }
  10336. else if (value !== oldValue) {
  10337. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10338. }
  10339. }
  10340. const vModelRadio = {
  10341. created(el, { value }, vnode) {
  10342. el.checked = looseEqual(value, vnode.props.value);
  10343. el._assign = getModelAssigner(vnode);
  10344. addEventListener(el, 'change', () => {
  10345. el._assign(getValue(el));
  10346. });
  10347. },
  10348. beforeUpdate(el, { value, oldValue }, vnode) {
  10349. el._assign = getModelAssigner(vnode);
  10350. if (value !== oldValue) {
  10351. el.checked = looseEqual(value, vnode.props.value);
  10352. }
  10353. }
  10354. };
  10355. const vModelSelect = {
  10356. // <select multiple> value need to be deep traversed
  10357. deep: true,
  10358. created(el, { value, modifiers: { number } }, vnode) {
  10359. const isSetModel = isSet(value);
  10360. addEventListener(el, 'change', () => {
  10361. const selectedVal = Array.prototype.filter
  10362. .call(el.options, (o) => o.selected)
  10363. .map((o) => number ? toNumber(getValue(o)) : getValue(o));
  10364. el._assign(el.multiple
  10365. ? isSetModel
  10366. ? new Set(selectedVal)
  10367. : selectedVal
  10368. : selectedVal[0]);
  10369. });
  10370. el._assign = getModelAssigner(vnode);
  10371. },
  10372. // set value in mounted & updated because <select> relies on its children
  10373. // <option>s.
  10374. mounted(el, { value }) {
  10375. setSelected(el, value);
  10376. },
  10377. beforeUpdate(el, _binding, vnode) {
  10378. el._assign = getModelAssigner(vnode);
  10379. },
  10380. updated(el, { value }) {
  10381. setSelected(el, value);
  10382. }
  10383. };
  10384. function setSelected(el, value) {
  10385. const isMultiple = el.multiple;
  10386. if (isMultiple && !isArray(value) && !isSet(value)) {
  10387. warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  10388. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  10389. return;
  10390. }
  10391. for (let i = 0, l = el.options.length; i < l; i++) {
  10392. const option = el.options[i];
  10393. const optionValue = getValue(option);
  10394. if (isMultiple) {
  10395. if (isArray(value)) {
  10396. option.selected = looseIndexOf(value, optionValue) > -1;
  10397. }
  10398. else {
  10399. option.selected = value.has(optionValue);
  10400. }
  10401. }
  10402. else {
  10403. if (looseEqual(getValue(option), value)) {
  10404. if (el.selectedIndex !== i)
  10405. el.selectedIndex = i;
  10406. return;
  10407. }
  10408. }
  10409. }
  10410. if (!isMultiple && el.selectedIndex !== -1) {
  10411. el.selectedIndex = -1;
  10412. }
  10413. }
  10414. // retrieve raw value set via :value bindings
  10415. function getValue(el) {
  10416. return '_value' in el ? el._value : el.value;
  10417. }
  10418. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  10419. function getCheckboxValue(el, checked) {
  10420. const key = checked ? '_trueValue' : '_falseValue';
  10421. return key in el ? el[key] : checked;
  10422. }
  10423. const vModelDynamic = {
  10424. created(el, binding, vnode) {
  10425. callModelHook(el, binding, vnode, null, 'created');
  10426. },
  10427. mounted(el, binding, vnode) {
  10428. callModelHook(el, binding, vnode, null, 'mounted');
  10429. },
  10430. beforeUpdate(el, binding, vnode, prevVNode) {
  10431. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  10432. },
  10433. updated(el, binding, vnode, prevVNode) {
  10434. callModelHook(el, binding, vnode, prevVNode, 'updated');
  10435. }
  10436. };
  10437. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10438. let modelToUse;
  10439. switch (el.tagName) {
  10440. case 'SELECT':
  10441. modelToUse = vModelSelect;
  10442. break;
  10443. case 'TEXTAREA':
  10444. modelToUse = vModelText;
  10445. break;
  10446. default:
  10447. switch (vnode.props && vnode.props.type) {
  10448. case 'checkbox':
  10449. modelToUse = vModelCheckbox;
  10450. break;
  10451. case 'radio':
  10452. modelToUse = vModelRadio;
  10453. break;
  10454. default:
  10455. modelToUse = vModelText;
  10456. }
  10457. }
  10458. const fn = modelToUse[hook];
  10459. fn && fn(el, binding, vnode, prevVNode);
  10460. }
  10461. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  10462. const modifierGuards = {
  10463. stop: e => e.stopPropagation(),
  10464. prevent: e => e.preventDefault(),
  10465. self: e => e.target !== e.currentTarget,
  10466. ctrl: e => !e.ctrlKey,
  10467. shift: e => !e.shiftKey,
  10468. alt: e => !e.altKey,
  10469. meta: e => !e.metaKey,
  10470. left: e => 'button' in e && e.button !== 0,
  10471. middle: e => 'button' in e && e.button !== 1,
  10472. right: e => 'button' in e && e.button !== 2,
  10473. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  10474. };
  10475. /**
  10476. * @private
  10477. */
  10478. const withModifiers = (fn, modifiers) => {
  10479. return (event, ...args) => {
  10480. for (let i = 0; i < modifiers.length; i++) {
  10481. const guard = modifierGuards[modifiers[i]];
  10482. if (guard && guard(event, modifiers))
  10483. return;
  10484. }
  10485. return fn(event, ...args);
  10486. };
  10487. };
  10488. // Kept for 2.x compat.
  10489. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  10490. const keyNames = {
  10491. esc: 'escape',
  10492. space: ' ',
  10493. up: 'arrow-up',
  10494. left: 'arrow-left',
  10495. right: 'arrow-right',
  10496. down: 'arrow-down',
  10497. delete: 'backspace'
  10498. };
  10499. /**
  10500. * @private
  10501. */
  10502. const withKeys = (fn, modifiers) => {
  10503. return (event) => {
  10504. if (!('key' in event)) {
  10505. return;
  10506. }
  10507. const eventKey = hyphenate(event.key);
  10508. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  10509. return fn(event);
  10510. }
  10511. };
  10512. };
  10513. const vShow = {
  10514. beforeMount(el, { value }, { transition }) {
  10515. el._vod = el.style.display === 'none' ? '' : el.style.display;
  10516. if (transition && value) {
  10517. transition.beforeEnter(el);
  10518. }
  10519. else {
  10520. setDisplay(el, value);
  10521. }
  10522. },
  10523. mounted(el, { value }, { transition }) {
  10524. if (transition && value) {
  10525. transition.enter(el);
  10526. }
  10527. },
  10528. updated(el, { value, oldValue }, { transition }) {
  10529. if (!value === !oldValue)
  10530. return;
  10531. if (transition) {
  10532. if (value) {
  10533. transition.beforeEnter(el);
  10534. setDisplay(el, true);
  10535. transition.enter(el);
  10536. }
  10537. else {
  10538. transition.leave(el, () => {
  10539. setDisplay(el, false);
  10540. });
  10541. }
  10542. }
  10543. else {
  10544. setDisplay(el, value);
  10545. }
  10546. },
  10547. beforeUnmount(el, { value }) {
  10548. setDisplay(el, value);
  10549. }
  10550. };
  10551. function setDisplay(el, value) {
  10552. el.style.display = value ? el._vod : 'none';
  10553. }
  10554. const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
  10555. // lazy create the renderer - this makes core renderer logic tree-shakable
  10556. // in case the user only imports reactivity utilities from Vue.
  10557. let renderer;
  10558. let enabledHydration = false;
  10559. function ensureRenderer() {
  10560. return (renderer ||
  10561. (renderer = createRenderer(rendererOptions)));
  10562. }
  10563. function ensureHydrationRenderer() {
  10564. renderer = enabledHydration
  10565. ? renderer
  10566. : createHydrationRenderer(rendererOptions);
  10567. enabledHydration = true;
  10568. return renderer;
  10569. }
  10570. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  10571. const render = ((...args) => {
  10572. ensureRenderer().render(...args);
  10573. });
  10574. const hydrate = ((...args) => {
  10575. ensureHydrationRenderer().hydrate(...args);
  10576. });
  10577. const createApp = ((...args) => {
  10578. const app = ensureRenderer().createApp(...args);
  10579. {
  10580. injectNativeTagCheck(app);
  10581. injectCompilerOptionsCheck(app);
  10582. }
  10583. const { mount } = app;
  10584. app.mount = (containerOrSelector) => {
  10585. const container = normalizeContainer(containerOrSelector);
  10586. if (!container)
  10587. return;
  10588. const component = app._component;
  10589. if (!isFunction(component) && !component.render && !component.template) {
  10590. // __UNSAFE__
  10591. // Reason: potential execution of JS expressions in in-DOM template.
  10592. // The user must make sure the in-DOM template is trusted. If it's
  10593. // rendered by the server, the template should not contain any user data.
  10594. component.template = container.innerHTML;
  10595. }
  10596. // clear content before mounting
  10597. container.innerHTML = '';
  10598. const proxy = mount(container, false, container instanceof SVGElement);
  10599. if (container instanceof Element) {
  10600. container.removeAttribute('v-cloak');
  10601. container.setAttribute('data-v-app', '');
  10602. }
  10603. return proxy;
  10604. };
  10605. return app;
  10606. });
  10607. const createSSRApp = ((...args) => {
  10608. const app = ensureHydrationRenderer().createApp(...args);
  10609. {
  10610. injectNativeTagCheck(app);
  10611. injectCompilerOptionsCheck(app);
  10612. }
  10613. const { mount } = app;
  10614. app.mount = (containerOrSelector) => {
  10615. const container = normalizeContainer(containerOrSelector);
  10616. if (container) {
  10617. return mount(container, true, container instanceof SVGElement);
  10618. }
  10619. };
  10620. return app;
  10621. });
  10622. function injectNativeTagCheck(app) {
  10623. // Inject `isNativeTag`
  10624. // this is used for component name validation (dev only)
  10625. Object.defineProperty(app.config, 'isNativeTag', {
  10626. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10627. writable: false
  10628. });
  10629. }
  10630. // dev only
  10631. function injectCompilerOptionsCheck(app) {
  10632. if (isRuntimeOnly()) {
  10633. const isCustomElement = app.config.isCustomElement;
  10634. Object.defineProperty(app.config, 'isCustomElement', {
  10635. get() {
  10636. return isCustomElement;
  10637. },
  10638. set() {
  10639. warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
  10640. `\`compilerOptions.isCustomElement\` instead.`);
  10641. }
  10642. });
  10643. const compilerOptions = app.config.compilerOptions;
  10644. const msg = `The \`compilerOptions\` config option is only respected when using ` +
  10645. `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
  10646. `Since you are using the runtime-only build, \`compilerOptions\` ` +
  10647. `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
  10648. `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
  10649. `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
  10650. `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
  10651. Object.defineProperty(app.config, 'compilerOptions', {
  10652. get() {
  10653. warn$1(msg);
  10654. return compilerOptions;
  10655. },
  10656. set() {
  10657. warn$1(msg);
  10658. }
  10659. });
  10660. }
  10661. }
  10662. function normalizeContainer(container) {
  10663. if (isString(container)) {
  10664. const res = document.querySelector(container);
  10665. if (!res) {
  10666. warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
  10667. }
  10668. return res;
  10669. }
  10670. if (window.ShadowRoot &&
  10671. container instanceof window.ShadowRoot &&
  10672. container.mode === 'closed') {
  10673. warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
  10674. }
  10675. return container;
  10676. }
  10677. /**
  10678. * @internal
  10679. */
  10680. const initDirectivesForSSR = NOOP;
  10681. function initDev() {
  10682. {
  10683. {
  10684. console.info(`You are running a development build of Vue.\n` +
  10685. `Make sure to use the production build (*.prod.js) when deploying for production.`);
  10686. }
  10687. initCustomFormatter();
  10688. }
  10689. }
  10690. // This entry exports the runtime only, and is built as
  10691. {
  10692. initDev();
  10693. }
  10694. const compile$1 = () => {
  10695. {
  10696. warn$1(`Runtime compilation is not supported in this build of Vue.` +
  10697. (` Use "vue.global.js" instead.`
  10698. ) /* should not happen */);
  10699. }
  10700. };
  10701. exports.BaseTransition = BaseTransition;
  10702. exports.Comment = Comment;
  10703. exports.EffectScope = EffectScope;
  10704. exports.Fragment = Fragment;
  10705. exports.KeepAlive = KeepAlive;
  10706. exports.ReactiveEffect = ReactiveEffect;
  10707. exports.Static = Static;
  10708. exports.Suspense = Suspense;
  10709. exports.Teleport = Teleport;
  10710. exports.Text = Text;
  10711. exports.Transition = Transition;
  10712. exports.TransitionGroup = TransitionGroup;
  10713. exports.VueElement = VueElement;
  10714. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  10715. exports.callWithErrorHandling = callWithErrorHandling;
  10716. exports.camelize = camelize;
  10717. exports.capitalize = capitalize;
  10718. exports.cloneVNode = cloneVNode;
  10719. exports.compatUtils = compatUtils;
  10720. exports.compile = compile$1;
  10721. exports.computed = computed$1;
  10722. exports.createApp = createApp;
  10723. exports.createBlock = createBlock;
  10724. exports.createCommentVNode = createCommentVNode;
  10725. exports.createElementBlock = createElementBlock;
  10726. exports.createElementVNode = createBaseVNode;
  10727. exports.createHydrationRenderer = createHydrationRenderer;
  10728. exports.createPropsRestProxy = createPropsRestProxy;
  10729. exports.createRenderer = createRenderer;
  10730. exports.createSSRApp = createSSRApp;
  10731. exports.createSlots = createSlots;
  10732. exports.createStaticVNode = createStaticVNode;
  10733. exports.createTextVNode = createTextVNode;
  10734. exports.createVNode = createVNode;
  10735. exports.customRef = customRef;
  10736. exports.defineAsyncComponent = defineAsyncComponent;
  10737. exports.defineComponent = defineComponent;
  10738. exports.defineCustomElement = defineCustomElement;
  10739. exports.defineEmits = defineEmits;
  10740. exports.defineExpose = defineExpose;
  10741. exports.defineProps = defineProps;
  10742. exports.defineSSRCustomElement = defineSSRCustomElement;
  10743. exports.effect = effect;
  10744. exports.effectScope = effectScope;
  10745. exports.getCurrentInstance = getCurrentInstance;
  10746. exports.getCurrentScope = getCurrentScope;
  10747. exports.getTransitionRawChildren = getTransitionRawChildren;
  10748. exports.guardReactiveProps = guardReactiveProps;
  10749. exports.h = h;
  10750. exports.handleError = handleError;
  10751. exports.hydrate = hydrate;
  10752. exports.initCustomFormatter = initCustomFormatter;
  10753. exports.initDirectivesForSSR = initDirectivesForSSR;
  10754. exports.inject = inject;
  10755. exports.isMemoSame = isMemoSame;
  10756. exports.isProxy = isProxy;
  10757. exports.isReactive = isReactive;
  10758. exports.isReadonly = isReadonly;
  10759. exports.isRef = isRef;
  10760. exports.isRuntimeOnly = isRuntimeOnly;
  10761. exports.isShallow = isShallow;
  10762. exports.isVNode = isVNode;
  10763. exports.markRaw = markRaw;
  10764. exports.mergeDefaults = mergeDefaults;
  10765. exports.mergeProps = mergeProps;
  10766. exports.nextTick = nextTick;
  10767. exports.normalizeClass = normalizeClass;
  10768. exports.normalizeProps = normalizeProps;
  10769. exports.normalizeStyle = normalizeStyle;
  10770. exports.onActivated = onActivated;
  10771. exports.onBeforeMount = onBeforeMount;
  10772. exports.onBeforeUnmount = onBeforeUnmount;
  10773. exports.onBeforeUpdate = onBeforeUpdate;
  10774. exports.onDeactivated = onDeactivated;
  10775. exports.onErrorCaptured = onErrorCaptured;
  10776. exports.onMounted = onMounted;
  10777. exports.onRenderTracked = onRenderTracked;
  10778. exports.onRenderTriggered = onRenderTriggered;
  10779. exports.onScopeDispose = onScopeDispose;
  10780. exports.onServerPrefetch = onServerPrefetch;
  10781. exports.onUnmounted = onUnmounted;
  10782. exports.onUpdated = onUpdated;
  10783. exports.openBlock = openBlock;
  10784. exports.popScopeId = popScopeId;
  10785. exports.provide = provide;
  10786. exports.proxyRefs = proxyRefs;
  10787. exports.pushScopeId = pushScopeId;
  10788. exports.queuePostFlushCb = queuePostFlushCb;
  10789. exports.reactive = reactive;
  10790. exports.readonly = readonly;
  10791. exports.ref = ref;
  10792. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  10793. exports.render = render;
  10794. exports.renderList = renderList;
  10795. exports.renderSlot = renderSlot;
  10796. exports.resolveComponent = resolveComponent;
  10797. exports.resolveDirective = resolveDirective;
  10798. exports.resolveDynamicComponent = resolveDynamicComponent;
  10799. exports.resolveFilter = resolveFilter;
  10800. exports.resolveTransitionHooks = resolveTransitionHooks;
  10801. exports.setBlockTracking = setBlockTracking;
  10802. exports.setDevtoolsHook = setDevtoolsHook;
  10803. exports.setTransitionHooks = setTransitionHooks;
  10804. exports.shallowReactive = shallowReactive;
  10805. exports.shallowReadonly = shallowReadonly;
  10806. exports.shallowRef = shallowRef;
  10807. exports.ssrContextKey = ssrContextKey;
  10808. exports.ssrUtils = ssrUtils;
  10809. exports.stop = stop;
  10810. exports.toDisplayString = toDisplayString;
  10811. exports.toHandlerKey = toHandlerKey;
  10812. exports.toHandlers = toHandlers;
  10813. exports.toRaw = toRaw;
  10814. exports.toRef = toRef;
  10815. exports.toRefs = toRefs;
  10816. exports.transformVNodeArgs = transformVNodeArgs;
  10817. exports.triggerRef = triggerRef;
  10818. exports.unref = unref;
  10819. exports.useAttrs = useAttrs;
  10820. exports.useCssModule = useCssModule;
  10821. exports.useCssVars = useCssVars;
  10822. exports.useSSRContext = useSSRContext;
  10823. exports.useSlots = useSlots;
  10824. exports.useTransitionState = useTransitionState;
  10825. exports.vModelCheckbox = vModelCheckbox;
  10826. exports.vModelDynamic = vModelDynamic;
  10827. exports.vModelRadio = vModelRadio;
  10828. exports.vModelSelect = vModelSelect;
  10829. exports.vModelText = vModelText;
  10830. exports.vShow = vShow;
  10831. exports.version = version;
  10832. exports.warn = warn$1;
  10833. exports.watch = watch;
  10834. exports.watchEffect = watchEffect;
  10835. exports.watchPostEffect = watchPostEffect;
  10836. exports.watchSyncEffect = watchSyncEffect;
  10837. exports.withAsyncContext = withAsyncContext;
  10838. exports.withCtx = withCtx;
  10839. exports.withDefaults = withDefaults;
  10840. exports.withDirectives = withDirectives;
  10841. exports.withKeys = withKeys;
  10842. exports.withMemo = withMemo;
  10843. exports.withModifiers = withModifiers;
  10844. exports.withScopeId = withScopeId;
  10845. Object.defineProperty(exports, '__esModule', { value: true });
  10846. return exports;
  10847. }({}));