vue.runtime.esm-browser.js 392 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866
  1. /**
  2. * Make a map and return a function for checking if a key
  3. * is in that map.
  4. * IMPORTANT: all calls of this function must be prefixed with
  5. * \/\*#\_\_PURE\_\_\*\/
  6. * So that rollup can tree-shake them if necessary.
  7. */
  8. function makeMap(str, expectsLowerCase) {
  9. const map = Object.create(null);
  10. const list = str.split(',');
  11. for (let i = 0; i < list.length; i++) {
  12. map[list[i]] = true;
  13. }
  14. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  15. }
  16. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  17. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  18. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  19. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  20. /**
  21. * On the client we only need to offer special cases for boolean attributes that
  22. * have different names from their corresponding dom properties:
  23. * - itemscope -> N/A
  24. * - allowfullscreen -> allowFullscreen
  25. * - formnovalidate -> formNoValidate
  26. * - ismap -> isMap
  27. * - nomodule -> noModule
  28. * - novalidate -> noValidate
  29. * - readonly -> readOnly
  30. */
  31. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  32. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  33. /**
  34. * Boolean attributes should be included if the value is truthy or ''.
  35. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  36. */
  37. function includeBooleanAttr(value) {
  38. return !!value || value === '';
  39. }
  40. function normalizeStyle(value) {
  41. if (isArray(value)) {
  42. const res = {};
  43. for (let i = 0; i < value.length; i++) {
  44. const item = value[i];
  45. const normalized = isString(item)
  46. ? parseStringStyle(item)
  47. : normalizeStyle(item);
  48. if (normalized) {
  49. for (const key in normalized) {
  50. res[key] = normalized[key];
  51. }
  52. }
  53. }
  54. return res;
  55. }
  56. else if (isString(value)) {
  57. return value;
  58. }
  59. else if (isObject(value)) {
  60. return value;
  61. }
  62. }
  63. const listDelimiterRE = /;(?![^(]*\))/g;
  64. const propertyDelimiterRE = /:(.+)/;
  65. function parseStringStyle(cssText) {
  66. const ret = {};
  67. cssText.split(listDelimiterRE).forEach(item => {
  68. if (item) {
  69. const tmp = item.split(propertyDelimiterRE);
  70. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  71. }
  72. });
  73. return ret;
  74. }
  75. function normalizeClass(value) {
  76. let res = '';
  77. if (isString(value)) {
  78. res = value;
  79. }
  80. else if (isArray(value)) {
  81. for (let i = 0; i < value.length; i++) {
  82. const normalized = normalizeClass(value[i]);
  83. if (normalized) {
  84. res += normalized + ' ';
  85. }
  86. }
  87. }
  88. else if (isObject(value)) {
  89. for (const name in value) {
  90. if (value[name]) {
  91. res += name + ' ';
  92. }
  93. }
  94. }
  95. return res.trim();
  96. }
  97. function normalizeProps(props) {
  98. if (!props)
  99. return null;
  100. let { class: klass, style } = props;
  101. if (klass && !isString(klass)) {
  102. props.class = normalizeClass(klass);
  103. }
  104. if (style) {
  105. props.style = normalizeStyle(style);
  106. }
  107. return props;
  108. }
  109. // These tag configs are shared between compiler-dom and runtime-dom, so they
  110. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  111. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  112. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  113. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  114. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  115. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  116. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  117. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  118. 'option,output,progress,select,textarea,details,dialog,menu,' +
  119. 'summary,template,blockquote,iframe,tfoot';
  120. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  121. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  122. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  123. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  124. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  125. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  126. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  127. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  128. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  129. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  130. 'text,textPath,title,tspan,unknown,use,view';
  131. /**
  132. * Compiler only.
  133. * Do NOT use in runtime code paths unless behind `true` flag.
  134. */
  135. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  136. /**
  137. * Compiler only.
  138. * Do NOT use in runtime code paths unless behind `true` flag.
  139. */
  140. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  141. function looseCompareArrays(a, b) {
  142. if (a.length !== b.length)
  143. return false;
  144. let equal = true;
  145. for (let i = 0; equal && i < a.length; i++) {
  146. equal = looseEqual(a[i], b[i]);
  147. }
  148. return equal;
  149. }
  150. function looseEqual(a, b) {
  151. if (a === b)
  152. return true;
  153. let aValidType = isDate(a);
  154. let bValidType = isDate(b);
  155. if (aValidType || bValidType) {
  156. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  157. }
  158. aValidType = isSymbol(a);
  159. bValidType = isSymbol(b);
  160. if (aValidType || bValidType) {
  161. return a === b;
  162. }
  163. aValidType = isArray(a);
  164. bValidType = isArray(b);
  165. if (aValidType || bValidType) {
  166. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  167. }
  168. aValidType = isObject(a);
  169. bValidType = isObject(b);
  170. if (aValidType || bValidType) {
  171. /* istanbul ignore if: this if will probably never be called */
  172. if (!aValidType || !bValidType) {
  173. return false;
  174. }
  175. const aKeysCount = Object.keys(a).length;
  176. const bKeysCount = Object.keys(b).length;
  177. if (aKeysCount !== bKeysCount) {
  178. return false;
  179. }
  180. for (const key in a) {
  181. const aHasKey = a.hasOwnProperty(key);
  182. const bHasKey = b.hasOwnProperty(key);
  183. if ((aHasKey && !bHasKey) ||
  184. (!aHasKey && bHasKey) ||
  185. !looseEqual(a[key], b[key])) {
  186. return false;
  187. }
  188. }
  189. }
  190. return String(a) === String(b);
  191. }
  192. function looseIndexOf(arr, val) {
  193. return arr.findIndex(item => looseEqual(item, val));
  194. }
  195. /**
  196. * For converting {{ interpolation }} values to displayed strings.
  197. * @private
  198. */
  199. const toDisplayString = (val) => {
  200. return isString(val)
  201. ? val
  202. : val == null
  203. ? ''
  204. : isArray(val) ||
  205. (isObject(val) &&
  206. (val.toString === objectToString || !isFunction(val.toString)))
  207. ? JSON.stringify(val, replacer, 2)
  208. : String(val);
  209. };
  210. const replacer = (_key, val) => {
  211. // can't use isRef here since @vue/shared has no deps
  212. if (val && val.__v_isRef) {
  213. return replacer(_key, val.value);
  214. }
  215. else if (isMap(val)) {
  216. return {
  217. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  218. entries[`${key} =>`] = val;
  219. return entries;
  220. }, {})
  221. };
  222. }
  223. else if (isSet(val)) {
  224. return {
  225. [`Set(${val.size})`]: [...val.values()]
  226. };
  227. }
  228. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  229. return String(val);
  230. }
  231. return val;
  232. };
  233. const EMPTY_OBJ = Object.freeze({})
  234. ;
  235. const EMPTY_ARR = Object.freeze([]) ;
  236. const NOOP = () => { };
  237. /**
  238. * Always return false.
  239. */
  240. const NO = () => false;
  241. const onRE = /^on[^a-z]/;
  242. const isOn = (key) => onRE.test(key);
  243. const isModelListener = (key) => key.startsWith('onUpdate:');
  244. const extend = Object.assign;
  245. const remove = (arr, el) => {
  246. const i = arr.indexOf(el);
  247. if (i > -1) {
  248. arr.splice(i, 1);
  249. }
  250. };
  251. const hasOwnProperty = Object.prototype.hasOwnProperty;
  252. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  253. const isArray = Array.isArray;
  254. const isMap = (val) => toTypeString(val) === '[object Map]';
  255. const isSet = (val) => toTypeString(val) === '[object Set]';
  256. const isDate = (val) => toTypeString(val) === '[object Date]';
  257. const isFunction = (val) => typeof val === 'function';
  258. const isString = (val) => typeof val === 'string';
  259. const isSymbol = (val) => typeof val === 'symbol';
  260. const isObject = (val) => val !== null && typeof val === 'object';
  261. const isPromise = (val) => {
  262. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  263. };
  264. const objectToString = Object.prototype.toString;
  265. const toTypeString = (value) => objectToString.call(value);
  266. const toRawType = (value) => {
  267. // extract "RawType" from strings like "[object RawType]"
  268. return toTypeString(value).slice(8, -1);
  269. };
  270. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  271. const isIntegerKey = (key) => isString(key) &&
  272. key !== 'NaN' &&
  273. key[0] !== '-' &&
  274. '' + parseInt(key, 10) === key;
  275. const isReservedProp = /*#__PURE__*/ makeMap(
  276. // the leading comma is intentional so empty string "" is also included
  277. ',key,ref,ref_for,ref_key,' +
  278. 'onVnodeBeforeMount,onVnodeMounted,' +
  279. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  280. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  281. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
  282. const cacheStringFunction = (fn) => {
  283. const cache = Object.create(null);
  284. return ((str) => {
  285. const hit = cache[str];
  286. return hit || (cache[str] = fn(str));
  287. });
  288. };
  289. const camelizeRE = /-(\w)/g;
  290. /**
  291. * @private
  292. */
  293. const camelize = cacheStringFunction((str) => {
  294. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  295. });
  296. const hyphenateRE = /\B([A-Z])/g;
  297. /**
  298. * @private
  299. */
  300. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  301. /**
  302. * @private
  303. */
  304. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  305. /**
  306. * @private
  307. */
  308. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  309. // compare whether a value has changed, accounting for NaN.
  310. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  311. const invokeArrayFns = (fns, arg) => {
  312. for (let i = 0; i < fns.length; i++) {
  313. fns[i](arg);
  314. }
  315. };
  316. const def = (obj, key, value) => {
  317. Object.defineProperty(obj, key, {
  318. configurable: true,
  319. enumerable: false,
  320. value
  321. });
  322. };
  323. const toNumber = (val) => {
  324. const n = parseFloat(val);
  325. return isNaN(n) ? val : n;
  326. };
  327. let _globalThis;
  328. const getGlobalThis = () => {
  329. return (_globalThis ||
  330. (_globalThis =
  331. typeof globalThis !== 'undefined'
  332. ? globalThis
  333. : typeof self !== 'undefined'
  334. ? self
  335. : typeof window !== 'undefined'
  336. ? window
  337. : typeof global !== 'undefined'
  338. ? global
  339. : {}));
  340. };
  341. function warn(msg, ...args) {
  342. console.warn(`[Vue warn] ${msg}`, ...args);
  343. }
  344. let activeEffectScope;
  345. class EffectScope {
  346. constructor(detached = false) {
  347. /**
  348. * @internal
  349. */
  350. this.active = true;
  351. /**
  352. * @internal
  353. */
  354. this.effects = [];
  355. /**
  356. * @internal
  357. */
  358. this.cleanups = [];
  359. if (!detached && activeEffectScope) {
  360. this.parent = activeEffectScope;
  361. this.index =
  362. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  363. }
  364. }
  365. run(fn) {
  366. if (this.active) {
  367. const currentEffectScope = activeEffectScope;
  368. try {
  369. activeEffectScope = this;
  370. return fn();
  371. }
  372. finally {
  373. activeEffectScope = currentEffectScope;
  374. }
  375. }
  376. else {
  377. warn(`cannot run an inactive effect scope.`);
  378. }
  379. }
  380. /**
  381. * This should only be called on non-detached scopes
  382. * @internal
  383. */
  384. on() {
  385. activeEffectScope = this;
  386. }
  387. /**
  388. * This should only be called on non-detached scopes
  389. * @internal
  390. */
  391. off() {
  392. activeEffectScope = this.parent;
  393. }
  394. stop(fromParent) {
  395. if (this.active) {
  396. let i, l;
  397. for (i = 0, l = this.effects.length; i < l; i++) {
  398. this.effects[i].stop();
  399. }
  400. for (i = 0, l = this.cleanups.length; i < l; i++) {
  401. this.cleanups[i]();
  402. }
  403. if (this.scopes) {
  404. for (i = 0, l = this.scopes.length; i < l; i++) {
  405. this.scopes[i].stop(true);
  406. }
  407. }
  408. // nested scope, dereference from parent to avoid memory leaks
  409. if (this.parent && !fromParent) {
  410. // optimized O(1) removal
  411. const last = this.parent.scopes.pop();
  412. if (last && last !== this) {
  413. this.parent.scopes[this.index] = last;
  414. last.index = this.index;
  415. }
  416. }
  417. this.active = false;
  418. }
  419. }
  420. }
  421. function effectScope(detached) {
  422. return new EffectScope(detached);
  423. }
  424. function recordEffectScope(effect, scope = activeEffectScope) {
  425. if (scope && scope.active) {
  426. scope.effects.push(effect);
  427. }
  428. }
  429. function getCurrentScope() {
  430. return activeEffectScope;
  431. }
  432. function onScopeDispose(fn) {
  433. if (activeEffectScope) {
  434. activeEffectScope.cleanups.push(fn);
  435. }
  436. else {
  437. warn(`onScopeDispose() is called when there is no active effect scope` +
  438. ` to be associated with.`);
  439. }
  440. }
  441. const createDep = (effects) => {
  442. const dep = new Set(effects);
  443. dep.w = 0;
  444. dep.n = 0;
  445. return dep;
  446. };
  447. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  448. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  449. const initDepMarkers = ({ deps }) => {
  450. if (deps.length) {
  451. for (let i = 0; i < deps.length; i++) {
  452. deps[i].w |= trackOpBit; // set was tracked
  453. }
  454. }
  455. };
  456. const finalizeDepMarkers = (effect) => {
  457. const { deps } = effect;
  458. if (deps.length) {
  459. let ptr = 0;
  460. for (let i = 0; i < deps.length; i++) {
  461. const dep = deps[i];
  462. if (wasTracked(dep) && !newTracked(dep)) {
  463. dep.delete(effect);
  464. }
  465. else {
  466. deps[ptr++] = dep;
  467. }
  468. // clear bits
  469. dep.w &= ~trackOpBit;
  470. dep.n &= ~trackOpBit;
  471. }
  472. deps.length = ptr;
  473. }
  474. };
  475. const targetMap = new WeakMap();
  476. // The number of effects currently being tracked recursively.
  477. let effectTrackDepth = 0;
  478. let trackOpBit = 1;
  479. /**
  480. * The bitwise track markers support at most 30 levels of recursion.
  481. * This value is chosen to enable modern JS engines to use a SMI on all platforms.
  482. * When recursion depth is greater, fall back to using a full cleanup.
  483. */
  484. const maxMarkerBits = 30;
  485. let activeEffect;
  486. const ITERATE_KEY = Symbol('iterate' );
  487. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
  488. class ReactiveEffect {
  489. constructor(fn, scheduler = null, scope) {
  490. this.fn = fn;
  491. this.scheduler = scheduler;
  492. this.active = true;
  493. this.deps = [];
  494. this.parent = undefined;
  495. recordEffectScope(this, scope);
  496. }
  497. run() {
  498. if (!this.active) {
  499. return this.fn();
  500. }
  501. let parent = activeEffect;
  502. let lastShouldTrack = shouldTrack;
  503. while (parent) {
  504. if (parent === this) {
  505. return;
  506. }
  507. parent = parent.parent;
  508. }
  509. try {
  510. this.parent = activeEffect;
  511. activeEffect = this;
  512. shouldTrack = true;
  513. trackOpBit = 1 << ++effectTrackDepth;
  514. if (effectTrackDepth <= maxMarkerBits) {
  515. initDepMarkers(this);
  516. }
  517. else {
  518. cleanupEffect(this);
  519. }
  520. return this.fn();
  521. }
  522. finally {
  523. if (effectTrackDepth <= maxMarkerBits) {
  524. finalizeDepMarkers(this);
  525. }
  526. trackOpBit = 1 << --effectTrackDepth;
  527. activeEffect = this.parent;
  528. shouldTrack = lastShouldTrack;
  529. this.parent = undefined;
  530. if (this.deferStop) {
  531. this.stop();
  532. }
  533. }
  534. }
  535. stop() {
  536. // stopped while running itself - defer the cleanup
  537. if (activeEffect === this) {
  538. this.deferStop = true;
  539. }
  540. else if (this.active) {
  541. cleanupEffect(this);
  542. if (this.onStop) {
  543. this.onStop();
  544. }
  545. this.active = false;
  546. }
  547. }
  548. }
  549. function cleanupEffect(effect) {
  550. const { deps } = effect;
  551. if (deps.length) {
  552. for (let i = 0; i < deps.length; i++) {
  553. deps[i].delete(effect);
  554. }
  555. deps.length = 0;
  556. }
  557. }
  558. function effect(fn, options) {
  559. if (fn.effect) {
  560. fn = fn.effect.fn;
  561. }
  562. const _effect = new ReactiveEffect(fn);
  563. if (options) {
  564. extend(_effect, options);
  565. if (options.scope)
  566. recordEffectScope(_effect, options.scope);
  567. }
  568. if (!options || !options.lazy) {
  569. _effect.run();
  570. }
  571. const runner = _effect.run.bind(_effect);
  572. runner.effect = _effect;
  573. return runner;
  574. }
  575. function stop(runner) {
  576. runner.effect.stop();
  577. }
  578. let shouldTrack = true;
  579. const trackStack = [];
  580. function pauseTracking() {
  581. trackStack.push(shouldTrack);
  582. shouldTrack = false;
  583. }
  584. function resetTracking() {
  585. const last = trackStack.pop();
  586. shouldTrack = last === undefined ? true : last;
  587. }
  588. function track(target, type, key) {
  589. if (shouldTrack && activeEffect) {
  590. let depsMap = targetMap.get(target);
  591. if (!depsMap) {
  592. targetMap.set(target, (depsMap = new Map()));
  593. }
  594. let dep = depsMap.get(key);
  595. if (!dep) {
  596. depsMap.set(key, (dep = createDep()));
  597. }
  598. const eventInfo = { effect: activeEffect, target, type, key }
  599. ;
  600. trackEffects(dep, eventInfo);
  601. }
  602. }
  603. function trackEffects(dep, debuggerEventExtraInfo) {
  604. let shouldTrack = false;
  605. if (effectTrackDepth <= maxMarkerBits) {
  606. if (!newTracked(dep)) {
  607. dep.n |= trackOpBit; // set newly tracked
  608. shouldTrack = !wasTracked(dep);
  609. }
  610. }
  611. else {
  612. // Full cleanup mode.
  613. shouldTrack = !dep.has(activeEffect);
  614. }
  615. if (shouldTrack) {
  616. dep.add(activeEffect);
  617. activeEffect.deps.push(dep);
  618. if (activeEffect.onTrack) {
  619. activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
  620. }
  621. }
  622. }
  623. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  624. const depsMap = targetMap.get(target);
  625. if (!depsMap) {
  626. // never been tracked
  627. return;
  628. }
  629. let deps = [];
  630. if (type === "clear" /* CLEAR */) {
  631. // collection being cleared
  632. // trigger all effects for target
  633. deps = [...depsMap.values()];
  634. }
  635. else if (key === 'length' && isArray(target)) {
  636. depsMap.forEach((dep, key) => {
  637. if (key === 'length' || key >= newValue) {
  638. deps.push(dep);
  639. }
  640. });
  641. }
  642. else {
  643. // schedule runs for SET | ADD | DELETE
  644. if (key !== void 0) {
  645. deps.push(depsMap.get(key));
  646. }
  647. // also run for iteration key on ADD | DELETE | Map.SET
  648. switch (type) {
  649. case "add" /* ADD */:
  650. if (!isArray(target)) {
  651. deps.push(depsMap.get(ITERATE_KEY));
  652. if (isMap(target)) {
  653. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  654. }
  655. }
  656. else if (isIntegerKey(key)) {
  657. // new index added to array -> length changes
  658. deps.push(depsMap.get('length'));
  659. }
  660. break;
  661. case "delete" /* DELETE */:
  662. if (!isArray(target)) {
  663. deps.push(depsMap.get(ITERATE_KEY));
  664. if (isMap(target)) {
  665. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  666. }
  667. }
  668. break;
  669. case "set" /* SET */:
  670. if (isMap(target)) {
  671. deps.push(depsMap.get(ITERATE_KEY));
  672. }
  673. break;
  674. }
  675. }
  676. const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
  677. ;
  678. if (deps.length === 1) {
  679. if (deps[0]) {
  680. {
  681. triggerEffects(deps[0], eventInfo);
  682. }
  683. }
  684. }
  685. else {
  686. const effects = [];
  687. for (const dep of deps) {
  688. if (dep) {
  689. effects.push(...dep);
  690. }
  691. }
  692. {
  693. triggerEffects(createDep(effects), eventInfo);
  694. }
  695. }
  696. }
  697. function triggerEffects(dep, debuggerEventExtraInfo) {
  698. // spread into array for stabilization
  699. const effects = isArray(dep) ? dep : [...dep];
  700. for (const effect of effects) {
  701. if (effect.computed) {
  702. triggerEffect(effect, debuggerEventExtraInfo);
  703. }
  704. }
  705. for (const effect of effects) {
  706. if (!effect.computed) {
  707. triggerEffect(effect, debuggerEventExtraInfo);
  708. }
  709. }
  710. }
  711. function triggerEffect(effect, debuggerEventExtraInfo) {
  712. if (effect !== activeEffect || effect.allowRecurse) {
  713. if (effect.onTrigger) {
  714. effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
  715. }
  716. if (effect.scheduler) {
  717. effect.scheduler();
  718. }
  719. else {
  720. effect.run();
  721. }
  722. }
  723. }
  724. const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
  725. const builtInSymbols = new Set(
  726. /*#__PURE__*/
  727. Object.getOwnPropertyNames(Symbol)
  728. // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
  729. // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
  730. // function
  731. .filter(key => key !== 'arguments' && key !== 'caller')
  732. .map(key => Symbol[key])
  733. .filter(isSymbol));
  734. const get = /*#__PURE__*/ createGetter();
  735. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  736. const readonlyGet = /*#__PURE__*/ createGetter(true);
  737. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  738. const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
  739. function createArrayInstrumentations() {
  740. const instrumentations = {};
  741. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  742. instrumentations[key] = function (...args) {
  743. const arr = toRaw(this);
  744. for (let i = 0, l = this.length; i < l; i++) {
  745. track(arr, "get" /* GET */, i + '');
  746. }
  747. // we run the method using the original args first (which may be reactive)
  748. const res = arr[key](...args);
  749. if (res === -1 || res === false) {
  750. // if that didn't work, run it again using raw values.
  751. return arr[key](...args.map(toRaw));
  752. }
  753. else {
  754. return res;
  755. }
  756. };
  757. });
  758. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  759. instrumentations[key] = function (...args) {
  760. pauseTracking();
  761. const res = toRaw(this)[key].apply(this, args);
  762. resetTracking();
  763. return res;
  764. };
  765. });
  766. return instrumentations;
  767. }
  768. function createGetter(isReadonly = false, shallow = false) {
  769. return function get(target, key, receiver) {
  770. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  771. return !isReadonly;
  772. }
  773. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  774. return isReadonly;
  775. }
  776. else if (key === "__v_isShallow" /* IS_SHALLOW */) {
  777. return shallow;
  778. }
  779. else if (key === "__v_raw" /* RAW */ &&
  780. receiver ===
  781. (isReadonly
  782. ? shallow
  783. ? shallowReadonlyMap
  784. : readonlyMap
  785. : shallow
  786. ? shallowReactiveMap
  787. : reactiveMap).get(target)) {
  788. return target;
  789. }
  790. const targetIsArray = isArray(target);
  791. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  792. return Reflect.get(arrayInstrumentations, key, receiver);
  793. }
  794. const res = Reflect.get(target, key, receiver);
  795. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  796. return res;
  797. }
  798. if (!isReadonly) {
  799. track(target, "get" /* GET */, key);
  800. }
  801. if (shallow) {
  802. return res;
  803. }
  804. if (isRef(res)) {
  805. // ref unwrapping - skip unwrap for Array + integer key.
  806. return targetIsArray && isIntegerKey(key) ? res : res.value;
  807. }
  808. if (isObject(res)) {
  809. // Convert returned value into a proxy as well. we do the isObject check
  810. // here to avoid invalid value warning. Also need to lazy access readonly
  811. // and reactive here to avoid circular dependency.
  812. return isReadonly ? readonly(res) : reactive(res);
  813. }
  814. return res;
  815. };
  816. }
  817. const set = /*#__PURE__*/ createSetter();
  818. const shallowSet = /*#__PURE__*/ createSetter(true);
  819. function createSetter(shallow = false) {
  820. return function set(target, key, value, receiver) {
  821. let oldValue = target[key];
  822. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  823. return false;
  824. }
  825. if (!shallow && !isReadonly(value)) {
  826. if (!isShallow(value)) {
  827. value = toRaw(value);
  828. oldValue = toRaw(oldValue);
  829. }
  830. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  831. oldValue.value = value;
  832. return true;
  833. }
  834. }
  835. const hadKey = isArray(target) && isIntegerKey(key)
  836. ? Number(key) < target.length
  837. : hasOwn(target, key);
  838. const result = Reflect.set(target, key, value, receiver);
  839. // don't trigger if target is something up in the prototype chain of original
  840. if (target === toRaw(receiver)) {
  841. if (!hadKey) {
  842. trigger(target, "add" /* ADD */, key, value);
  843. }
  844. else if (hasChanged(value, oldValue)) {
  845. trigger(target, "set" /* SET */, key, value, oldValue);
  846. }
  847. }
  848. return result;
  849. };
  850. }
  851. function deleteProperty(target, key) {
  852. const hadKey = hasOwn(target, key);
  853. const oldValue = target[key];
  854. const result = Reflect.deleteProperty(target, key);
  855. if (result && hadKey) {
  856. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  857. }
  858. return result;
  859. }
  860. function has(target, key) {
  861. const result = Reflect.has(target, key);
  862. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  863. track(target, "has" /* HAS */, key);
  864. }
  865. return result;
  866. }
  867. function ownKeys(target) {
  868. track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
  869. return Reflect.ownKeys(target);
  870. }
  871. const mutableHandlers = {
  872. get,
  873. set,
  874. deleteProperty,
  875. has,
  876. ownKeys
  877. };
  878. const readonlyHandlers = {
  879. get: readonlyGet,
  880. set(target, key) {
  881. {
  882. warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  883. }
  884. return true;
  885. },
  886. deleteProperty(target, key) {
  887. {
  888. warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  889. }
  890. return true;
  891. }
  892. };
  893. const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
  894. get: shallowGet,
  895. set: shallowSet
  896. });
  897. // Props handlers are special in the sense that it should not unwrap top-level
  898. // refs (in order to allow refs to be explicitly passed down), but should
  899. // retain the reactivity of the normal readonly object.
  900. const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
  901. get: shallowReadonlyGet
  902. });
  903. const toShallow = (value) => value;
  904. const getProto = (v) => Reflect.getPrototypeOf(v);
  905. function get$1(target, key, isReadonly = false, isShallow = false) {
  906. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  907. // of the value
  908. target = target["__v_raw" /* RAW */];
  909. const rawTarget = toRaw(target);
  910. const rawKey = toRaw(key);
  911. if (!isReadonly) {
  912. if (key !== rawKey) {
  913. track(rawTarget, "get" /* GET */, key);
  914. }
  915. track(rawTarget, "get" /* GET */, rawKey);
  916. }
  917. const { has } = getProto(rawTarget);
  918. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  919. if (has.call(rawTarget, key)) {
  920. return wrap(target.get(key));
  921. }
  922. else if (has.call(rawTarget, rawKey)) {
  923. return wrap(target.get(rawKey));
  924. }
  925. else if (target !== rawTarget) {
  926. // #3602 readonly(reactive(Map))
  927. // ensure that the nested reactive `Map` can do tracking for itself
  928. target.get(key);
  929. }
  930. }
  931. function has$1(key, isReadonly = false) {
  932. const target = this["__v_raw" /* RAW */];
  933. const rawTarget = toRaw(target);
  934. const rawKey = toRaw(key);
  935. if (!isReadonly) {
  936. if (key !== rawKey) {
  937. track(rawTarget, "has" /* HAS */, key);
  938. }
  939. track(rawTarget, "has" /* HAS */, rawKey);
  940. }
  941. return key === rawKey
  942. ? target.has(key)
  943. : target.has(key) || target.has(rawKey);
  944. }
  945. function size(target, isReadonly = false) {
  946. target = target["__v_raw" /* RAW */];
  947. !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
  948. return Reflect.get(target, 'size', target);
  949. }
  950. function add(value) {
  951. value = toRaw(value);
  952. const target = toRaw(this);
  953. const proto = getProto(target);
  954. const hadKey = proto.has.call(target, value);
  955. if (!hadKey) {
  956. target.add(value);
  957. trigger(target, "add" /* ADD */, value, value);
  958. }
  959. return this;
  960. }
  961. function set$1(key, value) {
  962. value = toRaw(value);
  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.call(target, key);
  974. target.set(key, value);
  975. if (!hadKey) {
  976. trigger(target, "add" /* ADD */, key, value);
  977. }
  978. else if (hasChanged(value, oldValue)) {
  979. trigger(target, "set" /* SET */, key, value, oldValue);
  980. }
  981. return this;
  982. }
  983. function deleteEntry(key) {
  984. const target = toRaw(this);
  985. const { has, get } = getProto(target);
  986. let hadKey = has.call(target, key);
  987. if (!hadKey) {
  988. key = toRaw(key);
  989. hadKey = has.call(target, key);
  990. }
  991. else {
  992. checkIdentityKeys(target, has, key);
  993. }
  994. const oldValue = get ? get.call(target, key) : undefined;
  995. // forward the operation before queueing reactions
  996. const result = target.delete(key);
  997. if (hadKey) {
  998. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  999. }
  1000. return result;
  1001. }
  1002. function clear() {
  1003. const target = toRaw(this);
  1004. const hadItems = target.size !== 0;
  1005. const oldTarget = isMap(target)
  1006. ? new Map(target)
  1007. : new Set(target)
  1008. ;
  1009. // forward the operation before queueing reactions
  1010. const result = target.clear();
  1011. if (hadItems) {
  1012. trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
  1013. }
  1014. return result;
  1015. }
  1016. function createForEach(isReadonly, isShallow) {
  1017. return function forEach(callback, thisArg) {
  1018. const observed = this;
  1019. const target = observed["__v_raw" /* RAW */];
  1020. const rawTarget = toRaw(target);
  1021. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1022. !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
  1023. return target.forEach((value, key) => {
  1024. // important: make sure the callback is
  1025. // 1. invoked with the reactive map as `this` and 3rd arg
  1026. // 2. the value received should be a corresponding reactive/readonly.
  1027. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1028. });
  1029. };
  1030. }
  1031. function createIterableMethod(method, isReadonly, isShallow) {
  1032. return function (...args) {
  1033. const target = this["__v_raw" /* RAW */];
  1034. const rawTarget = toRaw(target);
  1035. const targetIsMap = isMap(rawTarget);
  1036. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  1037. const isKeyOnly = method === 'keys' && targetIsMap;
  1038. const innerIterator = target[method](...args);
  1039. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1040. !isReadonly &&
  1041. track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  1042. // return a wrapped iterator which returns observed versions of the
  1043. // values emitted from the real iterator
  1044. return {
  1045. // iterator protocol
  1046. next() {
  1047. const { value, done } = innerIterator.next();
  1048. return done
  1049. ? { value, done }
  1050. : {
  1051. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1052. done
  1053. };
  1054. },
  1055. // iterable protocol
  1056. [Symbol.iterator]() {
  1057. return this;
  1058. }
  1059. };
  1060. };
  1061. }
  1062. function createReadonlyMethod(type) {
  1063. return function (...args) {
  1064. {
  1065. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1066. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1067. }
  1068. return type === "delete" /* DELETE */ ? false : this;
  1069. };
  1070. }
  1071. function createInstrumentations() {
  1072. const mutableInstrumentations = {
  1073. get(key) {
  1074. return get$1(this, key);
  1075. },
  1076. get size() {
  1077. return size(this);
  1078. },
  1079. has: has$1,
  1080. add,
  1081. set: set$1,
  1082. delete: deleteEntry,
  1083. clear,
  1084. forEach: createForEach(false, false)
  1085. };
  1086. const shallowInstrumentations = {
  1087. get(key) {
  1088. return get$1(this, key, false, true);
  1089. },
  1090. get size() {
  1091. return size(this);
  1092. },
  1093. has: has$1,
  1094. add,
  1095. set: set$1,
  1096. delete: deleteEntry,
  1097. clear,
  1098. forEach: createForEach(false, true)
  1099. };
  1100. const readonlyInstrumentations = {
  1101. get(key) {
  1102. return get$1(this, key, true);
  1103. },
  1104. get size() {
  1105. return size(this, true);
  1106. },
  1107. has(key) {
  1108. return has$1.call(this, key, true);
  1109. },
  1110. add: createReadonlyMethod("add" /* ADD */),
  1111. set: createReadonlyMethod("set" /* SET */),
  1112. delete: createReadonlyMethod("delete" /* DELETE */),
  1113. clear: createReadonlyMethod("clear" /* CLEAR */),
  1114. forEach: createForEach(true, false)
  1115. };
  1116. const shallowReadonlyInstrumentations = {
  1117. get(key) {
  1118. return get$1(this, key, true, true);
  1119. },
  1120. get size() {
  1121. return size(this, true);
  1122. },
  1123. has(key) {
  1124. return has$1.call(this, key, true);
  1125. },
  1126. add: createReadonlyMethod("add" /* ADD */),
  1127. set: createReadonlyMethod("set" /* SET */),
  1128. delete: createReadonlyMethod("delete" /* DELETE */),
  1129. clear: createReadonlyMethod("clear" /* CLEAR */),
  1130. forEach: createForEach(true, true)
  1131. };
  1132. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  1133. iteratorMethods.forEach(method => {
  1134. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  1135. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  1136. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  1137. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  1138. });
  1139. return [
  1140. mutableInstrumentations,
  1141. readonlyInstrumentations,
  1142. shallowInstrumentations,
  1143. shallowReadonlyInstrumentations
  1144. ];
  1145. }
  1146. const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
  1147. function createInstrumentationGetter(isReadonly, shallow) {
  1148. const instrumentations = shallow
  1149. ? isReadonly
  1150. ? shallowReadonlyInstrumentations
  1151. : shallowInstrumentations
  1152. : isReadonly
  1153. ? readonlyInstrumentations
  1154. : mutableInstrumentations;
  1155. return (target, key, receiver) => {
  1156. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  1157. return !isReadonly;
  1158. }
  1159. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  1160. return isReadonly;
  1161. }
  1162. else if (key === "__v_raw" /* RAW */) {
  1163. return target;
  1164. }
  1165. return Reflect.get(hasOwn(instrumentations, key) && key in target
  1166. ? instrumentations
  1167. : target, key, receiver);
  1168. };
  1169. }
  1170. const mutableCollectionHandlers = {
  1171. get: /*#__PURE__*/ createInstrumentationGetter(false, false)
  1172. };
  1173. const shallowCollectionHandlers = {
  1174. get: /*#__PURE__*/ createInstrumentationGetter(false, true)
  1175. };
  1176. const readonlyCollectionHandlers = {
  1177. get: /*#__PURE__*/ createInstrumentationGetter(true, false)
  1178. };
  1179. const shallowReadonlyCollectionHandlers = {
  1180. get: /*#__PURE__*/ createInstrumentationGetter(true, true)
  1181. };
  1182. function checkIdentityKeys(target, has, key) {
  1183. const rawKey = toRaw(key);
  1184. if (rawKey !== key && has.call(target, rawKey)) {
  1185. const type = toRawType(target);
  1186. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  1187. `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
  1188. `which can lead to inconsistencies. ` +
  1189. `Avoid differentiating between the raw and reactive versions ` +
  1190. `of an object and only use the reactive version if possible.`);
  1191. }
  1192. }
  1193. const reactiveMap = new WeakMap();
  1194. const shallowReactiveMap = new WeakMap();
  1195. const readonlyMap = new WeakMap();
  1196. const shallowReadonlyMap = new WeakMap();
  1197. function targetTypeMap(rawType) {
  1198. switch (rawType) {
  1199. case 'Object':
  1200. case 'Array':
  1201. return 1 /* COMMON */;
  1202. case 'Map':
  1203. case 'Set':
  1204. case 'WeakMap':
  1205. case 'WeakSet':
  1206. return 2 /* COLLECTION */;
  1207. default:
  1208. return 0 /* INVALID */;
  1209. }
  1210. }
  1211. function getTargetType(value) {
  1212. return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
  1213. ? 0 /* INVALID */
  1214. : targetTypeMap(toRawType(value));
  1215. }
  1216. function reactive(target) {
  1217. // if trying to observe a readonly proxy, return the readonly version.
  1218. if (isReadonly(target)) {
  1219. return target;
  1220. }
  1221. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  1222. }
  1223. /**
  1224. * Return a shallowly-reactive copy of the original object, where only the root
  1225. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1226. * root level).
  1227. */
  1228. function shallowReactive(target) {
  1229. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
  1230. }
  1231. /**
  1232. * Creates a readonly copy of the original object. Note the returned copy is not
  1233. * made reactive, but `readonly` can be called on an already reactive object.
  1234. */
  1235. function readonly(target) {
  1236. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  1237. }
  1238. /**
  1239. * Returns a reactive-copy of the original object, where only the root level
  1240. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1241. * returned properties.
  1242. * This is used for creating the props proxy object for stateful components.
  1243. */
  1244. function shallowReadonly(target) {
  1245. return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  1246. }
  1247. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  1248. if (!isObject(target)) {
  1249. {
  1250. console.warn(`value cannot be made reactive: ${String(target)}`);
  1251. }
  1252. return target;
  1253. }
  1254. // target is already a Proxy, return it.
  1255. // exception: calling readonly() on a reactive object
  1256. if (target["__v_raw" /* RAW */] &&
  1257. !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
  1258. return target;
  1259. }
  1260. // target already has corresponding Proxy
  1261. const existingProxy = proxyMap.get(target);
  1262. if (existingProxy) {
  1263. return existingProxy;
  1264. }
  1265. // only specific value types can be observed.
  1266. const targetType = getTargetType(target);
  1267. if (targetType === 0 /* INVALID */) {
  1268. return target;
  1269. }
  1270. const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
  1271. proxyMap.set(target, proxy);
  1272. return proxy;
  1273. }
  1274. function isReactive(value) {
  1275. if (isReadonly(value)) {
  1276. return isReactive(value["__v_raw" /* RAW */]);
  1277. }
  1278. return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
  1279. }
  1280. function isReadonly(value) {
  1281. return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
  1282. }
  1283. function isShallow(value) {
  1284. return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
  1285. }
  1286. function isProxy(value) {
  1287. return isReactive(value) || isReadonly(value);
  1288. }
  1289. function toRaw(observed) {
  1290. const raw = observed && observed["__v_raw" /* RAW */];
  1291. return raw ? toRaw(raw) : observed;
  1292. }
  1293. function markRaw(value) {
  1294. def(value, "__v_skip" /* SKIP */, true);
  1295. return value;
  1296. }
  1297. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1298. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1299. function trackRefValue(ref) {
  1300. if (shouldTrack && activeEffect) {
  1301. ref = toRaw(ref);
  1302. {
  1303. trackEffects(ref.dep || (ref.dep = createDep()), {
  1304. target: ref,
  1305. type: "get" /* GET */,
  1306. key: 'value'
  1307. });
  1308. }
  1309. }
  1310. }
  1311. function triggerRefValue(ref, newVal) {
  1312. ref = toRaw(ref);
  1313. if (ref.dep) {
  1314. {
  1315. triggerEffects(ref.dep, {
  1316. target: ref,
  1317. type: "set" /* SET */,
  1318. key: 'value',
  1319. newValue: newVal
  1320. });
  1321. }
  1322. }
  1323. }
  1324. function isRef(r) {
  1325. return !!(r && r.__v_isRef === true);
  1326. }
  1327. function ref(value) {
  1328. return createRef(value, false);
  1329. }
  1330. function shallowRef(value) {
  1331. return createRef(value, true);
  1332. }
  1333. function createRef(rawValue, shallow) {
  1334. if (isRef(rawValue)) {
  1335. return rawValue;
  1336. }
  1337. return new RefImpl(rawValue, shallow);
  1338. }
  1339. class RefImpl {
  1340. constructor(value, __v_isShallow) {
  1341. this.__v_isShallow = __v_isShallow;
  1342. this.dep = undefined;
  1343. this.__v_isRef = true;
  1344. this._rawValue = __v_isShallow ? value : toRaw(value);
  1345. this._value = __v_isShallow ? value : toReactive(value);
  1346. }
  1347. get value() {
  1348. trackRefValue(this);
  1349. return this._value;
  1350. }
  1351. set value(newVal) {
  1352. newVal = this.__v_isShallow ? newVal : toRaw(newVal);
  1353. if (hasChanged(newVal, this._rawValue)) {
  1354. this._rawValue = newVal;
  1355. this._value = this.__v_isShallow ? newVal : toReactive(newVal);
  1356. triggerRefValue(this, newVal);
  1357. }
  1358. }
  1359. }
  1360. function triggerRef(ref) {
  1361. triggerRefValue(ref, ref.value );
  1362. }
  1363. function unref(ref) {
  1364. return isRef(ref) ? ref.value : ref;
  1365. }
  1366. const shallowUnwrapHandlers = {
  1367. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1368. set: (target, key, value, receiver) => {
  1369. const oldValue = target[key];
  1370. if (isRef(oldValue) && !isRef(value)) {
  1371. oldValue.value = value;
  1372. return true;
  1373. }
  1374. else {
  1375. return Reflect.set(target, key, value, receiver);
  1376. }
  1377. }
  1378. };
  1379. function proxyRefs(objectWithRefs) {
  1380. return isReactive(objectWithRefs)
  1381. ? objectWithRefs
  1382. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1383. }
  1384. class CustomRefImpl {
  1385. constructor(factory) {
  1386. this.dep = undefined;
  1387. this.__v_isRef = true;
  1388. const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
  1389. this._get = get;
  1390. this._set = set;
  1391. }
  1392. get value() {
  1393. return this._get();
  1394. }
  1395. set value(newVal) {
  1396. this._set(newVal);
  1397. }
  1398. }
  1399. function customRef(factory) {
  1400. return new CustomRefImpl(factory);
  1401. }
  1402. function toRefs(object) {
  1403. if (!isProxy(object)) {
  1404. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1405. }
  1406. const ret = isArray(object) ? new Array(object.length) : {};
  1407. for (const key in object) {
  1408. ret[key] = toRef(object, key);
  1409. }
  1410. return ret;
  1411. }
  1412. class ObjectRefImpl {
  1413. constructor(_object, _key, _defaultValue) {
  1414. this._object = _object;
  1415. this._key = _key;
  1416. this._defaultValue = _defaultValue;
  1417. this.__v_isRef = true;
  1418. }
  1419. get value() {
  1420. const val = this._object[this._key];
  1421. return val === undefined ? this._defaultValue : val;
  1422. }
  1423. set value(newVal) {
  1424. this._object[this._key] = newVal;
  1425. }
  1426. }
  1427. function toRef(object, key, defaultValue) {
  1428. const val = object[key];
  1429. return isRef(val)
  1430. ? val
  1431. : new ObjectRefImpl(object, key, defaultValue);
  1432. }
  1433. class ComputedRefImpl {
  1434. constructor(getter, _setter, isReadonly, isSSR) {
  1435. this._setter = _setter;
  1436. this.dep = undefined;
  1437. this.__v_isRef = true;
  1438. this._dirty = true;
  1439. this.effect = new ReactiveEffect(getter, () => {
  1440. if (!this._dirty) {
  1441. this._dirty = true;
  1442. triggerRefValue(this);
  1443. }
  1444. });
  1445. this.effect.computed = this;
  1446. this.effect.active = this._cacheable = !isSSR;
  1447. this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
  1448. }
  1449. get value() {
  1450. // the computed ref may get wrapped by other proxies e.g. readonly() #3376
  1451. const self = toRaw(this);
  1452. trackRefValue(self);
  1453. if (self._dirty || !self._cacheable) {
  1454. self._dirty = false;
  1455. self._value = self.effect.run();
  1456. }
  1457. return self._value;
  1458. }
  1459. set value(newValue) {
  1460. this._setter(newValue);
  1461. }
  1462. }
  1463. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1464. let getter;
  1465. let setter;
  1466. const onlyGetter = isFunction(getterOrOptions);
  1467. if (onlyGetter) {
  1468. getter = getterOrOptions;
  1469. setter = () => {
  1470. console.warn('Write operation failed: computed value is readonly');
  1471. }
  1472. ;
  1473. }
  1474. else {
  1475. getter = getterOrOptions.get;
  1476. setter = getterOrOptions.set;
  1477. }
  1478. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1479. if (debugOptions && !isSSR) {
  1480. cRef.effect.onTrack = debugOptions.onTrack;
  1481. cRef.effect.onTrigger = debugOptions.onTrigger;
  1482. }
  1483. return cRef;
  1484. }
  1485. const stack = [];
  1486. function pushWarningContext(vnode) {
  1487. stack.push(vnode);
  1488. }
  1489. function popWarningContext() {
  1490. stack.pop();
  1491. }
  1492. function warn$1(msg, ...args) {
  1493. // avoid props formatting or warn handler tracking deps that might be mutated
  1494. // during patch, leading to infinite recursion.
  1495. pauseTracking();
  1496. const instance = stack.length ? stack[stack.length - 1].component : null;
  1497. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1498. const trace = getComponentTrace();
  1499. if (appWarnHandler) {
  1500. callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
  1501. msg + args.join(''),
  1502. instance && instance.proxy,
  1503. trace
  1504. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  1505. .join('\n'),
  1506. trace
  1507. ]);
  1508. }
  1509. else {
  1510. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1511. /* istanbul ignore if */
  1512. if (trace.length &&
  1513. // avoid spamming console during tests
  1514. !false) {
  1515. warnArgs.push(`\n`, ...formatTrace(trace));
  1516. }
  1517. console.warn(...warnArgs);
  1518. }
  1519. resetTracking();
  1520. }
  1521. function getComponentTrace() {
  1522. let currentVNode = stack[stack.length - 1];
  1523. if (!currentVNode) {
  1524. return [];
  1525. }
  1526. // we can't just use the stack because it will be incomplete during updates
  1527. // that did not start from the root. Re-construct the parent chain using
  1528. // instance parent pointers.
  1529. const normalizedStack = [];
  1530. while (currentVNode) {
  1531. const last = normalizedStack[0];
  1532. if (last && last.vnode === currentVNode) {
  1533. last.recurseCount++;
  1534. }
  1535. else {
  1536. normalizedStack.push({
  1537. vnode: currentVNode,
  1538. recurseCount: 0
  1539. });
  1540. }
  1541. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1542. currentVNode = parentInstance && parentInstance.vnode;
  1543. }
  1544. return normalizedStack;
  1545. }
  1546. /* istanbul ignore next */
  1547. function formatTrace(trace) {
  1548. const logs = [];
  1549. trace.forEach((entry, i) => {
  1550. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  1551. });
  1552. return logs;
  1553. }
  1554. function formatTraceEntry({ vnode, recurseCount }) {
  1555. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1556. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1557. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  1558. const close = `>` + postfix;
  1559. return vnode.props
  1560. ? [open, ...formatProps(vnode.props), close]
  1561. : [open + close];
  1562. }
  1563. /* istanbul ignore next */
  1564. function formatProps(props) {
  1565. const res = [];
  1566. const keys = Object.keys(props);
  1567. keys.slice(0, 3).forEach(key => {
  1568. res.push(...formatProp(key, props[key]));
  1569. });
  1570. if (keys.length > 3) {
  1571. res.push(` ...`);
  1572. }
  1573. return res;
  1574. }
  1575. /* istanbul ignore next */
  1576. function formatProp(key, value, raw) {
  1577. if (isString(value)) {
  1578. value = JSON.stringify(value);
  1579. return raw ? value : [`${key}=${value}`];
  1580. }
  1581. else if (typeof value === 'number' ||
  1582. typeof value === 'boolean' ||
  1583. value == null) {
  1584. return raw ? value : [`${key}=${value}`];
  1585. }
  1586. else if (isRef(value)) {
  1587. value = formatProp(key, toRaw(value.value), true);
  1588. return raw ? value : [`${key}=Ref<`, value, `>`];
  1589. }
  1590. else if (isFunction(value)) {
  1591. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1592. }
  1593. else {
  1594. value = toRaw(value);
  1595. return raw ? value : [`${key}=`, value];
  1596. }
  1597. }
  1598. const ErrorTypeStrings = {
  1599. ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
  1600. ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
  1601. ["c" /* CREATED */]: 'created hook',
  1602. ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
  1603. ["m" /* MOUNTED */]: 'mounted hook',
  1604. ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
  1605. ["u" /* UPDATED */]: 'updated',
  1606. ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  1607. ["um" /* UNMOUNTED */]: 'unmounted hook',
  1608. ["a" /* ACTIVATED */]: 'activated hook',
  1609. ["da" /* DEACTIVATED */]: 'deactivated hook',
  1610. ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
  1611. ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
  1612. ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
  1613. [0 /* SETUP_FUNCTION */]: 'setup function',
  1614. [1 /* RENDER_FUNCTION */]: 'render function',
  1615. [2 /* WATCH_GETTER */]: 'watcher getter',
  1616. [3 /* WATCH_CALLBACK */]: 'watcher callback',
  1617. [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
  1618. [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
  1619. [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
  1620. [7 /* VNODE_HOOK */]: 'vnode hook',
  1621. [8 /* DIRECTIVE_HOOK */]: 'directive hook',
  1622. [9 /* TRANSITION_HOOK */]: 'transition hook',
  1623. [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
  1624. [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
  1625. [12 /* FUNCTION_REF */]: 'ref function',
  1626. [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
  1627. [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  1628. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
  1629. };
  1630. function callWithErrorHandling(fn, instance, type, args) {
  1631. let res;
  1632. try {
  1633. res = args ? fn(...args) : fn();
  1634. }
  1635. catch (err) {
  1636. handleError(err, instance, type);
  1637. }
  1638. return res;
  1639. }
  1640. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1641. if (isFunction(fn)) {
  1642. const res = callWithErrorHandling(fn, instance, type, args);
  1643. if (res && isPromise(res)) {
  1644. res.catch(err => {
  1645. handleError(err, instance, type);
  1646. });
  1647. }
  1648. return res;
  1649. }
  1650. const values = [];
  1651. for (let i = 0; i < fn.length; i++) {
  1652. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1653. }
  1654. return values;
  1655. }
  1656. function handleError(err, instance, type, throwInDev = true) {
  1657. const contextVNode = instance ? instance.vnode : null;
  1658. if (instance) {
  1659. let cur = instance.parent;
  1660. // the exposed instance is the render proxy to keep it consistent with 2.x
  1661. const exposedInstance = instance.proxy;
  1662. // in production the hook receives only the error code
  1663. const errorInfo = ErrorTypeStrings[type] ;
  1664. while (cur) {
  1665. const errorCapturedHooks = cur.ec;
  1666. if (errorCapturedHooks) {
  1667. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1668. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1669. return;
  1670. }
  1671. }
  1672. }
  1673. cur = cur.parent;
  1674. }
  1675. // app-level handling
  1676. const appErrorHandler = instance.appContext.config.errorHandler;
  1677. if (appErrorHandler) {
  1678. callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  1679. return;
  1680. }
  1681. }
  1682. logError(err, type, contextVNode, throwInDev);
  1683. }
  1684. function logError(err, type, contextVNode, throwInDev = true) {
  1685. {
  1686. const info = ErrorTypeStrings[type];
  1687. if (contextVNode) {
  1688. pushWarningContext(contextVNode);
  1689. }
  1690. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1691. if (contextVNode) {
  1692. popWarningContext();
  1693. }
  1694. // crash in dev by default so it's more noticeable
  1695. if (throwInDev) {
  1696. throw err;
  1697. }
  1698. else {
  1699. console.error(err);
  1700. }
  1701. }
  1702. }
  1703. let isFlushing = false;
  1704. let isFlushPending = false;
  1705. const queue = [];
  1706. let flushIndex = 0;
  1707. const pendingPreFlushCbs = [];
  1708. let activePreFlushCbs = null;
  1709. let preFlushIndex = 0;
  1710. const pendingPostFlushCbs = [];
  1711. let activePostFlushCbs = null;
  1712. let postFlushIndex = 0;
  1713. const resolvedPromise = /*#__PURE__*/ Promise.resolve();
  1714. let currentFlushPromise = null;
  1715. let currentPreFlushParentJob = null;
  1716. const RECURSION_LIMIT = 100;
  1717. function nextTick(fn) {
  1718. const p = currentFlushPromise || resolvedPromise;
  1719. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1720. }
  1721. // #2768
  1722. // Use binary-search to find a suitable position in the queue,
  1723. // so that the queue maintains the increasing order of job's id,
  1724. // which can prevent the job from being skipped and also can avoid repeated patching.
  1725. function findInsertionIndex(id) {
  1726. // the start index should be `flushIndex + 1`
  1727. let start = flushIndex + 1;
  1728. let end = queue.length;
  1729. while (start < end) {
  1730. const middle = (start + end) >>> 1;
  1731. const middleJobId = getId(queue[middle]);
  1732. middleJobId < id ? (start = middle + 1) : (end = middle);
  1733. }
  1734. return start;
  1735. }
  1736. function queueJob(job) {
  1737. // the dedupe search uses the startIndex argument of Array.includes()
  1738. // by default the search index includes the current job that is being run
  1739. // so it cannot recursively trigger itself again.
  1740. // if the job is a watch() callback, the search will start with a +1 index to
  1741. // allow it recursively trigger itself - it is the user's responsibility to
  1742. // ensure it doesn't end up in an infinite loop.
  1743. if ((!queue.length ||
  1744. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
  1745. job !== currentPreFlushParentJob) {
  1746. if (job.id == null) {
  1747. queue.push(job);
  1748. }
  1749. else {
  1750. queue.splice(findInsertionIndex(job.id), 0, job);
  1751. }
  1752. queueFlush();
  1753. }
  1754. }
  1755. function queueFlush() {
  1756. if (!isFlushing && !isFlushPending) {
  1757. isFlushPending = true;
  1758. currentFlushPromise = resolvedPromise.then(flushJobs);
  1759. }
  1760. }
  1761. function invalidateJob(job) {
  1762. const i = queue.indexOf(job);
  1763. if (i > flushIndex) {
  1764. queue.splice(i, 1);
  1765. }
  1766. }
  1767. function queueCb(cb, activeQueue, pendingQueue, index) {
  1768. if (!isArray(cb)) {
  1769. if (!activeQueue ||
  1770. !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
  1771. pendingQueue.push(cb);
  1772. }
  1773. }
  1774. else {
  1775. // if cb is an array, it is a component lifecycle hook which can only be
  1776. // triggered by a job, which is already deduped in the main queue, so
  1777. // we can skip duplicate check here to improve perf
  1778. pendingQueue.push(...cb);
  1779. }
  1780. queueFlush();
  1781. }
  1782. function queuePreFlushCb(cb) {
  1783. queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  1784. }
  1785. function queuePostFlushCb(cb) {
  1786. queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  1787. }
  1788. function flushPreFlushCbs(seen, parentJob = null) {
  1789. if (pendingPreFlushCbs.length) {
  1790. currentPreFlushParentJob = parentJob;
  1791. activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
  1792. pendingPreFlushCbs.length = 0;
  1793. {
  1794. seen = seen || new Map();
  1795. }
  1796. for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
  1797. if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
  1798. continue;
  1799. }
  1800. activePreFlushCbs[preFlushIndex]();
  1801. }
  1802. activePreFlushCbs = null;
  1803. preFlushIndex = 0;
  1804. currentPreFlushParentJob = null;
  1805. // recursively flush until it drains
  1806. flushPreFlushCbs(seen, parentJob);
  1807. }
  1808. }
  1809. function flushPostFlushCbs(seen) {
  1810. // flush any pre cbs queued during the flush (e.g. pre watchers)
  1811. flushPreFlushCbs();
  1812. if (pendingPostFlushCbs.length) {
  1813. const deduped = [...new Set(pendingPostFlushCbs)];
  1814. pendingPostFlushCbs.length = 0;
  1815. // #1947 already has active queue, nested flushPostFlushCbs call
  1816. if (activePostFlushCbs) {
  1817. activePostFlushCbs.push(...deduped);
  1818. return;
  1819. }
  1820. activePostFlushCbs = deduped;
  1821. {
  1822. seen = seen || new Map();
  1823. }
  1824. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1825. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1826. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1827. continue;
  1828. }
  1829. activePostFlushCbs[postFlushIndex]();
  1830. }
  1831. activePostFlushCbs = null;
  1832. postFlushIndex = 0;
  1833. }
  1834. }
  1835. const getId = (job) => job.id == null ? Infinity : job.id;
  1836. function flushJobs(seen) {
  1837. isFlushPending = false;
  1838. isFlushing = true;
  1839. {
  1840. seen = seen || new Map();
  1841. }
  1842. flushPreFlushCbs(seen);
  1843. // Sort queue before flush.
  1844. // This ensures that:
  1845. // 1. Components are updated from parent to child. (because parent is always
  1846. // created before the child so its render effect will have smaller
  1847. // priority number)
  1848. // 2. If a component is unmounted during a parent component's update,
  1849. // its update can be skipped.
  1850. queue.sort((a, b) => getId(a) - getId(b));
  1851. // conditional usage of checkRecursiveUpdate must be determined out of
  1852. // try ... catch block since Rollup by default de-optimizes treeshaking
  1853. // inside try-catch. This can leave all warning code unshaked. Although
  1854. // they would get eventually shaken by a minifier like terser, some minifiers
  1855. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  1856. const check = (job) => checkRecursiveUpdates(seen, job)
  1857. ;
  1858. try {
  1859. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1860. const job = queue[flushIndex];
  1861. if (job && job.active !== false) {
  1862. if (true && check(job)) {
  1863. continue;
  1864. }
  1865. // console.log(`running:`, job.id)
  1866. callWithErrorHandling(job, null, 14 /* SCHEDULER */);
  1867. }
  1868. }
  1869. }
  1870. finally {
  1871. flushIndex = 0;
  1872. queue.length = 0;
  1873. flushPostFlushCbs(seen);
  1874. isFlushing = false;
  1875. currentFlushPromise = null;
  1876. // some postFlushCb queued jobs!
  1877. // keep flushing until it drains.
  1878. if (queue.length ||
  1879. pendingPreFlushCbs.length ||
  1880. pendingPostFlushCbs.length) {
  1881. flushJobs(seen);
  1882. }
  1883. }
  1884. }
  1885. function checkRecursiveUpdates(seen, fn) {
  1886. if (!seen.has(fn)) {
  1887. seen.set(fn, 1);
  1888. }
  1889. else {
  1890. const count = seen.get(fn);
  1891. if (count > RECURSION_LIMIT) {
  1892. const instance = fn.ownerInstance;
  1893. const componentName = instance && getComponentName(instance.type);
  1894. warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
  1895. `This means you have a reactive effect that is mutating its own ` +
  1896. `dependencies and thus recursively triggering itself. Possible sources ` +
  1897. `include component template, render function, updated hook or ` +
  1898. `watcher source function.`);
  1899. return true;
  1900. }
  1901. else {
  1902. seen.set(fn, count + 1);
  1903. }
  1904. }
  1905. }
  1906. /* eslint-disable no-restricted-globals */
  1907. let isHmrUpdating = false;
  1908. const hmrDirtyComponents = new Set();
  1909. // Expose the HMR runtime on the global object
  1910. // This makes it entirely tree-shakable without polluting the exports and makes
  1911. // it easier to be used in toolings like vue-loader
  1912. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1913. // to be set so that its instances can be registered / removed.
  1914. {
  1915. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1916. createRecord: tryWrap(createRecord),
  1917. rerender: tryWrap(rerender),
  1918. reload: tryWrap(reload)
  1919. };
  1920. }
  1921. const map = new Map();
  1922. function registerHMR(instance) {
  1923. const id = instance.type.__hmrId;
  1924. let record = map.get(id);
  1925. if (!record) {
  1926. createRecord(id, instance.type);
  1927. record = map.get(id);
  1928. }
  1929. record.instances.add(instance);
  1930. }
  1931. function unregisterHMR(instance) {
  1932. map.get(instance.type.__hmrId).instances.delete(instance);
  1933. }
  1934. function createRecord(id, initialDef) {
  1935. if (map.has(id)) {
  1936. return false;
  1937. }
  1938. map.set(id, {
  1939. initialDef: normalizeClassComponent(initialDef),
  1940. instances: new Set()
  1941. });
  1942. return true;
  1943. }
  1944. function normalizeClassComponent(component) {
  1945. return isClassComponent(component) ? component.__vccOpts : component;
  1946. }
  1947. function rerender(id, newRender) {
  1948. const record = map.get(id);
  1949. if (!record) {
  1950. return;
  1951. }
  1952. // update initial record (for not-yet-rendered component)
  1953. record.initialDef.render = newRender;
  1954. [...record.instances].forEach(instance => {
  1955. if (newRender) {
  1956. instance.render = newRender;
  1957. normalizeClassComponent(instance.type).render = newRender;
  1958. }
  1959. instance.renderCache = [];
  1960. // this flag forces child components with slot content to update
  1961. isHmrUpdating = true;
  1962. instance.update();
  1963. isHmrUpdating = false;
  1964. });
  1965. }
  1966. function reload(id, newComp) {
  1967. const record = map.get(id);
  1968. if (!record)
  1969. return;
  1970. newComp = normalizeClassComponent(newComp);
  1971. // update initial def (for not-yet-rendered components)
  1972. updateComponentDef(record.initialDef, newComp);
  1973. // create a snapshot which avoids the set being mutated during updates
  1974. const instances = [...record.instances];
  1975. for (const instance of instances) {
  1976. const oldComp = normalizeClassComponent(instance.type);
  1977. if (!hmrDirtyComponents.has(oldComp)) {
  1978. // 1. Update existing comp definition to match new one
  1979. if (oldComp !== record.initialDef) {
  1980. updateComponentDef(oldComp, newComp);
  1981. }
  1982. // 2. mark definition dirty. This forces the renderer to replace the
  1983. // component on patch.
  1984. hmrDirtyComponents.add(oldComp);
  1985. }
  1986. // 3. invalidate options resolution cache
  1987. instance.appContext.optionsCache.delete(instance.type);
  1988. // 4. actually update
  1989. if (instance.ceReload) {
  1990. // custom element
  1991. hmrDirtyComponents.add(oldComp);
  1992. instance.ceReload(newComp.styles);
  1993. hmrDirtyComponents.delete(oldComp);
  1994. }
  1995. else if (instance.parent) {
  1996. // 4. Force the parent instance to re-render. This will cause all updated
  1997. // components to be unmounted and re-mounted. Queue the update so that we
  1998. // don't end up forcing the same parent to re-render multiple times.
  1999. queueJob(instance.parent.update);
  2000. // instance is the inner component of an async custom element
  2001. // invoke to reset styles
  2002. if (instance.parent.type.__asyncLoader &&
  2003. instance.parent.ceReload) {
  2004. instance.parent.ceReload(newComp.styles);
  2005. }
  2006. }
  2007. else if (instance.appContext.reload) {
  2008. // root instance mounted via createApp() has a reload method
  2009. instance.appContext.reload();
  2010. }
  2011. else if (typeof window !== 'undefined') {
  2012. // root instance inside tree created via raw render(). Force reload.
  2013. window.location.reload();
  2014. }
  2015. else {
  2016. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  2017. }
  2018. }
  2019. // 5. make sure to cleanup dirty hmr components after update
  2020. queuePostFlushCb(() => {
  2021. for (const instance of instances) {
  2022. hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
  2023. }
  2024. });
  2025. }
  2026. function updateComponentDef(oldComp, newComp) {
  2027. extend(oldComp, newComp);
  2028. for (const key in oldComp) {
  2029. if (key !== '__file' && !(key in newComp)) {
  2030. delete oldComp[key];
  2031. }
  2032. }
  2033. }
  2034. function tryWrap(fn) {
  2035. return (id, arg) => {
  2036. try {
  2037. return fn(id, arg);
  2038. }
  2039. catch (e) {
  2040. console.error(e);
  2041. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  2042. `Full reload required.`);
  2043. }
  2044. };
  2045. }
  2046. let devtools;
  2047. let buffer = [];
  2048. let devtoolsNotInstalled = false;
  2049. function emit(event, ...args) {
  2050. if (devtools) {
  2051. devtools.emit(event, ...args);
  2052. }
  2053. else if (!devtoolsNotInstalled) {
  2054. buffer.push({ event, args });
  2055. }
  2056. }
  2057. function setDevtoolsHook(hook, target) {
  2058. var _a, _b;
  2059. devtools = hook;
  2060. if (devtools) {
  2061. devtools.enabled = true;
  2062. buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
  2063. buffer = [];
  2064. }
  2065. else if (
  2066. // handle late devtools injection - only do this if we are in an actual
  2067. // browser environment to avoid the timer handle stalling test runner exit
  2068. // (#4815)
  2069. typeof window !== 'undefined' &&
  2070. // some envs mock window but not fully
  2071. window.HTMLElement &&
  2072. // also exclude jsdom
  2073. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  2074. const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
  2075. target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
  2076. replay.push((newHook) => {
  2077. setDevtoolsHook(newHook, target);
  2078. });
  2079. // clear buffer after 3s - the user probably doesn't have devtools installed
  2080. // at all, and keeping the buffer will cause memory leaks (#4738)
  2081. setTimeout(() => {
  2082. if (!devtools) {
  2083. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2084. devtoolsNotInstalled = true;
  2085. buffer = [];
  2086. }
  2087. }, 3000);
  2088. }
  2089. else {
  2090. // non-browser env, assume not installed
  2091. devtoolsNotInstalled = true;
  2092. buffer = [];
  2093. }
  2094. }
  2095. function devtoolsInitApp(app, version) {
  2096. emit("app:init" /* APP_INIT */, app, version, {
  2097. Fragment,
  2098. Text,
  2099. Comment,
  2100. Static
  2101. });
  2102. }
  2103. function devtoolsUnmountApp(app) {
  2104. emit("app:unmount" /* APP_UNMOUNT */, app);
  2105. }
  2106. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  2107. const devtoolsComponentUpdated =
  2108. /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2109. const devtoolsComponentRemoved =
  2110. /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
  2111. function createDevtoolsComponentHook(hook) {
  2112. return (component) => {
  2113. emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  2114. };
  2115. }
  2116. const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
  2117. const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
  2118. function createDevtoolsPerformanceHook(hook) {
  2119. return (component, type, time) => {
  2120. emit(hook, component.appContext.app, component.uid, component, type, time);
  2121. };
  2122. }
  2123. function devtoolsComponentEmit(component, event, params) {
  2124. emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
  2125. }
  2126. function emit$1(instance, event, ...rawArgs) {
  2127. if (instance.isUnmounted)
  2128. return;
  2129. const props = instance.vnode.props || EMPTY_OBJ;
  2130. {
  2131. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  2132. if (emitsOptions) {
  2133. if (!(event in emitsOptions) &&
  2134. !(false )) {
  2135. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2136. warn$1(`Component emitted event "${event}" but it is neither declared in ` +
  2137. `the emits option nor as an "${toHandlerKey(event)}" prop.`);
  2138. }
  2139. }
  2140. else {
  2141. const validator = emitsOptions[event];
  2142. if (isFunction(validator)) {
  2143. const isValid = validator(...rawArgs);
  2144. if (!isValid) {
  2145. warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
  2146. }
  2147. }
  2148. }
  2149. }
  2150. }
  2151. let args = rawArgs;
  2152. const isModelListener = event.startsWith('update:');
  2153. // for v-model update:xxx events, apply modifiers on args
  2154. const modelArg = isModelListener && event.slice(7);
  2155. if (modelArg && modelArg in props) {
  2156. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  2157. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2158. if (trim) {
  2159. args = rawArgs.map(a => a.trim());
  2160. }
  2161. if (number) {
  2162. args = rawArgs.map(toNumber);
  2163. }
  2164. }
  2165. {
  2166. devtoolsComponentEmit(instance, event, args);
  2167. }
  2168. {
  2169. const lowerCaseEvent = event.toLowerCase();
  2170. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2171. warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
  2172. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  2173. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2174. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2175. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2176. }
  2177. }
  2178. let handlerName;
  2179. let handler = props[(handlerName = toHandlerKey(event))] ||
  2180. // also try camelCase event handler (#2249)
  2181. props[(handlerName = toHandlerKey(camelize(event)))];
  2182. // for v-model update:xxx events, also trigger kebab-case equivalent
  2183. // for props passed via kebab-case
  2184. if (!handler && isModelListener) {
  2185. handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
  2186. }
  2187. if (handler) {
  2188. callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  2189. }
  2190. const onceHandler = props[handlerName + `Once`];
  2191. if (onceHandler) {
  2192. if (!instance.emitted) {
  2193. instance.emitted = {};
  2194. }
  2195. else if (instance.emitted[handlerName]) {
  2196. return;
  2197. }
  2198. instance.emitted[handlerName] = true;
  2199. callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  2200. }
  2201. }
  2202. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2203. const cache = appContext.emitsCache;
  2204. const cached = cache.get(comp);
  2205. if (cached !== undefined) {
  2206. return cached;
  2207. }
  2208. const raw = comp.emits;
  2209. let normalized = {};
  2210. // apply mixin/extends props
  2211. let hasExtends = false;
  2212. if (!isFunction(comp)) {
  2213. const extendEmits = (raw) => {
  2214. const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  2215. if (normalizedFromExtend) {
  2216. hasExtends = true;
  2217. extend(normalized, normalizedFromExtend);
  2218. }
  2219. };
  2220. if (!asMixin && appContext.mixins.length) {
  2221. appContext.mixins.forEach(extendEmits);
  2222. }
  2223. if (comp.extends) {
  2224. extendEmits(comp.extends);
  2225. }
  2226. if (comp.mixins) {
  2227. comp.mixins.forEach(extendEmits);
  2228. }
  2229. }
  2230. if (!raw && !hasExtends) {
  2231. cache.set(comp, null);
  2232. return null;
  2233. }
  2234. if (isArray(raw)) {
  2235. raw.forEach(key => (normalized[key] = null));
  2236. }
  2237. else {
  2238. extend(normalized, raw);
  2239. }
  2240. cache.set(comp, normalized);
  2241. return normalized;
  2242. }
  2243. // Check if an incoming prop key is a declared emit event listener.
  2244. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  2245. // both considered matched listeners.
  2246. function isEmitListener(options, key) {
  2247. if (!options || !isOn(key)) {
  2248. return false;
  2249. }
  2250. key = key.slice(2).replace(/Once$/, '');
  2251. return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  2252. hasOwn(options, hyphenate(key)) ||
  2253. hasOwn(options, key));
  2254. }
  2255. /**
  2256. * mark the current rendering instance for asset resolution (e.g.
  2257. * resolveComponent, resolveDirective) during render
  2258. */
  2259. let currentRenderingInstance = null;
  2260. let currentScopeId = null;
  2261. /**
  2262. * Note: rendering calls maybe nested. The function returns the parent rendering
  2263. * instance if present, which should be restored after the render is done:
  2264. *
  2265. * ```js
  2266. * const prev = setCurrentRenderingInstance(i)
  2267. * // ...render
  2268. * setCurrentRenderingInstance(prev)
  2269. * ```
  2270. */
  2271. function setCurrentRenderingInstance(instance) {
  2272. const prev = currentRenderingInstance;
  2273. currentRenderingInstance = instance;
  2274. currentScopeId = (instance && instance.type.__scopeId) || null;
  2275. return prev;
  2276. }
  2277. /**
  2278. * Set scope id when creating hoisted vnodes.
  2279. * @private compiler helper
  2280. */
  2281. function pushScopeId(id) {
  2282. currentScopeId = id;
  2283. }
  2284. /**
  2285. * Technically we no longer need this after 3.0.8 but we need to keep the same
  2286. * API for backwards compat w/ code generated by compilers.
  2287. * @private
  2288. */
  2289. function popScopeId() {
  2290. currentScopeId = null;
  2291. }
  2292. /**
  2293. * Only for backwards compat
  2294. * @private
  2295. */
  2296. const withScopeId = (_id) => withCtx;
  2297. /**
  2298. * Wrap a slot function to memoize current rendering instance
  2299. * @private compiler helper
  2300. */
  2301. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
  2302. ) {
  2303. if (!ctx)
  2304. return fn;
  2305. // already normalized
  2306. if (fn._n) {
  2307. return fn;
  2308. }
  2309. const renderFnWithContext = (...args) => {
  2310. // If a user calls a compiled slot inside a template expression (#1745), it
  2311. // can mess up block tracking, so by default we disable block tracking and
  2312. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  2313. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  2314. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  2315. if (renderFnWithContext._d) {
  2316. setBlockTracking(-1);
  2317. }
  2318. const prevInstance = setCurrentRenderingInstance(ctx);
  2319. const res = fn(...args);
  2320. setCurrentRenderingInstance(prevInstance);
  2321. if (renderFnWithContext._d) {
  2322. setBlockTracking(1);
  2323. }
  2324. {
  2325. devtoolsComponentUpdated(ctx);
  2326. }
  2327. return res;
  2328. };
  2329. // mark normalized to avoid duplicated wrapping
  2330. renderFnWithContext._n = true;
  2331. // mark this as compiled by default
  2332. // this is used in vnode.ts -> normalizeChildren() to set the slot
  2333. // rendering flag.
  2334. renderFnWithContext._c = true;
  2335. // disable block tracking by default
  2336. renderFnWithContext._d = true;
  2337. return renderFnWithContext;
  2338. }
  2339. /**
  2340. * dev only flag to track whether $attrs was used during render.
  2341. * If $attrs was used during render then the warning for failed attrs
  2342. * fallthrough can be suppressed.
  2343. */
  2344. let accessedAttrs = false;
  2345. function markAttrsAccessed() {
  2346. accessedAttrs = true;
  2347. }
  2348. function renderComponentRoot(instance) {
  2349. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
  2350. let result;
  2351. let fallthroughAttrs;
  2352. const prev = setCurrentRenderingInstance(instance);
  2353. {
  2354. accessedAttrs = false;
  2355. }
  2356. try {
  2357. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  2358. // withProxy is a proxy with a different `has` trap only for
  2359. // runtime-compiled render functions using `with` block.
  2360. const proxyToUse = withProxy || proxy;
  2361. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  2362. fallthroughAttrs = attrs;
  2363. }
  2364. else {
  2365. // functional
  2366. const render = Component;
  2367. // in dev, mark attrs accessed if optional props (attrs === props)
  2368. if (true && attrs === props) {
  2369. markAttrsAccessed();
  2370. }
  2371. result = normalizeVNode(render.length > 1
  2372. ? render(props, true
  2373. ? {
  2374. get attrs() {
  2375. markAttrsAccessed();
  2376. return attrs;
  2377. },
  2378. slots,
  2379. emit
  2380. }
  2381. : { attrs, slots, emit })
  2382. : render(props, null /* we know it doesn't need it */));
  2383. fallthroughAttrs = Component.props
  2384. ? attrs
  2385. : getFunctionalFallthrough(attrs);
  2386. }
  2387. }
  2388. catch (err) {
  2389. blockStack.length = 0;
  2390. handleError(err, instance, 1 /* RENDER_FUNCTION */);
  2391. result = createVNode(Comment);
  2392. }
  2393. // attr merging
  2394. // in dev mode, comments are preserved, and it's possible for a template
  2395. // to have comments along side the root element which makes it a fragment
  2396. let root = result;
  2397. let setRoot = undefined;
  2398. if (result.patchFlag > 0 &&
  2399. result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  2400. [root, setRoot] = getChildRoot(result);
  2401. }
  2402. if (fallthroughAttrs && inheritAttrs !== false) {
  2403. const keys = Object.keys(fallthroughAttrs);
  2404. const { shapeFlag } = root;
  2405. if (keys.length) {
  2406. if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
  2407. if (propsOptions && keys.some(isModelListener)) {
  2408. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  2409. // prop, it indicates this component expects to handle v-model and
  2410. // it should not fallthrough.
  2411. // related: #1543, #1643, #1989
  2412. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  2413. }
  2414. root = cloneVNode(root, fallthroughAttrs);
  2415. }
  2416. else if (!accessedAttrs && root.type !== Comment) {
  2417. const allAttrs = Object.keys(attrs);
  2418. const eventAttrs = [];
  2419. const extraAttrs = [];
  2420. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2421. const key = allAttrs[i];
  2422. if (isOn(key)) {
  2423. // ignore v-model handlers when they fail to fallthrough
  2424. if (!isModelListener(key)) {
  2425. // remove `on`, lowercase first letter to reflect event casing
  2426. // accurately
  2427. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2428. }
  2429. }
  2430. else {
  2431. extraAttrs.push(key);
  2432. }
  2433. }
  2434. if (extraAttrs.length) {
  2435. warn$1(`Extraneous non-props attributes (` +
  2436. `${extraAttrs.join(', ')}) ` +
  2437. `were passed to component but could not be automatically inherited ` +
  2438. `because component renders fragment or text root nodes.`);
  2439. }
  2440. if (eventAttrs.length) {
  2441. warn$1(`Extraneous non-emits event listeners (` +
  2442. `${eventAttrs.join(', ')}) ` +
  2443. `were passed to component but could not be automatically inherited ` +
  2444. `because component renders fragment or text root nodes. ` +
  2445. `If the listener is intended to be a component custom event listener only, ` +
  2446. `declare it using the "emits" option.`);
  2447. }
  2448. }
  2449. }
  2450. }
  2451. // inherit directives
  2452. if (vnode.dirs) {
  2453. if (!isElementRoot(root)) {
  2454. warn$1(`Runtime directive used on component with non-element root node. ` +
  2455. `The directives will not function as intended.`);
  2456. }
  2457. // clone before mutating since the root may be a hoisted vnode
  2458. root = cloneVNode(root);
  2459. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2460. }
  2461. // inherit transition data
  2462. if (vnode.transition) {
  2463. if (!isElementRoot(root)) {
  2464. warn$1(`Component inside <Transition> renders non-element root node ` +
  2465. `that cannot be animated.`);
  2466. }
  2467. root.transition = vnode.transition;
  2468. }
  2469. if (setRoot) {
  2470. setRoot(root);
  2471. }
  2472. else {
  2473. result = root;
  2474. }
  2475. setCurrentRenderingInstance(prev);
  2476. return result;
  2477. }
  2478. /**
  2479. * dev only
  2480. * In dev mode, template root level comments are rendered, which turns the
  2481. * template into a fragment root, but we need to locate the single element
  2482. * root for attrs and scope id processing.
  2483. */
  2484. const getChildRoot = (vnode) => {
  2485. const rawChildren = vnode.children;
  2486. const dynamicChildren = vnode.dynamicChildren;
  2487. const childRoot = filterSingleRoot(rawChildren);
  2488. if (!childRoot) {
  2489. return [vnode, undefined];
  2490. }
  2491. const index = rawChildren.indexOf(childRoot);
  2492. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2493. const setRoot = (updatedRoot) => {
  2494. rawChildren[index] = updatedRoot;
  2495. if (dynamicChildren) {
  2496. if (dynamicIndex > -1) {
  2497. dynamicChildren[dynamicIndex] = updatedRoot;
  2498. }
  2499. else if (updatedRoot.patchFlag > 0) {
  2500. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2501. }
  2502. }
  2503. };
  2504. return [normalizeVNode(childRoot), setRoot];
  2505. };
  2506. function filterSingleRoot(children) {
  2507. let singleRoot;
  2508. for (let i = 0; i < children.length; i++) {
  2509. const child = children[i];
  2510. if (isVNode(child)) {
  2511. // ignore user comment
  2512. if (child.type !== Comment || child.children === 'v-if') {
  2513. if (singleRoot) {
  2514. // has more than 1 non-comment child, return now
  2515. return;
  2516. }
  2517. else {
  2518. singleRoot = child;
  2519. }
  2520. }
  2521. }
  2522. else {
  2523. return;
  2524. }
  2525. }
  2526. return singleRoot;
  2527. }
  2528. const getFunctionalFallthrough = (attrs) => {
  2529. let res;
  2530. for (const key in attrs) {
  2531. if (key === 'class' || key === 'style' || isOn(key)) {
  2532. (res || (res = {}))[key] = attrs[key];
  2533. }
  2534. }
  2535. return res;
  2536. };
  2537. const filterModelListeners = (attrs, props) => {
  2538. const res = {};
  2539. for (const key in attrs) {
  2540. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2541. res[key] = attrs[key];
  2542. }
  2543. }
  2544. return res;
  2545. };
  2546. const isElementRoot = (vnode) => {
  2547. return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
  2548. vnode.type === Comment // potential v-if branch switch
  2549. );
  2550. };
  2551. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2552. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2553. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2554. const emits = component.emitsOptions;
  2555. // Parent component's render function was hot-updated. Since this may have
  2556. // caused the child component's slots content to have changed, we need to
  2557. // force the child to update as well.
  2558. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2559. return true;
  2560. }
  2561. // force child update for runtime directive or transition on component vnode.
  2562. if (nextVNode.dirs || nextVNode.transition) {
  2563. return true;
  2564. }
  2565. if (optimized && patchFlag >= 0) {
  2566. if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  2567. // slot content that references values that might have changed,
  2568. // e.g. in a v-for
  2569. return true;
  2570. }
  2571. if (patchFlag & 16 /* FULL_PROPS */) {
  2572. if (!prevProps) {
  2573. return !!nextProps;
  2574. }
  2575. // presence of this flag indicates props are always non-null
  2576. return hasPropsChanged(prevProps, nextProps, emits);
  2577. }
  2578. else if (patchFlag & 8 /* PROPS */) {
  2579. const dynamicProps = nextVNode.dynamicProps;
  2580. for (let i = 0; i < dynamicProps.length; i++) {
  2581. const key = dynamicProps[i];
  2582. if (nextProps[key] !== prevProps[key] &&
  2583. !isEmitListener(emits, key)) {
  2584. return true;
  2585. }
  2586. }
  2587. }
  2588. }
  2589. else {
  2590. // this path is only taken by manually written render functions
  2591. // so presence of any children leads to a forced update
  2592. if (prevChildren || nextChildren) {
  2593. if (!nextChildren || !nextChildren.$stable) {
  2594. return true;
  2595. }
  2596. }
  2597. if (prevProps === nextProps) {
  2598. return false;
  2599. }
  2600. if (!prevProps) {
  2601. return !!nextProps;
  2602. }
  2603. if (!nextProps) {
  2604. return true;
  2605. }
  2606. return hasPropsChanged(prevProps, nextProps, emits);
  2607. }
  2608. return false;
  2609. }
  2610. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2611. const nextKeys = Object.keys(nextProps);
  2612. if (nextKeys.length !== Object.keys(prevProps).length) {
  2613. return true;
  2614. }
  2615. for (let i = 0; i < nextKeys.length; i++) {
  2616. const key = nextKeys[i];
  2617. if (nextProps[key] !== prevProps[key] &&
  2618. !isEmitListener(emitsOptions, key)) {
  2619. return true;
  2620. }
  2621. }
  2622. return false;
  2623. }
  2624. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2625. ) {
  2626. while (parent && parent.subTree === vnode) {
  2627. (vnode = parent.vnode).el = el;
  2628. parent = parent.parent;
  2629. }
  2630. }
  2631. const isSuspense = (type) => type.__isSuspense;
  2632. // Suspense exposes a component-like API, and is treated like a component
  2633. // in the compiler, but internally it's a special built-in type that hooks
  2634. // directly into the renderer.
  2635. const SuspenseImpl = {
  2636. name: 'Suspense',
  2637. // In order to make Suspense tree-shakable, we need to avoid importing it
  2638. // directly in the renderer. The renderer checks for the __isSuspense flag
  2639. // on a vnode's type and calls the `process` method, passing in renderer
  2640. // internals.
  2641. __isSuspense: true,
  2642. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  2643. // platform-specific impl passed from renderer
  2644. rendererInternals) {
  2645. if (n1 == null) {
  2646. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  2647. }
  2648. else {
  2649. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  2650. }
  2651. },
  2652. hydrate: hydrateSuspense,
  2653. create: createSuspenseBoundary,
  2654. normalize: normalizeSuspenseChildren
  2655. };
  2656. // Force-casted public typing for h and TSX props inference
  2657. const Suspense = (SuspenseImpl );
  2658. function triggerEvent(vnode, name) {
  2659. const eventListener = vnode.props && vnode.props[name];
  2660. if (isFunction(eventListener)) {
  2661. eventListener();
  2662. }
  2663. }
  2664. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2665. const { p: patch, o: { createElement } } = rendererInternals;
  2666. const hiddenContainer = createElement('div');
  2667. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
  2668. // start mounting the content subtree in an off-dom container
  2669. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  2670. // now check if we have encountered any async deps
  2671. if (suspense.deps > 0) {
  2672. // has async
  2673. // invoke @fallback event
  2674. triggerEvent(vnode, 'onPending');
  2675. triggerEvent(vnode, 'onFallback');
  2676. // mount the fallback tree
  2677. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2678. isSVG, slotScopeIds);
  2679. setActiveBranch(suspense, vnode.ssFallback);
  2680. }
  2681. else {
  2682. // Suspense has no async deps. Just resolve.
  2683. suspense.resolve();
  2684. }
  2685. }
  2686. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2687. const suspense = (n2.suspense = n1.suspense);
  2688. suspense.vnode = n2;
  2689. n2.el = n1.el;
  2690. const newBranch = n2.ssContent;
  2691. const newFallback = n2.ssFallback;
  2692. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2693. if (pendingBranch) {
  2694. suspense.pendingBranch = newBranch;
  2695. if (isSameVNodeType(newBranch, pendingBranch)) {
  2696. // same root type but content may have changed.
  2697. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2698. if (suspense.deps <= 0) {
  2699. suspense.resolve();
  2700. }
  2701. else if (isInFallback) {
  2702. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2703. isSVG, slotScopeIds, optimized);
  2704. setActiveBranch(suspense, newFallback);
  2705. }
  2706. }
  2707. else {
  2708. // toggled before pending tree is resolved
  2709. suspense.pendingId++;
  2710. if (isHydrating) {
  2711. // if toggled before hydration is finished, the current DOM tree is
  2712. // no longer valid. set it as the active branch so it will be unmounted
  2713. // when resolved
  2714. suspense.isHydrating = false;
  2715. suspense.activeBranch = pendingBranch;
  2716. }
  2717. else {
  2718. unmount(pendingBranch, parentComponent, suspense);
  2719. }
  2720. // increment pending ID. this is used to invalidate async callbacks
  2721. // reset suspense state
  2722. suspense.deps = 0;
  2723. // discard effects from pending branch
  2724. suspense.effects.length = 0;
  2725. // discard previous container
  2726. suspense.hiddenContainer = createElement('div');
  2727. if (isInFallback) {
  2728. // already in fallback state
  2729. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2730. if (suspense.deps <= 0) {
  2731. suspense.resolve();
  2732. }
  2733. else {
  2734. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2735. isSVG, slotScopeIds, optimized);
  2736. setActiveBranch(suspense, newFallback);
  2737. }
  2738. }
  2739. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2740. // toggled "back" to current active branch
  2741. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2742. // force resolve
  2743. suspense.resolve(true);
  2744. }
  2745. else {
  2746. // switched to a 3rd branch
  2747. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2748. if (suspense.deps <= 0) {
  2749. suspense.resolve();
  2750. }
  2751. }
  2752. }
  2753. }
  2754. else {
  2755. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2756. // root did not change, just normal patch
  2757. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2758. setActiveBranch(suspense, newBranch);
  2759. }
  2760. else {
  2761. // root node toggled
  2762. // invoke @pending event
  2763. triggerEvent(n2, 'onPending');
  2764. // mount pending branch in off-dom container
  2765. suspense.pendingBranch = newBranch;
  2766. suspense.pendingId++;
  2767. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2768. if (suspense.deps <= 0) {
  2769. // incoming branch has no async deps, resolve now.
  2770. suspense.resolve();
  2771. }
  2772. else {
  2773. const { timeout, pendingId } = suspense;
  2774. if (timeout > 0) {
  2775. setTimeout(() => {
  2776. if (suspense.pendingId === pendingId) {
  2777. suspense.fallback(newFallback);
  2778. }
  2779. }, timeout);
  2780. }
  2781. else if (timeout === 0) {
  2782. suspense.fallback(newFallback);
  2783. }
  2784. }
  2785. }
  2786. }
  2787. }
  2788. let hasWarned = false;
  2789. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2790. /* istanbul ignore if */
  2791. if (!hasWarned) {
  2792. hasWarned = true;
  2793. // @ts-ignore `console.info` cannot be null error
  2794. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2795. }
  2796. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2797. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2798. const suspense = {
  2799. vnode,
  2800. parent,
  2801. parentComponent,
  2802. isSVG,
  2803. container,
  2804. hiddenContainer,
  2805. anchor,
  2806. deps: 0,
  2807. pendingId: 0,
  2808. timeout: typeof timeout === 'number' ? timeout : -1,
  2809. activeBranch: null,
  2810. pendingBranch: null,
  2811. isInFallback: true,
  2812. isHydrating,
  2813. isUnmounted: false,
  2814. effects: [],
  2815. resolve(resume = false) {
  2816. {
  2817. if (!resume && !suspense.pendingBranch) {
  2818. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2819. }
  2820. if (suspense.isUnmounted) {
  2821. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2822. }
  2823. }
  2824. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2825. if (suspense.isHydrating) {
  2826. suspense.isHydrating = false;
  2827. }
  2828. else if (!resume) {
  2829. const delayEnter = activeBranch &&
  2830. pendingBranch.transition &&
  2831. pendingBranch.transition.mode === 'out-in';
  2832. if (delayEnter) {
  2833. activeBranch.transition.afterLeave = () => {
  2834. if (pendingId === suspense.pendingId) {
  2835. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2836. }
  2837. };
  2838. }
  2839. // this is initial anchor on mount
  2840. let { anchor } = suspense;
  2841. // unmount current active tree
  2842. if (activeBranch) {
  2843. // if the fallback tree was mounted, it may have been moved
  2844. // as part of a parent suspense. get the latest anchor for insertion
  2845. anchor = next(activeBranch);
  2846. unmount(activeBranch, parentComponent, suspense, true);
  2847. }
  2848. if (!delayEnter) {
  2849. // move content from off-dom container to actual container
  2850. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2851. }
  2852. }
  2853. setActiveBranch(suspense, pendingBranch);
  2854. suspense.pendingBranch = null;
  2855. suspense.isInFallback = false;
  2856. // flush buffered effects
  2857. // check if there is a pending parent suspense
  2858. let parent = suspense.parent;
  2859. let hasUnresolvedAncestor = false;
  2860. while (parent) {
  2861. if (parent.pendingBranch) {
  2862. // found a pending parent suspense, merge buffered post jobs
  2863. // into that parent
  2864. parent.effects.push(...effects);
  2865. hasUnresolvedAncestor = true;
  2866. break;
  2867. }
  2868. parent = parent.parent;
  2869. }
  2870. // no pending parent suspense, flush all jobs
  2871. if (!hasUnresolvedAncestor) {
  2872. queuePostFlushCb(effects);
  2873. }
  2874. suspense.effects = [];
  2875. // invoke @resolve event
  2876. triggerEvent(vnode, 'onResolve');
  2877. },
  2878. fallback(fallbackVNode) {
  2879. if (!suspense.pendingBranch) {
  2880. return;
  2881. }
  2882. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  2883. // invoke @fallback event
  2884. triggerEvent(vnode, 'onFallback');
  2885. const anchor = next(activeBranch);
  2886. const mountFallback = () => {
  2887. if (!suspense.isInFallback) {
  2888. return;
  2889. }
  2890. // mount the fallback tree
  2891. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2892. isSVG, slotScopeIds, optimized);
  2893. setActiveBranch(suspense, fallbackVNode);
  2894. };
  2895. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2896. if (delayEnter) {
  2897. activeBranch.transition.afterLeave = mountFallback;
  2898. }
  2899. suspense.isInFallback = true;
  2900. // unmount current active branch
  2901. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2902. true // shouldRemove
  2903. );
  2904. if (!delayEnter) {
  2905. mountFallback();
  2906. }
  2907. },
  2908. move(container, anchor, type) {
  2909. suspense.activeBranch &&
  2910. move(suspense.activeBranch, container, anchor, type);
  2911. suspense.container = container;
  2912. },
  2913. next() {
  2914. return suspense.activeBranch && next(suspense.activeBranch);
  2915. },
  2916. registerDep(instance, setupRenderEffect) {
  2917. const isInPendingSuspense = !!suspense.pendingBranch;
  2918. if (isInPendingSuspense) {
  2919. suspense.deps++;
  2920. }
  2921. const hydratedEl = instance.vnode.el;
  2922. instance
  2923. .asyncDep.catch(err => {
  2924. handleError(err, instance, 0 /* SETUP_FUNCTION */);
  2925. })
  2926. .then(asyncSetupResult => {
  2927. // retry when the setup() promise resolves.
  2928. // component may have been unmounted before resolve.
  2929. if (instance.isUnmounted ||
  2930. suspense.isUnmounted ||
  2931. suspense.pendingId !== instance.suspenseId) {
  2932. return;
  2933. }
  2934. // retry from this component
  2935. instance.asyncResolved = true;
  2936. const { vnode } = instance;
  2937. {
  2938. pushWarningContext(vnode);
  2939. }
  2940. handleSetupResult(instance, asyncSetupResult, false);
  2941. if (hydratedEl) {
  2942. // vnode may have been replaced if an update happened before the
  2943. // async dep is resolved.
  2944. vnode.el = hydratedEl;
  2945. }
  2946. const placeholder = !hydratedEl && instance.subTree.el;
  2947. setupRenderEffect(instance, vnode,
  2948. // component may have been moved before resolve.
  2949. // if this is not a hydration, instance.subTree will be the comment
  2950. // placeholder.
  2951. parentNode(hydratedEl || instance.subTree.el),
  2952. // anchor will not be used if this is hydration, so only need to
  2953. // consider the comment placeholder case.
  2954. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2955. if (placeholder) {
  2956. remove(placeholder);
  2957. }
  2958. updateHOCHostEl(instance, vnode.el);
  2959. {
  2960. popWarningContext();
  2961. }
  2962. // only decrease deps count if suspense is not already resolved
  2963. if (isInPendingSuspense && --suspense.deps === 0) {
  2964. suspense.resolve();
  2965. }
  2966. });
  2967. },
  2968. unmount(parentSuspense, doRemove) {
  2969. suspense.isUnmounted = true;
  2970. if (suspense.activeBranch) {
  2971. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2972. }
  2973. if (suspense.pendingBranch) {
  2974. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2975. }
  2976. }
  2977. };
  2978. return suspense;
  2979. }
  2980. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2981. /* eslint-disable no-restricted-globals */
  2982. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
  2983. // there are two possible scenarios for server-rendered suspense:
  2984. // - success: ssr content should be fully resolved
  2985. // - failure: ssr content should be the fallback branch.
  2986. // however, on the client we don't really know if it has failed or not
  2987. // attempt to hydrate the DOM assuming it has succeeded, but we still
  2988. // need to construct a suspense boundary first
  2989. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
  2990. if (suspense.deps === 0) {
  2991. suspense.resolve();
  2992. }
  2993. return result;
  2994. /* eslint-enable no-restricted-globals */
  2995. }
  2996. function normalizeSuspenseChildren(vnode) {
  2997. const { shapeFlag, children } = vnode;
  2998. const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
  2999. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  3000. vnode.ssFallback = isSlotChildren
  3001. ? normalizeSuspenseSlot(children.fallback)
  3002. : createVNode(Comment);
  3003. }
  3004. function normalizeSuspenseSlot(s) {
  3005. let block;
  3006. if (isFunction(s)) {
  3007. const trackBlock = isBlockTreeEnabled && s._c;
  3008. if (trackBlock) {
  3009. // disableTracking: false
  3010. // allow block tracking for compiled slots
  3011. // (see ./componentRenderContext.ts)
  3012. s._d = false;
  3013. openBlock();
  3014. }
  3015. s = s();
  3016. if (trackBlock) {
  3017. s._d = true;
  3018. block = currentBlock;
  3019. closeBlock();
  3020. }
  3021. }
  3022. if (isArray(s)) {
  3023. const singleChild = filterSingleRoot(s);
  3024. if (!singleChild) {
  3025. warn$1(`<Suspense> slots expect a single root node.`);
  3026. }
  3027. s = singleChild;
  3028. }
  3029. s = normalizeVNode(s);
  3030. if (block && !s.dynamicChildren) {
  3031. s.dynamicChildren = block.filter(c => c !== s);
  3032. }
  3033. return s;
  3034. }
  3035. function queueEffectWithSuspense(fn, suspense) {
  3036. if (suspense && suspense.pendingBranch) {
  3037. if (isArray(fn)) {
  3038. suspense.effects.push(...fn);
  3039. }
  3040. else {
  3041. suspense.effects.push(fn);
  3042. }
  3043. }
  3044. else {
  3045. queuePostFlushCb(fn);
  3046. }
  3047. }
  3048. function setActiveBranch(suspense, branch) {
  3049. suspense.activeBranch = branch;
  3050. const { vnode, parentComponent } = suspense;
  3051. const el = (vnode.el = branch.el);
  3052. // in case suspense is the root node of a component,
  3053. // recursively update the HOC el
  3054. if (parentComponent && parentComponent.subTree === vnode) {
  3055. parentComponent.vnode.el = el;
  3056. updateHOCHostEl(parentComponent, el);
  3057. }
  3058. }
  3059. function provide(key, value) {
  3060. if (!currentInstance) {
  3061. {
  3062. warn$1(`provide() can only be used inside setup().`);
  3063. }
  3064. }
  3065. else {
  3066. let provides = currentInstance.provides;
  3067. // by default an instance inherits its parent's provides object
  3068. // but when it needs to provide values of its own, it creates its
  3069. // own provides object using parent provides object as prototype.
  3070. // this way in `inject` we can simply look up injections from direct
  3071. // parent and let the prototype chain do the work.
  3072. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  3073. if (parentProvides === provides) {
  3074. provides = currentInstance.provides = Object.create(parentProvides);
  3075. }
  3076. // TS doesn't allow symbol as index type
  3077. provides[key] = value;
  3078. }
  3079. }
  3080. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3081. // fallback to `currentRenderingInstance` so that this can be called in
  3082. // a functional component
  3083. const instance = currentInstance || currentRenderingInstance;
  3084. if (instance) {
  3085. // #2400
  3086. // to support `app.use` plugins,
  3087. // fallback to appContext's `provides` if the instance is at root
  3088. const provides = instance.parent == null
  3089. ? instance.vnode.appContext && instance.vnode.appContext.provides
  3090. : instance.parent.provides;
  3091. if (provides && key in provides) {
  3092. // TS doesn't allow symbol as index type
  3093. return provides[key];
  3094. }
  3095. else if (arguments.length > 1) {
  3096. return treatDefaultAsFactory && isFunction(defaultValue)
  3097. ? defaultValue.call(instance.proxy)
  3098. : defaultValue;
  3099. }
  3100. else {
  3101. warn$1(`injection "${String(key)}" not found.`);
  3102. }
  3103. }
  3104. else {
  3105. warn$1(`inject() can only be used inside setup() or functional components.`);
  3106. }
  3107. }
  3108. // Simple effect.
  3109. function watchEffect(effect, options) {
  3110. return doWatch(effect, null, options);
  3111. }
  3112. function watchPostEffect(effect, options) {
  3113. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3114. }
  3115. function watchSyncEffect(effect, options) {
  3116. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3117. }
  3118. // initial value for watchers to trigger on undefined initial values
  3119. const INITIAL_WATCHER_VALUE = {};
  3120. // implementation
  3121. function watch(source, cb, options) {
  3122. if (!isFunction(cb)) {
  3123. warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3124. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3125. `supports \`watch(source, cb, options?) signature.`);
  3126. }
  3127. return doWatch(source, cb, options);
  3128. }
  3129. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3130. if (!cb) {
  3131. if (immediate !== undefined) {
  3132. warn$1(`watch() "immediate" option is only respected when using the ` +
  3133. `watch(source, callback, options?) signature.`);
  3134. }
  3135. if (deep !== undefined) {
  3136. warn$1(`watch() "deep" option is only respected when using the ` +
  3137. `watch(source, callback, options?) signature.`);
  3138. }
  3139. }
  3140. const warnInvalidSource = (s) => {
  3141. warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  3142. `a reactive object, or an array of these types.`);
  3143. };
  3144. const instance = currentInstance;
  3145. let getter;
  3146. let forceTrigger = false;
  3147. let isMultiSource = false;
  3148. if (isRef(source)) {
  3149. getter = () => source.value;
  3150. forceTrigger = isShallow(source);
  3151. }
  3152. else if (isReactive(source)) {
  3153. getter = () => source;
  3154. deep = true;
  3155. }
  3156. else if (isArray(source)) {
  3157. isMultiSource = true;
  3158. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3159. getter = () => source.map(s => {
  3160. if (isRef(s)) {
  3161. return s.value;
  3162. }
  3163. else if (isReactive(s)) {
  3164. return traverse(s);
  3165. }
  3166. else if (isFunction(s)) {
  3167. return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
  3168. }
  3169. else {
  3170. warnInvalidSource(s);
  3171. }
  3172. });
  3173. }
  3174. else if (isFunction(source)) {
  3175. if (cb) {
  3176. // getter with cb
  3177. getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
  3178. }
  3179. else {
  3180. // no cb -> simple effect
  3181. getter = () => {
  3182. if (instance && instance.isUnmounted) {
  3183. return;
  3184. }
  3185. if (cleanup) {
  3186. cleanup();
  3187. }
  3188. return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onCleanup]);
  3189. };
  3190. }
  3191. }
  3192. else {
  3193. getter = NOOP;
  3194. warnInvalidSource(source);
  3195. }
  3196. if (cb && deep) {
  3197. const baseGetter = getter;
  3198. getter = () => traverse(baseGetter());
  3199. }
  3200. let cleanup;
  3201. let onCleanup = (fn) => {
  3202. cleanup = effect.onStop = () => {
  3203. callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
  3204. };
  3205. };
  3206. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3207. const job = () => {
  3208. if (!effect.active) {
  3209. return;
  3210. }
  3211. if (cb) {
  3212. // watch(source, cb)
  3213. const newValue = effect.run();
  3214. if (deep ||
  3215. forceTrigger ||
  3216. (isMultiSource
  3217. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3218. : hasChanged(newValue, oldValue)) ||
  3219. (false )) {
  3220. // cleanup before running cb again
  3221. if (cleanup) {
  3222. cleanup();
  3223. }
  3224. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  3225. newValue,
  3226. // pass undefined as the old value when it's changed for the first time
  3227. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3228. onCleanup
  3229. ]);
  3230. oldValue = newValue;
  3231. }
  3232. }
  3233. else {
  3234. // watchEffect
  3235. effect.run();
  3236. }
  3237. };
  3238. // important: mark the job as a watcher callback so that scheduler knows
  3239. // it is allowed to self-trigger (#1727)
  3240. job.allowRecurse = !!cb;
  3241. let scheduler;
  3242. if (flush === 'sync') {
  3243. scheduler = job; // the scheduler function gets called directly
  3244. }
  3245. else if (flush === 'post') {
  3246. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3247. }
  3248. else {
  3249. // default: 'pre'
  3250. scheduler = () => queuePreFlushCb(job);
  3251. }
  3252. const effect = new ReactiveEffect(getter, scheduler);
  3253. {
  3254. effect.onTrack = onTrack;
  3255. effect.onTrigger = onTrigger;
  3256. }
  3257. // initial run
  3258. if (cb) {
  3259. if (immediate) {
  3260. job();
  3261. }
  3262. else {
  3263. oldValue = effect.run();
  3264. }
  3265. }
  3266. else if (flush === 'post') {
  3267. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  3268. }
  3269. else {
  3270. effect.run();
  3271. }
  3272. return () => {
  3273. effect.stop();
  3274. if (instance && instance.scope) {
  3275. remove(instance.scope.effects, effect);
  3276. }
  3277. };
  3278. }
  3279. // this.$watch
  3280. function instanceWatch(source, value, options) {
  3281. const publicThis = this.proxy;
  3282. const getter = isString(source)
  3283. ? source.includes('.')
  3284. ? createPathGetter(publicThis, source)
  3285. : () => publicThis[source]
  3286. : source.bind(publicThis, publicThis);
  3287. let cb;
  3288. if (isFunction(value)) {
  3289. cb = value;
  3290. }
  3291. else {
  3292. cb = value.handler;
  3293. options = value;
  3294. }
  3295. const cur = currentInstance;
  3296. setCurrentInstance(this);
  3297. const res = doWatch(getter, cb.bind(publicThis), options);
  3298. if (cur) {
  3299. setCurrentInstance(cur);
  3300. }
  3301. else {
  3302. unsetCurrentInstance();
  3303. }
  3304. return res;
  3305. }
  3306. function createPathGetter(ctx, path) {
  3307. const segments = path.split('.');
  3308. return () => {
  3309. let cur = ctx;
  3310. for (let i = 0; i < segments.length && cur; i++) {
  3311. cur = cur[segments[i]];
  3312. }
  3313. return cur;
  3314. };
  3315. }
  3316. function traverse(value, seen) {
  3317. if (!isObject(value) || value["__v_skip" /* SKIP */]) {
  3318. return value;
  3319. }
  3320. seen = seen || new Set();
  3321. if (seen.has(value)) {
  3322. return value;
  3323. }
  3324. seen.add(value);
  3325. if (isRef(value)) {
  3326. traverse(value.value, seen);
  3327. }
  3328. else if (isArray(value)) {
  3329. for (let i = 0; i < value.length; i++) {
  3330. traverse(value[i], seen);
  3331. }
  3332. }
  3333. else if (isSet(value) || isMap(value)) {
  3334. value.forEach((v) => {
  3335. traverse(v, seen);
  3336. });
  3337. }
  3338. else if (isPlainObject(value)) {
  3339. for (const key in value) {
  3340. traverse(value[key], seen);
  3341. }
  3342. }
  3343. return value;
  3344. }
  3345. function useTransitionState() {
  3346. const state = {
  3347. isMounted: false,
  3348. isLeaving: false,
  3349. isUnmounting: false,
  3350. leavingVNodes: new Map()
  3351. };
  3352. onMounted(() => {
  3353. state.isMounted = true;
  3354. });
  3355. onBeforeUnmount(() => {
  3356. state.isUnmounting = true;
  3357. });
  3358. return state;
  3359. }
  3360. const TransitionHookValidator = [Function, Array];
  3361. const BaseTransitionImpl = {
  3362. name: `BaseTransition`,
  3363. props: {
  3364. mode: String,
  3365. appear: Boolean,
  3366. persisted: Boolean,
  3367. // enter
  3368. onBeforeEnter: TransitionHookValidator,
  3369. onEnter: TransitionHookValidator,
  3370. onAfterEnter: TransitionHookValidator,
  3371. onEnterCancelled: TransitionHookValidator,
  3372. // leave
  3373. onBeforeLeave: TransitionHookValidator,
  3374. onLeave: TransitionHookValidator,
  3375. onAfterLeave: TransitionHookValidator,
  3376. onLeaveCancelled: TransitionHookValidator,
  3377. // appear
  3378. onBeforeAppear: TransitionHookValidator,
  3379. onAppear: TransitionHookValidator,
  3380. onAfterAppear: TransitionHookValidator,
  3381. onAppearCancelled: TransitionHookValidator
  3382. },
  3383. setup(props, { slots }) {
  3384. const instance = getCurrentInstance();
  3385. const state = useTransitionState();
  3386. let prevTransitionKey;
  3387. return () => {
  3388. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3389. if (!children || !children.length) {
  3390. return;
  3391. }
  3392. let child = children[0];
  3393. if (children.length > 1) {
  3394. let hasFound = false;
  3395. // locate first non-comment child
  3396. for (const c of children) {
  3397. if (c.type !== Comment) {
  3398. if (hasFound) {
  3399. // warn more than one non-comment child
  3400. warn$1('<transition> can only be used on a single element or component. ' +
  3401. 'Use <transition-group> for lists.');
  3402. break;
  3403. }
  3404. child = c;
  3405. hasFound = true;
  3406. }
  3407. }
  3408. }
  3409. // there's no need to track reactivity for these props so use the raw
  3410. // props for a bit better perf
  3411. const rawProps = toRaw(props);
  3412. const { mode } = rawProps;
  3413. // check mode
  3414. if (mode &&
  3415. mode !== 'in-out' &&
  3416. mode !== 'out-in' &&
  3417. mode !== 'default') {
  3418. warn$1(`invalid <transition> mode: ${mode}`);
  3419. }
  3420. if (state.isLeaving) {
  3421. return emptyPlaceholder(child);
  3422. }
  3423. // in the case of <transition><keep-alive/></transition>, we need to
  3424. // compare the type of the kept-alive children.
  3425. const innerChild = getKeepAliveChild(child);
  3426. if (!innerChild) {
  3427. return emptyPlaceholder(child);
  3428. }
  3429. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  3430. setTransitionHooks(innerChild, enterHooks);
  3431. const oldChild = instance.subTree;
  3432. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3433. let transitionKeyChanged = false;
  3434. const { getTransitionKey } = innerChild.type;
  3435. if (getTransitionKey) {
  3436. const key = getTransitionKey();
  3437. if (prevTransitionKey === undefined) {
  3438. prevTransitionKey = key;
  3439. }
  3440. else if (key !== prevTransitionKey) {
  3441. prevTransitionKey = key;
  3442. transitionKeyChanged = true;
  3443. }
  3444. }
  3445. // handle mode
  3446. if (oldInnerChild &&
  3447. oldInnerChild.type !== Comment &&
  3448. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3449. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  3450. // update old tree's hooks in case of dynamic transition
  3451. setTransitionHooks(oldInnerChild, leavingHooks);
  3452. // switching between different views
  3453. if (mode === 'out-in') {
  3454. state.isLeaving = true;
  3455. // return placeholder node and queue update when leave finishes
  3456. leavingHooks.afterLeave = () => {
  3457. state.isLeaving = false;
  3458. instance.update();
  3459. };
  3460. return emptyPlaceholder(child);
  3461. }
  3462. else if (mode === 'in-out' && innerChild.type !== Comment) {
  3463. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3464. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  3465. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3466. // early removal callback
  3467. el._leaveCb = () => {
  3468. earlyRemove();
  3469. el._leaveCb = undefined;
  3470. delete enterHooks.delayedLeave;
  3471. };
  3472. enterHooks.delayedLeave = delayedLeave;
  3473. };
  3474. }
  3475. }
  3476. return child;
  3477. };
  3478. }
  3479. };
  3480. // export the public type for h/tsx inference
  3481. // also to avoid inline import() in generated d.ts files
  3482. const BaseTransition = BaseTransitionImpl;
  3483. function getLeavingNodesForType(state, vnode) {
  3484. const { leavingVNodes } = state;
  3485. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3486. if (!leavingVNodesCache) {
  3487. leavingVNodesCache = Object.create(null);
  3488. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3489. }
  3490. return leavingVNodesCache;
  3491. }
  3492. // The transition hooks are attached to the vnode as vnode.transition
  3493. // and will be called at appropriate timing in the renderer.
  3494. function resolveTransitionHooks(vnode, props, state, instance) {
  3495. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  3496. const key = String(vnode.key);
  3497. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3498. const callHook = (hook, args) => {
  3499. hook &&
  3500. callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
  3501. };
  3502. const callAsyncHook = (hook, args) => {
  3503. const done = args[1];
  3504. callHook(hook, args);
  3505. if (isArray(hook)) {
  3506. if (hook.every(hook => hook.length <= 1))
  3507. done();
  3508. }
  3509. else if (hook.length <= 1) {
  3510. done();
  3511. }
  3512. };
  3513. const hooks = {
  3514. mode,
  3515. persisted,
  3516. beforeEnter(el) {
  3517. let hook = onBeforeEnter;
  3518. if (!state.isMounted) {
  3519. if (appear) {
  3520. hook = onBeforeAppear || onBeforeEnter;
  3521. }
  3522. else {
  3523. return;
  3524. }
  3525. }
  3526. // for same element (v-show)
  3527. if (el._leaveCb) {
  3528. el._leaveCb(true /* cancelled */);
  3529. }
  3530. // for toggled element with same key (v-if)
  3531. const leavingVNode = leavingVNodesCache[key];
  3532. if (leavingVNode &&
  3533. isSameVNodeType(vnode, leavingVNode) &&
  3534. leavingVNode.el._leaveCb) {
  3535. // force early removal (not cancelled)
  3536. leavingVNode.el._leaveCb();
  3537. }
  3538. callHook(hook, [el]);
  3539. },
  3540. enter(el) {
  3541. let hook = onEnter;
  3542. let afterHook = onAfterEnter;
  3543. let cancelHook = onEnterCancelled;
  3544. if (!state.isMounted) {
  3545. if (appear) {
  3546. hook = onAppear || onEnter;
  3547. afterHook = onAfterAppear || onAfterEnter;
  3548. cancelHook = onAppearCancelled || onEnterCancelled;
  3549. }
  3550. else {
  3551. return;
  3552. }
  3553. }
  3554. let called = false;
  3555. const done = (el._enterCb = (cancelled) => {
  3556. if (called)
  3557. return;
  3558. called = true;
  3559. if (cancelled) {
  3560. callHook(cancelHook, [el]);
  3561. }
  3562. else {
  3563. callHook(afterHook, [el]);
  3564. }
  3565. if (hooks.delayedLeave) {
  3566. hooks.delayedLeave();
  3567. }
  3568. el._enterCb = undefined;
  3569. });
  3570. if (hook) {
  3571. callAsyncHook(hook, [el, done]);
  3572. }
  3573. else {
  3574. done();
  3575. }
  3576. },
  3577. leave(el, remove) {
  3578. const key = String(vnode.key);
  3579. if (el._enterCb) {
  3580. el._enterCb(true /* cancelled */);
  3581. }
  3582. if (state.isUnmounting) {
  3583. return remove();
  3584. }
  3585. callHook(onBeforeLeave, [el]);
  3586. let called = false;
  3587. const done = (el._leaveCb = (cancelled) => {
  3588. if (called)
  3589. return;
  3590. called = true;
  3591. remove();
  3592. if (cancelled) {
  3593. callHook(onLeaveCancelled, [el]);
  3594. }
  3595. else {
  3596. callHook(onAfterLeave, [el]);
  3597. }
  3598. el._leaveCb = undefined;
  3599. if (leavingVNodesCache[key] === vnode) {
  3600. delete leavingVNodesCache[key];
  3601. }
  3602. });
  3603. leavingVNodesCache[key] = vnode;
  3604. if (onLeave) {
  3605. callAsyncHook(onLeave, [el, done]);
  3606. }
  3607. else {
  3608. done();
  3609. }
  3610. },
  3611. clone(vnode) {
  3612. return resolveTransitionHooks(vnode, props, state, instance);
  3613. }
  3614. };
  3615. return hooks;
  3616. }
  3617. // the placeholder really only handles one special case: KeepAlive
  3618. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  3619. // placeholder with empty content to avoid the KeepAlive instance from being
  3620. // unmounted.
  3621. function emptyPlaceholder(vnode) {
  3622. if (isKeepAlive(vnode)) {
  3623. vnode = cloneVNode(vnode);
  3624. vnode.children = null;
  3625. return vnode;
  3626. }
  3627. }
  3628. function getKeepAliveChild(vnode) {
  3629. return isKeepAlive(vnode)
  3630. ? vnode.children
  3631. ? vnode.children[0]
  3632. : undefined
  3633. : vnode;
  3634. }
  3635. function setTransitionHooks(vnode, hooks) {
  3636. if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
  3637. setTransitionHooks(vnode.component.subTree, hooks);
  3638. }
  3639. else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  3640. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3641. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3642. }
  3643. else {
  3644. vnode.transition = hooks;
  3645. }
  3646. }
  3647. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3648. let ret = [];
  3649. let keyedFragmentCount = 0;
  3650. for (let i = 0; i < children.length; i++) {
  3651. let child = children[i];
  3652. // #5360 inherit parent key in case of <template v-for>
  3653. const key = parentKey == null
  3654. ? child.key
  3655. : String(parentKey) + String(child.key != null ? child.key : i);
  3656. // handle fragment children case, e.g. v-for
  3657. if (child.type === Fragment) {
  3658. if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
  3659. keyedFragmentCount++;
  3660. ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
  3661. }
  3662. // comment placeholders should be skipped, e.g. v-if
  3663. else if (keepComment || child.type !== Comment) {
  3664. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3665. }
  3666. }
  3667. // #1126 if a transition children list contains multiple sub fragments, these
  3668. // fragments will be merged into a flat children array. Since each v-for
  3669. // fragment may contain different static bindings inside, we need to de-op
  3670. // these children to force full diffs to ensure correct behavior.
  3671. if (keyedFragmentCount > 1) {
  3672. for (let i = 0; i < ret.length; i++) {
  3673. ret[i].patchFlag = -2 /* BAIL */;
  3674. }
  3675. }
  3676. return ret;
  3677. }
  3678. // implementation, close to no-op
  3679. function defineComponent(options) {
  3680. return isFunction(options) ? { setup: options, name: options.name } : options;
  3681. }
  3682. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3683. function defineAsyncComponent(source) {
  3684. if (isFunction(source)) {
  3685. source = { loader: source };
  3686. }
  3687. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3688. suspensible = true, onError: userOnError } = source;
  3689. let pendingRequest = null;
  3690. let resolvedComp;
  3691. let retries = 0;
  3692. const retry = () => {
  3693. retries++;
  3694. pendingRequest = null;
  3695. return load();
  3696. };
  3697. const load = () => {
  3698. let thisRequest;
  3699. return (pendingRequest ||
  3700. (thisRequest = pendingRequest =
  3701. loader()
  3702. .catch(err => {
  3703. err = err instanceof Error ? err : new Error(String(err));
  3704. if (userOnError) {
  3705. return new Promise((resolve, reject) => {
  3706. const userRetry = () => resolve(retry());
  3707. const userFail = () => reject(err);
  3708. userOnError(err, userRetry, userFail, retries + 1);
  3709. });
  3710. }
  3711. else {
  3712. throw err;
  3713. }
  3714. })
  3715. .then((comp) => {
  3716. if (thisRequest !== pendingRequest && pendingRequest) {
  3717. return pendingRequest;
  3718. }
  3719. if (!comp) {
  3720. warn$1(`Async component loader resolved to undefined. ` +
  3721. `If you are using retry(), make sure to return its return value.`);
  3722. }
  3723. // interop module default
  3724. if (comp &&
  3725. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3726. comp = comp.default;
  3727. }
  3728. if (comp && !isObject(comp) && !isFunction(comp)) {
  3729. throw new Error(`Invalid async component load result: ${comp}`);
  3730. }
  3731. resolvedComp = comp;
  3732. return comp;
  3733. })));
  3734. };
  3735. return defineComponent({
  3736. name: 'AsyncComponentWrapper',
  3737. __asyncLoader: load,
  3738. get __asyncResolved() {
  3739. return resolvedComp;
  3740. },
  3741. setup() {
  3742. const instance = currentInstance;
  3743. // already resolved
  3744. if (resolvedComp) {
  3745. return () => createInnerComp(resolvedComp, instance);
  3746. }
  3747. const onError = (err) => {
  3748. pendingRequest = null;
  3749. handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3750. };
  3751. // suspense-controlled or SSR.
  3752. if ((suspensible && instance.suspense) ||
  3753. (false )) {
  3754. return load()
  3755. .then(comp => {
  3756. return () => createInnerComp(comp, instance);
  3757. })
  3758. .catch(err => {
  3759. onError(err);
  3760. return () => errorComponent
  3761. ? createVNode(errorComponent, {
  3762. error: err
  3763. })
  3764. : null;
  3765. });
  3766. }
  3767. const loaded = ref(false);
  3768. const error = ref();
  3769. const delayed = ref(!!delay);
  3770. if (delay) {
  3771. setTimeout(() => {
  3772. delayed.value = false;
  3773. }, delay);
  3774. }
  3775. if (timeout != null) {
  3776. setTimeout(() => {
  3777. if (!loaded.value && !error.value) {
  3778. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3779. onError(err);
  3780. error.value = err;
  3781. }
  3782. }, timeout);
  3783. }
  3784. load()
  3785. .then(() => {
  3786. loaded.value = true;
  3787. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3788. // parent is keep-alive, force update so the loaded component's
  3789. // name is taken into account
  3790. queueJob(instance.parent.update);
  3791. }
  3792. })
  3793. .catch(err => {
  3794. onError(err);
  3795. error.value = err;
  3796. });
  3797. return () => {
  3798. if (loaded.value && resolvedComp) {
  3799. return createInnerComp(resolvedComp, instance);
  3800. }
  3801. else if (error.value && errorComponent) {
  3802. return createVNode(errorComponent, {
  3803. error: error.value
  3804. });
  3805. }
  3806. else if (loadingComponent && !delayed.value) {
  3807. return createVNode(loadingComponent);
  3808. }
  3809. };
  3810. }
  3811. });
  3812. }
  3813. function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
  3814. const vnode = createVNode(comp, props, children);
  3815. // ensure inner component inherits the async wrapper's ref owner
  3816. vnode.ref = ref;
  3817. return vnode;
  3818. }
  3819. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3820. const KeepAliveImpl = {
  3821. name: `KeepAlive`,
  3822. // Marker for special handling inside the renderer. We are not using a ===
  3823. // check directly on KeepAlive in the renderer, because importing it directly
  3824. // would prevent it from being tree-shaken.
  3825. __isKeepAlive: true,
  3826. props: {
  3827. include: [String, RegExp, Array],
  3828. exclude: [String, RegExp, Array],
  3829. max: [String, Number]
  3830. },
  3831. setup(props, { slots }) {
  3832. const instance = getCurrentInstance();
  3833. // KeepAlive communicates with the instantiated renderer via the
  3834. // ctx where the renderer passes in its internals,
  3835. // and the KeepAlive instance exposes activate/deactivate implementations.
  3836. // The whole point of this is to avoid importing KeepAlive directly in the
  3837. // renderer to facilitate tree-shaking.
  3838. const sharedContext = instance.ctx;
  3839. const cache = new Map();
  3840. const keys = new Set();
  3841. let current = null;
  3842. {
  3843. instance.__v_cache = cache;
  3844. }
  3845. const parentSuspense = instance.suspense;
  3846. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  3847. const storageContainer = createElement('div');
  3848. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3849. const instance = vnode.component;
  3850. move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
  3851. // in case props have changed
  3852. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  3853. queuePostRenderEffect(() => {
  3854. instance.isDeactivated = false;
  3855. if (instance.a) {
  3856. invokeArrayFns(instance.a);
  3857. }
  3858. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3859. if (vnodeHook) {
  3860. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3861. }
  3862. }, parentSuspense);
  3863. {
  3864. // Update components tree
  3865. devtoolsComponentAdded(instance);
  3866. }
  3867. };
  3868. sharedContext.deactivate = (vnode) => {
  3869. const instance = vnode.component;
  3870. move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
  3871. queuePostRenderEffect(() => {
  3872. if (instance.da) {
  3873. invokeArrayFns(instance.da);
  3874. }
  3875. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3876. if (vnodeHook) {
  3877. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3878. }
  3879. instance.isDeactivated = true;
  3880. }, parentSuspense);
  3881. {
  3882. // Update components tree
  3883. devtoolsComponentAdded(instance);
  3884. }
  3885. };
  3886. function unmount(vnode) {
  3887. // reset the shapeFlag so it can be properly unmounted
  3888. resetShapeFlag(vnode);
  3889. _unmount(vnode, instance, parentSuspense, true);
  3890. }
  3891. function pruneCache(filter) {
  3892. cache.forEach((vnode, key) => {
  3893. const name = getComponentName(vnode.type);
  3894. if (name && (!filter || !filter(name))) {
  3895. pruneCacheEntry(key);
  3896. }
  3897. });
  3898. }
  3899. function pruneCacheEntry(key) {
  3900. const cached = cache.get(key);
  3901. if (!current || cached.type !== current.type) {
  3902. unmount(cached);
  3903. }
  3904. else if (current) {
  3905. // current active instance should no longer be kept-alive.
  3906. // we can't unmount it now but it might be later, so reset its flag now.
  3907. resetShapeFlag(current);
  3908. }
  3909. cache.delete(key);
  3910. keys.delete(key);
  3911. }
  3912. // prune cache on include/exclude prop change
  3913. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  3914. include && pruneCache(name => matches(include, name));
  3915. exclude && pruneCache(name => !matches(exclude, name));
  3916. },
  3917. // prune post-render after `current` has been updated
  3918. { flush: 'post', deep: true });
  3919. // cache sub tree after render
  3920. let pendingCacheKey = null;
  3921. const cacheSubtree = () => {
  3922. // fix #1621, the pendingCacheKey could be 0
  3923. if (pendingCacheKey != null) {
  3924. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3925. }
  3926. };
  3927. onMounted(cacheSubtree);
  3928. onUpdated(cacheSubtree);
  3929. onBeforeUnmount(() => {
  3930. cache.forEach(cached => {
  3931. const { subTree, suspense } = instance;
  3932. const vnode = getInnerChild(subTree);
  3933. if (cached.type === vnode.type) {
  3934. // current instance will be unmounted as part of keep-alive's unmount
  3935. resetShapeFlag(vnode);
  3936. // but invoke its deactivated hook here
  3937. const da = vnode.component.da;
  3938. da && queuePostRenderEffect(da, suspense);
  3939. return;
  3940. }
  3941. unmount(cached);
  3942. });
  3943. });
  3944. return () => {
  3945. pendingCacheKey = null;
  3946. if (!slots.default) {
  3947. return null;
  3948. }
  3949. const children = slots.default();
  3950. const rawVNode = children[0];
  3951. if (children.length > 1) {
  3952. {
  3953. warn$1(`KeepAlive should contain exactly one component child.`);
  3954. }
  3955. current = null;
  3956. return children;
  3957. }
  3958. else if (!isVNode(rawVNode) ||
  3959. (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
  3960. !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
  3961. current = null;
  3962. return rawVNode;
  3963. }
  3964. let vnode = getInnerChild(rawVNode);
  3965. const comp = vnode.type;
  3966. // for async components, name check should be based in its loaded
  3967. // inner component if available
  3968. const name = getComponentName(isAsyncWrapper(vnode)
  3969. ? vnode.type.__asyncResolved || {}
  3970. : comp);
  3971. const { include, exclude, max } = props;
  3972. if ((include && (!name || !matches(include, name))) ||
  3973. (exclude && name && matches(exclude, name))) {
  3974. current = vnode;
  3975. return rawVNode;
  3976. }
  3977. const key = vnode.key == null ? comp : vnode.key;
  3978. const cachedVNode = cache.get(key);
  3979. // clone vnode if it's reused because we are going to mutate it
  3980. if (vnode.el) {
  3981. vnode = cloneVNode(vnode);
  3982. if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
  3983. rawVNode.ssContent = vnode;
  3984. }
  3985. }
  3986. // #1513 it's possible for the returned vnode to be cloned due to attr
  3987. // fallthrough or scopeId, so the vnode here may not be the final vnode
  3988. // that is mounted. Instead of caching it directly, we store the pending
  3989. // key and cache `instance.subTree` (the normalized vnode) in
  3990. // beforeMount/beforeUpdate hooks.
  3991. pendingCacheKey = key;
  3992. if (cachedVNode) {
  3993. // copy over mounted state
  3994. vnode.el = cachedVNode.el;
  3995. vnode.component = cachedVNode.component;
  3996. if (vnode.transition) {
  3997. // recursively update transition hooks on subTree
  3998. setTransitionHooks(vnode, vnode.transition);
  3999. }
  4000. // avoid vnode being mounted as fresh
  4001. vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
  4002. // make this key the freshest
  4003. keys.delete(key);
  4004. keys.add(key);
  4005. }
  4006. else {
  4007. keys.add(key);
  4008. // prune oldest entry
  4009. if (max && keys.size > parseInt(max, 10)) {
  4010. pruneCacheEntry(keys.values().next().value);
  4011. }
  4012. }
  4013. // avoid vnode being unmounted
  4014. vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4015. current = vnode;
  4016. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  4017. };
  4018. }
  4019. };
  4020. // export the public type for h/tsx inference
  4021. // also to avoid inline import() in generated d.ts files
  4022. const KeepAlive = KeepAliveImpl;
  4023. function matches(pattern, name) {
  4024. if (isArray(pattern)) {
  4025. return pattern.some((p) => matches(p, name));
  4026. }
  4027. else if (isString(pattern)) {
  4028. return pattern.split(',').includes(name);
  4029. }
  4030. else if (pattern.test) {
  4031. return pattern.test(name);
  4032. }
  4033. /* istanbul ignore next */
  4034. return false;
  4035. }
  4036. function onActivated(hook, target) {
  4037. registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
  4038. }
  4039. function onDeactivated(hook, target) {
  4040. registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
  4041. }
  4042. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4043. // cache the deactivate branch check wrapper for injected hooks so the same
  4044. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  4045. // deactivation check".
  4046. const wrappedHook = hook.__wdc ||
  4047. (hook.__wdc = () => {
  4048. // only fire the hook if the target instance is NOT in a deactivated branch.
  4049. let current = target;
  4050. while (current) {
  4051. if (current.isDeactivated) {
  4052. return;
  4053. }
  4054. current = current.parent;
  4055. }
  4056. return hook();
  4057. });
  4058. injectHook(type, wrappedHook, target);
  4059. // In addition to registering it on the target instance, we walk up the parent
  4060. // chain and register it on all ancestor instances that are keep-alive roots.
  4061. // This avoids the need to walk the entire component tree when invoking these
  4062. // hooks, and more importantly, avoids the need to track child components in
  4063. // arrays.
  4064. if (target) {
  4065. let current = target.parent;
  4066. while (current && current.parent) {
  4067. if (isKeepAlive(current.parent.vnode)) {
  4068. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4069. }
  4070. current = current.parent;
  4071. }
  4072. }
  4073. }
  4074. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4075. // injectHook wraps the original for error handling, so make sure to remove
  4076. // the wrapped version.
  4077. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  4078. onUnmounted(() => {
  4079. remove(keepAliveRoot[type], injected);
  4080. }, target);
  4081. }
  4082. function resetShapeFlag(vnode) {
  4083. let shapeFlag = vnode.shapeFlag;
  4084. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  4085. shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4086. }
  4087. if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  4088. shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
  4089. }
  4090. vnode.shapeFlag = shapeFlag;
  4091. }
  4092. function getInnerChild(vnode) {
  4093. return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
  4094. }
  4095. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4096. if (target) {
  4097. const hooks = target[type] || (target[type] = []);
  4098. // cache the error handling wrapper for injected hooks so the same hook
  4099. // can be properly deduped by the scheduler. "__weh" stands for "with error
  4100. // handling".
  4101. const wrappedHook = hook.__weh ||
  4102. (hook.__weh = (...args) => {
  4103. if (target.isUnmounted) {
  4104. return;
  4105. }
  4106. // disable tracking inside all lifecycle hooks
  4107. // since they can potentially be called inside effects.
  4108. pauseTracking();
  4109. // Set currentInstance during hook invocation.
  4110. // This assumes the hook does not synchronously trigger other hooks, which
  4111. // can only be false when the user does something really funky.
  4112. setCurrentInstance(target);
  4113. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4114. unsetCurrentInstance();
  4115. resetTracking();
  4116. return res;
  4117. });
  4118. if (prepend) {
  4119. hooks.unshift(wrappedHook);
  4120. }
  4121. else {
  4122. hooks.push(wrappedHook);
  4123. }
  4124. return wrappedHook;
  4125. }
  4126. else {
  4127. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  4128. warn$1(`${apiName} is called when there is no active component instance to be ` +
  4129. `associated with. ` +
  4130. `Lifecycle injection APIs can only be used during execution of setup().` +
  4131. (` If you are using async setup(), make sure to register lifecycle ` +
  4132. `hooks before the first await statement.`
  4133. ));
  4134. }
  4135. }
  4136. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  4137. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4138. (!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&
  4139. injectHook(lifecycle, hook, target);
  4140. const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
  4141. const onMounted = createHook("m" /* MOUNTED */);
  4142. const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
  4143. const onUpdated = createHook("u" /* UPDATED */);
  4144. const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
  4145. const onUnmounted = createHook("um" /* UNMOUNTED */);
  4146. const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);
  4147. const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
  4148. const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
  4149. function onErrorCaptured(hook, target = currentInstance) {
  4150. injectHook("ec" /* ERROR_CAPTURED */, hook, target);
  4151. }
  4152. /**
  4153. Runtime helper for applying directives to a vnode. Example usage:
  4154. const comp = resolveComponent('comp')
  4155. const foo = resolveDirective('foo')
  4156. const bar = resolveDirective('bar')
  4157. return withDirectives(h(comp), [
  4158. [foo, this.x],
  4159. [bar, this.y]
  4160. ])
  4161. */
  4162. function validateDirectiveName(name) {
  4163. if (isBuiltInDirective(name)) {
  4164. warn$1('Do not use built-in directive ids as custom directive id: ' + name);
  4165. }
  4166. }
  4167. /**
  4168. * Adds directives to a VNode.
  4169. */
  4170. function withDirectives(vnode, directives) {
  4171. const internalInstance = currentRenderingInstance;
  4172. if (internalInstance === null) {
  4173. warn$1(`withDirectives can only be used inside render functions.`);
  4174. return vnode;
  4175. }
  4176. const instance = getExposeProxy(internalInstance) ||
  4177. internalInstance.proxy;
  4178. const bindings = vnode.dirs || (vnode.dirs = []);
  4179. for (let i = 0; i < directives.length; i++) {
  4180. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  4181. if (isFunction(dir)) {
  4182. dir = {
  4183. mounted: dir,
  4184. updated: dir
  4185. };
  4186. }
  4187. if (dir.deep) {
  4188. traverse(value);
  4189. }
  4190. bindings.push({
  4191. dir,
  4192. instance,
  4193. value,
  4194. oldValue: void 0,
  4195. arg,
  4196. modifiers
  4197. });
  4198. }
  4199. return vnode;
  4200. }
  4201. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  4202. const bindings = vnode.dirs;
  4203. const oldBindings = prevVNode && prevVNode.dirs;
  4204. for (let i = 0; i < bindings.length; i++) {
  4205. const binding = bindings[i];
  4206. if (oldBindings) {
  4207. binding.oldValue = oldBindings[i].value;
  4208. }
  4209. let hook = binding.dir[name];
  4210. if (hook) {
  4211. // disable tracking inside all lifecycle hooks
  4212. // since they can potentially be called inside effects.
  4213. pauseTracking();
  4214. callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
  4215. vnode.el,
  4216. binding,
  4217. vnode,
  4218. prevVNode
  4219. ]);
  4220. resetTracking();
  4221. }
  4222. }
  4223. }
  4224. const COMPONENTS = 'components';
  4225. const DIRECTIVES = 'directives';
  4226. /**
  4227. * @private
  4228. */
  4229. function resolveComponent(name, maybeSelfReference) {
  4230. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  4231. }
  4232. const NULL_DYNAMIC_COMPONENT = Symbol();
  4233. /**
  4234. * @private
  4235. */
  4236. function resolveDynamicComponent(component) {
  4237. if (isString(component)) {
  4238. return resolveAsset(COMPONENTS, component, false) || component;
  4239. }
  4240. else {
  4241. // invalid types will fallthrough to createVNode and raise warning
  4242. return (component || NULL_DYNAMIC_COMPONENT);
  4243. }
  4244. }
  4245. /**
  4246. * @private
  4247. */
  4248. function resolveDirective(name) {
  4249. return resolveAsset(DIRECTIVES, name);
  4250. }
  4251. // implementation
  4252. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  4253. const instance = currentRenderingInstance || currentInstance;
  4254. if (instance) {
  4255. const Component = instance.type;
  4256. // explicit self name has highest priority
  4257. if (type === COMPONENTS) {
  4258. const selfName = getComponentName(Component, false /* do not include inferred name to avoid breaking existing code */);
  4259. if (selfName &&
  4260. (selfName === name ||
  4261. selfName === camelize(name) ||
  4262. selfName === capitalize(camelize(name)))) {
  4263. return Component;
  4264. }
  4265. }
  4266. const res =
  4267. // local registration
  4268. // check instance[type] first which is resolved for options API
  4269. resolve(instance[type] || Component[type], name) ||
  4270. // global registration
  4271. resolve(instance.appContext[type], name);
  4272. if (!res && maybeSelfReference) {
  4273. // fallback to implicit self-reference
  4274. return Component;
  4275. }
  4276. if (warnMissing && !res) {
  4277. const extra = type === COMPONENTS
  4278. ? `\nIf this is a native custom element, make sure to exclude it from ` +
  4279. `component resolution via compilerOptions.isCustomElement.`
  4280. : ``;
  4281. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  4282. }
  4283. return res;
  4284. }
  4285. else {
  4286. warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
  4287. `can only be used in render() or setup().`);
  4288. }
  4289. }
  4290. function resolve(registry, name) {
  4291. return (registry &&
  4292. (registry[name] ||
  4293. registry[camelize(name)] ||
  4294. registry[capitalize(camelize(name))]));
  4295. }
  4296. /**
  4297. * Actual implementation
  4298. */
  4299. function renderList(source, renderItem, cache, index) {
  4300. let ret;
  4301. const cached = (cache && cache[index]);
  4302. if (isArray(source) || isString(source)) {
  4303. ret = new Array(source.length);
  4304. for (let i = 0, l = source.length; i < l; i++) {
  4305. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  4306. }
  4307. }
  4308. else if (typeof source === 'number') {
  4309. if (!Number.isInteger(source)) {
  4310. warn$1(`The v-for range expect an integer value but got ${source}.`);
  4311. }
  4312. ret = new Array(source);
  4313. for (let i = 0; i < source; i++) {
  4314. ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
  4315. }
  4316. }
  4317. else if (isObject(source)) {
  4318. if (source[Symbol.iterator]) {
  4319. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  4320. }
  4321. else {
  4322. const keys = Object.keys(source);
  4323. ret = new Array(keys.length);
  4324. for (let i = 0, l = keys.length; i < l; i++) {
  4325. const key = keys[i];
  4326. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4327. }
  4328. }
  4329. }
  4330. else {
  4331. ret = [];
  4332. }
  4333. if (cache) {
  4334. cache[index] = ret;
  4335. }
  4336. return ret;
  4337. }
  4338. /**
  4339. * Compiler runtime helper for creating dynamic slots object
  4340. * @private
  4341. */
  4342. function createSlots(slots, dynamicSlots) {
  4343. for (let i = 0; i < dynamicSlots.length; i++) {
  4344. const slot = dynamicSlots[i];
  4345. // array of dynamic slot generated by <template v-for="..." #[...]>
  4346. if (isArray(slot)) {
  4347. for (let j = 0; j < slot.length; j++) {
  4348. slots[slot[j].name] = slot[j].fn;
  4349. }
  4350. }
  4351. else if (slot) {
  4352. // conditional single slot generated by <template v-if="..." #foo>
  4353. slots[slot.name] = slot.fn;
  4354. }
  4355. }
  4356. return slots;
  4357. }
  4358. /**
  4359. * Compiler runtime helper for rendering `<slot/>`
  4360. * @private
  4361. */
  4362. function renderSlot(slots, name, props = {},
  4363. // this is not a user-facing function, so the fallback is always generated by
  4364. // the compiler and guaranteed to be a function returning an array
  4365. fallback, noSlotted) {
  4366. if (currentRenderingInstance.isCE ||
  4367. (currentRenderingInstance.parent &&
  4368. isAsyncWrapper(currentRenderingInstance.parent) &&
  4369. currentRenderingInstance.parent.isCE)) {
  4370. return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
  4371. }
  4372. let slot = slots[name];
  4373. if (slot && slot.length > 1) {
  4374. warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  4375. `function. You need to mark this component with $dynamic-slots in the ` +
  4376. `parent template.`);
  4377. slot = () => [];
  4378. }
  4379. // a compiled slot disables block tracking by default to avoid manual
  4380. // invocation interfering with template-based block tracking, but in
  4381. // `renderSlot` we can be sure that it's template-based so we can force
  4382. // enable it.
  4383. if (slot && slot._c) {
  4384. slot._d = false;
  4385. }
  4386. openBlock();
  4387. const validSlotContent = slot && ensureValidVNode(slot(props));
  4388. const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
  4389. ? 64 /* STABLE_FRAGMENT */
  4390. : -2 /* BAIL */);
  4391. if (!noSlotted && rendered.scopeId) {
  4392. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  4393. }
  4394. if (slot && slot._c) {
  4395. slot._d = true;
  4396. }
  4397. return rendered;
  4398. }
  4399. function ensureValidVNode(vnodes) {
  4400. return vnodes.some(child => {
  4401. if (!isVNode(child))
  4402. return true;
  4403. if (child.type === Comment)
  4404. return false;
  4405. if (child.type === Fragment &&
  4406. !ensureValidVNode(child.children))
  4407. return false;
  4408. return true;
  4409. })
  4410. ? vnodes
  4411. : null;
  4412. }
  4413. /**
  4414. * For prefixing keys in v-on="obj" with "on"
  4415. * @private
  4416. */
  4417. function toHandlers(obj) {
  4418. const ret = {};
  4419. if (!isObject(obj)) {
  4420. warn$1(`v-on with no argument expects an object value.`);
  4421. return ret;
  4422. }
  4423. for (const key in obj) {
  4424. ret[toHandlerKey(key)] = obj[key];
  4425. }
  4426. return ret;
  4427. }
  4428. /**
  4429. * #2437 In Vue 3, functional components do not have a public instance proxy but
  4430. * they exist in the internal parent chain. For code that relies on traversing
  4431. * public $parent chains, skip functional ones and go to the parent instead.
  4432. */
  4433. const getPublicInstance = (i) => {
  4434. if (!i)
  4435. return null;
  4436. if (isStatefulComponent(i))
  4437. return getExposeProxy(i) || i.proxy;
  4438. return getPublicInstance(i.parent);
  4439. };
  4440. const publicPropertiesMap =
  4441. // Move PURE marker to new line to workaround compiler discarding it
  4442. // due to type annotation
  4443. /*#__PURE__*/ extend(Object.create(null), {
  4444. $: i => i,
  4445. $el: i => i.vnode.el,
  4446. $data: i => i.data,
  4447. $props: i => (shallowReadonly(i.props) ),
  4448. $attrs: i => (shallowReadonly(i.attrs) ),
  4449. $slots: i => (shallowReadonly(i.slots) ),
  4450. $refs: i => (shallowReadonly(i.refs) ),
  4451. $parent: i => getPublicInstance(i.parent),
  4452. $root: i => getPublicInstance(i.root),
  4453. $emit: i => i.emit,
  4454. $options: i => (resolveMergedOptions(i) ),
  4455. $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
  4456. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  4457. $watch: i => (instanceWatch.bind(i) )
  4458. });
  4459. const isReservedPrefix = (key) => key === '_' || key === '$';
  4460. const PublicInstanceProxyHandlers = {
  4461. get({ _: instance }, key) {
  4462. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4463. // for internal formatters to know that this is a Vue instance
  4464. if (key === '__isVue') {
  4465. return true;
  4466. }
  4467. // prioritize <script setup> bindings during dev.
  4468. // this allows even properties that start with _ or $ to be used - so that
  4469. // it aligns with the production behavior where the render fn is inlined and
  4470. // indeed has access to all declared variables.
  4471. if (setupState !== EMPTY_OBJ &&
  4472. setupState.__isScriptSetup &&
  4473. hasOwn(setupState, key)) {
  4474. return setupState[key];
  4475. }
  4476. // data / props / ctx
  4477. // This getter gets called for every property access on the render context
  4478. // during render and is a major hotspot. The most expensive part of this
  4479. // is the multiple hasOwn() calls. It's much faster to do a simple property
  4480. // access on a plain object, so we use an accessCache object (with null
  4481. // prototype) to memoize what access type a key corresponds to.
  4482. let normalizedProps;
  4483. if (key[0] !== '$') {
  4484. const n = accessCache[key];
  4485. if (n !== undefined) {
  4486. switch (n) {
  4487. case 1 /* SETUP */:
  4488. return setupState[key];
  4489. case 2 /* DATA */:
  4490. return data[key];
  4491. case 4 /* CONTEXT */:
  4492. return ctx[key];
  4493. case 3 /* PROPS */:
  4494. return props[key];
  4495. // default: just fallthrough
  4496. }
  4497. }
  4498. else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  4499. accessCache[key] = 1 /* SETUP */;
  4500. return setupState[key];
  4501. }
  4502. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4503. accessCache[key] = 2 /* DATA */;
  4504. return data[key];
  4505. }
  4506. else if (
  4507. // only cache other properties when instance has declared (thus stable)
  4508. // props
  4509. (normalizedProps = instance.propsOptions[0]) &&
  4510. hasOwn(normalizedProps, key)) {
  4511. accessCache[key] = 3 /* PROPS */;
  4512. return props[key];
  4513. }
  4514. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4515. accessCache[key] = 4 /* CONTEXT */;
  4516. return ctx[key];
  4517. }
  4518. else if (shouldCacheAccess) {
  4519. accessCache[key] = 0 /* OTHER */;
  4520. }
  4521. }
  4522. const publicGetter = publicPropertiesMap[key];
  4523. let cssModule, globalProperties;
  4524. // public $xxx properties
  4525. if (publicGetter) {
  4526. if (key === '$attrs') {
  4527. track(instance, "get" /* GET */, key);
  4528. markAttrsAccessed();
  4529. }
  4530. return publicGetter(instance);
  4531. }
  4532. else if (
  4533. // css module (injected by vue-loader)
  4534. (cssModule = type.__cssModules) &&
  4535. (cssModule = cssModule[key])) {
  4536. return cssModule;
  4537. }
  4538. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4539. // user may set custom properties to `this` that start with `$`
  4540. accessCache[key] = 4 /* CONTEXT */;
  4541. return ctx[key];
  4542. }
  4543. else if (
  4544. // global properties
  4545. ((globalProperties = appContext.config.globalProperties),
  4546. hasOwn(globalProperties, key))) {
  4547. {
  4548. return globalProperties[key];
  4549. }
  4550. }
  4551. else if (currentRenderingInstance &&
  4552. (!isString(key) ||
  4553. // #1091 avoid internal isRef/isVNode checks on component instance leading
  4554. // to infinite warning loop
  4555. key.indexOf('__v') !== 0)) {
  4556. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4557. warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  4558. `character ("$" or "_") and is not proxied on the render context.`);
  4559. }
  4560. else if (instance === currentRenderingInstance) {
  4561. warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
  4562. `but is not defined on instance.`);
  4563. }
  4564. }
  4565. },
  4566. set({ _: instance }, key, value) {
  4567. const { data, setupState, ctx } = instance;
  4568. if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  4569. setupState[key] = value;
  4570. return true;
  4571. }
  4572. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4573. data[key] = value;
  4574. return true;
  4575. }
  4576. else if (hasOwn(instance.props, key)) {
  4577. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
  4578. return false;
  4579. }
  4580. if (key[0] === '$' && key.slice(1) in instance) {
  4581. warn$1(`Attempting to mutate public property "${key}". ` +
  4582. `Properties starting with $ are reserved and readonly.`, instance);
  4583. return false;
  4584. }
  4585. else {
  4586. if (key in instance.appContext.config.globalProperties) {
  4587. Object.defineProperty(ctx, key, {
  4588. enumerable: true,
  4589. configurable: true,
  4590. value
  4591. });
  4592. }
  4593. else {
  4594. ctx[key] = value;
  4595. }
  4596. }
  4597. return true;
  4598. },
  4599. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  4600. let normalizedProps;
  4601. return (!!accessCache[key] ||
  4602. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  4603. (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
  4604. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  4605. hasOwn(ctx, key) ||
  4606. hasOwn(publicPropertiesMap, key) ||
  4607. hasOwn(appContext.config.globalProperties, key));
  4608. },
  4609. defineProperty(target, key, descriptor) {
  4610. if (descriptor.get != null) {
  4611. // invalidate key cache of a getter based property #5417
  4612. target._.accessCache[key] = 0;
  4613. }
  4614. else if (hasOwn(descriptor, 'value')) {
  4615. this.set(target, key, descriptor.value, null);
  4616. }
  4617. return Reflect.defineProperty(target, key, descriptor);
  4618. }
  4619. };
  4620. {
  4621. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4622. warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  4623. `The keys will be empty in production mode to avoid performance overhead.`);
  4624. return Reflect.ownKeys(target);
  4625. };
  4626. }
  4627. const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
  4628. get(target, key) {
  4629. // fast path for unscopables when using `with` block
  4630. if (key === Symbol.unscopables) {
  4631. return;
  4632. }
  4633. return PublicInstanceProxyHandlers.get(target, key, target);
  4634. },
  4635. has(_, key) {
  4636. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  4637. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4638. warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  4639. }
  4640. return has;
  4641. }
  4642. });
  4643. // dev only
  4644. // In dev mode, the proxy target exposes the same properties as seen on `this`
  4645. // for easier console inspection. In prod mode it will be an empty object so
  4646. // these properties definitions can be skipped.
  4647. function createDevRenderContext(instance) {
  4648. const target = {};
  4649. // expose internal instance for proxy handlers
  4650. Object.defineProperty(target, `_`, {
  4651. configurable: true,
  4652. enumerable: false,
  4653. get: () => instance
  4654. });
  4655. // expose public properties
  4656. Object.keys(publicPropertiesMap).forEach(key => {
  4657. Object.defineProperty(target, key, {
  4658. configurable: true,
  4659. enumerable: false,
  4660. get: () => publicPropertiesMap[key](instance),
  4661. // intercepted by the proxy so no need for implementation,
  4662. // but needed to prevent set errors
  4663. set: NOOP
  4664. });
  4665. });
  4666. return target;
  4667. }
  4668. // dev only
  4669. function exposePropsOnRenderContext(instance) {
  4670. const { ctx, propsOptions: [propsOptions] } = instance;
  4671. if (propsOptions) {
  4672. Object.keys(propsOptions).forEach(key => {
  4673. Object.defineProperty(ctx, key, {
  4674. enumerable: true,
  4675. configurable: true,
  4676. get: () => instance.props[key],
  4677. set: NOOP
  4678. });
  4679. });
  4680. }
  4681. }
  4682. // dev only
  4683. function exposeSetupStateOnRenderContext(instance) {
  4684. const { ctx, setupState } = instance;
  4685. Object.keys(toRaw(setupState)).forEach(key => {
  4686. if (!setupState.__isScriptSetup) {
  4687. if (isReservedPrefix(key[0])) {
  4688. warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  4689. `which are reserved prefixes for Vue internals.`);
  4690. return;
  4691. }
  4692. Object.defineProperty(ctx, key, {
  4693. enumerable: true,
  4694. configurable: true,
  4695. get: () => setupState[key],
  4696. set: NOOP
  4697. });
  4698. }
  4699. });
  4700. }
  4701. function createDuplicateChecker() {
  4702. const cache = Object.create(null);
  4703. return (type, key) => {
  4704. if (cache[key]) {
  4705. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4706. }
  4707. else {
  4708. cache[key] = type;
  4709. }
  4710. };
  4711. }
  4712. let shouldCacheAccess = true;
  4713. function applyOptions(instance) {
  4714. const options = resolveMergedOptions(instance);
  4715. const publicThis = instance.proxy;
  4716. const ctx = instance.ctx;
  4717. // do not cache property access on public proxy during state initialization
  4718. shouldCacheAccess = false;
  4719. // call beforeCreate first before accessing other options since
  4720. // the hook may mutate resolved options (#2791)
  4721. if (options.beforeCreate) {
  4722. callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
  4723. }
  4724. const {
  4725. // state
  4726. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  4727. // lifecycle
  4728. created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
  4729. // public API
  4730. expose, inheritAttrs,
  4731. // assets
  4732. components, directives, filters } = options;
  4733. const checkDuplicateProperties = createDuplicateChecker() ;
  4734. {
  4735. const [propsOptions] = instance.propsOptions;
  4736. if (propsOptions) {
  4737. for (const key in propsOptions) {
  4738. checkDuplicateProperties("Props" /* PROPS */, key);
  4739. }
  4740. }
  4741. }
  4742. // options initialization order (to be consistent with Vue 2):
  4743. // - props (already done outside of this function)
  4744. // - inject
  4745. // - methods
  4746. // - data (deferred since it relies on `this` access)
  4747. // - computed
  4748. // - watch (deferred since it relies on `this` access)
  4749. if (injectOptions) {
  4750. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  4751. }
  4752. if (methods) {
  4753. for (const key in methods) {
  4754. const methodHandler = methods[key];
  4755. if (isFunction(methodHandler)) {
  4756. // In dev mode, we use the `createRenderContext` function to define
  4757. // methods to the proxy target, and those are read-only but
  4758. // reconfigurable, so it needs to be redefined here
  4759. {
  4760. Object.defineProperty(ctx, key, {
  4761. value: methodHandler.bind(publicThis),
  4762. configurable: true,
  4763. enumerable: true,
  4764. writable: true
  4765. });
  4766. }
  4767. {
  4768. checkDuplicateProperties("Methods" /* METHODS */, key);
  4769. }
  4770. }
  4771. else {
  4772. warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  4773. `Did you reference the function correctly?`);
  4774. }
  4775. }
  4776. }
  4777. if (dataOptions) {
  4778. if (!isFunction(dataOptions)) {
  4779. warn$1(`The data option must be a function. ` +
  4780. `Plain object usage is no longer supported.`);
  4781. }
  4782. const data = dataOptions.call(publicThis, publicThis);
  4783. if (isPromise(data)) {
  4784. warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
  4785. `intend to perform data fetching before component renders, use ` +
  4786. `async setup() + <Suspense>.`);
  4787. }
  4788. if (!isObject(data)) {
  4789. warn$1(`data() should return an object.`);
  4790. }
  4791. else {
  4792. instance.data = reactive(data);
  4793. {
  4794. for (const key in data) {
  4795. checkDuplicateProperties("Data" /* DATA */, key);
  4796. // expose data on ctx during dev
  4797. if (!isReservedPrefix(key[0])) {
  4798. Object.defineProperty(ctx, key, {
  4799. configurable: true,
  4800. enumerable: true,
  4801. get: () => data[key],
  4802. set: NOOP
  4803. });
  4804. }
  4805. }
  4806. }
  4807. }
  4808. }
  4809. // state initialization complete at this point - start caching access
  4810. shouldCacheAccess = true;
  4811. if (computedOptions) {
  4812. for (const key in computedOptions) {
  4813. const opt = computedOptions[key];
  4814. const get = isFunction(opt)
  4815. ? opt.bind(publicThis, publicThis)
  4816. : isFunction(opt.get)
  4817. ? opt.get.bind(publicThis, publicThis)
  4818. : NOOP;
  4819. if (get === NOOP) {
  4820. warn$1(`Computed property "${key}" has no getter.`);
  4821. }
  4822. const set = !isFunction(opt) && isFunction(opt.set)
  4823. ? opt.set.bind(publicThis)
  4824. : () => {
  4825. warn$1(`Write operation failed: computed property "${key}" is readonly.`);
  4826. }
  4827. ;
  4828. const c = computed$1({
  4829. get,
  4830. set
  4831. });
  4832. Object.defineProperty(ctx, key, {
  4833. enumerable: true,
  4834. configurable: true,
  4835. get: () => c.value,
  4836. set: v => (c.value = v)
  4837. });
  4838. {
  4839. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  4840. }
  4841. }
  4842. }
  4843. if (watchOptions) {
  4844. for (const key in watchOptions) {
  4845. createWatcher(watchOptions[key], ctx, publicThis, key);
  4846. }
  4847. }
  4848. if (provideOptions) {
  4849. const provides = isFunction(provideOptions)
  4850. ? provideOptions.call(publicThis)
  4851. : provideOptions;
  4852. Reflect.ownKeys(provides).forEach(key => {
  4853. provide(key, provides[key]);
  4854. });
  4855. }
  4856. if (created) {
  4857. callHook(created, instance, "c" /* CREATED */);
  4858. }
  4859. function registerLifecycleHook(register, hook) {
  4860. if (isArray(hook)) {
  4861. hook.forEach(_hook => register(_hook.bind(publicThis)));
  4862. }
  4863. else if (hook) {
  4864. register(hook.bind(publicThis));
  4865. }
  4866. }
  4867. registerLifecycleHook(onBeforeMount, beforeMount);
  4868. registerLifecycleHook(onMounted, mounted);
  4869. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4870. registerLifecycleHook(onUpdated, updated);
  4871. registerLifecycleHook(onActivated, activated);
  4872. registerLifecycleHook(onDeactivated, deactivated);
  4873. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4874. registerLifecycleHook(onRenderTracked, renderTracked);
  4875. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4876. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4877. registerLifecycleHook(onUnmounted, unmounted);
  4878. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4879. if (isArray(expose)) {
  4880. if (expose.length) {
  4881. const exposed = instance.exposed || (instance.exposed = {});
  4882. expose.forEach(key => {
  4883. Object.defineProperty(exposed, key, {
  4884. get: () => publicThis[key],
  4885. set: val => (publicThis[key] = val)
  4886. });
  4887. });
  4888. }
  4889. else if (!instance.exposed) {
  4890. instance.exposed = {};
  4891. }
  4892. }
  4893. // options that are handled when creating the instance but also need to be
  4894. // applied from mixins
  4895. if (render && instance.render === NOOP) {
  4896. instance.render = render;
  4897. }
  4898. if (inheritAttrs != null) {
  4899. instance.inheritAttrs = inheritAttrs;
  4900. }
  4901. // asset options.
  4902. if (components)
  4903. instance.components = components;
  4904. if (directives)
  4905. instance.directives = directives;
  4906. }
  4907. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
  4908. if (isArray(injectOptions)) {
  4909. injectOptions = normalizeInject(injectOptions);
  4910. }
  4911. for (const key in injectOptions) {
  4912. const opt = injectOptions[key];
  4913. let injected;
  4914. if (isObject(opt)) {
  4915. if ('default' in opt) {
  4916. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  4917. }
  4918. else {
  4919. injected = inject(opt.from || key);
  4920. }
  4921. }
  4922. else {
  4923. injected = inject(opt);
  4924. }
  4925. if (isRef(injected)) {
  4926. // TODO remove the check in 3.3
  4927. if (unwrapRef) {
  4928. Object.defineProperty(ctx, key, {
  4929. enumerable: true,
  4930. configurable: true,
  4931. get: () => injected.value,
  4932. set: v => (injected.value = v)
  4933. });
  4934. }
  4935. else {
  4936. {
  4937. warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
  4938. `and no longer needs \`.value\` in the next minor release. ` +
  4939. `To opt-in to the new behavior now, ` +
  4940. `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
  4941. `temporary and will not be needed in the future.)`);
  4942. }
  4943. ctx[key] = injected;
  4944. }
  4945. }
  4946. else {
  4947. ctx[key] = injected;
  4948. }
  4949. {
  4950. checkDuplicateProperties("Inject" /* INJECT */, key);
  4951. }
  4952. }
  4953. }
  4954. function callHook(hook, instance, type) {
  4955. callWithAsyncErrorHandling(isArray(hook)
  4956. ? hook.map(h => h.bind(instance.proxy))
  4957. : hook.bind(instance.proxy), instance, type);
  4958. }
  4959. function createWatcher(raw, ctx, publicThis, key) {
  4960. const getter = key.includes('.')
  4961. ? createPathGetter(publicThis, key)
  4962. : () => publicThis[key];
  4963. if (isString(raw)) {
  4964. const handler = ctx[raw];
  4965. if (isFunction(handler)) {
  4966. watch(getter, handler);
  4967. }
  4968. else {
  4969. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  4970. }
  4971. }
  4972. else if (isFunction(raw)) {
  4973. watch(getter, raw.bind(publicThis));
  4974. }
  4975. else if (isObject(raw)) {
  4976. if (isArray(raw)) {
  4977. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  4978. }
  4979. else {
  4980. const handler = isFunction(raw.handler)
  4981. ? raw.handler.bind(publicThis)
  4982. : ctx[raw.handler];
  4983. if (isFunction(handler)) {
  4984. watch(getter, handler, raw);
  4985. }
  4986. else {
  4987. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  4988. }
  4989. }
  4990. }
  4991. else {
  4992. warn$1(`Invalid watch option: "${key}"`, raw);
  4993. }
  4994. }
  4995. /**
  4996. * Resolve merged options and cache it on the component.
  4997. * This is done only once per-component since the merging does not involve
  4998. * instances.
  4999. */
  5000. function resolveMergedOptions(instance) {
  5001. const base = instance.type;
  5002. const { mixins, extends: extendsOptions } = base;
  5003. const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
  5004. const cached = cache.get(base);
  5005. let resolved;
  5006. if (cached) {
  5007. resolved = cached;
  5008. }
  5009. else if (!globalMixins.length && !mixins && !extendsOptions) {
  5010. {
  5011. resolved = base;
  5012. }
  5013. }
  5014. else {
  5015. resolved = {};
  5016. if (globalMixins.length) {
  5017. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  5018. }
  5019. mergeOptions(resolved, base, optionMergeStrategies);
  5020. }
  5021. cache.set(base, resolved);
  5022. return resolved;
  5023. }
  5024. function mergeOptions(to, from, strats, asMixin = false) {
  5025. const { mixins, extends: extendsOptions } = from;
  5026. if (extendsOptions) {
  5027. mergeOptions(to, extendsOptions, strats, true);
  5028. }
  5029. if (mixins) {
  5030. mixins.forEach((m) => mergeOptions(to, m, strats, true));
  5031. }
  5032. for (const key in from) {
  5033. if (asMixin && key === 'expose') {
  5034. warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
  5035. `It should only be declared in the base component itself.`);
  5036. }
  5037. else {
  5038. const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
  5039. to[key] = strat ? strat(to[key], from[key]) : from[key];
  5040. }
  5041. }
  5042. return to;
  5043. }
  5044. const internalOptionMergeStrats = {
  5045. data: mergeDataFn,
  5046. props: mergeObjectOptions,
  5047. emits: mergeObjectOptions,
  5048. // objects
  5049. methods: mergeObjectOptions,
  5050. computed: mergeObjectOptions,
  5051. // lifecycle
  5052. beforeCreate: mergeAsArray,
  5053. created: mergeAsArray,
  5054. beforeMount: mergeAsArray,
  5055. mounted: mergeAsArray,
  5056. beforeUpdate: mergeAsArray,
  5057. updated: mergeAsArray,
  5058. beforeDestroy: mergeAsArray,
  5059. beforeUnmount: mergeAsArray,
  5060. destroyed: mergeAsArray,
  5061. unmounted: mergeAsArray,
  5062. activated: mergeAsArray,
  5063. deactivated: mergeAsArray,
  5064. errorCaptured: mergeAsArray,
  5065. serverPrefetch: mergeAsArray,
  5066. // assets
  5067. components: mergeObjectOptions,
  5068. directives: mergeObjectOptions,
  5069. // watch
  5070. watch: mergeWatchOptions,
  5071. // provide / inject
  5072. provide: mergeDataFn,
  5073. inject: mergeInject
  5074. };
  5075. function mergeDataFn(to, from) {
  5076. if (!from) {
  5077. return to;
  5078. }
  5079. if (!to) {
  5080. return from;
  5081. }
  5082. return function mergedDataFn() {
  5083. return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  5084. };
  5085. }
  5086. function mergeInject(to, from) {
  5087. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5088. }
  5089. function normalizeInject(raw) {
  5090. if (isArray(raw)) {
  5091. const res = {};
  5092. for (let i = 0; i < raw.length; i++) {
  5093. res[raw[i]] = raw[i];
  5094. }
  5095. return res;
  5096. }
  5097. return raw;
  5098. }
  5099. function mergeAsArray(to, from) {
  5100. return to ? [...new Set([].concat(to, from))] : from;
  5101. }
  5102. function mergeObjectOptions(to, from) {
  5103. return to ? extend(extend(Object.create(null), to), from) : from;
  5104. }
  5105. function mergeWatchOptions(to, from) {
  5106. if (!to)
  5107. return from;
  5108. if (!from)
  5109. return to;
  5110. const merged = extend(Object.create(null), to);
  5111. for (const key in from) {
  5112. merged[key] = mergeAsArray(to[key], from[key]);
  5113. }
  5114. return merged;
  5115. }
  5116. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  5117. isSSR = false) {
  5118. const props = {};
  5119. const attrs = {};
  5120. def(attrs, InternalObjectKey, 1);
  5121. instance.propsDefaults = Object.create(null);
  5122. setFullProps(instance, rawProps, props, attrs);
  5123. // ensure all declared prop keys are present
  5124. for (const key in instance.propsOptions[0]) {
  5125. if (!(key in props)) {
  5126. props[key] = undefined;
  5127. }
  5128. }
  5129. // validation
  5130. {
  5131. validateProps(rawProps || {}, props, instance);
  5132. }
  5133. if (isStateful) {
  5134. // stateful
  5135. instance.props = isSSR ? props : shallowReactive(props);
  5136. }
  5137. else {
  5138. if (!instance.type.props) {
  5139. // functional w/ optional props, props === attrs
  5140. instance.props = attrs;
  5141. }
  5142. else {
  5143. // functional w/ declared props
  5144. instance.props = props;
  5145. }
  5146. }
  5147. instance.attrs = attrs;
  5148. }
  5149. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5150. const { props, attrs, vnode: { patchFlag } } = instance;
  5151. const rawCurrentProps = toRaw(props);
  5152. const [options] = instance.propsOptions;
  5153. let hasAttrsChanged = false;
  5154. if (
  5155. // always force full diff in dev
  5156. // - #1942 if hmr is enabled with sfc component
  5157. // - vite#872 non-sfc component used by sfc component
  5158. !((instance.type.__hmrId ||
  5159. (instance.parent && instance.parent.type.__hmrId))) &&
  5160. (optimized || patchFlag > 0) &&
  5161. !(patchFlag & 16 /* FULL_PROPS */)) {
  5162. if (patchFlag & 8 /* PROPS */) {
  5163. // Compiler-generated props & no keys change, just set the updated
  5164. // the props.
  5165. const propsToUpdate = instance.vnode.dynamicProps;
  5166. for (let i = 0; i < propsToUpdate.length; i++) {
  5167. let key = propsToUpdate[i];
  5168. // skip if the prop key is a declared emit event listener
  5169. if (isEmitListener(instance.emitsOptions, key)) {
  5170. continue;
  5171. }
  5172. // PROPS flag guarantees rawProps to be non-null
  5173. const value = rawProps[key];
  5174. if (options) {
  5175. // attr / props separation was done on init and will be consistent
  5176. // in this code path, so just check if attrs have it.
  5177. if (hasOwn(attrs, key)) {
  5178. if (value !== attrs[key]) {
  5179. attrs[key] = value;
  5180. hasAttrsChanged = true;
  5181. }
  5182. }
  5183. else {
  5184. const camelizedKey = camelize(key);
  5185. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  5186. }
  5187. }
  5188. else {
  5189. if (value !== attrs[key]) {
  5190. attrs[key] = value;
  5191. hasAttrsChanged = true;
  5192. }
  5193. }
  5194. }
  5195. }
  5196. }
  5197. else {
  5198. // full props update.
  5199. if (setFullProps(instance, rawProps, props, attrs)) {
  5200. hasAttrsChanged = true;
  5201. }
  5202. // in case of dynamic props, check if we need to delete keys from
  5203. // the props object
  5204. let kebabKey;
  5205. for (const key in rawCurrentProps) {
  5206. if (!rawProps ||
  5207. // for camelCase
  5208. (!hasOwn(rawProps, key) &&
  5209. // it's possible the original props was passed in as kebab-case
  5210. // and converted to camelCase (#955)
  5211. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  5212. if (options) {
  5213. if (rawPrevProps &&
  5214. // for camelCase
  5215. (rawPrevProps[key] !== undefined ||
  5216. // for kebab-case
  5217. rawPrevProps[kebabKey] !== undefined)) {
  5218. props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
  5219. }
  5220. }
  5221. else {
  5222. delete props[key];
  5223. }
  5224. }
  5225. }
  5226. // in the case of functional component w/o props declaration, props and
  5227. // attrs point to the same object so it should already have been updated.
  5228. if (attrs !== rawCurrentProps) {
  5229. for (const key in attrs) {
  5230. if (!rawProps ||
  5231. (!hasOwn(rawProps, key) &&
  5232. (!false ))) {
  5233. delete attrs[key];
  5234. hasAttrsChanged = true;
  5235. }
  5236. }
  5237. }
  5238. }
  5239. // trigger updates for $attrs in case it's used in component slots
  5240. if (hasAttrsChanged) {
  5241. trigger(instance, "set" /* SET */, '$attrs');
  5242. }
  5243. {
  5244. validateProps(rawProps || {}, props, instance);
  5245. }
  5246. }
  5247. function setFullProps(instance, rawProps, props, attrs) {
  5248. const [options, needCastKeys] = instance.propsOptions;
  5249. let hasAttrsChanged = false;
  5250. let rawCastValues;
  5251. if (rawProps) {
  5252. for (let key in rawProps) {
  5253. // key, ref are reserved and never passed down
  5254. if (isReservedProp(key)) {
  5255. continue;
  5256. }
  5257. const value = rawProps[key];
  5258. // prop option names are camelized during normalization, so to support
  5259. // kebab -> camel conversion here we need to camelize the key.
  5260. let camelKey;
  5261. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  5262. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5263. props[camelKey] = value;
  5264. }
  5265. else {
  5266. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5267. }
  5268. }
  5269. else if (!isEmitListener(instance.emitsOptions, key)) {
  5270. if (!(key in attrs) || value !== attrs[key]) {
  5271. attrs[key] = value;
  5272. hasAttrsChanged = true;
  5273. }
  5274. }
  5275. }
  5276. }
  5277. if (needCastKeys) {
  5278. const rawCurrentProps = toRaw(props);
  5279. const castValues = rawCastValues || EMPTY_OBJ;
  5280. for (let i = 0; i < needCastKeys.length; i++) {
  5281. const key = needCastKeys[i];
  5282. props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
  5283. }
  5284. }
  5285. return hasAttrsChanged;
  5286. }
  5287. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5288. const opt = options[key];
  5289. if (opt != null) {
  5290. const hasDefault = hasOwn(opt, 'default');
  5291. // default values
  5292. if (hasDefault && value === undefined) {
  5293. const defaultValue = opt.default;
  5294. if (opt.type !== Function && isFunction(defaultValue)) {
  5295. const { propsDefaults } = instance;
  5296. if (key in propsDefaults) {
  5297. value = propsDefaults[key];
  5298. }
  5299. else {
  5300. setCurrentInstance(instance);
  5301. value = propsDefaults[key] = defaultValue.call(null, props);
  5302. unsetCurrentInstance();
  5303. }
  5304. }
  5305. else {
  5306. value = defaultValue;
  5307. }
  5308. }
  5309. // boolean casting
  5310. if (opt[0 /* shouldCast */]) {
  5311. if (isAbsent && !hasDefault) {
  5312. value = false;
  5313. }
  5314. else if (opt[1 /* shouldCastTrue */] &&
  5315. (value === '' || value === hyphenate(key))) {
  5316. value = true;
  5317. }
  5318. }
  5319. }
  5320. return value;
  5321. }
  5322. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5323. const cache = appContext.propsCache;
  5324. const cached = cache.get(comp);
  5325. if (cached) {
  5326. return cached;
  5327. }
  5328. const raw = comp.props;
  5329. const normalized = {};
  5330. const needCastKeys = [];
  5331. // apply mixin/extends props
  5332. let hasExtends = false;
  5333. if (!isFunction(comp)) {
  5334. const extendProps = (raw) => {
  5335. hasExtends = true;
  5336. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  5337. extend(normalized, props);
  5338. if (keys)
  5339. needCastKeys.push(...keys);
  5340. };
  5341. if (!asMixin && appContext.mixins.length) {
  5342. appContext.mixins.forEach(extendProps);
  5343. }
  5344. if (comp.extends) {
  5345. extendProps(comp.extends);
  5346. }
  5347. if (comp.mixins) {
  5348. comp.mixins.forEach(extendProps);
  5349. }
  5350. }
  5351. if (!raw && !hasExtends) {
  5352. cache.set(comp, EMPTY_ARR);
  5353. return EMPTY_ARR;
  5354. }
  5355. if (isArray(raw)) {
  5356. for (let i = 0; i < raw.length; i++) {
  5357. if (!isString(raw[i])) {
  5358. warn$1(`props must be strings when using array syntax.`, raw[i]);
  5359. }
  5360. const normalizedKey = camelize(raw[i]);
  5361. if (validatePropName(normalizedKey)) {
  5362. normalized[normalizedKey] = EMPTY_OBJ;
  5363. }
  5364. }
  5365. }
  5366. else if (raw) {
  5367. if (!isObject(raw)) {
  5368. warn$1(`invalid props options`, raw);
  5369. }
  5370. for (const key in raw) {
  5371. const normalizedKey = camelize(key);
  5372. if (validatePropName(normalizedKey)) {
  5373. const opt = raw[key];
  5374. const prop = (normalized[normalizedKey] =
  5375. isArray(opt) || isFunction(opt) ? { type: opt } : opt);
  5376. if (prop) {
  5377. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5378. const stringIndex = getTypeIndex(String, prop.type);
  5379. prop[0 /* shouldCast */] = booleanIndex > -1;
  5380. prop[1 /* shouldCastTrue */] =
  5381. stringIndex < 0 || booleanIndex < stringIndex;
  5382. // if the prop needs boolean casting or default value
  5383. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  5384. needCastKeys.push(normalizedKey);
  5385. }
  5386. }
  5387. }
  5388. }
  5389. }
  5390. const res = [normalized, needCastKeys];
  5391. cache.set(comp, res);
  5392. return res;
  5393. }
  5394. function validatePropName(key) {
  5395. if (key[0] !== '$') {
  5396. return true;
  5397. }
  5398. else {
  5399. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  5400. }
  5401. return false;
  5402. }
  5403. // use function string name to check type constructors
  5404. // so that it works across vms / iframes.
  5405. function getType(ctor) {
  5406. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  5407. return match ? match[1] : ctor === null ? 'null' : '';
  5408. }
  5409. function isSameType(a, b) {
  5410. return getType(a) === getType(b);
  5411. }
  5412. function getTypeIndex(type, expectedTypes) {
  5413. if (isArray(expectedTypes)) {
  5414. return expectedTypes.findIndex(t => isSameType(t, type));
  5415. }
  5416. else if (isFunction(expectedTypes)) {
  5417. return isSameType(expectedTypes, type) ? 0 : -1;
  5418. }
  5419. return -1;
  5420. }
  5421. /**
  5422. * dev only
  5423. */
  5424. function validateProps(rawProps, props, instance) {
  5425. const resolvedValues = toRaw(props);
  5426. const options = instance.propsOptions[0];
  5427. for (const key in options) {
  5428. let opt = options[key];
  5429. if (opt == null)
  5430. continue;
  5431. validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
  5432. }
  5433. }
  5434. /**
  5435. * dev only
  5436. */
  5437. function validateProp(name, value, prop, isAbsent) {
  5438. const { type, required, validator } = prop;
  5439. // required!
  5440. if (required && isAbsent) {
  5441. warn$1('Missing required prop: "' + name + '"');
  5442. return;
  5443. }
  5444. // missing but optional
  5445. if (value == null && !prop.required) {
  5446. return;
  5447. }
  5448. // type check
  5449. if (type != null && type !== true) {
  5450. let isValid = false;
  5451. const types = isArray(type) ? type : [type];
  5452. const expectedTypes = [];
  5453. // value is valid as long as one of the specified types match
  5454. for (let i = 0; i < types.length && !isValid; i++) {
  5455. const { valid, expectedType } = assertType(value, types[i]);
  5456. expectedTypes.push(expectedType || '');
  5457. isValid = valid;
  5458. }
  5459. if (!isValid) {
  5460. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  5461. return;
  5462. }
  5463. }
  5464. // custom validator
  5465. if (validator && !validator(value)) {
  5466. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  5467. }
  5468. }
  5469. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  5470. /**
  5471. * dev only
  5472. */
  5473. function assertType(value, type) {
  5474. let valid;
  5475. const expectedType = getType(type);
  5476. if (isSimpleType(expectedType)) {
  5477. const t = typeof value;
  5478. valid = t === expectedType.toLowerCase();
  5479. // for primitive wrapper objects
  5480. if (!valid && t === 'object') {
  5481. valid = value instanceof type;
  5482. }
  5483. }
  5484. else if (expectedType === 'Object') {
  5485. valid = isObject(value);
  5486. }
  5487. else if (expectedType === 'Array') {
  5488. valid = isArray(value);
  5489. }
  5490. else if (expectedType === 'null') {
  5491. valid = value === null;
  5492. }
  5493. else {
  5494. valid = value instanceof type;
  5495. }
  5496. return {
  5497. valid,
  5498. expectedType
  5499. };
  5500. }
  5501. /**
  5502. * dev only
  5503. */
  5504. function getInvalidTypeMessage(name, value, expectedTypes) {
  5505. let message = `Invalid prop: type check failed for prop "${name}".` +
  5506. ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
  5507. const expectedType = expectedTypes[0];
  5508. const receivedType = toRawType(value);
  5509. const expectedValue = styleValue(value, expectedType);
  5510. const receivedValue = styleValue(value, receivedType);
  5511. // check if we need to specify expected value
  5512. if (expectedTypes.length === 1 &&
  5513. isExplicable(expectedType) &&
  5514. !isBoolean(expectedType, receivedType)) {
  5515. message += ` with value ${expectedValue}`;
  5516. }
  5517. message += `, got ${receivedType} `;
  5518. // check if we need to specify received value
  5519. if (isExplicable(receivedType)) {
  5520. message += `with value ${receivedValue}.`;
  5521. }
  5522. return message;
  5523. }
  5524. /**
  5525. * dev only
  5526. */
  5527. function styleValue(value, type) {
  5528. if (type === 'String') {
  5529. return `"${value}"`;
  5530. }
  5531. else if (type === 'Number') {
  5532. return `${Number(value)}`;
  5533. }
  5534. else {
  5535. return `${value}`;
  5536. }
  5537. }
  5538. /**
  5539. * dev only
  5540. */
  5541. function isExplicable(type) {
  5542. const explicitTypes = ['string', 'number', 'boolean'];
  5543. return explicitTypes.some(elem => type.toLowerCase() === elem);
  5544. }
  5545. /**
  5546. * dev only
  5547. */
  5548. function isBoolean(...args) {
  5549. return args.some(elem => elem.toLowerCase() === 'boolean');
  5550. }
  5551. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  5552. const normalizeSlotValue = (value) => isArray(value)
  5553. ? value.map(normalizeVNode)
  5554. : [normalizeVNode(value)];
  5555. const normalizeSlot = (key, rawSlot, ctx) => {
  5556. if (rawSlot._n) {
  5557. // already normalized - #5353
  5558. return rawSlot;
  5559. }
  5560. const normalized = withCtx((...args) => {
  5561. if (currentInstance) {
  5562. warn$1(`Slot "${key}" invoked outside of the render function: ` +
  5563. `this will not track dependencies used in the slot. ` +
  5564. `Invoke the slot function inside the render function instead.`);
  5565. }
  5566. return normalizeSlotValue(rawSlot(...args));
  5567. }, ctx);
  5568. normalized._c = false;
  5569. return normalized;
  5570. };
  5571. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5572. const ctx = rawSlots._ctx;
  5573. for (const key in rawSlots) {
  5574. if (isInternalKey(key))
  5575. continue;
  5576. const value = rawSlots[key];
  5577. if (isFunction(value)) {
  5578. slots[key] = normalizeSlot(key, value, ctx);
  5579. }
  5580. else if (value != null) {
  5581. {
  5582. warn$1(`Non-function value encountered for slot "${key}". ` +
  5583. `Prefer function slots for better performance.`);
  5584. }
  5585. const normalized = normalizeSlotValue(value);
  5586. slots[key] = () => normalized;
  5587. }
  5588. }
  5589. };
  5590. const normalizeVNodeSlots = (instance, children) => {
  5591. if (!isKeepAlive(instance.vnode) &&
  5592. !(false )) {
  5593. warn$1(`Non-function value encountered for default slot. ` +
  5594. `Prefer function slots for better performance.`);
  5595. }
  5596. const normalized = normalizeSlotValue(children);
  5597. instance.slots.default = () => normalized;
  5598. };
  5599. const initSlots = (instance, children) => {
  5600. if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  5601. const type = children._;
  5602. if (type) {
  5603. // users can get the shallow readonly version of the slots object through `this.$slots`,
  5604. // we should avoid the proxy object polluting the slots of the internal instance
  5605. instance.slots = toRaw(children);
  5606. // make compiler marker non-enumerable
  5607. def(children, '_', type);
  5608. }
  5609. else {
  5610. normalizeObjectSlots(children, (instance.slots = {}));
  5611. }
  5612. }
  5613. else {
  5614. instance.slots = {};
  5615. if (children) {
  5616. normalizeVNodeSlots(instance, children);
  5617. }
  5618. }
  5619. def(instance.slots, InternalObjectKey, 1);
  5620. };
  5621. const updateSlots = (instance, children, optimized) => {
  5622. const { vnode, slots } = instance;
  5623. let needDeletionCheck = true;
  5624. let deletionComparisonTarget = EMPTY_OBJ;
  5625. if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  5626. const type = children._;
  5627. if (type) {
  5628. // compiled slots.
  5629. if (isHmrUpdating) {
  5630. // Parent was HMR updated so slot content may have changed.
  5631. // force update slots and mark instance for hmr as well
  5632. extend(slots, children);
  5633. }
  5634. else if (optimized && type === 1 /* STABLE */) {
  5635. // compiled AND stable.
  5636. // no need to update, and skip stale slots removal.
  5637. needDeletionCheck = false;
  5638. }
  5639. else {
  5640. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  5641. // normalization.
  5642. extend(slots, children);
  5643. // #2893
  5644. // when rendering the optimized slots by manually written render function,
  5645. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  5646. // i.e. let the `renderSlot` create the bailed Fragment
  5647. if (!optimized && type === 1 /* STABLE */) {
  5648. delete slots._;
  5649. }
  5650. }
  5651. }
  5652. else {
  5653. needDeletionCheck = !children.$stable;
  5654. normalizeObjectSlots(children, slots);
  5655. }
  5656. deletionComparisonTarget = children;
  5657. }
  5658. else if (children) {
  5659. // non slot object children (direct value) passed to a component
  5660. normalizeVNodeSlots(instance, children);
  5661. deletionComparisonTarget = { default: 1 };
  5662. }
  5663. // delete stale slots
  5664. if (needDeletionCheck) {
  5665. for (const key in slots) {
  5666. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5667. delete slots[key];
  5668. }
  5669. }
  5670. }
  5671. };
  5672. function createAppContext() {
  5673. return {
  5674. app: null,
  5675. config: {
  5676. isNativeTag: NO,
  5677. performance: false,
  5678. globalProperties: {},
  5679. optionMergeStrategies: {},
  5680. errorHandler: undefined,
  5681. warnHandler: undefined,
  5682. compilerOptions: {}
  5683. },
  5684. mixins: [],
  5685. components: {},
  5686. directives: {},
  5687. provides: Object.create(null),
  5688. optionsCache: new WeakMap(),
  5689. propsCache: new WeakMap(),
  5690. emitsCache: new WeakMap()
  5691. };
  5692. }
  5693. let uid = 0;
  5694. function createAppAPI(render, hydrate) {
  5695. return function createApp(rootComponent, rootProps = null) {
  5696. if (!isFunction(rootComponent)) {
  5697. rootComponent = Object.assign({}, rootComponent);
  5698. }
  5699. if (rootProps != null && !isObject(rootProps)) {
  5700. warn$1(`root props passed to app.mount() must be an object.`);
  5701. rootProps = null;
  5702. }
  5703. const context = createAppContext();
  5704. const installedPlugins = new Set();
  5705. let isMounted = false;
  5706. const app = (context.app = {
  5707. _uid: uid++,
  5708. _component: rootComponent,
  5709. _props: rootProps,
  5710. _container: null,
  5711. _context: context,
  5712. _instance: null,
  5713. version,
  5714. get config() {
  5715. return context.config;
  5716. },
  5717. set config(v) {
  5718. {
  5719. warn$1(`app.config cannot be replaced. Modify individual options instead.`);
  5720. }
  5721. },
  5722. use(plugin, ...options) {
  5723. if (installedPlugins.has(plugin)) {
  5724. warn$1(`Plugin has already been applied to target app.`);
  5725. }
  5726. else if (plugin && isFunction(plugin.install)) {
  5727. installedPlugins.add(plugin);
  5728. plugin.install(app, ...options);
  5729. }
  5730. else if (isFunction(plugin)) {
  5731. installedPlugins.add(plugin);
  5732. plugin(app, ...options);
  5733. }
  5734. else {
  5735. warn$1(`A plugin must either be a function or an object with an "install" ` +
  5736. `function.`);
  5737. }
  5738. return app;
  5739. },
  5740. mixin(mixin) {
  5741. {
  5742. if (!context.mixins.includes(mixin)) {
  5743. context.mixins.push(mixin);
  5744. }
  5745. else {
  5746. warn$1('Mixin has already been applied to target app' +
  5747. (mixin.name ? `: ${mixin.name}` : ''));
  5748. }
  5749. }
  5750. return app;
  5751. },
  5752. component(name, component) {
  5753. {
  5754. validateComponentName(name, context.config);
  5755. }
  5756. if (!component) {
  5757. return context.components[name];
  5758. }
  5759. if (context.components[name]) {
  5760. warn$1(`Component "${name}" has already been registered in target app.`);
  5761. }
  5762. context.components[name] = component;
  5763. return app;
  5764. },
  5765. directive(name, directive) {
  5766. {
  5767. validateDirectiveName(name);
  5768. }
  5769. if (!directive) {
  5770. return context.directives[name];
  5771. }
  5772. if (context.directives[name]) {
  5773. warn$1(`Directive "${name}" has already been registered in target app.`);
  5774. }
  5775. context.directives[name] = directive;
  5776. return app;
  5777. },
  5778. mount(rootContainer, isHydrate, isSVG) {
  5779. if (!isMounted) {
  5780. // #5571
  5781. if (rootContainer.__vue_app__) {
  5782. warn$1(`There is already an app instance mounted on the host container.\n` +
  5783. ` If you want to mount another app on the same host container,` +
  5784. ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
  5785. }
  5786. const vnode = createVNode(rootComponent, rootProps);
  5787. // store app context on the root VNode.
  5788. // this will be set on the root instance on initial mount.
  5789. vnode.appContext = context;
  5790. // HMR root reload
  5791. {
  5792. context.reload = () => {
  5793. render(cloneVNode(vnode), rootContainer, isSVG);
  5794. };
  5795. }
  5796. if (isHydrate && hydrate) {
  5797. hydrate(vnode, rootContainer);
  5798. }
  5799. else {
  5800. render(vnode, rootContainer, isSVG);
  5801. }
  5802. isMounted = true;
  5803. app._container = rootContainer;
  5804. rootContainer.__vue_app__ = app;
  5805. {
  5806. app._instance = vnode.component;
  5807. devtoolsInitApp(app, version);
  5808. }
  5809. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5810. }
  5811. else {
  5812. warn$1(`App has already been mounted.\n` +
  5813. `If you want to remount the same app, move your app creation logic ` +
  5814. `into a factory function and create fresh app instances for each ` +
  5815. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  5816. }
  5817. },
  5818. unmount() {
  5819. if (isMounted) {
  5820. render(null, app._container);
  5821. {
  5822. app._instance = null;
  5823. devtoolsUnmountApp(app);
  5824. }
  5825. delete app._container.__vue_app__;
  5826. }
  5827. else {
  5828. warn$1(`Cannot unmount an app that is not mounted.`);
  5829. }
  5830. },
  5831. provide(key, value) {
  5832. if (key in context.provides) {
  5833. warn$1(`App already provides property with key "${String(key)}". ` +
  5834. `It will be overwritten with the new value.`);
  5835. }
  5836. context.provides[key] = value;
  5837. return app;
  5838. }
  5839. });
  5840. return app;
  5841. };
  5842. }
  5843. /**
  5844. * Function for handling a template ref
  5845. */
  5846. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5847. if (isArray(rawRef)) {
  5848. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  5849. return;
  5850. }
  5851. if (isAsyncWrapper(vnode) && !isUnmount) {
  5852. // when mounting async components, nothing needs to be done,
  5853. // because the template ref is forwarded to inner component
  5854. return;
  5855. }
  5856. const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
  5857. ? getExposeProxy(vnode.component) || vnode.component.proxy
  5858. : vnode.el;
  5859. const value = isUnmount ? null : refValue;
  5860. const { i: owner, r: ref } = rawRef;
  5861. if (!owner) {
  5862. warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  5863. `A vnode with ref must be created inside the render function.`);
  5864. return;
  5865. }
  5866. const oldRef = oldRawRef && oldRawRef.r;
  5867. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  5868. const setupState = owner.setupState;
  5869. // dynamic ref changed. unset old ref
  5870. if (oldRef != null && oldRef !== ref) {
  5871. if (isString(oldRef)) {
  5872. refs[oldRef] = null;
  5873. if (hasOwn(setupState, oldRef)) {
  5874. setupState[oldRef] = null;
  5875. }
  5876. }
  5877. else if (isRef(oldRef)) {
  5878. oldRef.value = null;
  5879. }
  5880. }
  5881. if (isFunction(ref)) {
  5882. callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
  5883. }
  5884. else {
  5885. const _isString = isString(ref);
  5886. const _isRef = isRef(ref);
  5887. if (_isString || _isRef) {
  5888. const doSet = () => {
  5889. if (rawRef.f) {
  5890. const existing = _isString ? refs[ref] : ref.value;
  5891. if (isUnmount) {
  5892. isArray(existing) && remove(existing, refValue);
  5893. }
  5894. else {
  5895. if (!isArray(existing)) {
  5896. if (_isString) {
  5897. refs[ref] = [refValue];
  5898. if (hasOwn(setupState, ref)) {
  5899. setupState[ref] = refs[ref];
  5900. }
  5901. }
  5902. else {
  5903. ref.value = [refValue];
  5904. if (rawRef.k)
  5905. refs[rawRef.k] = ref.value;
  5906. }
  5907. }
  5908. else if (!existing.includes(refValue)) {
  5909. existing.push(refValue);
  5910. }
  5911. }
  5912. }
  5913. else if (_isString) {
  5914. refs[ref] = value;
  5915. if (hasOwn(setupState, ref)) {
  5916. setupState[ref] = value;
  5917. }
  5918. }
  5919. else if (_isRef) {
  5920. ref.value = value;
  5921. if (rawRef.k)
  5922. refs[rawRef.k] = value;
  5923. }
  5924. else {
  5925. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5926. }
  5927. };
  5928. if (value) {
  5929. doSet.id = -1;
  5930. queuePostRenderEffect(doSet, parentSuspense);
  5931. }
  5932. else {
  5933. doSet();
  5934. }
  5935. }
  5936. else {
  5937. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5938. }
  5939. }
  5940. }
  5941. let hasMismatch = false;
  5942. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  5943. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  5944. // Note: hydration is DOM-specific
  5945. // But we have to place it in core due to tight coupling with core - splitting
  5946. // it out creates a ton of unnecessary complexity.
  5947. // Hydration also depends on some renderer internal logic which needs to be
  5948. // passed in via arguments.
  5949. function createHydrationFunctions(rendererInternals) {
  5950. const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  5951. const hydrate = (vnode, container) => {
  5952. if (!container.hasChildNodes()) {
  5953. warn$1(`Attempting to hydrate existing markup but container is empty. ` +
  5954. `Performing full mount instead.`);
  5955. patch(null, vnode, container);
  5956. flushPostFlushCbs();
  5957. container._vnode = vnode;
  5958. return;
  5959. }
  5960. hasMismatch = false;
  5961. hydrateNode(container.firstChild, vnode, null, null, null);
  5962. flushPostFlushCbs();
  5963. container._vnode = vnode;
  5964. if (hasMismatch && !false) {
  5965. // this error should show up in production
  5966. console.error(`Hydration completed but contains mismatches.`);
  5967. }
  5968. };
  5969. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5970. const isFragmentStart = isComment(node) && node.data === '[';
  5971. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  5972. const { type, ref, shapeFlag, patchFlag } = vnode;
  5973. const domType = node.nodeType;
  5974. vnode.el = node;
  5975. if (patchFlag === -2 /* BAIL */) {
  5976. optimized = false;
  5977. vnode.dynamicChildren = null;
  5978. }
  5979. let nextNode = null;
  5980. switch (type) {
  5981. case Text:
  5982. if (domType !== 3 /* TEXT */) {
  5983. // #5728 empty text node inside a slot can cause hydration failure
  5984. // because the server rendered HTML won't contain a text node
  5985. if (vnode.children === '') {
  5986. insert((vnode.el = createText('')), parentNode(node), node);
  5987. nextNode = node;
  5988. }
  5989. else {
  5990. nextNode = onMismatch();
  5991. }
  5992. }
  5993. else {
  5994. if (node.data !== vnode.children) {
  5995. hasMismatch = true;
  5996. warn$1(`Hydration text mismatch:` +
  5997. `\n- Client: ${JSON.stringify(node.data)}` +
  5998. `\n- Server: ${JSON.stringify(vnode.children)}`);
  5999. node.data = vnode.children;
  6000. }
  6001. nextNode = nextSibling(node);
  6002. }
  6003. break;
  6004. case Comment:
  6005. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  6006. nextNode = onMismatch();
  6007. }
  6008. else {
  6009. nextNode = nextSibling(node);
  6010. }
  6011. break;
  6012. case Static:
  6013. if (domType !== 1 /* ELEMENT */ && domType !== 3 /* TEXT */) {
  6014. nextNode = onMismatch();
  6015. }
  6016. else {
  6017. // determine anchor, adopt content
  6018. nextNode = node;
  6019. // if the static vnode has its content stripped during build,
  6020. // adopt it from the server-rendered HTML.
  6021. const needToAdoptContent = !vnode.children.length;
  6022. for (let i = 0; i < vnode.staticCount; i++) {
  6023. if (needToAdoptContent)
  6024. vnode.children +=
  6025. nextNode.nodeType === 1 /* ELEMENT */
  6026. ? nextNode.outerHTML
  6027. : nextNode.data;
  6028. if (i === vnode.staticCount - 1) {
  6029. vnode.anchor = nextNode;
  6030. }
  6031. nextNode = nextSibling(nextNode);
  6032. }
  6033. return nextNode;
  6034. }
  6035. break;
  6036. case Fragment:
  6037. if (!isFragmentStart) {
  6038. nextNode = onMismatch();
  6039. }
  6040. else {
  6041. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6042. }
  6043. break;
  6044. default:
  6045. if (shapeFlag & 1 /* ELEMENT */) {
  6046. if (domType !== 1 /* ELEMENT */ ||
  6047. vnode.type.toLowerCase() !==
  6048. node.tagName.toLowerCase()) {
  6049. nextNode = onMismatch();
  6050. }
  6051. else {
  6052. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6053. }
  6054. }
  6055. else if (shapeFlag & 6 /* COMPONENT */) {
  6056. // when setting up the render effect, if the initial vnode already
  6057. // has .el set, the component will perform hydration instead of mount
  6058. // on its sub-tree.
  6059. vnode.slotScopeIds = slotScopeIds;
  6060. const container = parentNode(node);
  6061. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  6062. // component may be async, so in the case of fragments we cannot rely
  6063. // on component's rendered output to determine the end of the fragment
  6064. // instead, we do a lookahead to find the end anchor node.
  6065. nextNode = isFragmentStart
  6066. ? locateClosingAsyncAnchor(node)
  6067. : nextSibling(node);
  6068. // #4293 teleport as component root
  6069. if (nextNode &&
  6070. isComment(nextNode) &&
  6071. nextNode.data === 'teleport end') {
  6072. nextNode = nextSibling(nextNode);
  6073. }
  6074. // #3787
  6075. // if component is async, it may get moved / unmounted before its
  6076. // inner component is loaded, so we need to give it a placeholder
  6077. // vnode that matches its adopted DOM.
  6078. if (isAsyncWrapper(vnode)) {
  6079. let subTree;
  6080. if (isFragmentStart) {
  6081. subTree = createVNode(Fragment);
  6082. subTree.anchor = nextNode
  6083. ? nextNode.previousSibling
  6084. : container.lastChild;
  6085. }
  6086. else {
  6087. subTree =
  6088. node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  6089. }
  6090. subTree.el = node;
  6091. vnode.component.subTree = subTree;
  6092. }
  6093. }
  6094. else if (shapeFlag & 64 /* TELEPORT */) {
  6095. if (domType !== 8 /* COMMENT */) {
  6096. nextNode = onMismatch();
  6097. }
  6098. else {
  6099. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  6100. }
  6101. }
  6102. else if (shapeFlag & 128 /* SUSPENSE */) {
  6103. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  6104. }
  6105. else {
  6106. warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
  6107. }
  6108. }
  6109. if (ref != null) {
  6110. setRef(ref, null, parentSuspense, vnode);
  6111. }
  6112. return nextNode;
  6113. };
  6114. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6115. optimized = optimized || !!vnode.dynamicChildren;
  6116. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  6117. // #4006 for form elements with non-string v-model value bindings
  6118. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  6119. const forcePatchValue = (type === 'input' && dirs) || type === 'option';
  6120. // skip props & children if this is hoisted static nodes
  6121. // #5405 in dev, always hydrate children for HMR
  6122. {
  6123. if (dirs) {
  6124. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6125. }
  6126. // props
  6127. if (props) {
  6128. if (forcePatchValue ||
  6129. !optimized ||
  6130. patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
  6131. for (const key in props) {
  6132. if ((forcePatchValue && key.endsWith('value')) ||
  6133. (isOn(key) && !isReservedProp(key))) {
  6134. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  6135. }
  6136. }
  6137. }
  6138. else if (props.onClick) {
  6139. // Fast path for click listeners (which is most often) to avoid
  6140. // iterating through props.
  6141. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  6142. }
  6143. }
  6144. // vnode / directive hooks
  6145. let vnodeHooks;
  6146. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  6147. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6148. }
  6149. if (dirs) {
  6150. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6151. }
  6152. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  6153. queueEffectWithSuspense(() => {
  6154. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6155. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6156. }, parentSuspense);
  6157. }
  6158. // children
  6159. if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
  6160. // skip if element has innerHTML / textContent
  6161. !(props && (props.innerHTML || props.textContent))) {
  6162. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  6163. let hasWarned = false;
  6164. while (next) {
  6165. hasMismatch = true;
  6166. if (!hasWarned) {
  6167. warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
  6168. `server rendered element contains more child nodes than client vdom.`);
  6169. hasWarned = true;
  6170. }
  6171. // The SSRed DOM contains more nodes than it should. Remove them.
  6172. const cur = next;
  6173. next = next.nextSibling;
  6174. remove(cur);
  6175. }
  6176. }
  6177. else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  6178. if (el.textContent !== vnode.children) {
  6179. hasMismatch = true;
  6180. warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
  6181. `- Client: ${el.textContent}\n` +
  6182. `- Server: ${vnode.children}`);
  6183. el.textContent = vnode.children;
  6184. }
  6185. }
  6186. }
  6187. return el.nextSibling;
  6188. };
  6189. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6190. optimized = optimized || !!parentVNode.dynamicChildren;
  6191. const children = parentVNode.children;
  6192. const l = children.length;
  6193. let hasWarned = false;
  6194. for (let i = 0; i < l; i++) {
  6195. const vnode = optimized
  6196. ? children[i]
  6197. : (children[i] = normalizeVNode(children[i]));
  6198. if (node) {
  6199. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6200. }
  6201. else if (vnode.type === Text && !vnode.children) {
  6202. continue;
  6203. }
  6204. else {
  6205. hasMismatch = true;
  6206. if (!hasWarned) {
  6207. warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  6208. `server rendered element contains fewer child nodes than client vdom.`);
  6209. hasWarned = true;
  6210. }
  6211. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  6212. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6213. }
  6214. }
  6215. return node;
  6216. };
  6217. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6218. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6219. if (fragmentSlotScopeIds) {
  6220. slotScopeIds = slotScopeIds
  6221. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6222. : fragmentSlotScopeIds;
  6223. }
  6224. const container = parentNode(node);
  6225. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  6226. if (next && isComment(next) && next.data === ']') {
  6227. return nextSibling((vnode.anchor = next));
  6228. }
  6229. else {
  6230. // fragment didn't hydrate successfully, since we didn't get a end anchor
  6231. // back. This should have led to node/children mismatch warnings.
  6232. hasMismatch = true;
  6233. // since the anchor is missing, we need to create one and insert it
  6234. insert((vnode.anchor = createComment(`]`)), container, next);
  6235. return next;
  6236. }
  6237. };
  6238. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6239. hasMismatch = true;
  6240. warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
  6241. ? `(text)`
  6242. : isComment(node) && node.data === '['
  6243. ? `(start of fragment)`
  6244. : ``);
  6245. vnode.el = null;
  6246. if (isFragment) {
  6247. // remove excessive fragment nodes
  6248. const end = locateClosingAsyncAnchor(node);
  6249. while (true) {
  6250. const next = nextSibling(node);
  6251. if (next && next !== end) {
  6252. remove(next);
  6253. }
  6254. else {
  6255. break;
  6256. }
  6257. }
  6258. }
  6259. const next = nextSibling(node);
  6260. const container = parentNode(node);
  6261. remove(node);
  6262. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6263. return next;
  6264. };
  6265. const locateClosingAsyncAnchor = (node) => {
  6266. let match = 0;
  6267. while (node) {
  6268. node = nextSibling(node);
  6269. if (node && isComment(node)) {
  6270. if (node.data === '[')
  6271. match++;
  6272. if (node.data === ']') {
  6273. if (match === 0) {
  6274. return nextSibling(node);
  6275. }
  6276. else {
  6277. match--;
  6278. }
  6279. }
  6280. }
  6281. }
  6282. return node;
  6283. };
  6284. return [hydrate, hydrateNode];
  6285. }
  6286. /* eslint-disable no-restricted-globals */
  6287. let supported;
  6288. let perf;
  6289. function startMeasure(instance, type) {
  6290. if (instance.appContext.config.performance && isSupported()) {
  6291. perf.mark(`vue-${type}-${instance.uid}`);
  6292. }
  6293. {
  6294. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6295. }
  6296. }
  6297. function endMeasure(instance, type) {
  6298. if (instance.appContext.config.performance && isSupported()) {
  6299. const startTag = `vue-${type}-${instance.uid}`;
  6300. const endTag = startTag + `:end`;
  6301. perf.mark(endTag);
  6302. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  6303. perf.clearMarks(startTag);
  6304. perf.clearMarks(endTag);
  6305. }
  6306. {
  6307. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6308. }
  6309. }
  6310. function isSupported() {
  6311. if (supported !== undefined) {
  6312. return supported;
  6313. }
  6314. if (typeof window !== 'undefined' && window.performance) {
  6315. supported = true;
  6316. perf = window.performance;
  6317. }
  6318. else {
  6319. supported = false;
  6320. }
  6321. return supported;
  6322. }
  6323. const queuePostRenderEffect = queueEffectWithSuspense
  6324. ;
  6325. /**
  6326. * The createRenderer function accepts two generic arguments:
  6327. * HostNode and HostElement, corresponding to Node and Element types in the
  6328. * host environment. For example, for runtime-dom, HostNode would be the DOM
  6329. * `Node` interface and HostElement would be the DOM `Element` interface.
  6330. *
  6331. * Custom renderers can pass in the platform specific types like this:
  6332. *
  6333. * ``` js
  6334. * const { render, createApp } = createRenderer<Node, Element>({
  6335. * patchProp,
  6336. * ...nodeOps
  6337. * })
  6338. * ```
  6339. */
  6340. function createRenderer(options) {
  6341. return baseCreateRenderer(options);
  6342. }
  6343. // Separate API for creating hydration-enabled renderer.
  6344. // Hydration logic is only used when calling this function, making it
  6345. // tree-shakable.
  6346. function createHydrationRenderer(options) {
  6347. return baseCreateRenderer(options, createHydrationFunctions);
  6348. }
  6349. // implementation
  6350. function baseCreateRenderer(options, createHydrationFns) {
  6351. const target = getGlobalThis();
  6352. target.__VUE__ = true;
  6353. {
  6354. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6355. }
  6356. 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;
  6357. // Note: functions inside this closure should use `const xxx = () => {}`
  6358. // style in order to prevent being inlined by minifiers.
  6359. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6360. if (n1 === n2) {
  6361. return;
  6362. }
  6363. // patching & not same type, unmount old tree
  6364. if (n1 && !isSameVNodeType(n1, n2)) {
  6365. anchor = getNextHostNode(n1);
  6366. unmount(n1, parentComponent, parentSuspense, true);
  6367. n1 = null;
  6368. }
  6369. if (n2.patchFlag === -2 /* BAIL */) {
  6370. optimized = false;
  6371. n2.dynamicChildren = null;
  6372. }
  6373. const { type, ref, shapeFlag } = n2;
  6374. switch (type) {
  6375. case Text:
  6376. processText(n1, n2, container, anchor);
  6377. break;
  6378. case Comment:
  6379. processCommentNode(n1, n2, container, anchor);
  6380. break;
  6381. case Static:
  6382. if (n1 == null) {
  6383. mountStaticNode(n2, container, anchor, isSVG);
  6384. }
  6385. else {
  6386. patchStaticNode(n1, n2, container, isSVG);
  6387. }
  6388. break;
  6389. case Fragment:
  6390. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6391. break;
  6392. default:
  6393. if (shapeFlag & 1 /* ELEMENT */) {
  6394. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6395. }
  6396. else if (shapeFlag & 6 /* COMPONENT */) {
  6397. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6398. }
  6399. else if (shapeFlag & 64 /* TELEPORT */) {
  6400. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6401. }
  6402. else if (shapeFlag & 128 /* SUSPENSE */) {
  6403. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6404. }
  6405. else {
  6406. warn$1('Invalid VNode type:', type, `(${typeof type})`);
  6407. }
  6408. }
  6409. // set ref
  6410. if (ref != null && parentComponent) {
  6411. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6412. }
  6413. };
  6414. const processText = (n1, n2, container, anchor) => {
  6415. if (n1 == null) {
  6416. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  6417. }
  6418. else {
  6419. const el = (n2.el = n1.el);
  6420. if (n2.children !== n1.children) {
  6421. hostSetText(el, n2.children);
  6422. }
  6423. }
  6424. };
  6425. const processCommentNode = (n1, n2, container, anchor) => {
  6426. if (n1 == null) {
  6427. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  6428. }
  6429. else {
  6430. // there's no support for dynamic comments
  6431. n2.el = n1.el;
  6432. }
  6433. };
  6434. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6435. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
  6436. };
  6437. /**
  6438. * Dev / HMR only
  6439. */
  6440. const patchStaticNode = (n1, n2, container, isSVG) => {
  6441. // static nodes are only patched during dev for HMR
  6442. if (n2.children !== n1.children) {
  6443. const anchor = hostNextSibling(n1.anchor);
  6444. // remove existing
  6445. removeStaticNode(n1);
  6446. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  6447. }
  6448. else {
  6449. n2.el = n1.el;
  6450. n2.anchor = n1.anchor;
  6451. }
  6452. };
  6453. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6454. let next;
  6455. while (el && el !== anchor) {
  6456. next = hostNextSibling(el);
  6457. hostInsert(el, container, nextSibling);
  6458. el = next;
  6459. }
  6460. hostInsert(anchor, container, nextSibling);
  6461. };
  6462. const removeStaticNode = ({ el, anchor }) => {
  6463. let next;
  6464. while (el && el !== anchor) {
  6465. next = hostNextSibling(el);
  6466. hostRemove(el);
  6467. el = next;
  6468. }
  6469. hostRemove(anchor);
  6470. };
  6471. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6472. isSVG = isSVG || n2.type === 'svg';
  6473. if (n1 == null) {
  6474. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6475. }
  6476. else {
  6477. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6478. }
  6479. };
  6480. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6481. let el;
  6482. let vnodeHook;
  6483. const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
  6484. {
  6485. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  6486. // mount children first, since some props may rely on child content
  6487. // being already rendered, e.g. `<select value>`
  6488. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  6489. hostSetElementText(el, vnode.children);
  6490. }
  6491. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6492. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  6493. }
  6494. if (dirs) {
  6495. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6496. }
  6497. // props
  6498. if (props) {
  6499. for (const key in props) {
  6500. if (key !== 'value' && !isReservedProp(key)) {
  6501. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6502. }
  6503. }
  6504. /**
  6505. * Special case for setting value on DOM elements:
  6506. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  6507. * - it needs to be forced (#1471)
  6508. * #2353 proposes adding another renderer option to configure this, but
  6509. * the properties affects are so finite it is worth special casing it
  6510. * here to reduce the complexity. (Special casing it also should not
  6511. * affect non-DOM renderers)
  6512. */
  6513. if ('value' in props) {
  6514. hostPatchProp(el, 'value', null, props.value);
  6515. }
  6516. if ((vnodeHook = props.onVnodeBeforeMount)) {
  6517. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6518. }
  6519. }
  6520. // scopeId
  6521. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6522. }
  6523. {
  6524. Object.defineProperty(el, '__vnode', {
  6525. value: vnode,
  6526. enumerable: false
  6527. });
  6528. Object.defineProperty(el, '__vueParentComponent', {
  6529. value: parentComponent,
  6530. enumerable: false
  6531. });
  6532. }
  6533. if (dirs) {
  6534. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6535. }
  6536. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  6537. // #1689 For inside suspense + suspense resolved case, just call it
  6538. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  6539. transition &&
  6540. !transition.persisted;
  6541. if (needCallTransitionHooks) {
  6542. transition.beforeEnter(el);
  6543. }
  6544. hostInsert(el, container, anchor);
  6545. if ((vnodeHook = props && props.onVnodeMounted) ||
  6546. needCallTransitionHooks ||
  6547. dirs) {
  6548. queuePostRenderEffect(() => {
  6549. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6550. needCallTransitionHooks && transition.enter(el);
  6551. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6552. }, parentSuspense);
  6553. }
  6554. };
  6555. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6556. if (scopeId) {
  6557. hostSetScopeId(el, scopeId);
  6558. }
  6559. if (slotScopeIds) {
  6560. for (let i = 0; i < slotScopeIds.length; i++) {
  6561. hostSetScopeId(el, slotScopeIds[i]);
  6562. }
  6563. }
  6564. if (parentComponent) {
  6565. let subTree = parentComponent.subTree;
  6566. if (subTree.patchFlag > 0 &&
  6567. subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  6568. subTree =
  6569. filterSingleRoot(subTree.children) || subTree;
  6570. }
  6571. if (vnode === subTree) {
  6572. const parentVNode = parentComponent.vnode;
  6573. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  6574. }
  6575. }
  6576. };
  6577. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6578. for (let i = start; i < children.length; i++) {
  6579. const child = (children[i] = optimized
  6580. ? cloneIfMounted(children[i])
  6581. : normalizeVNode(children[i]));
  6582. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6583. }
  6584. };
  6585. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6586. const el = (n2.el = n1.el);
  6587. let { patchFlag, dynamicChildren, dirs } = n2;
  6588. // #1426 take the old vnode's patch flag into account since user may clone a
  6589. // compiler-generated vnode, which de-opts to FULL_PROPS
  6590. patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
  6591. const oldProps = n1.props || EMPTY_OBJ;
  6592. const newProps = n2.props || EMPTY_OBJ;
  6593. let vnodeHook;
  6594. // disable recurse in beforeUpdate hooks
  6595. parentComponent && toggleRecurse(parentComponent, false);
  6596. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  6597. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6598. }
  6599. if (dirs) {
  6600. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  6601. }
  6602. parentComponent && toggleRecurse(parentComponent, true);
  6603. if (isHmrUpdating) {
  6604. // HMR updated, force full diff
  6605. patchFlag = 0;
  6606. optimized = false;
  6607. dynamicChildren = null;
  6608. }
  6609. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  6610. if (dynamicChildren) {
  6611. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  6612. if (parentComponent && parentComponent.type.__hmrId) {
  6613. traverseStaticChildren(n1, n2);
  6614. }
  6615. }
  6616. else if (!optimized) {
  6617. // full diff
  6618. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  6619. }
  6620. if (patchFlag > 0) {
  6621. // the presence of a patchFlag means this element's render code was
  6622. // generated by the compiler and can take the fast path.
  6623. // in this path old node and new node are guaranteed to have the same shape
  6624. // (i.e. at the exact same position in the source template)
  6625. if (patchFlag & 16 /* FULL_PROPS */) {
  6626. // element props contain dynamic keys, full diff needed
  6627. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6628. }
  6629. else {
  6630. // class
  6631. // this flag is matched when the element has dynamic class bindings.
  6632. if (patchFlag & 2 /* CLASS */) {
  6633. if (oldProps.class !== newProps.class) {
  6634. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  6635. }
  6636. }
  6637. // style
  6638. // this flag is matched when the element has dynamic style bindings
  6639. if (patchFlag & 4 /* STYLE */) {
  6640. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  6641. }
  6642. // props
  6643. // This flag is matched when the element has dynamic prop/attr bindings
  6644. // other than class and style. The keys of dynamic prop/attrs are saved for
  6645. // faster iteration.
  6646. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  6647. // bail out and go through a full diff because we need to unset the old key
  6648. if (patchFlag & 8 /* PROPS */) {
  6649. // if the flag is present then dynamicProps must be non-null
  6650. const propsToUpdate = n2.dynamicProps;
  6651. for (let i = 0; i < propsToUpdate.length; i++) {
  6652. const key = propsToUpdate[i];
  6653. const prev = oldProps[key];
  6654. const next = newProps[key];
  6655. // #1471 force patch value
  6656. if (next !== prev || key === 'value') {
  6657. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  6658. }
  6659. }
  6660. }
  6661. }
  6662. // text
  6663. // This flag is matched when the element has only dynamic text children.
  6664. if (patchFlag & 1 /* TEXT */) {
  6665. if (n1.children !== n2.children) {
  6666. hostSetElementText(el, n2.children);
  6667. }
  6668. }
  6669. }
  6670. else if (!optimized && dynamicChildren == null) {
  6671. // unoptimized, full diff
  6672. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6673. }
  6674. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6675. queuePostRenderEffect(() => {
  6676. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6677. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  6678. }, parentSuspense);
  6679. }
  6680. };
  6681. // The fast path for blocks.
  6682. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6683. for (let i = 0; i < newChildren.length; i++) {
  6684. const oldVNode = oldChildren[i];
  6685. const newVNode = newChildren[i];
  6686. // Determine the container (parent element) for the patch.
  6687. const container =
  6688. // oldVNode may be an errored async setup() component inside Suspense
  6689. // which will not have a mounted element
  6690. oldVNode.el &&
  6691. // - In the case of a Fragment, we need to provide the actual parent
  6692. // of the Fragment itself so it can move its children.
  6693. (oldVNode.type === Fragment ||
  6694. // - In the case of different nodes, there is going to be a replacement
  6695. // which also requires the correct parent container
  6696. !isSameVNodeType(oldVNode, newVNode) ||
  6697. // - In the case of a component, it could contain anything.
  6698. oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
  6699. ? hostParentNode(oldVNode.el)
  6700. : // In other cases, the parent container is not actually used so we
  6701. // just pass the block element here to avoid a DOM parentNode call.
  6702. fallbackContainer;
  6703. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  6704. }
  6705. };
  6706. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6707. if (oldProps !== newProps) {
  6708. for (const key in newProps) {
  6709. // empty string is not valid prop
  6710. if (isReservedProp(key))
  6711. continue;
  6712. const next = newProps[key];
  6713. const prev = oldProps[key];
  6714. // defer patching value
  6715. if (next !== prev && key !== 'value') {
  6716. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6717. }
  6718. }
  6719. if (oldProps !== EMPTY_OBJ) {
  6720. for (const key in oldProps) {
  6721. if (!isReservedProp(key) && !(key in newProps)) {
  6722. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6723. }
  6724. }
  6725. }
  6726. if ('value' in newProps) {
  6727. hostPatchProp(el, 'value', oldProps.value, newProps.value);
  6728. }
  6729. }
  6730. };
  6731. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6732. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  6733. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  6734. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6735. if (// #5523 dev root fragment may inherit directives
  6736. (isHmrUpdating || patchFlag & 2048 /* DEV_ROOT_FRAGMENT */)) {
  6737. // HMR updated / Dev root fragment (w/ comments), force full diff
  6738. patchFlag = 0;
  6739. optimized = false;
  6740. dynamicChildren = null;
  6741. }
  6742. // check if this is a slot fragment with :slotted scope ids
  6743. if (fragmentSlotScopeIds) {
  6744. slotScopeIds = slotScopeIds
  6745. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6746. : fragmentSlotScopeIds;
  6747. }
  6748. if (n1 == null) {
  6749. hostInsert(fragmentStartAnchor, container, anchor);
  6750. hostInsert(fragmentEndAnchor, container, anchor);
  6751. // a fragment can only have array children
  6752. // since they are either generated by the compiler, or implicitly created
  6753. // from arrays.
  6754. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6755. }
  6756. else {
  6757. if (patchFlag > 0 &&
  6758. patchFlag & 64 /* STABLE_FRAGMENT */ &&
  6759. dynamicChildren &&
  6760. // #2715 the previous fragment could've been a BAILed one as a result
  6761. // of renderSlot() with no valid children
  6762. n1.dynamicChildren) {
  6763. // a stable fragment (template root or <template v-for>) doesn't need to
  6764. // patch children order, but it may contain dynamicChildren.
  6765. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  6766. if (parentComponent && parentComponent.type.__hmrId) {
  6767. traverseStaticChildren(n1, n2);
  6768. }
  6769. else if (
  6770. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  6771. // get moved around. Make sure all root level vnodes inherit el.
  6772. // #2134 or if it's a component root, it may also get moved around
  6773. // as the component is being moved.
  6774. n2.key != null ||
  6775. (parentComponent && n2 === parentComponent.subTree)) {
  6776. traverseStaticChildren(n1, n2, true /* shallow */);
  6777. }
  6778. }
  6779. else {
  6780. // keyed / unkeyed, or manual fragments.
  6781. // for keyed & unkeyed, since they are compiler generated from v-for,
  6782. // each child is guaranteed to be a block so the fragment will never
  6783. // have dynamicChildren.
  6784. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6785. }
  6786. }
  6787. };
  6788. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6789. n2.slotScopeIds = slotScopeIds;
  6790. if (n1 == null) {
  6791. if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  6792. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  6793. }
  6794. else {
  6795. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  6796. }
  6797. }
  6798. else {
  6799. updateComponent(n1, n2, optimized);
  6800. }
  6801. };
  6802. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  6803. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  6804. if (instance.type.__hmrId) {
  6805. registerHMR(instance);
  6806. }
  6807. {
  6808. pushWarningContext(initialVNode);
  6809. startMeasure(instance, `mount`);
  6810. }
  6811. // inject renderer internals for keepAlive
  6812. if (isKeepAlive(initialVNode)) {
  6813. instance.ctx.renderer = internals;
  6814. }
  6815. // resolve props and slots for setup context
  6816. {
  6817. {
  6818. startMeasure(instance, `init`);
  6819. }
  6820. setupComponent(instance);
  6821. {
  6822. endMeasure(instance, `init`);
  6823. }
  6824. }
  6825. // setup() is async. This component relies on async logic to be resolved
  6826. // before proceeding
  6827. if (instance.asyncDep) {
  6828. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  6829. // Give it a placeholder if this is not hydration
  6830. // TODO handle self-defined fallback
  6831. if (!initialVNode.el) {
  6832. const placeholder = (instance.subTree = createVNode(Comment));
  6833. processCommentNode(null, placeholder, container, anchor);
  6834. }
  6835. return;
  6836. }
  6837. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  6838. {
  6839. popWarningContext();
  6840. endMeasure(instance, `mount`);
  6841. }
  6842. };
  6843. const updateComponent = (n1, n2, optimized) => {
  6844. const instance = (n2.component = n1.component);
  6845. if (shouldUpdateComponent(n1, n2, optimized)) {
  6846. if (instance.asyncDep &&
  6847. !instance.asyncResolved) {
  6848. // async & still pending - just update props and slots
  6849. // since the component's reactive effect for render isn't set-up yet
  6850. {
  6851. pushWarningContext(n2);
  6852. }
  6853. updateComponentPreRender(instance, n2, optimized);
  6854. {
  6855. popWarningContext();
  6856. }
  6857. return;
  6858. }
  6859. else {
  6860. // normal update
  6861. instance.next = n2;
  6862. // in case the child component is also queued, remove it to avoid
  6863. // double updating the same child component in the same flush.
  6864. invalidateJob(instance.update);
  6865. // instance.update is the reactive effect.
  6866. instance.update();
  6867. }
  6868. }
  6869. else {
  6870. // no update needed. just copy over properties
  6871. n2.el = n1.el;
  6872. instance.vnode = n2;
  6873. }
  6874. };
  6875. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  6876. const componentUpdateFn = () => {
  6877. if (!instance.isMounted) {
  6878. let vnodeHook;
  6879. const { el, props } = initialVNode;
  6880. const { bm, m, parent } = instance;
  6881. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  6882. toggleRecurse(instance, false);
  6883. // beforeMount hook
  6884. if (bm) {
  6885. invokeArrayFns(bm);
  6886. }
  6887. // onVnodeBeforeMount
  6888. if (!isAsyncWrapperVNode &&
  6889. (vnodeHook = props && props.onVnodeBeforeMount)) {
  6890. invokeVNodeHook(vnodeHook, parent, initialVNode);
  6891. }
  6892. toggleRecurse(instance, true);
  6893. if (el && hydrateNode) {
  6894. // vnode has adopted host node - perform hydration instead of mount.
  6895. const hydrateSubTree = () => {
  6896. {
  6897. startMeasure(instance, `render`);
  6898. }
  6899. instance.subTree = renderComponentRoot(instance);
  6900. {
  6901. endMeasure(instance, `render`);
  6902. }
  6903. {
  6904. startMeasure(instance, `hydrate`);
  6905. }
  6906. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  6907. {
  6908. endMeasure(instance, `hydrate`);
  6909. }
  6910. };
  6911. if (isAsyncWrapperVNode) {
  6912. initialVNode.type.__asyncLoader().then(
  6913. // note: we are moving the render call into an async callback,
  6914. // which means it won't track dependencies - but it's ok because
  6915. // a server-rendered async wrapper is already in resolved state
  6916. // and it will never need to change.
  6917. () => !instance.isUnmounted && hydrateSubTree());
  6918. }
  6919. else {
  6920. hydrateSubTree();
  6921. }
  6922. }
  6923. else {
  6924. {
  6925. startMeasure(instance, `render`);
  6926. }
  6927. const subTree = (instance.subTree = renderComponentRoot(instance));
  6928. {
  6929. endMeasure(instance, `render`);
  6930. }
  6931. {
  6932. startMeasure(instance, `patch`);
  6933. }
  6934. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  6935. {
  6936. endMeasure(instance, `patch`);
  6937. }
  6938. initialVNode.el = subTree.el;
  6939. }
  6940. // mounted hook
  6941. if (m) {
  6942. queuePostRenderEffect(m, parentSuspense);
  6943. }
  6944. // onVnodeMounted
  6945. if (!isAsyncWrapperVNode &&
  6946. (vnodeHook = props && props.onVnodeMounted)) {
  6947. const scopedInitialVNode = initialVNode;
  6948. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  6949. }
  6950. // activated hook for keep-alive roots.
  6951. // #1742 activated hook must be accessed after first render
  6952. // since the hook may be injected by a child keep-alive
  6953. if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */ ||
  6954. (parent &&
  6955. isAsyncWrapper(parent.vnode) &&
  6956. parent.vnode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */)) {
  6957. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  6958. }
  6959. instance.isMounted = true;
  6960. {
  6961. devtoolsComponentAdded(instance);
  6962. }
  6963. // #2458: deference mount-only object parameters to prevent memleaks
  6964. initialVNode = container = anchor = null;
  6965. }
  6966. else {
  6967. // updateComponent
  6968. // This is triggered by mutation of component's own state (next: null)
  6969. // OR parent calling processComponent (next: VNode)
  6970. let { next, bu, u, parent, vnode } = instance;
  6971. let originNext = next;
  6972. let vnodeHook;
  6973. {
  6974. pushWarningContext(next || instance.vnode);
  6975. }
  6976. // Disallow component effect recursion during pre-lifecycle hooks.
  6977. toggleRecurse(instance, false);
  6978. if (next) {
  6979. next.el = vnode.el;
  6980. updateComponentPreRender(instance, next, optimized);
  6981. }
  6982. else {
  6983. next = vnode;
  6984. }
  6985. // beforeUpdate hook
  6986. if (bu) {
  6987. invokeArrayFns(bu);
  6988. }
  6989. // onVnodeBeforeUpdate
  6990. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  6991. invokeVNodeHook(vnodeHook, parent, next, vnode);
  6992. }
  6993. toggleRecurse(instance, true);
  6994. // render
  6995. {
  6996. startMeasure(instance, `render`);
  6997. }
  6998. const nextTree = renderComponentRoot(instance);
  6999. {
  7000. endMeasure(instance, `render`);
  7001. }
  7002. const prevTree = instance.subTree;
  7003. instance.subTree = nextTree;
  7004. {
  7005. startMeasure(instance, `patch`);
  7006. }
  7007. patch(prevTree, nextTree,
  7008. // parent may have changed if it's in a teleport
  7009. hostParentNode(prevTree.el),
  7010. // anchor may have changed if it's in a fragment
  7011. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  7012. {
  7013. endMeasure(instance, `patch`);
  7014. }
  7015. next.el = nextTree.el;
  7016. if (originNext === null) {
  7017. // self-triggered update. In case of HOC, update parent component
  7018. // vnode el. HOC is indicated by parent instance's subTree pointing
  7019. // to child component's vnode
  7020. updateHOCHostEl(instance, nextTree.el);
  7021. }
  7022. // updated hook
  7023. if (u) {
  7024. queuePostRenderEffect(u, parentSuspense);
  7025. }
  7026. // onVnodeUpdated
  7027. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  7028. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
  7029. }
  7030. {
  7031. devtoolsComponentUpdated(instance);
  7032. }
  7033. {
  7034. popWarningContext();
  7035. }
  7036. }
  7037. };
  7038. // create reactive effect for rendering
  7039. const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
  7040. ));
  7041. const update = (instance.update = () => effect.run());
  7042. update.id = instance.uid;
  7043. // allowRecurse
  7044. // #1801, #2043 component render effects should allow recursive updates
  7045. toggleRecurse(instance, true);
  7046. {
  7047. effect.onTrack = instance.rtc
  7048. ? e => invokeArrayFns(instance.rtc, e)
  7049. : void 0;
  7050. effect.onTrigger = instance.rtg
  7051. ? e => invokeArrayFns(instance.rtg, e)
  7052. : void 0;
  7053. update.ownerInstance = instance;
  7054. }
  7055. update();
  7056. };
  7057. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7058. nextVNode.component = instance;
  7059. const prevProps = instance.vnode.props;
  7060. instance.vnode = nextVNode;
  7061. instance.next = null;
  7062. updateProps(instance, nextVNode.props, prevProps, optimized);
  7063. updateSlots(instance, nextVNode.children, optimized);
  7064. pauseTracking();
  7065. // props update may have triggered pre-flush watchers.
  7066. // flush them before the render update.
  7067. flushPreFlushCbs(undefined, instance.update);
  7068. resetTracking();
  7069. };
  7070. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7071. const c1 = n1 && n1.children;
  7072. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7073. const c2 = n2.children;
  7074. const { patchFlag, shapeFlag } = n2;
  7075. // fast path
  7076. if (patchFlag > 0) {
  7077. if (patchFlag & 128 /* KEYED_FRAGMENT */) {
  7078. // this could be either fully-keyed or mixed (some keyed some not)
  7079. // presence of patchFlag means children are guaranteed to be arrays
  7080. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7081. return;
  7082. }
  7083. else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
  7084. // unkeyed
  7085. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7086. return;
  7087. }
  7088. }
  7089. // children has 3 possibilities: text, array or no children.
  7090. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  7091. // text children fast path
  7092. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  7093. unmountChildren(c1, parentComponent, parentSuspense);
  7094. }
  7095. if (c2 !== c1) {
  7096. hostSetElementText(container, c2);
  7097. }
  7098. }
  7099. else {
  7100. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  7101. // prev children was array
  7102. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7103. // two arrays, cannot assume anything, do full diff
  7104. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7105. }
  7106. else {
  7107. // no new children, just unmount old
  7108. unmountChildren(c1, parentComponent, parentSuspense, true);
  7109. }
  7110. }
  7111. else {
  7112. // prev children was text OR null
  7113. // new children is array OR null
  7114. if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
  7115. hostSetElementText(container, '');
  7116. }
  7117. // mount new if array
  7118. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7119. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7120. }
  7121. }
  7122. }
  7123. };
  7124. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7125. c1 = c1 || EMPTY_ARR;
  7126. c2 = c2 || EMPTY_ARR;
  7127. const oldLength = c1.length;
  7128. const newLength = c2.length;
  7129. const commonLength = Math.min(oldLength, newLength);
  7130. let i;
  7131. for (i = 0; i < commonLength; i++) {
  7132. const nextChild = (c2[i] = optimized
  7133. ? cloneIfMounted(c2[i])
  7134. : normalizeVNode(c2[i]));
  7135. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7136. }
  7137. if (oldLength > newLength) {
  7138. // remove old
  7139. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  7140. }
  7141. else {
  7142. // mount new
  7143. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  7144. }
  7145. };
  7146. // can be all-keyed or mixed
  7147. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7148. let i = 0;
  7149. const l2 = c2.length;
  7150. let e1 = c1.length - 1; // prev ending index
  7151. let e2 = l2 - 1; // next ending index
  7152. // 1. sync from start
  7153. // (a b) c
  7154. // (a b) d e
  7155. while (i <= e1 && i <= e2) {
  7156. const n1 = c1[i];
  7157. const n2 = (c2[i] = optimized
  7158. ? cloneIfMounted(c2[i])
  7159. : normalizeVNode(c2[i]));
  7160. if (isSameVNodeType(n1, n2)) {
  7161. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7162. }
  7163. else {
  7164. break;
  7165. }
  7166. i++;
  7167. }
  7168. // 2. sync from end
  7169. // a (b c)
  7170. // d e (b c)
  7171. while (i <= e1 && i <= e2) {
  7172. const n1 = c1[e1];
  7173. const n2 = (c2[e2] = optimized
  7174. ? cloneIfMounted(c2[e2])
  7175. : normalizeVNode(c2[e2]));
  7176. if (isSameVNodeType(n1, n2)) {
  7177. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7178. }
  7179. else {
  7180. break;
  7181. }
  7182. e1--;
  7183. e2--;
  7184. }
  7185. // 3. common sequence + mount
  7186. // (a b)
  7187. // (a b) c
  7188. // i = 2, e1 = 1, e2 = 2
  7189. // (a b)
  7190. // c (a b)
  7191. // i = 0, e1 = -1, e2 = 0
  7192. if (i > e1) {
  7193. if (i <= e2) {
  7194. const nextPos = e2 + 1;
  7195. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7196. while (i <= e2) {
  7197. patch(null, (c2[i] = optimized
  7198. ? cloneIfMounted(c2[i])
  7199. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7200. i++;
  7201. }
  7202. }
  7203. }
  7204. // 4. common sequence + unmount
  7205. // (a b) c
  7206. // (a b)
  7207. // i = 2, e1 = 2, e2 = 1
  7208. // a (b c)
  7209. // (b c)
  7210. // i = 0, e1 = 0, e2 = -1
  7211. else if (i > e2) {
  7212. while (i <= e1) {
  7213. unmount(c1[i], parentComponent, parentSuspense, true);
  7214. i++;
  7215. }
  7216. }
  7217. // 5. unknown sequence
  7218. // [i ... e1 + 1]: a b [c d e] f g
  7219. // [i ... e2 + 1]: a b [e d c h] f g
  7220. // i = 2, e1 = 4, e2 = 5
  7221. else {
  7222. const s1 = i; // prev starting index
  7223. const s2 = i; // next starting index
  7224. // 5.1 build key:index map for newChildren
  7225. const keyToNewIndexMap = new Map();
  7226. for (i = s2; i <= e2; i++) {
  7227. const nextChild = (c2[i] = optimized
  7228. ? cloneIfMounted(c2[i])
  7229. : normalizeVNode(c2[i]));
  7230. if (nextChild.key != null) {
  7231. if (keyToNewIndexMap.has(nextChild.key)) {
  7232. warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  7233. }
  7234. keyToNewIndexMap.set(nextChild.key, i);
  7235. }
  7236. }
  7237. // 5.2 loop through old children left to be patched and try to patch
  7238. // matching nodes & remove nodes that are no longer present
  7239. let j;
  7240. let patched = 0;
  7241. const toBePatched = e2 - s2 + 1;
  7242. let moved = false;
  7243. // used to track whether any node has moved
  7244. let maxNewIndexSoFar = 0;
  7245. // works as Map<newIndex, oldIndex>
  7246. // Note that oldIndex is offset by +1
  7247. // and oldIndex = 0 is a special value indicating the new node has
  7248. // no corresponding old node.
  7249. // used for determining longest stable subsequence
  7250. const newIndexToOldIndexMap = new Array(toBePatched);
  7251. for (i = 0; i < toBePatched; i++)
  7252. newIndexToOldIndexMap[i] = 0;
  7253. for (i = s1; i <= e1; i++) {
  7254. const prevChild = c1[i];
  7255. if (patched >= toBePatched) {
  7256. // all new children have been patched so this can only be a removal
  7257. unmount(prevChild, parentComponent, parentSuspense, true);
  7258. continue;
  7259. }
  7260. let newIndex;
  7261. if (prevChild.key != null) {
  7262. newIndex = keyToNewIndexMap.get(prevChild.key);
  7263. }
  7264. else {
  7265. // key-less node, try to locate a key-less node of the same type
  7266. for (j = s2; j <= e2; j++) {
  7267. if (newIndexToOldIndexMap[j - s2] === 0 &&
  7268. isSameVNodeType(prevChild, c2[j])) {
  7269. newIndex = j;
  7270. break;
  7271. }
  7272. }
  7273. }
  7274. if (newIndex === undefined) {
  7275. unmount(prevChild, parentComponent, parentSuspense, true);
  7276. }
  7277. else {
  7278. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7279. if (newIndex >= maxNewIndexSoFar) {
  7280. maxNewIndexSoFar = newIndex;
  7281. }
  7282. else {
  7283. moved = true;
  7284. }
  7285. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7286. patched++;
  7287. }
  7288. }
  7289. // 5.3 move and mount
  7290. // generate longest stable subsequence only when nodes have moved
  7291. const increasingNewIndexSequence = moved
  7292. ? getSequence(newIndexToOldIndexMap)
  7293. : EMPTY_ARR;
  7294. j = increasingNewIndexSequence.length - 1;
  7295. // looping backwards so that we can use last patched node as anchor
  7296. for (i = toBePatched - 1; i >= 0; i--) {
  7297. const nextIndex = s2 + i;
  7298. const nextChild = c2[nextIndex];
  7299. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7300. if (newIndexToOldIndexMap[i] === 0) {
  7301. // mount new
  7302. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7303. }
  7304. else if (moved) {
  7305. // move if:
  7306. // There is no stable subsequence (e.g. a reverse)
  7307. // OR current node is not among the stable sequence
  7308. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7309. move(nextChild, container, anchor, 2 /* REORDER */);
  7310. }
  7311. else {
  7312. j--;
  7313. }
  7314. }
  7315. }
  7316. }
  7317. };
  7318. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7319. const { el, type, transition, children, shapeFlag } = vnode;
  7320. if (shapeFlag & 6 /* COMPONENT */) {
  7321. move(vnode.component.subTree, container, anchor, moveType);
  7322. return;
  7323. }
  7324. if (shapeFlag & 128 /* SUSPENSE */) {
  7325. vnode.suspense.move(container, anchor, moveType);
  7326. return;
  7327. }
  7328. if (shapeFlag & 64 /* TELEPORT */) {
  7329. type.move(vnode, container, anchor, internals);
  7330. return;
  7331. }
  7332. if (type === Fragment) {
  7333. hostInsert(el, container, anchor);
  7334. for (let i = 0; i < children.length; i++) {
  7335. move(children[i], container, anchor, moveType);
  7336. }
  7337. hostInsert(vnode.anchor, container, anchor);
  7338. return;
  7339. }
  7340. if (type === Static) {
  7341. moveStaticNode(vnode, container, anchor);
  7342. return;
  7343. }
  7344. // single nodes
  7345. const needTransition = moveType !== 2 /* REORDER */ &&
  7346. shapeFlag & 1 /* ELEMENT */ &&
  7347. transition;
  7348. if (needTransition) {
  7349. if (moveType === 0 /* ENTER */) {
  7350. transition.beforeEnter(el);
  7351. hostInsert(el, container, anchor);
  7352. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7353. }
  7354. else {
  7355. const { leave, delayLeave, afterLeave } = transition;
  7356. const remove = () => hostInsert(el, container, anchor);
  7357. const performLeave = () => {
  7358. leave(el, () => {
  7359. remove();
  7360. afterLeave && afterLeave();
  7361. });
  7362. };
  7363. if (delayLeave) {
  7364. delayLeave(el, remove, performLeave);
  7365. }
  7366. else {
  7367. performLeave();
  7368. }
  7369. }
  7370. }
  7371. else {
  7372. hostInsert(el, container, anchor);
  7373. }
  7374. };
  7375. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7376. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  7377. // unset ref
  7378. if (ref != null) {
  7379. setRef(ref, null, parentSuspense, vnode, true);
  7380. }
  7381. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  7382. parentComponent.ctx.deactivate(vnode);
  7383. return;
  7384. }
  7385. const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
  7386. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7387. let vnodeHook;
  7388. if (shouldInvokeVnodeHook &&
  7389. (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7390. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7391. }
  7392. if (shapeFlag & 6 /* COMPONENT */) {
  7393. unmountComponent(vnode.component, parentSuspense, doRemove);
  7394. }
  7395. else {
  7396. if (shapeFlag & 128 /* SUSPENSE */) {
  7397. vnode.suspense.unmount(parentSuspense, doRemove);
  7398. return;
  7399. }
  7400. if (shouldInvokeDirs) {
  7401. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  7402. }
  7403. if (shapeFlag & 64 /* TELEPORT */) {
  7404. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  7405. }
  7406. else if (dynamicChildren &&
  7407. // #1153: fast path should not be taken for non-stable (v-for) fragments
  7408. (type !== Fragment ||
  7409. (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
  7410. // fast path for block nodes: only need to unmount dynamic children.
  7411. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  7412. }
  7413. else if ((type === Fragment &&
  7414. patchFlag &
  7415. (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
  7416. (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
  7417. unmountChildren(children, parentComponent, parentSuspense);
  7418. }
  7419. if (doRemove) {
  7420. remove(vnode);
  7421. }
  7422. }
  7423. if ((shouldInvokeVnodeHook &&
  7424. (vnodeHook = props && props.onVnodeUnmounted)) ||
  7425. shouldInvokeDirs) {
  7426. queuePostRenderEffect(() => {
  7427. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7428. shouldInvokeDirs &&
  7429. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  7430. }, parentSuspense);
  7431. }
  7432. };
  7433. const remove = vnode => {
  7434. const { type, el, anchor, transition } = vnode;
  7435. if (type === Fragment) {
  7436. if (vnode.patchFlag > 0 &&
  7437. vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
  7438. transition &&
  7439. !transition.persisted) {
  7440. vnode.children.forEach(child => {
  7441. if (child.type === Comment) {
  7442. hostRemove(child.el);
  7443. }
  7444. else {
  7445. remove(child);
  7446. }
  7447. });
  7448. }
  7449. else {
  7450. removeFragment(el, anchor);
  7451. }
  7452. return;
  7453. }
  7454. if (type === Static) {
  7455. removeStaticNode(vnode);
  7456. return;
  7457. }
  7458. const performRemove = () => {
  7459. hostRemove(el);
  7460. if (transition && !transition.persisted && transition.afterLeave) {
  7461. transition.afterLeave();
  7462. }
  7463. };
  7464. if (vnode.shapeFlag & 1 /* ELEMENT */ &&
  7465. transition &&
  7466. !transition.persisted) {
  7467. const { leave, delayLeave } = transition;
  7468. const performLeave = () => leave(el, performRemove);
  7469. if (delayLeave) {
  7470. delayLeave(vnode.el, performRemove, performLeave);
  7471. }
  7472. else {
  7473. performLeave();
  7474. }
  7475. }
  7476. else {
  7477. performRemove();
  7478. }
  7479. };
  7480. const removeFragment = (cur, end) => {
  7481. // For fragments, directly remove all contained DOM nodes.
  7482. // (fragment child nodes cannot have transition)
  7483. let next;
  7484. while (cur !== end) {
  7485. next = hostNextSibling(cur);
  7486. hostRemove(cur);
  7487. cur = next;
  7488. }
  7489. hostRemove(end);
  7490. };
  7491. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7492. if (instance.type.__hmrId) {
  7493. unregisterHMR(instance);
  7494. }
  7495. const { bum, scope, update, subTree, um } = instance;
  7496. // beforeUnmount hook
  7497. if (bum) {
  7498. invokeArrayFns(bum);
  7499. }
  7500. // stop effects in component scope
  7501. scope.stop();
  7502. // update may be null if a component is unmounted before its async
  7503. // setup has resolved.
  7504. if (update) {
  7505. // so that scheduler will no longer invoke it
  7506. update.active = false;
  7507. unmount(subTree, instance, parentSuspense, doRemove);
  7508. }
  7509. // unmounted hook
  7510. if (um) {
  7511. queuePostRenderEffect(um, parentSuspense);
  7512. }
  7513. queuePostRenderEffect(() => {
  7514. instance.isUnmounted = true;
  7515. }, parentSuspense);
  7516. // A component with async dep inside a pending suspense is unmounted before
  7517. // its async dep resolves. This should remove the dep from the suspense, and
  7518. // cause the suspense to resolve immediately if that was the last dep.
  7519. if (parentSuspense &&
  7520. parentSuspense.pendingBranch &&
  7521. !parentSuspense.isUnmounted &&
  7522. instance.asyncDep &&
  7523. !instance.asyncResolved &&
  7524. instance.suspenseId === parentSuspense.pendingId) {
  7525. parentSuspense.deps--;
  7526. if (parentSuspense.deps === 0) {
  7527. parentSuspense.resolve();
  7528. }
  7529. }
  7530. {
  7531. devtoolsComponentRemoved(instance);
  7532. }
  7533. };
  7534. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7535. for (let i = start; i < children.length; i++) {
  7536. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7537. }
  7538. };
  7539. const getNextHostNode = vnode => {
  7540. if (vnode.shapeFlag & 6 /* COMPONENT */) {
  7541. return getNextHostNode(vnode.component.subTree);
  7542. }
  7543. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  7544. return vnode.suspense.next();
  7545. }
  7546. return hostNextSibling((vnode.anchor || vnode.el));
  7547. };
  7548. const render = (vnode, container, isSVG) => {
  7549. if (vnode == null) {
  7550. if (container._vnode) {
  7551. unmount(container._vnode, null, null, true);
  7552. }
  7553. }
  7554. else {
  7555. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7556. }
  7557. flushPostFlushCbs();
  7558. container._vnode = vnode;
  7559. };
  7560. const internals = {
  7561. p: patch,
  7562. um: unmount,
  7563. m: move,
  7564. r: remove,
  7565. mt: mountComponent,
  7566. mc: mountChildren,
  7567. pc: patchChildren,
  7568. pbc: patchBlockChildren,
  7569. n: getNextHostNode,
  7570. o: options
  7571. };
  7572. let hydrate;
  7573. let hydrateNode;
  7574. if (createHydrationFns) {
  7575. [hydrate, hydrateNode] = createHydrationFns(internals);
  7576. }
  7577. return {
  7578. render,
  7579. hydrate,
  7580. createApp: createAppAPI(render, hydrate)
  7581. };
  7582. }
  7583. function toggleRecurse({ effect, update }, allowed) {
  7584. effect.allowRecurse = update.allowRecurse = allowed;
  7585. }
  7586. /**
  7587. * #1156
  7588. * When a component is HMR-enabled, we need to make sure that all static nodes
  7589. * inside a block also inherit the DOM element from the previous tree so that
  7590. * HMR updates (which are full updates) can retrieve the element for patching.
  7591. *
  7592. * #2080
  7593. * Inside keyed `template` fragment static children, if a fragment is moved,
  7594. * the children will always be moved. Therefore, in order to ensure correct move
  7595. * position, el should be inherited from previous nodes.
  7596. */
  7597. function traverseStaticChildren(n1, n2, shallow = false) {
  7598. const ch1 = n1.children;
  7599. const ch2 = n2.children;
  7600. if (isArray(ch1) && isArray(ch2)) {
  7601. for (let i = 0; i < ch1.length; i++) {
  7602. // this is only called in the optimized path so array children are
  7603. // guaranteed to be vnodes
  7604. const c1 = ch1[i];
  7605. let c2 = ch2[i];
  7606. if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
  7607. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
  7608. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7609. c2.el = c1.el;
  7610. }
  7611. if (!shallow)
  7612. traverseStaticChildren(c1, c2);
  7613. }
  7614. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  7615. // would have received .el during block patch)
  7616. if (c2.type === Comment && !c2.el) {
  7617. c2.el = c1.el;
  7618. }
  7619. }
  7620. }
  7621. }
  7622. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  7623. function getSequence(arr) {
  7624. const p = arr.slice();
  7625. const result = [0];
  7626. let i, j, u, v, c;
  7627. const len = arr.length;
  7628. for (i = 0; i < len; i++) {
  7629. const arrI = arr[i];
  7630. if (arrI !== 0) {
  7631. j = result[result.length - 1];
  7632. if (arr[j] < arrI) {
  7633. p[i] = j;
  7634. result.push(i);
  7635. continue;
  7636. }
  7637. u = 0;
  7638. v = result.length - 1;
  7639. while (u < v) {
  7640. c = (u + v) >> 1;
  7641. if (arr[result[c]] < arrI) {
  7642. u = c + 1;
  7643. }
  7644. else {
  7645. v = c;
  7646. }
  7647. }
  7648. if (arrI < arr[result[u]]) {
  7649. if (u > 0) {
  7650. p[i] = result[u - 1];
  7651. }
  7652. result[u] = i;
  7653. }
  7654. }
  7655. }
  7656. u = result.length;
  7657. v = result[u - 1];
  7658. while (u-- > 0) {
  7659. result[u] = v;
  7660. v = p[v];
  7661. }
  7662. return result;
  7663. }
  7664. const isTeleport = (type) => type.__isTeleport;
  7665. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  7666. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  7667. const resolveTarget = (props, select) => {
  7668. const targetSelector = props && props.to;
  7669. if (isString(targetSelector)) {
  7670. if (!select) {
  7671. warn$1(`Current renderer does not support string target for Teleports. ` +
  7672. `(missing querySelector renderer option)`);
  7673. return null;
  7674. }
  7675. else {
  7676. const target = select(targetSelector);
  7677. if (!target) {
  7678. warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  7679. `Note the target element must exist before the component is mounted - ` +
  7680. `i.e. the target cannot be rendered by the component itself, and ` +
  7681. `ideally should be outside of the entire Vue component tree.`);
  7682. }
  7683. return target;
  7684. }
  7685. }
  7686. else {
  7687. if (!targetSelector && !isTeleportDisabled(props)) {
  7688. warn$1(`Invalid Teleport target: ${targetSelector}`);
  7689. }
  7690. return targetSelector;
  7691. }
  7692. };
  7693. const TeleportImpl = {
  7694. __isTeleport: true,
  7695. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7696. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  7697. const disabled = isTeleportDisabled(n2.props);
  7698. let { shapeFlag, children, dynamicChildren } = n2;
  7699. // #3302
  7700. // HMR updated, force full diff
  7701. if (isHmrUpdating) {
  7702. optimized = false;
  7703. dynamicChildren = null;
  7704. }
  7705. if (n1 == null) {
  7706. // insert anchors in the main view
  7707. const placeholder = (n2.el = createComment('teleport start')
  7708. );
  7709. const mainAnchor = (n2.anchor = createComment('teleport end')
  7710. );
  7711. insert(placeholder, container, anchor);
  7712. insert(mainAnchor, container, anchor);
  7713. const target = (n2.target = resolveTarget(n2.props, querySelector));
  7714. const targetAnchor = (n2.targetAnchor = createText(''));
  7715. if (target) {
  7716. insert(targetAnchor, target);
  7717. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  7718. isSVG = isSVG || isTargetSVG(target);
  7719. }
  7720. else if (!disabled) {
  7721. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
  7722. }
  7723. const mount = (container, anchor) => {
  7724. // Teleport *always* has Array children. This is enforced in both the
  7725. // compiler and vnode children normalization.
  7726. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7727. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7728. }
  7729. };
  7730. if (disabled) {
  7731. mount(container, mainAnchor);
  7732. }
  7733. else if (target) {
  7734. mount(target, targetAnchor);
  7735. }
  7736. }
  7737. else {
  7738. // update content
  7739. n2.el = n1.el;
  7740. const mainAnchor = (n2.anchor = n1.anchor);
  7741. const target = (n2.target = n1.target);
  7742. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  7743. const wasDisabled = isTeleportDisabled(n1.props);
  7744. const currentContainer = wasDisabled ? container : target;
  7745. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7746. isSVG = isSVG || isTargetSVG(target);
  7747. if (dynamicChildren) {
  7748. // fast path when the teleport happens to be a block root
  7749. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  7750. // even in block tree mode we need to make sure all root-level nodes
  7751. // in the teleport inherit previous DOM references so that they can
  7752. // be moved in future patches.
  7753. traverseStaticChildren(n1, n2, true);
  7754. }
  7755. else if (!optimized) {
  7756. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  7757. }
  7758. if (disabled) {
  7759. if (!wasDisabled) {
  7760. // enabled -> disabled
  7761. // move into main container
  7762. moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
  7763. }
  7764. }
  7765. else {
  7766. // target changed
  7767. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7768. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  7769. if (nextTarget) {
  7770. moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
  7771. }
  7772. else {
  7773. warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
  7774. }
  7775. }
  7776. else if (wasDisabled) {
  7777. // disabled -> enabled
  7778. // move into teleport target
  7779. moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
  7780. }
  7781. }
  7782. }
  7783. },
  7784. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  7785. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  7786. if (target) {
  7787. hostRemove(targetAnchor);
  7788. }
  7789. // an unmounted teleport should always remove its children if not disabled
  7790. if (doRemove || !isTeleportDisabled(props)) {
  7791. hostRemove(anchor);
  7792. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7793. for (let i = 0; i < children.length; i++) {
  7794. const child = children[i];
  7795. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  7796. }
  7797. }
  7798. }
  7799. },
  7800. move: moveTeleport,
  7801. hydrate: hydrateTeleport
  7802. };
  7803. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
  7804. // move target anchor if this is a target change.
  7805. if (moveType === 0 /* TARGET_CHANGE */) {
  7806. insert(vnode.targetAnchor, container, parentAnchor);
  7807. }
  7808. const { el, anchor, shapeFlag, children, props } = vnode;
  7809. const isReorder = moveType === 2 /* REORDER */;
  7810. // move main view anchor if this is a re-order.
  7811. if (isReorder) {
  7812. insert(el, container, parentAnchor);
  7813. }
  7814. // if this is a re-order and teleport is enabled (content is in target)
  7815. // do not move children. So the opposite is: only move children if this
  7816. // is not a reorder, or the teleport is disabled
  7817. if (!isReorder || isTeleportDisabled(props)) {
  7818. // Teleport has either Array children or no children.
  7819. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7820. for (let i = 0; i < children.length; i++) {
  7821. move(children[i], container, parentAnchor, 2 /* REORDER */);
  7822. }
  7823. }
  7824. }
  7825. // move main view anchor if this is a re-order.
  7826. if (isReorder) {
  7827. insert(anchor, container, parentAnchor);
  7828. }
  7829. }
  7830. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  7831. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  7832. if (target) {
  7833. // if multiple teleports rendered to the same target element, we need to
  7834. // pick up from where the last teleport finished instead of the first node
  7835. const targetNode = target._lpa || target.firstChild;
  7836. if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7837. if (isTeleportDisabled(vnode.props)) {
  7838. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  7839. vnode.targetAnchor = targetNode;
  7840. }
  7841. else {
  7842. vnode.anchor = nextSibling(node);
  7843. // lookahead until we find the target anchor
  7844. // we cannot rely on return value of hydrateChildren() because there
  7845. // could be nested teleports
  7846. let targetAnchor = targetNode;
  7847. while (targetAnchor) {
  7848. targetAnchor = nextSibling(targetAnchor);
  7849. if (targetAnchor &&
  7850. targetAnchor.nodeType === 8 &&
  7851. targetAnchor.data === 'teleport anchor') {
  7852. vnode.targetAnchor = targetAnchor;
  7853. target._lpa =
  7854. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  7855. break;
  7856. }
  7857. }
  7858. hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  7859. }
  7860. }
  7861. }
  7862. return vnode.anchor && nextSibling(vnode.anchor);
  7863. }
  7864. // Force-casted public typing for h and TSX props inference
  7865. const Teleport = TeleportImpl;
  7866. const Fragment = Symbol('Fragment' );
  7867. const Text = Symbol('Text' );
  7868. const Comment = Symbol('Comment' );
  7869. const Static = Symbol('Static' );
  7870. // Since v-if and v-for are the two possible ways node structure can dynamically
  7871. // change, once we consider v-if branches and each v-for fragment a block, we
  7872. // can divide a template into nested blocks, and within each block the node
  7873. // structure would be stable. This allows us to skip most children diffing
  7874. // and only worry about the dynamic nodes (indicated by patch flags).
  7875. const blockStack = [];
  7876. let currentBlock = null;
  7877. /**
  7878. * Open a block.
  7879. * This must be called before `createBlock`. It cannot be part of `createBlock`
  7880. * because the children of the block are evaluated before `createBlock` itself
  7881. * is called. The generated code typically looks like this:
  7882. *
  7883. * ```js
  7884. * function render() {
  7885. * return (openBlock(),createBlock('div', null, [...]))
  7886. * }
  7887. * ```
  7888. * disableTracking is true when creating a v-for fragment block, since a v-for
  7889. * fragment always diffs its children.
  7890. *
  7891. * @private
  7892. */
  7893. function openBlock(disableTracking = false) {
  7894. blockStack.push((currentBlock = disableTracking ? null : []));
  7895. }
  7896. function closeBlock() {
  7897. blockStack.pop();
  7898. currentBlock = blockStack[blockStack.length - 1] || null;
  7899. }
  7900. // Whether we should be tracking dynamic child nodes inside a block.
  7901. // Only tracks when this value is > 0
  7902. // We are not using a simple boolean because this value may need to be
  7903. // incremented/decremented by nested usage of v-once (see below)
  7904. let isBlockTreeEnabled = 1;
  7905. /**
  7906. * Block tracking sometimes needs to be disabled, for example during the
  7907. * creation of a tree that needs to be cached by v-once. The compiler generates
  7908. * code like this:
  7909. *
  7910. * ``` js
  7911. * _cache[1] || (
  7912. * setBlockTracking(-1),
  7913. * _cache[1] = createVNode(...),
  7914. * setBlockTracking(1),
  7915. * _cache[1]
  7916. * )
  7917. * ```
  7918. *
  7919. * @private
  7920. */
  7921. function setBlockTracking(value) {
  7922. isBlockTreeEnabled += value;
  7923. }
  7924. function setupBlock(vnode) {
  7925. // save current block children on the block vnode
  7926. vnode.dynamicChildren =
  7927. isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  7928. // close block
  7929. closeBlock();
  7930. // a block is always going to be patched, so track it as a child of its
  7931. // parent block
  7932. if (isBlockTreeEnabled > 0 && currentBlock) {
  7933. currentBlock.push(vnode);
  7934. }
  7935. return vnode;
  7936. }
  7937. /**
  7938. * @private
  7939. */
  7940. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  7941. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  7942. }
  7943. /**
  7944. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  7945. * A block root keeps track of dynamic nodes within the block in the
  7946. * `dynamicChildren` array.
  7947. *
  7948. * @private
  7949. */
  7950. function createBlock(type, props, children, patchFlag, dynamicProps) {
  7951. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  7952. }
  7953. function isVNode(value) {
  7954. return value ? value.__v_isVNode === true : false;
  7955. }
  7956. function isSameVNodeType(n1, n2) {
  7957. if (n2.shapeFlag & 6 /* COMPONENT */ &&
  7958. hmrDirtyComponents.has(n2.type)) {
  7959. // HMR only: if the component has been hot-updated, force a reload.
  7960. return false;
  7961. }
  7962. return n1.type === n2.type && n1.key === n2.key;
  7963. }
  7964. let vnodeArgsTransformer;
  7965. /**
  7966. * Internal API for registering an arguments transform for createVNode
  7967. * used for creating stubs in the test-utils
  7968. * It is *internal* but needs to be exposed for test-utils to pick up proper
  7969. * typings
  7970. */
  7971. function transformVNodeArgs(transformer) {
  7972. vnodeArgsTransformer = transformer;
  7973. }
  7974. const createVNodeWithArgsTransform = (...args) => {
  7975. return _createVNode(...(vnodeArgsTransformer
  7976. ? vnodeArgsTransformer(args, currentRenderingInstance)
  7977. : args));
  7978. };
  7979. const InternalObjectKey = `__vInternal`;
  7980. const normalizeKey = ({ key }) => key != null ? key : null;
  7981. const normalizeRef = ({ ref, ref_key, ref_for }) => {
  7982. return (ref != null
  7983. ? isString(ref) || isRef(ref) || isFunction(ref)
  7984. ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
  7985. : ref
  7986. : null);
  7987. };
  7988. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
  7989. const vnode = {
  7990. __v_isVNode: true,
  7991. __v_skip: true,
  7992. type,
  7993. props,
  7994. key: props && normalizeKey(props),
  7995. ref: props && normalizeRef(props),
  7996. scopeId: currentScopeId,
  7997. slotScopeIds: null,
  7998. children,
  7999. component: null,
  8000. suspense: null,
  8001. ssContent: null,
  8002. ssFallback: null,
  8003. dirs: null,
  8004. transition: null,
  8005. el: null,
  8006. anchor: null,
  8007. target: null,
  8008. targetAnchor: null,
  8009. staticCount: 0,
  8010. shapeFlag,
  8011. patchFlag,
  8012. dynamicProps,
  8013. dynamicChildren: null,
  8014. appContext: null
  8015. };
  8016. if (needFullChildrenNormalization) {
  8017. normalizeChildren(vnode, children);
  8018. // normalize suspense children
  8019. if (shapeFlag & 128 /* SUSPENSE */) {
  8020. type.normalize(vnode);
  8021. }
  8022. }
  8023. else if (children) {
  8024. // compiled element vnode - if children is passed, only possible types are
  8025. // string or Array.
  8026. vnode.shapeFlag |= isString(children)
  8027. ? 8 /* TEXT_CHILDREN */
  8028. : 16 /* ARRAY_CHILDREN */;
  8029. }
  8030. // validate key
  8031. if (vnode.key !== vnode.key) {
  8032. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8033. }
  8034. // track vnode for block tree
  8035. if (isBlockTreeEnabled > 0 &&
  8036. // avoid a block node from tracking itself
  8037. !isBlockNode &&
  8038. // has current parent block
  8039. currentBlock &&
  8040. // presence of a patch flag indicates this node needs patching on updates.
  8041. // component nodes also should always be patched, because even if the
  8042. // component doesn't need to update, it needs to persist the instance on to
  8043. // the next vnode so that it can be properly unmounted later.
  8044. (vnode.patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
  8045. // the EVENTS flag is only for hydration and if it is the only flag, the
  8046. // vnode should not be considered dynamic due to handler caching.
  8047. vnode.patchFlag !== 32 /* HYDRATE_EVENTS */) {
  8048. currentBlock.push(vnode);
  8049. }
  8050. return vnode;
  8051. }
  8052. const createVNode = (createVNodeWithArgsTransform );
  8053. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8054. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8055. if (!type) {
  8056. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  8057. }
  8058. type = Comment;
  8059. }
  8060. if (isVNode(type)) {
  8061. // createVNode receiving an existing vnode. This happens in cases like
  8062. // <component :is="vnode"/>
  8063. // #2078 make sure to merge refs during the clone instead of overwriting it
  8064. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  8065. if (children) {
  8066. normalizeChildren(cloned, children);
  8067. }
  8068. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8069. if (cloned.shapeFlag & 6 /* COMPONENT */) {
  8070. currentBlock[currentBlock.indexOf(type)] = cloned;
  8071. }
  8072. else {
  8073. currentBlock.push(cloned);
  8074. }
  8075. }
  8076. cloned.patchFlag |= -2 /* BAIL */;
  8077. return cloned;
  8078. }
  8079. // class component normalization.
  8080. if (isClassComponent(type)) {
  8081. type = type.__vccOpts;
  8082. }
  8083. // class & style normalization.
  8084. if (props) {
  8085. // for reactive or proxy objects, we need to clone it to enable mutation.
  8086. props = guardReactiveProps(props);
  8087. let { class: klass, style } = props;
  8088. if (klass && !isString(klass)) {
  8089. props.class = normalizeClass(klass);
  8090. }
  8091. if (isObject(style)) {
  8092. // reactive state objects need to be cloned since they are likely to be
  8093. // mutated
  8094. if (isProxy(style) && !isArray(style)) {
  8095. style = extend({}, style);
  8096. }
  8097. props.style = normalizeStyle(style);
  8098. }
  8099. }
  8100. // encode the vnode type information into a bitmap
  8101. const shapeFlag = isString(type)
  8102. ? 1 /* ELEMENT */
  8103. : isSuspense(type)
  8104. ? 128 /* SUSPENSE */
  8105. : isTeleport(type)
  8106. ? 64 /* TELEPORT */
  8107. : isObject(type)
  8108. ? 4 /* STATEFUL_COMPONENT */
  8109. : isFunction(type)
  8110. ? 2 /* FUNCTIONAL_COMPONENT */
  8111. : 0;
  8112. if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
  8113. type = toRaw(type);
  8114. warn$1(`Vue received a Component which was made a reactive object. This can ` +
  8115. `lead to unnecessary performance overhead, and should be avoided by ` +
  8116. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  8117. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  8118. }
  8119. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  8120. }
  8121. function guardReactiveProps(props) {
  8122. if (!props)
  8123. return null;
  8124. return isProxy(props) || InternalObjectKey in props
  8125. ? extend({}, props)
  8126. : props;
  8127. }
  8128. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8129. // This is intentionally NOT using spread or extend to avoid the runtime
  8130. // key enumeration cost.
  8131. const { props, ref, patchFlag, children } = vnode;
  8132. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8133. const cloned = {
  8134. __v_isVNode: true,
  8135. __v_skip: true,
  8136. type: vnode.type,
  8137. props: mergedProps,
  8138. key: mergedProps && normalizeKey(mergedProps),
  8139. ref: extraProps && extraProps.ref
  8140. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  8141. // if the vnode itself already has a ref, cloneVNode will need to merge
  8142. // the refs so the single vnode can be set on multiple refs
  8143. mergeRef && ref
  8144. ? isArray(ref)
  8145. ? ref.concat(normalizeRef(extraProps))
  8146. : [ref, normalizeRef(extraProps)]
  8147. : normalizeRef(extraProps)
  8148. : ref,
  8149. scopeId: vnode.scopeId,
  8150. slotScopeIds: vnode.slotScopeIds,
  8151. children: patchFlag === -1 /* HOISTED */ && isArray(children)
  8152. ? children.map(deepCloneVNode)
  8153. : children,
  8154. target: vnode.target,
  8155. targetAnchor: vnode.targetAnchor,
  8156. staticCount: vnode.staticCount,
  8157. shapeFlag: vnode.shapeFlag,
  8158. // if the vnode is cloned with extra props, we can no longer assume its
  8159. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8160. // note: preserve flag for fragments since they use the flag for children
  8161. // fast paths only.
  8162. patchFlag: extraProps && vnode.type !== Fragment
  8163. ? patchFlag === -1 // hoisted node
  8164. ? 16 /* FULL_PROPS */
  8165. : patchFlag | 16 /* FULL_PROPS */
  8166. : patchFlag,
  8167. dynamicProps: vnode.dynamicProps,
  8168. dynamicChildren: vnode.dynamicChildren,
  8169. appContext: vnode.appContext,
  8170. dirs: vnode.dirs,
  8171. transition: vnode.transition,
  8172. // These should technically only be non-null on mounted VNodes. However,
  8173. // they *should* be copied for kept-alive vnodes. So we just always copy
  8174. // them since them being non-null during a mount doesn't affect the logic as
  8175. // they will simply be overwritten.
  8176. component: vnode.component,
  8177. suspense: vnode.suspense,
  8178. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8179. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8180. el: vnode.el,
  8181. anchor: vnode.anchor
  8182. };
  8183. return cloned;
  8184. }
  8185. /**
  8186. * Dev only, for HMR of hoisted vnodes reused in v-for
  8187. * https://github.com/vitejs/vite/issues/2022
  8188. */
  8189. function deepCloneVNode(vnode) {
  8190. const cloned = cloneVNode(vnode);
  8191. if (isArray(vnode.children)) {
  8192. cloned.children = vnode.children.map(deepCloneVNode);
  8193. }
  8194. return cloned;
  8195. }
  8196. /**
  8197. * @private
  8198. */
  8199. function createTextVNode(text = ' ', flag = 0) {
  8200. return createVNode(Text, null, text, flag);
  8201. }
  8202. /**
  8203. * @private
  8204. */
  8205. function createStaticVNode(content, numberOfNodes) {
  8206. // A static vnode can contain multiple stringified elements, and the number
  8207. // of elements is necessary for hydration.
  8208. const vnode = createVNode(Static, null, content);
  8209. vnode.staticCount = numberOfNodes;
  8210. return vnode;
  8211. }
  8212. /**
  8213. * @private
  8214. */
  8215. function createCommentVNode(text = '',
  8216. // when used as the v-else branch, the comment node must be created as a
  8217. // block to ensure correct updates.
  8218. asBlock = false) {
  8219. return asBlock
  8220. ? (openBlock(), createBlock(Comment, null, text))
  8221. : createVNode(Comment, null, text);
  8222. }
  8223. function normalizeVNode(child) {
  8224. if (child == null || typeof child === 'boolean') {
  8225. // empty placeholder
  8226. return createVNode(Comment);
  8227. }
  8228. else if (isArray(child)) {
  8229. // fragment
  8230. return createVNode(Fragment, null,
  8231. // #3666, avoid reference pollution when reusing vnode
  8232. child.slice());
  8233. }
  8234. else if (typeof child === 'object') {
  8235. // already vnode, this should be the most common since compiled templates
  8236. // always produce all-vnode children arrays
  8237. return cloneIfMounted(child);
  8238. }
  8239. else {
  8240. // strings and numbers
  8241. return createVNode(Text, null, String(child));
  8242. }
  8243. }
  8244. // optimized normalization for template-compiled render fns
  8245. function cloneIfMounted(child) {
  8246. return child.el === null || child.memo ? child : cloneVNode(child);
  8247. }
  8248. function normalizeChildren(vnode, children) {
  8249. let type = 0;
  8250. const { shapeFlag } = vnode;
  8251. if (children == null) {
  8252. children = null;
  8253. }
  8254. else if (isArray(children)) {
  8255. type = 16 /* ARRAY_CHILDREN */;
  8256. }
  8257. else if (typeof children === 'object') {
  8258. if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
  8259. // Normalize slot to plain children for plain element and Teleport
  8260. const slot = children.default;
  8261. if (slot) {
  8262. // _c marker is added by withCtx() indicating this is a compiled slot
  8263. slot._c && (slot._d = false);
  8264. normalizeChildren(vnode, slot());
  8265. slot._c && (slot._d = true);
  8266. }
  8267. return;
  8268. }
  8269. else {
  8270. type = 32 /* SLOTS_CHILDREN */;
  8271. const slotFlag = children._;
  8272. if (!slotFlag && !(InternalObjectKey in children)) {
  8273. children._ctx = currentRenderingInstance;
  8274. }
  8275. else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
  8276. // a child component receives forwarded slots from the parent.
  8277. // its slot type is determined by its parent's slot type.
  8278. if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
  8279. children._ = 1 /* STABLE */;
  8280. }
  8281. else {
  8282. children._ = 2 /* DYNAMIC */;
  8283. vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  8284. }
  8285. }
  8286. }
  8287. }
  8288. else if (isFunction(children)) {
  8289. children = { default: children, _ctx: currentRenderingInstance };
  8290. type = 32 /* SLOTS_CHILDREN */;
  8291. }
  8292. else {
  8293. children = String(children);
  8294. // force teleport children to array so it can be moved around
  8295. if (shapeFlag & 64 /* TELEPORT */) {
  8296. type = 16 /* ARRAY_CHILDREN */;
  8297. children = [createTextVNode(children)];
  8298. }
  8299. else {
  8300. type = 8 /* TEXT_CHILDREN */;
  8301. }
  8302. }
  8303. vnode.children = children;
  8304. vnode.shapeFlag |= type;
  8305. }
  8306. function mergeProps(...args) {
  8307. const ret = {};
  8308. for (let i = 0; i < args.length; i++) {
  8309. const toMerge = args[i];
  8310. for (const key in toMerge) {
  8311. if (key === 'class') {
  8312. if (ret.class !== toMerge.class) {
  8313. ret.class = normalizeClass([ret.class, toMerge.class]);
  8314. }
  8315. }
  8316. else if (key === 'style') {
  8317. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8318. }
  8319. else if (isOn(key)) {
  8320. const existing = ret[key];
  8321. const incoming = toMerge[key];
  8322. if (incoming &&
  8323. existing !== incoming &&
  8324. !(isArray(existing) && existing.includes(incoming))) {
  8325. ret[key] = existing
  8326. ? [].concat(existing, incoming)
  8327. : incoming;
  8328. }
  8329. }
  8330. else if (key !== '') {
  8331. ret[key] = toMerge[key];
  8332. }
  8333. }
  8334. }
  8335. return ret;
  8336. }
  8337. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8338. callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
  8339. vnode,
  8340. prevVNode
  8341. ]);
  8342. }
  8343. const emptyAppContext = createAppContext();
  8344. let uid$1 = 0;
  8345. function createComponentInstance(vnode, parent, suspense) {
  8346. const type = vnode.type;
  8347. // inherit parent app context - or - if root, adopt from root vnode
  8348. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8349. const instance = {
  8350. uid: uid$1++,
  8351. vnode,
  8352. type,
  8353. parent,
  8354. appContext,
  8355. root: null,
  8356. next: null,
  8357. subTree: null,
  8358. effect: null,
  8359. update: null,
  8360. scope: new EffectScope(true /* detached */),
  8361. render: null,
  8362. proxy: null,
  8363. exposed: null,
  8364. exposeProxy: null,
  8365. withProxy: null,
  8366. provides: parent ? parent.provides : Object.create(appContext.provides),
  8367. accessCache: null,
  8368. renderCache: [],
  8369. // local resolved assets
  8370. components: null,
  8371. directives: null,
  8372. // resolved props and emits options
  8373. propsOptions: normalizePropsOptions(type, appContext),
  8374. emitsOptions: normalizeEmitsOptions(type, appContext),
  8375. // emit
  8376. emit: null,
  8377. emitted: null,
  8378. // props default value
  8379. propsDefaults: EMPTY_OBJ,
  8380. // inheritAttrs
  8381. inheritAttrs: type.inheritAttrs,
  8382. // state
  8383. ctx: EMPTY_OBJ,
  8384. data: EMPTY_OBJ,
  8385. props: EMPTY_OBJ,
  8386. attrs: EMPTY_OBJ,
  8387. slots: EMPTY_OBJ,
  8388. refs: EMPTY_OBJ,
  8389. setupState: EMPTY_OBJ,
  8390. setupContext: null,
  8391. // suspense related
  8392. suspense,
  8393. suspenseId: suspense ? suspense.pendingId : 0,
  8394. asyncDep: null,
  8395. asyncResolved: false,
  8396. // lifecycle hooks
  8397. // not using enums here because it results in computed properties
  8398. isMounted: false,
  8399. isUnmounted: false,
  8400. isDeactivated: false,
  8401. bc: null,
  8402. c: null,
  8403. bm: null,
  8404. m: null,
  8405. bu: null,
  8406. u: null,
  8407. um: null,
  8408. bum: null,
  8409. da: null,
  8410. a: null,
  8411. rtg: null,
  8412. rtc: null,
  8413. ec: null,
  8414. sp: null
  8415. };
  8416. {
  8417. instance.ctx = createDevRenderContext(instance);
  8418. }
  8419. instance.root = parent ? parent.root : instance;
  8420. instance.emit = emit$1.bind(null, instance);
  8421. // apply custom element special handling
  8422. if (vnode.ce) {
  8423. vnode.ce(instance);
  8424. }
  8425. return instance;
  8426. }
  8427. let currentInstance = null;
  8428. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8429. const setCurrentInstance = (instance) => {
  8430. currentInstance = instance;
  8431. instance.scope.on();
  8432. };
  8433. const unsetCurrentInstance = () => {
  8434. currentInstance && currentInstance.scope.off();
  8435. currentInstance = null;
  8436. };
  8437. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  8438. function validateComponentName(name, config) {
  8439. const appIsNativeTag = config.isNativeTag || NO;
  8440. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8441. warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
  8442. }
  8443. }
  8444. function isStatefulComponent(instance) {
  8445. return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
  8446. }
  8447. let isInSSRComponentSetup = false;
  8448. function setupComponent(instance, isSSR = false) {
  8449. isInSSRComponentSetup = isSSR;
  8450. const { props, children } = instance.vnode;
  8451. const isStateful = isStatefulComponent(instance);
  8452. initProps(instance, props, isStateful, isSSR);
  8453. initSlots(instance, children);
  8454. const setupResult = isStateful
  8455. ? setupStatefulComponent(instance, isSSR)
  8456. : undefined;
  8457. isInSSRComponentSetup = false;
  8458. return setupResult;
  8459. }
  8460. function setupStatefulComponent(instance, isSSR) {
  8461. var _a;
  8462. const Component = instance.type;
  8463. {
  8464. if (Component.name) {
  8465. validateComponentName(Component.name, instance.appContext.config);
  8466. }
  8467. if (Component.components) {
  8468. const names = Object.keys(Component.components);
  8469. for (let i = 0; i < names.length; i++) {
  8470. validateComponentName(names[i], instance.appContext.config);
  8471. }
  8472. }
  8473. if (Component.directives) {
  8474. const names = Object.keys(Component.directives);
  8475. for (let i = 0; i < names.length; i++) {
  8476. validateDirectiveName(names[i]);
  8477. }
  8478. }
  8479. if (Component.compilerOptions && isRuntimeOnly()) {
  8480. warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
  8481. `includes the runtime compiler. Since you are using a runtime-only ` +
  8482. `build, the options should be passed via your build tool config instead.`);
  8483. }
  8484. }
  8485. // 0. create render proxy property access cache
  8486. instance.accessCache = Object.create(null);
  8487. // 1. create public instance / render proxy
  8488. // also mark it raw so it's never observed
  8489. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8490. {
  8491. exposePropsOnRenderContext(instance);
  8492. }
  8493. // 2. call setup()
  8494. const { setup } = Component;
  8495. if (setup) {
  8496. const setupContext = (instance.setupContext =
  8497. setup.length > 1 ? createSetupContext(instance) : null);
  8498. setCurrentInstance(instance);
  8499. pauseTracking();
  8500. const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
  8501. resetTracking();
  8502. unsetCurrentInstance();
  8503. if (isPromise(setupResult)) {
  8504. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8505. if (isSSR) {
  8506. // return the promise so server-renderer can wait on it
  8507. return setupResult
  8508. .then((resolvedResult) => {
  8509. handleSetupResult(instance, resolvedResult, isSSR);
  8510. })
  8511. .catch(e => {
  8512. handleError(e, instance, 0 /* SETUP_FUNCTION */);
  8513. });
  8514. }
  8515. else {
  8516. // async setup returned Promise.
  8517. // bail here and wait for re-entry.
  8518. instance.asyncDep = setupResult;
  8519. if (!instance.suspense) {
  8520. const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
  8521. warn$1(`Component <${name}>: setup function returned a promise, but no ` +
  8522. `<Suspense> boundary was found in the parent component tree. ` +
  8523. `A component with async setup() must be nested in a <Suspense> ` +
  8524. `in order to be rendered.`);
  8525. }
  8526. }
  8527. }
  8528. else {
  8529. handleSetupResult(instance, setupResult, isSSR);
  8530. }
  8531. }
  8532. else {
  8533. finishComponentSetup(instance, isSSR);
  8534. }
  8535. }
  8536. function handleSetupResult(instance, setupResult, isSSR) {
  8537. if (isFunction(setupResult)) {
  8538. // setup returned an inline render function
  8539. {
  8540. instance.render = setupResult;
  8541. }
  8542. }
  8543. else if (isObject(setupResult)) {
  8544. if (isVNode(setupResult)) {
  8545. warn$1(`setup() should not return VNodes directly - ` +
  8546. `return a render function instead.`);
  8547. }
  8548. // setup returned bindings.
  8549. // assuming a render function compiled from template is present.
  8550. {
  8551. instance.devtoolsRawSetupState = setupResult;
  8552. }
  8553. instance.setupState = proxyRefs(setupResult);
  8554. {
  8555. exposeSetupStateOnRenderContext(instance);
  8556. }
  8557. }
  8558. else if (setupResult !== undefined) {
  8559. warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  8560. }
  8561. finishComponentSetup(instance, isSSR);
  8562. }
  8563. let compile;
  8564. let installWithProxy;
  8565. /**
  8566. * For runtime-dom to register the compiler.
  8567. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  8568. */
  8569. function registerRuntimeCompiler(_compile) {
  8570. compile = _compile;
  8571. installWithProxy = i => {
  8572. if (i.render._rc) {
  8573. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8574. }
  8575. };
  8576. }
  8577. // dev only
  8578. const isRuntimeOnly = () => !compile;
  8579. function finishComponentSetup(instance, isSSR, skipOptions) {
  8580. const Component = instance.type;
  8581. // template / render function normalization
  8582. // could be already set when returned from setup()
  8583. if (!instance.render) {
  8584. // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
  8585. // is done by server-renderer
  8586. if (!isSSR && compile && !Component.render) {
  8587. const template = Component.template;
  8588. if (template) {
  8589. {
  8590. startMeasure(instance, `compile`);
  8591. }
  8592. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8593. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8594. const finalCompilerOptions = extend(extend({
  8595. isCustomElement,
  8596. delimiters
  8597. }, compilerOptions), componentCompilerOptions);
  8598. Component.render = compile(template, finalCompilerOptions);
  8599. {
  8600. endMeasure(instance, `compile`);
  8601. }
  8602. }
  8603. }
  8604. instance.render = (Component.render || NOOP);
  8605. // for runtime-compiled render functions using `with` blocks, the render
  8606. // proxy used needs a different `has` handler which is more performant and
  8607. // also only allows a whitelist of globals to fallthrough.
  8608. if (installWithProxy) {
  8609. installWithProxy(instance);
  8610. }
  8611. }
  8612. // support for 2.x options
  8613. {
  8614. setCurrentInstance(instance);
  8615. pauseTracking();
  8616. applyOptions(instance);
  8617. resetTracking();
  8618. unsetCurrentInstance();
  8619. }
  8620. // warn missing template/render
  8621. // the runtime compilation of template in SSR is done by server-render
  8622. if (!Component.render && instance.render === NOOP && !isSSR) {
  8623. /* istanbul ignore if */
  8624. if (!compile && Component.template) {
  8625. warn$1(`Component provided template option but ` +
  8626. `runtime compilation is not supported in this build of Vue.` +
  8627. (` Use "vue.esm-browser.js" instead.`
  8628. ) /* should not happen */);
  8629. }
  8630. else {
  8631. warn$1(`Component is missing template or render function.`);
  8632. }
  8633. }
  8634. }
  8635. function createAttrsProxy(instance) {
  8636. return new Proxy(instance.attrs, {
  8637. get(target, key) {
  8638. markAttrsAccessed();
  8639. track(instance, "get" /* GET */, '$attrs');
  8640. return target[key];
  8641. },
  8642. set() {
  8643. warn$1(`setupContext.attrs is readonly.`);
  8644. return false;
  8645. },
  8646. deleteProperty() {
  8647. warn$1(`setupContext.attrs is readonly.`);
  8648. return false;
  8649. }
  8650. }
  8651. );
  8652. }
  8653. function createSetupContext(instance) {
  8654. const expose = exposed => {
  8655. if (instance.exposed) {
  8656. warn$1(`expose() should be called only once per setup().`);
  8657. }
  8658. instance.exposed = exposed || {};
  8659. };
  8660. let attrs;
  8661. {
  8662. // We use getters in dev in case libs like test-utils overwrite instance
  8663. // properties (overwrites should not be done in prod)
  8664. return Object.freeze({
  8665. get attrs() {
  8666. return attrs || (attrs = createAttrsProxy(instance));
  8667. },
  8668. get slots() {
  8669. return shallowReadonly(instance.slots);
  8670. },
  8671. get emit() {
  8672. return (event, ...args) => instance.emit(event, ...args);
  8673. },
  8674. expose
  8675. });
  8676. }
  8677. }
  8678. function getExposeProxy(instance) {
  8679. if (instance.exposed) {
  8680. return (instance.exposeProxy ||
  8681. (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8682. get(target, key) {
  8683. if (key in target) {
  8684. return target[key];
  8685. }
  8686. else if (key in publicPropertiesMap) {
  8687. return publicPropertiesMap[key](instance);
  8688. }
  8689. }
  8690. })));
  8691. }
  8692. }
  8693. const classifyRE = /(?:^|[-_])(\w)/g;
  8694. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  8695. function getComponentName(Component, includeInferred = true) {
  8696. return isFunction(Component)
  8697. ? Component.displayName || Component.name
  8698. : Component.name || (includeInferred && Component.__name);
  8699. }
  8700. /* istanbul ignore next */
  8701. function formatComponentName(instance, Component, isRoot = false) {
  8702. let name = getComponentName(Component);
  8703. if (!name && Component.__file) {
  8704. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8705. if (match) {
  8706. name = match[1];
  8707. }
  8708. }
  8709. if (!name && instance && instance.parent) {
  8710. // try to infer the name based on reverse resolution
  8711. const inferFromRegistry = (registry) => {
  8712. for (const key in registry) {
  8713. if (registry[key] === Component) {
  8714. return key;
  8715. }
  8716. }
  8717. };
  8718. name =
  8719. inferFromRegistry(instance.components ||
  8720. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  8721. }
  8722. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8723. }
  8724. function isClassComponent(value) {
  8725. return isFunction(value) && '__vccOpts' in value;
  8726. }
  8727. const computed$1 = ((getterOrOptions, debugOptions) => {
  8728. // @ts-ignore
  8729. return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8730. });
  8731. // dev only
  8732. const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
  8733. `<script setup> of a single file component. Its arguments should be ` +
  8734. `compiled away and passing it at runtime has no effect.`);
  8735. // implementation
  8736. function defineProps() {
  8737. {
  8738. warnRuntimeUsage(`defineProps`);
  8739. }
  8740. return null;
  8741. }
  8742. // implementation
  8743. function defineEmits() {
  8744. {
  8745. warnRuntimeUsage(`defineEmits`);
  8746. }
  8747. return null;
  8748. }
  8749. /**
  8750. * Vue `<script setup>` compiler macro for declaring a component's exposed
  8751. * instance properties when it is accessed by a parent component via template
  8752. * refs.
  8753. *
  8754. * `<script setup>` components are closed by default - i.e. variables inside
  8755. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  8756. * via `defineExpose`.
  8757. *
  8758. * This is only usable inside `<script setup>`, is compiled away in the
  8759. * output and should **not** be actually called at runtime.
  8760. */
  8761. function defineExpose(exposed) {
  8762. {
  8763. warnRuntimeUsage(`defineExpose`);
  8764. }
  8765. }
  8766. /**
  8767. * Vue `<script setup>` compiler macro for providing props default values when
  8768. * using type-based `defineProps` declaration.
  8769. *
  8770. * Example usage:
  8771. * ```ts
  8772. * withDefaults(defineProps<{
  8773. * size?: number
  8774. * labels?: string[]
  8775. * }>(), {
  8776. * size: 3,
  8777. * labels: () => ['default label']
  8778. * })
  8779. * ```
  8780. *
  8781. * This is only usable inside `<script setup>`, is compiled away in the output
  8782. * and should **not** be actually called at runtime.
  8783. */
  8784. function withDefaults(props, defaults) {
  8785. {
  8786. warnRuntimeUsage(`withDefaults`);
  8787. }
  8788. return null;
  8789. }
  8790. function useSlots() {
  8791. return getContext().slots;
  8792. }
  8793. function useAttrs() {
  8794. return getContext().attrs;
  8795. }
  8796. function getContext() {
  8797. const i = getCurrentInstance();
  8798. if (!i) {
  8799. warn$1(`useContext() called without active instance.`);
  8800. }
  8801. return i.setupContext || (i.setupContext = createSetupContext(i));
  8802. }
  8803. /**
  8804. * Runtime helper for merging default declarations. Imported by compiled code
  8805. * only.
  8806. * @internal
  8807. */
  8808. function mergeDefaults(raw, defaults) {
  8809. const props = isArray(raw)
  8810. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  8811. : raw;
  8812. for (const key in defaults) {
  8813. const opt = props[key];
  8814. if (opt) {
  8815. if (isArray(opt) || isFunction(opt)) {
  8816. props[key] = { type: opt, default: defaults[key] };
  8817. }
  8818. else {
  8819. opt.default = defaults[key];
  8820. }
  8821. }
  8822. else if (opt === null) {
  8823. props[key] = { default: defaults[key] };
  8824. }
  8825. else {
  8826. warn$1(`props default key "${key}" has no corresponding declaration.`);
  8827. }
  8828. }
  8829. return props;
  8830. }
  8831. /**
  8832. * Used to create a proxy for the rest element when destructuring props with
  8833. * defineProps().
  8834. * @internal
  8835. */
  8836. function createPropsRestProxy(props, excludedKeys) {
  8837. const ret = {};
  8838. for (const key in props) {
  8839. if (!excludedKeys.includes(key)) {
  8840. Object.defineProperty(ret, key, {
  8841. enumerable: true,
  8842. get: () => props[key]
  8843. });
  8844. }
  8845. }
  8846. return ret;
  8847. }
  8848. /**
  8849. * `<script setup>` helper for persisting the current instance context over
  8850. * async/await flows.
  8851. *
  8852. * `@vue/compiler-sfc` converts the following:
  8853. *
  8854. * ```ts
  8855. * const x = await foo()
  8856. * ```
  8857. *
  8858. * into:
  8859. *
  8860. * ```ts
  8861. * let __temp, __restore
  8862. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  8863. * ```
  8864. * @internal
  8865. */
  8866. function withAsyncContext(getAwaitable) {
  8867. const ctx = getCurrentInstance();
  8868. if (!ctx) {
  8869. warn$1(`withAsyncContext called without active current instance. ` +
  8870. `This is likely a bug.`);
  8871. }
  8872. let awaitable = getAwaitable();
  8873. unsetCurrentInstance();
  8874. if (isPromise(awaitable)) {
  8875. awaitable = awaitable.catch(e => {
  8876. setCurrentInstance(ctx);
  8877. throw e;
  8878. });
  8879. }
  8880. return [awaitable, () => setCurrentInstance(ctx)];
  8881. }
  8882. // Actual implementation
  8883. function h(type, propsOrChildren, children) {
  8884. const l = arguments.length;
  8885. if (l === 2) {
  8886. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8887. // single vnode without props
  8888. if (isVNode(propsOrChildren)) {
  8889. return createVNode(type, null, [propsOrChildren]);
  8890. }
  8891. // props without children
  8892. return createVNode(type, propsOrChildren);
  8893. }
  8894. else {
  8895. // omit props
  8896. return createVNode(type, null, propsOrChildren);
  8897. }
  8898. }
  8899. else {
  8900. if (l > 3) {
  8901. children = Array.prototype.slice.call(arguments, 2);
  8902. }
  8903. else if (l === 3 && isVNode(children)) {
  8904. children = [children];
  8905. }
  8906. return createVNode(type, propsOrChildren, children);
  8907. }
  8908. }
  8909. const ssrContextKey = Symbol(`ssrContext` );
  8910. const useSSRContext = () => {
  8911. {
  8912. const ctx = inject(ssrContextKey);
  8913. if (!ctx) {
  8914. warn$1(`Server rendering context not provided. Make sure to only call ` +
  8915. `useSSRContext() conditionally in the server build.`);
  8916. }
  8917. return ctx;
  8918. }
  8919. };
  8920. function initCustomFormatter() {
  8921. /* eslint-disable no-restricted-globals */
  8922. if (typeof window === 'undefined') {
  8923. return;
  8924. }
  8925. const vueStyle = { style: 'color:#3ba776' };
  8926. const numberStyle = { style: 'color:#0b1bc9' };
  8927. const stringStyle = { style: 'color:#b62e24' };
  8928. const keywordStyle = { style: 'color:#9d288c' };
  8929. // custom formatter for Chrome
  8930. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  8931. const formatter = {
  8932. header(obj) {
  8933. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  8934. if (!isObject(obj)) {
  8935. return null;
  8936. }
  8937. if (obj.__isVue) {
  8938. return ['div', vueStyle, `VueInstance`];
  8939. }
  8940. else if (isRef(obj)) {
  8941. return [
  8942. 'div',
  8943. {},
  8944. ['span', vueStyle, genRefFlag(obj)],
  8945. '<',
  8946. formatValue(obj.value),
  8947. `>`
  8948. ];
  8949. }
  8950. else if (isReactive(obj)) {
  8951. return [
  8952. 'div',
  8953. {},
  8954. ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
  8955. '<',
  8956. formatValue(obj),
  8957. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8958. ];
  8959. }
  8960. else if (isReadonly(obj)) {
  8961. return [
  8962. 'div',
  8963. {},
  8964. ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
  8965. '<',
  8966. formatValue(obj),
  8967. '>'
  8968. ];
  8969. }
  8970. return null;
  8971. },
  8972. hasBody(obj) {
  8973. return obj && obj.__isVue;
  8974. },
  8975. body(obj) {
  8976. if (obj && obj.__isVue) {
  8977. return [
  8978. 'div',
  8979. {},
  8980. ...formatInstance(obj.$)
  8981. ];
  8982. }
  8983. }
  8984. };
  8985. function formatInstance(instance) {
  8986. const blocks = [];
  8987. if (instance.type.props && instance.props) {
  8988. blocks.push(createInstanceBlock('props', toRaw(instance.props)));
  8989. }
  8990. if (instance.setupState !== EMPTY_OBJ) {
  8991. blocks.push(createInstanceBlock('setup', instance.setupState));
  8992. }
  8993. if (instance.data !== EMPTY_OBJ) {
  8994. blocks.push(createInstanceBlock('data', toRaw(instance.data)));
  8995. }
  8996. const computed = extractKeys(instance, 'computed');
  8997. if (computed) {
  8998. blocks.push(createInstanceBlock('computed', computed));
  8999. }
  9000. const injected = extractKeys(instance, 'inject');
  9001. if (injected) {
  9002. blocks.push(createInstanceBlock('injected', injected));
  9003. }
  9004. blocks.push([
  9005. 'div',
  9006. {},
  9007. [
  9008. 'span',
  9009. {
  9010. style: keywordStyle.style + ';opacity:0.66'
  9011. },
  9012. '$ (internal): '
  9013. ],
  9014. ['object', { object: instance }]
  9015. ]);
  9016. return blocks;
  9017. }
  9018. function createInstanceBlock(type, target) {
  9019. target = extend({}, target);
  9020. if (!Object.keys(target).length) {
  9021. return ['span', {}];
  9022. }
  9023. return [
  9024. 'div',
  9025. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  9026. [
  9027. 'div',
  9028. {
  9029. style: 'color:#476582'
  9030. },
  9031. type
  9032. ],
  9033. [
  9034. 'div',
  9035. {
  9036. style: 'padding-left:1.25em'
  9037. },
  9038. ...Object.keys(target).map(key => {
  9039. return [
  9040. 'div',
  9041. {},
  9042. ['span', keywordStyle, key + ': '],
  9043. formatValue(target[key], false)
  9044. ];
  9045. })
  9046. ]
  9047. ];
  9048. }
  9049. function formatValue(v, asRaw = true) {
  9050. if (typeof v === 'number') {
  9051. return ['span', numberStyle, v];
  9052. }
  9053. else if (typeof v === 'string') {
  9054. return ['span', stringStyle, JSON.stringify(v)];
  9055. }
  9056. else if (typeof v === 'boolean') {
  9057. return ['span', keywordStyle, v];
  9058. }
  9059. else if (isObject(v)) {
  9060. return ['object', { object: asRaw ? toRaw(v) : v }];
  9061. }
  9062. else {
  9063. return ['span', stringStyle, String(v)];
  9064. }
  9065. }
  9066. function extractKeys(instance, type) {
  9067. const Comp = instance.type;
  9068. if (isFunction(Comp)) {
  9069. return;
  9070. }
  9071. const extracted = {};
  9072. for (const key in instance.ctx) {
  9073. if (isKeyOfType(Comp, key, type)) {
  9074. extracted[key] = instance.ctx[key];
  9075. }
  9076. }
  9077. return extracted;
  9078. }
  9079. function isKeyOfType(Comp, key, type) {
  9080. const opts = Comp[type];
  9081. if ((isArray(opts) && opts.includes(key)) ||
  9082. (isObject(opts) && key in opts)) {
  9083. return true;
  9084. }
  9085. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  9086. return true;
  9087. }
  9088. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  9089. return true;
  9090. }
  9091. }
  9092. function genRefFlag(v) {
  9093. if (isShallow(v)) {
  9094. return `ShallowRef`;
  9095. }
  9096. if (v.effect) {
  9097. return `ComputedRef`;
  9098. }
  9099. return `Ref`;
  9100. }
  9101. if (window.devtoolsFormatters) {
  9102. window.devtoolsFormatters.push(formatter);
  9103. }
  9104. else {
  9105. window.devtoolsFormatters = [formatter];
  9106. }
  9107. }
  9108. function withMemo(memo, render, cache, index) {
  9109. const cached = cache[index];
  9110. if (cached && isMemoSame(cached, memo)) {
  9111. return cached;
  9112. }
  9113. const ret = render();
  9114. // shallow clone
  9115. ret.memo = memo.slice();
  9116. return (cache[index] = ret);
  9117. }
  9118. function isMemoSame(cached, memo) {
  9119. const prev = cached.memo;
  9120. if (prev.length != memo.length) {
  9121. return false;
  9122. }
  9123. for (let i = 0; i < prev.length; i++) {
  9124. if (hasChanged(prev[i], memo[i])) {
  9125. return false;
  9126. }
  9127. }
  9128. // make sure to let parent block track it when returning cached
  9129. if (isBlockTreeEnabled > 0 && currentBlock) {
  9130. currentBlock.push(cached);
  9131. }
  9132. return true;
  9133. }
  9134. // Core API ------------------------------------------------------------------
  9135. const version = "3.2.37";
  9136. /**
  9137. * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
  9138. * @internal
  9139. */
  9140. const ssrUtils = (null);
  9141. /**
  9142. * @internal only exposed in compat builds
  9143. */
  9144. const resolveFilter = null;
  9145. /**
  9146. * @internal only exposed in compat builds.
  9147. */
  9148. const compatUtils = (null);
  9149. const svgNS = 'http://www.w3.org/2000/svg';
  9150. const doc = (typeof document !== 'undefined' ? document : null);
  9151. const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
  9152. const nodeOps = {
  9153. insert: (child, parent, anchor) => {
  9154. parent.insertBefore(child, anchor || null);
  9155. },
  9156. remove: child => {
  9157. const parent = child.parentNode;
  9158. if (parent) {
  9159. parent.removeChild(child);
  9160. }
  9161. },
  9162. createElement: (tag, isSVG, is, props) => {
  9163. const el = isSVG
  9164. ? doc.createElementNS(svgNS, tag)
  9165. : doc.createElement(tag, is ? { is } : undefined);
  9166. if (tag === 'select' && props && props.multiple != null) {
  9167. el.setAttribute('multiple', props.multiple);
  9168. }
  9169. return el;
  9170. },
  9171. createText: text => doc.createTextNode(text),
  9172. createComment: text => doc.createComment(text),
  9173. setText: (node, text) => {
  9174. node.nodeValue = text;
  9175. },
  9176. setElementText: (el, text) => {
  9177. el.textContent = text;
  9178. },
  9179. parentNode: node => node.parentNode,
  9180. nextSibling: node => node.nextSibling,
  9181. querySelector: selector => doc.querySelector(selector),
  9182. setScopeId(el, id) {
  9183. el.setAttribute(id, '');
  9184. },
  9185. cloneNode(el) {
  9186. const cloned = el.cloneNode(true);
  9187. // #3072
  9188. // - in `patchDOMProp`, we store the actual value in the `el._value` property.
  9189. // - normally, elements using `:value` bindings will not be hoisted, but if
  9190. // the bound value is a constant, e.g. `:value="true"` - they do get
  9191. // hoisted.
  9192. // - in production, hoisted nodes are cloned when subsequent inserts, but
  9193. // cloneNode() does not copy the custom property we attached.
  9194. // - This may need to account for other custom DOM properties we attach to
  9195. // elements in addition to `_value` in the future.
  9196. if (`_value` in el) {
  9197. cloned._value = el._value;
  9198. }
  9199. return cloned;
  9200. },
  9201. // __UNSAFE__
  9202. // Reason: innerHTML.
  9203. // Static content here can only come from compiled templates.
  9204. // As long as the user only uses trusted templates, this is safe.
  9205. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9206. // <parent> before | first ... last | anchor </parent>
  9207. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9208. // #5308 can only take cached path if:
  9209. // - has a single root node
  9210. // - nextSibling info is still available
  9211. if (start && (start === end || start.nextSibling)) {
  9212. // cached
  9213. while (true) {
  9214. parent.insertBefore(start.cloneNode(true), anchor);
  9215. if (start === end || !(start = start.nextSibling))
  9216. break;
  9217. }
  9218. }
  9219. else {
  9220. // fresh insert
  9221. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9222. const template = templateContainer.content;
  9223. if (isSVG) {
  9224. // remove outer svg wrapper
  9225. const wrapper = template.firstChild;
  9226. while (wrapper.firstChild) {
  9227. template.appendChild(wrapper.firstChild);
  9228. }
  9229. template.removeChild(wrapper);
  9230. }
  9231. parent.insertBefore(template, anchor);
  9232. }
  9233. return [
  9234. // first
  9235. before ? before.nextSibling : parent.firstChild,
  9236. // last
  9237. anchor ? anchor.previousSibling : parent.lastChild
  9238. ];
  9239. }
  9240. };
  9241. // compiler should normalize class + :class bindings on the same element
  9242. // into a single binding ['staticClass', dynamic]
  9243. function patchClass(el, value, isSVG) {
  9244. // directly setting className should be faster than setAttribute in theory
  9245. // if this is an element during a transition, take the temporary transition
  9246. // classes into account.
  9247. const transitionClasses = el._vtc;
  9248. if (transitionClasses) {
  9249. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
  9250. }
  9251. if (value == null) {
  9252. el.removeAttribute('class');
  9253. }
  9254. else if (isSVG) {
  9255. el.setAttribute('class', value);
  9256. }
  9257. else {
  9258. el.className = value;
  9259. }
  9260. }
  9261. function patchStyle(el, prev, next) {
  9262. const style = el.style;
  9263. const isCssString = isString(next);
  9264. if (next && !isCssString) {
  9265. for (const key in next) {
  9266. setStyle(style, key, next[key]);
  9267. }
  9268. if (prev && !isString(prev)) {
  9269. for (const key in prev) {
  9270. if (next[key] == null) {
  9271. setStyle(style, key, '');
  9272. }
  9273. }
  9274. }
  9275. }
  9276. else {
  9277. const currentDisplay = style.display;
  9278. if (isCssString) {
  9279. if (prev !== next) {
  9280. style.cssText = next;
  9281. }
  9282. }
  9283. else if (prev) {
  9284. el.removeAttribute('style');
  9285. }
  9286. // indicates that the `display` of the element is controlled by `v-show`,
  9287. // so we always keep the current `display` value regardless of the `style`
  9288. // value, thus handing over control to `v-show`.
  9289. if ('_vod' in el) {
  9290. style.display = currentDisplay;
  9291. }
  9292. }
  9293. }
  9294. const importantRE = /\s*!important$/;
  9295. function setStyle(style, name, val) {
  9296. if (isArray(val)) {
  9297. val.forEach(v => setStyle(style, name, v));
  9298. }
  9299. else {
  9300. if (val == null)
  9301. val = '';
  9302. if (name.startsWith('--')) {
  9303. // custom property definition
  9304. style.setProperty(name, val);
  9305. }
  9306. else {
  9307. const prefixed = autoPrefix(style, name);
  9308. if (importantRE.test(val)) {
  9309. // !important
  9310. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  9311. }
  9312. else {
  9313. style[prefixed] = val;
  9314. }
  9315. }
  9316. }
  9317. }
  9318. const prefixes = ['Webkit', 'Moz', 'ms'];
  9319. const prefixCache = {};
  9320. function autoPrefix(style, rawName) {
  9321. const cached = prefixCache[rawName];
  9322. if (cached) {
  9323. return cached;
  9324. }
  9325. let name = camelize(rawName);
  9326. if (name !== 'filter' && name in style) {
  9327. return (prefixCache[rawName] = name);
  9328. }
  9329. name = capitalize(name);
  9330. for (let i = 0; i < prefixes.length; i++) {
  9331. const prefixed = prefixes[i] + name;
  9332. if (prefixed in style) {
  9333. return (prefixCache[rawName] = prefixed);
  9334. }
  9335. }
  9336. return rawName;
  9337. }
  9338. const xlinkNS = 'http://www.w3.org/1999/xlink';
  9339. function patchAttr(el, key, value, isSVG, instance) {
  9340. if (isSVG && key.startsWith('xlink:')) {
  9341. if (value == null) {
  9342. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9343. }
  9344. else {
  9345. el.setAttributeNS(xlinkNS, key, value);
  9346. }
  9347. }
  9348. else {
  9349. // note we are only checking boolean attributes that don't have a
  9350. // corresponding dom prop of the same name here.
  9351. const isBoolean = isSpecialBooleanAttr(key);
  9352. if (value == null || (isBoolean && !includeBooleanAttr(value))) {
  9353. el.removeAttribute(key);
  9354. }
  9355. else {
  9356. el.setAttribute(key, isBoolean ? '' : value);
  9357. }
  9358. }
  9359. }
  9360. // __UNSAFE__
  9361. // functions. The user is responsible for using them with only trusted content.
  9362. function patchDOMProp(el, key, value,
  9363. // the following args are passed only due to potential innerHTML/textContent
  9364. // overriding existing VNodes, in which case the old tree must be properly
  9365. // unmounted.
  9366. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9367. if (key === 'innerHTML' || key === 'textContent') {
  9368. if (prevChildren) {
  9369. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9370. }
  9371. el[key] = value == null ? '' : value;
  9372. return;
  9373. }
  9374. if (key === 'value' &&
  9375. el.tagName !== 'PROGRESS' &&
  9376. // custom elements may use _value internally
  9377. !el.tagName.includes('-')) {
  9378. // store value as _value as well since
  9379. // non-string values will be stringified.
  9380. el._value = value;
  9381. const newValue = value == null ? '' : value;
  9382. if (el.value !== newValue ||
  9383. // #4956: always set for OPTION elements because its value falls back to
  9384. // textContent if no value attribute is present. And setting .value for
  9385. // OPTION has no side effect
  9386. el.tagName === 'OPTION') {
  9387. el.value = newValue;
  9388. }
  9389. if (value == null) {
  9390. el.removeAttribute(key);
  9391. }
  9392. return;
  9393. }
  9394. let needRemove = false;
  9395. if (value === '' || value == null) {
  9396. const type = typeof el[key];
  9397. if (type === 'boolean') {
  9398. // e.g. <select multiple> compiles to { multiple: '' }
  9399. value = includeBooleanAttr(value);
  9400. }
  9401. else if (value == null && type === 'string') {
  9402. // e.g. <div :id="null">
  9403. value = '';
  9404. needRemove = true;
  9405. }
  9406. else if (type === 'number') {
  9407. // e.g. <img :width="null">
  9408. // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
  9409. value = 0;
  9410. needRemove = true;
  9411. }
  9412. }
  9413. // some properties perform value validation and throw,
  9414. // some properties has getter, no setter, will error in 'use strict'
  9415. // eg. <select :type="null"></select> <select :willValidate="null"></select>
  9416. try {
  9417. el[key] = value;
  9418. }
  9419. catch (e) {
  9420. {
  9421. warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  9422. `value ${value} is invalid.`, e);
  9423. }
  9424. }
  9425. needRemove && el.removeAttribute(key);
  9426. }
  9427. // Async edge case fix requires storing an event listener's attach timestamp.
  9428. const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
  9429. let _getNow = Date.now;
  9430. let skipTimestampCheck = false;
  9431. if (typeof window !== 'undefined') {
  9432. // Determine what event timestamp the browser is using. Annoyingly, the
  9433. // timestamp can either be hi-res (relative to page load) or low-res
  9434. // (relative to UNIX epoch), so in order to compare time we have to use the
  9435. // same timestamp type when saving the flush timestamp.
  9436. if (Date.now() > document.createEvent('Event').timeStamp) {
  9437. // if the low-res timestamp which is bigger than the event timestamp
  9438. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  9439. // and we need to use the hi-res version for event listeners as well.
  9440. _getNow = performance.now.bind(performance);
  9441. }
  9442. // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
  9443. // and does not fire microtasks in between event propagation, so safe to exclude.
  9444. const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
  9445. skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
  9446. }
  9447. return [_getNow, skipTimestampCheck];
  9448. })();
  9449. // To avoid the overhead of repeatedly calling performance.now(), we cache
  9450. // and use the same timestamp for all event listeners attached in the same tick.
  9451. let cachedNow = 0;
  9452. const p = /*#__PURE__*/ Promise.resolve();
  9453. const reset = () => {
  9454. cachedNow = 0;
  9455. };
  9456. const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
  9457. function addEventListener(el, event, handler, options) {
  9458. el.addEventListener(event, handler, options);
  9459. }
  9460. function removeEventListener(el, event, handler, options) {
  9461. el.removeEventListener(event, handler, options);
  9462. }
  9463. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9464. // vei = vue event invokers
  9465. const invokers = el._vei || (el._vei = {});
  9466. const existingInvoker = invokers[rawName];
  9467. if (nextValue && existingInvoker) {
  9468. // patch
  9469. existingInvoker.value = nextValue;
  9470. }
  9471. else {
  9472. const [name, options] = parseName(rawName);
  9473. if (nextValue) {
  9474. // add
  9475. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  9476. addEventListener(el, name, invoker, options);
  9477. }
  9478. else if (existingInvoker) {
  9479. // remove
  9480. removeEventListener(el, name, existingInvoker, options);
  9481. invokers[rawName] = undefined;
  9482. }
  9483. }
  9484. }
  9485. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9486. function parseName(name) {
  9487. let options;
  9488. if (optionsModifierRE.test(name)) {
  9489. options = {};
  9490. let m;
  9491. while ((m = name.match(optionsModifierRE))) {
  9492. name = name.slice(0, name.length - m[0].length);
  9493. options[m[0].toLowerCase()] = true;
  9494. }
  9495. }
  9496. return [hyphenate(name.slice(2)), options];
  9497. }
  9498. function createInvoker(initialValue, instance) {
  9499. const invoker = (e) => {
  9500. // async edge case #6566: inner click event triggers patch, event handler
  9501. // attached to outer element during patch, and triggered again. This
  9502. // happens because browsers fire microtask ticks between event propagation.
  9503. // the solution is simple: we save the timestamp when a handler is attached,
  9504. // and the handler would only fire if the event passed to it was fired
  9505. // AFTER it was attached.
  9506. const timeStamp = e.timeStamp || _getNow();
  9507. if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
  9508. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
  9509. }
  9510. };
  9511. invoker.value = initialValue;
  9512. invoker.attached = getNow();
  9513. return invoker;
  9514. }
  9515. function patchStopImmediatePropagation(e, value) {
  9516. if (isArray(value)) {
  9517. const originalStop = e.stopImmediatePropagation;
  9518. e.stopImmediatePropagation = () => {
  9519. originalStop.call(e);
  9520. e._stopped = true;
  9521. };
  9522. return value.map(fn => (e) => !e._stopped && fn && fn(e));
  9523. }
  9524. else {
  9525. return value;
  9526. }
  9527. }
  9528. const nativeOnRE = /^on[a-z]/;
  9529. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9530. if (key === 'class') {
  9531. patchClass(el, nextValue, isSVG);
  9532. }
  9533. else if (key === 'style') {
  9534. patchStyle(el, prevValue, nextValue);
  9535. }
  9536. else if (isOn(key)) {
  9537. // ignore v-model listeners
  9538. if (!isModelListener(key)) {
  9539. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9540. }
  9541. }
  9542. else if (key[0] === '.'
  9543. ? ((key = key.slice(1)), true)
  9544. : key[0] === '^'
  9545. ? ((key = key.slice(1)), false)
  9546. : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9547. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  9548. }
  9549. else {
  9550. // special case for <input v-model type="checkbox"> with
  9551. // :true-value & :false-value
  9552. // store value as dom properties since non-string values will be
  9553. // stringified.
  9554. if (key === 'true-value') {
  9555. el._trueValue = nextValue;
  9556. }
  9557. else if (key === 'false-value') {
  9558. el._falseValue = nextValue;
  9559. }
  9560. patchAttr(el, key, nextValue, isSVG);
  9561. }
  9562. };
  9563. function shouldSetAsProp(el, key, value, isSVG) {
  9564. if (isSVG) {
  9565. // most keys must be set as attribute on svg elements to work
  9566. // ...except innerHTML & textContent
  9567. if (key === 'innerHTML' || key === 'textContent') {
  9568. return true;
  9569. }
  9570. // or native onclick with function values
  9571. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9572. return true;
  9573. }
  9574. return false;
  9575. }
  9576. // these are enumerated attrs, however their corresponding DOM properties
  9577. // are actually booleans - this leads to setting it with a string "false"
  9578. // value leading it to be coerced to `true`, so we need to always treat
  9579. // them as attributes.
  9580. // Note that `contentEditable` doesn't have this problem: its DOM
  9581. // property is also enumerated string values.
  9582. if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
  9583. return false;
  9584. }
  9585. // #1787, #2840 form property on form elements is readonly and must be set as
  9586. // attribute.
  9587. if (key === 'form') {
  9588. return false;
  9589. }
  9590. // #1526 <input list> must be set as attribute
  9591. if (key === 'list' && el.tagName === 'INPUT') {
  9592. return false;
  9593. }
  9594. // #2766 <textarea type> must be set as attribute
  9595. if (key === 'type' && el.tagName === 'TEXTAREA') {
  9596. return false;
  9597. }
  9598. // native onclick with string value, must be set as attribute
  9599. if (nativeOnRE.test(key) && isString(value)) {
  9600. return false;
  9601. }
  9602. return key in el;
  9603. }
  9604. function defineCustomElement(options, hydrate) {
  9605. const Comp = defineComponent(options);
  9606. class VueCustomElement extends VueElement {
  9607. constructor(initialProps) {
  9608. super(Comp, initialProps, hydrate);
  9609. }
  9610. }
  9611. VueCustomElement.def = Comp;
  9612. return VueCustomElement;
  9613. }
  9614. const defineSSRCustomElement = ((options) => {
  9615. // @ts-ignore
  9616. return defineCustomElement(options, hydrate);
  9617. });
  9618. const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
  9619. });
  9620. class VueElement extends BaseClass {
  9621. constructor(_def, _props = {}, hydrate) {
  9622. super();
  9623. this._def = _def;
  9624. this._props = _props;
  9625. /**
  9626. * @internal
  9627. */
  9628. this._instance = null;
  9629. this._connected = false;
  9630. this._resolved = false;
  9631. this._numberProps = null;
  9632. if (this.shadowRoot && hydrate) {
  9633. hydrate(this._createVNode(), this.shadowRoot);
  9634. }
  9635. else {
  9636. if (this.shadowRoot) {
  9637. warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
  9638. `defined as hydratable. Use \`defineSSRCustomElement\`.`);
  9639. }
  9640. this.attachShadow({ mode: 'open' });
  9641. }
  9642. }
  9643. connectedCallback() {
  9644. this._connected = true;
  9645. if (!this._instance) {
  9646. this._resolveDef();
  9647. }
  9648. }
  9649. disconnectedCallback() {
  9650. this._connected = false;
  9651. nextTick(() => {
  9652. if (!this._connected) {
  9653. render(null, this.shadowRoot);
  9654. this._instance = null;
  9655. }
  9656. });
  9657. }
  9658. /**
  9659. * resolve inner component definition (handle possible async component)
  9660. */
  9661. _resolveDef() {
  9662. if (this._resolved) {
  9663. return;
  9664. }
  9665. this._resolved = true;
  9666. // set initial attrs
  9667. for (let i = 0; i < this.attributes.length; i++) {
  9668. this._setAttr(this.attributes[i].name);
  9669. }
  9670. // watch future attr changes
  9671. new MutationObserver(mutations => {
  9672. for (const m of mutations) {
  9673. this._setAttr(m.attributeName);
  9674. }
  9675. }).observe(this, { attributes: true });
  9676. const resolve = (def) => {
  9677. const { props, styles } = def;
  9678. const hasOptions = !isArray(props);
  9679. const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
  9680. // cast Number-type props set before resolve
  9681. let numberProps;
  9682. if (hasOptions) {
  9683. for (const key in this._props) {
  9684. const opt = props[key];
  9685. if (opt === Number || (opt && opt.type === Number)) {
  9686. this._props[key] = toNumber(this._props[key]);
  9687. (numberProps || (numberProps = Object.create(null)))[key] = true;
  9688. }
  9689. }
  9690. }
  9691. this._numberProps = numberProps;
  9692. // check if there are props set pre-upgrade or connect
  9693. for (const key of Object.keys(this)) {
  9694. if (key[0] !== '_') {
  9695. this._setProp(key, this[key], true, false);
  9696. }
  9697. }
  9698. // defining getter/setters on prototype
  9699. for (const key of rawKeys.map(camelize)) {
  9700. Object.defineProperty(this, key, {
  9701. get() {
  9702. return this._getProp(key);
  9703. },
  9704. set(val) {
  9705. this._setProp(key, val);
  9706. }
  9707. });
  9708. }
  9709. // apply CSS
  9710. this._applyStyles(styles);
  9711. // initial render
  9712. this._update();
  9713. };
  9714. const asyncDef = this._def.__asyncLoader;
  9715. if (asyncDef) {
  9716. asyncDef().then(resolve);
  9717. }
  9718. else {
  9719. resolve(this._def);
  9720. }
  9721. }
  9722. _setAttr(key) {
  9723. let value = this.getAttribute(key);
  9724. if (this._numberProps && this._numberProps[key]) {
  9725. value = toNumber(value);
  9726. }
  9727. this._setProp(camelize(key), value, false);
  9728. }
  9729. /**
  9730. * @internal
  9731. */
  9732. _getProp(key) {
  9733. return this._props[key];
  9734. }
  9735. /**
  9736. * @internal
  9737. */
  9738. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9739. if (val !== this._props[key]) {
  9740. this._props[key] = val;
  9741. if (shouldUpdate && this._instance) {
  9742. this._update();
  9743. }
  9744. // reflect
  9745. if (shouldReflect) {
  9746. if (val === true) {
  9747. this.setAttribute(hyphenate(key), '');
  9748. }
  9749. else if (typeof val === 'string' || typeof val === 'number') {
  9750. this.setAttribute(hyphenate(key), val + '');
  9751. }
  9752. else if (!val) {
  9753. this.removeAttribute(hyphenate(key));
  9754. }
  9755. }
  9756. }
  9757. }
  9758. _update() {
  9759. render(this._createVNode(), this.shadowRoot);
  9760. }
  9761. _createVNode() {
  9762. const vnode = createVNode(this._def, extend({}, this._props));
  9763. if (!this._instance) {
  9764. vnode.ce = instance => {
  9765. this._instance = instance;
  9766. instance.isCE = true;
  9767. // HMR
  9768. {
  9769. instance.ceReload = newStyles => {
  9770. // always reset styles
  9771. if (this._styles) {
  9772. this._styles.forEach(s => this.shadowRoot.removeChild(s));
  9773. this._styles.length = 0;
  9774. }
  9775. this._applyStyles(newStyles);
  9776. // if this is an async component, ceReload is called from the inner
  9777. // component so no need to reload the async wrapper
  9778. if (!this._def.__asyncLoader) {
  9779. // reload
  9780. this._instance = null;
  9781. this._update();
  9782. }
  9783. };
  9784. }
  9785. // intercept emit
  9786. instance.emit = (event, ...args) => {
  9787. this.dispatchEvent(new CustomEvent(event, {
  9788. detail: args
  9789. }));
  9790. };
  9791. // locate nearest Vue custom element parent for provide/inject
  9792. let parent = this;
  9793. while ((parent =
  9794. parent && (parent.parentNode || parent.host))) {
  9795. if (parent instanceof VueElement) {
  9796. instance.parent = parent._instance;
  9797. break;
  9798. }
  9799. }
  9800. };
  9801. }
  9802. return vnode;
  9803. }
  9804. _applyStyles(styles) {
  9805. if (styles) {
  9806. styles.forEach(css => {
  9807. const s = document.createElement('style');
  9808. s.textContent = css;
  9809. this.shadowRoot.appendChild(s);
  9810. // record for HMR
  9811. {
  9812. (this._styles || (this._styles = [])).push(s);
  9813. }
  9814. });
  9815. }
  9816. }
  9817. }
  9818. function useCssModule(name = '$style') {
  9819. /* istanbul ignore else */
  9820. {
  9821. const instance = getCurrentInstance();
  9822. if (!instance) {
  9823. warn$1(`useCssModule must be called inside setup()`);
  9824. return EMPTY_OBJ;
  9825. }
  9826. const modules = instance.type.__cssModules;
  9827. if (!modules) {
  9828. warn$1(`Current instance does not have CSS modules injected.`);
  9829. return EMPTY_OBJ;
  9830. }
  9831. const mod = modules[name];
  9832. if (!mod) {
  9833. warn$1(`Current instance does not have CSS module named "${name}".`);
  9834. return EMPTY_OBJ;
  9835. }
  9836. return mod;
  9837. }
  9838. }
  9839. /**
  9840. * Runtime helper for SFC's CSS variable injection feature.
  9841. * @private
  9842. */
  9843. function useCssVars(getter) {
  9844. const instance = getCurrentInstance();
  9845. /* istanbul ignore next */
  9846. if (!instance) {
  9847. warn$1(`useCssVars is called without current active component instance.`);
  9848. return;
  9849. }
  9850. const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
  9851. watchPostEffect(setVars);
  9852. onMounted(() => {
  9853. const ob = new MutationObserver(setVars);
  9854. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9855. onUnmounted(() => ob.disconnect());
  9856. });
  9857. }
  9858. function setVarsOnVNode(vnode, vars) {
  9859. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  9860. const suspense = vnode.suspense;
  9861. vnode = suspense.activeBranch;
  9862. if (suspense.pendingBranch && !suspense.isHydrating) {
  9863. suspense.effects.push(() => {
  9864. setVarsOnVNode(suspense.activeBranch, vars);
  9865. });
  9866. }
  9867. }
  9868. // drill down HOCs until it's a non-component vnode
  9869. while (vnode.component) {
  9870. vnode = vnode.component.subTree;
  9871. }
  9872. if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
  9873. setVarsOnNode(vnode.el, vars);
  9874. }
  9875. else if (vnode.type === Fragment) {
  9876. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  9877. }
  9878. else if (vnode.type === Static) {
  9879. let { el, anchor } = vnode;
  9880. while (el) {
  9881. setVarsOnNode(el, vars);
  9882. if (el === anchor)
  9883. break;
  9884. el = el.nextSibling;
  9885. }
  9886. }
  9887. }
  9888. function setVarsOnNode(el, vars) {
  9889. if (el.nodeType === 1) {
  9890. const style = el.style;
  9891. for (const key in vars) {
  9892. style.setProperty(`--${key}`, vars[key]);
  9893. }
  9894. }
  9895. }
  9896. const TRANSITION = 'transition';
  9897. const ANIMATION = 'animation';
  9898. // DOM Transition is a higher-order-component based on the platform-agnostic
  9899. // base Transition component, with DOM-specific logic.
  9900. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9901. Transition.displayName = 'Transition';
  9902. const DOMTransitionPropsValidators = {
  9903. name: String,
  9904. type: String,
  9905. css: {
  9906. type: Boolean,
  9907. default: true
  9908. },
  9909. duration: [String, Number, Object],
  9910. enterFromClass: String,
  9911. enterActiveClass: String,
  9912. enterToClass: String,
  9913. appearFromClass: String,
  9914. appearActiveClass: String,
  9915. appearToClass: String,
  9916. leaveFromClass: String,
  9917. leaveActiveClass: String,
  9918. leaveToClass: String
  9919. };
  9920. const TransitionPropsValidators = (Transition.props =
  9921. /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  9922. /**
  9923. * #3227 Incoming hooks may be merged into arrays when wrapping Transition
  9924. * with custom HOCs.
  9925. */
  9926. const callHook$1 = (hook, args = []) => {
  9927. if (isArray(hook)) {
  9928. hook.forEach(h => h(...args));
  9929. }
  9930. else if (hook) {
  9931. hook(...args);
  9932. }
  9933. };
  9934. /**
  9935. * Check if a hook expects a callback (2nd arg), which means the user
  9936. * intends to explicitly control the end of the transition.
  9937. */
  9938. const hasExplicitCallback = (hook) => {
  9939. return hook
  9940. ? isArray(hook)
  9941. ? hook.some(h => h.length > 1)
  9942. : hook.length > 1
  9943. : false;
  9944. };
  9945. function resolveTransitionProps(rawProps) {
  9946. const baseProps = {};
  9947. for (const key in rawProps) {
  9948. if (!(key in DOMTransitionPropsValidators)) {
  9949. baseProps[key] = rawProps[key];
  9950. }
  9951. }
  9952. if (rawProps.css === false) {
  9953. return baseProps;
  9954. }
  9955. 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;
  9956. const durations = normalizeDuration(duration);
  9957. const enterDuration = durations && durations[0];
  9958. const leaveDuration = durations && durations[1];
  9959. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  9960. const finishEnter = (el, isAppear, done) => {
  9961. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9962. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9963. done && done();
  9964. };
  9965. const finishLeave = (el, done) => {
  9966. el._isLeaving = false;
  9967. removeTransitionClass(el, leaveFromClass);
  9968. removeTransitionClass(el, leaveToClass);
  9969. removeTransitionClass(el, leaveActiveClass);
  9970. done && done();
  9971. };
  9972. const makeEnterHook = (isAppear) => {
  9973. return (el, done) => {
  9974. const hook = isAppear ? onAppear : onEnter;
  9975. const resolve = () => finishEnter(el, isAppear, done);
  9976. callHook$1(hook, [el, resolve]);
  9977. nextFrame(() => {
  9978. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9979. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9980. if (!hasExplicitCallback(hook)) {
  9981. whenTransitionEnds(el, type, enterDuration, resolve);
  9982. }
  9983. });
  9984. };
  9985. };
  9986. return extend(baseProps, {
  9987. onBeforeEnter(el) {
  9988. callHook$1(onBeforeEnter, [el]);
  9989. addTransitionClass(el, enterFromClass);
  9990. addTransitionClass(el, enterActiveClass);
  9991. },
  9992. onBeforeAppear(el) {
  9993. callHook$1(onBeforeAppear, [el]);
  9994. addTransitionClass(el, appearFromClass);
  9995. addTransitionClass(el, appearActiveClass);
  9996. },
  9997. onEnter: makeEnterHook(false),
  9998. onAppear: makeEnterHook(true),
  9999. onLeave(el, done) {
  10000. el._isLeaving = true;
  10001. const resolve = () => finishLeave(el, done);
  10002. addTransitionClass(el, leaveFromClass);
  10003. // force reflow so *-leave-from classes immediately take effect (#2593)
  10004. forceReflow();
  10005. addTransitionClass(el, leaveActiveClass);
  10006. nextFrame(() => {
  10007. if (!el._isLeaving) {
  10008. // cancelled
  10009. return;
  10010. }
  10011. removeTransitionClass(el, leaveFromClass);
  10012. addTransitionClass(el, leaveToClass);
  10013. if (!hasExplicitCallback(onLeave)) {
  10014. whenTransitionEnds(el, type, leaveDuration, resolve);
  10015. }
  10016. });
  10017. callHook$1(onLeave, [el, resolve]);
  10018. },
  10019. onEnterCancelled(el) {
  10020. finishEnter(el, false);
  10021. callHook$1(onEnterCancelled, [el]);
  10022. },
  10023. onAppearCancelled(el) {
  10024. finishEnter(el, true);
  10025. callHook$1(onAppearCancelled, [el]);
  10026. },
  10027. onLeaveCancelled(el) {
  10028. finishLeave(el);
  10029. callHook$1(onLeaveCancelled, [el]);
  10030. }
  10031. });
  10032. }
  10033. function normalizeDuration(duration) {
  10034. if (duration == null) {
  10035. return null;
  10036. }
  10037. else if (isObject(duration)) {
  10038. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  10039. }
  10040. else {
  10041. const n = NumberOf(duration);
  10042. return [n, n];
  10043. }
  10044. }
  10045. function NumberOf(val) {
  10046. const res = toNumber(val);
  10047. validateDuration(res);
  10048. return res;
  10049. }
  10050. function validateDuration(val) {
  10051. if (typeof val !== 'number') {
  10052. warn$1(`<transition> explicit duration is not a valid number - ` +
  10053. `got ${JSON.stringify(val)}.`);
  10054. }
  10055. else if (isNaN(val)) {
  10056. warn$1(`<transition> explicit duration is NaN - ` +
  10057. 'the duration expression might be incorrect.');
  10058. }
  10059. }
  10060. function addTransitionClass(el, cls) {
  10061. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  10062. (el._vtc ||
  10063. (el._vtc = new Set())).add(cls);
  10064. }
  10065. function removeTransitionClass(el, cls) {
  10066. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  10067. const { _vtc } = el;
  10068. if (_vtc) {
  10069. _vtc.delete(cls);
  10070. if (!_vtc.size) {
  10071. el._vtc = undefined;
  10072. }
  10073. }
  10074. }
  10075. function nextFrame(cb) {
  10076. requestAnimationFrame(() => {
  10077. requestAnimationFrame(cb);
  10078. });
  10079. }
  10080. let endId = 0;
  10081. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  10082. const id = (el._endId = ++endId);
  10083. const resolveIfNotStale = () => {
  10084. if (id === el._endId) {
  10085. resolve();
  10086. }
  10087. };
  10088. if (explicitTimeout) {
  10089. return setTimeout(resolveIfNotStale, explicitTimeout);
  10090. }
  10091. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  10092. if (!type) {
  10093. return resolve();
  10094. }
  10095. const endEvent = type + 'end';
  10096. let ended = 0;
  10097. const end = () => {
  10098. el.removeEventListener(endEvent, onEnd);
  10099. resolveIfNotStale();
  10100. };
  10101. const onEnd = (e) => {
  10102. if (e.target === el && ++ended >= propCount) {
  10103. end();
  10104. }
  10105. };
  10106. setTimeout(() => {
  10107. if (ended < propCount) {
  10108. end();
  10109. }
  10110. }, timeout + 1);
  10111. el.addEventListener(endEvent, onEnd);
  10112. }
  10113. function getTransitionInfo(el, expectedType) {
  10114. const styles = window.getComputedStyle(el);
  10115. // JSDOM may return undefined for transition properties
  10116. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  10117. const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
  10118. const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
  10119. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  10120. const animationDelays = getStyleProperties(ANIMATION + 'Delay');
  10121. const animationDurations = getStyleProperties(ANIMATION + 'Duration');
  10122. const animationTimeout = getTimeout(animationDelays, animationDurations);
  10123. let type = null;
  10124. let timeout = 0;
  10125. let propCount = 0;
  10126. /* istanbul ignore if */
  10127. if (expectedType === TRANSITION) {
  10128. if (transitionTimeout > 0) {
  10129. type = TRANSITION;
  10130. timeout = transitionTimeout;
  10131. propCount = transitionDurations.length;
  10132. }
  10133. }
  10134. else if (expectedType === ANIMATION) {
  10135. if (animationTimeout > 0) {
  10136. type = ANIMATION;
  10137. timeout = animationTimeout;
  10138. propCount = animationDurations.length;
  10139. }
  10140. }
  10141. else {
  10142. timeout = Math.max(transitionTimeout, animationTimeout);
  10143. type =
  10144. timeout > 0
  10145. ? transitionTimeout > animationTimeout
  10146. ? TRANSITION
  10147. : ANIMATION
  10148. : null;
  10149. propCount = type
  10150. ? type === TRANSITION
  10151. ? transitionDurations.length
  10152. : animationDurations.length
  10153. : 0;
  10154. }
  10155. const hasTransform = type === TRANSITION &&
  10156. /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
  10157. return {
  10158. type,
  10159. timeout,
  10160. propCount,
  10161. hasTransform
  10162. };
  10163. }
  10164. function getTimeout(delays, durations) {
  10165. while (delays.length < durations.length) {
  10166. delays = delays.concat(delays);
  10167. }
  10168. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  10169. }
  10170. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  10171. // numbers in a locale-dependent way, using a comma instead of a dot.
  10172. // If comma is not replaced with a dot, the input will be rounded down
  10173. // (i.e. acting as a floor function) causing unexpected behaviors
  10174. function toMs(s) {
  10175. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  10176. }
  10177. // synchronously force layout to put elements into a certain state
  10178. function forceReflow() {
  10179. return document.body.offsetHeight;
  10180. }
  10181. const positionMap = new WeakMap();
  10182. const newPositionMap = new WeakMap();
  10183. const TransitionGroupImpl = {
  10184. name: 'TransitionGroup',
  10185. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  10186. tag: String,
  10187. moveClass: String
  10188. }),
  10189. setup(props, { slots }) {
  10190. const instance = getCurrentInstance();
  10191. const state = useTransitionState();
  10192. let prevChildren;
  10193. let children;
  10194. onUpdated(() => {
  10195. // children is guaranteed to exist after initial render
  10196. if (!prevChildren.length) {
  10197. return;
  10198. }
  10199. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  10200. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  10201. return;
  10202. }
  10203. // we divide the work into three loops to avoid mixing DOM reads and writes
  10204. // in each iteration - which helps prevent layout thrashing.
  10205. prevChildren.forEach(callPendingCbs);
  10206. prevChildren.forEach(recordPosition);
  10207. const movedChildren = prevChildren.filter(applyTranslation);
  10208. // force reflow to put everything in position
  10209. forceReflow();
  10210. movedChildren.forEach(c => {
  10211. const el = c.el;
  10212. const style = el.style;
  10213. addTransitionClass(el, moveClass);
  10214. style.transform = style.webkitTransform = style.transitionDuration = '';
  10215. const cb = (el._moveCb = (e) => {
  10216. if (e && e.target !== el) {
  10217. return;
  10218. }
  10219. if (!e || /transform$/.test(e.propertyName)) {
  10220. el.removeEventListener('transitionend', cb);
  10221. el._moveCb = null;
  10222. removeTransitionClass(el, moveClass);
  10223. }
  10224. });
  10225. el.addEventListener('transitionend', cb);
  10226. });
  10227. });
  10228. return () => {
  10229. const rawProps = toRaw(props);
  10230. const cssTransitionProps = resolveTransitionProps(rawProps);
  10231. let tag = rawProps.tag || Fragment;
  10232. prevChildren = children;
  10233. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10234. for (let i = 0; i < children.length; i++) {
  10235. const child = children[i];
  10236. if (child.key != null) {
  10237. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10238. }
  10239. else {
  10240. warn$1(`<TransitionGroup> children must be keyed.`);
  10241. }
  10242. }
  10243. if (prevChildren) {
  10244. for (let i = 0; i < prevChildren.length; i++) {
  10245. const child = prevChildren[i];
  10246. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10247. positionMap.set(child, child.el.getBoundingClientRect());
  10248. }
  10249. }
  10250. return createVNode(tag, null, children);
  10251. };
  10252. }
  10253. };
  10254. const TransitionGroup = TransitionGroupImpl;
  10255. function callPendingCbs(c) {
  10256. const el = c.el;
  10257. if (el._moveCb) {
  10258. el._moveCb();
  10259. }
  10260. if (el._enterCb) {
  10261. el._enterCb();
  10262. }
  10263. }
  10264. function recordPosition(c) {
  10265. newPositionMap.set(c, c.el.getBoundingClientRect());
  10266. }
  10267. function applyTranslation(c) {
  10268. const oldPos = positionMap.get(c);
  10269. const newPos = newPositionMap.get(c);
  10270. const dx = oldPos.left - newPos.left;
  10271. const dy = oldPos.top - newPos.top;
  10272. if (dx || dy) {
  10273. const s = c.el.style;
  10274. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10275. s.transitionDuration = '0s';
  10276. return c;
  10277. }
  10278. }
  10279. function hasCSSTransform(el, root, moveClass) {
  10280. // Detect whether an element with the move class applied has
  10281. // CSS transitions. Since the element may be inside an entering
  10282. // transition at this very moment, we make a clone of it and remove
  10283. // all other transition classes applied to ensure only the move class
  10284. // is applied.
  10285. const clone = el.cloneNode();
  10286. if (el._vtc) {
  10287. el._vtc.forEach(cls => {
  10288. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  10289. });
  10290. }
  10291. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  10292. clone.style.display = 'none';
  10293. const container = (root.nodeType === 1 ? root : root.parentNode);
  10294. container.appendChild(clone);
  10295. const { hasTransform } = getTransitionInfo(clone);
  10296. container.removeChild(clone);
  10297. return hasTransform;
  10298. }
  10299. const getModelAssigner = (vnode) => {
  10300. const fn = vnode.props['onUpdate:modelValue'] ||
  10301. (false );
  10302. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  10303. };
  10304. function onCompositionStart(e) {
  10305. e.target.composing = true;
  10306. }
  10307. function onCompositionEnd(e) {
  10308. const target = e.target;
  10309. if (target.composing) {
  10310. target.composing = false;
  10311. target.dispatchEvent(new Event('input'));
  10312. }
  10313. }
  10314. // We are exporting the v-model runtime directly as vnode hooks so that it can
  10315. // be tree-shaken in case v-model is never used.
  10316. const vModelText = {
  10317. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10318. el._assign = getModelAssigner(vnode);
  10319. const castToNumber = number || (vnode.props && vnode.props.type === 'number');
  10320. addEventListener(el, lazy ? 'change' : 'input', e => {
  10321. if (e.target.composing)
  10322. return;
  10323. let domValue = el.value;
  10324. if (trim) {
  10325. domValue = domValue.trim();
  10326. }
  10327. if (castToNumber) {
  10328. domValue = toNumber(domValue);
  10329. }
  10330. el._assign(domValue);
  10331. });
  10332. if (trim) {
  10333. addEventListener(el, 'change', () => {
  10334. el.value = el.value.trim();
  10335. });
  10336. }
  10337. if (!lazy) {
  10338. addEventListener(el, 'compositionstart', onCompositionStart);
  10339. addEventListener(el, 'compositionend', onCompositionEnd);
  10340. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  10341. // switching focus before confirming composition choice
  10342. // this also fixes the issue where some browsers e.g. iOS Chrome
  10343. // fires "change" instead of "input" on autocomplete.
  10344. addEventListener(el, 'change', onCompositionEnd);
  10345. }
  10346. },
  10347. // set value on mounted so it's after min/max for type="range"
  10348. mounted(el, { value }) {
  10349. el.value = value == null ? '' : value;
  10350. },
  10351. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10352. el._assign = getModelAssigner(vnode);
  10353. // avoid clearing unresolved text. #2302
  10354. if (el.composing)
  10355. return;
  10356. if (document.activeElement === el && el.type !== 'range') {
  10357. if (lazy) {
  10358. return;
  10359. }
  10360. if (trim && el.value.trim() === value) {
  10361. return;
  10362. }
  10363. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  10364. return;
  10365. }
  10366. }
  10367. const newValue = value == null ? '' : value;
  10368. if (el.value !== newValue) {
  10369. el.value = newValue;
  10370. }
  10371. }
  10372. };
  10373. const vModelCheckbox = {
  10374. // #4096 array checkboxes need to be deep traversed
  10375. deep: true,
  10376. created(el, _, vnode) {
  10377. el._assign = getModelAssigner(vnode);
  10378. addEventListener(el, 'change', () => {
  10379. const modelValue = el._modelValue;
  10380. const elementValue = getValue(el);
  10381. const checked = el.checked;
  10382. const assign = el._assign;
  10383. if (isArray(modelValue)) {
  10384. const index = looseIndexOf(modelValue, elementValue);
  10385. const found = index !== -1;
  10386. if (checked && !found) {
  10387. assign(modelValue.concat(elementValue));
  10388. }
  10389. else if (!checked && found) {
  10390. const filtered = [...modelValue];
  10391. filtered.splice(index, 1);
  10392. assign(filtered);
  10393. }
  10394. }
  10395. else if (isSet(modelValue)) {
  10396. const cloned = new Set(modelValue);
  10397. if (checked) {
  10398. cloned.add(elementValue);
  10399. }
  10400. else {
  10401. cloned.delete(elementValue);
  10402. }
  10403. assign(cloned);
  10404. }
  10405. else {
  10406. assign(getCheckboxValue(el, checked));
  10407. }
  10408. });
  10409. },
  10410. // set initial checked on mount to wait for true-value/false-value
  10411. mounted: setChecked,
  10412. beforeUpdate(el, binding, vnode) {
  10413. el._assign = getModelAssigner(vnode);
  10414. setChecked(el, binding, vnode);
  10415. }
  10416. };
  10417. function setChecked(el, { value, oldValue }, vnode) {
  10418. el._modelValue = value;
  10419. if (isArray(value)) {
  10420. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10421. }
  10422. else if (isSet(value)) {
  10423. el.checked = value.has(vnode.props.value);
  10424. }
  10425. else if (value !== oldValue) {
  10426. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10427. }
  10428. }
  10429. const vModelRadio = {
  10430. created(el, { value }, vnode) {
  10431. el.checked = looseEqual(value, vnode.props.value);
  10432. el._assign = getModelAssigner(vnode);
  10433. addEventListener(el, 'change', () => {
  10434. el._assign(getValue(el));
  10435. });
  10436. },
  10437. beforeUpdate(el, { value, oldValue }, vnode) {
  10438. el._assign = getModelAssigner(vnode);
  10439. if (value !== oldValue) {
  10440. el.checked = looseEqual(value, vnode.props.value);
  10441. }
  10442. }
  10443. };
  10444. const vModelSelect = {
  10445. // <select multiple> value need to be deep traversed
  10446. deep: true,
  10447. created(el, { value, modifiers: { number } }, vnode) {
  10448. const isSetModel = isSet(value);
  10449. addEventListener(el, 'change', () => {
  10450. const selectedVal = Array.prototype.filter
  10451. .call(el.options, (o) => o.selected)
  10452. .map((o) => number ? toNumber(getValue(o)) : getValue(o));
  10453. el._assign(el.multiple
  10454. ? isSetModel
  10455. ? new Set(selectedVal)
  10456. : selectedVal
  10457. : selectedVal[0]);
  10458. });
  10459. el._assign = getModelAssigner(vnode);
  10460. },
  10461. // set value in mounted & updated because <select> relies on its children
  10462. // <option>s.
  10463. mounted(el, { value }) {
  10464. setSelected(el, value);
  10465. },
  10466. beforeUpdate(el, _binding, vnode) {
  10467. el._assign = getModelAssigner(vnode);
  10468. },
  10469. updated(el, { value }) {
  10470. setSelected(el, value);
  10471. }
  10472. };
  10473. function setSelected(el, value) {
  10474. const isMultiple = el.multiple;
  10475. if (isMultiple && !isArray(value) && !isSet(value)) {
  10476. warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  10477. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  10478. return;
  10479. }
  10480. for (let i = 0, l = el.options.length; i < l; i++) {
  10481. const option = el.options[i];
  10482. const optionValue = getValue(option);
  10483. if (isMultiple) {
  10484. if (isArray(value)) {
  10485. option.selected = looseIndexOf(value, optionValue) > -1;
  10486. }
  10487. else {
  10488. option.selected = value.has(optionValue);
  10489. }
  10490. }
  10491. else {
  10492. if (looseEqual(getValue(option), value)) {
  10493. if (el.selectedIndex !== i)
  10494. el.selectedIndex = i;
  10495. return;
  10496. }
  10497. }
  10498. }
  10499. if (!isMultiple && el.selectedIndex !== -1) {
  10500. el.selectedIndex = -1;
  10501. }
  10502. }
  10503. // retrieve raw value set via :value bindings
  10504. function getValue(el) {
  10505. return '_value' in el ? el._value : el.value;
  10506. }
  10507. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  10508. function getCheckboxValue(el, checked) {
  10509. const key = checked ? '_trueValue' : '_falseValue';
  10510. return key in el ? el[key] : checked;
  10511. }
  10512. const vModelDynamic = {
  10513. created(el, binding, vnode) {
  10514. callModelHook(el, binding, vnode, null, 'created');
  10515. },
  10516. mounted(el, binding, vnode) {
  10517. callModelHook(el, binding, vnode, null, 'mounted');
  10518. },
  10519. beforeUpdate(el, binding, vnode, prevVNode) {
  10520. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  10521. },
  10522. updated(el, binding, vnode, prevVNode) {
  10523. callModelHook(el, binding, vnode, prevVNode, 'updated');
  10524. }
  10525. };
  10526. function resolveDynamicModel(tagName, type) {
  10527. switch (tagName) {
  10528. case 'SELECT':
  10529. return vModelSelect;
  10530. case 'TEXTAREA':
  10531. return vModelText;
  10532. default:
  10533. switch (type) {
  10534. case 'checkbox':
  10535. return vModelCheckbox;
  10536. case 'radio':
  10537. return vModelRadio;
  10538. default:
  10539. return vModelText;
  10540. }
  10541. }
  10542. }
  10543. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10544. const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
  10545. const fn = modelToUse[hook];
  10546. fn && fn(el, binding, vnode, prevVNode);
  10547. }
  10548. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  10549. const modifierGuards = {
  10550. stop: e => e.stopPropagation(),
  10551. prevent: e => e.preventDefault(),
  10552. self: e => e.target !== e.currentTarget,
  10553. ctrl: e => !e.ctrlKey,
  10554. shift: e => !e.shiftKey,
  10555. alt: e => !e.altKey,
  10556. meta: e => !e.metaKey,
  10557. left: e => 'button' in e && e.button !== 0,
  10558. middle: e => 'button' in e && e.button !== 1,
  10559. right: e => 'button' in e && e.button !== 2,
  10560. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  10561. };
  10562. /**
  10563. * @private
  10564. */
  10565. const withModifiers = (fn, modifiers) => {
  10566. return (event, ...args) => {
  10567. for (let i = 0; i < modifiers.length; i++) {
  10568. const guard = modifierGuards[modifiers[i]];
  10569. if (guard && guard(event, modifiers))
  10570. return;
  10571. }
  10572. return fn(event, ...args);
  10573. };
  10574. };
  10575. // Kept for 2.x compat.
  10576. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  10577. const keyNames = {
  10578. esc: 'escape',
  10579. space: ' ',
  10580. up: 'arrow-up',
  10581. left: 'arrow-left',
  10582. right: 'arrow-right',
  10583. down: 'arrow-down',
  10584. delete: 'backspace'
  10585. };
  10586. /**
  10587. * @private
  10588. */
  10589. const withKeys = (fn, modifiers) => {
  10590. return (event) => {
  10591. if (!('key' in event)) {
  10592. return;
  10593. }
  10594. const eventKey = hyphenate(event.key);
  10595. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  10596. return fn(event);
  10597. }
  10598. };
  10599. };
  10600. const vShow = {
  10601. beforeMount(el, { value }, { transition }) {
  10602. el._vod = el.style.display === 'none' ? '' : el.style.display;
  10603. if (transition && value) {
  10604. transition.beforeEnter(el);
  10605. }
  10606. else {
  10607. setDisplay(el, value);
  10608. }
  10609. },
  10610. mounted(el, { value }, { transition }) {
  10611. if (transition && value) {
  10612. transition.enter(el);
  10613. }
  10614. },
  10615. updated(el, { value, oldValue }, { transition }) {
  10616. if (!value === !oldValue)
  10617. return;
  10618. if (transition) {
  10619. if (value) {
  10620. transition.beforeEnter(el);
  10621. setDisplay(el, true);
  10622. transition.enter(el);
  10623. }
  10624. else {
  10625. transition.leave(el, () => {
  10626. setDisplay(el, false);
  10627. });
  10628. }
  10629. }
  10630. else {
  10631. setDisplay(el, value);
  10632. }
  10633. },
  10634. beforeUnmount(el, { value }) {
  10635. setDisplay(el, value);
  10636. }
  10637. };
  10638. function setDisplay(el, value) {
  10639. el.style.display = value ? el._vod : 'none';
  10640. }
  10641. const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
  10642. // lazy create the renderer - this makes core renderer logic tree-shakable
  10643. // in case the user only imports reactivity utilities from Vue.
  10644. let renderer;
  10645. let enabledHydration = false;
  10646. function ensureRenderer() {
  10647. return (renderer ||
  10648. (renderer = createRenderer(rendererOptions)));
  10649. }
  10650. function ensureHydrationRenderer() {
  10651. renderer = enabledHydration
  10652. ? renderer
  10653. : createHydrationRenderer(rendererOptions);
  10654. enabledHydration = true;
  10655. return renderer;
  10656. }
  10657. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  10658. const render = ((...args) => {
  10659. ensureRenderer().render(...args);
  10660. });
  10661. const hydrate = ((...args) => {
  10662. ensureHydrationRenderer().hydrate(...args);
  10663. });
  10664. const createApp = ((...args) => {
  10665. const app = ensureRenderer().createApp(...args);
  10666. {
  10667. injectNativeTagCheck(app);
  10668. injectCompilerOptionsCheck(app);
  10669. }
  10670. const { mount } = app;
  10671. app.mount = (containerOrSelector) => {
  10672. const container = normalizeContainer(containerOrSelector);
  10673. if (!container)
  10674. return;
  10675. const component = app._component;
  10676. if (!isFunction(component) && !component.render && !component.template) {
  10677. // __UNSAFE__
  10678. // Reason: potential execution of JS expressions in in-DOM template.
  10679. // The user must make sure the in-DOM template is trusted. If it's
  10680. // rendered by the server, the template should not contain any user data.
  10681. component.template = container.innerHTML;
  10682. }
  10683. // clear content before mounting
  10684. container.innerHTML = '';
  10685. const proxy = mount(container, false, container instanceof SVGElement);
  10686. if (container instanceof Element) {
  10687. container.removeAttribute('v-cloak');
  10688. container.setAttribute('data-v-app', '');
  10689. }
  10690. return proxy;
  10691. };
  10692. return app;
  10693. });
  10694. const createSSRApp = ((...args) => {
  10695. const app = ensureHydrationRenderer().createApp(...args);
  10696. {
  10697. injectNativeTagCheck(app);
  10698. injectCompilerOptionsCheck(app);
  10699. }
  10700. const { mount } = app;
  10701. app.mount = (containerOrSelector) => {
  10702. const container = normalizeContainer(containerOrSelector);
  10703. if (container) {
  10704. return mount(container, true, container instanceof SVGElement);
  10705. }
  10706. };
  10707. return app;
  10708. });
  10709. function injectNativeTagCheck(app) {
  10710. // Inject `isNativeTag`
  10711. // this is used for component name validation (dev only)
  10712. Object.defineProperty(app.config, 'isNativeTag', {
  10713. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10714. writable: false
  10715. });
  10716. }
  10717. // dev only
  10718. function injectCompilerOptionsCheck(app) {
  10719. if (isRuntimeOnly()) {
  10720. const isCustomElement = app.config.isCustomElement;
  10721. Object.defineProperty(app.config, 'isCustomElement', {
  10722. get() {
  10723. return isCustomElement;
  10724. },
  10725. set() {
  10726. warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
  10727. `\`compilerOptions.isCustomElement\` instead.`);
  10728. }
  10729. });
  10730. const compilerOptions = app.config.compilerOptions;
  10731. const msg = `The \`compilerOptions\` config option is only respected when using ` +
  10732. `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
  10733. `Since you are using the runtime-only build, \`compilerOptions\` ` +
  10734. `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
  10735. `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
  10736. `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
  10737. `- 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`;
  10738. Object.defineProperty(app.config, 'compilerOptions', {
  10739. get() {
  10740. warn$1(msg);
  10741. return compilerOptions;
  10742. },
  10743. set() {
  10744. warn$1(msg);
  10745. }
  10746. });
  10747. }
  10748. }
  10749. function normalizeContainer(container) {
  10750. if (isString(container)) {
  10751. const res = document.querySelector(container);
  10752. if (!res) {
  10753. warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
  10754. }
  10755. return res;
  10756. }
  10757. if (window.ShadowRoot &&
  10758. container instanceof window.ShadowRoot &&
  10759. container.mode === 'closed') {
  10760. warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
  10761. }
  10762. return container;
  10763. }
  10764. /**
  10765. * @internal
  10766. */
  10767. const initDirectivesForSSR = NOOP;
  10768. function initDev() {
  10769. {
  10770. {
  10771. console.info(`You are running a development build of Vue.\n` +
  10772. `Make sure to use the production build (*.prod.js) when deploying for production.`);
  10773. }
  10774. initCustomFormatter();
  10775. }
  10776. }
  10777. // This entry exports the runtime only, and is built as
  10778. {
  10779. initDev();
  10780. }
  10781. const compile$1 = () => {
  10782. {
  10783. warn$1(`Runtime compilation is not supported in this build of Vue.` +
  10784. (` Use "vue.esm-browser.js" instead.`
  10785. ) /* should not happen */);
  10786. }
  10787. };
  10788. export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compile$1 as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };