vue.global.js 469 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505
  1. var Vue = (function (exports) {
  2. 'use strict';
  3. function makeMap(str, expectsLowerCase) {
  4. const map = /* @__PURE__ */ Object.create(null);
  5. const list = str.split(",");
  6. for (let i = 0; i < list.length; i++) {
  7. map[list[i]] = true;
  8. }
  9. return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
  10. }
  11. const EMPTY_OBJ = Object.freeze({}) ;
  12. const EMPTY_ARR = Object.freeze([]) ;
  13. const NOOP = () => {
  14. };
  15. const NO = () => false;
  16. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  17. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  18. const isModelListener = (key) => key.startsWith("onUpdate:");
  19. const extend = Object.assign;
  20. const remove = (arr, el) => {
  21. const i = arr.indexOf(el);
  22. if (i > -1) {
  23. arr.splice(i, 1);
  24. }
  25. };
  26. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  27. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
  28. const isArray = Array.isArray;
  29. const isMap = (val) => toTypeString(val) === "[object Map]";
  30. const isSet = (val) => toTypeString(val) === "[object Set]";
  31. const isDate = (val) => toTypeString(val) === "[object Date]";
  32. const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
  33. const isFunction = (val) => typeof val === "function";
  34. const isString = (val) => typeof val === "string";
  35. const isSymbol = (val) => typeof val === "symbol";
  36. const isObject = (val) => val !== null && typeof val === "object";
  37. const isPromise = (val) => {
  38. return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
  39. };
  40. const objectToString = Object.prototype.toString;
  41. const toTypeString = (value) => objectToString.call(value);
  42. const toRawType = (value) => {
  43. return toTypeString(value).slice(8, -1);
  44. };
  45. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  46. const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  47. const isReservedProp = /* @__PURE__ */ makeMap(
  48. // the leading comma is intentional so empty string "" is also included
  49. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  50. );
  51. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  52. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  53. );
  54. const cacheStringFunction = (fn) => {
  55. const cache = /* @__PURE__ */ Object.create(null);
  56. return (str) => {
  57. const hit = cache[str];
  58. return hit || (cache[str] = fn(str));
  59. };
  60. };
  61. const camelizeRE = /-(\w)/g;
  62. const camelize = cacheStringFunction((str) => {
  63. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  64. });
  65. const hyphenateRE = /\B([A-Z])/g;
  66. const hyphenate = cacheStringFunction(
  67. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  68. );
  69. const capitalize = cacheStringFunction((str) => {
  70. return str.charAt(0).toUpperCase() + str.slice(1);
  71. });
  72. const toHandlerKey = cacheStringFunction((str) => {
  73. const s = str ? `on${capitalize(str)}` : ``;
  74. return s;
  75. });
  76. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  77. const invokeArrayFns = (fns, arg) => {
  78. for (let i = 0; i < fns.length; i++) {
  79. fns[i](arg);
  80. }
  81. };
  82. const def = (obj, key, value) => {
  83. Object.defineProperty(obj, key, {
  84. configurable: true,
  85. enumerable: false,
  86. value
  87. });
  88. };
  89. const looseToNumber = (val) => {
  90. const n = parseFloat(val);
  91. return isNaN(n) ? val : n;
  92. };
  93. const toNumber = (val) => {
  94. const n = isString(val) ? Number(val) : NaN;
  95. return isNaN(n) ? val : n;
  96. };
  97. let _globalThis;
  98. const getGlobalThis = () => {
  99. return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  100. };
  101. const PatchFlagNames = {
  102. [1]: `TEXT`,
  103. [2]: `CLASS`,
  104. [4]: `STYLE`,
  105. [8]: `PROPS`,
  106. [16]: `FULL_PROPS`,
  107. [32]: `NEED_HYDRATION`,
  108. [64]: `STABLE_FRAGMENT`,
  109. [128]: `KEYED_FRAGMENT`,
  110. [256]: `UNKEYED_FRAGMENT`,
  111. [512]: `NEED_PATCH`,
  112. [1024]: `DYNAMIC_SLOTS`,
  113. [2048]: `DEV_ROOT_FRAGMENT`,
  114. [-1]: `HOISTED`,
  115. [-2]: `BAIL`
  116. };
  117. const slotFlagsText = {
  118. [1]: "STABLE",
  119. [2]: "DYNAMIC",
  120. [3]: "FORWARDED"
  121. };
  122. const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
  123. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  124. const range = 2;
  125. function generateCodeFrame(source, start = 0, end = source.length) {
  126. let lines = source.split(/(\r?\n)/);
  127. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  128. lines = lines.filter((_, idx) => idx % 2 === 0);
  129. let count = 0;
  130. const res = [];
  131. for (let i = 0; i < lines.length; i++) {
  132. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  133. if (count >= start) {
  134. for (let j = i - range; j <= i + range || end > count; j++) {
  135. if (j < 0 || j >= lines.length)
  136. continue;
  137. const line = j + 1;
  138. res.push(
  139. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  140. );
  141. const lineLength = lines[j].length;
  142. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  143. if (j === i) {
  144. const pad = start - (count - (lineLength + newLineSeqLength));
  145. const length = Math.max(
  146. 1,
  147. end > count ? lineLength - pad : end - start
  148. );
  149. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  150. } else if (j > i) {
  151. if (end > count) {
  152. const length = Math.max(Math.min(end - count, lineLength), 1);
  153. res.push(` | ` + "^".repeat(length));
  154. }
  155. count += lineLength + newLineSeqLength;
  156. }
  157. }
  158. break;
  159. }
  160. }
  161. return res.join("\n");
  162. }
  163. function normalizeStyle(value) {
  164. if (isArray(value)) {
  165. const res = {};
  166. for (let i = 0; i < value.length; i++) {
  167. const item = value[i];
  168. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
  169. if (normalized) {
  170. for (const key in normalized) {
  171. res[key] = normalized[key];
  172. }
  173. }
  174. }
  175. return res;
  176. } else if (isString(value) || isObject(value)) {
  177. return value;
  178. }
  179. }
  180. const listDelimiterRE = /;(?![^(]*\))/g;
  181. const propertyDelimiterRE = /:([^]+)/;
  182. const styleCommentRE = /\/\*[^]*?\*\//g;
  183. function parseStringStyle(cssText) {
  184. const ret = {};
  185. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  186. if (item) {
  187. const tmp = item.split(propertyDelimiterRE);
  188. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  189. }
  190. });
  191. return ret;
  192. }
  193. function normalizeClass(value) {
  194. let res = "";
  195. if (isString(value)) {
  196. res = value;
  197. } else if (isArray(value)) {
  198. for (let i = 0; i < value.length; i++) {
  199. const normalized = normalizeClass(value[i]);
  200. if (normalized) {
  201. res += normalized + " ";
  202. }
  203. }
  204. } else if (isObject(value)) {
  205. for (const name in value) {
  206. if (value[name]) {
  207. res += name + " ";
  208. }
  209. }
  210. }
  211. return res.trim();
  212. }
  213. function normalizeProps(props) {
  214. if (!props)
  215. return null;
  216. let { class: klass, style } = props;
  217. if (klass && !isString(klass)) {
  218. props.class = normalizeClass(klass);
  219. }
  220. if (style) {
  221. props.style = normalizeStyle(style);
  222. }
  223. return props;
  224. }
  225. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  226. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  227. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  228. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  229. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  230. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  231. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  232. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
  233. function includeBooleanAttr(value) {
  234. return !!value || value === "";
  235. }
  236. function looseCompareArrays(a, b) {
  237. if (a.length !== b.length)
  238. return false;
  239. let equal = true;
  240. for (let i = 0; equal && i < a.length; i++) {
  241. equal = looseEqual(a[i], b[i]);
  242. }
  243. return equal;
  244. }
  245. function looseEqual(a, b) {
  246. if (a === b)
  247. return true;
  248. let aValidType = isDate(a);
  249. let bValidType = isDate(b);
  250. if (aValidType || bValidType) {
  251. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  252. }
  253. aValidType = isSymbol(a);
  254. bValidType = isSymbol(b);
  255. if (aValidType || bValidType) {
  256. return a === b;
  257. }
  258. aValidType = isArray(a);
  259. bValidType = isArray(b);
  260. if (aValidType || bValidType) {
  261. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  262. }
  263. aValidType = isObject(a);
  264. bValidType = isObject(b);
  265. if (aValidType || bValidType) {
  266. if (!aValidType || !bValidType) {
  267. return false;
  268. }
  269. const aKeysCount = Object.keys(a).length;
  270. const bKeysCount = Object.keys(b).length;
  271. if (aKeysCount !== bKeysCount) {
  272. return false;
  273. }
  274. for (const key in a) {
  275. const aHasKey = a.hasOwnProperty(key);
  276. const bHasKey = b.hasOwnProperty(key);
  277. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
  278. return false;
  279. }
  280. }
  281. }
  282. return String(a) === String(b);
  283. }
  284. function looseIndexOf(arr, val) {
  285. return arr.findIndex((item) => looseEqual(item, val));
  286. }
  287. const toDisplayString = (val) => {
  288. return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
  289. };
  290. const replacer = (_key, val) => {
  291. if (val && val.__v_isRef) {
  292. return replacer(_key, val.value);
  293. } else if (isMap(val)) {
  294. return {
  295. [`Map(${val.size})`]: [...val.entries()].reduce(
  296. (entries, [key, val2], i) => {
  297. entries[stringifySymbol(key, i) + " =>"] = val2;
  298. return entries;
  299. },
  300. {}
  301. )
  302. };
  303. } else if (isSet(val)) {
  304. return {
  305. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  306. };
  307. } else if (isSymbol(val)) {
  308. return stringifySymbol(val);
  309. } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  310. return String(val);
  311. }
  312. return val;
  313. };
  314. const stringifySymbol = (v, i = "") => {
  315. var _a;
  316. return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
  317. };
  318. function warn$1(msg, ...args) {
  319. console.warn(`[Vue warn] ${msg}`, ...args);
  320. }
  321. let activeEffectScope;
  322. class EffectScope {
  323. constructor(detached = false) {
  324. this.detached = detached;
  325. /**
  326. * @internal
  327. */
  328. this._active = true;
  329. /**
  330. * @internal
  331. */
  332. this.effects = [];
  333. /**
  334. * @internal
  335. */
  336. this.cleanups = [];
  337. this.parent = activeEffectScope;
  338. if (!detached && activeEffectScope) {
  339. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  340. this
  341. ) - 1;
  342. }
  343. }
  344. get active() {
  345. return this._active;
  346. }
  347. run(fn) {
  348. if (this._active) {
  349. const currentEffectScope = activeEffectScope;
  350. try {
  351. activeEffectScope = this;
  352. return fn();
  353. } finally {
  354. activeEffectScope = currentEffectScope;
  355. }
  356. } else {
  357. warn$1(`cannot run an inactive effect scope.`);
  358. }
  359. }
  360. /**
  361. * This should only be called on non-detached scopes
  362. * @internal
  363. */
  364. on() {
  365. activeEffectScope = this;
  366. }
  367. /**
  368. * This should only be called on non-detached scopes
  369. * @internal
  370. */
  371. off() {
  372. activeEffectScope = this.parent;
  373. }
  374. stop(fromParent) {
  375. if (this._active) {
  376. let i, l;
  377. for (i = 0, l = this.effects.length; i < l; i++) {
  378. this.effects[i].stop();
  379. }
  380. for (i = 0, l = this.cleanups.length; i < l; i++) {
  381. this.cleanups[i]();
  382. }
  383. if (this.scopes) {
  384. for (i = 0, l = this.scopes.length; i < l; i++) {
  385. this.scopes[i].stop(true);
  386. }
  387. }
  388. if (!this.detached && this.parent && !fromParent) {
  389. const last = this.parent.scopes.pop();
  390. if (last && last !== this) {
  391. this.parent.scopes[this.index] = last;
  392. last.index = this.index;
  393. }
  394. }
  395. this.parent = void 0;
  396. this._active = false;
  397. }
  398. }
  399. }
  400. function effectScope(detached) {
  401. return new EffectScope(detached);
  402. }
  403. function recordEffectScope(effect, scope = activeEffectScope) {
  404. if (scope && scope.active) {
  405. scope.effects.push(effect);
  406. }
  407. }
  408. function getCurrentScope() {
  409. return activeEffectScope;
  410. }
  411. function onScopeDispose(fn) {
  412. if (activeEffectScope) {
  413. activeEffectScope.cleanups.push(fn);
  414. } else {
  415. warn$1(
  416. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  417. );
  418. }
  419. }
  420. const createDep = (effects) => {
  421. const dep = new Set(effects);
  422. dep.w = 0;
  423. dep.n = 0;
  424. return dep;
  425. };
  426. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  427. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  428. const initDepMarkers = ({ deps }) => {
  429. if (deps.length) {
  430. for (let i = 0; i < deps.length; i++) {
  431. deps[i].w |= trackOpBit;
  432. }
  433. }
  434. };
  435. const finalizeDepMarkers = (effect) => {
  436. const { deps } = effect;
  437. if (deps.length) {
  438. let ptr = 0;
  439. for (let i = 0; i < deps.length; i++) {
  440. const dep = deps[i];
  441. if (wasTracked(dep) && !newTracked(dep)) {
  442. dep.delete(effect);
  443. } else {
  444. deps[ptr++] = dep;
  445. }
  446. dep.w &= ~trackOpBit;
  447. dep.n &= ~trackOpBit;
  448. }
  449. deps.length = ptr;
  450. }
  451. };
  452. const targetMap = /* @__PURE__ */ new WeakMap();
  453. let effectTrackDepth = 0;
  454. let trackOpBit = 1;
  455. const maxMarkerBits = 30;
  456. let activeEffect;
  457. const ITERATE_KEY = Symbol("iterate" );
  458. const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
  459. class ReactiveEffect {
  460. constructor(fn, scheduler = null, scope) {
  461. this.fn = fn;
  462. this.scheduler = scheduler;
  463. this.active = true;
  464. this.deps = [];
  465. this.parent = void 0;
  466. recordEffectScope(this, scope);
  467. }
  468. run() {
  469. if (!this.active) {
  470. return this.fn();
  471. }
  472. let parent = activeEffect;
  473. let lastShouldTrack = shouldTrack;
  474. while (parent) {
  475. if (parent === this) {
  476. return;
  477. }
  478. parent = parent.parent;
  479. }
  480. try {
  481. this.parent = activeEffect;
  482. activeEffect = this;
  483. shouldTrack = true;
  484. trackOpBit = 1 << ++effectTrackDepth;
  485. if (effectTrackDepth <= maxMarkerBits) {
  486. initDepMarkers(this);
  487. } else {
  488. cleanupEffect(this);
  489. }
  490. return this.fn();
  491. } finally {
  492. if (effectTrackDepth <= maxMarkerBits) {
  493. finalizeDepMarkers(this);
  494. }
  495. trackOpBit = 1 << --effectTrackDepth;
  496. activeEffect = this.parent;
  497. shouldTrack = lastShouldTrack;
  498. this.parent = void 0;
  499. if (this.deferStop) {
  500. this.stop();
  501. }
  502. }
  503. }
  504. stop() {
  505. if (activeEffect === this) {
  506. this.deferStop = true;
  507. } else if (this.active) {
  508. cleanupEffect(this);
  509. if (this.onStop) {
  510. this.onStop();
  511. }
  512. this.active = false;
  513. }
  514. }
  515. }
  516. function cleanupEffect(effect2) {
  517. const { deps } = effect2;
  518. if (deps.length) {
  519. for (let i = 0; i < deps.length; i++) {
  520. deps[i].delete(effect2);
  521. }
  522. deps.length = 0;
  523. }
  524. }
  525. function effect(fn, options) {
  526. if (fn.effect instanceof ReactiveEffect) {
  527. fn = fn.effect.fn;
  528. }
  529. const _effect = new ReactiveEffect(fn);
  530. if (options) {
  531. extend(_effect, options);
  532. if (options.scope)
  533. recordEffectScope(_effect, options.scope);
  534. }
  535. if (!options || !options.lazy) {
  536. _effect.run();
  537. }
  538. const runner = _effect.run.bind(_effect);
  539. runner.effect = _effect;
  540. return runner;
  541. }
  542. function stop(runner) {
  543. runner.effect.stop();
  544. }
  545. let shouldTrack = true;
  546. const trackStack = [];
  547. function pauseTracking() {
  548. trackStack.push(shouldTrack);
  549. shouldTrack = false;
  550. }
  551. function resetTracking() {
  552. const last = trackStack.pop();
  553. shouldTrack = last === void 0 ? true : last;
  554. }
  555. function track(target, type, key) {
  556. if (shouldTrack && activeEffect) {
  557. let depsMap = targetMap.get(target);
  558. if (!depsMap) {
  559. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  560. }
  561. let dep = depsMap.get(key);
  562. if (!dep) {
  563. depsMap.set(key, dep = createDep());
  564. }
  565. const eventInfo = { effect: activeEffect, target, type, key } ;
  566. trackEffects(dep, eventInfo);
  567. }
  568. }
  569. function trackEffects(dep, debuggerEventExtraInfo) {
  570. let shouldTrack2 = false;
  571. if (effectTrackDepth <= maxMarkerBits) {
  572. if (!newTracked(dep)) {
  573. dep.n |= trackOpBit;
  574. shouldTrack2 = !wasTracked(dep);
  575. }
  576. } else {
  577. shouldTrack2 = !dep.has(activeEffect);
  578. }
  579. if (shouldTrack2) {
  580. dep.add(activeEffect);
  581. activeEffect.deps.push(dep);
  582. if (activeEffect.onTrack) {
  583. activeEffect.onTrack(
  584. extend(
  585. {
  586. effect: activeEffect
  587. },
  588. debuggerEventExtraInfo
  589. )
  590. );
  591. }
  592. }
  593. }
  594. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  595. const depsMap = targetMap.get(target);
  596. if (!depsMap) {
  597. return;
  598. }
  599. let deps = [];
  600. if (type === "clear") {
  601. deps = [...depsMap.values()];
  602. } else if (key === "length" && isArray(target)) {
  603. const newLength = Number(newValue);
  604. depsMap.forEach((dep, key2) => {
  605. if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
  606. deps.push(dep);
  607. }
  608. });
  609. } else {
  610. if (key !== void 0) {
  611. deps.push(depsMap.get(key));
  612. }
  613. switch (type) {
  614. case "add":
  615. if (!isArray(target)) {
  616. deps.push(depsMap.get(ITERATE_KEY));
  617. if (isMap(target)) {
  618. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  619. }
  620. } else if (isIntegerKey(key)) {
  621. deps.push(depsMap.get("length"));
  622. }
  623. break;
  624. case "delete":
  625. if (!isArray(target)) {
  626. deps.push(depsMap.get(ITERATE_KEY));
  627. if (isMap(target)) {
  628. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  629. }
  630. }
  631. break;
  632. case "set":
  633. if (isMap(target)) {
  634. deps.push(depsMap.get(ITERATE_KEY));
  635. }
  636. break;
  637. }
  638. }
  639. const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
  640. if (deps.length === 1) {
  641. if (deps[0]) {
  642. {
  643. triggerEffects(deps[0], eventInfo);
  644. }
  645. }
  646. } else {
  647. const effects = [];
  648. for (const dep of deps) {
  649. if (dep) {
  650. effects.push(...dep);
  651. }
  652. }
  653. {
  654. triggerEffects(createDep(effects), eventInfo);
  655. }
  656. }
  657. }
  658. function triggerEffects(dep, debuggerEventExtraInfo) {
  659. const effects = isArray(dep) ? dep : [...dep];
  660. for (const effect2 of effects) {
  661. if (effect2.computed) {
  662. triggerEffect(effect2, debuggerEventExtraInfo);
  663. }
  664. }
  665. for (const effect2 of effects) {
  666. if (!effect2.computed) {
  667. triggerEffect(effect2, debuggerEventExtraInfo);
  668. }
  669. }
  670. }
  671. function triggerEffect(effect2, debuggerEventExtraInfo) {
  672. if (effect2 !== activeEffect || effect2.allowRecurse) {
  673. if (effect2.onTrigger) {
  674. effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
  675. }
  676. if (effect2.scheduler) {
  677. effect2.scheduler();
  678. } else {
  679. effect2.run();
  680. }
  681. }
  682. }
  683. function getDepFromReactive(object, key) {
  684. var _a;
  685. return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
  686. }
  687. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  688. const builtInSymbols = new Set(
  689. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  690. );
  691. const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
  692. function createArrayInstrumentations() {
  693. const instrumentations = {};
  694. ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
  695. instrumentations[key] = function(...args) {
  696. const arr = toRaw(this);
  697. for (let i = 0, l = this.length; i < l; i++) {
  698. track(arr, "get", i + "");
  699. }
  700. const res = arr[key](...args);
  701. if (res === -1 || res === false) {
  702. return arr[key](...args.map(toRaw));
  703. } else {
  704. return res;
  705. }
  706. };
  707. });
  708. ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
  709. instrumentations[key] = function(...args) {
  710. pauseTracking();
  711. const res = toRaw(this)[key].apply(this, args);
  712. resetTracking();
  713. return res;
  714. };
  715. });
  716. return instrumentations;
  717. }
  718. function hasOwnProperty(key) {
  719. const obj = toRaw(this);
  720. track(obj, "has", key);
  721. return obj.hasOwnProperty(key);
  722. }
  723. class BaseReactiveHandler {
  724. constructor(_isReadonly = false, _shallow = false) {
  725. this._isReadonly = _isReadonly;
  726. this._shallow = _shallow;
  727. }
  728. get(target, key, receiver) {
  729. const isReadonly2 = this._isReadonly, shallow = this._shallow;
  730. if (key === "__v_isReactive") {
  731. return !isReadonly2;
  732. } else if (key === "__v_isReadonly") {
  733. return isReadonly2;
  734. } else if (key === "__v_isShallow") {
  735. return shallow;
  736. } else if (key === "__v_raw") {
  737. if (receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  738. // this means the reciever is a user proxy of the reactive proxy
  739. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  740. return target;
  741. }
  742. return;
  743. }
  744. const targetIsArray = isArray(target);
  745. if (!isReadonly2) {
  746. if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
  747. return Reflect.get(arrayInstrumentations, key, receiver);
  748. }
  749. if (key === "hasOwnProperty") {
  750. return hasOwnProperty;
  751. }
  752. }
  753. const res = Reflect.get(target, key, receiver);
  754. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  755. return res;
  756. }
  757. if (!isReadonly2) {
  758. track(target, "get", key);
  759. }
  760. if (shallow) {
  761. return res;
  762. }
  763. if (isRef(res)) {
  764. return targetIsArray && isIntegerKey(key) ? res : res.value;
  765. }
  766. if (isObject(res)) {
  767. return isReadonly2 ? readonly(res) : reactive(res);
  768. }
  769. return res;
  770. }
  771. }
  772. class MutableReactiveHandler extends BaseReactiveHandler {
  773. constructor(shallow = false) {
  774. super(false, shallow);
  775. }
  776. set(target, key, value, receiver) {
  777. let oldValue = target[key];
  778. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  779. return false;
  780. }
  781. if (!this._shallow) {
  782. if (!isShallow(value) && !isReadonly(value)) {
  783. oldValue = toRaw(oldValue);
  784. value = toRaw(value);
  785. }
  786. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  787. oldValue.value = value;
  788. return true;
  789. }
  790. }
  791. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
  792. const result = Reflect.set(target, key, value, receiver);
  793. if (target === toRaw(receiver)) {
  794. if (!hadKey) {
  795. trigger(target, "add", key, value);
  796. } else if (hasChanged(value, oldValue)) {
  797. trigger(target, "set", key, value, oldValue);
  798. }
  799. }
  800. return result;
  801. }
  802. deleteProperty(target, key) {
  803. const hadKey = hasOwn(target, key);
  804. const oldValue = target[key];
  805. const result = Reflect.deleteProperty(target, key);
  806. if (result && hadKey) {
  807. trigger(target, "delete", key, void 0, oldValue);
  808. }
  809. return result;
  810. }
  811. has(target, key) {
  812. const result = Reflect.has(target, key);
  813. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  814. track(target, "has", key);
  815. }
  816. return result;
  817. }
  818. ownKeys(target) {
  819. track(
  820. target,
  821. "iterate",
  822. isArray(target) ? "length" : ITERATE_KEY
  823. );
  824. return Reflect.ownKeys(target);
  825. }
  826. }
  827. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  828. constructor(shallow = false) {
  829. super(true, shallow);
  830. }
  831. set(target, key) {
  832. {
  833. warn$1(
  834. `Set operation on key "${String(key)}" failed: target is readonly.`,
  835. target
  836. );
  837. }
  838. return true;
  839. }
  840. deleteProperty(target, key) {
  841. {
  842. warn$1(
  843. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  844. target
  845. );
  846. }
  847. return true;
  848. }
  849. }
  850. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  851. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  852. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
  853. true
  854. );
  855. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  856. const toShallow = (value) => value;
  857. const getProto = (v) => Reflect.getPrototypeOf(v);
  858. function get(target, key, isReadonly = false, isShallow = false) {
  859. target = target["__v_raw"];
  860. const rawTarget = toRaw(target);
  861. const rawKey = toRaw(key);
  862. if (!isReadonly) {
  863. if (hasChanged(key, rawKey)) {
  864. track(rawTarget, "get", key);
  865. }
  866. track(rawTarget, "get", rawKey);
  867. }
  868. const { has: has2 } = getProto(rawTarget);
  869. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  870. if (has2.call(rawTarget, key)) {
  871. return wrap(target.get(key));
  872. } else if (has2.call(rawTarget, rawKey)) {
  873. return wrap(target.get(rawKey));
  874. } else if (target !== rawTarget) {
  875. target.get(key);
  876. }
  877. }
  878. function has(key, isReadonly = false) {
  879. const target = this["__v_raw"];
  880. const rawTarget = toRaw(target);
  881. const rawKey = toRaw(key);
  882. if (!isReadonly) {
  883. if (hasChanged(key, rawKey)) {
  884. track(rawTarget, "has", key);
  885. }
  886. track(rawTarget, "has", rawKey);
  887. }
  888. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  889. }
  890. function size(target, isReadonly = false) {
  891. target = target["__v_raw"];
  892. !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
  893. return Reflect.get(target, "size", target);
  894. }
  895. function add(value) {
  896. value = toRaw(value);
  897. const target = toRaw(this);
  898. const proto = getProto(target);
  899. const hadKey = proto.has.call(target, value);
  900. if (!hadKey) {
  901. target.add(value);
  902. trigger(target, "add", value, value);
  903. }
  904. return this;
  905. }
  906. function set(key, value) {
  907. value = toRaw(value);
  908. const target = toRaw(this);
  909. const { has: has2, get: get2 } = getProto(target);
  910. let hadKey = has2.call(target, key);
  911. if (!hadKey) {
  912. key = toRaw(key);
  913. hadKey = has2.call(target, key);
  914. } else {
  915. checkIdentityKeys(target, has2, key);
  916. }
  917. const oldValue = get2.call(target, key);
  918. target.set(key, value);
  919. if (!hadKey) {
  920. trigger(target, "add", key, value);
  921. } else if (hasChanged(value, oldValue)) {
  922. trigger(target, "set", key, value, oldValue);
  923. }
  924. return this;
  925. }
  926. function deleteEntry(key) {
  927. const target = toRaw(this);
  928. const { has: has2, get: get2 } = getProto(target);
  929. let hadKey = has2.call(target, key);
  930. if (!hadKey) {
  931. key = toRaw(key);
  932. hadKey = has2.call(target, key);
  933. } else {
  934. checkIdentityKeys(target, has2, key);
  935. }
  936. const oldValue = get2 ? get2.call(target, key) : void 0;
  937. const result = target.delete(key);
  938. if (hadKey) {
  939. trigger(target, "delete", key, void 0, oldValue);
  940. }
  941. return result;
  942. }
  943. function clear() {
  944. const target = toRaw(this);
  945. const hadItems = target.size !== 0;
  946. const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
  947. const result = target.clear();
  948. if (hadItems) {
  949. trigger(target, "clear", void 0, void 0, oldTarget);
  950. }
  951. return result;
  952. }
  953. function createForEach(isReadonly, isShallow) {
  954. return function forEach(callback, thisArg) {
  955. const observed = this;
  956. const target = observed["__v_raw"];
  957. const rawTarget = toRaw(target);
  958. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  959. !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
  960. return target.forEach((value, key) => {
  961. return callback.call(thisArg, wrap(value), wrap(key), observed);
  962. });
  963. };
  964. }
  965. function createIterableMethod(method, isReadonly, isShallow) {
  966. return function(...args) {
  967. const target = this["__v_raw"];
  968. const rawTarget = toRaw(target);
  969. const targetIsMap = isMap(rawTarget);
  970. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  971. const isKeyOnly = method === "keys" && targetIsMap;
  972. const innerIterator = target[method](...args);
  973. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  974. !isReadonly && track(
  975. rawTarget,
  976. "iterate",
  977. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  978. );
  979. return {
  980. // iterator protocol
  981. next() {
  982. const { value, done } = innerIterator.next();
  983. return done ? { value, done } : {
  984. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  985. done
  986. };
  987. },
  988. // iterable protocol
  989. [Symbol.iterator]() {
  990. return this;
  991. }
  992. };
  993. };
  994. }
  995. function createReadonlyMethod(type) {
  996. return function(...args) {
  997. {
  998. const key = args[0] ? `on key "${args[0]}" ` : ``;
  999. console.warn(
  1000. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  1001. toRaw(this)
  1002. );
  1003. }
  1004. return type === "delete" ? false : type === "clear" ? void 0 : this;
  1005. };
  1006. }
  1007. function createInstrumentations() {
  1008. const mutableInstrumentations2 = {
  1009. get(key) {
  1010. return get(this, key);
  1011. },
  1012. get size() {
  1013. return size(this);
  1014. },
  1015. has,
  1016. add,
  1017. set,
  1018. delete: deleteEntry,
  1019. clear,
  1020. forEach: createForEach(false, false)
  1021. };
  1022. const shallowInstrumentations2 = {
  1023. get(key) {
  1024. return get(this, key, false, true);
  1025. },
  1026. get size() {
  1027. return size(this);
  1028. },
  1029. has,
  1030. add,
  1031. set,
  1032. delete: deleteEntry,
  1033. clear,
  1034. forEach: createForEach(false, true)
  1035. };
  1036. const readonlyInstrumentations2 = {
  1037. get(key) {
  1038. return get(this, key, true);
  1039. },
  1040. get size() {
  1041. return size(this, true);
  1042. },
  1043. has(key) {
  1044. return has.call(this, key, true);
  1045. },
  1046. add: createReadonlyMethod("add"),
  1047. set: createReadonlyMethod("set"),
  1048. delete: createReadonlyMethod("delete"),
  1049. clear: createReadonlyMethod("clear"),
  1050. forEach: createForEach(true, false)
  1051. };
  1052. const shallowReadonlyInstrumentations2 = {
  1053. get(key) {
  1054. return get(this, key, true, true);
  1055. },
  1056. get size() {
  1057. return size(this, true);
  1058. },
  1059. has(key) {
  1060. return has.call(this, key, true);
  1061. },
  1062. add: createReadonlyMethod("add"),
  1063. set: createReadonlyMethod("set"),
  1064. delete: createReadonlyMethod("delete"),
  1065. clear: createReadonlyMethod("clear"),
  1066. forEach: createForEach(true, true)
  1067. };
  1068. const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
  1069. iteratorMethods.forEach((method) => {
  1070. mutableInstrumentations2[method] = createIterableMethod(
  1071. method,
  1072. false,
  1073. false
  1074. );
  1075. readonlyInstrumentations2[method] = createIterableMethod(
  1076. method,
  1077. true,
  1078. false
  1079. );
  1080. shallowInstrumentations2[method] = createIterableMethod(
  1081. method,
  1082. false,
  1083. true
  1084. );
  1085. shallowReadonlyInstrumentations2[method] = createIterableMethod(
  1086. method,
  1087. true,
  1088. true
  1089. );
  1090. });
  1091. return [
  1092. mutableInstrumentations2,
  1093. readonlyInstrumentations2,
  1094. shallowInstrumentations2,
  1095. shallowReadonlyInstrumentations2
  1096. ];
  1097. }
  1098. const [
  1099. mutableInstrumentations,
  1100. readonlyInstrumentations,
  1101. shallowInstrumentations,
  1102. shallowReadonlyInstrumentations
  1103. ] = /* @__PURE__ */ createInstrumentations();
  1104. function createInstrumentationGetter(isReadonly, shallow) {
  1105. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
  1106. return (target, key, receiver) => {
  1107. if (key === "__v_isReactive") {
  1108. return !isReadonly;
  1109. } else if (key === "__v_isReadonly") {
  1110. return isReadonly;
  1111. } else if (key === "__v_raw") {
  1112. return target;
  1113. }
  1114. return Reflect.get(
  1115. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1116. key,
  1117. receiver
  1118. );
  1119. };
  1120. }
  1121. const mutableCollectionHandlers = {
  1122. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1123. };
  1124. const shallowCollectionHandlers = {
  1125. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1126. };
  1127. const readonlyCollectionHandlers = {
  1128. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1129. };
  1130. const shallowReadonlyCollectionHandlers = {
  1131. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1132. };
  1133. function checkIdentityKeys(target, has2, key) {
  1134. const rawKey = toRaw(key);
  1135. if (rawKey !== key && has2.call(target, rawKey)) {
  1136. const type = toRawType(target);
  1137. console.warn(
  1138. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
  1139. );
  1140. }
  1141. }
  1142. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1143. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1144. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1145. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1146. function targetTypeMap(rawType) {
  1147. switch (rawType) {
  1148. case "Object":
  1149. case "Array":
  1150. return 1 /* COMMON */;
  1151. case "Map":
  1152. case "Set":
  1153. case "WeakMap":
  1154. case "WeakSet":
  1155. return 2 /* COLLECTION */;
  1156. default:
  1157. return 0 /* INVALID */;
  1158. }
  1159. }
  1160. function getTargetType(value) {
  1161. return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
  1162. }
  1163. function reactive(target) {
  1164. if (isReadonly(target)) {
  1165. return target;
  1166. }
  1167. return createReactiveObject(
  1168. target,
  1169. false,
  1170. mutableHandlers,
  1171. mutableCollectionHandlers,
  1172. reactiveMap
  1173. );
  1174. }
  1175. function shallowReactive(target) {
  1176. return createReactiveObject(
  1177. target,
  1178. false,
  1179. shallowReactiveHandlers,
  1180. shallowCollectionHandlers,
  1181. shallowReactiveMap
  1182. );
  1183. }
  1184. function readonly(target) {
  1185. return createReactiveObject(
  1186. target,
  1187. true,
  1188. readonlyHandlers,
  1189. readonlyCollectionHandlers,
  1190. readonlyMap
  1191. );
  1192. }
  1193. function shallowReadonly(target) {
  1194. return createReactiveObject(
  1195. target,
  1196. true,
  1197. shallowReadonlyHandlers,
  1198. shallowReadonlyCollectionHandlers,
  1199. shallowReadonlyMap
  1200. );
  1201. }
  1202. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1203. if (!isObject(target)) {
  1204. {
  1205. console.warn(`value cannot be made reactive: ${String(target)}`);
  1206. }
  1207. return target;
  1208. }
  1209. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1210. return target;
  1211. }
  1212. const existingProxy = proxyMap.get(target);
  1213. if (existingProxy) {
  1214. return existingProxy;
  1215. }
  1216. const targetType = getTargetType(target);
  1217. if (targetType === 0 /* INVALID */) {
  1218. return target;
  1219. }
  1220. const proxy = new Proxy(
  1221. target,
  1222. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1223. );
  1224. proxyMap.set(target, proxy);
  1225. return proxy;
  1226. }
  1227. function isReactive(value) {
  1228. if (isReadonly(value)) {
  1229. return isReactive(value["__v_raw"]);
  1230. }
  1231. return !!(value && value["__v_isReactive"]);
  1232. }
  1233. function isReadonly(value) {
  1234. return !!(value && value["__v_isReadonly"]);
  1235. }
  1236. function isShallow(value) {
  1237. return !!(value && value["__v_isShallow"]);
  1238. }
  1239. function isProxy(value) {
  1240. return isReactive(value) || isReadonly(value);
  1241. }
  1242. function toRaw(observed) {
  1243. const raw = observed && observed["__v_raw"];
  1244. return raw ? toRaw(raw) : observed;
  1245. }
  1246. function markRaw(value) {
  1247. def(value, "__v_skip", true);
  1248. return value;
  1249. }
  1250. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1251. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1252. function trackRefValue(ref2) {
  1253. if (shouldTrack && activeEffect) {
  1254. ref2 = toRaw(ref2);
  1255. {
  1256. trackEffects(ref2.dep || (ref2.dep = createDep()), {
  1257. target: ref2,
  1258. type: "get",
  1259. key: "value"
  1260. });
  1261. }
  1262. }
  1263. }
  1264. function triggerRefValue(ref2, newVal) {
  1265. ref2 = toRaw(ref2);
  1266. const dep = ref2.dep;
  1267. if (dep) {
  1268. {
  1269. triggerEffects(dep, {
  1270. target: ref2,
  1271. type: "set",
  1272. key: "value",
  1273. newValue: newVal
  1274. });
  1275. }
  1276. }
  1277. }
  1278. function isRef(r) {
  1279. return !!(r && r.__v_isRef === true);
  1280. }
  1281. function ref(value) {
  1282. return createRef(value, false);
  1283. }
  1284. function shallowRef(value) {
  1285. return createRef(value, true);
  1286. }
  1287. function createRef(rawValue, shallow) {
  1288. if (isRef(rawValue)) {
  1289. return rawValue;
  1290. }
  1291. return new RefImpl(rawValue, shallow);
  1292. }
  1293. class RefImpl {
  1294. constructor(value, __v_isShallow) {
  1295. this.__v_isShallow = __v_isShallow;
  1296. this.dep = void 0;
  1297. this.__v_isRef = true;
  1298. this._rawValue = __v_isShallow ? value : toRaw(value);
  1299. this._value = __v_isShallow ? value : toReactive(value);
  1300. }
  1301. get value() {
  1302. trackRefValue(this);
  1303. return this._value;
  1304. }
  1305. set value(newVal) {
  1306. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
  1307. newVal = useDirectValue ? newVal : toRaw(newVal);
  1308. if (hasChanged(newVal, this._rawValue)) {
  1309. this._rawValue = newVal;
  1310. this._value = useDirectValue ? newVal : toReactive(newVal);
  1311. triggerRefValue(this, newVal);
  1312. }
  1313. }
  1314. }
  1315. function triggerRef(ref2) {
  1316. triggerRefValue(ref2, ref2.value );
  1317. }
  1318. function unref(ref2) {
  1319. return isRef(ref2) ? ref2.value : ref2;
  1320. }
  1321. function toValue(source) {
  1322. return isFunction(source) ? source() : unref(source);
  1323. }
  1324. const shallowUnwrapHandlers = {
  1325. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1326. set: (target, key, value, receiver) => {
  1327. const oldValue = target[key];
  1328. if (isRef(oldValue) && !isRef(value)) {
  1329. oldValue.value = value;
  1330. return true;
  1331. } else {
  1332. return Reflect.set(target, key, value, receiver);
  1333. }
  1334. }
  1335. };
  1336. function proxyRefs(objectWithRefs) {
  1337. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1338. }
  1339. class CustomRefImpl {
  1340. constructor(factory) {
  1341. this.dep = void 0;
  1342. this.__v_isRef = true;
  1343. const { get, set } = factory(
  1344. () => trackRefValue(this),
  1345. () => triggerRefValue(this)
  1346. );
  1347. this._get = get;
  1348. this._set = set;
  1349. }
  1350. get value() {
  1351. return this._get();
  1352. }
  1353. set value(newVal) {
  1354. this._set(newVal);
  1355. }
  1356. }
  1357. function customRef(factory) {
  1358. return new CustomRefImpl(factory);
  1359. }
  1360. function toRefs(object) {
  1361. if (!isProxy(object)) {
  1362. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1363. }
  1364. const ret = isArray(object) ? new Array(object.length) : {};
  1365. for (const key in object) {
  1366. ret[key] = propertyToRef(object, key);
  1367. }
  1368. return ret;
  1369. }
  1370. class ObjectRefImpl {
  1371. constructor(_object, _key, _defaultValue) {
  1372. this._object = _object;
  1373. this._key = _key;
  1374. this._defaultValue = _defaultValue;
  1375. this.__v_isRef = true;
  1376. }
  1377. get value() {
  1378. const val = this._object[this._key];
  1379. return val === void 0 ? this._defaultValue : val;
  1380. }
  1381. set value(newVal) {
  1382. this._object[this._key] = newVal;
  1383. }
  1384. get dep() {
  1385. return getDepFromReactive(toRaw(this._object), this._key);
  1386. }
  1387. }
  1388. class GetterRefImpl {
  1389. constructor(_getter) {
  1390. this._getter = _getter;
  1391. this.__v_isRef = true;
  1392. this.__v_isReadonly = true;
  1393. }
  1394. get value() {
  1395. return this._getter();
  1396. }
  1397. }
  1398. function toRef(source, key, defaultValue) {
  1399. if (isRef(source)) {
  1400. return source;
  1401. } else if (isFunction(source)) {
  1402. return new GetterRefImpl(source);
  1403. } else if (isObject(source) && arguments.length > 1) {
  1404. return propertyToRef(source, key, defaultValue);
  1405. } else {
  1406. return ref(source);
  1407. }
  1408. }
  1409. function propertyToRef(source, key, defaultValue) {
  1410. const val = source[key];
  1411. return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
  1412. }
  1413. class ComputedRefImpl {
  1414. constructor(getter, _setter, isReadonly, isSSR) {
  1415. this._setter = _setter;
  1416. this.dep = void 0;
  1417. this.__v_isRef = true;
  1418. this["__v_isReadonly"] = false;
  1419. this._dirty = true;
  1420. this.effect = new ReactiveEffect(getter, () => {
  1421. if (!this._dirty) {
  1422. this._dirty = true;
  1423. triggerRefValue(this);
  1424. }
  1425. });
  1426. this.effect.computed = this;
  1427. this.effect.active = this._cacheable = !isSSR;
  1428. this["__v_isReadonly"] = isReadonly;
  1429. }
  1430. get value() {
  1431. const self = toRaw(this);
  1432. trackRefValue(self);
  1433. if (self._dirty || !self._cacheable) {
  1434. self._dirty = false;
  1435. self._value = self.effect.run();
  1436. }
  1437. return self._value;
  1438. }
  1439. set value(newValue) {
  1440. this._setter(newValue);
  1441. }
  1442. }
  1443. function computed$1(getterOrOptions, debugOptions, isSSR = false) {
  1444. let getter;
  1445. let setter;
  1446. const onlyGetter = isFunction(getterOrOptions);
  1447. if (onlyGetter) {
  1448. getter = getterOrOptions;
  1449. setter = () => {
  1450. console.warn("Write operation failed: computed value is readonly");
  1451. } ;
  1452. } else {
  1453. getter = getterOrOptions.get;
  1454. setter = getterOrOptions.set;
  1455. }
  1456. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1457. if (debugOptions && !isSSR) {
  1458. cRef.effect.onTrack = debugOptions.onTrack;
  1459. cRef.effect.onTrigger = debugOptions.onTrigger;
  1460. }
  1461. return cRef;
  1462. }
  1463. const stack = [];
  1464. function pushWarningContext(vnode) {
  1465. stack.push(vnode);
  1466. }
  1467. function popWarningContext() {
  1468. stack.pop();
  1469. }
  1470. function warn(msg, ...args) {
  1471. pauseTracking();
  1472. const instance = stack.length ? stack[stack.length - 1].component : null;
  1473. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1474. const trace = getComponentTrace();
  1475. if (appWarnHandler) {
  1476. callWithErrorHandling(
  1477. appWarnHandler,
  1478. instance,
  1479. 11,
  1480. [
  1481. msg + args.join(""),
  1482. instance && instance.proxy,
  1483. trace.map(
  1484. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
  1485. ).join("\n"),
  1486. trace
  1487. ]
  1488. );
  1489. } else {
  1490. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1491. if (trace.length && // avoid spamming console during tests
  1492. true) {
  1493. warnArgs.push(`
  1494. `, ...formatTrace(trace));
  1495. }
  1496. console.warn(...warnArgs);
  1497. }
  1498. resetTracking();
  1499. }
  1500. function getComponentTrace() {
  1501. let currentVNode = stack[stack.length - 1];
  1502. if (!currentVNode) {
  1503. return [];
  1504. }
  1505. const normalizedStack = [];
  1506. while (currentVNode) {
  1507. const last = normalizedStack[0];
  1508. if (last && last.vnode === currentVNode) {
  1509. last.recurseCount++;
  1510. } else {
  1511. normalizedStack.push({
  1512. vnode: currentVNode,
  1513. recurseCount: 0
  1514. });
  1515. }
  1516. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1517. currentVNode = parentInstance && parentInstance.vnode;
  1518. }
  1519. return normalizedStack;
  1520. }
  1521. function formatTrace(trace) {
  1522. const logs = [];
  1523. trace.forEach((entry, i) => {
  1524. logs.push(...i === 0 ? [] : [`
  1525. `], ...formatTraceEntry(entry));
  1526. });
  1527. return logs;
  1528. }
  1529. function formatTraceEntry({ vnode, recurseCount }) {
  1530. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1531. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1532. const open = ` at <${formatComponentName(
  1533. vnode.component,
  1534. vnode.type,
  1535. isRoot
  1536. )}`;
  1537. const close = `>` + postfix;
  1538. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
  1539. }
  1540. function formatProps(props) {
  1541. const res = [];
  1542. const keys = Object.keys(props);
  1543. keys.slice(0, 3).forEach((key) => {
  1544. res.push(...formatProp(key, props[key]));
  1545. });
  1546. if (keys.length > 3) {
  1547. res.push(` ...`);
  1548. }
  1549. return res;
  1550. }
  1551. function formatProp(key, value, raw) {
  1552. if (isString(value)) {
  1553. value = JSON.stringify(value);
  1554. return raw ? value : [`${key}=${value}`];
  1555. } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
  1556. return raw ? value : [`${key}=${value}`];
  1557. } else if (isRef(value)) {
  1558. value = formatProp(key, toRaw(value.value), true);
  1559. return raw ? value : [`${key}=Ref<`, value, `>`];
  1560. } else if (isFunction(value)) {
  1561. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1562. } else {
  1563. value = toRaw(value);
  1564. return raw ? value : [`${key}=`, value];
  1565. }
  1566. }
  1567. function assertNumber(val, type) {
  1568. if (val === void 0) {
  1569. return;
  1570. } else if (typeof val !== "number") {
  1571. warn(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
  1572. } else if (isNaN(val)) {
  1573. warn(`${type} is NaN - the duration expression might be incorrect.`);
  1574. }
  1575. }
  1576. const ErrorTypeStrings = {
  1577. ["sp"]: "serverPrefetch hook",
  1578. ["bc"]: "beforeCreate hook",
  1579. ["c"]: "created hook",
  1580. ["bm"]: "beforeMount hook",
  1581. ["m"]: "mounted hook",
  1582. ["bu"]: "beforeUpdate hook",
  1583. ["u"]: "updated",
  1584. ["bum"]: "beforeUnmount hook",
  1585. ["um"]: "unmounted hook",
  1586. ["a"]: "activated hook",
  1587. ["da"]: "deactivated hook",
  1588. ["ec"]: "errorCaptured hook",
  1589. ["rtc"]: "renderTracked hook",
  1590. ["rtg"]: "renderTriggered hook",
  1591. [0]: "setup function",
  1592. [1]: "render function",
  1593. [2]: "watcher getter",
  1594. [3]: "watcher callback",
  1595. [4]: "watcher cleanup function",
  1596. [5]: "native event handler",
  1597. [6]: "component event handler",
  1598. [7]: "vnode hook",
  1599. [8]: "directive hook",
  1600. [9]: "transition hook",
  1601. [10]: "app errorHandler",
  1602. [11]: "app warnHandler",
  1603. [12]: "ref function",
  1604. [13]: "async component loader",
  1605. [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
  1606. };
  1607. function callWithErrorHandling(fn, instance, type, args) {
  1608. let res;
  1609. try {
  1610. res = args ? fn(...args) : fn();
  1611. } catch (err) {
  1612. handleError(err, instance, type);
  1613. }
  1614. return res;
  1615. }
  1616. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1617. if (isFunction(fn)) {
  1618. const res = callWithErrorHandling(fn, instance, type, args);
  1619. if (res && isPromise(res)) {
  1620. res.catch((err) => {
  1621. handleError(err, instance, type);
  1622. });
  1623. }
  1624. return res;
  1625. }
  1626. const values = [];
  1627. for (let i = 0; i < fn.length; i++) {
  1628. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1629. }
  1630. return values;
  1631. }
  1632. function handleError(err, instance, type, throwInDev = true) {
  1633. const contextVNode = instance ? instance.vnode : null;
  1634. if (instance) {
  1635. let cur = instance.parent;
  1636. const exposedInstance = instance.proxy;
  1637. const errorInfo = ErrorTypeStrings[type] ;
  1638. while (cur) {
  1639. const errorCapturedHooks = cur.ec;
  1640. if (errorCapturedHooks) {
  1641. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1642. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1643. return;
  1644. }
  1645. }
  1646. }
  1647. cur = cur.parent;
  1648. }
  1649. const appErrorHandler = instance.appContext.config.errorHandler;
  1650. if (appErrorHandler) {
  1651. callWithErrorHandling(
  1652. appErrorHandler,
  1653. null,
  1654. 10,
  1655. [err, exposedInstance, errorInfo]
  1656. );
  1657. return;
  1658. }
  1659. }
  1660. logError(err, type, contextVNode, throwInDev);
  1661. }
  1662. function logError(err, type, contextVNode, throwInDev = true) {
  1663. {
  1664. const info = ErrorTypeStrings[type];
  1665. if (contextVNode) {
  1666. pushWarningContext(contextVNode);
  1667. }
  1668. warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1669. if (contextVNode) {
  1670. popWarningContext();
  1671. }
  1672. if (throwInDev) {
  1673. throw err;
  1674. } else {
  1675. console.error(err);
  1676. }
  1677. }
  1678. }
  1679. let isFlushing = false;
  1680. let isFlushPending = false;
  1681. const queue = [];
  1682. let flushIndex = 0;
  1683. const pendingPostFlushCbs = [];
  1684. let activePostFlushCbs = null;
  1685. let postFlushIndex = 0;
  1686. const resolvedPromise = /* @__PURE__ */ Promise.resolve();
  1687. let currentFlushPromise = null;
  1688. const RECURSION_LIMIT = 100;
  1689. function nextTick(fn) {
  1690. const p = currentFlushPromise || resolvedPromise;
  1691. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1692. }
  1693. function findInsertionIndex(id) {
  1694. let start = flushIndex + 1;
  1695. let end = queue.length;
  1696. while (start < end) {
  1697. const middle = start + end >>> 1;
  1698. const middleJob = queue[middle];
  1699. const middleJobId = getId(middleJob);
  1700. if (middleJobId < id || middleJobId === id && middleJob.pre) {
  1701. start = middle + 1;
  1702. } else {
  1703. end = middle;
  1704. }
  1705. }
  1706. return start;
  1707. }
  1708. function queueJob(job) {
  1709. if (!queue.length || !queue.includes(
  1710. job,
  1711. isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
  1712. )) {
  1713. if (job.id == null) {
  1714. queue.push(job);
  1715. } else {
  1716. queue.splice(findInsertionIndex(job.id), 0, job);
  1717. }
  1718. queueFlush();
  1719. }
  1720. }
  1721. function queueFlush() {
  1722. if (!isFlushing && !isFlushPending) {
  1723. isFlushPending = true;
  1724. currentFlushPromise = resolvedPromise.then(flushJobs);
  1725. }
  1726. }
  1727. function invalidateJob(job) {
  1728. const i = queue.indexOf(job);
  1729. if (i > flushIndex) {
  1730. queue.splice(i, 1);
  1731. }
  1732. }
  1733. function queuePostFlushCb(cb) {
  1734. if (!isArray(cb)) {
  1735. if (!activePostFlushCbs || !activePostFlushCbs.includes(
  1736. cb,
  1737. cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
  1738. )) {
  1739. pendingPostFlushCbs.push(cb);
  1740. }
  1741. } else {
  1742. pendingPostFlushCbs.push(...cb);
  1743. }
  1744. queueFlush();
  1745. }
  1746. function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
  1747. {
  1748. seen = seen || /* @__PURE__ */ new Map();
  1749. }
  1750. for (; i < queue.length; i++) {
  1751. const cb = queue[i];
  1752. if (cb && cb.pre) {
  1753. if (instance && cb.id !== instance.uid) {
  1754. continue;
  1755. }
  1756. if (checkRecursiveUpdates(seen, cb)) {
  1757. continue;
  1758. }
  1759. queue.splice(i, 1);
  1760. i--;
  1761. cb();
  1762. }
  1763. }
  1764. }
  1765. function flushPostFlushCbs(seen) {
  1766. if (pendingPostFlushCbs.length) {
  1767. const deduped = [...new Set(pendingPostFlushCbs)];
  1768. pendingPostFlushCbs.length = 0;
  1769. if (activePostFlushCbs) {
  1770. activePostFlushCbs.push(...deduped);
  1771. return;
  1772. }
  1773. activePostFlushCbs = deduped;
  1774. {
  1775. seen = seen || /* @__PURE__ */ new Map();
  1776. }
  1777. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1778. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1779. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1780. continue;
  1781. }
  1782. activePostFlushCbs[postFlushIndex]();
  1783. }
  1784. activePostFlushCbs = null;
  1785. postFlushIndex = 0;
  1786. }
  1787. }
  1788. const getId = (job) => job.id == null ? Infinity : job.id;
  1789. const comparator = (a, b) => {
  1790. const diff = getId(a) - getId(b);
  1791. if (diff === 0) {
  1792. if (a.pre && !b.pre)
  1793. return -1;
  1794. if (b.pre && !a.pre)
  1795. return 1;
  1796. }
  1797. return diff;
  1798. };
  1799. function flushJobs(seen) {
  1800. isFlushPending = false;
  1801. isFlushing = true;
  1802. {
  1803. seen = seen || /* @__PURE__ */ new Map();
  1804. }
  1805. queue.sort(comparator);
  1806. const check = (job) => checkRecursiveUpdates(seen, job) ;
  1807. try {
  1808. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1809. const job = queue[flushIndex];
  1810. if (job && job.active !== false) {
  1811. if (check(job)) {
  1812. continue;
  1813. }
  1814. callWithErrorHandling(job, null, 14);
  1815. }
  1816. }
  1817. } finally {
  1818. flushIndex = 0;
  1819. queue.length = 0;
  1820. flushPostFlushCbs(seen);
  1821. isFlushing = false;
  1822. currentFlushPromise = null;
  1823. if (queue.length || pendingPostFlushCbs.length) {
  1824. flushJobs(seen);
  1825. }
  1826. }
  1827. }
  1828. function checkRecursiveUpdates(seen, fn) {
  1829. if (!seen.has(fn)) {
  1830. seen.set(fn, 1);
  1831. } else {
  1832. const count = seen.get(fn);
  1833. if (count > RECURSION_LIMIT) {
  1834. const instance = fn.ownerInstance;
  1835. const componentName = instance && getComponentName(instance.type);
  1836. warn(
  1837. `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`
  1838. );
  1839. return true;
  1840. } else {
  1841. seen.set(fn, count + 1);
  1842. }
  1843. }
  1844. }
  1845. let isHmrUpdating = false;
  1846. const hmrDirtyComponents = /* @__PURE__ */ new Set();
  1847. {
  1848. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1849. createRecord: tryWrap(createRecord),
  1850. rerender: tryWrap(rerender),
  1851. reload: tryWrap(reload)
  1852. };
  1853. }
  1854. const map = /* @__PURE__ */ new Map();
  1855. function registerHMR(instance) {
  1856. const id = instance.type.__hmrId;
  1857. let record = map.get(id);
  1858. if (!record) {
  1859. createRecord(id, instance.type);
  1860. record = map.get(id);
  1861. }
  1862. record.instances.add(instance);
  1863. }
  1864. function unregisterHMR(instance) {
  1865. map.get(instance.type.__hmrId).instances.delete(instance);
  1866. }
  1867. function createRecord(id, initialDef) {
  1868. if (map.has(id)) {
  1869. return false;
  1870. }
  1871. map.set(id, {
  1872. initialDef: normalizeClassComponent(initialDef),
  1873. instances: /* @__PURE__ */ new Set()
  1874. });
  1875. return true;
  1876. }
  1877. function normalizeClassComponent(component) {
  1878. return isClassComponent(component) ? component.__vccOpts : component;
  1879. }
  1880. function rerender(id, newRender) {
  1881. const record = map.get(id);
  1882. if (!record) {
  1883. return;
  1884. }
  1885. record.initialDef.render = newRender;
  1886. [...record.instances].forEach((instance) => {
  1887. if (newRender) {
  1888. instance.render = newRender;
  1889. normalizeClassComponent(instance.type).render = newRender;
  1890. }
  1891. instance.renderCache = [];
  1892. isHmrUpdating = true;
  1893. instance.update();
  1894. isHmrUpdating = false;
  1895. });
  1896. }
  1897. function reload(id, newComp) {
  1898. const record = map.get(id);
  1899. if (!record)
  1900. return;
  1901. newComp = normalizeClassComponent(newComp);
  1902. updateComponentDef(record.initialDef, newComp);
  1903. const instances = [...record.instances];
  1904. for (const instance of instances) {
  1905. const oldComp = normalizeClassComponent(instance.type);
  1906. if (!hmrDirtyComponents.has(oldComp)) {
  1907. if (oldComp !== record.initialDef) {
  1908. updateComponentDef(oldComp, newComp);
  1909. }
  1910. hmrDirtyComponents.add(oldComp);
  1911. }
  1912. instance.appContext.propsCache.delete(instance.type);
  1913. instance.appContext.emitsCache.delete(instance.type);
  1914. instance.appContext.optionsCache.delete(instance.type);
  1915. if (instance.ceReload) {
  1916. hmrDirtyComponents.add(oldComp);
  1917. instance.ceReload(newComp.styles);
  1918. hmrDirtyComponents.delete(oldComp);
  1919. } else if (instance.parent) {
  1920. queueJob(instance.parent.update);
  1921. } else if (instance.appContext.reload) {
  1922. instance.appContext.reload();
  1923. } else if (typeof window !== "undefined") {
  1924. window.location.reload();
  1925. } else {
  1926. console.warn(
  1927. "[HMR] Root or manually mounted instance modified. Full reload required."
  1928. );
  1929. }
  1930. }
  1931. queuePostFlushCb(() => {
  1932. for (const instance of instances) {
  1933. hmrDirtyComponents.delete(
  1934. normalizeClassComponent(instance.type)
  1935. );
  1936. }
  1937. });
  1938. }
  1939. function updateComponentDef(oldComp, newComp) {
  1940. extend(oldComp, newComp);
  1941. for (const key in oldComp) {
  1942. if (key !== "__file" && !(key in newComp)) {
  1943. delete oldComp[key];
  1944. }
  1945. }
  1946. }
  1947. function tryWrap(fn) {
  1948. return (id, arg) => {
  1949. try {
  1950. return fn(id, arg);
  1951. } catch (e) {
  1952. console.error(e);
  1953. console.warn(
  1954. `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
  1955. );
  1956. }
  1957. };
  1958. }
  1959. exports.devtools = void 0;
  1960. let buffer = [];
  1961. let devtoolsNotInstalled = false;
  1962. function emit$1(event, ...args) {
  1963. if (exports.devtools) {
  1964. exports.devtools.emit(event, ...args);
  1965. } else if (!devtoolsNotInstalled) {
  1966. buffer.push({ event, args });
  1967. }
  1968. }
  1969. function setDevtoolsHook(hook, target) {
  1970. var _a, _b;
  1971. exports.devtools = hook;
  1972. if (exports.devtools) {
  1973. exports.devtools.enabled = true;
  1974. buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
  1975. buffer = [];
  1976. } else if (
  1977. // handle late devtools injection - only do this if we are in an actual
  1978. // browser environment to avoid the timer handle stalling test runner exit
  1979. // (#4815)
  1980. typeof window !== "undefined" && // some envs mock window but not fully
  1981. window.HTMLElement && // also exclude jsdom
  1982. !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
  1983. ) {
  1984. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
  1985. replay.push((newHook) => {
  1986. setDevtoolsHook(newHook, target);
  1987. });
  1988. setTimeout(() => {
  1989. if (!exports.devtools) {
  1990. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  1991. devtoolsNotInstalled = true;
  1992. buffer = [];
  1993. }
  1994. }, 3e3);
  1995. } else {
  1996. devtoolsNotInstalled = true;
  1997. buffer = [];
  1998. }
  1999. }
  2000. function devtoolsInitApp(app, version) {
  2001. emit$1("app:init" /* APP_INIT */, app, version, {
  2002. Fragment,
  2003. Text,
  2004. Comment,
  2005. Static
  2006. });
  2007. }
  2008. function devtoolsUnmountApp(app) {
  2009. emit$1("app:unmount" /* APP_UNMOUNT */, app);
  2010. }
  2011. const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
  2012. "component:added" /* COMPONENT_ADDED */
  2013. );
  2014. const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2015. const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
  2016. "component:removed" /* COMPONENT_REMOVED */
  2017. );
  2018. const devtoolsComponentRemoved = (component) => {
  2019. if (exports.devtools && typeof exports.devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered
  2020. !exports.devtools.cleanupBuffer(component)) {
  2021. _devtoolsComponentRemoved(component);
  2022. }
  2023. };
  2024. function createDevtoolsComponentHook(hook) {
  2025. return (component) => {
  2026. emit$1(
  2027. hook,
  2028. component.appContext.app,
  2029. component.uid,
  2030. component.parent ? component.parent.uid : void 0,
  2031. component
  2032. );
  2033. };
  2034. }
  2035. const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2036. "perf:start" /* PERFORMANCE_START */
  2037. );
  2038. const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2039. "perf:end" /* PERFORMANCE_END */
  2040. );
  2041. function createDevtoolsPerformanceHook(hook) {
  2042. return (component, type, time) => {
  2043. emit$1(hook, component.appContext.app, component.uid, component, type, time);
  2044. };
  2045. }
  2046. function devtoolsComponentEmit(component, event, params) {
  2047. emit$1(
  2048. "component:emit" /* COMPONENT_EMIT */,
  2049. component.appContext.app,
  2050. component,
  2051. event,
  2052. params
  2053. );
  2054. }
  2055. function emit(instance, event, ...rawArgs) {
  2056. if (instance.isUnmounted)
  2057. return;
  2058. const props = instance.vnode.props || EMPTY_OBJ;
  2059. {
  2060. const {
  2061. emitsOptions,
  2062. propsOptions: [propsOptions]
  2063. } = instance;
  2064. if (emitsOptions) {
  2065. if (!(event in emitsOptions) && true) {
  2066. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2067. warn(
  2068. `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
  2069. );
  2070. }
  2071. } else {
  2072. const validator = emitsOptions[event];
  2073. if (isFunction(validator)) {
  2074. const isValid = validator(...rawArgs);
  2075. if (!isValid) {
  2076. warn(
  2077. `Invalid event arguments: event validation failed for event "${event}".`
  2078. );
  2079. }
  2080. }
  2081. }
  2082. }
  2083. }
  2084. let args = rawArgs;
  2085. const isModelListener = event.startsWith("update:");
  2086. const modelArg = isModelListener && event.slice(7);
  2087. if (modelArg && modelArg in props) {
  2088. const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
  2089. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2090. if (trim) {
  2091. args = rawArgs.map((a) => isString(a) ? a.trim() : a);
  2092. }
  2093. if (number) {
  2094. args = rawArgs.map(looseToNumber);
  2095. }
  2096. }
  2097. {
  2098. devtoolsComponentEmit(instance, event, args);
  2099. }
  2100. {
  2101. const lowerCaseEvent = event.toLowerCase();
  2102. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2103. warn(
  2104. `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
  2105. instance,
  2106. instance.type
  2107. )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`
  2108. );
  2109. }
  2110. }
  2111. let handlerName;
  2112. let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
  2113. props[handlerName = toHandlerKey(camelize(event))];
  2114. if (!handler && isModelListener) {
  2115. handler = props[handlerName = toHandlerKey(hyphenate(event))];
  2116. }
  2117. if (handler) {
  2118. callWithAsyncErrorHandling(
  2119. handler,
  2120. instance,
  2121. 6,
  2122. args
  2123. );
  2124. }
  2125. const onceHandler = props[handlerName + `Once`];
  2126. if (onceHandler) {
  2127. if (!instance.emitted) {
  2128. instance.emitted = {};
  2129. } else if (instance.emitted[handlerName]) {
  2130. return;
  2131. }
  2132. instance.emitted[handlerName] = true;
  2133. callWithAsyncErrorHandling(
  2134. onceHandler,
  2135. instance,
  2136. 6,
  2137. args
  2138. );
  2139. }
  2140. }
  2141. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2142. const cache = appContext.emitsCache;
  2143. const cached = cache.get(comp);
  2144. if (cached !== void 0) {
  2145. return cached;
  2146. }
  2147. const raw = comp.emits;
  2148. let normalized = {};
  2149. let hasExtends = false;
  2150. if (!isFunction(comp)) {
  2151. const extendEmits = (raw2) => {
  2152. const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
  2153. if (normalizedFromExtend) {
  2154. hasExtends = true;
  2155. extend(normalized, normalizedFromExtend);
  2156. }
  2157. };
  2158. if (!asMixin && appContext.mixins.length) {
  2159. appContext.mixins.forEach(extendEmits);
  2160. }
  2161. if (comp.extends) {
  2162. extendEmits(comp.extends);
  2163. }
  2164. if (comp.mixins) {
  2165. comp.mixins.forEach(extendEmits);
  2166. }
  2167. }
  2168. if (!raw && !hasExtends) {
  2169. if (isObject(comp)) {
  2170. cache.set(comp, null);
  2171. }
  2172. return null;
  2173. }
  2174. if (isArray(raw)) {
  2175. raw.forEach((key) => normalized[key] = null);
  2176. } else {
  2177. extend(normalized, raw);
  2178. }
  2179. if (isObject(comp)) {
  2180. cache.set(comp, normalized);
  2181. }
  2182. return normalized;
  2183. }
  2184. function isEmitListener(options, key) {
  2185. if (!options || !isOn(key)) {
  2186. return false;
  2187. }
  2188. key = key.slice(2).replace(/Once$/, "");
  2189. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
  2190. }
  2191. let currentRenderingInstance = null;
  2192. let currentScopeId = null;
  2193. function setCurrentRenderingInstance(instance) {
  2194. const prev = currentRenderingInstance;
  2195. currentRenderingInstance = instance;
  2196. currentScopeId = instance && instance.type.__scopeId || null;
  2197. return prev;
  2198. }
  2199. function pushScopeId(id) {
  2200. currentScopeId = id;
  2201. }
  2202. function popScopeId() {
  2203. currentScopeId = null;
  2204. }
  2205. const withScopeId = (_id) => withCtx;
  2206. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
  2207. if (!ctx)
  2208. return fn;
  2209. if (fn._n) {
  2210. return fn;
  2211. }
  2212. const renderFnWithContext = (...args) => {
  2213. if (renderFnWithContext._d) {
  2214. setBlockTracking(-1);
  2215. }
  2216. const prevInstance = setCurrentRenderingInstance(ctx);
  2217. let res;
  2218. try {
  2219. res = fn(...args);
  2220. } finally {
  2221. setCurrentRenderingInstance(prevInstance);
  2222. if (renderFnWithContext._d) {
  2223. setBlockTracking(1);
  2224. }
  2225. }
  2226. {
  2227. devtoolsComponentUpdated(ctx);
  2228. }
  2229. return res;
  2230. };
  2231. renderFnWithContext._n = true;
  2232. renderFnWithContext._c = true;
  2233. renderFnWithContext._d = true;
  2234. return renderFnWithContext;
  2235. }
  2236. let accessedAttrs = false;
  2237. function markAttrsAccessed() {
  2238. accessedAttrs = true;
  2239. }
  2240. function renderComponentRoot(instance) {
  2241. const {
  2242. type: Component,
  2243. vnode,
  2244. proxy,
  2245. withProxy,
  2246. props,
  2247. propsOptions: [propsOptions],
  2248. slots,
  2249. attrs,
  2250. emit,
  2251. render,
  2252. renderCache,
  2253. data,
  2254. setupState,
  2255. ctx,
  2256. inheritAttrs
  2257. } = instance;
  2258. let result;
  2259. let fallthroughAttrs;
  2260. const prev = setCurrentRenderingInstance(instance);
  2261. {
  2262. accessedAttrs = false;
  2263. }
  2264. try {
  2265. if (vnode.shapeFlag & 4) {
  2266. const proxyToUse = withProxy || proxy;
  2267. const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
  2268. get(target, key, receiver) {
  2269. warn(
  2270. `Property '${String(
  2271. key
  2272. )}' was accessed via 'this'. Avoid using 'this' in templates.`
  2273. );
  2274. return Reflect.get(target, key, receiver);
  2275. }
  2276. }) : proxyToUse;
  2277. result = normalizeVNode(
  2278. render.call(
  2279. thisProxy,
  2280. proxyToUse,
  2281. renderCache,
  2282. props,
  2283. setupState,
  2284. data,
  2285. ctx
  2286. )
  2287. );
  2288. fallthroughAttrs = attrs;
  2289. } else {
  2290. const render2 = Component;
  2291. if (attrs === props) {
  2292. markAttrsAccessed();
  2293. }
  2294. result = normalizeVNode(
  2295. render2.length > 1 ? render2(
  2296. props,
  2297. true ? {
  2298. get attrs() {
  2299. markAttrsAccessed();
  2300. return attrs;
  2301. },
  2302. slots,
  2303. emit
  2304. } : { attrs, slots, emit }
  2305. ) : render2(
  2306. props,
  2307. null
  2308. /* we know it doesn't need it */
  2309. )
  2310. );
  2311. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
  2312. }
  2313. } catch (err) {
  2314. blockStack.length = 0;
  2315. handleError(err, instance, 1);
  2316. result = createVNode(Comment);
  2317. }
  2318. let root = result;
  2319. let setRoot = void 0;
  2320. if (result.patchFlag > 0 && result.patchFlag & 2048) {
  2321. [root, setRoot] = getChildRoot(result);
  2322. }
  2323. if (fallthroughAttrs && inheritAttrs !== false) {
  2324. const keys = Object.keys(fallthroughAttrs);
  2325. const { shapeFlag } = root;
  2326. if (keys.length) {
  2327. if (shapeFlag & (1 | 6)) {
  2328. if (propsOptions && keys.some(isModelListener)) {
  2329. fallthroughAttrs = filterModelListeners(
  2330. fallthroughAttrs,
  2331. propsOptions
  2332. );
  2333. }
  2334. root = cloneVNode(root, fallthroughAttrs);
  2335. } else if (!accessedAttrs && root.type !== Comment) {
  2336. const allAttrs = Object.keys(attrs);
  2337. const eventAttrs = [];
  2338. const extraAttrs = [];
  2339. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2340. const key = allAttrs[i];
  2341. if (isOn(key)) {
  2342. if (!isModelListener(key)) {
  2343. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2344. }
  2345. } else {
  2346. extraAttrs.push(key);
  2347. }
  2348. }
  2349. if (extraAttrs.length) {
  2350. warn(
  2351. `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
  2352. );
  2353. }
  2354. if (eventAttrs.length) {
  2355. warn(
  2356. `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
  2357. );
  2358. }
  2359. }
  2360. }
  2361. }
  2362. if (vnode.dirs) {
  2363. if (!isElementRoot(root)) {
  2364. warn(
  2365. `Runtime directive used on component with non-element root node. The directives will not function as intended.`
  2366. );
  2367. }
  2368. root = cloneVNode(root);
  2369. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2370. }
  2371. if (vnode.transition) {
  2372. if (!isElementRoot(root)) {
  2373. warn(
  2374. `Component inside <Transition> renders non-element root node that cannot be animated.`
  2375. );
  2376. }
  2377. root.transition = vnode.transition;
  2378. }
  2379. if (setRoot) {
  2380. setRoot(root);
  2381. } else {
  2382. result = root;
  2383. }
  2384. setCurrentRenderingInstance(prev);
  2385. return result;
  2386. }
  2387. const getChildRoot = (vnode) => {
  2388. const rawChildren = vnode.children;
  2389. const dynamicChildren = vnode.dynamicChildren;
  2390. const childRoot = filterSingleRoot(rawChildren);
  2391. if (!childRoot) {
  2392. return [vnode, void 0];
  2393. }
  2394. const index = rawChildren.indexOf(childRoot);
  2395. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2396. const setRoot = (updatedRoot) => {
  2397. rawChildren[index] = updatedRoot;
  2398. if (dynamicChildren) {
  2399. if (dynamicIndex > -1) {
  2400. dynamicChildren[dynamicIndex] = updatedRoot;
  2401. } else if (updatedRoot.patchFlag > 0) {
  2402. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2403. }
  2404. }
  2405. };
  2406. return [normalizeVNode(childRoot), setRoot];
  2407. };
  2408. function filterSingleRoot(children) {
  2409. let singleRoot;
  2410. for (let i = 0; i < children.length; i++) {
  2411. const child = children[i];
  2412. if (isVNode(child)) {
  2413. if (child.type !== Comment || child.children === "v-if") {
  2414. if (singleRoot) {
  2415. return;
  2416. } else {
  2417. singleRoot = child;
  2418. }
  2419. }
  2420. } else {
  2421. return;
  2422. }
  2423. }
  2424. return singleRoot;
  2425. }
  2426. const getFunctionalFallthrough = (attrs) => {
  2427. let res;
  2428. for (const key in attrs) {
  2429. if (key === "class" || key === "style" || isOn(key)) {
  2430. (res || (res = {}))[key] = attrs[key];
  2431. }
  2432. }
  2433. return res;
  2434. };
  2435. const filterModelListeners = (attrs, props) => {
  2436. const res = {};
  2437. for (const key in attrs) {
  2438. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2439. res[key] = attrs[key];
  2440. }
  2441. }
  2442. return res;
  2443. };
  2444. const isElementRoot = (vnode) => {
  2445. return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
  2446. };
  2447. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2448. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2449. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2450. const emits = component.emitsOptions;
  2451. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2452. return true;
  2453. }
  2454. if (nextVNode.dirs || nextVNode.transition) {
  2455. return true;
  2456. }
  2457. if (optimized && patchFlag >= 0) {
  2458. if (patchFlag & 1024) {
  2459. return true;
  2460. }
  2461. if (patchFlag & 16) {
  2462. if (!prevProps) {
  2463. return !!nextProps;
  2464. }
  2465. return hasPropsChanged(prevProps, nextProps, emits);
  2466. } else if (patchFlag & 8) {
  2467. const dynamicProps = nextVNode.dynamicProps;
  2468. for (let i = 0; i < dynamicProps.length; i++) {
  2469. const key = dynamicProps[i];
  2470. if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
  2471. return true;
  2472. }
  2473. }
  2474. }
  2475. } else {
  2476. if (prevChildren || nextChildren) {
  2477. if (!nextChildren || !nextChildren.$stable) {
  2478. return true;
  2479. }
  2480. }
  2481. if (prevProps === nextProps) {
  2482. return false;
  2483. }
  2484. if (!prevProps) {
  2485. return !!nextProps;
  2486. }
  2487. if (!nextProps) {
  2488. return true;
  2489. }
  2490. return hasPropsChanged(prevProps, nextProps, emits);
  2491. }
  2492. return false;
  2493. }
  2494. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2495. const nextKeys = Object.keys(nextProps);
  2496. if (nextKeys.length !== Object.keys(prevProps).length) {
  2497. return true;
  2498. }
  2499. for (let i = 0; i < nextKeys.length; i++) {
  2500. const key = nextKeys[i];
  2501. if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
  2502. return true;
  2503. }
  2504. }
  2505. return false;
  2506. }
  2507. function updateHOCHostEl({ vnode, parent }, el) {
  2508. while (parent && parent.subTree === vnode) {
  2509. (vnode = parent.vnode).el = el;
  2510. parent = parent.parent;
  2511. }
  2512. }
  2513. const COMPONENTS = "components";
  2514. const DIRECTIVES = "directives";
  2515. function resolveComponent(name, maybeSelfReference) {
  2516. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  2517. }
  2518. const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
  2519. function resolveDynamicComponent(component) {
  2520. if (isString(component)) {
  2521. return resolveAsset(COMPONENTS, component, false) || component;
  2522. } else {
  2523. return component || NULL_DYNAMIC_COMPONENT;
  2524. }
  2525. }
  2526. function resolveDirective(name) {
  2527. return resolveAsset(DIRECTIVES, name);
  2528. }
  2529. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  2530. const instance = currentRenderingInstance || currentInstance;
  2531. if (instance) {
  2532. const Component = instance.type;
  2533. if (type === COMPONENTS) {
  2534. const selfName = getComponentName(
  2535. Component,
  2536. false
  2537. /* do not include inferred name to avoid breaking existing code */
  2538. );
  2539. if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
  2540. return Component;
  2541. }
  2542. }
  2543. const res = (
  2544. // local registration
  2545. // check instance[type] first which is resolved for options API
  2546. resolve(instance[type] || Component[type], name) || // global registration
  2547. resolve(instance.appContext[type], name)
  2548. );
  2549. if (!res && maybeSelfReference) {
  2550. return Component;
  2551. }
  2552. if (warnMissing && !res) {
  2553. const extra = type === COMPONENTS ? `
  2554. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
  2555. warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  2556. }
  2557. return res;
  2558. } else {
  2559. warn(
  2560. `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
  2561. );
  2562. }
  2563. }
  2564. function resolve(registry, name) {
  2565. return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
  2566. }
  2567. const isSuspense = (type) => type.__isSuspense;
  2568. const SuspenseImpl = {
  2569. name: "Suspense",
  2570. // In order to make Suspense tree-shakable, we need to avoid importing it
  2571. // directly in the renderer. The renderer checks for the __isSuspense flag
  2572. // on a vnode's type and calls the `process` method, passing in renderer
  2573. // internals.
  2574. __isSuspense: true,
  2575. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2576. if (n1 == null) {
  2577. mountSuspense(
  2578. n2,
  2579. container,
  2580. anchor,
  2581. parentComponent,
  2582. parentSuspense,
  2583. isSVG,
  2584. slotScopeIds,
  2585. optimized,
  2586. rendererInternals
  2587. );
  2588. } else {
  2589. patchSuspense(
  2590. n1,
  2591. n2,
  2592. container,
  2593. anchor,
  2594. parentComponent,
  2595. isSVG,
  2596. slotScopeIds,
  2597. optimized,
  2598. rendererInternals
  2599. );
  2600. }
  2601. },
  2602. hydrate: hydrateSuspense,
  2603. create: createSuspenseBoundary,
  2604. normalize: normalizeSuspenseChildren
  2605. };
  2606. const Suspense = SuspenseImpl ;
  2607. function triggerEvent(vnode, name) {
  2608. const eventListener = vnode.props && vnode.props[name];
  2609. if (isFunction(eventListener)) {
  2610. eventListener();
  2611. }
  2612. }
  2613. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2614. const {
  2615. p: patch,
  2616. o: { createElement }
  2617. } = rendererInternals;
  2618. const hiddenContainer = createElement("div");
  2619. const suspense = vnode.suspense = createSuspenseBoundary(
  2620. vnode,
  2621. parentSuspense,
  2622. parentComponent,
  2623. container,
  2624. hiddenContainer,
  2625. anchor,
  2626. isSVG,
  2627. slotScopeIds,
  2628. optimized,
  2629. rendererInternals
  2630. );
  2631. patch(
  2632. null,
  2633. suspense.pendingBranch = vnode.ssContent,
  2634. hiddenContainer,
  2635. null,
  2636. parentComponent,
  2637. suspense,
  2638. isSVG,
  2639. slotScopeIds
  2640. );
  2641. if (suspense.deps > 0) {
  2642. triggerEvent(vnode, "onPending");
  2643. triggerEvent(vnode, "onFallback");
  2644. patch(
  2645. null,
  2646. vnode.ssFallback,
  2647. container,
  2648. anchor,
  2649. parentComponent,
  2650. null,
  2651. // fallback tree will not have suspense context
  2652. isSVG,
  2653. slotScopeIds
  2654. );
  2655. setActiveBranch(suspense, vnode.ssFallback);
  2656. } else {
  2657. suspense.resolve(false, true);
  2658. }
  2659. }
  2660. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2661. const suspense = n2.suspense = n1.suspense;
  2662. suspense.vnode = n2;
  2663. n2.el = n1.el;
  2664. const newBranch = n2.ssContent;
  2665. const newFallback = n2.ssFallback;
  2666. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2667. if (pendingBranch) {
  2668. suspense.pendingBranch = newBranch;
  2669. if (isSameVNodeType(newBranch, pendingBranch)) {
  2670. patch(
  2671. pendingBranch,
  2672. newBranch,
  2673. suspense.hiddenContainer,
  2674. null,
  2675. parentComponent,
  2676. suspense,
  2677. isSVG,
  2678. slotScopeIds,
  2679. optimized
  2680. );
  2681. if (suspense.deps <= 0) {
  2682. suspense.resolve();
  2683. } else if (isInFallback) {
  2684. patch(
  2685. activeBranch,
  2686. newFallback,
  2687. container,
  2688. anchor,
  2689. parentComponent,
  2690. null,
  2691. // fallback tree will not have suspense context
  2692. isSVG,
  2693. slotScopeIds,
  2694. optimized
  2695. );
  2696. setActiveBranch(suspense, newFallback);
  2697. }
  2698. } else {
  2699. suspense.pendingId++;
  2700. if (isHydrating) {
  2701. suspense.isHydrating = false;
  2702. suspense.activeBranch = pendingBranch;
  2703. } else {
  2704. unmount(pendingBranch, parentComponent, suspense);
  2705. }
  2706. suspense.deps = 0;
  2707. suspense.effects.length = 0;
  2708. suspense.hiddenContainer = createElement("div");
  2709. if (isInFallback) {
  2710. patch(
  2711. null,
  2712. newBranch,
  2713. suspense.hiddenContainer,
  2714. null,
  2715. parentComponent,
  2716. suspense,
  2717. isSVG,
  2718. slotScopeIds,
  2719. optimized
  2720. );
  2721. if (suspense.deps <= 0) {
  2722. suspense.resolve();
  2723. } else {
  2724. patch(
  2725. activeBranch,
  2726. newFallback,
  2727. container,
  2728. anchor,
  2729. parentComponent,
  2730. null,
  2731. // fallback tree will not have suspense context
  2732. isSVG,
  2733. slotScopeIds,
  2734. optimized
  2735. );
  2736. setActiveBranch(suspense, newFallback);
  2737. }
  2738. } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2739. patch(
  2740. activeBranch,
  2741. newBranch,
  2742. container,
  2743. anchor,
  2744. parentComponent,
  2745. suspense,
  2746. isSVG,
  2747. slotScopeIds,
  2748. optimized
  2749. );
  2750. suspense.resolve(true);
  2751. } else {
  2752. patch(
  2753. null,
  2754. newBranch,
  2755. suspense.hiddenContainer,
  2756. null,
  2757. parentComponent,
  2758. suspense,
  2759. isSVG,
  2760. slotScopeIds,
  2761. optimized
  2762. );
  2763. if (suspense.deps <= 0) {
  2764. suspense.resolve();
  2765. }
  2766. }
  2767. }
  2768. } else {
  2769. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2770. patch(
  2771. activeBranch,
  2772. newBranch,
  2773. container,
  2774. anchor,
  2775. parentComponent,
  2776. suspense,
  2777. isSVG,
  2778. slotScopeIds,
  2779. optimized
  2780. );
  2781. setActiveBranch(suspense, newBranch);
  2782. } else {
  2783. triggerEvent(n2, "onPending");
  2784. suspense.pendingBranch = newBranch;
  2785. suspense.pendingId++;
  2786. patch(
  2787. null,
  2788. newBranch,
  2789. suspense.hiddenContainer,
  2790. null,
  2791. parentComponent,
  2792. suspense,
  2793. isSVG,
  2794. slotScopeIds,
  2795. optimized
  2796. );
  2797. if (suspense.deps <= 0) {
  2798. suspense.resolve();
  2799. } else {
  2800. const { timeout, pendingId } = suspense;
  2801. if (timeout > 0) {
  2802. setTimeout(() => {
  2803. if (suspense.pendingId === pendingId) {
  2804. suspense.fallback(newFallback);
  2805. }
  2806. }, timeout);
  2807. } else if (timeout === 0) {
  2808. suspense.fallback(newFallback);
  2809. }
  2810. }
  2811. }
  2812. }
  2813. }
  2814. let hasWarned = false;
  2815. function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2816. if (!hasWarned) {
  2817. hasWarned = true;
  2818. console[console.info ? "info" : "log"](
  2819. `<Suspense> is an experimental feature and its API will likely change.`
  2820. );
  2821. }
  2822. const {
  2823. p: patch,
  2824. m: move,
  2825. um: unmount,
  2826. n: next,
  2827. o: { parentNode, remove }
  2828. } = rendererInternals;
  2829. let parentSuspenseId;
  2830. const isSuspensible = isVNodeSuspensible(vnode);
  2831. if (isSuspensible) {
  2832. if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
  2833. parentSuspenseId = parentSuspense.pendingId;
  2834. parentSuspense.deps++;
  2835. }
  2836. }
  2837. const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
  2838. {
  2839. assertNumber(timeout, `Suspense timeout`);
  2840. }
  2841. const suspense = {
  2842. vnode,
  2843. parent: parentSuspense,
  2844. parentComponent,
  2845. isSVG,
  2846. container,
  2847. hiddenContainer,
  2848. anchor,
  2849. deps: 0,
  2850. pendingId: 0,
  2851. timeout: typeof timeout === "number" ? timeout : -1,
  2852. activeBranch: null,
  2853. pendingBranch: null,
  2854. isInFallback: true,
  2855. isHydrating,
  2856. isUnmounted: false,
  2857. effects: [],
  2858. resolve(resume = false, sync = false) {
  2859. {
  2860. if (!resume && !suspense.pendingBranch) {
  2861. throw new Error(
  2862. `suspense.resolve() is called without a pending branch.`
  2863. );
  2864. }
  2865. if (suspense.isUnmounted) {
  2866. throw new Error(
  2867. `suspense.resolve() is called on an already unmounted suspense boundary.`
  2868. );
  2869. }
  2870. }
  2871. const {
  2872. vnode: vnode2,
  2873. activeBranch,
  2874. pendingBranch,
  2875. pendingId,
  2876. effects,
  2877. parentComponent: parentComponent2,
  2878. container: container2
  2879. } = suspense;
  2880. let delayEnter = false;
  2881. if (suspense.isHydrating) {
  2882. suspense.isHydrating = false;
  2883. } else if (!resume) {
  2884. delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
  2885. if (delayEnter) {
  2886. activeBranch.transition.afterLeave = () => {
  2887. if (pendingId === suspense.pendingId) {
  2888. move(
  2889. pendingBranch,
  2890. container2,
  2891. next(activeBranch),
  2892. 0
  2893. );
  2894. queuePostFlushCb(effects);
  2895. }
  2896. };
  2897. }
  2898. let { anchor: anchor2 } = suspense;
  2899. if (activeBranch) {
  2900. anchor2 = next(activeBranch);
  2901. unmount(activeBranch, parentComponent2, suspense, true);
  2902. }
  2903. if (!delayEnter) {
  2904. move(pendingBranch, container2, anchor2, 0);
  2905. }
  2906. }
  2907. setActiveBranch(suspense, pendingBranch);
  2908. suspense.pendingBranch = null;
  2909. suspense.isInFallback = false;
  2910. let parent = suspense.parent;
  2911. let hasUnresolvedAncestor = false;
  2912. while (parent) {
  2913. if (parent.pendingBranch) {
  2914. parent.effects.push(...effects);
  2915. hasUnresolvedAncestor = true;
  2916. break;
  2917. }
  2918. parent = parent.parent;
  2919. }
  2920. if (!hasUnresolvedAncestor && !delayEnter) {
  2921. queuePostFlushCb(effects);
  2922. }
  2923. suspense.effects = [];
  2924. if (isSuspensible) {
  2925. if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
  2926. parentSuspense.deps--;
  2927. if (parentSuspense.deps === 0 && !sync) {
  2928. parentSuspense.resolve();
  2929. }
  2930. }
  2931. }
  2932. triggerEvent(vnode2, "onResolve");
  2933. },
  2934. fallback(fallbackVNode) {
  2935. if (!suspense.pendingBranch) {
  2936. return;
  2937. }
  2938. const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
  2939. triggerEvent(vnode2, "onFallback");
  2940. const anchor2 = next(activeBranch);
  2941. const mountFallback = () => {
  2942. if (!suspense.isInFallback) {
  2943. return;
  2944. }
  2945. patch(
  2946. null,
  2947. fallbackVNode,
  2948. container2,
  2949. anchor2,
  2950. parentComponent2,
  2951. null,
  2952. // fallback tree will not have suspense context
  2953. isSVG2,
  2954. slotScopeIds,
  2955. optimized
  2956. );
  2957. setActiveBranch(suspense, fallbackVNode);
  2958. };
  2959. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
  2960. if (delayEnter) {
  2961. activeBranch.transition.afterLeave = mountFallback;
  2962. }
  2963. suspense.isInFallback = true;
  2964. unmount(
  2965. activeBranch,
  2966. parentComponent2,
  2967. null,
  2968. // no suspense so unmount hooks fire now
  2969. true
  2970. // shouldRemove
  2971. );
  2972. if (!delayEnter) {
  2973. mountFallback();
  2974. }
  2975. },
  2976. move(container2, anchor2, type) {
  2977. suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
  2978. suspense.container = container2;
  2979. },
  2980. next() {
  2981. return suspense.activeBranch && next(suspense.activeBranch);
  2982. },
  2983. registerDep(instance, setupRenderEffect) {
  2984. const isInPendingSuspense = !!suspense.pendingBranch;
  2985. if (isInPendingSuspense) {
  2986. suspense.deps++;
  2987. }
  2988. const hydratedEl = instance.vnode.el;
  2989. instance.asyncDep.catch((err) => {
  2990. handleError(err, instance, 0);
  2991. }).then((asyncSetupResult) => {
  2992. if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
  2993. return;
  2994. }
  2995. instance.asyncResolved = true;
  2996. const { vnode: vnode2 } = instance;
  2997. {
  2998. pushWarningContext(vnode2);
  2999. }
  3000. handleSetupResult(instance, asyncSetupResult, false);
  3001. if (hydratedEl) {
  3002. vnode2.el = hydratedEl;
  3003. }
  3004. const placeholder = !hydratedEl && instance.subTree.el;
  3005. setupRenderEffect(
  3006. instance,
  3007. vnode2,
  3008. // component may have been moved before resolve.
  3009. // if this is not a hydration, instance.subTree will be the comment
  3010. // placeholder.
  3011. parentNode(hydratedEl || instance.subTree.el),
  3012. // anchor will not be used if this is hydration, so only need to
  3013. // consider the comment placeholder case.
  3014. hydratedEl ? null : next(instance.subTree),
  3015. suspense,
  3016. isSVG,
  3017. optimized
  3018. );
  3019. if (placeholder) {
  3020. remove(placeholder);
  3021. }
  3022. updateHOCHostEl(instance, vnode2.el);
  3023. {
  3024. popWarningContext();
  3025. }
  3026. if (isInPendingSuspense && --suspense.deps === 0) {
  3027. suspense.resolve();
  3028. }
  3029. });
  3030. },
  3031. unmount(parentSuspense2, doRemove) {
  3032. suspense.isUnmounted = true;
  3033. if (suspense.activeBranch) {
  3034. unmount(
  3035. suspense.activeBranch,
  3036. parentComponent,
  3037. parentSuspense2,
  3038. doRemove
  3039. );
  3040. }
  3041. if (suspense.pendingBranch) {
  3042. unmount(
  3043. suspense.pendingBranch,
  3044. parentComponent,
  3045. parentSuspense2,
  3046. doRemove
  3047. );
  3048. }
  3049. }
  3050. };
  3051. return suspense;
  3052. }
  3053. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  3054. const suspense = vnode.suspense = createSuspenseBoundary(
  3055. vnode,
  3056. parentSuspense,
  3057. parentComponent,
  3058. node.parentNode,
  3059. document.createElement("div"),
  3060. null,
  3061. isSVG,
  3062. slotScopeIds,
  3063. optimized,
  3064. rendererInternals,
  3065. true
  3066. /* hydrating */
  3067. );
  3068. const result = hydrateNode(
  3069. node,
  3070. suspense.pendingBranch = vnode.ssContent,
  3071. parentComponent,
  3072. suspense,
  3073. slotScopeIds,
  3074. optimized
  3075. );
  3076. if (suspense.deps === 0) {
  3077. suspense.resolve(false, true);
  3078. }
  3079. return result;
  3080. }
  3081. function normalizeSuspenseChildren(vnode) {
  3082. const { shapeFlag, children } = vnode;
  3083. const isSlotChildren = shapeFlag & 32;
  3084. vnode.ssContent = normalizeSuspenseSlot(
  3085. isSlotChildren ? children.default : children
  3086. );
  3087. vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
  3088. }
  3089. function normalizeSuspenseSlot(s) {
  3090. let block;
  3091. if (isFunction(s)) {
  3092. const trackBlock = isBlockTreeEnabled && s._c;
  3093. if (trackBlock) {
  3094. s._d = false;
  3095. openBlock();
  3096. }
  3097. s = s();
  3098. if (trackBlock) {
  3099. s._d = true;
  3100. block = currentBlock;
  3101. closeBlock();
  3102. }
  3103. }
  3104. if (isArray(s)) {
  3105. const singleChild = filterSingleRoot(s);
  3106. if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
  3107. warn(`<Suspense> slots expect a single root node.`);
  3108. }
  3109. s = singleChild;
  3110. }
  3111. s = normalizeVNode(s);
  3112. if (block && !s.dynamicChildren) {
  3113. s.dynamicChildren = block.filter((c) => c !== s);
  3114. }
  3115. return s;
  3116. }
  3117. function queueEffectWithSuspense(fn, suspense) {
  3118. if (suspense && suspense.pendingBranch) {
  3119. if (isArray(fn)) {
  3120. suspense.effects.push(...fn);
  3121. } else {
  3122. suspense.effects.push(fn);
  3123. }
  3124. } else {
  3125. queuePostFlushCb(fn);
  3126. }
  3127. }
  3128. function setActiveBranch(suspense, branch) {
  3129. suspense.activeBranch = branch;
  3130. const { vnode, parentComponent } = suspense;
  3131. const el = vnode.el = branch.el;
  3132. if (parentComponent && parentComponent.subTree === vnode) {
  3133. parentComponent.vnode.el = el;
  3134. updateHOCHostEl(parentComponent, el);
  3135. }
  3136. }
  3137. function isVNodeSuspensible(vnode) {
  3138. var _a;
  3139. return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
  3140. }
  3141. function watchEffect(effect, options) {
  3142. return doWatch(effect, null, options);
  3143. }
  3144. function watchPostEffect(effect, options) {
  3145. return doWatch(
  3146. effect,
  3147. null,
  3148. extend({}, options, { flush: "post" })
  3149. );
  3150. }
  3151. function watchSyncEffect(effect, options) {
  3152. return doWatch(
  3153. effect,
  3154. null,
  3155. extend({}, options, { flush: "sync" })
  3156. );
  3157. }
  3158. const INITIAL_WATCHER_VALUE = {};
  3159. function watch(source, cb, options) {
  3160. if (!isFunction(cb)) {
  3161. warn(
  3162. `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
  3163. );
  3164. }
  3165. return doWatch(source, cb, options);
  3166. }
  3167. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3168. var _a;
  3169. if (!cb) {
  3170. if (immediate !== void 0) {
  3171. warn(
  3172. `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
  3173. );
  3174. }
  3175. if (deep !== void 0) {
  3176. warn(
  3177. `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
  3178. );
  3179. }
  3180. }
  3181. const warnInvalidSource = (s) => {
  3182. warn(
  3183. `Invalid watch source: `,
  3184. s,
  3185. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  3186. );
  3187. };
  3188. const instance = getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
  3189. let getter;
  3190. let forceTrigger = false;
  3191. let isMultiSource = false;
  3192. if (isRef(source)) {
  3193. getter = () => source.value;
  3194. forceTrigger = isShallow(source);
  3195. } else if (isReactive(source)) {
  3196. getter = () => source;
  3197. deep = true;
  3198. } else if (isArray(source)) {
  3199. isMultiSource = true;
  3200. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  3201. getter = () => source.map((s) => {
  3202. if (isRef(s)) {
  3203. return s.value;
  3204. } else if (isReactive(s)) {
  3205. return traverse(s);
  3206. } else if (isFunction(s)) {
  3207. return callWithErrorHandling(s, instance, 2);
  3208. } else {
  3209. warnInvalidSource(s);
  3210. }
  3211. });
  3212. } else if (isFunction(source)) {
  3213. if (cb) {
  3214. getter = () => callWithErrorHandling(source, instance, 2);
  3215. } else {
  3216. getter = () => {
  3217. if (instance && instance.isUnmounted) {
  3218. return;
  3219. }
  3220. if (cleanup) {
  3221. cleanup();
  3222. }
  3223. return callWithAsyncErrorHandling(
  3224. source,
  3225. instance,
  3226. 3,
  3227. [onCleanup]
  3228. );
  3229. };
  3230. }
  3231. } else {
  3232. getter = NOOP;
  3233. warnInvalidSource(source);
  3234. }
  3235. if (cb && deep) {
  3236. const baseGetter = getter;
  3237. getter = () => traverse(baseGetter());
  3238. }
  3239. let cleanup;
  3240. let onCleanup = (fn) => {
  3241. cleanup = effect.onStop = () => {
  3242. callWithErrorHandling(fn, instance, 4);
  3243. cleanup = effect.onStop = void 0;
  3244. };
  3245. };
  3246. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  3247. const job = () => {
  3248. if (!effect.active) {
  3249. return;
  3250. }
  3251. if (cb) {
  3252. const newValue = effect.run();
  3253. if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
  3254. if (cleanup) {
  3255. cleanup();
  3256. }
  3257. callWithAsyncErrorHandling(cb, instance, 3, [
  3258. newValue,
  3259. // pass undefined as the old value when it's changed for the first time
  3260. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  3261. onCleanup
  3262. ]);
  3263. oldValue = newValue;
  3264. }
  3265. } else {
  3266. effect.run();
  3267. }
  3268. };
  3269. job.allowRecurse = !!cb;
  3270. let scheduler;
  3271. if (flush === "sync") {
  3272. scheduler = job;
  3273. } else if (flush === "post") {
  3274. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3275. } else {
  3276. job.pre = true;
  3277. if (instance)
  3278. job.id = instance.uid;
  3279. scheduler = () => queueJob(job);
  3280. }
  3281. const effect = new ReactiveEffect(getter, scheduler);
  3282. {
  3283. effect.onTrack = onTrack;
  3284. effect.onTrigger = onTrigger;
  3285. }
  3286. if (cb) {
  3287. if (immediate) {
  3288. job();
  3289. } else {
  3290. oldValue = effect.run();
  3291. }
  3292. } else if (flush === "post") {
  3293. queuePostRenderEffect(
  3294. effect.run.bind(effect),
  3295. instance && instance.suspense
  3296. );
  3297. } else {
  3298. effect.run();
  3299. }
  3300. const unwatch = () => {
  3301. effect.stop();
  3302. if (instance && instance.scope) {
  3303. remove(instance.scope.effects, effect);
  3304. }
  3305. };
  3306. return unwatch;
  3307. }
  3308. function instanceWatch(source, value, options) {
  3309. const publicThis = this.proxy;
  3310. const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
  3311. let cb;
  3312. if (isFunction(value)) {
  3313. cb = value;
  3314. } else {
  3315. cb = value.handler;
  3316. options = value;
  3317. }
  3318. const cur = currentInstance;
  3319. setCurrentInstance(this);
  3320. const res = doWatch(getter, cb.bind(publicThis), options);
  3321. if (cur) {
  3322. setCurrentInstance(cur);
  3323. } else {
  3324. unsetCurrentInstance();
  3325. }
  3326. return res;
  3327. }
  3328. function createPathGetter(ctx, path) {
  3329. const segments = path.split(".");
  3330. return () => {
  3331. let cur = ctx;
  3332. for (let i = 0; i < segments.length && cur; i++) {
  3333. cur = cur[segments[i]];
  3334. }
  3335. return cur;
  3336. };
  3337. }
  3338. function traverse(value, seen) {
  3339. if (!isObject(value) || value["__v_skip"]) {
  3340. return value;
  3341. }
  3342. seen = seen || /* @__PURE__ */ new Set();
  3343. if (seen.has(value)) {
  3344. return value;
  3345. }
  3346. seen.add(value);
  3347. if (isRef(value)) {
  3348. traverse(value.value, seen);
  3349. } else if (isArray(value)) {
  3350. for (let i = 0; i < value.length; i++) {
  3351. traverse(value[i], seen);
  3352. }
  3353. } else if (isSet(value) || isMap(value)) {
  3354. value.forEach((v) => {
  3355. traverse(v, seen);
  3356. });
  3357. } else if (isPlainObject(value)) {
  3358. for (const key in value) {
  3359. traverse(value[key], seen);
  3360. }
  3361. }
  3362. return value;
  3363. }
  3364. function validateDirectiveName(name) {
  3365. if (isBuiltInDirective(name)) {
  3366. warn("Do not use built-in directive ids as custom directive id: " + name);
  3367. }
  3368. }
  3369. function withDirectives(vnode, directives) {
  3370. const internalInstance = currentRenderingInstance;
  3371. if (internalInstance === null) {
  3372. warn(`withDirectives can only be used inside render functions.`);
  3373. return vnode;
  3374. }
  3375. const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
  3376. const bindings = vnode.dirs || (vnode.dirs = []);
  3377. for (let i = 0; i < directives.length; i++) {
  3378. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  3379. if (dir) {
  3380. if (isFunction(dir)) {
  3381. dir = {
  3382. mounted: dir,
  3383. updated: dir
  3384. };
  3385. }
  3386. if (dir.deep) {
  3387. traverse(value);
  3388. }
  3389. bindings.push({
  3390. dir,
  3391. instance,
  3392. value,
  3393. oldValue: void 0,
  3394. arg,
  3395. modifiers
  3396. });
  3397. }
  3398. }
  3399. return vnode;
  3400. }
  3401. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  3402. const bindings = vnode.dirs;
  3403. const oldBindings = prevVNode && prevVNode.dirs;
  3404. for (let i = 0; i < bindings.length; i++) {
  3405. const binding = bindings[i];
  3406. if (oldBindings) {
  3407. binding.oldValue = oldBindings[i].value;
  3408. }
  3409. let hook = binding.dir[name];
  3410. if (hook) {
  3411. pauseTracking();
  3412. callWithAsyncErrorHandling(hook, instance, 8, [
  3413. vnode.el,
  3414. binding,
  3415. vnode,
  3416. prevVNode
  3417. ]);
  3418. resetTracking();
  3419. }
  3420. }
  3421. }
  3422. const leaveCbKey = Symbol("_leaveCb");
  3423. const enterCbKey$1 = Symbol("_enterCb");
  3424. function useTransitionState() {
  3425. const state = {
  3426. isMounted: false,
  3427. isLeaving: false,
  3428. isUnmounting: false,
  3429. leavingVNodes: /* @__PURE__ */ new Map()
  3430. };
  3431. onMounted(() => {
  3432. state.isMounted = true;
  3433. });
  3434. onBeforeUnmount(() => {
  3435. state.isUnmounting = true;
  3436. });
  3437. return state;
  3438. }
  3439. const TransitionHookValidator = [Function, Array];
  3440. const BaseTransitionPropsValidators = {
  3441. mode: String,
  3442. appear: Boolean,
  3443. persisted: Boolean,
  3444. // enter
  3445. onBeforeEnter: TransitionHookValidator,
  3446. onEnter: TransitionHookValidator,
  3447. onAfterEnter: TransitionHookValidator,
  3448. onEnterCancelled: TransitionHookValidator,
  3449. // leave
  3450. onBeforeLeave: TransitionHookValidator,
  3451. onLeave: TransitionHookValidator,
  3452. onAfterLeave: TransitionHookValidator,
  3453. onLeaveCancelled: TransitionHookValidator,
  3454. // appear
  3455. onBeforeAppear: TransitionHookValidator,
  3456. onAppear: TransitionHookValidator,
  3457. onAfterAppear: TransitionHookValidator,
  3458. onAppearCancelled: TransitionHookValidator
  3459. };
  3460. const BaseTransitionImpl = {
  3461. name: `BaseTransition`,
  3462. props: BaseTransitionPropsValidators,
  3463. setup(props, { slots }) {
  3464. const instance = getCurrentInstance();
  3465. const state = useTransitionState();
  3466. let prevTransitionKey;
  3467. return () => {
  3468. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3469. if (!children || !children.length) {
  3470. return;
  3471. }
  3472. let child = children[0];
  3473. if (children.length > 1) {
  3474. let hasFound = false;
  3475. for (const c of children) {
  3476. if (c.type !== Comment) {
  3477. if (hasFound) {
  3478. warn(
  3479. "<transition> can only be used on a single element or component. Use <transition-group> for lists."
  3480. );
  3481. break;
  3482. }
  3483. child = c;
  3484. hasFound = true;
  3485. }
  3486. }
  3487. }
  3488. const rawProps = toRaw(props);
  3489. const { mode } = rawProps;
  3490. if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
  3491. warn(`invalid <transition> mode: ${mode}`);
  3492. }
  3493. if (state.isLeaving) {
  3494. return emptyPlaceholder(child);
  3495. }
  3496. const innerChild = getKeepAliveChild(child);
  3497. if (!innerChild) {
  3498. return emptyPlaceholder(child);
  3499. }
  3500. const enterHooks = resolveTransitionHooks(
  3501. innerChild,
  3502. rawProps,
  3503. state,
  3504. instance
  3505. );
  3506. setTransitionHooks(innerChild, enterHooks);
  3507. const oldChild = instance.subTree;
  3508. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3509. let transitionKeyChanged = false;
  3510. const { getTransitionKey } = innerChild.type;
  3511. if (getTransitionKey) {
  3512. const key = getTransitionKey();
  3513. if (prevTransitionKey === void 0) {
  3514. prevTransitionKey = key;
  3515. } else if (key !== prevTransitionKey) {
  3516. prevTransitionKey = key;
  3517. transitionKeyChanged = true;
  3518. }
  3519. }
  3520. if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3521. const leavingHooks = resolveTransitionHooks(
  3522. oldInnerChild,
  3523. rawProps,
  3524. state,
  3525. instance
  3526. );
  3527. setTransitionHooks(oldInnerChild, leavingHooks);
  3528. if (mode === "out-in") {
  3529. state.isLeaving = true;
  3530. leavingHooks.afterLeave = () => {
  3531. state.isLeaving = false;
  3532. if (instance.update.active !== false) {
  3533. instance.update();
  3534. }
  3535. };
  3536. return emptyPlaceholder(child);
  3537. } else if (mode === "in-out" && innerChild.type !== Comment) {
  3538. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3539. const leavingVNodesCache = getLeavingNodesForType(
  3540. state,
  3541. oldInnerChild
  3542. );
  3543. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3544. el[leaveCbKey] = () => {
  3545. earlyRemove();
  3546. el[leaveCbKey] = void 0;
  3547. delete enterHooks.delayedLeave;
  3548. };
  3549. enterHooks.delayedLeave = delayedLeave;
  3550. };
  3551. }
  3552. }
  3553. return child;
  3554. };
  3555. }
  3556. };
  3557. const BaseTransition = BaseTransitionImpl;
  3558. function getLeavingNodesForType(state, vnode) {
  3559. const { leavingVNodes } = state;
  3560. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3561. if (!leavingVNodesCache) {
  3562. leavingVNodesCache = /* @__PURE__ */ Object.create(null);
  3563. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3564. }
  3565. return leavingVNodesCache;
  3566. }
  3567. function resolveTransitionHooks(vnode, props, state, instance) {
  3568. const {
  3569. appear,
  3570. mode,
  3571. persisted = false,
  3572. onBeforeEnter,
  3573. onEnter,
  3574. onAfterEnter,
  3575. onEnterCancelled,
  3576. onBeforeLeave,
  3577. onLeave,
  3578. onAfterLeave,
  3579. onLeaveCancelled,
  3580. onBeforeAppear,
  3581. onAppear,
  3582. onAfterAppear,
  3583. onAppearCancelled
  3584. } = props;
  3585. const key = String(vnode.key);
  3586. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3587. const callHook = (hook, args) => {
  3588. hook && callWithAsyncErrorHandling(
  3589. hook,
  3590. instance,
  3591. 9,
  3592. args
  3593. );
  3594. };
  3595. const callAsyncHook = (hook, args) => {
  3596. const done = args[1];
  3597. callHook(hook, args);
  3598. if (isArray(hook)) {
  3599. if (hook.every((hook2) => hook2.length <= 1))
  3600. done();
  3601. } else if (hook.length <= 1) {
  3602. done();
  3603. }
  3604. };
  3605. const hooks = {
  3606. mode,
  3607. persisted,
  3608. beforeEnter(el) {
  3609. let hook = onBeforeEnter;
  3610. if (!state.isMounted) {
  3611. if (appear) {
  3612. hook = onBeforeAppear || onBeforeEnter;
  3613. } else {
  3614. return;
  3615. }
  3616. }
  3617. if (el[leaveCbKey]) {
  3618. el[leaveCbKey](
  3619. true
  3620. /* cancelled */
  3621. );
  3622. }
  3623. const leavingVNode = leavingVNodesCache[key];
  3624. if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
  3625. leavingVNode.el[leaveCbKey]();
  3626. }
  3627. callHook(hook, [el]);
  3628. },
  3629. enter(el) {
  3630. let hook = onEnter;
  3631. let afterHook = onAfterEnter;
  3632. let cancelHook = onEnterCancelled;
  3633. if (!state.isMounted) {
  3634. if (appear) {
  3635. hook = onAppear || onEnter;
  3636. afterHook = onAfterAppear || onAfterEnter;
  3637. cancelHook = onAppearCancelled || onEnterCancelled;
  3638. } else {
  3639. return;
  3640. }
  3641. }
  3642. let called = false;
  3643. const done = el[enterCbKey$1] = (cancelled) => {
  3644. if (called)
  3645. return;
  3646. called = true;
  3647. if (cancelled) {
  3648. callHook(cancelHook, [el]);
  3649. } else {
  3650. callHook(afterHook, [el]);
  3651. }
  3652. if (hooks.delayedLeave) {
  3653. hooks.delayedLeave();
  3654. }
  3655. el[enterCbKey$1] = void 0;
  3656. };
  3657. if (hook) {
  3658. callAsyncHook(hook, [el, done]);
  3659. } else {
  3660. done();
  3661. }
  3662. },
  3663. leave(el, remove) {
  3664. const key2 = String(vnode.key);
  3665. if (el[enterCbKey$1]) {
  3666. el[enterCbKey$1](
  3667. true
  3668. /* cancelled */
  3669. );
  3670. }
  3671. if (state.isUnmounting) {
  3672. return remove();
  3673. }
  3674. callHook(onBeforeLeave, [el]);
  3675. let called = false;
  3676. const done = el[leaveCbKey] = (cancelled) => {
  3677. if (called)
  3678. return;
  3679. called = true;
  3680. remove();
  3681. if (cancelled) {
  3682. callHook(onLeaveCancelled, [el]);
  3683. } else {
  3684. callHook(onAfterLeave, [el]);
  3685. }
  3686. el[leaveCbKey] = void 0;
  3687. if (leavingVNodesCache[key2] === vnode) {
  3688. delete leavingVNodesCache[key2];
  3689. }
  3690. };
  3691. leavingVNodesCache[key2] = vnode;
  3692. if (onLeave) {
  3693. callAsyncHook(onLeave, [el, done]);
  3694. } else {
  3695. done();
  3696. }
  3697. },
  3698. clone(vnode2) {
  3699. return resolveTransitionHooks(vnode2, props, state, instance);
  3700. }
  3701. };
  3702. return hooks;
  3703. }
  3704. function emptyPlaceholder(vnode) {
  3705. if (isKeepAlive(vnode)) {
  3706. vnode = cloneVNode(vnode);
  3707. vnode.children = null;
  3708. return vnode;
  3709. }
  3710. }
  3711. function getKeepAliveChild(vnode) {
  3712. return isKeepAlive(vnode) ? (
  3713. // #7121 ensure get the child component subtree in case
  3714. // it's been replaced during HMR
  3715. vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
  3716. ) : vnode;
  3717. }
  3718. function setTransitionHooks(vnode, hooks) {
  3719. if (vnode.shapeFlag & 6 && vnode.component) {
  3720. setTransitionHooks(vnode.component.subTree, hooks);
  3721. } else if (vnode.shapeFlag & 128) {
  3722. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3723. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3724. } else {
  3725. vnode.transition = hooks;
  3726. }
  3727. }
  3728. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3729. let ret = [];
  3730. let keyedFragmentCount = 0;
  3731. for (let i = 0; i < children.length; i++) {
  3732. let child = children[i];
  3733. const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
  3734. if (child.type === Fragment) {
  3735. if (child.patchFlag & 128)
  3736. keyedFragmentCount++;
  3737. ret = ret.concat(
  3738. getTransitionRawChildren(child.children, keepComment, key)
  3739. );
  3740. } else if (keepComment || child.type !== Comment) {
  3741. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3742. }
  3743. }
  3744. if (keyedFragmentCount > 1) {
  3745. for (let i = 0; i < ret.length; i++) {
  3746. ret[i].patchFlag = -2;
  3747. }
  3748. }
  3749. return ret;
  3750. }
  3751. /*! #__NO_SIDE_EFFECTS__ */
  3752. // @__NO_SIDE_EFFECTS__
  3753. function defineComponent(options, extraOptions) {
  3754. return isFunction(options) ? (
  3755. // #8326: extend call and options.name access are considered side-effects
  3756. // by Rollup, so we have to wrap it in a pure-annotated IIFE.
  3757. /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
  3758. ) : options;
  3759. }
  3760. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3761. /*! #__NO_SIDE_EFFECTS__ */
  3762. // @__NO_SIDE_EFFECTS__
  3763. function defineAsyncComponent(source) {
  3764. if (isFunction(source)) {
  3765. source = { loader: source };
  3766. }
  3767. const {
  3768. loader,
  3769. loadingComponent,
  3770. errorComponent,
  3771. delay = 200,
  3772. timeout,
  3773. // undefined = never times out
  3774. suspensible = true,
  3775. onError: userOnError
  3776. } = source;
  3777. let pendingRequest = null;
  3778. let resolvedComp;
  3779. let retries = 0;
  3780. const retry = () => {
  3781. retries++;
  3782. pendingRequest = null;
  3783. return load();
  3784. };
  3785. const load = () => {
  3786. let thisRequest;
  3787. return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
  3788. err = err instanceof Error ? err : new Error(String(err));
  3789. if (userOnError) {
  3790. return new Promise((resolve, reject) => {
  3791. const userRetry = () => resolve(retry());
  3792. const userFail = () => reject(err);
  3793. userOnError(err, userRetry, userFail, retries + 1);
  3794. });
  3795. } else {
  3796. throw err;
  3797. }
  3798. }).then((comp) => {
  3799. if (thisRequest !== pendingRequest && pendingRequest) {
  3800. return pendingRequest;
  3801. }
  3802. if (!comp) {
  3803. warn(
  3804. `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
  3805. );
  3806. }
  3807. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  3808. comp = comp.default;
  3809. }
  3810. if (comp && !isObject(comp) && !isFunction(comp)) {
  3811. throw new Error(`Invalid async component load result: ${comp}`);
  3812. }
  3813. resolvedComp = comp;
  3814. return comp;
  3815. }));
  3816. };
  3817. return defineComponent({
  3818. name: "AsyncComponentWrapper",
  3819. __asyncLoader: load,
  3820. get __asyncResolved() {
  3821. return resolvedComp;
  3822. },
  3823. setup() {
  3824. const instance = currentInstance;
  3825. if (resolvedComp) {
  3826. return () => createInnerComp(resolvedComp, instance);
  3827. }
  3828. const onError = (err) => {
  3829. pendingRequest = null;
  3830. handleError(
  3831. err,
  3832. instance,
  3833. 13,
  3834. !errorComponent
  3835. /* do not throw in dev if user provided error component */
  3836. );
  3837. };
  3838. if (suspensible && instance.suspense || false) {
  3839. return load().then((comp) => {
  3840. return () => createInnerComp(comp, instance);
  3841. }).catch((err) => {
  3842. onError(err);
  3843. return () => errorComponent ? createVNode(errorComponent, {
  3844. error: err
  3845. }) : null;
  3846. });
  3847. }
  3848. const loaded = ref(false);
  3849. const error = ref();
  3850. const delayed = ref(!!delay);
  3851. if (delay) {
  3852. setTimeout(() => {
  3853. delayed.value = false;
  3854. }, delay);
  3855. }
  3856. if (timeout != null) {
  3857. setTimeout(() => {
  3858. if (!loaded.value && !error.value) {
  3859. const err = new Error(
  3860. `Async component timed out after ${timeout}ms.`
  3861. );
  3862. onError(err);
  3863. error.value = err;
  3864. }
  3865. }, timeout);
  3866. }
  3867. load().then(() => {
  3868. loaded.value = true;
  3869. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3870. queueJob(instance.parent.update);
  3871. }
  3872. }).catch((err) => {
  3873. onError(err);
  3874. error.value = err;
  3875. });
  3876. return () => {
  3877. if (loaded.value && resolvedComp) {
  3878. return createInnerComp(resolvedComp, instance);
  3879. } else if (error.value && errorComponent) {
  3880. return createVNode(errorComponent, {
  3881. error: error.value
  3882. });
  3883. } else if (loadingComponent && !delayed.value) {
  3884. return createVNode(loadingComponent);
  3885. }
  3886. };
  3887. }
  3888. });
  3889. }
  3890. function createInnerComp(comp, parent) {
  3891. const { ref: ref2, props, children, ce } = parent.vnode;
  3892. const vnode = createVNode(comp, props, children);
  3893. vnode.ref = ref2;
  3894. vnode.ce = ce;
  3895. delete parent.vnode.ce;
  3896. return vnode;
  3897. }
  3898. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3899. const KeepAliveImpl = {
  3900. name: `KeepAlive`,
  3901. // Marker for special handling inside the renderer. We are not using a ===
  3902. // check directly on KeepAlive in the renderer, because importing it directly
  3903. // would prevent it from being tree-shaken.
  3904. __isKeepAlive: true,
  3905. props: {
  3906. include: [String, RegExp, Array],
  3907. exclude: [String, RegExp, Array],
  3908. max: [String, Number]
  3909. },
  3910. setup(props, { slots }) {
  3911. const instance = getCurrentInstance();
  3912. const sharedContext = instance.ctx;
  3913. const cache = /* @__PURE__ */ new Map();
  3914. const keys = /* @__PURE__ */ new Set();
  3915. let current = null;
  3916. {
  3917. instance.__v_cache = cache;
  3918. }
  3919. const parentSuspense = instance.suspense;
  3920. const {
  3921. renderer: {
  3922. p: patch,
  3923. m: move,
  3924. um: _unmount,
  3925. o: { createElement }
  3926. }
  3927. } = sharedContext;
  3928. const storageContainer = createElement("div");
  3929. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3930. const instance2 = vnode.component;
  3931. move(vnode, container, anchor, 0, parentSuspense);
  3932. patch(
  3933. instance2.vnode,
  3934. vnode,
  3935. container,
  3936. anchor,
  3937. instance2,
  3938. parentSuspense,
  3939. isSVG,
  3940. vnode.slotScopeIds,
  3941. optimized
  3942. );
  3943. queuePostRenderEffect(() => {
  3944. instance2.isDeactivated = false;
  3945. if (instance2.a) {
  3946. invokeArrayFns(instance2.a);
  3947. }
  3948. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3949. if (vnodeHook) {
  3950. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  3951. }
  3952. }, parentSuspense);
  3953. {
  3954. devtoolsComponentAdded(instance2);
  3955. }
  3956. };
  3957. sharedContext.deactivate = (vnode) => {
  3958. const instance2 = vnode.component;
  3959. move(vnode, storageContainer, null, 1, parentSuspense);
  3960. queuePostRenderEffect(() => {
  3961. if (instance2.da) {
  3962. invokeArrayFns(instance2.da);
  3963. }
  3964. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3965. if (vnodeHook) {
  3966. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  3967. }
  3968. instance2.isDeactivated = true;
  3969. }, parentSuspense);
  3970. {
  3971. devtoolsComponentAdded(instance2);
  3972. }
  3973. };
  3974. function unmount(vnode) {
  3975. resetShapeFlag(vnode);
  3976. _unmount(vnode, instance, parentSuspense, true);
  3977. }
  3978. function pruneCache(filter) {
  3979. cache.forEach((vnode, key) => {
  3980. const name = getComponentName(vnode.type);
  3981. if (name && (!filter || !filter(name))) {
  3982. pruneCacheEntry(key);
  3983. }
  3984. });
  3985. }
  3986. function pruneCacheEntry(key) {
  3987. const cached = cache.get(key);
  3988. if (!current || !isSameVNodeType(cached, current)) {
  3989. unmount(cached);
  3990. } else if (current) {
  3991. resetShapeFlag(current);
  3992. }
  3993. cache.delete(key);
  3994. keys.delete(key);
  3995. }
  3996. watch(
  3997. () => [props.include, props.exclude],
  3998. ([include, exclude]) => {
  3999. include && pruneCache((name) => matches(include, name));
  4000. exclude && pruneCache((name) => !matches(exclude, name));
  4001. },
  4002. // prune post-render after `current` has been updated
  4003. { flush: "post", deep: true }
  4004. );
  4005. let pendingCacheKey = null;
  4006. const cacheSubtree = () => {
  4007. if (pendingCacheKey != null) {
  4008. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  4009. }
  4010. };
  4011. onMounted(cacheSubtree);
  4012. onUpdated(cacheSubtree);
  4013. onBeforeUnmount(() => {
  4014. cache.forEach((cached) => {
  4015. const { subTree, suspense } = instance;
  4016. const vnode = getInnerChild(subTree);
  4017. if (cached.type === vnode.type && cached.key === vnode.key) {
  4018. resetShapeFlag(vnode);
  4019. const da = vnode.component.da;
  4020. da && queuePostRenderEffect(da, suspense);
  4021. return;
  4022. }
  4023. unmount(cached);
  4024. });
  4025. });
  4026. return () => {
  4027. pendingCacheKey = null;
  4028. if (!slots.default) {
  4029. return null;
  4030. }
  4031. const children = slots.default();
  4032. const rawVNode = children[0];
  4033. if (children.length > 1) {
  4034. {
  4035. warn(`KeepAlive should contain exactly one component child.`);
  4036. }
  4037. current = null;
  4038. return children;
  4039. } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
  4040. current = null;
  4041. return rawVNode;
  4042. }
  4043. let vnode = getInnerChild(rawVNode);
  4044. const comp = vnode.type;
  4045. const name = getComponentName(
  4046. isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
  4047. );
  4048. const { include, exclude, max } = props;
  4049. if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
  4050. current = vnode;
  4051. return rawVNode;
  4052. }
  4053. const key = vnode.key == null ? comp : vnode.key;
  4054. const cachedVNode = cache.get(key);
  4055. if (vnode.el) {
  4056. vnode = cloneVNode(vnode);
  4057. if (rawVNode.shapeFlag & 128) {
  4058. rawVNode.ssContent = vnode;
  4059. }
  4060. }
  4061. pendingCacheKey = key;
  4062. if (cachedVNode) {
  4063. vnode.el = cachedVNode.el;
  4064. vnode.component = cachedVNode.component;
  4065. if (vnode.transition) {
  4066. setTransitionHooks(vnode, vnode.transition);
  4067. }
  4068. vnode.shapeFlag |= 512;
  4069. keys.delete(key);
  4070. keys.add(key);
  4071. } else {
  4072. keys.add(key);
  4073. if (max && keys.size > parseInt(max, 10)) {
  4074. pruneCacheEntry(keys.values().next().value);
  4075. }
  4076. }
  4077. vnode.shapeFlag |= 256;
  4078. current = vnode;
  4079. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  4080. };
  4081. }
  4082. };
  4083. const KeepAlive = KeepAliveImpl;
  4084. function matches(pattern, name) {
  4085. if (isArray(pattern)) {
  4086. return pattern.some((p) => matches(p, name));
  4087. } else if (isString(pattern)) {
  4088. return pattern.split(",").includes(name);
  4089. } else if (isRegExp(pattern)) {
  4090. return pattern.test(name);
  4091. }
  4092. return false;
  4093. }
  4094. function onActivated(hook, target) {
  4095. registerKeepAliveHook(hook, "a", target);
  4096. }
  4097. function onDeactivated(hook, target) {
  4098. registerKeepAliveHook(hook, "da", target);
  4099. }
  4100. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4101. const wrappedHook = hook.__wdc || (hook.__wdc = () => {
  4102. let current = target;
  4103. while (current) {
  4104. if (current.isDeactivated) {
  4105. return;
  4106. }
  4107. current = current.parent;
  4108. }
  4109. return hook();
  4110. });
  4111. injectHook(type, wrappedHook, target);
  4112. if (target) {
  4113. let current = target.parent;
  4114. while (current && current.parent) {
  4115. if (isKeepAlive(current.parent.vnode)) {
  4116. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4117. }
  4118. current = current.parent;
  4119. }
  4120. }
  4121. }
  4122. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4123. const injected = injectHook(
  4124. type,
  4125. hook,
  4126. keepAliveRoot,
  4127. true
  4128. /* prepend */
  4129. );
  4130. onUnmounted(() => {
  4131. remove(keepAliveRoot[type], injected);
  4132. }, target);
  4133. }
  4134. function resetShapeFlag(vnode) {
  4135. vnode.shapeFlag &= ~256;
  4136. vnode.shapeFlag &= ~512;
  4137. }
  4138. function getInnerChild(vnode) {
  4139. return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
  4140. }
  4141. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4142. if (target) {
  4143. const hooks = target[type] || (target[type] = []);
  4144. const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
  4145. if (target.isUnmounted) {
  4146. return;
  4147. }
  4148. pauseTracking();
  4149. setCurrentInstance(target);
  4150. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4151. unsetCurrentInstance();
  4152. resetTracking();
  4153. return res;
  4154. });
  4155. if (prepend) {
  4156. hooks.unshift(wrappedHook);
  4157. } else {
  4158. hooks.push(wrappedHook);
  4159. }
  4160. return wrappedHook;
  4161. } else {
  4162. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
  4163. warn(
  4164. `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
  4165. );
  4166. }
  4167. }
  4168. const createHook = (lifecycle) => (hook, target = currentInstance) => (
  4169. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4170. (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
  4171. );
  4172. const onBeforeMount = createHook("bm");
  4173. const onMounted = createHook("m");
  4174. const onBeforeUpdate = createHook("bu");
  4175. const onUpdated = createHook("u");
  4176. const onBeforeUnmount = createHook("bum");
  4177. const onUnmounted = createHook("um");
  4178. const onServerPrefetch = createHook("sp");
  4179. const onRenderTriggered = createHook(
  4180. "rtg"
  4181. );
  4182. const onRenderTracked = createHook(
  4183. "rtc"
  4184. );
  4185. function onErrorCaptured(hook, target = currentInstance) {
  4186. injectHook("ec", hook, target);
  4187. }
  4188. function renderList(source, renderItem, cache, index) {
  4189. let ret;
  4190. const cached = cache && cache[index];
  4191. if (isArray(source) || isString(source)) {
  4192. ret = new Array(source.length);
  4193. for (let i = 0, l = source.length; i < l; i++) {
  4194. ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
  4195. }
  4196. } else if (typeof source === "number") {
  4197. if (!Number.isInteger(source)) {
  4198. warn(`The v-for range expect an integer value but got ${source}.`);
  4199. }
  4200. ret = new Array(source);
  4201. for (let i = 0; i < source; i++) {
  4202. ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
  4203. }
  4204. } else if (isObject(source)) {
  4205. if (source[Symbol.iterator]) {
  4206. ret = Array.from(
  4207. source,
  4208. (item, i) => renderItem(item, i, void 0, cached && cached[i])
  4209. );
  4210. } else {
  4211. const keys = Object.keys(source);
  4212. ret = new Array(keys.length);
  4213. for (let i = 0, l = keys.length; i < l; i++) {
  4214. const key = keys[i];
  4215. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4216. }
  4217. }
  4218. } else {
  4219. ret = [];
  4220. }
  4221. if (cache) {
  4222. cache[index] = ret;
  4223. }
  4224. return ret;
  4225. }
  4226. function createSlots(slots, dynamicSlots) {
  4227. for (let i = 0; i < dynamicSlots.length; i++) {
  4228. const slot = dynamicSlots[i];
  4229. if (isArray(slot)) {
  4230. for (let j = 0; j < slot.length; j++) {
  4231. slots[slot[j].name] = slot[j].fn;
  4232. }
  4233. } else if (slot) {
  4234. slots[slot.name] = slot.key ? (...args) => {
  4235. const res = slot.fn(...args);
  4236. if (res)
  4237. res.key = slot.key;
  4238. return res;
  4239. } : slot.fn;
  4240. }
  4241. }
  4242. return slots;
  4243. }
  4244. function renderSlot(slots, name, props = {}, fallback, noSlotted) {
  4245. if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
  4246. if (name !== "default")
  4247. props.name = name;
  4248. return createVNode("slot", props, fallback && fallback());
  4249. }
  4250. let slot = slots[name];
  4251. if (slot && slot.length > 1) {
  4252. warn(
  4253. `SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
  4254. );
  4255. slot = () => [];
  4256. }
  4257. if (slot && slot._c) {
  4258. slot._d = false;
  4259. }
  4260. openBlock();
  4261. const validSlotContent = slot && ensureValidVNode(slot(props));
  4262. const rendered = createBlock(
  4263. Fragment,
  4264. {
  4265. key: props.key || // slot content array of a dynamic conditional slot may have a branch
  4266. // key attached in the `createSlots` helper, respect that
  4267. validSlotContent && validSlotContent.key || `_${name}`
  4268. },
  4269. validSlotContent || (fallback ? fallback() : []),
  4270. validSlotContent && slots._ === 1 ? 64 : -2
  4271. );
  4272. if (!noSlotted && rendered.scopeId) {
  4273. rendered.slotScopeIds = [rendered.scopeId + "-s"];
  4274. }
  4275. if (slot && slot._c) {
  4276. slot._d = true;
  4277. }
  4278. return rendered;
  4279. }
  4280. function ensureValidVNode(vnodes) {
  4281. return vnodes.some((child) => {
  4282. if (!isVNode(child))
  4283. return true;
  4284. if (child.type === Comment)
  4285. return false;
  4286. if (child.type === Fragment && !ensureValidVNode(child.children))
  4287. return false;
  4288. return true;
  4289. }) ? vnodes : null;
  4290. }
  4291. function toHandlers(obj, preserveCaseIfNecessary) {
  4292. const ret = {};
  4293. if (!isObject(obj)) {
  4294. warn(`v-on with no argument expects an object value.`);
  4295. return ret;
  4296. }
  4297. for (const key in obj) {
  4298. ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
  4299. }
  4300. return ret;
  4301. }
  4302. const getPublicInstance = (i) => {
  4303. if (!i)
  4304. return null;
  4305. if (isStatefulComponent(i))
  4306. return getExposeProxy(i) || i.proxy;
  4307. return getPublicInstance(i.parent);
  4308. };
  4309. const publicPropertiesMap = (
  4310. // Move PURE marker to new line to workaround compiler discarding it
  4311. // due to type annotation
  4312. /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
  4313. $: (i) => i,
  4314. $el: (i) => i.vnode.el,
  4315. $data: (i) => i.data,
  4316. $props: (i) => shallowReadonly(i.props) ,
  4317. $attrs: (i) => shallowReadonly(i.attrs) ,
  4318. $slots: (i) => shallowReadonly(i.slots) ,
  4319. $refs: (i) => shallowReadonly(i.refs) ,
  4320. $parent: (i) => getPublicInstance(i.parent),
  4321. $root: (i) => getPublicInstance(i.root),
  4322. $emit: (i) => i.emit,
  4323. $options: (i) => resolveMergedOptions(i) ,
  4324. $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
  4325. $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
  4326. $watch: (i) => instanceWatch.bind(i)
  4327. })
  4328. );
  4329. const isReservedPrefix = (key) => key === "_" || key === "$";
  4330. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  4331. const PublicInstanceProxyHandlers = {
  4332. get({ _: instance }, key) {
  4333. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4334. if (key === "__isVue") {
  4335. return true;
  4336. }
  4337. let normalizedProps;
  4338. if (key[0] !== "$") {
  4339. const n = accessCache[key];
  4340. if (n !== void 0) {
  4341. switch (n) {
  4342. case 1 /* SETUP */:
  4343. return setupState[key];
  4344. case 2 /* DATA */:
  4345. return data[key];
  4346. case 4 /* CONTEXT */:
  4347. return ctx[key];
  4348. case 3 /* PROPS */:
  4349. return props[key];
  4350. }
  4351. } else if (hasSetupBinding(setupState, key)) {
  4352. accessCache[key] = 1 /* SETUP */;
  4353. return setupState[key];
  4354. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4355. accessCache[key] = 2 /* DATA */;
  4356. return data[key];
  4357. } else if (
  4358. // only cache other properties when instance has declared (thus stable)
  4359. // props
  4360. (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
  4361. ) {
  4362. accessCache[key] = 3 /* PROPS */;
  4363. return props[key];
  4364. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4365. accessCache[key] = 4 /* CONTEXT */;
  4366. return ctx[key];
  4367. } else if (shouldCacheAccess) {
  4368. accessCache[key] = 0 /* OTHER */;
  4369. }
  4370. }
  4371. const publicGetter = publicPropertiesMap[key];
  4372. let cssModule, globalProperties;
  4373. if (publicGetter) {
  4374. if (key === "$attrs") {
  4375. track(instance, "get", key);
  4376. markAttrsAccessed();
  4377. } else if (key === "$slots") {
  4378. track(instance, "get", key);
  4379. }
  4380. return publicGetter(instance);
  4381. } else if (
  4382. // css module (injected by vue-loader)
  4383. (cssModule = type.__cssModules) && (cssModule = cssModule[key])
  4384. ) {
  4385. return cssModule;
  4386. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4387. accessCache[key] = 4 /* CONTEXT */;
  4388. return ctx[key];
  4389. } else if (
  4390. // global properties
  4391. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
  4392. ) {
  4393. {
  4394. return globalProperties[key];
  4395. }
  4396. } else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
  4397. // to infinite warning loop
  4398. key.indexOf("__v") !== 0)) {
  4399. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4400. warn(
  4401. `Property ${JSON.stringify(
  4402. key
  4403. )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
  4404. );
  4405. } else if (instance === currentRenderingInstance) {
  4406. warn(
  4407. `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
  4408. );
  4409. }
  4410. }
  4411. },
  4412. set({ _: instance }, key, value) {
  4413. const { data, setupState, ctx } = instance;
  4414. if (hasSetupBinding(setupState, key)) {
  4415. setupState[key] = value;
  4416. return true;
  4417. } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
  4418. warn(`Cannot mutate <script setup> binding "${key}" from Options API.`);
  4419. return false;
  4420. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4421. data[key] = value;
  4422. return true;
  4423. } else if (hasOwn(instance.props, key)) {
  4424. warn(`Attempting to mutate prop "${key}". Props are readonly.`);
  4425. return false;
  4426. }
  4427. if (key[0] === "$" && key.slice(1) in instance) {
  4428. warn(
  4429. `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
  4430. );
  4431. return false;
  4432. } else {
  4433. if (key in instance.appContext.config.globalProperties) {
  4434. Object.defineProperty(ctx, key, {
  4435. enumerable: true,
  4436. configurable: true,
  4437. value
  4438. });
  4439. } else {
  4440. ctx[key] = value;
  4441. }
  4442. }
  4443. return true;
  4444. },
  4445. has({
  4446. _: { data, setupState, accessCache, ctx, appContext, propsOptions }
  4447. }, key) {
  4448. let normalizedProps;
  4449. return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
  4450. },
  4451. defineProperty(target, key, descriptor) {
  4452. if (descriptor.get != null) {
  4453. target._.accessCache[key] = 0;
  4454. } else if (hasOwn(descriptor, "value")) {
  4455. this.set(target, key, descriptor.value, null);
  4456. }
  4457. return Reflect.defineProperty(target, key, descriptor);
  4458. }
  4459. };
  4460. {
  4461. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4462. warn(
  4463. `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
  4464. );
  4465. return Reflect.ownKeys(target);
  4466. };
  4467. }
  4468. const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend(
  4469. {},
  4470. PublicInstanceProxyHandlers,
  4471. {
  4472. get(target, key) {
  4473. if (key === Symbol.unscopables) {
  4474. return;
  4475. }
  4476. return PublicInstanceProxyHandlers.get(target, key, target);
  4477. },
  4478. has(_, key) {
  4479. const has = key[0] !== "_" && !isGloballyAllowed(key);
  4480. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4481. warn(
  4482. `Property ${JSON.stringify(
  4483. key
  4484. )} should not start with _ which is a reserved prefix for Vue internals.`
  4485. );
  4486. }
  4487. return has;
  4488. }
  4489. }
  4490. );
  4491. function createDevRenderContext(instance) {
  4492. const target = {};
  4493. Object.defineProperty(target, `_`, {
  4494. configurable: true,
  4495. enumerable: false,
  4496. get: () => instance
  4497. });
  4498. Object.keys(publicPropertiesMap).forEach((key) => {
  4499. Object.defineProperty(target, key, {
  4500. configurable: true,
  4501. enumerable: false,
  4502. get: () => publicPropertiesMap[key](instance),
  4503. // intercepted by the proxy so no need for implementation,
  4504. // but needed to prevent set errors
  4505. set: NOOP
  4506. });
  4507. });
  4508. return target;
  4509. }
  4510. function exposePropsOnRenderContext(instance) {
  4511. const {
  4512. ctx,
  4513. propsOptions: [propsOptions]
  4514. } = instance;
  4515. if (propsOptions) {
  4516. Object.keys(propsOptions).forEach((key) => {
  4517. Object.defineProperty(ctx, key, {
  4518. enumerable: true,
  4519. configurable: true,
  4520. get: () => instance.props[key],
  4521. set: NOOP
  4522. });
  4523. });
  4524. }
  4525. }
  4526. function exposeSetupStateOnRenderContext(instance) {
  4527. const { ctx, setupState } = instance;
  4528. Object.keys(toRaw(setupState)).forEach((key) => {
  4529. if (!setupState.__isScriptSetup) {
  4530. if (isReservedPrefix(key[0])) {
  4531. warn(
  4532. `setup() return property ${JSON.stringify(
  4533. key
  4534. )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
  4535. );
  4536. return;
  4537. }
  4538. Object.defineProperty(ctx, key, {
  4539. enumerable: true,
  4540. configurable: true,
  4541. get: () => setupState[key],
  4542. set: NOOP
  4543. });
  4544. }
  4545. });
  4546. }
  4547. const warnRuntimeUsage = (method) => warn(
  4548. `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
  4549. );
  4550. function defineProps() {
  4551. {
  4552. warnRuntimeUsage(`defineProps`);
  4553. }
  4554. return null;
  4555. }
  4556. function defineEmits() {
  4557. {
  4558. warnRuntimeUsage(`defineEmits`);
  4559. }
  4560. return null;
  4561. }
  4562. function defineExpose(exposed) {
  4563. {
  4564. warnRuntimeUsage(`defineExpose`);
  4565. }
  4566. }
  4567. function defineOptions(options) {
  4568. {
  4569. warnRuntimeUsage(`defineOptions`);
  4570. }
  4571. }
  4572. function defineSlots() {
  4573. {
  4574. warnRuntimeUsage(`defineSlots`);
  4575. }
  4576. return null;
  4577. }
  4578. function defineModel() {
  4579. {
  4580. warnRuntimeUsage("defineModel");
  4581. }
  4582. }
  4583. function withDefaults(props, defaults) {
  4584. {
  4585. warnRuntimeUsage(`withDefaults`);
  4586. }
  4587. return null;
  4588. }
  4589. function useSlots() {
  4590. return getContext().slots;
  4591. }
  4592. function useAttrs() {
  4593. return getContext().attrs;
  4594. }
  4595. function useModel(props, name, options) {
  4596. const i = getCurrentInstance();
  4597. if (!i) {
  4598. warn(`useModel() called without active instance.`);
  4599. return ref();
  4600. }
  4601. if (!i.propsOptions[0][name]) {
  4602. warn(`useModel() called with prop "${name}" which is not declared.`);
  4603. return ref();
  4604. }
  4605. if (options && options.local) {
  4606. const proxy = ref(props[name]);
  4607. watch(
  4608. () => props[name],
  4609. (v) => proxy.value = v
  4610. );
  4611. watch(proxy, (value) => {
  4612. if (value !== props[name]) {
  4613. i.emit(`update:${name}`, value);
  4614. }
  4615. });
  4616. return proxy;
  4617. } else {
  4618. return {
  4619. __v_isRef: true,
  4620. get value() {
  4621. return props[name];
  4622. },
  4623. set value(value) {
  4624. i.emit(`update:${name}`, value);
  4625. }
  4626. };
  4627. }
  4628. }
  4629. function getContext() {
  4630. const i = getCurrentInstance();
  4631. if (!i) {
  4632. warn(`useContext() called without active instance.`);
  4633. }
  4634. return i.setupContext || (i.setupContext = createSetupContext(i));
  4635. }
  4636. function normalizePropsOrEmits(props) {
  4637. return isArray(props) ? props.reduce(
  4638. (normalized, p) => (normalized[p] = null, normalized),
  4639. {}
  4640. ) : props;
  4641. }
  4642. function mergeDefaults(raw, defaults) {
  4643. const props = normalizePropsOrEmits(raw);
  4644. for (const key in defaults) {
  4645. if (key.startsWith("__skip"))
  4646. continue;
  4647. let opt = props[key];
  4648. if (opt) {
  4649. if (isArray(opt) || isFunction(opt)) {
  4650. opt = props[key] = { type: opt, default: defaults[key] };
  4651. } else {
  4652. opt.default = defaults[key];
  4653. }
  4654. } else if (opt === null) {
  4655. opt = props[key] = { default: defaults[key] };
  4656. } else {
  4657. warn(`props default key "${key}" has no corresponding declaration.`);
  4658. }
  4659. if (opt && defaults[`__skip_${key}`]) {
  4660. opt.skipFactory = true;
  4661. }
  4662. }
  4663. return props;
  4664. }
  4665. function mergeModels(a, b) {
  4666. if (!a || !b)
  4667. return a || b;
  4668. if (isArray(a) && isArray(b))
  4669. return a.concat(b);
  4670. return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
  4671. }
  4672. function createPropsRestProxy(props, excludedKeys) {
  4673. const ret = {};
  4674. for (const key in props) {
  4675. if (!excludedKeys.includes(key)) {
  4676. Object.defineProperty(ret, key, {
  4677. enumerable: true,
  4678. get: () => props[key]
  4679. });
  4680. }
  4681. }
  4682. return ret;
  4683. }
  4684. function withAsyncContext(getAwaitable) {
  4685. const ctx = getCurrentInstance();
  4686. if (!ctx) {
  4687. warn(
  4688. `withAsyncContext called without active current instance. This is likely a bug.`
  4689. );
  4690. }
  4691. let awaitable = getAwaitable();
  4692. unsetCurrentInstance();
  4693. if (isPromise(awaitable)) {
  4694. awaitable = awaitable.catch((e) => {
  4695. setCurrentInstance(ctx);
  4696. throw e;
  4697. });
  4698. }
  4699. return [awaitable, () => setCurrentInstance(ctx)];
  4700. }
  4701. function createDuplicateChecker() {
  4702. const cache = /* @__PURE__ */ Object.create(null);
  4703. return (type, key) => {
  4704. if (cache[key]) {
  4705. warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4706. } else {
  4707. cache[key] = type;
  4708. }
  4709. };
  4710. }
  4711. let shouldCacheAccess = true;
  4712. function applyOptions(instance) {
  4713. const options = resolveMergedOptions(instance);
  4714. const publicThis = instance.proxy;
  4715. const ctx = instance.ctx;
  4716. shouldCacheAccess = false;
  4717. if (options.beforeCreate) {
  4718. callHook$1(options.beforeCreate, instance, "bc");
  4719. }
  4720. const {
  4721. // state
  4722. data: dataOptions,
  4723. computed: computedOptions,
  4724. methods,
  4725. watch: watchOptions,
  4726. provide: provideOptions,
  4727. inject: injectOptions,
  4728. // lifecycle
  4729. created,
  4730. beforeMount,
  4731. mounted,
  4732. beforeUpdate,
  4733. updated,
  4734. activated,
  4735. deactivated,
  4736. beforeDestroy,
  4737. beforeUnmount,
  4738. destroyed,
  4739. unmounted,
  4740. render,
  4741. renderTracked,
  4742. renderTriggered,
  4743. errorCaptured,
  4744. serverPrefetch,
  4745. // public API
  4746. expose,
  4747. inheritAttrs,
  4748. // assets
  4749. components,
  4750. directives,
  4751. filters
  4752. } = options;
  4753. const checkDuplicateProperties = createDuplicateChecker() ;
  4754. {
  4755. const [propsOptions] = instance.propsOptions;
  4756. if (propsOptions) {
  4757. for (const key in propsOptions) {
  4758. checkDuplicateProperties("Props" /* PROPS */, key);
  4759. }
  4760. }
  4761. }
  4762. if (injectOptions) {
  4763. resolveInjections(injectOptions, ctx, checkDuplicateProperties);
  4764. }
  4765. if (methods) {
  4766. for (const key in methods) {
  4767. const methodHandler = methods[key];
  4768. if (isFunction(methodHandler)) {
  4769. {
  4770. Object.defineProperty(ctx, key, {
  4771. value: methodHandler.bind(publicThis),
  4772. configurable: true,
  4773. enumerable: true,
  4774. writable: true
  4775. });
  4776. }
  4777. {
  4778. checkDuplicateProperties("Methods" /* METHODS */, key);
  4779. }
  4780. } else {
  4781. warn(
  4782. `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
  4783. );
  4784. }
  4785. }
  4786. }
  4787. if (dataOptions) {
  4788. if (!isFunction(dataOptions)) {
  4789. warn(
  4790. `The data option must be a function. Plain object usage is no longer supported.`
  4791. );
  4792. }
  4793. const data = dataOptions.call(publicThis, publicThis);
  4794. if (isPromise(data)) {
  4795. warn(
  4796. `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
  4797. );
  4798. }
  4799. if (!isObject(data)) {
  4800. warn(`data() should return an object.`);
  4801. } else {
  4802. instance.data = reactive(data);
  4803. {
  4804. for (const key in data) {
  4805. checkDuplicateProperties("Data" /* DATA */, key);
  4806. if (!isReservedPrefix(key[0])) {
  4807. Object.defineProperty(ctx, key, {
  4808. configurable: true,
  4809. enumerable: true,
  4810. get: () => data[key],
  4811. set: NOOP
  4812. });
  4813. }
  4814. }
  4815. }
  4816. }
  4817. }
  4818. shouldCacheAccess = true;
  4819. if (computedOptions) {
  4820. for (const key in computedOptions) {
  4821. const opt = computedOptions[key];
  4822. const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
  4823. if (get === NOOP) {
  4824. warn(`Computed property "${key}" has no getter.`);
  4825. }
  4826. const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
  4827. warn(
  4828. `Write operation failed: computed property "${key}" is readonly.`
  4829. );
  4830. } ;
  4831. const c = computed({
  4832. get,
  4833. set
  4834. });
  4835. Object.defineProperty(ctx, key, {
  4836. enumerable: true,
  4837. configurable: true,
  4838. get: () => c.value,
  4839. set: (v) => c.value = v
  4840. });
  4841. {
  4842. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  4843. }
  4844. }
  4845. }
  4846. if (watchOptions) {
  4847. for (const key in watchOptions) {
  4848. createWatcher(watchOptions[key], ctx, publicThis, key);
  4849. }
  4850. }
  4851. if (provideOptions) {
  4852. const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
  4853. Reflect.ownKeys(provides).forEach((key) => {
  4854. provide(key, provides[key]);
  4855. });
  4856. }
  4857. if (created) {
  4858. callHook$1(created, instance, "c");
  4859. }
  4860. function registerLifecycleHook(register, hook) {
  4861. if (isArray(hook)) {
  4862. hook.forEach((_hook) => register(_hook.bind(publicThis)));
  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. } else if (!instance.exposed) {
  4889. instance.exposed = {};
  4890. }
  4891. }
  4892. if (render && instance.render === NOOP) {
  4893. instance.render = render;
  4894. }
  4895. if (inheritAttrs != null) {
  4896. instance.inheritAttrs = inheritAttrs;
  4897. }
  4898. if (components)
  4899. instance.components = components;
  4900. if (directives)
  4901. instance.directives = directives;
  4902. }
  4903. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
  4904. if (isArray(injectOptions)) {
  4905. injectOptions = normalizeInject(injectOptions);
  4906. }
  4907. for (const key in injectOptions) {
  4908. const opt = injectOptions[key];
  4909. let injected;
  4910. if (isObject(opt)) {
  4911. if ("default" in opt) {
  4912. injected = inject(
  4913. opt.from || key,
  4914. opt.default,
  4915. true
  4916. /* treat default function as factory */
  4917. );
  4918. } else {
  4919. injected = inject(opt.from || key);
  4920. }
  4921. } else {
  4922. injected = inject(opt);
  4923. }
  4924. if (isRef(injected)) {
  4925. Object.defineProperty(ctx, key, {
  4926. enumerable: true,
  4927. configurable: true,
  4928. get: () => injected.value,
  4929. set: (v) => injected.value = v
  4930. });
  4931. } else {
  4932. ctx[key] = injected;
  4933. }
  4934. {
  4935. checkDuplicateProperties("Inject" /* INJECT */, key);
  4936. }
  4937. }
  4938. }
  4939. function callHook$1(hook, instance, type) {
  4940. callWithAsyncErrorHandling(
  4941. isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
  4942. instance,
  4943. type
  4944. );
  4945. }
  4946. function createWatcher(raw, ctx, publicThis, key) {
  4947. const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
  4948. if (isString(raw)) {
  4949. const handler = ctx[raw];
  4950. if (isFunction(handler)) {
  4951. watch(getter, handler);
  4952. } else {
  4953. warn(`Invalid watch handler specified by key "${raw}"`, handler);
  4954. }
  4955. } else if (isFunction(raw)) {
  4956. watch(getter, raw.bind(publicThis));
  4957. } else if (isObject(raw)) {
  4958. if (isArray(raw)) {
  4959. raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
  4960. } else {
  4961. const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
  4962. if (isFunction(handler)) {
  4963. watch(getter, handler, raw);
  4964. } else {
  4965. warn(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  4966. }
  4967. }
  4968. } else {
  4969. warn(`Invalid watch option: "${key}"`, raw);
  4970. }
  4971. }
  4972. function resolveMergedOptions(instance) {
  4973. const base = instance.type;
  4974. const { mixins, extends: extendsOptions } = base;
  4975. const {
  4976. mixins: globalMixins,
  4977. optionsCache: cache,
  4978. config: { optionMergeStrategies }
  4979. } = instance.appContext;
  4980. const cached = cache.get(base);
  4981. let resolved;
  4982. if (cached) {
  4983. resolved = cached;
  4984. } else if (!globalMixins.length && !mixins && !extendsOptions) {
  4985. {
  4986. resolved = base;
  4987. }
  4988. } else {
  4989. resolved = {};
  4990. if (globalMixins.length) {
  4991. globalMixins.forEach(
  4992. (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
  4993. );
  4994. }
  4995. mergeOptions(resolved, base, optionMergeStrategies);
  4996. }
  4997. if (isObject(base)) {
  4998. cache.set(base, resolved);
  4999. }
  5000. return resolved;
  5001. }
  5002. function mergeOptions(to, from, strats, asMixin = false) {
  5003. const { mixins, extends: extendsOptions } = from;
  5004. if (extendsOptions) {
  5005. mergeOptions(to, extendsOptions, strats, true);
  5006. }
  5007. if (mixins) {
  5008. mixins.forEach(
  5009. (m) => mergeOptions(to, m, strats, true)
  5010. );
  5011. }
  5012. for (const key in from) {
  5013. if (asMixin && key === "expose") {
  5014. warn(
  5015. `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
  5016. );
  5017. } else {
  5018. const strat = internalOptionMergeStrats[key] || strats && strats[key];
  5019. to[key] = strat ? strat(to[key], from[key]) : from[key];
  5020. }
  5021. }
  5022. return to;
  5023. }
  5024. const internalOptionMergeStrats = {
  5025. data: mergeDataFn,
  5026. props: mergeEmitsOrPropsOptions,
  5027. emits: mergeEmitsOrPropsOptions,
  5028. // objects
  5029. methods: mergeObjectOptions,
  5030. computed: mergeObjectOptions,
  5031. // lifecycle
  5032. beforeCreate: mergeAsArray$1,
  5033. created: mergeAsArray$1,
  5034. beforeMount: mergeAsArray$1,
  5035. mounted: mergeAsArray$1,
  5036. beforeUpdate: mergeAsArray$1,
  5037. updated: mergeAsArray$1,
  5038. beforeDestroy: mergeAsArray$1,
  5039. beforeUnmount: mergeAsArray$1,
  5040. destroyed: mergeAsArray$1,
  5041. unmounted: mergeAsArray$1,
  5042. activated: mergeAsArray$1,
  5043. deactivated: mergeAsArray$1,
  5044. errorCaptured: mergeAsArray$1,
  5045. serverPrefetch: mergeAsArray$1,
  5046. // assets
  5047. components: mergeObjectOptions,
  5048. directives: mergeObjectOptions,
  5049. // watch
  5050. watch: mergeWatchOptions,
  5051. // provide / inject
  5052. provide: mergeDataFn,
  5053. inject: mergeInject
  5054. };
  5055. function mergeDataFn(to, from) {
  5056. if (!from) {
  5057. return to;
  5058. }
  5059. if (!to) {
  5060. return from;
  5061. }
  5062. return function mergedDataFn() {
  5063. return (extend)(
  5064. isFunction(to) ? to.call(this, this) : to,
  5065. isFunction(from) ? from.call(this, this) : from
  5066. );
  5067. };
  5068. }
  5069. function mergeInject(to, from) {
  5070. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5071. }
  5072. function normalizeInject(raw) {
  5073. if (isArray(raw)) {
  5074. const res = {};
  5075. for (let i = 0; i < raw.length; i++) {
  5076. res[raw[i]] = raw[i];
  5077. }
  5078. return res;
  5079. }
  5080. return raw;
  5081. }
  5082. function mergeAsArray$1(to, from) {
  5083. return to ? [...new Set([].concat(to, from))] : from;
  5084. }
  5085. function mergeObjectOptions(to, from) {
  5086. return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
  5087. }
  5088. function mergeEmitsOrPropsOptions(to, from) {
  5089. if (to) {
  5090. if (isArray(to) && isArray(from)) {
  5091. return [.../* @__PURE__ */ new Set([...to, ...from])];
  5092. }
  5093. return extend(
  5094. /* @__PURE__ */ Object.create(null),
  5095. normalizePropsOrEmits(to),
  5096. normalizePropsOrEmits(from != null ? from : {})
  5097. );
  5098. } else {
  5099. return from;
  5100. }
  5101. }
  5102. function mergeWatchOptions(to, from) {
  5103. if (!to)
  5104. return from;
  5105. if (!from)
  5106. return to;
  5107. const merged = extend(/* @__PURE__ */ Object.create(null), to);
  5108. for (const key in from) {
  5109. merged[key] = mergeAsArray$1(to[key], from[key]);
  5110. }
  5111. return merged;
  5112. }
  5113. function createAppContext() {
  5114. return {
  5115. app: null,
  5116. config: {
  5117. isNativeTag: NO,
  5118. performance: false,
  5119. globalProperties: {},
  5120. optionMergeStrategies: {},
  5121. errorHandler: void 0,
  5122. warnHandler: void 0,
  5123. compilerOptions: {}
  5124. },
  5125. mixins: [],
  5126. components: {},
  5127. directives: {},
  5128. provides: /* @__PURE__ */ Object.create(null),
  5129. optionsCache: /* @__PURE__ */ new WeakMap(),
  5130. propsCache: /* @__PURE__ */ new WeakMap(),
  5131. emitsCache: /* @__PURE__ */ new WeakMap()
  5132. };
  5133. }
  5134. let uid$1 = 0;
  5135. function createAppAPI(render, hydrate) {
  5136. return function createApp(rootComponent, rootProps = null) {
  5137. if (!isFunction(rootComponent)) {
  5138. rootComponent = extend({}, rootComponent);
  5139. }
  5140. if (rootProps != null && !isObject(rootProps)) {
  5141. warn(`root props passed to app.mount() must be an object.`);
  5142. rootProps = null;
  5143. }
  5144. const context = createAppContext();
  5145. {
  5146. Object.defineProperty(context.config, "unwrapInjectedRef", {
  5147. get() {
  5148. return true;
  5149. },
  5150. set() {
  5151. warn(
  5152. `app.config.unwrapInjectedRef has been deprecated. 3.3 now always unwraps injected refs in Options API.`
  5153. );
  5154. }
  5155. });
  5156. }
  5157. const installedPlugins = /* @__PURE__ */ new WeakSet();
  5158. let isMounted = false;
  5159. const app = context.app = {
  5160. _uid: uid$1++,
  5161. _component: rootComponent,
  5162. _props: rootProps,
  5163. _container: null,
  5164. _context: context,
  5165. _instance: null,
  5166. version,
  5167. get config() {
  5168. return context.config;
  5169. },
  5170. set config(v) {
  5171. {
  5172. warn(
  5173. `app.config cannot be replaced. Modify individual options instead.`
  5174. );
  5175. }
  5176. },
  5177. use(plugin, ...options) {
  5178. if (installedPlugins.has(plugin)) {
  5179. warn(`Plugin has already been applied to target app.`);
  5180. } else if (plugin && isFunction(plugin.install)) {
  5181. installedPlugins.add(plugin);
  5182. plugin.install(app, ...options);
  5183. } else if (isFunction(plugin)) {
  5184. installedPlugins.add(plugin);
  5185. plugin(app, ...options);
  5186. } else {
  5187. warn(
  5188. `A plugin must either be a function or an object with an "install" function.`
  5189. );
  5190. }
  5191. return app;
  5192. },
  5193. mixin(mixin) {
  5194. {
  5195. if (!context.mixins.includes(mixin)) {
  5196. context.mixins.push(mixin);
  5197. } else {
  5198. warn(
  5199. "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
  5200. );
  5201. }
  5202. }
  5203. return app;
  5204. },
  5205. component(name, component) {
  5206. {
  5207. validateComponentName(name, context.config);
  5208. }
  5209. if (!component) {
  5210. return context.components[name];
  5211. }
  5212. if (context.components[name]) {
  5213. warn(`Component "${name}" has already been registered in target app.`);
  5214. }
  5215. context.components[name] = component;
  5216. return app;
  5217. },
  5218. directive(name, directive) {
  5219. {
  5220. validateDirectiveName(name);
  5221. }
  5222. if (!directive) {
  5223. return context.directives[name];
  5224. }
  5225. if (context.directives[name]) {
  5226. warn(`Directive "${name}" has already been registered in target app.`);
  5227. }
  5228. context.directives[name] = directive;
  5229. return app;
  5230. },
  5231. mount(rootContainer, isHydrate, isSVG) {
  5232. if (!isMounted) {
  5233. if (rootContainer.__vue_app__) {
  5234. warn(
  5235. `There is already an app instance mounted on the host container.
  5236. If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
  5237. );
  5238. }
  5239. const vnode = createVNode(rootComponent, rootProps);
  5240. vnode.appContext = context;
  5241. {
  5242. context.reload = () => {
  5243. render(cloneVNode(vnode), rootContainer, isSVG);
  5244. };
  5245. }
  5246. if (isHydrate && hydrate) {
  5247. hydrate(vnode, rootContainer);
  5248. } else {
  5249. render(vnode, rootContainer, isSVG);
  5250. }
  5251. isMounted = true;
  5252. app._container = rootContainer;
  5253. rootContainer.__vue_app__ = app;
  5254. {
  5255. app._instance = vnode.component;
  5256. devtoolsInitApp(app, version);
  5257. }
  5258. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5259. } else {
  5260. warn(
  5261. `App has already been mounted.
  5262. If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
  5263. );
  5264. }
  5265. },
  5266. unmount() {
  5267. if (isMounted) {
  5268. render(null, app._container);
  5269. {
  5270. app._instance = null;
  5271. devtoolsUnmountApp(app);
  5272. }
  5273. delete app._container.__vue_app__;
  5274. } else {
  5275. warn(`Cannot unmount an app that is not mounted.`);
  5276. }
  5277. },
  5278. provide(key, value) {
  5279. if (key in context.provides) {
  5280. warn(
  5281. `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
  5282. );
  5283. }
  5284. context.provides[key] = value;
  5285. return app;
  5286. },
  5287. runWithContext(fn) {
  5288. currentApp = app;
  5289. try {
  5290. return fn();
  5291. } finally {
  5292. currentApp = null;
  5293. }
  5294. }
  5295. };
  5296. return app;
  5297. };
  5298. }
  5299. let currentApp = null;
  5300. function provide(key, value) {
  5301. if (!currentInstance) {
  5302. {
  5303. warn(`provide() can only be used inside setup().`);
  5304. }
  5305. } else {
  5306. let provides = currentInstance.provides;
  5307. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  5308. if (parentProvides === provides) {
  5309. provides = currentInstance.provides = Object.create(parentProvides);
  5310. }
  5311. provides[key] = value;
  5312. }
  5313. }
  5314. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  5315. const instance = currentInstance || currentRenderingInstance;
  5316. if (instance || currentApp) {
  5317. const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
  5318. if (provides && key in provides) {
  5319. return provides[key];
  5320. } else if (arguments.length > 1) {
  5321. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
  5322. } else {
  5323. warn(`injection "${String(key)}" not found.`);
  5324. }
  5325. } else {
  5326. warn(`inject() can only be used inside setup() or functional components.`);
  5327. }
  5328. }
  5329. function hasInjectionContext() {
  5330. return !!(currentInstance || currentRenderingInstance || currentApp);
  5331. }
  5332. function initProps(instance, rawProps, isStateful, isSSR = false) {
  5333. const props = {};
  5334. const attrs = {};
  5335. def(attrs, InternalObjectKey, 1);
  5336. instance.propsDefaults = /* @__PURE__ */ Object.create(null);
  5337. setFullProps(instance, rawProps, props, attrs);
  5338. for (const key in instance.propsOptions[0]) {
  5339. if (!(key in props)) {
  5340. props[key] = void 0;
  5341. }
  5342. }
  5343. {
  5344. validateProps(rawProps || {}, props, instance);
  5345. }
  5346. if (isStateful) {
  5347. instance.props = isSSR ? props : shallowReactive(props);
  5348. } else {
  5349. if (!instance.type.props) {
  5350. instance.props = attrs;
  5351. } else {
  5352. instance.props = props;
  5353. }
  5354. }
  5355. instance.attrs = attrs;
  5356. }
  5357. function isInHmrContext(instance) {
  5358. while (instance) {
  5359. if (instance.type.__hmrId)
  5360. return true;
  5361. instance = instance.parent;
  5362. }
  5363. }
  5364. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5365. const {
  5366. props,
  5367. attrs,
  5368. vnode: { patchFlag }
  5369. } = instance;
  5370. const rawCurrentProps = toRaw(props);
  5371. const [options] = instance.propsOptions;
  5372. let hasAttrsChanged = false;
  5373. if (
  5374. // always force full diff in dev
  5375. // - #1942 if hmr is enabled with sfc component
  5376. // - vite#872 non-sfc component used by sfc component
  5377. !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
  5378. ) {
  5379. if (patchFlag & 8) {
  5380. const propsToUpdate = instance.vnode.dynamicProps;
  5381. for (let i = 0; i < propsToUpdate.length; i++) {
  5382. let key = propsToUpdate[i];
  5383. if (isEmitListener(instance.emitsOptions, key)) {
  5384. continue;
  5385. }
  5386. const value = rawProps[key];
  5387. if (options) {
  5388. if (hasOwn(attrs, key)) {
  5389. if (value !== attrs[key]) {
  5390. attrs[key] = value;
  5391. hasAttrsChanged = true;
  5392. }
  5393. } else {
  5394. const camelizedKey = camelize(key);
  5395. props[camelizedKey] = resolvePropValue(
  5396. options,
  5397. rawCurrentProps,
  5398. camelizedKey,
  5399. value,
  5400. instance,
  5401. false
  5402. /* isAbsent */
  5403. );
  5404. }
  5405. } else {
  5406. if (value !== attrs[key]) {
  5407. attrs[key] = value;
  5408. hasAttrsChanged = true;
  5409. }
  5410. }
  5411. }
  5412. }
  5413. } else {
  5414. if (setFullProps(instance, rawProps, props, attrs)) {
  5415. hasAttrsChanged = true;
  5416. }
  5417. let kebabKey;
  5418. for (const key in rawCurrentProps) {
  5419. if (!rawProps || // for camelCase
  5420. !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
  5421. // and converted to camelCase (#955)
  5422. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
  5423. if (options) {
  5424. if (rawPrevProps && // for camelCase
  5425. (rawPrevProps[key] !== void 0 || // for kebab-case
  5426. rawPrevProps[kebabKey] !== void 0)) {
  5427. props[key] = resolvePropValue(
  5428. options,
  5429. rawCurrentProps,
  5430. key,
  5431. void 0,
  5432. instance,
  5433. true
  5434. /* isAbsent */
  5435. );
  5436. }
  5437. } else {
  5438. delete props[key];
  5439. }
  5440. }
  5441. }
  5442. if (attrs !== rawCurrentProps) {
  5443. for (const key in attrs) {
  5444. if (!rawProps || !hasOwn(rawProps, key) && true) {
  5445. delete attrs[key];
  5446. hasAttrsChanged = true;
  5447. }
  5448. }
  5449. }
  5450. }
  5451. if (hasAttrsChanged) {
  5452. trigger(instance, "set", "$attrs");
  5453. }
  5454. {
  5455. validateProps(rawProps || {}, props, instance);
  5456. }
  5457. }
  5458. function setFullProps(instance, rawProps, props, attrs) {
  5459. const [options, needCastKeys] = instance.propsOptions;
  5460. let hasAttrsChanged = false;
  5461. let rawCastValues;
  5462. if (rawProps) {
  5463. for (let key in rawProps) {
  5464. if (isReservedProp(key)) {
  5465. continue;
  5466. }
  5467. const value = rawProps[key];
  5468. let camelKey;
  5469. if (options && hasOwn(options, camelKey = camelize(key))) {
  5470. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5471. props[camelKey] = value;
  5472. } else {
  5473. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5474. }
  5475. } else if (!isEmitListener(instance.emitsOptions, key)) {
  5476. if (!(key in attrs) || value !== attrs[key]) {
  5477. attrs[key] = value;
  5478. hasAttrsChanged = true;
  5479. }
  5480. }
  5481. }
  5482. }
  5483. if (needCastKeys) {
  5484. const rawCurrentProps = toRaw(props);
  5485. const castValues = rawCastValues || EMPTY_OBJ;
  5486. for (let i = 0; i < needCastKeys.length; i++) {
  5487. const key = needCastKeys[i];
  5488. props[key] = resolvePropValue(
  5489. options,
  5490. rawCurrentProps,
  5491. key,
  5492. castValues[key],
  5493. instance,
  5494. !hasOwn(castValues, key)
  5495. );
  5496. }
  5497. }
  5498. return hasAttrsChanged;
  5499. }
  5500. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5501. const opt = options[key];
  5502. if (opt != null) {
  5503. const hasDefault = hasOwn(opt, "default");
  5504. if (hasDefault && value === void 0) {
  5505. const defaultValue = opt.default;
  5506. if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
  5507. const { propsDefaults } = instance;
  5508. if (key in propsDefaults) {
  5509. value = propsDefaults[key];
  5510. } else {
  5511. setCurrentInstance(instance);
  5512. value = propsDefaults[key] = defaultValue.call(
  5513. null,
  5514. props
  5515. );
  5516. unsetCurrentInstance();
  5517. }
  5518. } else {
  5519. value = defaultValue;
  5520. }
  5521. }
  5522. if (opt[0 /* shouldCast */]) {
  5523. if (isAbsent && !hasDefault) {
  5524. value = false;
  5525. } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
  5526. value = true;
  5527. }
  5528. }
  5529. }
  5530. return value;
  5531. }
  5532. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5533. const cache = appContext.propsCache;
  5534. const cached = cache.get(comp);
  5535. if (cached) {
  5536. return cached;
  5537. }
  5538. const raw = comp.props;
  5539. const normalized = {};
  5540. const needCastKeys = [];
  5541. let hasExtends = false;
  5542. if (!isFunction(comp)) {
  5543. const extendProps = (raw2) => {
  5544. hasExtends = true;
  5545. const [props, keys] = normalizePropsOptions(raw2, appContext, true);
  5546. extend(normalized, props);
  5547. if (keys)
  5548. needCastKeys.push(...keys);
  5549. };
  5550. if (!asMixin && appContext.mixins.length) {
  5551. appContext.mixins.forEach(extendProps);
  5552. }
  5553. if (comp.extends) {
  5554. extendProps(comp.extends);
  5555. }
  5556. if (comp.mixins) {
  5557. comp.mixins.forEach(extendProps);
  5558. }
  5559. }
  5560. if (!raw && !hasExtends) {
  5561. if (isObject(comp)) {
  5562. cache.set(comp, EMPTY_ARR);
  5563. }
  5564. return EMPTY_ARR;
  5565. }
  5566. if (isArray(raw)) {
  5567. for (let i = 0; i < raw.length; i++) {
  5568. if (!isString(raw[i])) {
  5569. warn(`props must be strings when using array syntax.`, raw[i]);
  5570. }
  5571. const normalizedKey = camelize(raw[i]);
  5572. if (validatePropName(normalizedKey)) {
  5573. normalized[normalizedKey] = EMPTY_OBJ;
  5574. }
  5575. }
  5576. } else if (raw) {
  5577. if (!isObject(raw)) {
  5578. warn(`invalid props options`, raw);
  5579. }
  5580. for (const key in raw) {
  5581. const normalizedKey = camelize(key);
  5582. if (validatePropName(normalizedKey)) {
  5583. const opt = raw[key];
  5584. const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
  5585. if (prop) {
  5586. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5587. const stringIndex = getTypeIndex(String, prop.type);
  5588. prop[0 /* shouldCast */] = booleanIndex > -1;
  5589. prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
  5590. if (booleanIndex > -1 || hasOwn(prop, "default")) {
  5591. needCastKeys.push(normalizedKey);
  5592. }
  5593. }
  5594. }
  5595. }
  5596. }
  5597. const res = [normalized, needCastKeys];
  5598. if (isObject(comp)) {
  5599. cache.set(comp, res);
  5600. }
  5601. return res;
  5602. }
  5603. function validatePropName(key) {
  5604. if (key[0] !== "$") {
  5605. return true;
  5606. } else {
  5607. warn(`Invalid prop name: "${key}" is a reserved property.`);
  5608. }
  5609. return false;
  5610. }
  5611. function getType(ctor) {
  5612. const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
  5613. return match ? match[2] : ctor === null ? "null" : "";
  5614. }
  5615. function isSameType(a, b) {
  5616. return getType(a) === getType(b);
  5617. }
  5618. function getTypeIndex(type, expectedTypes) {
  5619. if (isArray(expectedTypes)) {
  5620. return expectedTypes.findIndex((t) => isSameType(t, type));
  5621. } else if (isFunction(expectedTypes)) {
  5622. return isSameType(expectedTypes, type) ? 0 : -1;
  5623. }
  5624. return -1;
  5625. }
  5626. function validateProps(rawProps, props, instance) {
  5627. const resolvedValues = toRaw(props);
  5628. const options = instance.propsOptions[0];
  5629. for (const key in options) {
  5630. let opt = options[key];
  5631. if (opt == null)
  5632. continue;
  5633. validateProp(
  5634. key,
  5635. resolvedValues[key],
  5636. opt,
  5637. !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
  5638. );
  5639. }
  5640. }
  5641. function validateProp(name, value, prop, isAbsent) {
  5642. const { type, required, validator, skipCheck } = prop;
  5643. if (required && isAbsent) {
  5644. warn('Missing required prop: "' + name + '"');
  5645. return;
  5646. }
  5647. if (value == null && !required) {
  5648. return;
  5649. }
  5650. if (type != null && type !== true && !skipCheck) {
  5651. let isValid = false;
  5652. const types = isArray(type) ? type : [type];
  5653. const expectedTypes = [];
  5654. for (let i = 0; i < types.length && !isValid; i++) {
  5655. const { valid, expectedType } = assertType(value, types[i]);
  5656. expectedTypes.push(expectedType || "");
  5657. isValid = valid;
  5658. }
  5659. if (!isValid) {
  5660. warn(getInvalidTypeMessage(name, value, expectedTypes));
  5661. return;
  5662. }
  5663. }
  5664. if (validator && !validator(value)) {
  5665. warn('Invalid prop: custom validator check failed for prop "' + name + '".');
  5666. }
  5667. }
  5668. const isSimpleType = /* @__PURE__ */ makeMap(
  5669. "String,Number,Boolean,Function,Symbol,BigInt"
  5670. );
  5671. function assertType(value, type) {
  5672. let valid;
  5673. const expectedType = getType(type);
  5674. if (isSimpleType(expectedType)) {
  5675. const t = typeof value;
  5676. valid = t === expectedType.toLowerCase();
  5677. if (!valid && t === "object") {
  5678. valid = value instanceof type;
  5679. }
  5680. } else if (expectedType === "Object") {
  5681. valid = isObject(value);
  5682. } else if (expectedType === "Array") {
  5683. valid = isArray(value);
  5684. } else if (expectedType === "null") {
  5685. valid = value === null;
  5686. } else {
  5687. valid = value instanceof type;
  5688. }
  5689. return {
  5690. valid,
  5691. expectedType
  5692. };
  5693. }
  5694. function getInvalidTypeMessage(name, value, expectedTypes) {
  5695. if (expectedTypes.length === 0) {
  5696. return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
  5697. }
  5698. let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
  5699. const expectedType = expectedTypes[0];
  5700. const receivedType = toRawType(value);
  5701. const expectedValue = styleValue(value, expectedType);
  5702. const receivedValue = styleValue(value, receivedType);
  5703. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
  5704. message += ` with value ${expectedValue}`;
  5705. }
  5706. message += `, got ${receivedType} `;
  5707. if (isExplicable(receivedType)) {
  5708. message += `with value ${receivedValue}.`;
  5709. }
  5710. return message;
  5711. }
  5712. function styleValue(value, type) {
  5713. if (type === "String") {
  5714. return `"${value}"`;
  5715. } else if (type === "Number") {
  5716. return `${Number(value)}`;
  5717. } else {
  5718. return `${value}`;
  5719. }
  5720. }
  5721. function isExplicable(type) {
  5722. const explicitTypes = ["string", "number", "boolean"];
  5723. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  5724. }
  5725. function isBoolean(...args) {
  5726. return args.some((elem) => elem.toLowerCase() === "boolean");
  5727. }
  5728. const isInternalKey = (key) => key[0] === "_" || key === "$stable";
  5729. const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
  5730. const normalizeSlot = (key, rawSlot, ctx) => {
  5731. if (rawSlot._n) {
  5732. return rawSlot;
  5733. }
  5734. const normalized = withCtx((...args) => {
  5735. if (currentInstance) {
  5736. warn(
  5737. `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
  5738. );
  5739. }
  5740. return normalizeSlotValue(rawSlot(...args));
  5741. }, ctx);
  5742. normalized._c = false;
  5743. return normalized;
  5744. };
  5745. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5746. const ctx = rawSlots._ctx;
  5747. for (const key in rawSlots) {
  5748. if (isInternalKey(key))
  5749. continue;
  5750. const value = rawSlots[key];
  5751. if (isFunction(value)) {
  5752. slots[key] = normalizeSlot(key, value, ctx);
  5753. } else if (value != null) {
  5754. {
  5755. warn(
  5756. `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
  5757. );
  5758. }
  5759. const normalized = normalizeSlotValue(value);
  5760. slots[key] = () => normalized;
  5761. }
  5762. }
  5763. };
  5764. const normalizeVNodeSlots = (instance, children) => {
  5765. if (!isKeepAlive(instance.vnode) && true) {
  5766. warn(
  5767. `Non-function value encountered for default slot. Prefer function slots for better performance.`
  5768. );
  5769. }
  5770. const normalized = normalizeSlotValue(children);
  5771. instance.slots.default = () => normalized;
  5772. };
  5773. const initSlots = (instance, children) => {
  5774. if (instance.vnode.shapeFlag & 32) {
  5775. const type = children._;
  5776. if (type) {
  5777. instance.slots = toRaw(children);
  5778. def(children, "_", type);
  5779. } else {
  5780. normalizeObjectSlots(
  5781. children,
  5782. instance.slots = {});
  5783. }
  5784. } else {
  5785. instance.slots = {};
  5786. if (children) {
  5787. normalizeVNodeSlots(instance, children);
  5788. }
  5789. }
  5790. def(instance.slots, InternalObjectKey, 1);
  5791. };
  5792. const updateSlots = (instance, children, optimized) => {
  5793. const { vnode, slots } = instance;
  5794. let needDeletionCheck = true;
  5795. let deletionComparisonTarget = EMPTY_OBJ;
  5796. if (vnode.shapeFlag & 32) {
  5797. const type = children._;
  5798. if (type) {
  5799. if (isHmrUpdating) {
  5800. extend(slots, children);
  5801. trigger(instance, "set", "$slots");
  5802. } else if (optimized && type === 1) {
  5803. needDeletionCheck = false;
  5804. } else {
  5805. extend(slots, children);
  5806. if (!optimized && type === 1) {
  5807. delete slots._;
  5808. }
  5809. }
  5810. } else {
  5811. needDeletionCheck = !children.$stable;
  5812. normalizeObjectSlots(children, slots);
  5813. }
  5814. deletionComparisonTarget = children;
  5815. } else if (children) {
  5816. normalizeVNodeSlots(instance, children);
  5817. deletionComparisonTarget = { default: 1 };
  5818. }
  5819. if (needDeletionCheck) {
  5820. for (const key in slots) {
  5821. if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
  5822. delete slots[key];
  5823. }
  5824. }
  5825. }
  5826. };
  5827. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5828. if (isArray(rawRef)) {
  5829. rawRef.forEach(
  5830. (r, i) => setRef(
  5831. r,
  5832. oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
  5833. parentSuspense,
  5834. vnode,
  5835. isUnmount
  5836. )
  5837. );
  5838. return;
  5839. }
  5840. if (isAsyncWrapper(vnode) && !isUnmount) {
  5841. return;
  5842. }
  5843. const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
  5844. const value = isUnmount ? null : refValue;
  5845. const { i: owner, r: ref } = rawRef;
  5846. if (!owner) {
  5847. warn(
  5848. `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
  5849. );
  5850. return;
  5851. }
  5852. const oldRef = oldRawRef && oldRawRef.r;
  5853. const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
  5854. const setupState = owner.setupState;
  5855. if (oldRef != null && oldRef !== ref) {
  5856. if (isString(oldRef)) {
  5857. refs[oldRef] = null;
  5858. if (hasOwn(setupState, oldRef)) {
  5859. setupState[oldRef] = null;
  5860. }
  5861. } else if (isRef(oldRef)) {
  5862. oldRef.value = null;
  5863. }
  5864. }
  5865. if (isFunction(ref)) {
  5866. callWithErrorHandling(ref, owner, 12, [value, refs]);
  5867. } else {
  5868. const _isString = isString(ref);
  5869. const _isRef = isRef(ref);
  5870. if (_isString || _isRef) {
  5871. const doSet = () => {
  5872. if (rawRef.f) {
  5873. const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
  5874. if (isUnmount) {
  5875. isArray(existing) && remove(existing, refValue);
  5876. } else {
  5877. if (!isArray(existing)) {
  5878. if (_isString) {
  5879. refs[ref] = [refValue];
  5880. if (hasOwn(setupState, ref)) {
  5881. setupState[ref] = refs[ref];
  5882. }
  5883. } else {
  5884. ref.value = [refValue];
  5885. if (rawRef.k)
  5886. refs[rawRef.k] = ref.value;
  5887. }
  5888. } else if (!existing.includes(refValue)) {
  5889. existing.push(refValue);
  5890. }
  5891. }
  5892. } else if (_isString) {
  5893. refs[ref] = value;
  5894. if (hasOwn(setupState, ref)) {
  5895. setupState[ref] = value;
  5896. }
  5897. } else if (_isRef) {
  5898. ref.value = value;
  5899. if (rawRef.k)
  5900. refs[rawRef.k] = value;
  5901. } else {
  5902. warn("Invalid template ref type:", ref, `(${typeof ref})`);
  5903. }
  5904. };
  5905. if (value) {
  5906. doSet.id = -1;
  5907. queuePostRenderEffect(doSet, parentSuspense);
  5908. } else {
  5909. doSet();
  5910. }
  5911. } else {
  5912. warn("Invalid template ref type:", ref, `(${typeof ref})`);
  5913. }
  5914. }
  5915. }
  5916. let hasMismatch = false;
  5917. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== "foreignObject";
  5918. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  5919. function createHydrationFunctions(rendererInternals) {
  5920. const {
  5921. mt: mountComponent,
  5922. p: patch,
  5923. o: {
  5924. patchProp,
  5925. createText,
  5926. nextSibling,
  5927. parentNode,
  5928. remove,
  5929. insert,
  5930. createComment
  5931. }
  5932. } = rendererInternals;
  5933. const hydrate = (vnode, container) => {
  5934. if (!container.hasChildNodes()) {
  5935. warn(
  5936. `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
  5937. );
  5938. patch(null, vnode, container);
  5939. flushPostFlushCbs();
  5940. container._vnode = vnode;
  5941. return;
  5942. }
  5943. hasMismatch = false;
  5944. hydrateNode(container.firstChild, vnode, null, null, null);
  5945. flushPostFlushCbs();
  5946. container._vnode = vnode;
  5947. if (hasMismatch && true) {
  5948. console.error(`Hydration completed but contains mismatches.`);
  5949. }
  5950. };
  5951. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5952. const isFragmentStart = isComment(node) && node.data === "[";
  5953. const onMismatch = () => handleMismatch(
  5954. node,
  5955. vnode,
  5956. parentComponent,
  5957. parentSuspense,
  5958. slotScopeIds,
  5959. isFragmentStart
  5960. );
  5961. const { type, ref, shapeFlag, patchFlag } = vnode;
  5962. let domType = node.nodeType;
  5963. vnode.el = node;
  5964. {
  5965. if (!("__vnode" in node)) {
  5966. Object.defineProperty(node, "__vnode", {
  5967. value: vnode,
  5968. enumerable: false
  5969. });
  5970. }
  5971. if (!("__vueParentComponent" in node)) {
  5972. Object.defineProperty(node, "__vueParentComponent", {
  5973. value: parentComponent,
  5974. enumerable: false
  5975. });
  5976. }
  5977. }
  5978. if (patchFlag === -2) {
  5979. optimized = false;
  5980. vnode.dynamicChildren = null;
  5981. }
  5982. let nextNode = null;
  5983. switch (type) {
  5984. case Text:
  5985. if (domType !== 3 /* TEXT */) {
  5986. if (vnode.children === "") {
  5987. insert(vnode.el = createText(""), parentNode(node), node);
  5988. nextNode = node;
  5989. } else {
  5990. nextNode = onMismatch();
  5991. }
  5992. } else {
  5993. if (node.data !== vnode.children) {
  5994. hasMismatch = true;
  5995. warn(
  5996. `Hydration text mismatch:
  5997. - Server rendered: ${JSON.stringify(
  5998. node.data
  5999. )}
  6000. - Client rendered: ${JSON.stringify(vnode.children)}`
  6001. );
  6002. node.data = vnode.children;
  6003. }
  6004. nextNode = nextSibling(node);
  6005. }
  6006. break;
  6007. case Comment:
  6008. if (isTemplateNode(node)) {
  6009. nextNode = nextSibling(node);
  6010. replaceNode(
  6011. vnode.el = node.content.firstChild,
  6012. node,
  6013. parentComponent
  6014. );
  6015. } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  6016. nextNode = onMismatch();
  6017. } else {
  6018. nextNode = nextSibling(node);
  6019. }
  6020. break;
  6021. case Static:
  6022. if (isFragmentStart) {
  6023. node = nextSibling(node);
  6024. domType = node.nodeType;
  6025. }
  6026. if (domType === 1 /* ELEMENT */ || domType === 3 /* TEXT */) {
  6027. nextNode = node;
  6028. const needToAdoptContent = !vnode.children.length;
  6029. for (let i = 0; i < vnode.staticCount; i++) {
  6030. if (needToAdoptContent)
  6031. vnode.children += nextNode.nodeType === 1 /* ELEMENT */ ? nextNode.outerHTML : nextNode.data;
  6032. if (i === vnode.staticCount - 1) {
  6033. vnode.anchor = nextNode;
  6034. }
  6035. nextNode = nextSibling(nextNode);
  6036. }
  6037. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  6038. } else {
  6039. onMismatch();
  6040. }
  6041. break;
  6042. case Fragment:
  6043. if (!isFragmentStart) {
  6044. nextNode = onMismatch();
  6045. } else {
  6046. nextNode = hydrateFragment(
  6047. node,
  6048. vnode,
  6049. parentComponent,
  6050. parentSuspense,
  6051. slotScopeIds,
  6052. optimized
  6053. );
  6054. }
  6055. break;
  6056. default:
  6057. if (shapeFlag & 1) {
  6058. if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
  6059. nextNode = onMismatch();
  6060. } else {
  6061. nextNode = hydrateElement(
  6062. node,
  6063. vnode,
  6064. parentComponent,
  6065. parentSuspense,
  6066. slotScopeIds,
  6067. optimized
  6068. );
  6069. }
  6070. } else if (shapeFlag & 6) {
  6071. vnode.slotScopeIds = slotScopeIds;
  6072. const container = parentNode(node);
  6073. if (isFragmentStart) {
  6074. nextNode = locateClosingAnchor(node);
  6075. } else if (isComment(node) && node.data === "teleport start") {
  6076. nextNode = locateClosingAnchor(node, node.data, "teleport end");
  6077. } else {
  6078. nextNode = nextSibling(node);
  6079. }
  6080. mountComponent(
  6081. vnode,
  6082. container,
  6083. null,
  6084. parentComponent,
  6085. parentSuspense,
  6086. isSVGContainer(container),
  6087. optimized
  6088. );
  6089. if (isAsyncWrapper(vnode)) {
  6090. let subTree;
  6091. if (isFragmentStart) {
  6092. subTree = createVNode(Fragment);
  6093. subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
  6094. } else {
  6095. subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
  6096. }
  6097. subTree.el = node;
  6098. vnode.component.subTree = subTree;
  6099. }
  6100. } else if (shapeFlag & 64) {
  6101. if (domType !== 8 /* COMMENT */) {
  6102. nextNode = onMismatch();
  6103. } else {
  6104. nextNode = vnode.type.hydrate(
  6105. node,
  6106. vnode,
  6107. parentComponent,
  6108. parentSuspense,
  6109. slotScopeIds,
  6110. optimized,
  6111. rendererInternals,
  6112. hydrateChildren
  6113. );
  6114. }
  6115. } else if (shapeFlag & 128) {
  6116. nextNode = vnode.type.hydrate(
  6117. node,
  6118. vnode,
  6119. parentComponent,
  6120. parentSuspense,
  6121. isSVGContainer(parentNode(node)),
  6122. slotScopeIds,
  6123. optimized,
  6124. rendererInternals,
  6125. hydrateNode
  6126. );
  6127. } else {
  6128. warn("Invalid HostVNode type:", type, `(${typeof type})`);
  6129. }
  6130. }
  6131. if (ref != null) {
  6132. setRef(ref, null, parentSuspense, vnode);
  6133. }
  6134. return nextNode;
  6135. };
  6136. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6137. optimized = optimized || !!vnode.dynamicChildren;
  6138. const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
  6139. const forcePatch = type === "input" || type === "option";
  6140. {
  6141. if (dirs) {
  6142. invokeDirectiveHook(vnode, null, parentComponent, "created");
  6143. }
  6144. if (props) {
  6145. if (forcePatch || !optimized || patchFlag & (16 | 32)) {
  6146. for (const key in props) {
  6147. if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
  6148. key[0] === ".") {
  6149. patchProp(
  6150. el,
  6151. key,
  6152. null,
  6153. props[key],
  6154. false,
  6155. void 0,
  6156. parentComponent
  6157. );
  6158. }
  6159. }
  6160. } else if (props.onClick) {
  6161. patchProp(
  6162. el,
  6163. "onClick",
  6164. null,
  6165. props.onClick,
  6166. false,
  6167. void 0,
  6168. parentComponent
  6169. );
  6170. }
  6171. }
  6172. let vnodeHooks;
  6173. if (vnodeHooks = props && props.onVnodeBeforeMount) {
  6174. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6175. }
  6176. let needCallTransitionHooks = false;
  6177. if (isTemplateNode(el)) {
  6178. needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
  6179. const content = el.content.firstChild;
  6180. if (needCallTransitionHooks) {
  6181. transition.beforeEnter(content);
  6182. }
  6183. replaceNode(content, el, parentComponent);
  6184. vnode.el = el = content;
  6185. }
  6186. if (dirs) {
  6187. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  6188. }
  6189. if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
  6190. queueEffectWithSuspense(() => {
  6191. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6192. needCallTransitionHooks && transition.enter(el);
  6193. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  6194. }, parentSuspense);
  6195. }
  6196. if (shapeFlag & 16 && // skip if element has innerHTML / textContent
  6197. !(props && (props.innerHTML || props.textContent))) {
  6198. let next = hydrateChildren(
  6199. el.firstChild,
  6200. vnode,
  6201. el,
  6202. parentComponent,
  6203. parentSuspense,
  6204. slotScopeIds,
  6205. optimized
  6206. );
  6207. let hasWarned = false;
  6208. while (next) {
  6209. hasMismatch = true;
  6210. if (!hasWarned) {
  6211. warn(
  6212. `Hydration children mismatch in <${vnode.type}>: server rendered element contains more child nodes than client vdom.`
  6213. );
  6214. hasWarned = true;
  6215. }
  6216. const cur = next;
  6217. next = next.nextSibling;
  6218. remove(cur);
  6219. }
  6220. } else if (shapeFlag & 8) {
  6221. if (el.textContent !== vnode.children) {
  6222. hasMismatch = true;
  6223. warn(
  6224. `Hydration text content mismatch in <${vnode.type}>:
  6225. - Server rendered: ${el.textContent}
  6226. - Client rendered: ${vnode.children}`
  6227. );
  6228. el.textContent = vnode.children;
  6229. }
  6230. }
  6231. }
  6232. return el.nextSibling;
  6233. };
  6234. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6235. optimized = optimized || !!parentVNode.dynamicChildren;
  6236. const children = parentVNode.children;
  6237. const l = children.length;
  6238. let hasWarned = false;
  6239. for (let i = 0; i < l; i++) {
  6240. const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
  6241. if (node) {
  6242. node = hydrateNode(
  6243. node,
  6244. vnode,
  6245. parentComponent,
  6246. parentSuspense,
  6247. slotScopeIds,
  6248. optimized
  6249. );
  6250. } else if (vnode.type === Text && !vnode.children) {
  6251. continue;
  6252. } else {
  6253. hasMismatch = true;
  6254. if (!hasWarned) {
  6255. warn(
  6256. `Hydration children mismatch in <${container.tagName.toLowerCase()}>: server rendered element contains fewer child nodes than client vdom.`
  6257. );
  6258. hasWarned = true;
  6259. }
  6260. patch(
  6261. null,
  6262. vnode,
  6263. container,
  6264. null,
  6265. parentComponent,
  6266. parentSuspense,
  6267. isSVGContainer(container),
  6268. slotScopeIds
  6269. );
  6270. }
  6271. }
  6272. return node;
  6273. };
  6274. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6275. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6276. if (fragmentSlotScopeIds) {
  6277. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  6278. }
  6279. const container = parentNode(node);
  6280. const next = hydrateChildren(
  6281. nextSibling(node),
  6282. vnode,
  6283. container,
  6284. parentComponent,
  6285. parentSuspense,
  6286. slotScopeIds,
  6287. optimized
  6288. );
  6289. if (next && isComment(next) && next.data === "]") {
  6290. return nextSibling(vnode.anchor = next);
  6291. } else {
  6292. hasMismatch = true;
  6293. insert(vnode.anchor = createComment(`]`), container, next);
  6294. return next;
  6295. }
  6296. };
  6297. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6298. hasMismatch = true;
  6299. warn(
  6300. `Hydration node mismatch:
  6301. - Client vnode:`,
  6302. vnode.type,
  6303. `
  6304. - Server rendered DOM:`,
  6305. node,
  6306. node.nodeType === 3 /* TEXT */ ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``
  6307. );
  6308. vnode.el = null;
  6309. if (isFragment) {
  6310. const end = locateClosingAnchor(node);
  6311. while (true) {
  6312. const next2 = nextSibling(node);
  6313. if (next2 && next2 !== end) {
  6314. remove(next2);
  6315. } else {
  6316. break;
  6317. }
  6318. }
  6319. }
  6320. const next = nextSibling(node);
  6321. const container = parentNode(node);
  6322. remove(node);
  6323. patch(
  6324. null,
  6325. vnode,
  6326. container,
  6327. next,
  6328. parentComponent,
  6329. parentSuspense,
  6330. isSVGContainer(container),
  6331. slotScopeIds
  6332. );
  6333. return next;
  6334. };
  6335. const locateClosingAnchor = (node, open = "[", close = "]") => {
  6336. let match = 0;
  6337. while (node) {
  6338. node = nextSibling(node);
  6339. if (node && isComment(node)) {
  6340. if (node.data === open)
  6341. match++;
  6342. if (node.data === close) {
  6343. if (match === 0) {
  6344. return nextSibling(node);
  6345. } else {
  6346. match--;
  6347. }
  6348. }
  6349. }
  6350. }
  6351. return node;
  6352. };
  6353. const replaceNode = (newNode, oldNode, parentComponent) => {
  6354. const parentNode2 = oldNode.parentNode;
  6355. if (parentNode2) {
  6356. parentNode2.replaceChild(newNode, oldNode);
  6357. }
  6358. let parent = parentComponent;
  6359. while (parent) {
  6360. if (parent.vnode.el === oldNode) {
  6361. parent.vnode.el = parent.subTree.el = newNode;
  6362. }
  6363. parent = parent.parent;
  6364. }
  6365. };
  6366. const isTemplateNode = (node) => {
  6367. return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
  6368. };
  6369. return [hydrate, hydrateNode];
  6370. }
  6371. let supported;
  6372. let perf;
  6373. function startMeasure(instance, type) {
  6374. if (instance.appContext.config.performance && isSupported()) {
  6375. perf.mark(`vue-${type}-${instance.uid}`);
  6376. }
  6377. {
  6378. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6379. }
  6380. }
  6381. function endMeasure(instance, type) {
  6382. if (instance.appContext.config.performance && isSupported()) {
  6383. const startTag = `vue-${type}-${instance.uid}`;
  6384. const endTag = startTag + `:end`;
  6385. perf.mark(endTag);
  6386. perf.measure(
  6387. `<${formatComponentName(instance, instance.type)}> ${type}`,
  6388. startTag,
  6389. endTag
  6390. );
  6391. perf.clearMarks(startTag);
  6392. perf.clearMarks(endTag);
  6393. }
  6394. {
  6395. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6396. }
  6397. }
  6398. function isSupported() {
  6399. if (supported !== void 0) {
  6400. return supported;
  6401. }
  6402. if (typeof window !== "undefined" && window.performance) {
  6403. supported = true;
  6404. perf = window.performance;
  6405. } else {
  6406. supported = false;
  6407. }
  6408. return supported;
  6409. }
  6410. const queuePostRenderEffect = queueEffectWithSuspense ;
  6411. function createRenderer(options) {
  6412. return baseCreateRenderer(options);
  6413. }
  6414. function createHydrationRenderer(options) {
  6415. return baseCreateRenderer(options, createHydrationFunctions);
  6416. }
  6417. function baseCreateRenderer(options, createHydrationFns) {
  6418. const target = getGlobalThis();
  6419. target.__VUE__ = true;
  6420. {
  6421. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6422. }
  6423. const {
  6424. insert: hostInsert,
  6425. remove: hostRemove,
  6426. patchProp: hostPatchProp,
  6427. createElement: hostCreateElement,
  6428. createText: hostCreateText,
  6429. createComment: hostCreateComment,
  6430. setText: hostSetText,
  6431. setElementText: hostSetElementText,
  6432. parentNode: hostParentNode,
  6433. nextSibling: hostNextSibling,
  6434. setScopeId: hostSetScopeId = NOOP,
  6435. insertStaticContent: hostInsertStaticContent
  6436. } = options;
  6437. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6438. if (n1 === n2) {
  6439. return;
  6440. }
  6441. if (n1 && !isSameVNodeType(n1, n2)) {
  6442. anchor = getNextHostNode(n1);
  6443. unmount(n1, parentComponent, parentSuspense, true);
  6444. n1 = null;
  6445. }
  6446. if (n2.patchFlag === -2) {
  6447. optimized = false;
  6448. n2.dynamicChildren = null;
  6449. }
  6450. const { type, ref, shapeFlag } = n2;
  6451. switch (type) {
  6452. case Text:
  6453. processText(n1, n2, container, anchor);
  6454. break;
  6455. case Comment:
  6456. processCommentNode(n1, n2, container, anchor);
  6457. break;
  6458. case Static:
  6459. if (n1 == null) {
  6460. mountStaticNode(n2, container, anchor, isSVG);
  6461. } else {
  6462. patchStaticNode(n1, n2, container, isSVG);
  6463. }
  6464. break;
  6465. case Fragment:
  6466. processFragment(
  6467. n1,
  6468. n2,
  6469. container,
  6470. anchor,
  6471. parentComponent,
  6472. parentSuspense,
  6473. isSVG,
  6474. slotScopeIds,
  6475. optimized
  6476. );
  6477. break;
  6478. default:
  6479. if (shapeFlag & 1) {
  6480. processElement(
  6481. n1,
  6482. n2,
  6483. container,
  6484. anchor,
  6485. parentComponent,
  6486. parentSuspense,
  6487. isSVG,
  6488. slotScopeIds,
  6489. optimized
  6490. );
  6491. } else if (shapeFlag & 6) {
  6492. processComponent(
  6493. n1,
  6494. n2,
  6495. container,
  6496. anchor,
  6497. parentComponent,
  6498. parentSuspense,
  6499. isSVG,
  6500. slotScopeIds,
  6501. optimized
  6502. );
  6503. } else if (shapeFlag & 64) {
  6504. type.process(
  6505. n1,
  6506. n2,
  6507. container,
  6508. anchor,
  6509. parentComponent,
  6510. parentSuspense,
  6511. isSVG,
  6512. slotScopeIds,
  6513. optimized,
  6514. internals
  6515. );
  6516. } else if (shapeFlag & 128) {
  6517. type.process(
  6518. n1,
  6519. n2,
  6520. container,
  6521. anchor,
  6522. parentComponent,
  6523. parentSuspense,
  6524. isSVG,
  6525. slotScopeIds,
  6526. optimized,
  6527. internals
  6528. );
  6529. } else {
  6530. warn("Invalid VNode type:", type, `(${typeof type})`);
  6531. }
  6532. }
  6533. if (ref != null && parentComponent) {
  6534. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6535. }
  6536. };
  6537. const processText = (n1, n2, container, anchor) => {
  6538. if (n1 == null) {
  6539. hostInsert(
  6540. n2.el = hostCreateText(n2.children),
  6541. container,
  6542. anchor
  6543. );
  6544. } else {
  6545. const el = n2.el = n1.el;
  6546. if (n2.children !== n1.children) {
  6547. hostSetText(el, n2.children);
  6548. }
  6549. }
  6550. };
  6551. const processCommentNode = (n1, n2, container, anchor) => {
  6552. if (n1 == null) {
  6553. hostInsert(
  6554. n2.el = hostCreateComment(n2.children || ""),
  6555. container,
  6556. anchor
  6557. );
  6558. } else {
  6559. n2.el = n1.el;
  6560. }
  6561. };
  6562. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6563. [n2.el, n2.anchor] = hostInsertStaticContent(
  6564. n2.children,
  6565. container,
  6566. anchor,
  6567. isSVG,
  6568. n2.el,
  6569. n2.anchor
  6570. );
  6571. };
  6572. const patchStaticNode = (n1, n2, container, isSVG) => {
  6573. if (n2.children !== n1.children) {
  6574. const anchor = hostNextSibling(n1.anchor);
  6575. removeStaticNode(n1);
  6576. [n2.el, n2.anchor] = hostInsertStaticContent(
  6577. n2.children,
  6578. container,
  6579. anchor,
  6580. isSVG
  6581. );
  6582. } else {
  6583. n2.el = n1.el;
  6584. n2.anchor = n1.anchor;
  6585. }
  6586. };
  6587. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6588. let next;
  6589. while (el && el !== anchor) {
  6590. next = hostNextSibling(el);
  6591. hostInsert(el, container, nextSibling);
  6592. el = next;
  6593. }
  6594. hostInsert(anchor, container, nextSibling);
  6595. };
  6596. const removeStaticNode = ({ el, anchor }) => {
  6597. let next;
  6598. while (el && el !== anchor) {
  6599. next = hostNextSibling(el);
  6600. hostRemove(el);
  6601. el = next;
  6602. }
  6603. hostRemove(anchor);
  6604. };
  6605. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6606. isSVG = isSVG || n2.type === "svg";
  6607. if (n1 == null) {
  6608. mountElement(
  6609. n2,
  6610. container,
  6611. anchor,
  6612. parentComponent,
  6613. parentSuspense,
  6614. isSVG,
  6615. slotScopeIds,
  6616. optimized
  6617. );
  6618. } else {
  6619. patchElement(
  6620. n1,
  6621. n2,
  6622. parentComponent,
  6623. parentSuspense,
  6624. isSVG,
  6625. slotScopeIds,
  6626. optimized
  6627. );
  6628. }
  6629. };
  6630. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6631. let el;
  6632. let vnodeHook;
  6633. const { type, props, shapeFlag, transition, dirs } = vnode;
  6634. el = vnode.el = hostCreateElement(
  6635. vnode.type,
  6636. isSVG,
  6637. props && props.is,
  6638. props
  6639. );
  6640. if (shapeFlag & 8) {
  6641. hostSetElementText(el, vnode.children);
  6642. } else if (shapeFlag & 16) {
  6643. mountChildren(
  6644. vnode.children,
  6645. el,
  6646. null,
  6647. parentComponent,
  6648. parentSuspense,
  6649. isSVG && type !== "foreignObject",
  6650. slotScopeIds,
  6651. optimized
  6652. );
  6653. }
  6654. if (dirs) {
  6655. invokeDirectiveHook(vnode, null, parentComponent, "created");
  6656. }
  6657. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6658. if (props) {
  6659. for (const key in props) {
  6660. if (key !== "value" && !isReservedProp(key)) {
  6661. hostPatchProp(
  6662. el,
  6663. key,
  6664. null,
  6665. props[key],
  6666. isSVG,
  6667. vnode.children,
  6668. parentComponent,
  6669. parentSuspense,
  6670. unmountChildren
  6671. );
  6672. }
  6673. }
  6674. if ("value" in props) {
  6675. hostPatchProp(el, "value", null, props.value);
  6676. }
  6677. if (vnodeHook = props.onVnodeBeforeMount) {
  6678. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6679. }
  6680. }
  6681. {
  6682. Object.defineProperty(el, "__vnode", {
  6683. value: vnode,
  6684. enumerable: false
  6685. });
  6686. Object.defineProperty(el, "__vueParentComponent", {
  6687. value: parentComponent,
  6688. enumerable: false
  6689. });
  6690. }
  6691. if (dirs) {
  6692. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  6693. }
  6694. const needCallTransitionHooks = needTransition(parentSuspense, transition);
  6695. if (needCallTransitionHooks) {
  6696. transition.beforeEnter(el);
  6697. }
  6698. hostInsert(el, container, anchor);
  6699. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  6700. queuePostRenderEffect(() => {
  6701. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6702. needCallTransitionHooks && transition.enter(el);
  6703. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  6704. }, parentSuspense);
  6705. }
  6706. };
  6707. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6708. if (scopeId) {
  6709. hostSetScopeId(el, scopeId);
  6710. }
  6711. if (slotScopeIds) {
  6712. for (let i = 0; i < slotScopeIds.length; i++) {
  6713. hostSetScopeId(el, slotScopeIds[i]);
  6714. }
  6715. }
  6716. if (parentComponent) {
  6717. let subTree = parentComponent.subTree;
  6718. if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
  6719. subTree = filterSingleRoot(subTree.children) || subTree;
  6720. }
  6721. if (vnode === subTree) {
  6722. const parentVNode = parentComponent.vnode;
  6723. setScopeId(
  6724. el,
  6725. parentVNode,
  6726. parentVNode.scopeId,
  6727. parentVNode.slotScopeIds,
  6728. parentComponent.parent
  6729. );
  6730. }
  6731. }
  6732. };
  6733. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6734. for (let i = start; i < children.length; i++) {
  6735. const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
  6736. patch(
  6737. null,
  6738. child,
  6739. container,
  6740. anchor,
  6741. parentComponent,
  6742. parentSuspense,
  6743. isSVG,
  6744. slotScopeIds,
  6745. optimized
  6746. );
  6747. }
  6748. };
  6749. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6750. const el = n2.el = n1.el;
  6751. let { patchFlag, dynamicChildren, dirs } = n2;
  6752. patchFlag |= n1.patchFlag & 16;
  6753. const oldProps = n1.props || EMPTY_OBJ;
  6754. const newProps = n2.props || EMPTY_OBJ;
  6755. let vnodeHook;
  6756. parentComponent && toggleRecurse(parentComponent, false);
  6757. if (vnodeHook = newProps.onVnodeBeforeUpdate) {
  6758. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6759. }
  6760. if (dirs) {
  6761. invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
  6762. }
  6763. parentComponent && toggleRecurse(parentComponent, true);
  6764. if (isHmrUpdating) {
  6765. patchFlag = 0;
  6766. optimized = false;
  6767. dynamicChildren = null;
  6768. }
  6769. const areChildrenSVG = isSVG && n2.type !== "foreignObject";
  6770. if (dynamicChildren) {
  6771. patchBlockChildren(
  6772. n1.dynamicChildren,
  6773. dynamicChildren,
  6774. el,
  6775. parentComponent,
  6776. parentSuspense,
  6777. areChildrenSVG,
  6778. slotScopeIds
  6779. );
  6780. {
  6781. traverseStaticChildren(n1, n2);
  6782. }
  6783. } else if (!optimized) {
  6784. patchChildren(
  6785. n1,
  6786. n2,
  6787. el,
  6788. null,
  6789. parentComponent,
  6790. parentSuspense,
  6791. areChildrenSVG,
  6792. slotScopeIds,
  6793. false
  6794. );
  6795. }
  6796. if (patchFlag > 0) {
  6797. if (patchFlag & 16) {
  6798. patchProps(
  6799. el,
  6800. n2,
  6801. oldProps,
  6802. newProps,
  6803. parentComponent,
  6804. parentSuspense,
  6805. isSVG
  6806. );
  6807. } else {
  6808. if (patchFlag & 2) {
  6809. if (oldProps.class !== newProps.class) {
  6810. hostPatchProp(el, "class", null, newProps.class, isSVG);
  6811. }
  6812. }
  6813. if (patchFlag & 4) {
  6814. hostPatchProp(el, "style", oldProps.style, newProps.style, isSVG);
  6815. }
  6816. if (patchFlag & 8) {
  6817. const propsToUpdate = n2.dynamicProps;
  6818. for (let i = 0; i < propsToUpdate.length; i++) {
  6819. const key = propsToUpdate[i];
  6820. const prev = oldProps[key];
  6821. const next = newProps[key];
  6822. if (next !== prev || key === "value") {
  6823. hostPatchProp(
  6824. el,
  6825. key,
  6826. prev,
  6827. next,
  6828. isSVG,
  6829. n1.children,
  6830. parentComponent,
  6831. parentSuspense,
  6832. unmountChildren
  6833. );
  6834. }
  6835. }
  6836. }
  6837. }
  6838. if (patchFlag & 1) {
  6839. if (n1.children !== n2.children) {
  6840. hostSetElementText(el, n2.children);
  6841. }
  6842. }
  6843. } else if (!optimized && dynamicChildren == null) {
  6844. patchProps(
  6845. el,
  6846. n2,
  6847. oldProps,
  6848. newProps,
  6849. parentComponent,
  6850. parentSuspense,
  6851. isSVG
  6852. );
  6853. }
  6854. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6855. queuePostRenderEffect(() => {
  6856. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6857. dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
  6858. }, parentSuspense);
  6859. }
  6860. };
  6861. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6862. for (let i = 0; i < newChildren.length; i++) {
  6863. const oldVNode = oldChildren[i];
  6864. const newVNode = newChildren[i];
  6865. const container = (
  6866. // oldVNode may be an errored async setup() component inside Suspense
  6867. // which will not have a mounted element
  6868. oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
  6869. // of the Fragment itself so it can move its children.
  6870. (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
  6871. // which also requires the correct parent container
  6872. !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
  6873. oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
  6874. // In other cases, the parent container is not actually used so we
  6875. // just pass the block element here to avoid a DOM parentNode call.
  6876. fallbackContainer
  6877. )
  6878. );
  6879. patch(
  6880. oldVNode,
  6881. newVNode,
  6882. container,
  6883. null,
  6884. parentComponent,
  6885. parentSuspense,
  6886. isSVG,
  6887. slotScopeIds,
  6888. true
  6889. );
  6890. }
  6891. };
  6892. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6893. if (oldProps !== newProps) {
  6894. if (oldProps !== EMPTY_OBJ) {
  6895. for (const key in oldProps) {
  6896. if (!isReservedProp(key) && !(key in newProps)) {
  6897. hostPatchProp(
  6898. el,
  6899. key,
  6900. oldProps[key],
  6901. null,
  6902. isSVG,
  6903. vnode.children,
  6904. parentComponent,
  6905. parentSuspense,
  6906. unmountChildren
  6907. );
  6908. }
  6909. }
  6910. }
  6911. for (const key in newProps) {
  6912. if (isReservedProp(key))
  6913. continue;
  6914. const next = newProps[key];
  6915. const prev = oldProps[key];
  6916. if (next !== prev && key !== "value") {
  6917. hostPatchProp(
  6918. el,
  6919. key,
  6920. prev,
  6921. next,
  6922. isSVG,
  6923. vnode.children,
  6924. parentComponent,
  6925. parentSuspense,
  6926. unmountChildren
  6927. );
  6928. }
  6929. }
  6930. if ("value" in newProps) {
  6931. hostPatchProp(el, "value", oldProps.value, newProps.value);
  6932. }
  6933. }
  6934. };
  6935. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6936. const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
  6937. const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
  6938. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6939. if (
  6940. // #5523 dev root fragment may inherit directives
  6941. isHmrUpdating || patchFlag & 2048
  6942. ) {
  6943. patchFlag = 0;
  6944. optimized = false;
  6945. dynamicChildren = null;
  6946. }
  6947. if (fragmentSlotScopeIds) {
  6948. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  6949. }
  6950. if (n1 == null) {
  6951. hostInsert(fragmentStartAnchor, container, anchor);
  6952. hostInsert(fragmentEndAnchor, container, anchor);
  6953. mountChildren(
  6954. n2.children,
  6955. container,
  6956. fragmentEndAnchor,
  6957. parentComponent,
  6958. parentSuspense,
  6959. isSVG,
  6960. slotScopeIds,
  6961. optimized
  6962. );
  6963. } else {
  6964. if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
  6965. // of renderSlot() with no valid children
  6966. n1.dynamicChildren) {
  6967. patchBlockChildren(
  6968. n1.dynamicChildren,
  6969. dynamicChildren,
  6970. container,
  6971. parentComponent,
  6972. parentSuspense,
  6973. isSVG,
  6974. slotScopeIds
  6975. );
  6976. {
  6977. traverseStaticChildren(n1, n2);
  6978. }
  6979. } else {
  6980. patchChildren(
  6981. n1,
  6982. n2,
  6983. container,
  6984. fragmentEndAnchor,
  6985. parentComponent,
  6986. parentSuspense,
  6987. isSVG,
  6988. slotScopeIds,
  6989. optimized
  6990. );
  6991. }
  6992. }
  6993. };
  6994. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6995. n2.slotScopeIds = slotScopeIds;
  6996. if (n1 == null) {
  6997. if (n2.shapeFlag & 512) {
  6998. parentComponent.ctx.activate(
  6999. n2,
  7000. container,
  7001. anchor,
  7002. isSVG,
  7003. optimized
  7004. );
  7005. } else {
  7006. mountComponent(
  7007. n2,
  7008. container,
  7009. anchor,
  7010. parentComponent,
  7011. parentSuspense,
  7012. isSVG,
  7013. optimized
  7014. );
  7015. }
  7016. } else {
  7017. updateComponent(n1, n2, optimized);
  7018. }
  7019. };
  7020. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  7021. const instance = (initialVNode.component = createComponentInstance(
  7022. initialVNode,
  7023. parentComponent,
  7024. parentSuspense
  7025. ));
  7026. if (instance.type.__hmrId) {
  7027. registerHMR(instance);
  7028. }
  7029. {
  7030. pushWarningContext(initialVNode);
  7031. startMeasure(instance, `mount`);
  7032. }
  7033. if (isKeepAlive(initialVNode)) {
  7034. instance.ctx.renderer = internals;
  7035. }
  7036. {
  7037. {
  7038. startMeasure(instance, `init`);
  7039. }
  7040. setupComponent(instance);
  7041. {
  7042. endMeasure(instance, `init`);
  7043. }
  7044. }
  7045. if (instance.asyncDep) {
  7046. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  7047. if (!initialVNode.el) {
  7048. const placeholder = instance.subTree = createVNode(Comment);
  7049. processCommentNode(null, placeholder, container, anchor);
  7050. }
  7051. return;
  7052. }
  7053. setupRenderEffect(
  7054. instance,
  7055. initialVNode,
  7056. container,
  7057. anchor,
  7058. parentSuspense,
  7059. isSVG,
  7060. optimized
  7061. );
  7062. {
  7063. popWarningContext();
  7064. endMeasure(instance, `mount`);
  7065. }
  7066. };
  7067. const updateComponent = (n1, n2, optimized) => {
  7068. const instance = n2.component = n1.component;
  7069. if (shouldUpdateComponent(n1, n2, optimized)) {
  7070. if (instance.asyncDep && !instance.asyncResolved) {
  7071. {
  7072. pushWarningContext(n2);
  7073. }
  7074. updateComponentPreRender(instance, n2, optimized);
  7075. {
  7076. popWarningContext();
  7077. }
  7078. return;
  7079. } else {
  7080. instance.next = n2;
  7081. invalidateJob(instance.update);
  7082. instance.update();
  7083. }
  7084. } else {
  7085. n2.el = n1.el;
  7086. instance.vnode = n2;
  7087. }
  7088. };
  7089. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  7090. const componentUpdateFn = () => {
  7091. if (!instance.isMounted) {
  7092. let vnodeHook;
  7093. const { el, props } = initialVNode;
  7094. const { bm, m, parent } = instance;
  7095. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  7096. toggleRecurse(instance, false);
  7097. if (bm) {
  7098. invokeArrayFns(bm);
  7099. }
  7100. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
  7101. invokeVNodeHook(vnodeHook, parent, initialVNode);
  7102. }
  7103. toggleRecurse(instance, true);
  7104. if (el && hydrateNode) {
  7105. const hydrateSubTree = () => {
  7106. {
  7107. startMeasure(instance, `render`);
  7108. }
  7109. instance.subTree = renderComponentRoot(instance);
  7110. {
  7111. endMeasure(instance, `render`);
  7112. }
  7113. {
  7114. startMeasure(instance, `hydrate`);
  7115. }
  7116. hydrateNode(
  7117. el,
  7118. instance.subTree,
  7119. instance,
  7120. parentSuspense,
  7121. null
  7122. );
  7123. {
  7124. endMeasure(instance, `hydrate`);
  7125. }
  7126. };
  7127. if (isAsyncWrapperVNode) {
  7128. initialVNode.type.__asyncLoader().then(
  7129. // note: we are moving the render call into an async callback,
  7130. // which means it won't track dependencies - but it's ok because
  7131. // a server-rendered async wrapper is already in resolved state
  7132. // and it will never need to change.
  7133. () => !instance.isUnmounted && hydrateSubTree()
  7134. );
  7135. } else {
  7136. hydrateSubTree();
  7137. }
  7138. } else {
  7139. {
  7140. startMeasure(instance, `render`);
  7141. }
  7142. const subTree = instance.subTree = renderComponentRoot(instance);
  7143. {
  7144. endMeasure(instance, `render`);
  7145. }
  7146. {
  7147. startMeasure(instance, `patch`);
  7148. }
  7149. patch(
  7150. null,
  7151. subTree,
  7152. container,
  7153. anchor,
  7154. instance,
  7155. parentSuspense,
  7156. isSVG
  7157. );
  7158. {
  7159. endMeasure(instance, `patch`);
  7160. }
  7161. initialVNode.el = subTree.el;
  7162. }
  7163. if (m) {
  7164. queuePostRenderEffect(m, parentSuspense);
  7165. }
  7166. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  7167. const scopedInitialVNode = initialVNode;
  7168. queuePostRenderEffect(
  7169. () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
  7170. parentSuspense
  7171. );
  7172. }
  7173. if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
  7174. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  7175. }
  7176. instance.isMounted = true;
  7177. {
  7178. devtoolsComponentAdded(instance);
  7179. }
  7180. initialVNode = container = anchor = null;
  7181. } else {
  7182. let { next, bu, u, parent, vnode } = instance;
  7183. let originNext = next;
  7184. let vnodeHook;
  7185. {
  7186. pushWarningContext(next || instance.vnode);
  7187. }
  7188. toggleRecurse(instance, false);
  7189. if (next) {
  7190. next.el = vnode.el;
  7191. updateComponentPreRender(instance, next, optimized);
  7192. } else {
  7193. next = vnode;
  7194. }
  7195. if (bu) {
  7196. invokeArrayFns(bu);
  7197. }
  7198. if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
  7199. invokeVNodeHook(vnodeHook, parent, next, vnode);
  7200. }
  7201. toggleRecurse(instance, true);
  7202. {
  7203. startMeasure(instance, `render`);
  7204. }
  7205. const nextTree = renderComponentRoot(instance);
  7206. {
  7207. endMeasure(instance, `render`);
  7208. }
  7209. const prevTree = instance.subTree;
  7210. instance.subTree = nextTree;
  7211. {
  7212. startMeasure(instance, `patch`);
  7213. }
  7214. patch(
  7215. prevTree,
  7216. nextTree,
  7217. // parent may have changed if it's in a teleport
  7218. hostParentNode(prevTree.el),
  7219. // anchor may have changed if it's in a fragment
  7220. getNextHostNode(prevTree),
  7221. instance,
  7222. parentSuspense,
  7223. isSVG
  7224. );
  7225. {
  7226. endMeasure(instance, `patch`);
  7227. }
  7228. next.el = nextTree.el;
  7229. if (originNext === null) {
  7230. updateHOCHostEl(instance, nextTree.el);
  7231. }
  7232. if (u) {
  7233. queuePostRenderEffect(u, parentSuspense);
  7234. }
  7235. if (vnodeHook = next.props && next.props.onVnodeUpdated) {
  7236. queuePostRenderEffect(
  7237. () => invokeVNodeHook(vnodeHook, parent, next, vnode),
  7238. parentSuspense
  7239. );
  7240. }
  7241. {
  7242. devtoolsComponentUpdated(instance);
  7243. }
  7244. {
  7245. popWarningContext();
  7246. }
  7247. }
  7248. };
  7249. const effect = instance.effect = new ReactiveEffect(
  7250. componentUpdateFn,
  7251. () => queueJob(update),
  7252. instance.scope
  7253. // track it in component's effect scope
  7254. );
  7255. const update = instance.update = () => effect.run();
  7256. update.id = instance.uid;
  7257. toggleRecurse(instance, true);
  7258. {
  7259. effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
  7260. effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
  7261. update.ownerInstance = instance;
  7262. }
  7263. update();
  7264. };
  7265. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7266. nextVNode.component = instance;
  7267. const prevProps = instance.vnode.props;
  7268. instance.vnode = nextVNode;
  7269. instance.next = null;
  7270. updateProps(instance, nextVNode.props, prevProps, optimized);
  7271. updateSlots(instance, nextVNode.children, optimized);
  7272. pauseTracking();
  7273. flushPreFlushCbs(instance);
  7274. resetTracking();
  7275. };
  7276. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7277. const c1 = n1 && n1.children;
  7278. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7279. const c2 = n2.children;
  7280. const { patchFlag, shapeFlag } = n2;
  7281. if (patchFlag > 0) {
  7282. if (patchFlag & 128) {
  7283. patchKeyedChildren(
  7284. c1,
  7285. c2,
  7286. container,
  7287. anchor,
  7288. parentComponent,
  7289. parentSuspense,
  7290. isSVG,
  7291. slotScopeIds,
  7292. optimized
  7293. );
  7294. return;
  7295. } else if (patchFlag & 256) {
  7296. patchUnkeyedChildren(
  7297. c1,
  7298. c2,
  7299. container,
  7300. anchor,
  7301. parentComponent,
  7302. parentSuspense,
  7303. isSVG,
  7304. slotScopeIds,
  7305. optimized
  7306. );
  7307. return;
  7308. }
  7309. }
  7310. if (shapeFlag & 8) {
  7311. if (prevShapeFlag & 16) {
  7312. unmountChildren(c1, parentComponent, parentSuspense);
  7313. }
  7314. if (c2 !== c1) {
  7315. hostSetElementText(container, c2);
  7316. }
  7317. } else {
  7318. if (prevShapeFlag & 16) {
  7319. if (shapeFlag & 16) {
  7320. patchKeyedChildren(
  7321. c1,
  7322. c2,
  7323. container,
  7324. anchor,
  7325. parentComponent,
  7326. parentSuspense,
  7327. isSVG,
  7328. slotScopeIds,
  7329. optimized
  7330. );
  7331. } else {
  7332. unmountChildren(c1, parentComponent, parentSuspense, true);
  7333. }
  7334. } else {
  7335. if (prevShapeFlag & 8) {
  7336. hostSetElementText(container, "");
  7337. }
  7338. if (shapeFlag & 16) {
  7339. mountChildren(
  7340. c2,
  7341. container,
  7342. anchor,
  7343. parentComponent,
  7344. parentSuspense,
  7345. isSVG,
  7346. slotScopeIds,
  7347. optimized
  7348. );
  7349. }
  7350. }
  7351. }
  7352. };
  7353. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7354. c1 = c1 || EMPTY_ARR;
  7355. c2 = c2 || EMPTY_ARR;
  7356. const oldLength = c1.length;
  7357. const newLength = c2.length;
  7358. const commonLength = Math.min(oldLength, newLength);
  7359. let i;
  7360. for (i = 0; i < commonLength; i++) {
  7361. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7362. patch(
  7363. c1[i],
  7364. nextChild,
  7365. container,
  7366. null,
  7367. parentComponent,
  7368. parentSuspense,
  7369. isSVG,
  7370. slotScopeIds,
  7371. optimized
  7372. );
  7373. }
  7374. if (oldLength > newLength) {
  7375. unmountChildren(
  7376. c1,
  7377. parentComponent,
  7378. parentSuspense,
  7379. true,
  7380. false,
  7381. commonLength
  7382. );
  7383. } else {
  7384. mountChildren(
  7385. c2,
  7386. container,
  7387. anchor,
  7388. parentComponent,
  7389. parentSuspense,
  7390. isSVG,
  7391. slotScopeIds,
  7392. optimized,
  7393. commonLength
  7394. );
  7395. }
  7396. };
  7397. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7398. let i = 0;
  7399. const l2 = c2.length;
  7400. let e1 = c1.length - 1;
  7401. let e2 = l2 - 1;
  7402. while (i <= e1 && i <= e2) {
  7403. const n1 = c1[i];
  7404. const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7405. if (isSameVNodeType(n1, n2)) {
  7406. patch(
  7407. n1,
  7408. n2,
  7409. container,
  7410. null,
  7411. parentComponent,
  7412. parentSuspense,
  7413. isSVG,
  7414. slotScopeIds,
  7415. optimized
  7416. );
  7417. } else {
  7418. break;
  7419. }
  7420. i++;
  7421. }
  7422. while (i <= e1 && i <= e2) {
  7423. const n1 = c1[e1];
  7424. const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
  7425. if (isSameVNodeType(n1, n2)) {
  7426. patch(
  7427. n1,
  7428. n2,
  7429. container,
  7430. null,
  7431. parentComponent,
  7432. parentSuspense,
  7433. isSVG,
  7434. slotScopeIds,
  7435. optimized
  7436. );
  7437. } else {
  7438. break;
  7439. }
  7440. e1--;
  7441. e2--;
  7442. }
  7443. if (i > e1) {
  7444. if (i <= e2) {
  7445. const nextPos = e2 + 1;
  7446. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7447. while (i <= e2) {
  7448. patch(
  7449. null,
  7450. c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
  7451. container,
  7452. anchor,
  7453. parentComponent,
  7454. parentSuspense,
  7455. isSVG,
  7456. slotScopeIds,
  7457. optimized
  7458. );
  7459. i++;
  7460. }
  7461. }
  7462. } else if (i > e2) {
  7463. while (i <= e1) {
  7464. unmount(c1[i], parentComponent, parentSuspense, true);
  7465. i++;
  7466. }
  7467. } else {
  7468. const s1 = i;
  7469. const s2 = i;
  7470. const keyToNewIndexMap = /* @__PURE__ */ new Map();
  7471. for (i = s2; i <= e2; i++) {
  7472. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7473. if (nextChild.key != null) {
  7474. if (keyToNewIndexMap.has(nextChild.key)) {
  7475. warn(
  7476. `Duplicate keys found during update:`,
  7477. JSON.stringify(nextChild.key),
  7478. `Make sure keys are unique.`
  7479. );
  7480. }
  7481. keyToNewIndexMap.set(nextChild.key, i);
  7482. }
  7483. }
  7484. let j;
  7485. let patched = 0;
  7486. const toBePatched = e2 - s2 + 1;
  7487. let moved = false;
  7488. let maxNewIndexSoFar = 0;
  7489. const newIndexToOldIndexMap = new Array(toBePatched);
  7490. for (i = 0; i < toBePatched; i++)
  7491. newIndexToOldIndexMap[i] = 0;
  7492. for (i = s1; i <= e1; i++) {
  7493. const prevChild = c1[i];
  7494. if (patched >= toBePatched) {
  7495. unmount(prevChild, parentComponent, parentSuspense, true);
  7496. continue;
  7497. }
  7498. let newIndex;
  7499. if (prevChild.key != null) {
  7500. newIndex = keyToNewIndexMap.get(prevChild.key);
  7501. } else {
  7502. for (j = s2; j <= e2; j++) {
  7503. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  7504. newIndex = j;
  7505. break;
  7506. }
  7507. }
  7508. }
  7509. if (newIndex === void 0) {
  7510. unmount(prevChild, parentComponent, parentSuspense, true);
  7511. } else {
  7512. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7513. if (newIndex >= maxNewIndexSoFar) {
  7514. maxNewIndexSoFar = newIndex;
  7515. } else {
  7516. moved = true;
  7517. }
  7518. patch(
  7519. prevChild,
  7520. c2[newIndex],
  7521. container,
  7522. null,
  7523. parentComponent,
  7524. parentSuspense,
  7525. isSVG,
  7526. slotScopeIds,
  7527. optimized
  7528. );
  7529. patched++;
  7530. }
  7531. }
  7532. const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
  7533. j = increasingNewIndexSequence.length - 1;
  7534. for (i = toBePatched - 1; i >= 0; i--) {
  7535. const nextIndex = s2 + i;
  7536. const nextChild = c2[nextIndex];
  7537. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7538. if (newIndexToOldIndexMap[i] === 0) {
  7539. patch(
  7540. null,
  7541. nextChild,
  7542. container,
  7543. anchor,
  7544. parentComponent,
  7545. parentSuspense,
  7546. isSVG,
  7547. slotScopeIds,
  7548. optimized
  7549. );
  7550. } else if (moved) {
  7551. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7552. move(nextChild, container, anchor, 2);
  7553. } else {
  7554. j--;
  7555. }
  7556. }
  7557. }
  7558. }
  7559. };
  7560. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7561. const { el, type, transition, children, shapeFlag } = vnode;
  7562. if (shapeFlag & 6) {
  7563. move(vnode.component.subTree, container, anchor, moveType);
  7564. return;
  7565. }
  7566. if (shapeFlag & 128) {
  7567. vnode.suspense.move(container, anchor, moveType);
  7568. return;
  7569. }
  7570. if (shapeFlag & 64) {
  7571. type.move(vnode, container, anchor, internals);
  7572. return;
  7573. }
  7574. if (type === Fragment) {
  7575. hostInsert(el, container, anchor);
  7576. for (let i = 0; i < children.length; i++) {
  7577. move(children[i], container, anchor, moveType);
  7578. }
  7579. hostInsert(vnode.anchor, container, anchor);
  7580. return;
  7581. }
  7582. if (type === Static) {
  7583. moveStaticNode(vnode, container, anchor);
  7584. return;
  7585. }
  7586. const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
  7587. if (needTransition2) {
  7588. if (moveType === 0) {
  7589. transition.beforeEnter(el);
  7590. hostInsert(el, container, anchor);
  7591. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7592. } else {
  7593. const { leave, delayLeave, afterLeave } = transition;
  7594. const remove2 = () => hostInsert(el, container, anchor);
  7595. const performLeave = () => {
  7596. leave(el, () => {
  7597. remove2();
  7598. afterLeave && afterLeave();
  7599. });
  7600. };
  7601. if (delayLeave) {
  7602. delayLeave(el, remove2, performLeave);
  7603. } else {
  7604. performLeave();
  7605. }
  7606. }
  7607. } else {
  7608. hostInsert(el, container, anchor);
  7609. }
  7610. };
  7611. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7612. const {
  7613. type,
  7614. props,
  7615. ref,
  7616. children,
  7617. dynamicChildren,
  7618. shapeFlag,
  7619. patchFlag,
  7620. dirs
  7621. } = vnode;
  7622. if (ref != null) {
  7623. setRef(ref, null, parentSuspense, vnode, true);
  7624. }
  7625. if (shapeFlag & 256) {
  7626. parentComponent.ctx.deactivate(vnode);
  7627. return;
  7628. }
  7629. const shouldInvokeDirs = shapeFlag & 1 && dirs;
  7630. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7631. let vnodeHook;
  7632. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7633. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7634. }
  7635. if (shapeFlag & 6) {
  7636. unmountComponent(vnode.component, parentSuspense, doRemove);
  7637. } else {
  7638. if (shapeFlag & 128) {
  7639. vnode.suspense.unmount(parentSuspense, doRemove);
  7640. return;
  7641. }
  7642. if (shouldInvokeDirs) {
  7643. invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
  7644. }
  7645. if (shapeFlag & 64) {
  7646. vnode.type.remove(
  7647. vnode,
  7648. parentComponent,
  7649. parentSuspense,
  7650. optimized,
  7651. internals,
  7652. doRemove
  7653. );
  7654. } else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
  7655. (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
  7656. unmountChildren(
  7657. dynamicChildren,
  7658. parentComponent,
  7659. parentSuspense,
  7660. false,
  7661. true
  7662. );
  7663. } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
  7664. unmountChildren(children, parentComponent, parentSuspense);
  7665. }
  7666. if (doRemove) {
  7667. remove(vnode);
  7668. }
  7669. }
  7670. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  7671. queuePostRenderEffect(() => {
  7672. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7673. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
  7674. }, parentSuspense);
  7675. }
  7676. };
  7677. const remove = (vnode) => {
  7678. const { type, el, anchor, transition } = vnode;
  7679. if (type === Fragment) {
  7680. if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
  7681. vnode.children.forEach((child) => {
  7682. if (child.type === Comment) {
  7683. hostRemove(child.el);
  7684. } else {
  7685. remove(child);
  7686. }
  7687. });
  7688. } else {
  7689. removeFragment(el, anchor);
  7690. }
  7691. return;
  7692. }
  7693. if (type === Static) {
  7694. removeStaticNode(vnode);
  7695. return;
  7696. }
  7697. const performRemove = () => {
  7698. hostRemove(el);
  7699. if (transition && !transition.persisted && transition.afterLeave) {
  7700. transition.afterLeave();
  7701. }
  7702. };
  7703. if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
  7704. const { leave, delayLeave } = transition;
  7705. const performLeave = () => leave(el, performRemove);
  7706. if (delayLeave) {
  7707. delayLeave(vnode.el, performRemove, performLeave);
  7708. } else {
  7709. performLeave();
  7710. }
  7711. } else {
  7712. performRemove();
  7713. }
  7714. };
  7715. const removeFragment = (cur, end) => {
  7716. let next;
  7717. while (cur !== end) {
  7718. next = hostNextSibling(cur);
  7719. hostRemove(cur);
  7720. cur = next;
  7721. }
  7722. hostRemove(end);
  7723. };
  7724. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7725. if (instance.type.__hmrId) {
  7726. unregisterHMR(instance);
  7727. }
  7728. const { bum, scope, update, subTree, um } = instance;
  7729. if (bum) {
  7730. invokeArrayFns(bum);
  7731. }
  7732. scope.stop();
  7733. if (update) {
  7734. update.active = false;
  7735. unmount(subTree, instance, parentSuspense, doRemove);
  7736. }
  7737. if (um) {
  7738. queuePostRenderEffect(um, parentSuspense);
  7739. }
  7740. queuePostRenderEffect(() => {
  7741. instance.isUnmounted = true;
  7742. }, parentSuspense);
  7743. if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
  7744. parentSuspense.deps--;
  7745. if (parentSuspense.deps === 0) {
  7746. parentSuspense.resolve();
  7747. }
  7748. }
  7749. {
  7750. devtoolsComponentRemoved(instance);
  7751. }
  7752. };
  7753. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7754. for (let i = start; i < children.length; i++) {
  7755. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7756. }
  7757. };
  7758. const getNextHostNode = (vnode) => {
  7759. if (vnode.shapeFlag & 6) {
  7760. return getNextHostNode(vnode.component.subTree);
  7761. }
  7762. if (vnode.shapeFlag & 128) {
  7763. return vnode.suspense.next();
  7764. }
  7765. return hostNextSibling(vnode.anchor || vnode.el);
  7766. };
  7767. const render = (vnode, container, isSVG) => {
  7768. if (vnode == null) {
  7769. if (container._vnode) {
  7770. unmount(container._vnode, null, null, true);
  7771. }
  7772. } else {
  7773. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7774. }
  7775. flushPreFlushCbs();
  7776. flushPostFlushCbs();
  7777. container._vnode = vnode;
  7778. };
  7779. const internals = {
  7780. p: patch,
  7781. um: unmount,
  7782. m: move,
  7783. r: remove,
  7784. mt: mountComponent,
  7785. mc: mountChildren,
  7786. pc: patchChildren,
  7787. pbc: patchBlockChildren,
  7788. n: getNextHostNode,
  7789. o: options
  7790. };
  7791. let hydrate;
  7792. let hydrateNode;
  7793. if (createHydrationFns) {
  7794. [hydrate, hydrateNode] = createHydrationFns(
  7795. internals
  7796. );
  7797. }
  7798. return {
  7799. render,
  7800. hydrate,
  7801. createApp: createAppAPI(render, hydrate)
  7802. };
  7803. }
  7804. function toggleRecurse({ effect, update }, allowed) {
  7805. effect.allowRecurse = update.allowRecurse = allowed;
  7806. }
  7807. function needTransition(parentSuspense, transition) {
  7808. return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
  7809. }
  7810. function traverseStaticChildren(n1, n2, shallow = false) {
  7811. const ch1 = n1.children;
  7812. const ch2 = n2.children;
  7813. if (isArray(ch1) && isArray(ch2)) {
  7814. for (let i = 0; i < ch1.length; i++) {
  7815. const c1 = ch1[i];
  7816. let c2 = ch2[i];
  7817. if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
  7818. if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
  7819. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7820. c2.el = c1.el;
  7821. }
  7822. if (!shallow)
  7823. traverseStaticChildren(c1, c2);
  7824. }
  7825. if (c2.type === Text) {
  7826. c2.el = c1.el;
  7827. }
  7828. if (c2.type === Comment && !c2.el) {
  7829. c2.el = c1.el;
  7830. }
  7831. }
  7832. }
  7833. }
  7834. function getSequence(arr) {
  7835. const p = arr.slice();
  7836. const result = [0];
  7837. let i, j, u, v, c;
  7838. const len = arr.length;
  7839. for (i = 0; i < len; i++) {
  7840. const arrI = arr[i];
  7841. if (arrI !== 0) {
  7842. j = result[result.length - 1];
  7843. if (arr[j] < arrI) {
  7844. p[i] = j;
  7845. result.push(i);
  7846. continue;
  7847. }
  7848. u = 0;
  7849. v = result.length - 1;
  7850. while (u < v) {
  7851. c = u + v >> 1;
  7852. if (arr[result[c]] < arrI) {
  7853. u = c + 1;
  7854. } else {
  7855. v = c;
  7856. }
  7857. }
  7858. if (arrI < arr[result[u]]) {
  7859. if (u > 0) {
  7860. p[i] = result[u - 1];
  7861. }
  7862. result[u] = i;
  7863. }
  7864. }
  7865. }
  7866. u = result.length;
  7867. v = result[u - 1];
  7868. while (u-- > 0) {
  7869. result[u] = v;
  7870. v = p[v];
  7871. }
  7872. return result;
  7873. }
  7874. const isTeleport = (type) => type.__isTeleport;
  7875. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
  7876. const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
  7877. const resolveTarget = (props, select) => {
  7878. const targetSelector = props && props.to;
  7879. if (isString(targetSelector)) {
  7880. if (!select) {
  7881. warn(
  7882. `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
  7883. );
  7884. return null;
  7885. } else {
  7886. const target = select(targetSelector);
  7887. if (!target) {
  7888. warn(
  7889. `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
  7890. );
  7891. }
  7892. return target;
  7893. }
  7894. } else {
  7895. if (!targetSelector && !isTeleportDisabled(props)) {
  7896. warn(`Invalid Teleport target: ${targetSelector}`);
  7897. }
  7898. return targetSelector;
  7899. }
  7900. };
  7901. const TeleportImpl = {
  7902. name: "Teleport",
  7903. __isTeleport: true,
  7904. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7905. const {
  7906. mc: mountChildren,
  7907. pc: patchChildren,
  7908. pbc: patchBlockChildren,
  7909. o: { insert, querySelector, createText, createComment }
  7910. } = internals;
  7911. const disabled = isTeleportDisabled(n2.props);
  7912. let { shapeFlag, children, dynamicChildren } = n2;
  7913. if (isHmrUpdating) {
  7914. optimized = false;
  7915. dynamicChildren = null;
  7916. }
  7917. if (n1 == null) {
  7918. const placeholder = n2.el = createComment("teleport start") ;
  7919. const mainAnchor = n2.anchor = createComment("teleport end") ;
  7920. insert(placeholder, container, anchor);
  7921. insert(mainAnchor, container, anchor);
  7922. const target = n2.target = resolveTarget(n2.props, querySelector);
  7923. const targetAnchor = n2.targetAnchor = createText("");
  7924. if (target) {
  7925. insert(targetAnchor, target);
  7926. isSVG = isSVG || isTargetSVG(target);
  7927. } else if (!disabled) {
  7928. warn("Invalid Teleport target on mount:", target, `(${typeof target})`);
  7929. }
  7930. const mount = (container2, anchor2) => {
  7931. if (shapeFlag & 16) {
  7932. mountChildren(
  7933. children,
  7934. container2,
  7935. anchor2,
  7936. parentComponent,
  7937. parentSuspense,
  7938. isSVG,
  7939. slotScopeIds,
  7940. optimized
  7941. );
  7942. }
  7943. };
  7944. if (disabled) {
  7945. mount(container, mainAnchor);
  7946. } else if (target) {
  7947. mount(target, targetAnchor);
  7948. }
  7949. } else {
  7950. n2.el = n1.el;
  7951. const mainAnchor = n2.anchor = n1.anchor;
  7952. const target = n2.target = n1.target;
  7953. const targetAnchor = n2.targetAnchor = n1.targetAnchor;
  7954. const wasDisabled = isTeleportDisabled(n1.props);
  7955. const currentContainer = wasDisabled ? container : target;
  7956. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7957. isSVG = isSVG || isTargetSVG(target);
  7958. if (dynamicChildren) {
  7959. patchBlockChildren(
  7960. n1.dynamicChildren,
  7961. dynamicChildren,
  7962. currentContainer,
  7963. parentComponent,
  7964. parentSuspense,
  7965. isSVG,
  7966. slotScopeIds
  7967. );
  7968. traverseStaticChildren(n1, n2, true);
  7969. } else if (!optimized) {
  7970. patchChildren(
  7971. n1,
  7972. n2,
  7973. currentContainer,
  7974. currentAnchor,
  7975. parentComponent,
  7976. parentSuspense,
  7977. isSVG,
  7978. slotScopeIds,
  7979. false
  7980. );
  7981. }
  7982. if (disabled) {
  7983. if (!wasDisabled) {
  7984. moveTeleport(
  7985. n2,
  7986. container,
  7987. mainAnchor,
  7988. internals,
  7989. 1
  7990. );
  7991. } else {
  7992. if (n2.props && n1.props && n2.props.to !== n1.props.to) {
  7993. n2.props.to = n1.props.to;
  7994. }
  7995. }
  7996. } else {
  7997. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7998. const nextTarget = n2.target = resolveTarget(
  7999. n2.props,
  8000. querySelector
  8001. );
  8002. if (nextTarget) {
  8003. moveTeleport(
  8004. n2,
  8005. nextTarget,
  8006. null,
  8007. internals,
  8008. 0
  8009. );
  8010. } else {
  8011. warn(
  8012. "Invalid Teleport target on update:",
  8013. target,
  8014. `(${typeof target})`
  8015. );
  8016. }
  8017. } else if (wasDisabled) {
  8018. moveTeleport(
  8019. n2,
  8020. target,
  8021. targetAnchor,
  8022. internals,
  8023. 1
  8024. );
  8025. }
  8026. }
  8027. }
  8028. updateCssVars(n2);
  8029. },
  8030. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  8031. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  8032. if (target) {
  8033. hostRemove(targetAnchor);
  8034. }
  8035. doRemove && hostRemove(anchor);
  8036. if (shapeFlag & 16) {
  8037. const shouldRemove = doRemove || !isTeleportDisabled(props);
  8038. for (let i = 0; i < children.length; i++) {
  8039. const child = children[i];
  8040. unmount(
  8041. child,
  8042. parentComponent,
  8043. parentSuspense,
  8044. shouldRemove,
  8045. !!child.dynamicChildren
  8046. );
  8047. }
  8048. }
  8049. },
  8050. move: moveTeleport,
  8051. hydrate: hydrateTeleport
  8052. };
  8053. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
  8054. if (moveType === 0) {
  8055. insert(vnode.targetAnchor, container, parentAnchor);
  8056. }
  8057. const { el, anchor, shapeFlag, children, props } = vnode;
  8058. const isReorder = moveType === 2;
  8059. if (isReorder) {
  8060. insert(el, container, parentAnchor);
  8061. }
  8062. if (!isReorder || isTeleportDisabled(props)) {
  8063. if (shapeFlag & 16) {
  8064. for (let i = 0; i < children.length; i++) {
  8065. move(
  8066. children[i],
  8067. container,
  8068. parentAnchor,
  8069. 2
  8070. );
  8071. }
  8072. }
  8073. }
  8074. if (isReorder) {
  8075. insert(anchor, container, parentAnchor);
  8076. }
  8077. }
  8078. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
  8079. o: { nextSibling, parentNode, querySelector }
  8080. }, hydrateChildren) {
  8081. const target = vnode.target = resolveTarget(
  8082. vnode.props,
  8083. querySelector
  8084. );
  8085. if (target) {
  8086. const targetNode = target._lpa || target.firstChild;
  8087. if (vnode.shapeFlag & 16) {
  8088. if (isTeleportDisabled(vnode.props)) {
  8089. vnode.anchor = hydrateChildren(
  8090. nextSibling(node),
  8091. vnode,
  8092. parentNode(node),
  8093. parentComponent,
  8094. parentSuspense,
  8095. slotScopeIds,
  8096. optimized
  8097. );
  8098. vnode.targetAnchor = targetNode;
  8099. } else {
  8100. vnode.anchor = nextSibling(node);
  8101. let targetAnchor = targetNode;
  8102. while (targetAnchor) {
  8103. targetAnchor = nextSibling(targetAnchor);
  8104. if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
  8105. vnode.targetAnchor = targetAnchor;
  8106. target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  8107. break;
  8108. }
  8109. }
  8110. hydrateChildren(
  8111. targetNode,
  8112. vnode,
  8113. target,
  8114. parentComponent,
  8115. parentSuspense,
  8116. slotScopeIds,
  8117. optimized
  8118. );
  8119. }
  8120. }
  8121. updateCssVars(vnode);
  8122. }
  8123. return vnode.anchor && nextSibling(vnode.anchor);
  8124. }
  8125. const Teleport = TeleportImpl;
  8126. function updateCssVars(vnode) {
  8127. const ctx = vnode.ctx;
  8128. if (ctx && ctx.ut) {
  8129. let node = vnode.children[0].el;
  8130. while (node && node !== vnode.targetAnchor) {
  8131. if (node.nodeType === 1)
  8132. node.setAttribute("data-v-owner", ctx.uid);
  8133. node = node.nextSibling;
  8134. }
  8135. ctx.ut();
  8136. }
  8137. }
  8138. const Fragment = Symbol.for("v-fgt");
  8139. const Text = Symbol.for("v-txt");
  8140. const Comment = Symbol.for("v-cmt");
  8141. const Static = Symbol.for("v-stc");
  8142. const blockStack = [];
  8143. let currentBlock = null;
  8144. function openBlock(disableTracking = false) {
  8145. blockStack.push(currentBlock = disableTracking ? null : []);
  8146. }
  8147. function closeBlock() {
  8148. blockStack.pop();
  8149. currentBlock = blockStack[blockStack.length - 1] || null;
  8150. }
  8151. let isBlockTreeEnabled = 1;
  8152. function setBlockTracking(value) {
  8153. isBlockTreeEnabled += value;
  8154. }
  8155. function setupBlock(vnode) {
  8156. vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  8157. closeBlock();
  8158. if (isBlockTreeEnabled > 0 && currentBlock) {
  8159. currentBlock.push(vnode);
  8160. }
  8161. return vnode;
  8162. }
  8163. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  8164. return setupBlock(
  8165. createBaseVNode(
  8166. type,
  8167. props,
  8168. children,
  8169. patchFlag,
  8170. dynamicProps,
  8171. shapeFlag,
  8172. true
  8173. /* isBlock */
  8174. )
  8175. );
  8176. }
  8177. function createBlock(type, props, children, patchFlag, dynamicProps) {
  8178. return setupBlock(
  8179. createVNode(
  8180. type,
  8181. props,
  8182. children,
  8183. patchFlag,
  8184. dynamicProps,
  8185. true
  8186. /* isBlock: prevent a block from tracking itself */
  8187. )
  8188. );
  8189. }
  8190. function isVNode(value) {
  8191. return value ? value.__v_isVNode === true : false;
  8192. }
  8193. function isSameVNodeType(n1, n2) {
  8194. if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
  8195. n1.shapeFlag &= ~256;
  8196. n2.shapeFlag &= ~512;
  8197. return false;
  8198. }
  8199. return n1.type === n2.type && n1.key === n2.key;
  8200. }
  8201. let vnodeArgsTransformer;
  8202. function transformVNodeArgs(transformer) {
  8203. vnodeArgsTransformer = transformer;
  8204. }
  8205. const createVNodeWithArgsTransform = (...args) => {
  8206. return _createVNode(
  8207. ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
  8208. );
  8209. };
  8210. const InternalObjectKey = `__vInternal`;
  8211. const normalizeKey = ({ key }) => key != null ? key : null;
  8212. const normalizeRef = ({
  8213. ref,
  8214. ref_key,
  8215. ref_for
  8216. }) => {
  8217. if (typeof ref === "number") {
  8218. ref = "" + ref;
  8219. }
  8220. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
  8221. };
  8222. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
  8223. const vnode = {
  8224. __v_isVNode: true,
  8225. __v_skip: true,
  8226. type,
  8227. props,
  8228. key: props && normalizeKey(props),
  8229. ref: props && normalizeRef(props),
  8230. scopeId: currentScopeId,
  8231. slotScopeIds: null,
  8232. children,
  8233. component: null,
  8234. suspense: null,
  8235. ssContent: null,
  8236. ssFallback: null,
  8237. dirs: null,
  8238. transition: null,
  8239. el: null,
  8240. anchor: null,
  8241. target: null,
  8242. targetAnchor: null,
  8243. staticCount: 0,
  8244. shapeFlag,
  8245. patchFlag,
  8246. dynamicProps,
  8247. dynamicChildren: null,
  8248. appContext: null,
  8249. ctx: currentRenderingInstance
  8250. };
  8251. if (needFullChildrenNormalization) {
  8252. normalizeChildren(vnode, children);
  8253. if (shapeFlag & 128) {
  8254. type.normalize(vnode);
  8255. }
  8256. } else if (children) {
  8257. vnode.shapeFlag |= isString(children) ? 8 : 16;
  8258. }
  8259. if (vnode.key !== vnode.key) {
  8260. warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8261. }
  8262. if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
  8263. !isBlockNode && // has current parent block
  8264. currentBlock && // presence of a patch flag indicates this node needs patching on updates.
  8265. // component nodes also should always be patched, because even if the
  8266. // component doesn't need to update, it needs to persist the instance on to
  8267. // the next vnode so that it can be properly unmounted later.
  8268. (vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
  8269. // vnode should not be considered dynamic due to handler caching.
  8270. vnode.patchFlag !== 32) {
  8271. currentBlock.push(vnode);
  8272. }
  8273. return vnode;
  8274. }
  8275. const createVNode = createVNodeWithArgsTransform ;
  8276. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8277. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8278. if (!type) {
  8279. warn(`Invalid vnode type when creating vnode: ${type}.`);
  8280. }
  8281. type = Comment;
  8282. }
  8283. if (isVNode(type)) {
  8284. const cloned = cloneVNode(
  8285. type,
  8286. props,
  8287. true
  8288. /* mergeRef: true */
  8289. );
  8290. if (children) {
  8291. normalizeChildren(cloned, children);
  8292. }
  8293. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8294. if (cloned.shapeFlag & 6) {
  8295. currentBlock[currentBlock.indexOf(type)] = cloned;
  8296. } else {
  8297. currentBlock.push(cloned);
  8298. }
  8299. }
  8300. cloned.patchFlag |= -2;
  8301. return cloned;
  8302. }
  8303. if (isClassComponent(type)) {
  8304. type = type.__vccOpts;
  8305. }
  8306. if (props) {
  8307. props = guardReactiveProps(props);
  8308. let { class: klass, style } = props;
  8309. if (klass && !isString(klass)) {
  8310. props.class = normalizeClass(klass);
  8311. }
  8312. if (isObject(style)) {
  8313. if (isProxy(style) && !isArray(style)) {
  8314. style = extend({}, style);
  8315. }
  8316. props.style = normalizeStyle(style);
  8317. }
  8318. }
  8319. const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
  8320. if (shapeFlag & 4 && isProxy(type)) {
  8321. type = toRaw(type);
  8322. warn(
  8323. `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
  8324. `
  8325. Component that was made reactive: `,
  8326. type
  8327. );
  8328. }
  8329. return createBaseVNode(
  8330. type,
  8331. props,
  8332. children,
  8333. patchFlag,
  8334. dynamicProps,
  8335. shapeFlag,
  8336. isBlockNode,
  8337. true
  8338. );
  8339. }
  8340. function guardReactiveProps(props) {
  8341. if (!props)
  8342. return null;
  8343. return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
  8344. }
  8345. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8346. const { props, ref, patchFlag, children } = vnode;
  8347. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8348. const cloned = {
  8349. __v_isVNode: true,
  8350. __v_skip: true,
  8351. type: vnode.type,
  8352. props: mergedProps,
  8353. key: mergedProps && normalizeKey(mergedProps),
  8354. ref: extraProps && extraProps.ref ? (
  8355. // #2078 in the case of <component :is="vnode" ref="extra"/>
  8356. // if the vnode itself already has a ref, cloneVNode will need to merge
  8357. // the refs so the single vnode can be set on multiple refs
  8358. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
  8359. ) : ref,
  8360. scopeId: vnode.scopeId,
  8361. slotScopeIds: vnode.slotScopeIds,
  8362. children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
  8363. target: vnode.target,
  8364. targetAnchor: vnode.targetAnchor,
  8365. staticCount: vnode.staticCount,
  8366. shapeFlag: vnode.shapeFlag,
  8367. // if the vnode is cloned with extra props, we can no longer assume its
  8368. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8369. // note: preserve flag for fragments since they use the flag for children
  8370. // fast paths only.
  8371. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
  8372. dynamicProps: vnode.dynamicProps,
  8373. dynamicChildren: vnode.dynamicChildren,
  8374. appContext: vnode.appContext,
  8375. dirs: vnode.dirs,
  8376. transition: vnode.transition,
  8377. // These should technically only be non-null on mounted VNodes. However,
  8378. // they *should* be copied for kept-alive vnodes. So we just always copy
  8379. // them since them being non-null during a mount doesn't affect the logic as
  8380. // they will simply be overwritten.
  8381. component: vnode.component,
  8382. suspense: vnode.suspense,
  8383. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8384. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8385. el: vnode.el,
  8386. anchor: vnode.anchor,
  8387. ctx: vnode.ctx,
  8388. ce: vnode.ce
  8389. };
  8390. return cloned;
  8391. }
  8392. function deepCloneVNode(vnode) {
  8393. const cloned = cloneVNode(vnode);
  8394. if (isArray(vnode.children)) {
  8395. cloned.children = vnode.children.map(deepCloneVNode);
  8396. }
  8397. return cloned;
  8398. }
  8399. function createTextVNode(text = " ", flag = 0) {
  8400. return createVNode(Text, null, text, flag);
  8401. }
  8402. function createStaticVNode(content, numberOfNodes) {
  8403. const vnode = createVNode(Static, null, content);
  8404. vnode.staticCount = numberOfNodes;
  8405. return vnode;
  8406. }
  8407. function createCommentVNode(text = "", asBlock = false) {
  8408. return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
  8409. }
  8410. function normalizeVNode(child) {
  8411. if (child == null || typeof child === "boolean") {
  8412. return createVNode(Comment);
  8413. } else if (isArray(child)) {
  8414. return createVNode(
  8415. Fragment,
  8416. null,
  8417. // #3666, avoid reference pollution when reusing vnode
  8418. child.slice()
  8419. );
  8420. } else if (typeof child === "object") {
  8421. return cloneIfMounted(child);
  8422. } else {
  8423. return createVNode(Text, null, String(child));
  8424. }
  8425. }
  8426. function cloneIfMounted(child) {
  8427. return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
  8428. }
  8429. function normalizeChildren(vnode, children) {
  8430. let type = 0;
  8431. const { shapeFlag } = vnode;
  8432. if (children == null) {
  8433. children = null;
  8434. } else if (isArray(children)) {
  8435. type = 16;
  8436. } else if (typeof children === "object") {
  8437. if (shapeFlag & (1 | 64)) {
  8438. const slot = children.default;
  8439. if (slot) {
  8440. slot._c && (slot._d = false);
  8441. normalizeChildren(vnode, slot());
  8442. slot._c && (slot._d = true);
  8443. }
  8444. return;
  8445. } else {
  8446. type = 32;
  8447. const slotFlag = children._;
  8448. if (!slotFlag && !(InternalObjectKey in children)) {
  8449. children._ctx = currentRenderingInstance;
  8450. } else if (slotFlag === 3 && currentRenderingInstance) {
  8451. if (currentRenderingInstance.slots._ === 1) {
  8452. children._ = 1;
  8453. } else {
  8454. children._ = 2;
  8455. vnode.patchFlag |= 1024;
  8456. }
  8457. }
  8458. }
  8459. } else if (isFunction(children)) {
  8460. children = { default: children, _ctx: currentRenderingInstance };
  8461. type = 32;
  8462. } else {
  8463. children = String(children);
  8464. if (shapeFlag & 64) {
  8465. type = 16;
  8466. children = [createTextVNode(children)];
  8467. } else {
  8468. type = 8;
  8469. }
  8470. }
  8471. vnode.children = children;
  8472. vnode.shapeFlag |= type;
  8473. }
  8474. function mergeProps(...args) {
  8475. const ret = {};
  8476. for (let i = 0; i < args.length; i++) {
  8477. const toMerge = args[i];
  8478. for (const key in toMerge) {
  8479. if (key === "class") {
  8480. if (ret.class !== toMerge.class) {
  8481. ret.class = normalizeClass([ret.class, toMerge.class]);
  8482. }
  8483. } else if (key === "style") {
  8484. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8485. } else if (isOn(key)) {
  8486. const existing = ret[key];
  8487. const incoming = toMerge[key];
  8488. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
  8489. ret[key] = existing ? [].concat(existing, incoming) : incoming;
  8490. }
  8491. } else if (key !== "") {
  8492. ret[key] = toMerge[key];
  8493. }
  8494. }
  8495. }
  8496. return ret;
  8497. }
  8498. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8499. callWithAsyncErrorHandling(hook, instance, 7, [
  8500. vnode,
  8501. prevVNode
  8502. ]);
  8503. }
  8504. const emptyAppContext = createAppContext();
  8505. let uid = 0;
  8506. function createComponentInstance(vnode, parent, suspense) {
  8507. const type = vnode.type;
  8508. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8509. const instance = {
  8510. uid: uid++,
  8511. vnode,
  8512. type,
  8513. parent,
  8514. appContext,
  8515. root: null,
  8516. // to be immediately set
  8517. next: null,
  8518. subTree: null,
  8519. // will be set synchronously right after creation
  8520. effect: null,
  8521. update: null,
  8522. // will be set synchronously right after creation
  8523. scope: new EffectScope(
  8524. true
  8525. /* detached */
  8526. ),
  8527. render: null,
  8528. proxy: null,
  8529. exposed: null,
  8530. exposeProxy: null,
  8531. withProxy: null,
  8532. provides: parent ? parent.provides : Object.create(appContext.provides),
  8533. accessCache: null,
  8534. renderCache: [],
  8535. // local resolved assets
  8536. components: null,
  8537. directives: null,
  8538. // resolved props and emits options
  8539. propsOptions: normalizePropsOptions(type, appContext),
  8540. emitsOptions: normalizeEmitsOptions(type, appContext),
  8541. // emit
  8542. emit: null,
  8543. // to be set immediately
  8544. emitted: null,
  8545. // props default value
  8546. propsDefaults: EMPTY_OBJ,
  8547. // inheritAttrs
  8548. inheritAttrs: type.inheritAttrs,
  8549. // state
  8550. ctx: EMPTY_OBJ,
  8551. data: EMPTY_OBJ,
  8552. props: EMPTY_OBJ,
  8553. attrs: EMPTY_OBJ,
  8554. slots: EMPTY_OBJ,
  8555. refs: EMPTY_OBJ,
  8556. setupState: EMPTY_OBJ,
  8557. setupContext: null,
  8558. attrsProxy: null,
  8559. slotsProxy: null,
  8560. // suspense related
  8561. suspense,
  8562. suspenseId: suspense ? suspense.pendingId : 0,
  8563. asyncDep: null,
  8564. asyncResolved: false,
  8565. // lifecycle hooks
  8566. // not using enums here because it results in computed properties
  8567. isMounted: false,
  8568. isUnmounted: false,
  8569. isDeactivated: false,
  8570. bc: null,
  8571. c: null,
  8572. bm: null,
  8573. m: null,
  8574. bu: null,
  8575. u: null,
  8576. um: null,
  8577. bum: null,
  8578. da: null,
  8579. a: null,
  8580. rtg: null,
  8581. rtc: null,
  8582. ec: null,
  8583. sp: null
  8584. };
  8585. {
  8586. instance.ctx = createDevRenderContext(instance);
  8587. }
  8588. instance.root = parent ? parent.root : instance;
  8589. instance.emit = emit.bind(null, instance);
  8590. if (vnode.ce) {
  8591. vnode.ce(instance);
  8592. }
  8593. return instance;
  8594. }
  8595. let currentInstance = null;
  8596. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8597. let internalSetCurrentInstance;
  8598. {
  8599. internalSetCurrentInstance = (i) => {
  8600. currentInstance = i;
  8601. };
  8602. }
  8603. const setCurrentInstance = (instance) => {
  8604. internalSetCurrentInstance(instance);
  8605. instance.scope.on();
  8606. };
  8607. const unsetCurrentInstance = () => {
  8608. currentInstance && currentInstance.scope.off();
  8609. internalSetCurrentInstance(null);
  8610. };
  8611. const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
  8612. function validateComponentName(name, config) {
  8613. const appIsNativeTag = config.isNativeTag || NO;
  8614. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8615. warn(
  8616. "Do not use built-in or reserved HTML elements as component id: " + name
  8617. );
  8618. }
  8619. }
  8620. function isStatefulComponent(instance) {
  8621. return instance.vnode.shapeFlag & 4;
  8622. }
  8623. let isInSSRComponentSetup = false;
  8624. function setupComponent(instance, isSSR = false) {
  8625. isInSSRComponentSetup = isSSR;
  8626. const { props, children } = instance.vnode;
  8627. const isStateful = isStatefulComponent(instance);
  8628. initProps(instance, props, isStateful, isSSR);
  8629. initSlots(instance, children);
  8630. const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
  8631. isInSSRComponentSetup = false;
  8632. return setupResult;
  8633. }
  8634. function setupStatefulComponent(instance, isSSR) {
  8635. var _a;
  8636. const Component = instance.type;
  8637. {
  8638. if (Component.name) {
  8639. validateComponentName(Component.name, instance.appContext.config);
  8640. }
  8641. if (Component.components) {
  8642. const names = Object.keys(Component.components);
  8643. for (let i = 0; i < names.length; i++) {
  8644. validateComponentName(names[i], instance.appContext.config);
  8645. }
  8646. }
  8647. if (Component.directives) {
  8648. const names = Object.keys(Component.directives);
  8649. for (let i = 0; i < names.length; i++) {
  8650. validateDirectiveName(names[i]);
  8651. }
  8652. }
  8653. if (Component.compilerOptions && isRuntimeOnly()) {
  8654. warn(
  8655. `"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
  8656. );
  8657. }
  8658. }
  8659. instance.accessCache = /* @__PURE__ */ Object.create(null);
  8660. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8661. {
  8662. exposePropsOnRenderContext(instance);
  8663. }
  8664. const { setup } = Component;
  8665. if (setup) {
  8666. const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
  8667. setCurrentInstance(instance);
  8668. pauseTracking();
  8669. const setupResult = callWithErrorHandling(
  8670. setup,
  8671. instance,
  8672. 0,
  8673. [shallowReadonly(instance.props) , setupContext]
  8674. );
  8675. resetTracking();
  8676. unsetCurrentInstance();
  8677. if (isPromise(setupResult)) {
  8678. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8679. if (isSSR) {
  8680. return setupResult.then((resolvedResult) => {
  8681. handleSetupResult(instance, resolvedResult, isSSR);
  8682. }).catch((e) => {
  8683. handleError(e, instance, 0);
  8684. });
  8685. } else {
  8686. instance.asyncDep = setupResult;
  8687. if (!instance.suspense) {
  8688. const name = (_a = Component.name) != null ? _a : "Anonymous";
  8689. warn(
  8690. `Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
  8691. );
  8692. }
  8693. }
  8694. } else {
  8695. handleSetupResult(instance, setupResult, isSSR);
  8696. }
  8697. } else {
  8698. finishComponentSetup(instance, isSSR);
  8699. }
  8700. }
  8701. function handleSetupResult(instance, setupResult, isSSR) {
  8702. if (isFunction(setupResult)) {
  8703. {
  8704. instance.render = setupResult;
  8705. }
  8706. } else if (isObject(setupResult)) {
  8707. if (isVNode(setupResult)) {
  8708. warn(
  8709. `setup() should not return VNodes directly - return a render function instead.`
  8710. );
  8711. }
  8712. {
  8713. instance.devtoolsRawSetupState = setupResult;
  8714. }
  8715. instance.setupState = proxyRefs(setupResult);
  8716. {
  8717. exposeSetupStateOnRenderContext(instance);
  8718. }
  8719. } else if (setupResult !== void 0) {
  8720. warn(
  8721. `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
  8722. );
  8723. }
  8724. finishComponentSetup(instance, isSSR);
  8725. }
  8726. let compile$1;
  8727. let installWithProxy;
  8728. function registerRuntimeCompiler(_compile) {
  8729. compile$1 = _compile;
  8730. installWithProxy = (i) => {
  8731. if (i.render._rc) {
  8732. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8733. }
  8734. };
  8735. }
  8736. const isRuntimeOnly = () => !compile$1;
  8737. function finishComponentSetup(instance, isSSR, skipOptions) {
  8738. const Component = instance.type;
  8739. if (!instance.render) {
  8740. if (!isSSR && compile$1 && !Component.render) {
  8741. const template = Component.template || resolveMergedOptions(instance).template;
  8742. if (template) {
  8743. {
  8744. startMeasure(instance, `compile`);
  8745. }
  8746. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8747. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8748. const finalCompilerOptions = extend(
  8749. extend(
  8750. {
  8751. isCustomElement,
  8752. delimiters
  8753. },
  8754. compilerOptions
  8755. ),
  8756. componentCompilerOptions
  8757. );
  8758. Component.render = compile$1(template, finalCompilerOptions);
  8759. {
  8760. endMeasure(instance, `compile`);
  8761. }
  8762. }
  8763. }
  8764. instance.render = Component.render || NOOP;
  8765. if (installWithProxy) {
  8766. installWithProxy(instance);
  8767. }
  8768. }
  8769. {
  8770. setCurrentInstance(instance);
  8771. pauseTracking();
  8772. try {
  8773. applyOptions(instance);
  8774. } finally {
  8775. resetTracking();
  8776. unsetCurrentInstance();
  8777. }
  8778. }
  8779. if (!Component.render && instance.render === NOOP && !isSSR) {
  8780. if (!compile$1 && Component.template) {
  8781. warn(
  8782. `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.global.js" instead.` )
  8783. /* should not happen */
  8784. );
  8785. } else {
  8786. warn(`Component is missing template or render function.`);
  8787. }
  8788. }
  8789. }
  8790. function getAttrsProxy(instance) {
  8791. return instance.attrsProxy || (instance.attrsProxy = new Proxy(
  8792. instance.attrs,
  8793. {
  8794. get(target, key) {
  8795. markAttrsAccessed();
  8796. track(instance, "get", "$attrs");
  8797. return target[key];
  8798. },
  8799. set() {
  8800. warn(`setupContext.attrs is readonly.`);
  8801. return false;
  8802. },
  8803. deleteProperty() {
  8804. warn(`setupContext.attrs is readonly.`);
  8805. return false;
  8806. }
  8807. }
  8808. ));
  8809. }
  8810. function getSlotsProxy(instance) {
  8811. return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
  8812. get(target, key) {
  8813. track(instance, "get", "$slots");
  8814. return target[key];
  8815. }
  8816. }));
  8817. }
  8818. function createSetupContext(instance) {
  8819. const expose = (exposed) => {
  8820. {
  8821. if (instance.exposed) {
  8822. warn(`expose() should be called only once per setup().`);
  8823. }
  8824. if (exposed != null) {
  8825. let exposedType = typeof exposed;
  8826. if (exposedType === "object") {
  8827. if (isArray(exposed)) {
  8828. exposedType = "array";
  8829. } else if (isRef(exposed)) {
  8830. exposedType = "ref";
  8831. }
  8832. }
  8833. if (exposedType !== "object") {
  8834. warn(
  8835. `expose() should be passed a plain object, received ${exposedType}.`
  8836. );
  8837. }
  8838. }
  8839. }
  8840. instance.exposed = exposed || {};
  8841. };
  8842. {
  8843. return Object.freeze({
  8844. get attrs() {
  8845. return getAttrsProxy(instance);
  8846. },
  8847. get slots() {
  8848. return getSlotsProxy(instance);
  8849. },
  8850. get emit() {
  8851. return (event, ...args) => instance.emit(event, ...args);
  8852. },
  8853. expose
  8854. });
  8855. }
  8856. }
  8857. function getExposeProxy(instance) {
  8858. if (instance.exposed) {
  8859. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8860. get(target, key) {
  8861. if (key in target) {
  8862. return target[key];
  8863. } else if (key in publicPropertiesMap) {
  8864. return publicPropertiesMap[key](instance);
  8865. }
  8866. },
  8867. has(target, key) {
  8868. return key in target || key in publicPropertiesMap;
  8869. }
  8870. }));
  8871. }
  8872. }
  8873. const classifyRE = /(?:^|[-_])(\w)/g;
  8874. const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
  8875. function getComponentName(Component, includeInferred = true) {
  8876. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
  8877. }
  8878. function formatComponentName(instance, Component, isRoot = false) {
  8879. let name = getComponentName(Component);
  8880. if (!name && Component.__file) {
  8881. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8882. if (match) {
  8883. name = match[1];
  8884. }
  8885. }
  8886. if (!name && instance && instance.parent) {
  8887. const inferFromRegistry = (registry) => {
  8888. for (const key in registry) {
  8889. if (registry[key] === Component) {
  8890. return key;
  8891. }
  8892. }
  8893. };
  8894. name = inferFromRegistry(
  8895. instance.components || instance.parent.type.components
  8896. ) || inferFromRegistry(instance.appContext.components);
  8897. }
  8898. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8899. }
  8900. function isClassComponent(value) {
  8901. return isFunction(value) && "__vccOpts" in value;
  8902. }
  8903. const computed = (getterOrOptions, debugOptions) => {
  8904. return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8905. };
  8906. function h(type, propsOrChildren, children) {
  8907. const l = arguments.length;
  8908. if (l === 2) {
  8909. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8910. if (isVNode(propsOrChildren)) {
  8911. return createVNode(type, null, [propsOrChildren]);
  8912. }
  8913. return createVNode(type, propsOrChildren);
  8914. } else {
  8915. return createVNode(type, null, propsOrChildren);
  8916. }
  8917. } else {
  8918. if (l > 3) {
  8919. children = Array.prototype.slice.call(arguments, 2);
  8920. } else if (l === 3 && isVNode(children)) {
  8921. children = [children];
  8922. }
  8923. return createVNode(type, propsOrChildren, children);
  8924. }
  8925. }
  8926. const ssrContextKey = Symbol.for("v-scx");
  8927. const useSSRContext = () => {
  8928. {
  8929. warn(`useSSRContext() is not supported in the global build.`);
  8930. }
  8931. };
  8932. function initCustomFormatter() {
  8933. if (typeof window === "undefined") {
  8934. return;
  8935. }
  8936. const vueStyle = { style: "color:#3ba776" };
  8937. const numberStyle = { style: "color:#1677ff" };
  8938. const stringStyle = { style: "color:#f5222d" };
  8939. const keywordStyle = { style: "color:#eb2f96" };
  8940. const formatter = {
  8941. header(obj) {
  8942. if (!isObject(obj)) {
  8943. return null;
  8944. }
  8945. if (obj.__isVue) {
  8946. return ["div", vueStyle, `VueInstance`];
  8947. } else if (isRef(obj)) {
  8948. return [
  8949. "div",
  8950. {},
  8951. ["span", vueStyle, genRefFlag(obj)],
  8952. "<",
  8953. formatValue(obj.value),
  8954. `>`
  8955. ];
  8956. } else if (isReactive(obj)) {
  8957. return [
  8958. "div",
  8959. {},
  8960. ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
  8961. "<",
  8962. formatValue(obj),
  8963. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8964. ];
  8965. } else if (isReadonly(obj)) {
  8966. return [
  8967. "div",
  8968. {},
  8969. ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
  8970. "<",
  8971. formatValue(obj),
  8972. ">"
  8973. ];
  8974. }
  8975. return null;
  8976. },
  8977. hasBody(obj) {
  8978. return obj && obj.__isVue;
  8979. },
  8980. body(obj) {
  8981. if (obj && obj.__isVue) {
  8982. return [
  8983. "div",
  8984. {},
  8985. ...formatInstance(obj.$)
  8986. ];
  8987. }
  8988. }
  8989. };
  8990. function formatInstance(instance) {
  8991. const blocks = [];
  8992. if (instance.type.props && instance.props) {
  8993. blocks.push(createInstanceBlock("props", toRaw(instance.props)));
  8994. }
  8995. if (instance.setupState !== EMPTY_OBJ) {
  8996. blocks.push(createInstanceBlock("setup", instance.setupState));
  8997. }
  8998. if (instance.data !== EMPTY_OBJ) {
  8999. blocks.push(createInstanceBlock("data", toRaw(instance.data)));
  9000. }
  9001. const computed = extractKeys(instance, "computed");
  9002. if (computed) {
  9003. blocks.push(createInstanceBlock("computed", computed));
  9004. }
  9005. const injected = extractKeys(instance, "inject");
  9006. if (injected) {
  9007. blocks.push(createInstanceBlock("injected", injected));
  9008. }
  9009. blocks.push([
  9010. "div",
  9011. {},
  9012. [
  9013. "span",
  9014. {
  9015. style: keywordStyle.style + ";opacity:0.66"
  9016. },
  9017. "$ (internal): "
  9018. ],
  9019. ["object", { object: instance }]
  9020. ]);
  9021. return blocks;
  9022. }
  9023. function createInstanceBlock(type, target) {
  9024. target = extend({}, target);
  9025. if (!Object.keys(target).length) {
  9026. return ["span", {}];
  9027. }
  9028. return [
  9029. "div",
  9030. { style: "line-height:1.25em;margin-bottom:0.6em" },
  9031. [
  9032. "div",
  9033. {
  9034. style: "color:#476582"
  9035. },
  9036. type
  9037. ],
  9038. [
  9039. "div",
  9040. {
  9041. style: "padding-left:1.25em"
  9042. },
  9043. ...Object.keys(target).map((key) => {
  9044. return [
  9045. "div",
  9046. {},
  9047. ["span", keywordStyle, key + ": "],
  9048. formatValue(target[key], false)
  9049. ];
  9050. })
  9051. ]
  9052. ];
  9053. }
  9054. function formatValue(v, asRaw = true) {
  9055. if (typeof v === "number") {
  9056. return ["span", numberStyle, v];
  9057. } else if (typeof v === "string") {
  9058. return ["span", stringStyle, JSON.stringify(v)];
  9059. } else if (typeof v === "boolean") {
  9060. return ["span", keywordStyle, v];
  9061. } else if (isObject(v)) {
  9062. return ["object", { object: asRaw ? toRaw(v) : v }];
  9063. } else {
  9064. return ["span", stringStyle, String(v)];
  9065. }
  9066. }
  9067. function extractKeys(instance, type) {
  9068. const Comp = instance.type;
  9069. if (isFunction(Comp)) {
  9070. return;
  9071. }
  9072. const extracted = {};
  9073. for (const key in instance.ctx) {
  9074. if (isKeyOfType(Comp, key, type)) {
  9075. extracted[key] = instance.ctx[key];
  9076. }
  9077. }
  9078. return extracted;
  9079. }
  9080. function isKeyOfType(Comp, key, type) {
  9081. const opts = Comp[type];
  9082. if (isArray(opts) && opts.includes(key) || 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. } else {
  9104. window.devtoolsFormatters = [formatter];
  9105. }
  9106. }
  9107. function withMemo(memo, render, cache, index) {
  9108. const cached = cache[index];
  9109. if (cached && isMemoSame(cached, memo)) {
  9110. return cached;
  9111. }
  9112. const ret = render();
  9113. ret.memo = memo.slice();
  9114. return cache[index] = ret;
  9115. }
  9116. function isMemoSame(cached, memo) {
  9117. const prev = cached.memo;
  9118. if (prev.length != memo.length) {
  9119. return false;
  9120. }
  9121. for (let i = 0; i < prev.length; i++) {
  9122. if (hasChanged(prev[i], memo[i])) {
  9123. return false;
  9124. }
  9125. }
  9126. if (isBlockTreeEnabled > 0 && currentBlock) {
  9127. currentBlock.push(cached);
  9128. }
  9129. return true;
  9130. }
  9131. const version = "3.3.11";
  9132. const ssrUtils = null;
  9133. const resolveFilter = null;
  9134. const compatUtils = null;
  9135. const svgNS = "http://www.w3.org/2000/svg";
  9136. const doc = typeof document !== "undefined" ? document : null;
  9137. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  9138. const nodeOps = {
  9139. insert: (child, parent, anchor) => {
  9140. parent.insertBefore(child, anchor || null);
  9141. },
  9142. remove: (child) => {
  9143. const parent = child.parentNode;
  9144. if (parent) {
  9145. parent.removeChild(child);
  9146. }
  9147. },
  9148. createElement: (tag, isSVG, is, props) => {
  9149. const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
  9150. if (tag === "select" && props && props.multiple != null) {
  9151. el.setAttribute("multiple", props.multiple);
  9152. }
  9153. return el;
  9154. },
  9155. createText: (text) => doc.createTextNode(text),
  9156. createComment: (text) => doc.createComment(text),
  9157. setText: (node, text) => {
  9158. node.nodeValue = text;
  9159. },
  9160. setElementText: (el, text) => {
  9161. el.textContent = text;
  9162. },
  9163. parentNode: (node) => node.parentNode,
  9164. nextSibling: (node) => node.nextSibling,
  9165. querySelector: (selector) => doc.querySelector(selector),
  9166. setScopeId(el, id) {
  9167. el.setAttribute(id, "");
  9168. },
  9169. // __UNSAFE__
  9170. // Reason: innerHTML.
  9171. // Static content here can only come from compiled templates.
  9172. // As long as the user only uses trusted templates, this is safe.
  9173. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9174. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9175. if (start && (start === end || start.nextSibling)) {
  9176. while (true) {
  9177. parent.insertBefore(start.cloneNode(true), anchor);
  9178. if (start === end || !(start = start.nextSibling))
  9179. break;
  9180. }
  9181. } else {
  9182. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9183. const template = templateContainer.content;
  9184. if (isSVG) {
  9185. const wrapper = template.firstChild;
  9186. while (wrapper.firstChild) {
  9187. template.appendChild(wrapper.firstChild);
  9188. }
  9189. template.removeChild(wrapper);
  9190. }
  9191. parent.insertBefore(template, anchor);
  9192. }
  9193. return [
  9194. // first
  9195. before ? before.nextSibling : parent.firstChild,
  9196. // last
  9197. anchor ? anchor.previousSibling : parent.lastChild
  9198. ];
  9199. }
  9200. };
  9201. const TRANSITION$1 = "transition";
  9202. const ANIMATION = "animation";
  9203. const vtcKey = Symbol("_vtc");
  9204. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9205. Transition.displayName = "Transition";
  9206. const DOMTransitionPropsValidators = {
  9207. name: String,
  9208. type: String,
  9209. css: {
  9210. type: Boolean,
  9211. default: true
  9212. },
  9213. duration: [String, Number, Object],
  9214. enterFromClass: String,
  9215. enterActiveClass: String,
  9216. enterToClass: String,
  9217. appearFromClass: String,
  9218. appearActiveClass: String,
  9219. appearToClass: String,
  9220. leaveFromClass: String,
  9221. leaveActiveClass: String,
  9222. leaveToClass: String
  9223. };
  9224. const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
  9225. {},
  9226. BaseTransitionPropsValidators,
  9227. DOMTransitionPropsValidators
  9228. );
  9229. const callHook = (hook, args = []) => {
  9230. if (isArray(hook)) {
  9231. hook.forEach((h2) => h2(...args));
  9232. } else if (hook) {
  9233. hook(...args);
  9234. }
  9235. };
  9236. const hasExplicitCallback = (hook) => {
  9237. return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  9238. };
  9239. function resolveTransitionProps(rawProps) {
  9240. const baseProps = {};
  9241. for (const key in rawProps) {
  9242. if (!(key in DOMTransitionPropsValidators)) {
  9243. baseProps[key] = rawProps[key];
  9244. }
  9245. }
  9246. if (rawProps.css === false) {
  9247. return baseProps;
  9248. }
  9249. const {
  9250. name = "v",
  9251. type,
  9252. duration,
  9253. enterFromClass = `${name}-enter-from`,
  9254. enterActiveClass = `${name}-enter-active`,
  9255. enterToClass = `${name}-enter-to`,
  9256. appearFromClass = enterFromClass,
  9257. appearActiveClass = enterActiveClass,
  9258. appearToClass = enterToClass,
  9259. leaveFromClass = `${name}-leave-from`,
  9260. leaveActiveClass = `${name}-leave-active`,
  9261. leaveToClass = `${name}-leave-to`
  9262. } = rawProps;
  9263. const durations = normalizeDuration(duration);
  9264. const enterDuration = durations && durations[0];
  9265. const leaveDuration = durations && durations[1];
  9266. const {
  9267. onBeforeEnter,
  9268. onEnter,
  9269. onEnterCancelled,
  9270. onLeave,
  9271. onLeaveCancelled,
  9272. onBeforeAppear = onBeforeEnter,
  9273. onAppear = onEnter,
  9274. onAppearCancelled = onEnterCancelled
  9275. } = baseProps;
  9276. const finishEnter = (el, isAppear, done) => {
  9277. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9278. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9279. done && done();
  9280. };
  9281. const finishLeave = (el, done) => {
  9282. el._isLeaving = false;
  9283. removeTransitionClass(el, leaveFromClass);
  9284. removeTransitionClass(el, leaveToClass);
  9285. removeTransitionClass(el, leaveActiveClass);
  9286. done && done();
  9287. };
  9288. const makeEnterHook = (isAppear) => {
  9289. return (el, done) => {
  9290. const hook = isAppear ? onAppear : onEnter;
  9291. const resolve = () => finishEnter(el, isAppear, done);
  9292. callHook(hook, [el, resolve]);
  9293. nextFrame(() => {
  9294. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9295. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9296. if (!hasExplicitCallback(hook)) {
  9297. whenTransitionEnds(el, type, enterDuration, resolve);
  9298. }
  9299. });
  9300. };
  9301. };
  9302. return extend(baseProps, {
  9303. onBeforeEnter(el) {
  9304. callHook(onBeforeEnter, [el]);
  9305. addTransitionClass(el, enterFromClass);
  9306. addTransitionClass(el, enterActiveClass);
  9307. },
  9308. onBeforeAppear(el) {
  9309. callHook(onBeforeAppear, [el]);
  9310. addTransitionClass(el, appearFromClass);
  9311. addTransitionClass(el, appearActiveClass);
  9312. },
  9313. onEnter: makeEnterHook(false),
  9314. onAppear: makeEnterHook(true),
  9315. onLeave(el, done) {
  9316. el._isLeaving = true;
  9317. const resolve = () => finishLeave(el, done);
  9318. addTransitionClass(el, leaveFromClass);
  9319. forceReflow();
  9320. addTransitionClass(el, leaveActiveClass);
  9321. nextFrame(() => {
  9322. if (!el._isLeaving) {
  9323. return;
  9324. }
  9325. removeTransitionClass(el, leaveFromClass);
  9326. addTransitionClass(el, leaveToClass);
  9327. if (!hasExplicitCallback(onLeave)) {
  9328. whenTransitionEnds(el, type, leaveDuration, resolve);
  9329. }
  9330. });
  9331. callHook(onLeave, [el, resolve]);
  9332. },
  9333. onEnterCancelled(el) {
  9334. finishEnter(el, false);
  9335. callHook(onEnterCancelled, [el]);
  9336. },
  9337. onAppearCancelled(el) {
  9338. finishEnter(el, true);
  9339. callHook(onAppearCancelled, [el]);
  9340. },
  9341. onLeaveCancelled(el) {
  9342. finishLeave(el);
  9343. callHook(onLeaveCancelled, [el]);
  9344. }
  9345. });
  9346. }
  9347. function normalizeDuration(duration) {
  9348. if (duration == null) {
  9349. return null;
  9350. } else if (isObject(duration)) {
  9351. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  9352. } else {
  9353. const n = NumberOf(duration);
  9354. return [n, n];
  9355. }
  9356. }
  9357. function NumberOf(val) {
  9358. const res = toNumber(val);
  9359. {
  9360. assertNumber(res, "<transition> explicit duration");
  9361. }
  9362. return res;
  9363. }
  9364. function addTransitionClass(el, cls) {
  9365. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  9366. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
  9367. }
  9368. function removeTransitionClass(el, cls) {
  9369. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  9370. const _vtc = el[vtcKey];
  9371. if (_vtc) {
  9372. _vtc.delete(cls);
  9373. if (!_vtc.size) {
  9374. el[vtcKey] = void 0;
  9375. }
  9376. }
  9377. }
  9378. function nextFrame(cb) {
  9379. requestAnimationFrame(() => {
  9380. requestAnimationFrame(cb);
  9381. });
  9382. }
  9383. let endId = 0;
  9384. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  9385. const id = el._endId = ++endId;
  9386. const resolveIfNotStale = () => {
  9387. if (id === el._endId) {
  9388. resolve();
  9389. }
  9390. };
  9391. if (explicitTimeout) {
  9392. return setTimeout(resolveIfNotStale, explicitTimeout);
  9393. }
  9394. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  9395. if (!type) {
  9396. return resolve();
  9397. }
  9398. const endEvent = type + "end";
  9399. let ended = 0;
  9400. const end = () => {
  9401. el.removeEventListener(endEvent, onEnd);
  9402. resolveIfNotStale();
  9403. };
  9404. const onEnd = (e) => {
  9405. if (e.target === el && ++ended >= propCount) {
  9406. end();
  9407. }
  9408. };
  9409. setTimeout(() => {
  9410. if (ended < propCount) {
  9411. end();
  9412. }
  9413. }, timeout + 1);
  9414. el.addEventListener(endEvent, onEnd);
  9415. }
  9416. function getTransitionInfo(el, expectedType) {
  9417. const styles = window.getComputedStyle(el);
  9418. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  9419. const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
  9420. const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
  9421. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  9422. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  9423. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  9424. const animationTimeout = getTimeout(animationDelays, animationDurations);
  9425. let type = null;
  9426. let timeout = 0;
  9427. let propCount = 0;
  9428. if (expectedType === TRANSITION$1) {
  9429. if (transitionTimeout > 0) {
  9430. type = TRANSITION$1;
  9431. timeout = transitionTimeout;
  9432. propCount = transitionDurations.length;
  9433. }
  9434. } else if (expectedType === ANIMATION) {
  9435. if (animationTimeout > 0) {
  9436. type = ANIMATION;
  9437. timeout = animationTimeout;
  9438. propCount = animationDurations.length;
  9439. }
  9440. } else {
  9441. timeout = Math.max(transitionTimeout, animationTimeout);
  9442. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
  9443. propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
  9444. }
  9445. const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
  9446. getStyleProperties(`${TRANSITION$1}Property`).toString()
  9447. );
  9448. return {
  9449. type,
  9450. timeout,
  9451. propCount,
  9452. hasTransform
  9453. };
  9454. }
  9455. function getTimeout(delays, durations) {
  9456. while (delays.length < durations.length) {
  9457. delays = delays.concat(delays);
  9458. }
  9459. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  9460. }
  9461. function toMs(s) {
  9462. if (s === "auto")
  9463. return 0;
  9464. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  9465. }
  9466. function forceReflow() {
  9467. return document.body.offsetHeight;
  9468. }
  9469. function patchClass(el, value, isSVG) {
  9470. const transitionClasses = el[vtcKey];
  9471. if (transitionClasses) {
  9472. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  9473. }
  9474. if (value == null) {
  9475. el.removeAttribute("class");
  9476. } else if (isSVG) {
  9477. el.setAttribute("class", value);
  9478. } else {
  9479. el.className = value;
  9480. }
  9481. }
  9482. const vShowOldKey = Symbol("_vod");
  9483. const vShow = {
  9484. beforeMount(el, { value }, { transition }) {
  9485. el[vShowOldKey] = el.style.display === "none" ? "" : el.style.display;
  9486. if (transition && value) {
  9487. transition.beforeEnter(el);
  9488. } else {
  9489. setDisplay(el, value);
  9490. }
  9491. },
  9492. mounted(el, { value }, { transition }) {
  9493. if (transition && value) {
  9494. transition.enter(el);
  9495. }
  9496. },
  9497. updated(el, { value, oldValue }, { transition }) {
  9498. if (!value === !oldValue)
  9499. return;
  9500. if (transition) {
  9501. if (value) {
  9502. transition.beforeEnter(el);
  9503. setDisplay(el, true);
  9504. transition.enter(el);
  9505. } else {
  9506. transition.leave(el, () => {
  9507. setDisplay(el, false);
  9508. });
  9509. }
  9510. } else {
  9511. setDisplay(el, value);
  9512. }
  9513. },
  9514. beforeUnmount(el, { value }) {
  9515. setDisplay(el, value);
  9516. }
  9517. };
  9518. function setDisplay(el, value) {
  9519. el.style.display = value ? el[vShowOldKey] : "none";
  9520. }
  9521. function patchStyle(el, prev, next) {
  9522. const style = el.style;
  9523. const isCssString = isString(next);
  9524. if (next && !isCssString) {
  9525. if (prev && !isString(prev)) {
  9526. for (const key in prev) {
  9527. if (next[key] == null) {
  9528. setStyle(style, key, "");
  9529. }
  9530. }
  9531. }
  9532. for (const key in next) {
  9533. setStyle(style, key, next[key]);
  9534. }
  9535. } else {
  9536. const currentDisplay = style.display;
  9537. if (isCssString) {
  9538. if (prev !== next) {
  9539. style.cssText = next;
  9540. }
  9541. } else if (prev) {
  9542. el.removeAttribute("style");
  9543. }
  9544. if (vShowOldKey in el) {
  9545. style.display = currentDisplay;
  9546. }
  9547. }
  9548. }
  9549. const semicolonRE = /[^\\];\s*$/;
  9550. const importantRE = /\s*!important$/;
  9551. function setStyle(style, name, val) {
  9552. if (isArray(val)) {
  9553. val.forEach((v) => setStyle(style, name, v));
  9554. } else {
  9555. if (val == null)
  9556. val = "";
  9557. {
  9558. if (semicolonRE.test(val)) {
  9559. warn(
  9560. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  9561. );
  9562. }
  9563. }
  9564. if (name.startsWith("--")) {
  9565. style.setProperty(name, val);
  9566. } else {
  9567. const prefixed = autoPrefix(style, name);
  9568. if (importantRE.test(val)) {
  9569. style.setProperty(
  9570. hyphenate(prefixed),
  9571. val.replace(importantRE, ""),
  9572. "important"
  9573. );
  9574. } else {
  9575. style[prefixed] = val;
  9576. }
  9577. }
  9578. }
  9579. }
  9580. const prefixes = ["Webkit", "Moz", "ms"];
  9581. const prefixCache = {};
  9582. function autoPrefix(style, rawName) {
  9583. const cached = prefixCache[rawName];
  9584. if (cached) {
  9585. return cached;
  9586. }
  9587. let name = camelize(rawName);
  9588. if (name !== "filter" && name in style) {
  9589. return prefixCache[rawName] = name;
  9590. }
  9591. name = capitalize(name);
  9592. for (let i = 0; i < prefixes.length; i++) {
  9593. const prefixed = prefixes[i] + name;
  9594. if (prefixed in style) {
  9595. return prefixCache[rawName] = prefixed;
  9596. }
  9597. }
  9598. return rawName;
  9599. }
  9600. const xlinkNS = "http://www.w3.org/1999/xlink";
  9601. function patchAttr(el, key, value, isSVG, instance) {
  9602. if (isSVG && key.startsWith("xlink:")) {
  9603. if (value == null) {
  9604. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9605. } else {
  9606. el.setAttributeNS(xlinkNS, key, value);
  9607. }
  9608. } else {
  9609. const isBoolean = isSpecialBooleanAttr(key);
  9610. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  9611. el.removeAttribute(key);
  9612. } else {
  9613. el.setAttribute(key, isBoolean ? "" : value);
  9614. }
  9615. }
  9616. }
  9617. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9618. if (key === "innerHTML" || key === "textContent") {
  9619. if (prevChildren) {
  9620. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9621. }
  9622. el[key] = value == null ? "" : value;
  9623. return;
  9624. }
  9625. const tag = el.tagName;
  9626. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  9627. !tag.includes("-")) {
  9628. el._value = value;
  9629. const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
  9630. const newValue = value == null ? "" : value;
  9631. if (oldValue !== newValue) {
  9632. el.value = newValue;
  9633. }
  9634. if (value == null) {
  9635. el.removeAttribute(key);
  9636. }
  9637. return;
  9638. }
  9639. let needRemove = false;
  9640. if (value === "" || value == null) {
  9641. const type = typeof el[key];
  9642. if (type === "boolean") {
  9643. value = includeBooleanAttr(value);
  9644. } else if (value == null && type === "string") {
  9645. value = "";
  9646. needRemove = true;
  9647. } else if (type === "number") {
  9648. value = 0;
  9649. needRemove = true;
  9650. }
  9651. }
  9652. try {
  9653. el[key] = value;
  9654. } catch (e) {
  9655. if (!needRemove) {
  9656. warn(
  9657. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  9658. e
  9659. );
  9660. }
  9661. }
  9662. needRemove && el.removeAttribute(key);
  9663. }
  9664. function addEventListener(el, event, handler, options) {
  9665. el.addEventListener(event, handler, options);
  9666. }
  9667. function removeEventListener(el, event, handler, options) {
  9668. el.removeEventListener(event, handler, options);
  9669. }
  9670. const veiKey = Symbol("_vei");
  9671. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9672. const invokers = el[veiKey] || (el[veiKey] = {});
  9673. const existingInvoker = invokers[rawName];
  9674. if (nextValue && existingInvoker) {
  9675. existingInvoker.value = nextValue;
  9676. } else {
  9677. const [name, options] = parseName(rawName);
  9678. if (nextValue) {
  9679. const invoker = invokers[rawName] = createInvoker(nextValue, instance);
  9680. addEventListener(el, name, invoker, options);
  9681. } else if (existingInvoker) {
  9682. removeEventListener(el, name, existingInvoker, options);
  9683. invokers[rawName] = void 0;
  9684. }
  9685. }
  9686. }
  9687. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9688. function parseName(name) {
  9689. let options;
  9690. if (optionsModifierRE.test(name)) {
  9691. options = {};
  9692. let m;
  9693. while (m = name.match(optionsModifierRE)) {
  9694. name = name.slice(0, name.length - m[0].length);
  9695. options[m[0].toLowerCase()] = true;
  9696. }
  9697. }
  9698. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  9699. return [event, options];
  9700. }
  9701. let cachedNow = 0;
  9702. const p = /* @__PURE__ */ Promise.resolve();
  9703. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  9704. function createInvoker(initialValue, instance) {
  9705. const invoker = (e) => {
  9706. if (!e._vts) {
  9707. e._vts = Date.now();
  9708. } else if (e._vts <= invoker.attached) {
  9709. return;
  9710. }
  9711. callWithAsyncErrorHandling(
  9712. patchStopImmediatePropagation(e, invoker.value),
  9713. instance,
  9714. 5,
  9715. [e]
  9716. );
  9717. };
  9718. invoker.value = initialValue;
  9719. invoker.attached = getNow();
  9720. return invoker;
  9721. }
  9722. function patchStopImmediatePropagation(e, value) {
  9723. if (isArray(value)) {
  9724. const originalStop = e.stopImmediatePropagation;
  9725. e.stopImmediatePropagation = () => {
  9726. originalStop.call(e);
  9727. e._stopped = true;
  9728. };
  9729. return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
  9730. } else {
  9731. return value;
  9732. }
  9733. }
  9734. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  9735. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  9736. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9737. if (key === "class") {
  9738. patchClass(el, nextValue, isSVG);
  9739. } else if (key === "style") {
  9740. patchStyle(el, prevValue, nextValue);
  9741. } else if (isOn(key)) {
  9742. if (!isModelListener(key)) {
  9743. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9744. }
  9745. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9746. patchDOMProp(
  9747. el,
  9748. key,
  9749. nextValue,
  9750. prevChildren,
  9751. parentComponent,
  9752. parentSuspense,
  9753. unmountChildren
  9754. );
  9755. } else {
  9756. if (key === "true-value") {
  9757. el._trueValue = nextValue;
  9758. } else if (key === "false-value") {
  9759. el._falseValue = nextValue;
  9760. }
  9761. patchAttr(el, key, nextValue, isSVG);
  9762. }
  9763. };
  9764. function shouldSetAsProp(el, key, value, isSVG) {
  9765. if (isSVG) {
  9766. if (key === "innerHTML" || key === "textContent") {
  9767. return true;
  9768. }
  9769. if (key in el && isNativeOn(key) && isFunction(value)) {
  9770. return true;
  9771. }
  9772. return false;
  9773. }
  9774. if (key === "spellcheck" || key === "draggable" || key === "translate") {
  9775. return false;
  9776. }
  9777. if (key === "form") {
  9778. return false;
  9779. }
  9780. if (key === "list" && el.tagName === "INPUT") {
  9781. return false;
  9782. }
  9783. if (key === "type" && el.tagName === "TEXTAREA") {
  9784. return false;
  9785. }
  9786. if (key === "width" || key === "height") {
  9787. const tag = el.tagName;
  9788. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  9789. return false;
  9790. }
  9791. }
  9792. if (isNativeOn(key) && isString(value)) {
  9793. return false;
  9794. }
  9795. return key in el;
  9796. }
  9797. /*! #__NO_SIDE_EFFECTS__ */
  9798. // @__NO_SIDE_EFFECTS__
  9799. function defineCustomElement(options, hydrate2) {
  9800. const Comp = defineComponent(options);
  9801. class VueCustomElement extends VueElement {
  9802. constructor(initialProps) {
  9803. super(Comp, initialProps, hydrate2);
  9804. }
  9805. }
  9806. VueCustomElement.def = Comp;
  9807. return VueCustomElement;
  9808. }
  9809. /*! #__NO_SIDE_EFFECTS__ */
  9810. const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options) => {
  9811. return /* @__PURE__ */ defineCustomElement(options, hydrate);
  9812. };
  9813. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  9814. };
  9815. class VueElement extends BaseClass {
  9816. constructor(_def, _props = {}, hydrate2) {
  9817. super();
  9818. this._def = _def;
  9819. this._props = _props;
  9820. /**
  9821. * @internal
  9822. */
  9823. this._instance = null;
  9824. this._connected = false;
  9825. this._resolved = false;
  9826. this._numberProps = null;
  9827. this._ob = null;
  9828. if (this.shadowRoot && hydrate2) {
  9829. hydrate2(this._createVNode(), this.shadowRoot);
  9830. } else {
  9831. if (this.shadowRoot) {
  9832. warn(
  9833. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  9834. );
  9835. }
  9836. this.attachShadow({ mode: "open" });
  9837. if (!this._def.__asyncLoader) {
  9838. this._resolveProps(this._def);
  9839. }
  9840. }
  9841. }
  9842. connectedCallback() {
  9843. this._connected = true;
  9844. if (!this._instance) {
  9845. if (this._resolved) {
  9846. this._update();
  9847. } else {
  9848. this._resolveDef();
  9849. }
  9850. }
  9851. }
  9852. disconnectedCallback() {
  9853. this._connected = false;
  9854. if (this._ob) {
  9855. this._ob.disconnect();
  9856. this._ob = null;
  9857. }
  9858. nextTick(() => {
  9859. if (!this._connected) {
  9860. render(null, this.shadowRoot);
  9861. this._instance = null;
  9862. }
  9863. });
  9864. }
  9865. /**
  9866. * resolve inner component definition (handle possible async component)
  9867. */
  9868. _resolveDef() {
  9869. this._resolved = true;
  9870. for (let i = 0; i < this.attributes.length; i++) {
  9871. this._setAttr(this.attributes[i].name);
  9872. }
  9873. this._ob = new MutationObserver((mutations) => {
  9874. for (const m of mutations) {
  9875. this._setAttr(m.attributeName);
  9876. }
  9877. });
  9878. this._ob.observe(this, { attributes: true });
  9879. const resolve = (def, isAsync = false) => {
  9880. const { props, styles } = def;
  9881. let numberProps;
  9882. if (props && !isArray(props)) {
  9883. for (const key in props) {
  9884. const opt = props[key];
  9885. if (opt === Number || opt && opt.type === Number) {
  9886. if (key in this._props) {
  9887. this._props[key] = toNumber(this._props[key]);
  9888. }
  9889. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize(key)] = true;
  9890. }
  9891. }
  9892. }
  9893. this._numberProps = numberProps;
  9894. if (isAsync) {
  9895. this._resolveProps(def);
  9896. }
  9897. this._applyStyles(styles);
  9898. this._update();
  9899. };
  9900. const asyncDef = this._def.__asyncLoader;
  9901. if (asyncDef) {
  9902. asyncDef().then((def) => resolve(def, true));
  9903. } else {
  9904. resolve(this._def);
  9905. }
  9906. }
  9907. _resolveProps(def) {
  9908. const { props } = def;
  9909. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  9910. for (const key of Object.keys(this)) {
  9911. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  9912. this._setProp(key, this[key], true, false);
  9913. }
  9914. }
  9915. for (const key of declaredPropKeys.map(camelize)) {
  9916. Object.defineProperty(this, key, {
  9917. get() {
  9918. return this._getProp(key);
  9919. },
  9920. set(val) {
  9921. this._setProp(key, val);
  9922. }
  9923. });
  9924. }
  9925. }
  9926. _setAttr(key) {
  9927. let value = this.getAttribute(key);
  9928. const camelKey = camelize(key);
  9929. if (this._numberProps && this._numberProps[camelKey]) {
  9930. value = toNumber(value);
  9931. }
  9932. this._setProp(camelKey, value, false);
  9933. }
  9934. /**
  9935. * @internal
  9936. */
  9937. _getProp(key) {
  9938. return this._props[key];
  9939. }
  9940. /**
  9941. * @internal
  9942. */
  9943. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9944. if (val !== this._props[key]) {
  9945. this._props[key] = val;
  9946. if (shouldUpdate && this._instance) {
  9947. this._update();
  9948. }
  9949. if (shouldReflect) {
  9950. if (val === true) {
  9951. this.setAttribute(hyphenate(key), "");
  9952. } else if (typeof val === "string" || typeof val === "number") {
  9953. this.setAttribute(hyphenate(key), val + "");
  9954. } else if (!val) {
  9955. this.removeAttribute(hyphenate(key));
  9956. }
  9957. }
  9958. }
  9959. }
  9960. _update() {
  9961. render(this._createVNode(), this.shadowRoot);
  9962. }
  9963. _createVNode() {
  9964. const vnode = createVNode(this._def, extend({}, this._props));
  9965. if (!this._instance) {
  9966. vnode.ce = (instance) => {
  9967. this._instance = instance;
  9968. instance.isCE = true;
  9969. {
  9970. instance.ceReload = (newStyles) => {
  9971. if (this._styles) {
  9972. this._styles.forEach((s) => this.shadowRoot.removeChild(s));
  9973. this._styles.length = 0;
  9974. }
  9975. this._applyStyles(newStyles);
  9976. this._instance = null;
  9977. this._update();
  9978. };
  9979. }
  9980. const dispatch = (event, args) => {
  9981. this.dispatchEvent(
  9982. new CustomEvent(event, {
  9983. detail: args
  9984. })
  9985. );
  9986. };
  9987. instance.emit = (event, ...args) => {
  9988. dispatch(event, args);
  9989. if (hyphenate(event) !== event) {
  9990. dispatch(hyphenate(event), args);
  9991. }
  9992. };
  9993. let parent = this;
  9994. while (parent = parent && (parent.parentNode || parent.host)) {
  9995. if (parent instanceof VueElement) {
  9996. instance.parent = parent._instance;
  9997. instance.provides = parent._instance.provides;
  9998. break;
  9999. }
  10000. }
  10001. };
  10002. }
  10003. return vnode;
  10004. }
  10005. _applyStyles(styles) {
  10006. if (styles) {
  10007. styles.forEach((css) => {
  10008. const s = document.createElement("style");
  10009. s.textContent = css;
  10010. this.shadowRoot.appendChild(s);
  10011. {
  10012. (this._styles || (this._styles = [])).push(s);
  10013. }
  10014. });
  10015. }
  10016. }
  10017. }
  10018. function useCssModule(name = "$style") {
  10019. {
  10020. {
  10021. warn(`useCssModule() is not supported in the global build.`);
  10022. }
  10023. return EMPTY_OBJ;
  10024. }
  10025. }
  10026. function useCssVars(getter) {
  10027. const instance = getCurrentInstance();
  10028. if (!instance) {
  10029. warn(`useCssVars is called without current active component instance.`);
  10030. return;
  10031. }
  10032. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  10033. Array.from(
  10034. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
  10035. ).forEach((node) => setVarsOnNode(node, vars));
  10036. };
  10037. const setVars = () => {
  10038. const vars = getter(instance.proxy);
  10039. setVarsOnVNode(instance.subTree, vars);
  10040. updateTeleports(vars);
  10041. };
  10042. watchPostEffect(setVars);
  10043. onMounted(() => {
  10044. const ob = new MutationObserver(setVars);
  10045. ob.observe(instance.subTree.el.parentNode, { childList: true });
  10046. onUnmounted(() => ob.disconnect());
  10047. });
  10048. }
  10049. function setVarsOnVNode(vnode, vars) {
  10050. if (vnode.shapeFlag & 128) {
  10051. const suspense = vnode.suspense;
  10052. vnode = suspense.activeBranch;
  10053. if (suspense.pendingBranch && !suspense.isHydrating) {
  10054. suspense.effects.push(() => {
  10055. setVarsOnVNode(suspense.activeBranch, vars);
  10056. });
  10057. }
  10058. }
  10059. while (vnode.component) {
  10060. vnode = vnode.component.subTree;
  10061. }
  10062. if (vnode.shapeFlag & 1 && vnode.el) {
  10063. setVarsOnNode(vnode.el, vars);
  10064. } else if (vnode.type === Fragment) {
  10065. vnode.children.forEach((c) => setVarsOnVNode(c, vars));
  10066. } else if (vnode.type === Static) {
  10067. let { el, anchor } = vnode;
  10068. while (el) {
  10069. setVarsOnNode(el, vars);
  10070. if (el === anchor)
  10071. break;
  10072. el = el.nextSibling;
  10073. }
  10074. }
  10075. }
  10076. function setVarsOnNode(el, vars) {
  10077. if (el.nodeType === 1) {
  10078. const style = el.style;
  10079. for (const key in vars) {
  10080. style.setProperty(`--${key}`, vars[key]);
  10081. }
  10082. }
  10083. }
  10084. const positionMap = /* @__PURE__ */ new WeakMap();
  10085. const newPositionMap = /* @__PURE__ */ new WeakMap();
  10086. const moveCbKey = Symbol("_moveCb");
  10087. const enterCbKey = Symbol("_enterCb");
  10088. const TransitionGroupImpl = {
  10089. name: "TransitionGroup",
  10090. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  10091. tag: String,
  10092. moveClass: String
  10093. }),
  10094. setup(props, { slots }) {
  10095. const instance = getCurrentInstance();
  10096. const state = useTransitionState();
  10097. let prevChildren;
  10098. let children;
  10099. onUpdated(() => {
  10100. if (!prevChildren.length) {
  10101. return;
  10102. }
  10103. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  10104. if (!hasCSSTransform(
  10105. prevChildren[0].el,
  10106. instance.vnode.el,
  10107. moveClass
  10108. )) {
  10109. return;
  10110. }
  10111. prevChildren.forEach(callPendingCbs);
  10112. prevChildren.forEach(recordPosition);
  10113. const movedChildren = prevChildren.filter(applyTranslation);
  10114. forceReflow();
  10115. movedChildren.forEach((c) => {
  10116. const el = c.el;
  10117. const style = el.style;
  10118. addTransitionClass(el, moveClass);
  10119. style.transform = style.webkitTransform = style.transitionDuration = "";
  10120. const cb = el[moveCbKey] = (e) => {
  10121. if (e && e.target !== el) {
  10122. return;
  10123. }
  10124. if (!e || /transform$/.test(e.propertyName)) {
  10125. el.removeEventListener("transitionend", cb);
  10126. el[moveCbKey] = null;
  10127. removeTransitionClass(el, moveClass);
  10128. }
  10129. };
  10130. el.addEventListener("transitionend", cb);
  10131. });
  10132. });
  10133. return () => {
  10134. const rawProps = toRaw(props);
  10135. const cssTransitionProps = resolveTransitionProps(rawProps);
  10136. let tag = rawProps.tag || Fragment;
  10137. prevChildren = children;
  10138. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10139. for (let i = 0; i < children.length; i++) {
  10140. const child = children[i];
  10141. if (child.key != null) {
  10142. setTransitionHooks(
  10143. child,
  10144. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  10145. );
  10146. } else {
  10147. warn(`<TransitionGroup> children must be keyed.`);
  10148. }
  10149. }
  10150. if (prevChildren) {
  10151. for (let i = 0; i < prevChildren.length; i++) {
  10152. const child = prevChildren[i];
  10153. setTransitionHooks(
  10154. child,
  10155. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  10156. );
  10157. positionMap.set(child, child.el.getBoundingClientRect());
  10158. }
  10159. }
  10160. return createVNode(tag, null, children);
  10161. };
  10162. }
  10163. };
  10164. const removeMode = (props) => delete props.mode;
  10165. /* @__PURE__ */ removeMode(TransitionGroupImpl.props);
  10166. const TransitionGroup = TransitionGroupImpl;
  10167. function callPendingCbs(c) {
  10168. const el = c.el;
  10169. if (el[moveCbKey]) {
  10170. el[moveCbKey]();
  10171. }
  10172. if (el[enterCbKey]) {
  10173. el[enterCbKey]();
  10174. }
  10175. }
  10176. function recordPosition(c) {
  10177. newPositionMap.set(c, c.el.getBoundingClientRect());
  10178. }
  10179. function applyTranslation(c) {
  10180. const oldPos = positionMap.get(c);
  10181. const newPos = newPositionMap.get(c);
  10182. const dx = oldPos.left - newPos.left;
  10183. const dy = oldPos.top - newPos.top;
  10184. if (dx || dy) {
  10185. const s = c.el.style;
  10186. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10187. s.transitionDuration = "0s";
  10188. return c;
  10189. }
  10190. }
  10191. function hasCSSTransform(el, root, moveClass) {
  10192. const clone = el.cloneNode();
  10193. const _vtc = el[vtcKey];
  10194. if (_vtc) {
  10195. _vtc.forEach((cls) => {
  10196. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  10197. });
  10198. }
  10199. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  10200. clone.style.display = "none";
  10201. const container = root.nodeType === 1 ? root : root.parentNode;
  10202. container.appendChild(clone);
  10203. const { hasTransform } = getTransitionInfo(clone);
  10204. container.removeChild(clone);
  10205. return hasTransform;
  10206. }
  10207. const getModelAssigner = (vnode) => {
  10208. const fn = vnode.props["onUpdate:modelValue"] || false;
  10209. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  10210. };
  10211. function onCompositionStart(e) {
  10212. e.target.composing = true;
  10213. }
  10214. function onCompositionEnd(e) {
  10215. const target = e.target;
  10216. if (target.composing) {
  10217. target.composing = false;
  10218. target.dispatchEvent(new Event("input"));
  10219. }
  10220. }
  10221. const assignKey = Symbol("_assign");
  10222. const vModelText = {
  10223. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10224. el[assignKey] = getModelAssigner(vnode);
  10225. const castToNumber = number || vnode.props && vnode.props.type === "number";
  10226. addEventListener(el, lazy ? "change" : "input", (e) => {
  10227. if (e.target.composing)
  10228. return;
  10229. let domValue = el.value;
  10230. if (trim) {
  10231. domValue = domValue.trim();
  10232. }
  10233. if (castToNumber) {
  10234. domValue = looseToNumber(domValue);
  10235. }
  10236. el[assignKey](domValue);
  10237. });
  10238. if (trim) {
  10239. addEventListener(el, "change", () => {
  10240. el.value = el.value.trim();
  10241. });
  10242. }
  10243. if (!lazy) {
  10244. addEventListener(el, "compositionstart", onCompositionStart);
  10245. addEventListener(el, "compositionend", onCompositionEnd);
  10246. addEventListener(el, "change", onCompositionEnd);
  10247. }
  10248. },
  10249. // set value on mounted so it's after min/max for type="range"
  10250. mounted(el, { value }) {
  10251. el.value = value == null ? "" : value;
  10252. },
  10253. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10254. el[assignKey] = getModelAssigner(vnode);
  10255. if (el.composing)
  10256. return;
  10257. const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
  10258. const newValue = value == null ? "" : value;
  10259. if (elValue === newValue) {
  10260. return;
  10261. }
  10262. if (document.activeElement === el && el.type !== "range") {
  10263. if (lazy) {
  10264. return;
  10265. }
  10266. if (trim && el.value.trim() === newValue) {
  10267. return;
  10268. }
  10269. }
  10270. el.value = newValue;
  10271. }
  10272. };
  10273. const vModelCheckbox = {
  10274. // #4096 array checkboxes need to be deep traversed
  10275. deep: true,
  10276. created(el, _, vnode) {
  10277. el[assignKey] = getModelAssigner(vnode);
  10278. addEventListener(el, "change", () => {
  10279. const modelValue = el._modelValue;
  10280. const elementValue = getValue(el);
  10281. const checked = el.checked;
  10282. const assign = el[assignKey];
  10283. if (isArray(modelValue)) {
  10284. const index = looseIndexOf(modelValue, elementValue);
  10285. const found = index !== -1;
  10286. if (checked && !found) {
  10287. assign(modelValue.concat(elementValue));
  10288. } else if (!checked && found) {
  10289. const filtered = [...modelValue];
  10290. filtered.splice(index, 1);
  10291. assign(filtered);
  10292. }
  10293. } else if (isSet(modelValue)) {
  10294. const cloned = new Set(modelValue);
  10295. if (checked) {
  10296. cloned.add(elementValue);
  10297. } else {
  10298. cloned.delete(elementValue);
  10299. }
  10300. assign(cloned);
  10301. } else {
  10302. assign(getCheckboxValue(el, checked));
  10303. }
  10304. });
  10305. },
  10306. // set initial checked on mount to wait for true-value/false-value
  10307. mounted: setChecked,
  10308. beforeUpdate(el, binding, vnode) {
  10309. el[assignKey] = getModelAssigner(vnode);
  10310. setChecked(el, binding, vnode);
  10311. }
  10312. };
  10313. function setChecked(el, { value, oldValue }, vnode) {
  10314. el._modelValue = value;
  10315. if (isArray(value)) {
  10316. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10317. } else if (isSet(value)) {
  10318. el.checked = value.has(vnode.props.value);
  10319. } else if (value !== oldValue) {
  10320. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10321. }
  10322. }
  10323. const vModelRadio = {
  10324. created(el, { value }, vnode) {
  10325. el.checked = looseEqual(value, vnode.props.value);
  10326. el[assignKey] = getModelAssigner(vnode);
  10327. addEventListener(el, "change", () => {
  10328. el[assignKey](getValue(el));
  10329. });
  10330. },
  10331. beforeUpdate(el, { value, oldValue }, vnode) {
  10332. el[assignKey] = getModelAssigner(vnode);
  10333. if (value !== oldValue) {
  10334. el.checked = looseEqual(value, vnode.props.value);
  10335. }
  10336. }
  10337. };
  10338. const vModelSelect = {
  10339. // <select multiple> value need to be deep traversed
  10340. deep: true,
  10341. created(el, { value, modifiers: { number } }, vnode) {
  10342. const isSetModel = isSet(value);
  10343. addEventListener(el, "change", () => {
  10344. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  10345. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  10346. );
  10347. el[assignKey](
  10348. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  10349. );
  10350. });
  10351. el[assignKey] = getModelAssigner(vnode);
  10352. },
  10353. // set value in mounted & updated because <select> relies on its children
  10354. // <option>s.
  10355. mounted(el, { value }) {
  10356. setSelected(el, value);
  10357. },
  10358. beforeUpdate(el, _binding, vnode) {
  10359. el[assignKey] = getModelAssigner(vnode);
  10360. },
  10361. updated(el, { value }) {
  10362. setSelected(el, value);
  10363. }
  10364. };
  10365. function setSelected(el, value) {
  10366. const isMultiple = el.multiple;
  10367. if (isMultiple && !isArray(value) && !isSet(value)) {
  10368. warn(
  10369. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  10370. );
  10371. return;
  10372. }
  10373. for (let i = 0, l = el.options.length; i < l; i++) {
  10374. const option = el.options[i];
  10375. const optionValue = getValue(option);
  10376. if (isMultiple) {
  10377. if (isArray(value)) {
  10378. option.selected = looseIndexOf(value, optionValue) > -1;
  10379. } else {
  10380. option.selected = value.has(optionValue);
  10381. }
  10382. } else {
  10383. if (looseEqual(getValue(option), value)) {
  10384. if (el.selectedIndex !== i)
  10385. el.selectedIndex = i;
  10386. return;
  10387. }
  10388. }
  10389. }
  10390. if (!isMultiple && el.selectedIndex !== -1) {
  10391. el.selectedIndex = -1;
  10392. }
  10393. }
  10394. function getValue(el) {
  10395. return "_value" in el ? el._value : el.value;
  10396. }
  10397. function getCheckboxValue(el, checked) {
  10398. const key = checked ? "_trueValue" : "_falseValue";
  10399. return key in el ? el[key] : checked;
  10400. }
  10401. const vModelDynamic = {
  10402. created(el, binding, vnode) {
  10403. callModelHook(el, binding, vnode, null, "created");
  10404. },
  10405. mounted(el, binding, vnode) {
  10406. callModelHook(el, binding, vnode, null, "mounted");
  10407. },
  10408. beforeUpdate(el, binding, vnode, prevVNode) {
  10409. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  10410. },
  10411. updated(el, binding, vnode, prevVNode) {
  10412. callModelHook(el, binding, vnode, prevVNode, "updated");
  10413. }
  10414. };
  10415. function resolveDynamicModel(tagName, type) {
  10416. switch (tagName) {
  10417. case "SELECT":
  10418. return vModelSelect;
  10419. case "TEXTAREA":
  10420. return vModelText;
  10421. default:
  10422. switch (type) {
  10423. case "checkbox":
  10424. return vModelCheckbox;
  10425. case "radio":
  10426. return vModelRadio;
  10427. default:
  10428. return vModelText;
  10429. }
  10430. }
  10431. }
  10432. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10433. const modelToUse = resolveDynamicModel(
  10434. el.tagName,
  10435. vnode.props && vnode.props.type
  10436. );
  10437. const fn = modelToUse[hook];
  10438. fn && fn(el, binding, vnode, prevVNode);
  10439. }
  10440. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  10441. const modifierGuards = {
  10442. stop: (e) => e.stopPropagation(),
  10443. prevent: (e) => e.preventDefault(),
  10444. self: (e) => e.target !== e.currentTarget,
  10445. ctrl: (e) => !e.ctrlKey,
  10446. shift: (e) => !e.shiftKey,
  10447. alt: (e) => !e.altKey,
  10448. meta: (e) => !e.metaKey,
  10449. left: (e) => "button" in e && e.button !== 0,
  10450. middle: (e) => "button" in e && e.button !== 1,
  10451. right: (e) => "button" in e && e.button !== 2,
  10452. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  10453. };
  10454. const withModifiers = (fn, modifiers) => {
  10455. return fn._withMods || (fn._withMods = (event, ...args) => {
  10456. for (let i = 0; i < modifiers.length; i++) {
  10457. const guard = modifierGuards[modifiers[i]];
  10458. if (guard && guard(event, modifiers))
  10459. return;
  10460. }
  10461. return fn(event, ...args);
  10462. });
  10463. };
  10464. const keyNames = {
  10465. esc: "escape",
  10466. space: " ",
  10467. up: "arrow-up",
  10468. left: "arrow-left",
  10469. right: "arrow-right",
  10470. down: "arrow-down",
  10471. delete: "backspace"
  10472. };
  10473. const withKeys = (fn, modifiers) => {
  10474. return fn._withKeys || (fn._withKeys = (event) => {
  10475. if (!("key" in event)) {
  10476. return;
  10477. }
  10478. const eventKey = hyphenate(event.key);
  10479. if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
  10480. return fn(event);
  10481. }
  10482. });
  10483. };
  10484. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  10485. let renderer;
  10486. let enabledHydration = false;
  10487. function ensureRenderer() {
  10488. return renderer || (renderer = createRenderer(rendererOptions));
  10489. }
  10490. function ensureHydrationRenderer() {
  10491. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  10492. enabledHydration = true;
  10493. return renderer;
  10494. }
  10495. const render = (...args) => {
  10496. ensureRenderer().render(...args);
  10497. };
  10498. const hydrate = (...args) => {
  10499. ensureHydrationRenderer().hydrate(...args);
  10500. };
  10501. const createApp = (...args) => {
  10502. const app = ensureRenderer().createApp(...args);
  10503. {
  10504. injectNativeTagCheck(app);
  10505. injectCompilerOptionsCheck(app);
  10506. }
  10507. const { mount } = app;
  10508. app.mount = (containerOrSelector) => {
  10509. const container = normalizeContainer(containerOrSelector);
  10510. if (!container)
  10511. return;
  10512. const component = app._component;
  10513. if (!isFunction(component) && !component.render && !component.template) {
  10514. component.template = container.innerHTML;
  10515. }
  10516. container.innerHTML = "";
  10517. const proxy = mount(container, false, container instanceof SVGElement);
  10518. if (container instanceof Element) {
  10519. container.removeAttribute("v-cloak");
  10520. container.setAttribute("data-v-app", "");
  10521. }
  10522. return proxy;
  10523. };
  10524. return app;
  10525. };
  10526. const createSSRApp = (...args) => {
  10527. const app = ensureHydrationRenderer().createApp(...args);
  10528. {
  10529. injectNativeTagCheck(app);
  10530. injectCompilerOptionsCheck(app);
  10531. }
  10532. const { mount } = app;
  10533. app.mount = (containerOrSelector) => {
  10534. const container = normalizeContainer(containerOrSelector);
  10535. if (container) {
  10536. return mount(container, true, container instanceof SVGElement);
  10537. }
  10538. };
  10539. return app;
  10540. };
  10541. function injectNativeTagCheck(app) {
  10542. Object.defineProperty(app.config, "isNativeTag", {
  10543. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10544. writable: false
  10545. });
  10546. }
  10547. function injectCompilerOptionsCheck(app) {
  10548. if (isRuntimeOnly()) {
  10549. const isCustomElement = app.config.isCustomElement;
  10550. Object.defineProperty(app.config, "isCustomElement", {
  10551. get() {
  10552. return isCustomElement;
  10553. },
  10554. set() {
  10555. warn(
  10556. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  10557. );
  10558. }
  10559. });
  10560. const compilerOptions = app.config.compilerOptions;
  10561. const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
  10562. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  10563. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  10564. - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
  10565. Object.defineProperty(app.config, "compilerOptions", {
  10566. get() {
  10567. warn(msg);
  10568. return compilerOptions;
  10569. },
  10570. set() {
  10571. warn(msg);
  10572. }
  10573. });
  10574. }
  10575. }
  10576. function normalizeContainer(container) {
  10577. if (isString(container)) {
  10578. const res = document.querySelector(container);
  10579. if (!res) {
  10580. warn(
  10581. `Failed to mount app: mount target selector "${container}" returned null.`
  10582. );
  10583. }
  10584. return res;
  10585. }
  10586. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  10587. warn(
  10588. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  10589. );
  10590. }
  10591. return container;
  10592. }
  10593. const initDirectivesForSSR = NOOP;
  10594. function initDev() {
  10595. {
  10596. {
  10597. console.info(
  10598. `You are running a development build of Vue.
  10599. Make sure to use the production build (*.prod.js) when deploying for production.`
  10600. );
  10601. }
  10602. initCustomFormatter();
  10603. }
  10604. }
  10605. function defaultOnError(error) {
  10606. throw error;
  10607. }
  10608. function defaultOnWarn(msg) {
  10609. console.warn(`[Vue warn] ${msg.message}`);
  10610. }
  10611. function createCompilerError(code, loc, messages, additionalMessage) {
  10612. const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
  10613. const error = new SyntaxError(String(msg));
  10614. error.code = code;
  10615. error.loc = loc;
  10616. return error;
  10617. }
  10618. const errorMessages = {
  10619. // parse errors
  10620. [0]: "Illegal comment.",
  10621. [1]: "CDATA section is allowed only in XML context.",
  10622. [2]: "Duplicate attribute.",
  10623. [3]: "End tag cannot have attributes.",
  10624. [4]: "Illegal '/' in tags.",
  10625. [5]: "Unexpected EOF in tag.",
  10626. [6]: "Unexpected EOF in CDATA section.",
  10627. [7]: "Unexpected EOF in comment.",
  10628. [8]: "Unexpected EOF in script.",
  10629. [9]: "Unexpected EOF in tag.",
  10630. [10]: "Incorrectly closed comment.",
  10631. [11]: "Incorrectly opened comment.",
  10632. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  10633. [13]: "Attribute value was expected.",
  10634. [14]: "End tag name was expected.",
  10635. [15]: "Whitespace was expected.",
  10636. [16]: "Unexpected '<!--' in comment.",
  10637. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  10638. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  10639. [19]: "Attribute name cannot start with '='.",
  10640. [21]: "'<?' is allowed only in XML context.",
  10641. [20]: `Unexpected null character.`,
  10642. [22]: "Illegal '/' in tags.",
  10643. // Vue-specific parse errors
  10644. [23]: "Invalid end tag.",
  10645. [24]: "Element is missing end tag.",
  10646. [25]: "Interpolation end sign was not found.",
  10647. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  10648. [26]: "Legal directive name was expected.",
  10649. // transform errors
  10650. [28]: `v-if/v-else-if is missing expression.`,
  10651. [29]: `v-if/else branches must use unique keys.`,
  10652. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  10653. [31]: `v-for is missing expression.`,
  10654. [32]: `v-for has invalid expression.`,
  10655. [33]: `<template v-for> key should be placed on the <template> tag.`,
  10656. [34]: `v-bind is missing expression.`,
  10657. [35]: `v-on is missing expression.`,
  10658. [36]: `Unexpected custom directive on <slot> outlet.`,
  10659. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  10660. [38]: `Duplicate slot names found. `,
  10661. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  10662. [40]: `v-slot can only be used on components or <template> tags.`,
  10663. [41]: `v-model is missing expression.`,
  10664. [42]: `v-model value must be a valid JavaScript member expression.`,
  10665. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  10666. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  10667. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  10668. [45]: `Error parsing JavaScript expression: `,
  10669. [46]: `<KeepAlive> expects exactly one child component.`,
  10670. // generic errors
  10671. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  10672. [48]: `ES module mode is not supported in this build of compiler.`,
  10673. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  10674. [50]: `"scopeId" option is only supported in module mode.`,
  10675. // deprecations
  10676. [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
  10677. [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
  10678. // just to fulfill types
  10679. [53]: ``
  10680. };
  10681. const FRAGMENT = Symbol(`Fragment` );
  10682. const TELEPORT = Symbol(`Teleport` );
  10683. const SUSPENSE = Symbol(`Suspense` );
  10684. const KEEP_ALIVE = Symbol(`KeepAlive` );
  10685. const BASE_TRANSITION = Symbol(`BaseTransition` );
  10686. const OPEN_BLOCK = Symbol(`openBlock` );
  10687. const CREATE_BLOCK = Symbol(`createBlock` );
  10688. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  10689. const CREATE_VNODE = Symbol(`createVNode` );
  10690. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  10691. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  10692. const CREATE_TEXT = Symbol(`createTextVNode` );
  10693. const CREATE_STATIC = Symbol(`createStaticVNode` );
  10694. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  10695. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  10696. `resolveDynamicComponent`
  10697. );
  10698. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  10699. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  10700. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  10701. const RENDER_LIST = Symbol(`renderList` );
  10702. const RENDER_SLOT = Symbol(`renderSlot` );
  10703. const CREATE_SLOTS = Symbol(`createSlots` );
  10704. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  10705. const MERGE_PROPS = Symbol(`mergeProps` );
  10706. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  10707. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  10708. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  10709. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  10710. const TO_HANDLERS = Symbol(`toHandlers` );
  10711. const CAMELIZE = Symbol(`camelize` );
  10712. const CAPITALIZE = Symbol(`capitalize` );
  10713. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  10714. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  10715. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  10716. const POP_SCOPE_ID = Symbol(`popScopeId` );
  10717. const WITH_CTX = Symbol(`withCtx` );
  10718. const UNREF = Symbol(`unref` );
  10719. const IS_REF = Symbol(`isRef` );
  10720. const WITH_MEMO = Symbol(`withMemo` );
  10721. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  10722. const helperNameMap = {
  10723. [FRAGMENT]: `Fragment`,
  10724. [TELEPORT]: `Teleport`,
  10725. [SUSPENSE]: `Suspense`,
  10726. [KEEP_ALIVE]: `KeepAlive`,
  10727. [BASE_TRANSITION]: `BaseTransition`,
  10728. [OPEN_BLOCK]: `openBlock`,
  10729. [CREATE_BLOCK]: `createBlock`,
  10730. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  10731. [CREATE_VNODE]: `createVNode`,
  10732. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  10733. [CREATE_COMMENT]: `createCommentVNode`,
  10734. [CREATE_TEXT]: `createTextVNode`,
  10735. [CREATE_STATIC]: `createStaticVNode`,
  10736. [RESOLVE_COMPONENT]: `resolveComponent`,
  10737. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  10738. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  10739. [RESOLVE_FILTER]: `resolveFilter`,
  10740. [WITH_DIRECTIVES]: `withDirectives`,
  10741. [RENDER_LIST]: `renderList`,
  10742. [RENDER_SLOT]: `renderSlot`,
  10743. [CREATE_SLOTS]: `createSlots`,
  10744. [TO_DISPLAY_STRING]: `toDisplayString`,
  10745. [MERGE_PROPS]: `mergeProps`,
  10746. [NORMALIZE_CLASS]: `normalizeClass`,
  10747. [NORMALIZE_STYLE]: `normalizeStyle`,
  10748. [NORMALIZE_PROPS]: `normalizeProps`,
  10749. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  10750. [TO_HANDLERS]: `toHandlers`,
  10751. [CAMELIZE]: `camelize`,
  10752. [CAPITALIZE]: `capitalize`,
  10753. [TO_HANDLER_KEY]: `toHandlerKey`,
  10754. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  10755. [PUSH_SCOPE_ID]: `pushScopeId`,
  10756. [POP_SCOPE_ID]: `popScopeId`,
  10757. [WITH_CTX]: `withCtx`,
  10758. [UNREF]: `unref`,
  10759. [IS_REF]: `isRef`,
  10760. [WITH_MEMO]: `withMemo`,
  10761. [IS_MEMO_SAME]: `isMemoSame`
  10762. };
  10763. function registerRuntimeHelpers(helpers) {
  10764. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  10765. helperNameMap[s] = helpers[s];
  10766. });
  10767. }
  10768. const locStub = {
  10769. source: "",
  10770. start: { line: 1, column: 1, offset: 0 },
  10771. end: { line: 1, column: 1, offset: 0 }
  10772. };
  10773. function createRoot(children, loc = locStub) {
  10774. return {
  10775. type: 0,
  10776. children,
  10777. helpers: /* @__PURE__ */ new Set(),
  10778. components: [],
  10779. directives: [],
  10780. hoists: [],
  10781. imports: [],
  10782. cached: 0,
  10783. temps: 0,
  10784. codegenNode: void 0,
  10785. loc
  10786. };
  10787. }
  10788. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  10789. if (context) {
  10790. if (isBlock) {
  10791. context.helper(OPEN_BLOCK);
  10792. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  10793. } else {
  10794. context.helper(getVNodeHelper(context.inSSR, isComponent));
  10795. }
  10796. if (directives) {
  10797. context.helper(WITH_DIRECTIVES);
  10798. }
  10799. }
  10800. return {
  10801. type: 13,
  10802. tag,
  10803. props,
  10804. children,
  10805. patchFlag,
  10806. dynamicProps,
  10807. directives,
  10808. isBlock,
  10809. disableTracking,
  10810. isComponent,
  10811. loc
  10812. };
  10813. }
  10814. function createArrayExpression(elements, loc = locStub) {
  10815. return {
  10816. type: 17,
  10817. loc,
  10818. elements
  10819. };
  10820. }
  10821. function createObjectExpression(properties, loc = locStub) {
  10822. return {
  10823. type: 15,
  10824. loc,
  10825. properties
  10826. };
  10827. }
  10828. function createObjectProperty(key, value) {
  10829. return {
  10830. type: 16,
  10831. loc: locStub,
  10832. key: isString(key) ? createSimpleExpression(key, true) : key,
  10833. value
  10834. };
  10835. }
  10836. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  10837. return {
  10838. type: 4,
  10839. loc,
  10840. content,
  10841. isStatic,
  10842. constType: isStatic ? 3 : constType
  10843. };
  10844. }
  10845. function createCompoundExpression(children, loc = locStub) {
  10846. return {
  10847. type: 8,
  10848. loc,
  10849. children
  10850. };
  10851. }
  10852. function createCallExpression(callee, args = [], loc = locStub) {
  10853. return {
  10854. type: 14,
  10855. loc,
  10856. callee,
  10857. arguments: args
  10858. };
  10859. }
  10860. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  10861. return {
  10862. type: 18,
  10863. params,
  10864. returns,
  10865. newline,
  10866. isSlot,
  10867. loc
  10868. };
  10869. }
  10870. function createConditionalExpression(test, consequent, alternate, newline = true) {
  10871. return {
  10872. type: 19,
  10873. test,
  10874. consequent,
  10875. alternate,
  10876. newline,
  10877. loc: locStub
  10878. };
  10879. }
  10880. function createCacheExpression(index, value, isVNode = false) {
  10881. return {
  10882. type: 20,
  10883. index,
  10884. value,
  10885. isVNode,
  10886. loc: locStub
  10887. };
  10888. }
  10889. function createBlockStatement(body) {
  10890. return {
  10891. type: 21,
  10892. body,
  10893. loc: locStub
  10894. };
  10895. }
  10896. function getVNodeHelper(ssr, isComponent) {
  10897. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  10898. }
  10899. function getVNodeBlockHelper(ssr, isComponent) {
  10900. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  10901. }
  10902. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  10903. if (!node.isBlock) {
  10904. node.isBlock = true;
  10905. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  10906. helper(OPEN_BLOCK);
  10907. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  10908. }
  10909. }
  10910. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  10911. const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
  10912. function isCoreComponent(tag) {
  10913. if (isBuiltInType(tag, "Teleport")) {
  10914. return TELEPORT;
  10915. } else if (isBuiltInType(tag, "Suspense")) {
  10916. return SUSPENSE;
  10917. } else if (isBuiltInType(tag, "KeepAlive")) {
  10918. return KEEP_ALIVE;
  10919. } else if (isBuiltInType(tag, "BaseTransition")) {
  10920. return BASE_TRANSITION;
  10921. }
  10922. }
  10923. const nonIdentifierRE = /^\d|[^\$\w]/;
  10924. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  10925. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  10926. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  10927. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  10928. const isMemberExpressionBrowser = (path) => {
  10929. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  10930. let state = 0 /* inMemberExp */;
  10931. let stateStack = [];
  10932. let currentOpenBracketCount = 0;
  10933. let currentOpenParensCount = 0;
  10934. let currentStringType = null;
  10935. for (let i = 0; i < path.length; i++) {
  10936. const char = path.charAt(i);
  10937. switch (state) {
  10938. case 0 /* inMemberExp */:
  10939. if (char === "[") {
  10940. stateStack.push(state);
  10941. state = 1 /* inBrackets */;
  10942. currentOpenBracketCount++;
  10943. } else if (char === "(") {
  10944. stateStack.push(state);
  10945. state = 2 /* inParens */;
  10946. currentOpenParensCount++;
  10947. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  10948. return false;
  10949. }
  10950. break;
  10951. case 1 /* inBrackets */:
  10952. if (char === `'` || char === `"` || char === "`") {
  10953. stateStack.push(state);
  10954. state = 3 /* inString */;
  10955. currentStringType = char;
  10956. } else if (char === `[`) {
  10957. currentOpenBracketCount++;
  10958. } else if (char === `]`) {
  10959. if (!--currentOpenBracketCount) {
  10960. state = stateStack.pop();
  10961. }
  10962. }
  10963. break;
  10964. case 2 /* inParens */:
  10965. if (char === `'` || char === `"` || char === "`") {
  10966. stateStack.push(state);
  10967. state = 3 /* inString */;
  10968. currentStringType = char;
  10969. } else if (char === `(`) {
  10970. currentOpenParensCount++;
  10971. } else if (char === `)`) {
  10972. if (i === path.length - 1) {
  10973. return false;
  10974. }
  10975. if (!--currentOpenParensCount) {
  10976. state = stateStack.pop();
  10977. }
  10978. }
  10979. break;
  10980. case 3 /* inString */:
  10981. if (char === currentStringType) {
  10982. state = stateStack.pop();
  10983. currentStringType = null;
  10984. }
  10985. break;
  10986. }
  10987. }
  10988. return !currentOpenBracketCount && !currentOpenParensCount;
  10989. };
  10990. const isMemberExpression = isMemberExpressionBrowser ;
  10991. function getInnerRange(loc, offset, length) {
  10992. const source = loc.source.slice(offset, offset + length);
  10993. const newLoc = {
  10994. source,
  10995. start: advancePositionWithClone(loc.start, loc.source, offset),
  10996. end: loc.end
  10997. };
  10998. if (length != null) {
  10999. newLoc.end = advancePositionWithClone(
  11000. loc.start,
  11001. loc.source,
  11002. offset + length
  11003. );
  11004. }
  11005. return newLoc;
  11006. }
  11007. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  11008. return advancePositionWithMutation(
  11009. extend({}, pos),
  11010. source,
  11011. numberOfCharacters
  11012. );
  11013. }
  11014. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  11015. let linesCount = 0;
  11016. let lastNewLinePos = -1;
  11017. for (let i = 0; i < numberOfCharacters; i++) {
  11018. if (source.charCodeAt(i) === 10) {
  11019. linesCount++;
  11020. lastNewLinePos = i;
  11021. }
  11022. }
  11023. pos.offset += numberOfCharacters;
  11024. pos.line += linesCount;
  11025. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  11026. return pos;
  11027. }
  11028. function assert(condition, msg) {
  11029. if (!condition) {
  11030. throw new Error(msg || `unexpected compiler condition`);
  11031. }
  11032. }
  11033. function findDir(node, name, allowEmpty = false) {
  11034. for (let i = 0; i < node.props.length; i++) {
  11035. const p = node.props[i];
  11036. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  11037. return p;
  11038. }
  11039. }
  11040. }
  11041. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  11042. for (let i = 0; i < node.props.length; i++) {
  11043. const p = node.props[i];
  11044. if (p.type === 6) {
  11045. if (dynamicOnly)
  11046. continue;
  11047. if (p.name === name && (p.value || allowEmpty)) {
  11048. return p;
  11049. }
  11050. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  11051. return p;
  11052. }
  11053. }
  11054. }
  11055. function isStaticArgOf(arg, name) {
  11056. return !!(arg && isStaticExp(arg) && arg.content === name);
  11057. }
  11058. function hasDynamicKeyVBind(node) {
  11059. return node.props.some(
  11060. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  11061. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  11062. !p.arg.isStatic)
  11063. // v-bind:[foo]
  11064. );
  11065. }
  11066. function isText$1(node) {
  11067. return node.type === 5 || node.type === 2;
  11068. }
  11069. function isVSlot(p) {
  11070. return p.type === 7 && p.name === "slot";
  11071. }
  11072. function isTemplateNode(node) {
  11073. return node.type === 1 && node.tagType === 3;
  11074. }
  11075. function isSlotOutlet(node) {
  11076. return node.type === 1 && node.tagType === 2;
  11077. }
  11078. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  11079. function getUnnormalizedProps(props, callPath = []) {
  11080. if (props && !isString(props) && props.type === 14) {
  11081. const callee = props.callee;
  11082. if (!isString(callee) && propsHelperSet.has(callee)) {
  11083. return getUnnormalizedProps(
  11084. props.arguments[0],
  11085. callPath.concat(props)
  11086. );
  11087. }
  11088. }
  11089. return [props, callPath];
  11090. }
  11091. function injectProp(node, prop, context) {
  11092. let propsWithInjection;
  11093. let props = node.type === 13 ? node.props : node.arguments[2];
  11094. let callPath = [];
  11095. let parentCall;
  11096. if (props && !isString(props) && props.type === 14) {
  11097. const ret = getUnnormalizedProps(props);
  11098. props = ret[0];
  11099. callPath = ret[1];
  11100. parentCall = callPath[callPath.length - 1];
  11101. }
  11102. if (props == null || isString(props)) {
  11103. propsWithInjection = createObjectExpression([prop]);
  11104. } else if (props.type === 14) {
  11105. const first = props.arguments[0];
  11106. if (!isString(first) && first.type === 15) {
  11107. if (!hasProp(prop, first)) {
  11108. first.properties.unshift(prop);
  11109. }
  11110. } else {
  11111. if (props.callee === TO_HANDLERS) {
  11112. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  11113. createObjectExpression([prop]),
  11114. props
  11115. ]);
  11116. } else {
  11117. props.arguments.unshift(createObjectExpression([prop]));
  11118. }
  11119. }
  11120. !propsWithInjection && (propsWithInjection = props);
  11121. } else if (props.type === 15) {
  11122. if (!hasProp(prop, props)) {
  11123. props.properties.unshift(prop);
  11124. }
  11125. propsWithInjection = props;
  11126. } else {
  11127. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  11128. createObjectExpression([prop]),
  11129. props
  11130. ]);
  11131. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  11132. parentCall = callPath[callPath.length - 2];
  11133. }
  11134. }
  11135. if (node.type === 13) {
  11136. if (parentCall) {
  11137. parentCall.arguments[0] = propsWithInjection;
  11138. } else {
  11139. node.props = propsWithInjection;
  11140. }
  11141. } else {
  11142. if (parentCall) {
  11143. parentCall.arguments[0] = propsWithInjection;
  11144. } else {
  11145. node.arguments[2] = propsWithInjection;
  11146. }
  11147. }
  11148. }
  11149. function hasProp(prop, props) {
  11150. let result = false;
  11151. if (prop.key.type === 4) {
  11152. const propKeyName = prop.key.content;
  11153. result = props.properties.some(
  11154. (p) => p.key.type === 4 && p.key.content === propKeyName
  11155. );
  11156. }
  11157. return result;
  11158. }
  11159. function toValidAssetId(name, type) {
  11160. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  11161. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  11162. })}`;
  11163. }
  11164. function getMemoedVNodeCall(node) {
  11165. if (node.type === 14 && node.callee === WITH_MEMO) {
  11166. return node.arguments[1].returns;
  11167. } else {
  11168. return node;
  11169. }
  11170. }
  11171. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  11172. const decodeRE = /&(gt|lt|amp|apos|quot);/g;
  11173. const decodeMap = {
  11174. gt: ">",
  11175. lt: "<",
  11176. amp: "&",
  11177. apos: "'",
  11178. quot: '"'
  11179. };
  11180. const defaultParserOptions = {
  11181. delimiters: [`{{`, `}}`],
  11182. getNamespace: () => 0,
  11183. getTextMode: () => 0,
  11184. isVoidTag: NO,
  11185. isPreTag: NO,
  11186. isCustomElement: NO,
  11187. decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
  11188. onError: defaultOnError,
  11189. onWarn: defaultOnWarn,
  11190. comments: true
  11191. };
  11192. function baseParse(content, options = {}) {
  11193. const context = createParserContext(content, options);
  11194. const start = getCursor(context);
  11195. return createRoot(
  11196. parseChildren(context, 0, []),
  11197. getSelection(context, start)
  11198. );
  11199. }
  11200. function createParserContext(content, rawOptions) {
  11201. const options = extend({}, defaultParserOptions);
  11202. let key;
  11203. for (key in rawOptions) {
  11204. options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
  11205. }
  11206. return {
  11207. options,
  11208. column: 1,
  11209. line: 1,
  11210. offset: 0,
  11211. originalSource: content,
  11212. source: content,
  11213. inPre: false,
  11214. inVPre: false,
  11215. onWarn: options.onWarn
  11216. };
  11217. }
  11218. function parseChildren(context, mode, ancestors) {
  11219. const parent = last(ancestors);
  11220. const ns = parent ? parent.ns : 0;
  11221. const nodes = [];
  11222. while (!isEnd(context, mode, ancestors)) {
  11223. const s = context.source;
  11224. let node = void 0;
  11225. if (mode === 0 || mode === 1) {
  11226. if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
  11227. node = parseInterpolation(context, mode);
  11228. } else if (mode === 0 && s[0] === "<") {
  11229. if (s.length === 1) {
  11230. emitError(context, 5, 1);
  11231. } else if (s[1] === "!") {
  11232. if (startsWith(s, "<!--")) {
  11233. node = parseComment(context);
  11234. } else if (startsWith(s, "<!DOCTYPE")) {
  11235. node = parseBogusComment(context);
  11236. } else if (startsWith(s, "<![CDATA[")) {
  11237. if (ns !== 0) {
  11238. node = parseCDATA(context, ancestors);
  11239. } else {
  11240. emitError(context, 1);
  11241. node = parseBogusComment(context);
  11242. }
  11243. } else {
  11244. emitError(context, 11);
  11245. node = parseBogusComment(context);
  11246. }
  11247. } else if (s[1] === "/") {
  11248. if (s.length === 2) {
  11249. emitError(context, 5, 2);
  11250. } else if (s[2] === ">") {
  11251. emitError(context, 14, 2);
  11252. advanceBy(context, 3);
  11253. continue;
  11254. } else if (/[a-z]/i.test(s[2])) {
  11255. emitError(context, 23);
  11256. parseTag(context, 1 /* End */, parent);
  11257. continue;
  11258. } else {
  11259. emitError(
  11260. context,
  11261. 12,
  11262. 2
  11263. );
  11264. node = parseBogusComment(context);
  11265. }
  11266. } else if (/[a-z]/i.test(s[1])) {
  11267. node = parseElement(context, ancestors);
  11268. } else if (s[1] === "?") {
  11269. emitError(
  11270. context,
  11271. 21,
  11272. 1
  11273. );
  11274. node = parseBogusComment(context);
  11275. } else {
  11276. emitError(context, 12, 1);
  11277. }
  11278. }
  11279. }
  11280. if (!node) {
  11281. node = parseText(context, mode);
  11282. }
  11283. if (isArray(node)) {
  11284. for (let i = 0; i < node.length; i++) {
  11285. pushNode(nodes, node[i]);
  11286. }
  11287. } else {
  11288. pushNode(nodes, node);
  11289. }
  11290. }
  11291. let removedWhitespace = false;
  11292. if (mode !== 2 && mode !== 1) {
  11293. const shouldCondense = context.options.whitespace !== "preserve";
  11294. for (let i = 0; i < nodes.length; i++) {
  11295. const node = nodes[i];
  11296. if (node.type === 2) {
  11297. if (!context.inPre) {
  11298. if (!/[^\t\r\n\f ]/.test(node.content)) {
  11299. const prev = nodes[i - 1];
  11300. const next = nodes[i + 1];
  11301. if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
  11302. removedWhitespace = true;
  11303. nodes[i] = null;
  11304. } else {
  11305. node.content = " ";
  11306. }
  11307. } else if (shouldCondense) {
  11308. node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
  11309. }
  11310. } else {
  11311. node.content = node.content.replace(/\r\n/g, "\n");
  11312. }
  11313. } else if (node.type === 3 && !context.options.comments) {
  11314. removedWhitespace = true;
  11315. nodes[i] = null;
  11316. }
  11317. }
  11318. if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
  11319. const first = nodes[0];
  11320. if (first && first.type === 2) {
  11321. first.content = first.content.replace(/^\r?\n/, "");
  11322. }
  11323. }
  11324. }
  11325. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  11326. }
  11327. function pushNode(nodes, node) {
  11328. if (node.type === 2) {
  11329. const prev = last(nodes);
  11330. if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
  11331. prev.content += node.content;
  11332. prev.loc.end = node.loc.end;
  11333. prev.loc.source += node.loc.source;
  11334. return;
  11335. }
  11336. }
  11337. nodes.push(node);
  11338. }
  11339. function parseCDATA(context, ancestors) {
  11340. advanceBy(context, 9);
  11341. const nodes = parseChildren(context, 3, ancestors);
  11342. if (context.source.length === 0) {
  11343. emitError(context, 6);
  11344. } else {
  11345. advanceBy(context, 3);
  11346. }
  11347. return nodes;
  11348. }
  11349. function parseComment(context) {
  11350. const start = getCursor(context);
  11351. let content;
  11352. const match = /--(\!)?>/.exec(context.source);
  11353. if (!match) {
  11354. content = context.source.slice(4);
  11355. advanceBy(context, context.source.length);
  11356. emitError(context, 7);
  11357. } else {
  11358. if (match.index <= 3) {
  11359. emitError(context, 0);
  11360. }
  11361. if (match[1]) {
  11362. emitError(context, 10);
  11363. }
  11364. content = context.source.slice(4, match.index);
  11365. const s = context.source.slice(0, match.index);
  11366. let prevIndex = 1, nestedIndex = 0;
  11367. while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
  11368. advanceBy(context, nestedIndex - prevIndex + 1);
  11369. if (nestedIndex + 4 < s.length) {
  11370. emitError(context, 16);
  11371. }
  11372. prevIndex = nestedIndex + 1;
  11373. }
  11374. advanceBy(context, match.index + match[0].length - prevIndex + 1);
  11375. }
  11376. return {
  11377. type: 3,
  11378. content,
  11379. loc: getSelection(context, start)
  11380. };
  11381. }
  11382. function parseBogusComment(context) {
  11383. const start = getCursor(context);
  11384. const contentStart = context.source[1] === "?" ? 1 : 2;
  11385. let content;
  11386. const closeIndex = context.source.indexOf(">");
  11387. if (closeIndex === -1) {
  11388. content = context.source.slice(contentStart);
  11389. advanceBy(context, context.source.length);
  11390. } else {
  11391. content = context.source.slice(contentStart, closeIndex);
  11392. advanceBy(context, closeIndex + 1);
  11393. }
  11394. return {
  11395. type: 3,
  11396. content,
  11397. loc: getSelection(context, start)
  11398. };
  11399. }
  11400. function parseElement(context, ancestors) {
  11401. const wasInPre = context.inPre;
  11402. const wasInVPre = context.inVPre;
  11403. const parent = last(ancestors);
  11404. const element = parseTag(context, 0 /* Start */, parent);
  11405. const isPreBoundary = context.inPre && !wasInPre;
  11406. const isVPreBoundary = context.inVPre && !wasInVPre;
  11407. if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
  11408. if (isPreBoundary) {
  11409. context.inPre = false;
  11410. }
  11411. if (isVPreBoundary) {
  11412. context.inVPre = false;
  11413. }
  11414. return element;
  11415. }
  11416. ancestors.push(element);
  11417. const mode = context.options.getTextMode(element, parent);
  11418. const children = parseChildren(context, mode, ancestors);
  11419. ancestors.pop();
  11420. element.children = children;
  11421. if (startsWithEndTagOpen(context.source, element.tag)) {
  11422. parseTag(context, 1 /* End */, parent);
  11423. } else {
  11424. emitError(context, 24, 0, element.loc.start);
  11425. if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
  11426. const first = children[0];
  11427. if (first && startsWith(first.loc.source, "<!--")) {
  11428. emitError(context, 8);
  11429. }
  11430. }
  11431. }
  11432. element.loc = getSelection(context, element.loc.start);
  11433. if (isPreBoundary) {
  11434. context.inPre = false;
  11435. }
  11436. if (isVPreBoundary) {
  11437. context.inVPre = false;
  11438. }
  11439. return element;
  11440. }
  11441. const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
  11442. `if,else,else-if,for,slot`
  11443. );
  11444. function parseTag(context, type, parent) {
  11445. const start = getCursor(context);
  11446. const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
  11447. const tag = match[1];
  11448. const ns = context.options.getNamespace(tag, parent);
  11449. advanceBy(context, match[0].length);
  11450. advanceSpaces(context);
  11451. const cursor = getCursor(context);
  11452. const currentSource = context.source;
  11453. if (context.options.isPreTag(tag)) {
  11454. context.inPre = true;
  11455. }
  11456. let props = parseAttributes(context, type);
  11457. if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
  11458. context.inVPre = true;
  11459. extend(context, cursor);
  11460. context.source = currentSource;
  11461. props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
  11462. }
  11463. let isSelfClosing = false;
  11464. if (context.source.length === 0) {
  11465. emitError(context, 9);
  11466. } else {
  11467. isSelfClosing = startsWith(context.source, "/>");
  11468. if (type === 1 /* End */ && isSelfClosing) {
  11469. emitError(context, 4);
  11470. }
  11471. advanceBy(context, isSelfClosing ? 2 : 1);
  11472. }
  11473. if (type === 1 /* End */) {
  11474. return;
  11475. }
  11476. let tagType = 0;
  11477. if (!context.inVPre) {
  11478. if (tag === "slot") {
  11479. tagType = 2;
  11480. } else if (tag === "template") {
  11481. if (props.some(
  11482. (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
  11483. )) {
  11484. tagType = 3;
  11485. }
  11486. } else if (isComponent(tag, props, context)) {
  11487. tagType = 1;
  11488. }
  11489. }
  11490. return {
  11491. type: 1,
  11492. ns,
  11493. tag,
  11494. tagType,
  11495. props,
  11496. isSelfClosing,
  11497. children: [],
  11498. loc: getSelection(context, start),
  11499. codegenNode: void 0
  11500. // to be created during transform phase
  11501. };
  11502. }
  11503. function isComponent(tag, props, context) {
  11504. const options = context.options;
  11505. if (options.isCustomElement(tag)) {
  11506. return false;
  11507. }
  11508. if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
  11509. return true;
  11510. }
  11511. for (let i = 0; i < props.length; i++) {
  11512. const p = props[i];
  11513. if (p.type === 6) {
  11514. if (p.name === "is" && p.value) {
  11515. if (p.value.content.startsWith("vue:")) {
  11516. return true;
  11517. }
  11518. }
  11519. } else {
  11520. if (p.name === "is") {
  11521. return true;
  11522. } else if (
  11523. // :is on plain element - only treat as component in compat mode
  11524. p.name === "bind" && isStaticArgOf(p.arg, "is") && false
  11525. ) {
  11526. return true;
  11527. }
  11528. }
  11529. }
  11530. }
  11531. function parseAttributes(context, type) {
  11532. const props = [];
  11533. const attributeNames = /* @__PURE__ */ new Set();
  11534. while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
  11535. if (startsWith(context.source, "/")) {
  11536. emitError(context, 22);
  11537. advanceBy(context, 1);
  11538. advanceSpaces(context);
  11539. continue;
  11540. }
  11541. if (type === 1 /* End */) {
  11542. emitError(context, 3);
  11543. }
  11544. const attr = parseAttribute(context, attributeNames);
  11545. if (attr.type === 6 && attr.value && attr.name === "class") {
  11546. attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
  11547. }
  11548. if (type === 0 /* Start */) {
  11549. props.push(attr);
  11550. }
  11551. if (/^[^\t\r\n\f />]/.test(context.source)) {
  11552. emitError(context, 15);
  11553. }
  11554. advanceSpaces(context);
  11555. }
  11556. return props;
  11557. }
  11558. function parseAttribute(context, nameSet) {
  11559. var _a;
  11560. const start = getCursor(context);
  11561. const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
  11562. const name = match[0];
  11563. if (nameSet.has(name)) {
  11564. emitError(context, 2);
  11565. }
  11566. nameSet.add(name);
  11567. if (name[0] === "=") {
  11568. emitError(context, 19);
  11569. }
  11570. {
  11571. const pattern = /["'<]/g;
  11572. let m;
  11573. while (m = pattern.exec(name)) {
  11574. emitError(
  11575. context,
  11576. 17,
  11577. m.index
  11578. );
  11579. }
  11580. }
  11581. advanceBy(context, name.length);
  11582. let value = void 0;
  11583. if (/^[\t\r\n\f ]*=/.test(context.source)) {
  11584. advanceSpaces(context);
  11585. advanceBy(context, 1);
  11586. advanceSpaces(context);
  11587. value = parseAttributeValue(context);
  11588. if (!value) {
  11589. emitError(context, 13);
  11590. }
  11591. }
  11592. const loc = getSelection(context, start);
  11593. if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
  11594. const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
  11595. name
  11596. );
  11597. let isPropShorthand = startsWith(name, ".");
  11598. let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
  11599. let arg;
  11600. if (match2[2]) {
  11601. const isSlot = dirName === "slot";
  11602. const startOffset = name.lastIndexOf(
  11603. match2[2],
  11604. name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
  11605. );
  11606. const loc2 = getSelection(
  11607. context,
  11608. getNewPosition(context, start, startOffset),
  11609. getNewPosition(
  11610. context,
  11611. start,
  11612. startOffset + match2[2].length + (isSlot && match2[3] || "").length
  11613. )
  11614. );
  11615. let content = match2[2];
  11616. let isStatic = true;
  11617. if (content.startsWith("[")) {
  11618. isStatic = false;
  11619. if (!content.endsWith("]")) {
  11620. emitError(
  11621. context,
  11622. 27
  11623. );
  11624. content = content.slice(1);
  11625. } else {
  11626. content = content.slice(1, content.length - 1);
  11627. }
  11628. } else if (isSlot) {
  11629. content += match2[3] || "";
  11630. }
  11631. arg = {
  11632. type: 4,
  11633. content,
  11634. isStatic,
  11635. constType: isStatic ? 3 : 0,
  11636. loc: loc2
  11637. };
  11638. }
  11639. if (value && value.isQuoted) {
  11640. const valueLoc = value.loc;
  11641. valueLoc.start.offset++;
  11642. valueLoc.start.column++;
  11643. valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
  11644. valueLoc.source = valueLoc.source.slice(1, -1);
  11645. }
  11646. const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
  11647. if (isPropShorthand)
  11648. modifiers.push("prop");
  11649. return {
  11650. type: 7,
  11651. name: dirName,
  11652. exp: value && {
  11653. type: 4,
  11654. content: value.content,
  11655. isStatic: false,
  11656. // Treat as non-constant by default. This can be potentially set to
  11657. // other values by `transformExpression` to make it eligible for hoisting.
  11658. constType: 0,
  11659. loc: value.loc
  11660. },
  11661. arg,
  11662. modifiers,
  11663. loc
  11664. };
  11665. }
  11666. if (!context.inVPre && startsWith(name, "v-")) {
  11667. emitError(context, 26);
  11668. }
  11669. return {
  11670. type: 6,
  11671. name,
  11672. value: value && {
  11673. type: 2,
  11674. content: value.content,
  11675. loc: value.loc
  11676. },
  11677. loc
  11678. };
  11679. }
  11680. function parseAttributeValue(context) {
  11681. const start = getCursor(context);
  11682. let content;
  11683. const quote = context.source[0];
  11684. const isQuoted = quote === `"` || quote === `'`;
  11685. if (isQuoted) {
  11686. advanceBy(context, 1);
  11687. const endIndex = context.source.indexOf(quote);
  11688. if (endIndex === -1) {
  11689. content = parseTextData(
  11690. context,
  11691. context.source.length,
  11692. 4
  11693. );
  11694. } else {
  11695. content = parseTextData(context, endIndex, 4);
  11696. advanceBy(context, 1);
  11697. }
  11698. } else {
  11699. const match = /^[^\t\r\n\f >]+/.exec(context.source);
  11700. if (!match) {
  11701. return void 0;
  11702. }
  11703. const unexpectedChars = /["'<=`]/g;
  11704. let m;
  11705. while (m = unexpectedChars.exec(match[0])) {
  11706. emitError(
  11707. context,
  11708. 18,
  11709. m.index
  11710. );
  11711. }
  11712. content = parseTextData(context, match[0].length, 4);
  11713. }
  11714. return { content, isQuoted, loc: getSelection(context, start) };
  11715. }
  11716. function parseInterpolation(context, mode) {
  11717. const [open, close] = context.options.delimiters;
  11718. const closeIndex = context.source.indexOf(close, open.length);
  11719. if (closeIndex === -1) {
  11720. emitError(context, 25);
  11721. return void 0;
  11722. }
  11723. const start = getCursor(context);
  11724. advanceBy(context, open.length);
  11725. const innerStart = getCursor(context);
  11726. const innerEnd = getCursor(context);
  11727. const rawContentLength = closeIndex - open.length;
  11728. const rawContent = context.source.slice(0, rawContentLength);
  11729. const preTrimContent = parseTextData(context, rawContentLength, mode);
  11730. const content = preTrimContent.trim();
  11731. const startOffset = preTrimContent.indexOf(content);
  11732. if (startOffset > 0) {
  11733. advancePositionWithMutation(innerStart, rawContent, startOffset);
  11734. }
  11735. const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
  11736. advancePositionWithMutation(innerEnd, rawContent, endOffset);
  11737. advanceBy(context, close.length);
  11738. return {
  11739. type: 5,
  11740. content: {
  11741. type: 4,
  11742. isStatic: false,
  11743. // Set `isConstant` to false by default and will decide in transformExpression
  11744. constType: 0,
  11745. content,
  11746. loc: getSelection(context, innerStart, innerEnd)
  11747. },
  11748. loc: getSelection(context, start)
  11749. };
  11750. }
  11751. function parseText(context, mode) {
  11752. const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
  11753. let endIndex = context.source.length;
  11754. for (let i = 0; i < endTokens.length; i++) {
  11755. const index = context.source.indexOf(endTokens[i], 1);
  11756. if (index !== -1 && endIndex > index) {
  11757. endIndex = index;
  11758. }
  11759. }
  11760. const start = getCursor(context);
  11761. const content = parseTextData(context, endIndex, mode);
  11762. return {
  11763. type: 2,
  11764. content,
  11765. loc: getSelection(context, start)
  11766. };
  11767. }
  11768. function parseTextData(context, length, mode) {
  11769. const rawText = context.source.slice(0, length);
  11770. advanceBy(context, length);
  11771. if (mode === 2 || mode === 3 || !rawText.includes("&")) {
  11772. return rawText;
  11773. } else {
  11774. return context.options.decodeEntities(
  11775. rawText,
  11776. mode === 4
  11777. );
  11778. }
  11779. }
  11780. function getCursor(context) {
  11781. const { column, line, offset } = context;
  11782. return { column, line, offset };
  11783. }
  11784. function getSelection(context, start, end) {
  11785. end = end || getCursor(context);
  11786. return {
  11787. start,
  11788. end,
  11789. source: context.originalSource.slice(start.offset, end.offset)
  11790. };
  11791. }
  11792. function last(xs) {
  11793. return xs[xs.length - 1];
  11794. }
  11795. function startsWith(source, searchString) {
  11796. return source.startsWith(searchString);
  11797. }
  11798. function advanceBy(context, numberOfCharacters) {
  11799. const { source } = context;
  11800. advancePositionWithMutation(context, source, numberOfCharacters);
  11801. context.source = source.slice(numberOfCharacters);
  11802. }
  11803. function advanceSpaces(context) {
  11804. const match = /^[\t\r\n\f ]+/.exec(context.source);
  11805. if (match) {
  11806. advanceBy(context, match[0].length);
  11807. }
  11808. }
  11809. function getNewPosition(context, start, numberOfCharacters) {
  11810. return advancePositionWithClone(
  11811. start,
  11812. context.originalSource.slice(start.offset, numberOfCharacters),
  11813. numberOfCharacters
  11814. );
  11815. }
  11816. function emitError(context, code, offset, loc = getCursor(context)) {
  11817. if (offset) {
  11818. loc.offset += offset;
  11819. loc.column += offset;
  11820. }
  11821. context.options.onError(
  11822. createCompilerError(code, {
  11823. start: loc,
  11824. end: loc,
  11825. source: ""
  11826. })
  11827. );
  11828. }
  11829. function isEnd(context, mode, ancestors) {
  11830. const s = context.source;
  11831. switch (mode) {
  11832. case 0:
  11833. if (startsWith(s, "</")) {
  11834. for (let i = ancestors.length - 1; i >= 0; --i) {
  11835. if (startsWithEndTagOpen(s, ancestors[i].tag)) {
  11836. return true;
  11837. }
  11838. }
  11839. }
  11840. break;
  11841. case 1:
  11842. case 2: {
  11843. const parent = last(ancestors);
  11844. if (parent && startsWithEndTagOpen(s, parent.tag)) {
  11845. return true;
  11846. }
  11847. break;
  11848. }
  11849. case 3:
  11850. if (startsWith(s, "]]>")) {
  11851. return true;
  11852. }
  11853. break;
  11854. }
  11855. return !s;
  11856. }
  11857. function startsWithEndTagOpen(source, tag) {
  11858. return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
  11859. }
  11860. function hoistStatic(root, context) {
  11861. walk(
  11862. root,
  11863. context,
  11864. // Root node is unfortunately non-hoistable due to potential parent
  11865. // fallthrough attributes.
  11866. isSingleElementRoot(root, root.children[0])
  11867. );
  11868. }
  11869. function isSingleElementRoot(root, child) {
  11870. const { children } = root;
  11871. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  11872. }
  11873. function walk(node, context, doNotHoistNode = false) {
  11874. const { children } = node;
  11875. const originalCount = children.length;
  11876. let hoistedCount = 0;
  11877. for (let i = 0; i < children.length; i++) {
  11878. const child = children[i];
  11879. if (child.type === 1 && child.tagType === 0) {
  11880. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  11881. if (constantType > 0) {
  11882. if (constantType >= 2) {
  11883. child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
  11884. child.codegenNode = context.hoist(child.codegenNode);
  11885. hoistedCount++;
  11886. continue;
  11887. }
  11888. } else {
  11889. const codegenNode = child.codegenNode;
  11890. if (codegenNode.type === 13) {
  11891. const flag = getPatchFlag(codegenNode);
  11892. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  11893. const props = getNodeProps(child);
  11894. if (props) {
  11895. codegenNode.props = context.hoist(props);
  11896. }
  11897. }
  11898. if (codegenNode.dynamicProps) {
  11899. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  11900. }
  11901. }
  11902. }
  11903. }
  11904. if (child.type === 1) {
  11905. const isComponent = child.tagType === 1;
  11906. if (isComponent) {
  11907. context.scopes.vSlot++;
  11908. }
  11909. walk(child, context);
  11910. if (isComponent) {
  11911. context.scopes.vSlot--;
  11912. }
  11913. } else if (child.type === 11) {
  11914. walk(child, context, child.children.length === 1);
  11915. } else if (child.type === 9) {
  11916. for (let i2 = 0; i2 < child.branches.length; i2++) {
  11917. walk(
  11918. child.branches[i2],
  11919. context,
  11920. child.branches[i2].children.length === 1
  11921. );
  11922. }
  11923. }
  11924. }
  11925. if (hoistedCount && context.transformHoist) {
  11926. context.transformHoist(children, context, node);
  11927. }
  11928. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  11929. const hoisted = context.hoist(
  11930. createArrayExpression(node.codegenNode.children)
  11931. );
  11932. if (context.hmr) {
  11933. hoisted.content = `[...${hoisted.content}]`;
  11934. }
  11935. node.codegenNode.children = hoisted;
  11936. }
  11937. }
  11938. function getConstantType(node, context) {
  11939. const { constantCache } = context;
  11940. switch (node.type) {
  11941. case 1:
  11942. if (node.tagType !== 0) {
  11943. return 0;
  11944. }
  11945. const cached = constantCache.get(node);
  11946. if (cached !== void 0) {
  11947. return cached;
  11948. }
  11949. const codegenNode = node.codegenNode;
  11950. if (codegenNode.type !== 13) {
  11951. return 0;
  11952. }
  11953. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  11954. return 0;
  11955. }
  11956. const flag = getPatchFlag(codegenNode);
  11957. if (!flag) {
  11958. let returnType2 = 3;
  11959. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  11960. if (generatedPropsType === 0) {
  11961. constantCache.set(node, 0);
  11962. return 0;
  11963. }
  11964. if (generatedPropsType < returnType2) {
  11965. returnType2 = generatedPropsType;
  11966. }
  11967. for (let i = 0; i < node.children.length; i++) {
  11968. const childType = getConstantType(node.children[i], context);
  11969. if (childType === 0) {
  11970. constantCache.set(node, 0);
  11971. return 0;
  11972. }
  11973. if (childType < returnType2) {
  11974. returnType2 = childType;
  11975. }
  11976. }
  11977. if (returnType2 > 1) {
  11978. for (let i = 0; i < node.props.length; i++) {
  11979. const p = node.props[i];
  11980. if (p.type === 7 && p.name === "bind" && p.exp) {
  11981. const expType = getConstantType(p.exp, context);
  11982. if (expType === 0) {
  11983. constantCache.set(node, 0);
  11984. return 0;
  11985. }
  11986. if (expType < returnType2) {
  11987. returnType2 = expType;
  11988. }
  11989. }
  11990. }
  11991. }
  11992. if (codegenNode.isBlock) {
  11993. for (let i = 0; i < node.props.length; i++) {
  11994. const p = node.props[i];
  11995. if (p.type === 7) {
  11996. constantCache.set(node, 0);
  11997. return 0;
  11998. }
  11999. }
  12000. context.removeHelper(OPEN_BLOCK);
  12001. context.removeHelper(
  12002. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  12003. );
  12004. codegenNode.isBlock = false;
  12005. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  12006. }
  12007. constantCache.set(node, returnType2);
  12008. return returnType2;
  12009. } else {
  12010. constantCache.set(node, 0);
  12011. return 0;
  12012. }
  12013. case 2:
  12014. case 3:
  12015. return 3;
  12016. case 9:
  12017. case 11:
  12018. case 10:
  12019. return 0;
  12020. case 5:
  12021. case 12:
  12022. return getConstantType(node.content, context);
  12023. case 4:
  12024. return node.constType;
  12025. case 8:
  12026. let returnType = 3;
  12027. for (let i = 0; i < node.children.length; i++) {
  12028. const child = node.children[i];
  12029. if (isString(child) || isSymbol(child)) {
  12030. continue;
  12031. }
  12032. const childType = getConstantType(child, context);
  12033. if (childType === 0) {
  12034. return 0;
  12035. } else if (childType < returnType) {
  12036. returnType = childType;
  12037. }
  12038. }
  12039. return returnType;
  12040. default:
  12041. return 0;
  12042. }
  12043. }
  12044. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  12045. NORMALIZE_CLASS,
  12046. NORMALIZE_STYLE,
  12047. NORMALIZE_PROPS,
  12048. GUARD_REACTIVE_PROPS
  12049. ]);
  12050. function getConstantTypeOfHelperCall(value, context) {
  12051. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  12052. const arg = value.arguments[0];
  12053. if (arg.type === 4) {
  12054. return getConstantType(arg, context);
  12055. } else if (arg.type === 14) {
  12056. return getConstantTypeOfHelperCall(arg, context);
  12057. }
  12058. }
  12059. return 0;
  12060. }
  12061. function getGeneratedPropsConstantType(node, context) {
  12062. let returnType = 3;
  12063. const props = getNodeProps(node);
  12064. if (props && props.type === 15) {
  12065. const { properties } = props;
  12066. for (let i = 0; i < properties.length; i++) {
  12067. const { key, value } = properties[i];
  12068. const keyType = getConstantType(key, context);
  12069. if (keyType === 0) {
  12070. return keyType;
  12071. }
  12072. if (keyType < returnType) {
  12073. returnType = keyType;
  12074. }
  12075. let valueType;
  12076. if (value.type === 4) {
  12077. valueType = getConstantType(value, context);
  12078. } else if (value.type === 14) {
  12079. valueType = getConstantTypeOfHelperCall(value, context);
  12080. } else {
  12081. valueType = 0;
  12082. }
  12083. if (valueType === 0) {
  12084. return valueType;
  12085. }
  12086. if (valueType < returnType) {
  12087. returnType = valueType;
  12088. }
  12089. }
  12090. }
  12091. return returnType;
  12092. }
  12093. function getNodeProps(node) {
  12094. const codegenNode = node.codegenNode;
  12095. if (codegenNode.type === 13) {
  12096. return codegenNode.props;
  12097. }
  12098. }
  12099. function getPatchFlag(node) {
  12100. const flag = node.patchFlag;
  12101. return flag ? parseInt(flag, 10) : void 0;
  12102. }
  12103. function createTransformContext(root, {
  12104. filename = "",
  12105. prefixIdentifiers = false,
  12106. hoistStatic: hoistStatic2 = false,
  12107. hmr = false,
  12108. cacheHandlers = false,
  12109. nodeTransforms = [],
  12110. directiveTransforms = {},
  12111. transformHoist = null,
  12112. isBuiltInComponent = NOOP,
  12113. isCustomElement = NOOP,
  12114. expressionPlugins = [],
  12115. scopeId = null,
  12116. slotted = true,
  12117. ssr = false,
  12118. inSSR = false,
  12119. ssrCssVars = ``,
  12120. bindingMetadata = EMPTY_OBJ,
  12121. inline = false,
  12122. isTS = false,
  12123. onError = defaultOnError,
  12124. onWarn = defaultOnWarn,
  12125. compatConfig
  12126. }) {
  12127. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  12128. const context = {
  12129. // options
  12130. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  12131. prefixIdentifiers,
  12132. hoistStatic: hoistStatic2,
  12133. hmr,
  12134. cacheHandlers,
  12135. nodeTransforms,
  12136. directiveTransforms,
  12137. transformHoist,
  12138. isBuiltInComponent,
  12139. isCustomElement,
  12140. expressionPlugins,
  12141. scopeId,
  12142. slotted,
  12143. ssr,
  12144. inSSR,
  12145. ssrCssVars,
  12146. bindingMetadata,
  12147. inline,
  12148. isTS,
  12149. onError,
  12150. onWarn,
  12151. compatConfig,
  12152. // state
  12153. root,
  12154. helpers: /* @__PURE__ */ new Map(),
  12155. components: /* @__PURE__ */ new Set(),
  12156. directives: /* @__PURE__ */ new Set(),
  12157. hoists: [],
  12158. imports: [],
  12159. constantCache: /* @__PURE__ */ new WeakMap(),
  12160. temps: 0,
  12161. cached: 0,
  12162. identifiers: /* @__PURE__ */ Object.create(null),
  12163. scopes: {
  12164. vFor: 0,
  12165. vSlot: 0,
  12166. vPre: 0,
  12167. vOnce: 0
  12168. },
  12169. parent: null,
  12170. currentNode: root,
  12171. childIndex: 0,
  12172. inVOnce: false,
  12173. // methods
  12174. helper(name) {
  12175. const count = context.helpers.get(name) || 0;
  12176. context.helpers.set(name, count + 1);
  12177. return name;
  12178. },
  12179. removeHelper(name) {
  12180. const count = context.helpers.get(name);
  12181. if (count) {
  12182. const currentCount = count - 1;
  12183. if (!currentCount) {
  12184. context.helpers.delete(name);
  12185. } else {
  12186. context.helpers.set(name, currentCount);
  12187. }
  12188. }
  12189. },
  12190. helperString(name) {
  12191. return `_${helperNameMap[context.helper(name)]}`;
  12192. },
  12193. replaceNode(node) {
  12194. {
  12195. if (!context.currentNode) {
  12196. throw new Error(`Node being replaced is already removed.`);
  12197. }
  12198. if (!context.parent) {
  12199. throw new Error(`Cannot replace root node.`);
  12200. }
  12201. }
  12202. context.parent.children[context.childIndex] = context.currentNode = node;
  12203. },
  12204. removeNode(node) {
  12205. if (!context.parent) {
  12206. throw new Error(`Cannot remove root node.`);
  12207. }
  12208. const list = context.parent.children;
  12209. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  12210. if (removalIndex < 0) {
  12211. throw new Error(`node being removed is not a child of current parent`);
  12212. }
  12213. if (!node || node === context.currentNode) {
  12214. context.currentNode = null;
  12215. context.onNodeRemoved();
  12216. } else {
  12217. if (context.childIndex > removalIndex) {
  12218. context.childIndex--;
  12219. context.onNodeRemoved();
  12220. }
  12221. }
  12222. context.parent.children.splice(removalIndex, 1);
  12223. },
  12224. onNodeRemoved: () => {
  12225. },
  12226. addIdentifiers(exp) {
  12227. },
  12228. removeIdentifiers(exp) {
  12229. },
  12230. hoist(exp) {
  12231. if (isString(exp))
  12232. exp = createSimpleExpression(exp);
  12233. context.hoists.push(exp);
  12234. const identifier = createSimpleExpression(
  12235. `_hoisted_${context.hoists.length}`,
  12236. false,
  12237. exp.loc,
  12238. 2
  12239. );
  12240. identifier.hoisted = exp;
  12241. return identifier;
  12242. },
  12243. cache(exp, isVNode = false) {
  12244. return createCacheExpression(context.cached++, exp, isVNode);
  12245. }
  12246. };
  12247. return context;
  12248. }
  12249. function transform(root, options) {
  12250. const context = createTransformContext(root, options);
  12251. traverseNode(root, context);
  12252. if (options.hoistStatic) {
  12253. hoistStatic(root, context);
  12254. }
  12255. if (!options.ssr) {
  12256. createRootCodegen(root, context);
  12257. }
  12258. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  12259. root.components = [...context.components];
  12260. root.directives = [...context.directives];
  12261. root.imports = context.imports;
  12262. root.hoists = context.hoists;
  12263. root.temps = context.temps;
  12264. root.cached = context.cached;
  12265. }
  12266. function createRootCodegen(root, context) {
  12267. const { helper } = context;
  12268. const { children } = root;
  12269. if (children.length === 1) {
  12270. const child = children[0];
  12271. if (isSingleElementRoot(root, child) && child.codegenNode) {
  12272. const codegenNode = child.codegenNode;
  12273. if (codegenNode.type === 13) {
  12274. convertToBlock(codegenNode, context);
  12275. }
  12276. root.codegenNode = codegenNode;
  12277. } else {
  12278. root.codegenNode = child;
  12279. }
  12280. } else if (children.length > 1) {
  12281. let patchFlag = 64;
  12282. let patchFlagText = PatchFlagNames[64];
  12283. if (children.filter((c) => c.type !== 3).length === 1) {
  12284. patchFlag |= 2048;
  12285. patchFlagText += `, ${PatchFlagNames[2048]}`;
  12286. }
  12287. root.codegenNode = createVNodeCall(
  12288. context,
  12289. helper(FRAGMENT),
  12290. void 0,
  12291. root.children,
  12292. patchFlag + (` /* ${patchFlagText} */` ),
  12293. void 0,
  12294. void 0,
  12295. true,
  12296. void 0,
  12297. false
  12298. /* isComponent */
  12299. );
  12300. } else ;
  12301. }
  12302. function traverseChildren(parent, context) {
  12303. let i = 0;
  12304. const nodeRemoved = () => {
  12305. i--;
  12306. };
  12307. for (; i < parent.children.length; i++) {
  12308. const child = parent.children[i];
  12309. if (isString(child))
  12310. continue;
  12311. context.parent = parent;
  12312. context.childIndex = i;
  12313. context.onNodeRemoved = nodeRemoved;
  12314. traverseNode(child, context);
  12315. }
  12316. }
  12317. function traverseNode(node, context) {
  12318. context.currentNode = node;
  12319. const { nodeTransforms } = context;
  12320. const exitFns = [];
  12321. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  12322. const onExit = nodeTransforms[i2](node, context);
  12323. if (onExit) {
  12324. if (isArray(onExit)) {
  12325. exitFns.push(...onExit);
  12326. } else {
  12327. exitFns.push(onExit);
  12328. }
  12329. }
  12330. if (!context.currentNode) {
  12331. return;
  12332. } else {
  12333. node = context.currentNode;
  12334. }
  12335. }
  12336. switch (node.type) {
  12337. case 3:
  12338. if (!context.ssr) {
  12339. context.helper(CREATE_COMMENT);
  12340. }
  12341. break;
  12342. case 5:
  12343. if (!context.ssr) {
  12344. context.helper(TO_DISPLAY_STRING);
  12345. }
  12346. break;
  12347. case 9:
  12348. for (let i2 = 0; i2 < node.branches.length; i2++) {
  12349. traverseNode(node.branches[i2], context);
  12350. }
  12351. break;
  12352. case 10:
  12353. case 11:
  12354. case 1:
  12355. case 0:
  12356. traverseChildren(node, context);
  12357. break;
  12358. }
  12359. context.currentNode = node;
  12360. let i = exitFns.length;
  12361. while (i--) {
  12362. exitFns[i]();
  12363. }
  12364. }
  12365. function createStructuralDirectiveTransform(name, fn) {
  12366. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  12367. return (node, context) => {
  12368. if (node.type === 1) {
  12369. const { props } = node;
  12370. if (node.tagType === 3 && props.some(isVSlot)) {
  12371. return;
  12372. }
  12373. const exitFns = [];
  12374. for (let i = 0; i < props.length; i++) {
  12375. const prop = props[i];
  12376. if (prop.type === 7 && matches(prop.name)) {
  12377. props.splice(i, 1);
  12378. i--;
  12379. const onExit = fn(node, prop, context);
  12380. if (onExit)
  12381. exitFns.push(onExit);
  12382. }
  12383. }
  12384. return exitFns;
  12385. }
  12386. };
  12387. }
  12388. const PURE_ANNOTATION = `/*#__PURE__*/`;
  12389. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  12390. function createCodegenContext(ast, {
  12391. mode = "function",
  12392. prefixIdentifiers = mode === "module",
  12393. sourceMap = false,
  12394. filename = `template.vue.html`,
  12395. scopeId = null,
  12396. optimizeImports = false,
  12397. runtimeGlobalName = `Vue`,
  12398. runtimeModuleName = `vue`,
  12399. ssrRuntimeModuleName = "vue/server-renderer",
  12400. ssr = false,
  12401. isTS = false,
  12402. inSSR = false
  12403. }) {
  12404. const context = {
  12405. mode,
  12406. prefixIdentifiers,
  12407. sourceMap,
  12408. filename,
  12409. scopeId,
  12410. optimizeImports,
  12411. runtimeGlobalName,
  12412. runtimeModuleName,
  12413. ssrRuntimeModuleName,
  12414. ssr,
  12415. isTS,
  12416. inSSR,
  12417. source: ast.loc.source,
  12418. code: ``,
  12419. column: 1,
  12420. line: 1,
  12421. offset: 0,
  12422. indentLevel: 0,
  12423. pure: false,
  12424. map: void 0,
  12425. helper(key) {
  12426. return `_${helperNameMap[key]}`;
  12427. },
  12428. push(code, node) {
  12429. context.code += code;
  12430. },
  12431. indent() {
  12432. newline(++context.indentLevel);
  12433. },
  12434. deindent(withoutNewLine = false) {
  12435. if (withoutNewLine) {
  12436. --context.indentLevel;
  12437. } else {
  12438. newline(--context.indentLevel);
  12439. }
  12440. },
  12441. newline() {
  12442. newline(context.indentLevel);
  12443. }
  12444. };
  12445. function newline(n) {
  12446. context.push("\n" + ` `.repeat(n));
  12447. }
  12448. return context;
  12449. }
  12450. function generate(ast, options = {}) {
  12451. const context = createCodegenContext(ast, options);
  12452. if (options.onContextCreated)
  12453. options.onContextCreated(context);
  12454. const {
  12455. mode,
  12456. push,
  12457. prefixIdentifiers,
  12458. indent,
  12459. deindent,
  12460. newline,
  12461. scopeId,
  12462. ssr
  12463. } = context;
  12464. const helpers = Array.from(ast.helpers);
  12465. const hasHelpers = helpers.length > 0;
  12466. const useWithBlock = !prefixIdentifiers && mode !== "module";
  12467. const isSetupInlined = false;
  12468. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  12469. {
  12470. genFunctionPreamble(ast, preambleContext);
  12471. }
  12472. const functionName = ssr ? `ssrRender` : `render`;
  12473. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  12474. const signature = args.join(", ");
  12475. {
  12476. push(`function ${functionName}(${signature}) {`);
  12477. }
  12478. indent();
  12479. if (useWithBlock) {
  12480. push(`with (_ctx) {`);
  12481. indent();
  12482. if (hasHelpers) {
  12483. push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
  12484. push(`
  12485. `);
  12486. newline();
  12487. }
  12488. }
  12489. if (ast.components.length) {
  12490. genAssets(ast.components, "component", context);
  12491. if (ast.directives.length || ast.temps > 0) {
  12492. newline();
  12493. }
  12494. }
  12495. if (ast.directives.length) {
  12496. genAssets(ast.directives, "directive", context);
  12497. if (ast.temps > 0) {
  12498. newline();
  12499. }
  12500. }
  12501. if (ast.temps > 0) {
  12502. push(`let `);
  12503. for (let i = 0; i < ast.temps; i++) {
  12504. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  12505. }
  12506. }
  12507. if (ast.components.length || ast.directives.length || ast.temps) {
  12508. push(`
  12509. `);
  12510. newline();
  12511. }
  12512. if (!ssr) {
  12513. push(`return `);
  12514. }
  12515. if (ast.codegenNode) {
  12516. genNode(ast.codegenNode, context);
  12517. } else {
  12518. push(`null`);
  12519. }
  12520. if (useWithBlock) {
  12521. deindent();
  12522. push(`}`);
  12523. }
  12524. deindent();
  12525. push(`}`);
  12526. return {
  12527. ast,
  12528. code: context.code,
  12529. preamble: isSetupInlined ? preambleContext.code : ``,
  12530. // SourceMapGenerator does have toJSON() method but it's not in the types
  12531. map: context.map ? context.map.toJSON() : void 0
  12532. };
  12533. }
  12534. function genFunctionPreamble(ast, context) {
  12535. const {
  12536. ssr,
  12537. prefixIdentifiers,
  12538. push,
  12539. newline,
  12540. runtimeModuleName,
  12541. runtimeGlobalName,
  12542. ssrRuntimeModuleName
  12543. } = context;
  12544. const VueBinding = runtimeGlobalName;
  12545. const helpers = Array.from(ast.helpers);
  12546. if (helpers.length > 0) {
  12547. {
  12548. push(`const _Vue = ${VueBinding}
  12549. `);
  12550. if (ast.hoists.length) {
  12551. const staticHelpers = [
  12552. CREATE_VNODE,
  12553. CREATE_ELEMENT_VNODE,
  12554. CREATE_COMMENT,
  12555. CREATE_TEXT,
  12556. CREATE_STATIC
  12557. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  12558. push(`const { ${staticHelpers} } = _Vue
  12559. `);
  12560. }
  12561. }
  12562. }
  12563. genHoists(ast.hoists, context);
  12564. newline();
  12565. push(`return `);
  12566. }
  12567. function genAssets(assets, type, { helper, push, newline, isTS }) {
  12568. const resolver = helper(
  12569. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  12570. );
  12571. for (let i = 0; i < assets.length; i++) {
  12572. let id = assets[i];
  12573. const maybeSelfReference = id.endsWith("__self");
  12574. if (maybeSelfReference) {
  12575. id = id.slice(0, -6);
  12576. }
  12577. push(
  12578. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  12579. );
  12580. if (i < assets.length - 1) {
  12581. newline();
  12582. }
  12583. }
  12584. }
  12585. function genHoists(hoists, context) {
  12586. if (!hoists.length) {
  12587. return;
  12588. }
  12589. context.pure = true;
  12590. const { push, newline, helper, scopeId, mode } = context;
  12591. newline();
  12592. for (let i = 0; i < hoists.length; i++) {
  12593. const exp = hoists[i];
  12594. if (exp) {
  12595. push(
  12596. `const _hoisted_${i + 1} = ${``}`
  12597. );
  12598. genNode(exp, context);
  12599. newline();
  12600. }
  12601. }
  12602. context.pure = false;
  12603. }
  12604. function isText(n) {
  12605. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  12606. }
  12607. function genNodeListAsArray(nodes, context) {
  12608. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
  12609. context.push(`[`);
  12610. multilines && context.indent();
  12611. genNodeList(nodes, context, multilines);
  12612. multilines && context.deindent();
  12613. context.push(`]`);
  12614. }
  12615. function genNodeList(nodes, context, multilines = false, comma = true) {
  12616. const { push, newline } = context;
  12617. for (let i = 0; i < nodes.length; i++) {
  12618. const node = nodes[i];
  12619. if (isString(node)) {
  12620. push(node);
  12621. } else if (isArray(node)) {
  12622. genNodeListAsArray(node, context);
  12623. } else {
  12624. genNode(node, context);
  12625. }
  12626. if (i < nodes.length - 1) {
  12627. if (multilines) {
  12628. comma && push(",");
  12629. newline();
  12630. } else {
  12631. comma && push(", ");
  12632. }
  12633. }
  12634. }
  12635. }
  12636. function genNode(node, context) {
  12637. if (isString(node)) {
  12638. context.push(node);
  12639. return;
  12640. }
  12641. if (isSymbol(node)) {
  12642. context.push(context.helper(node));
  12643. return;
  12644. }
  12645. switch (node.type) {
  12646. case 1:
  12647. case 9:
  12648. case 11:
  12649. assert(
  12650. node.codegenNode != null,
  12651. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  12652. );
  12653. genNode(node.codegenNode, context);
  12654. break;
  12655. case 2:
  12656. genText(node, context);
  12657. break;
  12658. case 4:
  12659. genExpression(node, context);
  12660. break;
  12661. case 5:
  12662. genInterpolation(node, context);
  12663. break;
  12664. case 12:
  12665. genNode(node.codegenNode, context);
  12666. break;
  12667. case 8:
  12668. genCompoundExpression(node, context);
  12669. break;
  12670. case 3:
  12671. genComment(node, context);
  12672. break;
  12673. case 13:
  12674. genVNodeCall(node, context);
  12675. break;
  12676. case 14:
  12677. genCallExpression(node, context);
  12678. break;
  12679. case 15:
  12680. genObjectExpression(node, context);
  12681. break;
  12682. case 17:
  12683. genArrayExpression(node, context);
  12684. break;
  12685. case 18:
  12686. genFunctionExpression(node, context);
  12687. break;
  12688. case 19:
  12689. genConditionalExpression(node, context);
  12690. break;
  12691. case 20:
  12692. genCacheExpression(node, context);
  12693. break;
  12694. case 21:
  12695. genNodeList(node.body, context, true, false);
  12696. break;
  12697. case 22:
  12698. break;
  12699. case 23:
  12700. break;
  12701. case 24:
  12702. break;
  12703. case 25:
  12704. break;
  12705. case 26:
  12706. break;
  12707. case 10:
  12708. break;
  12709. default:
  12710. {
  12711. assert(false, `unhandled codegen node type: ${node.type}`);
  12712. const exhaustiveCheck = node;
  12713. return exhaustiveCheck;
  12714. }
  12715. }
  12716. }
  12717. function genText(node, context) {
  12718. context.push(JSON.stringify(node.content), node);
  12719. }
  12720. function genExpression(node, context) {
  12721. const { content, isStatic } = node;
  12722. context.push(isStatic ? JSON.stringify(content) : content, node);
  12723. }
  12724. function genInterpolation(node, context) {
  12725. const { push, helper, pure } = context;
  12726. if (pure)
  12727. push(PURE_ANNOTATION);
  12728. push(`${helper(TO_DISPLAY_STRING)}(`);
  12729. genNode(node.content, context);
  12730. push(`)`);
  12731. }
  12732. function genCompoundExpression(node, context) {
  12733. for (let i = 0; i < node.children.length; i++) {
  12734. const child = node.children[i];
  12735. if (isString(child)) {
  12736. context.push(child);
  12737. } else {
  12738. genNode(child, context);
  12739. }
  12740. }
  12741. }
  12742. function genExpressionAsPropertyKey(node, context) {
  12743. const { push } = context;
  12744. if (node.type === 8) {
  12745. push(`[`);
  12746. genCompoundExpression(node, context);
  12747. push(`]`);
  12748. } else if (node.isStatic) {
  12749. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  12750. push(text, node);
  12751. } else {
  12752. push(`[${node.content}]`, node);
  12753. }
  12754. }
  12755. function genComment(node, context) {
  12756. const { push, helper, pure } = context;
  12757. if (pure) {
  12758. push(PURE_ANNOTATION);
  12759. }
  12760. push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
  12761. }
  12762. function genVNodeCall(node, context) {
  12763. const { push, helper, pure } = context;
  12764. const {
  12765. tag,
  12766. props,
  12767. children,
  12768. patchFlag,
  12769. dynamicProps,
  12770. directives,
  12771. isBlock,
  12772. disableTracking,
  12773. isComponent
  12774. } = node;
  12775. if (directives) {
  12776. push(helper(WITH_DIRECTIVES) + `(`);
  12777. }
  12778. if (isBlock) {
  12779. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  12780. }
  12781. if (pure) {
  12782. push(PURE_ANNOTATION);
  12783. }
  12784. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  12785. push(helper(callHelper) + `(`, node);
  12786. genNodeList(
  12787. genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
  12788. context
  12789. );
  12790. push(`)`);
  12791. if (isBlock) {
  12792. push(`)`);
  12793. }
  12794. if (directives) {
  12795. push(`, `);
  12796. genNode(directives, context);
  12797. push(`)`);
  12798. }
  12799. }
  12800. function genNullableArgs(args) {
  12801. let i = args.length;
  12802. while (i--) {
  12803. if (args[i] != null)
  12804. break;
  12805. }
  12806. return args.slice(0, i + 1).map((arg) => arg || `null`);
  12807. }
  12808. function genCallExpression(node, context) {
  12809. const { push, helper, pure } = context;
  12810. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  12811. if (pure) {
  12812. push(PURE_ANNOTATION);
  12813. }
  12814. push(callee + `(`, node);
  12815. genNodeList(node.arguments, context);
  12816. push(`)`);
  12817. }
  12818. function genObjectExpression(node, context) {
  12819. const { push, indent, deindent, newline } = context;
  12820. const { properties } = node;
  12821. if (!properties.length) {
  12822. push(`{}`, node);
  12823. return;
  12824. }
  12825. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  12826. push(multilines ? `{` : `{ `);
  12827. multilines && indent();
  12828. for (let i = 0; i < properties.length; i++) {
  12829. const { key, value } = properties[i];
  12830. genExpressionAsPropertyKey(key, context);
  12831. push(`: `);
  12832. genNode(value, context);
  12833. if (i < properties.length - 1) {
  12834. push(`,`);
  12835. newline();
  12836. }
  12837. }
  12838. multilines && deindent();
  12839. push(multilines ? `}` : ` }`);
  12840. }
  12841. function genArrayExpression(node, context) {
  12842. genNodeListAsArray(node.elements, context);
  12843. }
  12844. function genFunctionExpression(node, context) {
  12845. const { push, indent, deindent } = context;
  12846. const { params, returns, body, newline, isSlot } = node;
  12847. if (isSlot) {
  12848. push(`_${helperNameMap[WITH_CTX]}(`);
  12849. }
  12850. push(`(`, node);
  12851. if (isArray(params)) {
  12852. genNodeList(params, context);
  12853. } else if (params) {
  12854. genNode(params, context);
  12855. }
  12856. push(`) => `);
  12857. if (newline || body) {
  12858. push(`{`);
  12859. indent();
  12860. }
  12861. if (returns) {
  12862. if (newline) {
  12863. push(`return `);
  12864. }
  12865. if (isArray(returns)) {
  12866. genNodeListAsArray(returns, context);
  12867. } else {
  12868. genNode(returns, context);
  12869. }
  12870. } else if (body) {
  12871. genNode(body, context);
  12872. }
  12873. if (newline || body) {
  12874. deindent();
  12875. push(`}`);
  12876. }
  12877. if (isSlot) {
  12878. push(`)`);
  12879. }
  12880. }
  12881. function genConditionalExpression(node, context) {
  12882. const { test, consequent, alternate, newline: needNewline } = node;
  12883. const { push, indent, deindent, newline } = context;
  12884. if (test.type === 4) {
  12885. const needsParens = !isSimpleIdentifier(test.content);
  12886. needsParens && push(`(`);
  12887. genExpression(test, context);
  12888. needsParens && push(`)`);
  12889. } else {
  12890. push(`(`);
  12891. genNode(test, context);
  12892. push(`)`);
  12893. }
  12894. needNewline && indent();
  12895. context.indentLevel++;
  12896. needNewline || push(` `);
  12897. push(`? `);
  12898. genNode(consequent, context);
  12899. context.indentLevel--;
  12900. needNewline && newline();
  12901. needNewline || push(` `);
  12902. push(`: `);
  12903. const isNested = alternate.type === 19;
  12904. if (!isNested) {
  12905. context.indentLevel++;
  12906. }
  12907. genNode(alternate, context);
  12908. if (!isNested) {
  12909. context.indentLevel--;
  12910. }
  12911. needNewline && deindent(
  12912. true
  12913. /* without newline */
  12914. );
  12915. }
  12916. function genCacheExpression(node, context) {
  12917. const { push, helper, indent, deindent, newline } = context;
  12918. push(`_cache[${node.index}] || (`);
  12919. if (node.isVNode) {
  12920. indent();
  12921. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  12922. newline();
  12923. }
  12924. push(`_cache[${node.index}] = `);
  12925. genNode(node.value, context);
  12926. if (node.isVNode) {
  12927. push(`,`);
  12928. newline();
  12929. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  12930. newline();
  12931. push(`_cache[${node.index}]`);
  12932. deindent();
  12933. }
  12934. push(`)`);
  12935. }
  12936. const prohibitedKeywordRE = new RegExp(
  12937. "\\b" + "arguments,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,let,new,return,super,switch,throw,try,var,void,while,with,yield".split(",").join("\\b|\\b") + "\\b"
  12938. );
  12939. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  12940. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  12941. const exp = node.content;
  12942. if (!exp.trim()) {
  12943. return;
  12944. }
  12945. try {
  12946. new Function(
  12947. asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
  12948. );
  12949. } catch (e) {
  12950. let message = e.message;
  12951. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  12952. if (keywordMatch) {
  12953. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  12954. }
  12955. context.onError(
  12956. createCompilerError(
  12957. 45,
  12958. node.loc,
  12959. void 0,
  12960. message
  12961. )
  12962. );
  12963. }
  12964. }
  12965. const transformExpression = (node, context) => {
  12966. if (node.type === 5) {
  12967. node.content = processExpression(
  12968. node.content,
  12969. context
  12970. );
  12971. } else if (node.type === 1) {
  12972. for (let i = 0; i < node.props.length; i++) {
  12973. const dir = node.props[i];
  12974. if (dir.type === 7 && dir.name !== "for") {
  12975. const exp = dir.exp;
  12976. const arg = dir.arg;
  12977. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  12978. dir.exp = processExpression(
  12979. exp,
  12980. context,
  12981. // slot args must be processed as function params
  12982. dir.name === "slot"
  12983. );
  12984. }
  12985. if (arg && arg.type === 4 && !arg.isStatic) {
  12986. dir.arg = processExpression(arg, context);
  12987. }
  12988. }
  12989. }
  12990. }
  12991. };
  12992. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  12993. {
  12994. {
  12995. validateBrowserExpression(node, context, asParams, asRawStatements);
  12996. }
  12997. return node;
  12998. }
  12999. }
  13000. const transformIf = createStructuralDirectiveTransform(
  13001. /^(if|else|else-if)$/,
  13002. (node, dir, context) => {
  13003. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  13004. const siblings = context.parent.children;
  13005. let i = siblings.indexOf(ifNode);
  13006. let key = 0;
  13007. while (i-- >= 0) {
  13008. const sibling = siblings[i];
  13009. if (sibling && sibling.type === 9) {
  13010. key += sibling.branches.length;
  13011. }
  13012. }
  13013. return () => {
  13014. if (isRoot) {
  13015. ifNode.codegenNode = createCodegenNodeForBranch(
  13016. branch,
  13017. key,
  13018. context
  13019. );
  13020. } else {
  13021. const parentCondition = getParentCondition(ifNode.codegenNode);
  13022. parentCondition.alternate = createCodegenNodeForBranch(
  13023. branch,
  13024. key + ifNode.branches.length - 1,
  13025. context
  13026. );
  13027. }
  13028. };
  13029. });
  13030. }
  13031. );
  13032. function processIf(node, dir, context, processCodegen) {
  13033. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  13034. const loc = dir.exp ? dir.exp.loc : node.loc;
  13035. context.onError(
  13036. createCompilerError(28, dir.loc)
  13037. );
  13038. dir.exp = createSimpleExpression(`true`, false, loc);
  13039. }
  13040. if (dir.exp) {
  13041. validateBrowserExpression(dir.exp, context);
  13042. }
  13043. if (dir.name === "if") {
  13044. const branch = createIfBranch(node, dir);
  13045. const ifNode = {
  13046. type: 9,
  13047. loc: node.loc,
  13048. branches: [branch]
  13049. };
  13050. context.replaceNode(ifNode);
  13051. if (processCodegen) {
  13052. return processCodegen(ifNode, branch, true);
  13053. }
  13054. } else {
  13055. const siblings = context.parent.children;
  13056. const comments = [];
  13057. let i = siblings.indexOf(node);
  13058. while (i-- >= -1) {
  13059. const sibling = siblings[i];
  13060. if (sibling && sibling.type === 3) {
  13061. context.removeNode(sibling);
  13062. comments.unshift(sibling);
  13063. continue;
  13064. }
  13065. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  13066. context.removeNode(sibling);
  13067. continue;
  13068. }
  13069. if (sibling && sibling.type === 9) {
  13070. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  13071. context.onError(
  13072. createCompilerError(30, node.loc)
  13073. );
  13074. }
  13075. context.removeNode();
  13076. const branch = createIfBranch(node, dir);
  13077. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  13078. !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
  13079. branch.children = [...comments, ...branch.children];
  13080. }
  13081. {
  13082. const key = branch.userKey;
  13083. if (key) {
  13084. sibling.branches.forEach(({ userKey }) => {
  13085. if (isSameKey(userKey, key)) {
  13086. context.onError(
  13087. createCompilerError(
  13088. 29,
  13089. branch.userKey.loc
  13090. )
  13091. );
  13092. }
  13093. });
  13094. }
  13095. }
  13096. sibling.branches.push(branch);
  13097. const onExit = processCodegen && processCodegen(sibling, branch, false);
  13098. traverseNode(branch, context);
  13099. if (onExit)
  13100. onExit();
  13101. context.currentNode = null;
  13102. } else {
  13103. context.onError(
  13104. createCompilerError(30, node.loc)
  13105. );
  13106. }
  13107. break;
  13108. }
  13109. }
  13110. }
  13111. function createIfBranch(node, dir) {
  13112. const isTemplateIf = node.tagType === 3;
  13113. return {
  13114. type: 10,
  13115. loc: node.loc,
  13116. condition: dir.name === "else" ? void 0 : dir.exp,
  13117. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  13118. userKey: findProp(node, `key`),
  13119. isTemplateIf
  13120. };
  13121. }
  13122. function createCodegenNodeForBranch(branch, keyIndex, context) {
  13123. if (branch.condition) {
  13124. return createConditionalExpression(
  13125. branch.condition,
  13126. createChildrenCodegenNode(branch, keyIndex, context),
  13127. // make sure to pass in asBlock: true so that the comment node call
  13128. // closes the current block.
  13129. createCallExpression(context.helper(CREATE_COMMENT), [
  13130. '"v-if"' ,
  13131. "true"
  13132. ])
  13133. );
  13134. } else {
  13135. return createChildrenCodegenNode(branch, keyIndex, context);
  13136. }
  13137. }
  13138. function createChildrenCodegenNode(branch, keyIndex, context) {
  13139. const { helper } = context;
  13140. const keyProperty = createObjectProperty(
  13141. `key`,
  13142. createSimpleExpression(
  13143. `${keyIndex}`,
  13144. false,
  13145. locStub,
  13146. 2
  13147. )
  13148. );
  13149. const { children } = branch;
  13150. const firstChild = children[0];
  13151. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  13152. if (needFragmentWrapper) {
  13153. if (children.length === 1 && firstChild.type === 11) {
  13154. const vnodeCall = firstChild.codegenNode;
  13155. injectProp(vnodeCall, keyProperty, context);
  13156. return vnodeCall;
  13157. } else {
  13158. let patchFlag = 64;
  13159. let patchFlagText = PatchFlagNames[64];
  13160. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  13161. patchFlag |= 2048;
  13162. patchFlagText += `, ${PatchFlagNames[2048]}`;
  13163. }
  13164. return createVNodeCall(
  13165. context,
  13166. helper(FRAGMENT),
  13167. createObjectExpression([keyProperty]),
  13168. children,
  13169. patchFlag + (` /* ${patchFlagText} */` ),
  13170. void 0,
  13171. void 0,
  13172. true,
  13173. false,
  13174. false,
  13175. branch.loc
  13176. );
  13177. }
  13178. } else {
  13179. const ret = firstChild.codegenNode;
  13180. const vnodeCall = getMemoedVNodeCall(ret);
  13181. if (vnodeCall.type === 13) {
  13182. convertToBlock(vnodeCall, context);
  13183. }
  13184. injectProp(vnodeCall, keyProperty, context);
  13185. return ret;
  13186. }
  13187. }
  13188. function isSameKey(a, b) {
  13189. if (!a || a.type !== b.type) {
  13190. return false;
  13191. }
  13192. if (a.type === 6) {
  13193. if (a.value.content !== b.value.content) {
  13194. return false;
  13195. }
  13196. } else {
  13197. const exp = a.exp;
  13198. const branchExp = b.exp;
  13199. if (exp.type !== branchExp.type) {
  13200. return false;
  13201. }
  13202. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  13203. return false;
  13204. }
  13205. }
  13206. return true;
  13207. }
  13208. function getParentCondition(node) {
  13209. while (true) {
  13210. if (node.type === 19) {
  13211. if (node.alternate.type === 19) {
  13212. node = node.alternate;
  13213. } else {
  13214. return node;
  13215. }
  13216. } else if (node.type === 20) {
  13217. node = node.value;
  13218. }
  13219. }
  13220. }
  13221. const transformFor = createStructuralDirectiveTransform(
  13222. "for",
  13223. (node, dir, context) => {
  13224. const { helper, removeHelper } = context;
  13225. return processFor(node, dir, context, (forNode) => {
  13226. const renderExp = createCallExpression(helper(RENDER_LIST), [
  13227. forNode.source
  13228. ]);
  13229. const isTemplate = isTemplateNode(node);
  13230. const memo = findDir(node, "memo");
  13231. const keyProp = findProp(node, `key`);
  13232. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  13233. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  13234. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  13235. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  13236. forNode.codegenNode = createVNodeCall(
  13237. context,
  13238. helper(FRAGMENT),
  13239. void 0,
  13240. renderExp,
  13241. fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
  13242. void 0,
  13243. void 0,
  13244. true,
  13245. !isStableFragment,
  13246. false,
  13247. node.loc
  13248. );
  13249. return () => {
  13250. let childBlock;
  13251. const { children } = forNode;
  13252. if (isTemplate) {
  13253. node.children.some((c) => {
  13254. if (c.type === 1) {
  13255. const key = findProp(c, "key");
  13256. if (key) {
  13257. context.onError(
  13258. createCompilerError(
  13259. 33,
  13260. key.loc
  13261. )
  13262. );
  13263. return true;
  13264. }
  13265. }
  13266. });
  13267. }
  13268. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  13269. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  13270. if (slotOutlet) {
  13271. childBlock = slotOutlet.codegenNode;
  13272. if (isTemplate && keyProperty) {
  13273. injectProp(childBlock, keyProperty, context);
  13274. }
  13275. } else if (needFragmentWrapper) {
  13276. childBlock = createVNodeCall(
  13277. context,
  13278. helper(FRAGMENT),
  13279. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  13280. node.children,
  13281. 64 + (` /* ${PatchFlagNames[64]} */` ),
  13282. void 0,
  13283. void 0,
  13284. true,
  13285. void 0,
  13286. false
  13287. /* isComponent */
  13288. );
  13289. } else {
  13290. childBlock = children[0].codegenNode;
  13291. if (isTemplate && keyProperty) {
  13292. injectProp(childBlock, keyProperty, context);
  13293. }
  13294. if (childBlock.isBlock !== !isStableFragment) {
  13295. if (childBlock.isBlock) {
  13296. removeHelper(OPEN_BLOCK);
  13297. removeHelper(
  13298. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  13299. );
  13300. } else {
  13301. removeHelper(
  13302. getVNodeHelper(context.inSSR, childBlock.isComponent)
  13303. );
  13304. }
  13305. }
  13306. childBlock.isBlock = !isStableFragment;
  13307. if (childBlock.isBlock) {
  13308. helper(OPEN_BLOCK);
  13309. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  13310. } else {
  13311. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  13312. }
  13313. }
  13314. if (memo) {
  13315. const loop = createFunctionExpression(
  13316. createForLoopParams(forNode.parseResult, [
  13317. createSimpleExpression(`_cached`)
  13318. ])
  13319. );
  13320. loop.body = createBlockStatement([
  13321. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  13322. createCompoundExpression([
  13323. `if (_cached`,
  13324. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  13325. ` && ${context.helperString(
  13326. IS_MEMO_SAME
  13327. )}(_cached, _memo)) return _cached`
  13328. ]),
  13329. createCompoundExpression([`const _item = `, childBlock]),
  13330. createSimpleExpression(`_item.memo = _memo`),
  13331. createSimpleExpression(`return _item`)
  13332. ]);
  13333. renderExp.arguments.push(
  13334. loop,
  13335. createSimpleExpression(`_cache`),
  13336. createSimpleExpression(String(context.cached++))
  13337. );
  13338. } else {
  13339. renderExp.arguments.push(
  13340. createFunctionExpression(
  13341. createForLoopParams(forNode.parseResult),
  13342. childBlock,
  13343. true
  13344. /* force newline */
  13345. )
  13346. );
  13347. }
  13348. };
  13349. });
  13350. }
  13351. );
  13352. function processFor(node, dir, context, processCodegen) {
  13353. if (!dir.exp) {
  13354. context.onError(
  13355. createCompilerError(31, dir.loc)
  13356. );
  13357. return;
  13358. }
  13359. const parseResult = parseForExpression(
  13360. // can only be simple expression because vFor transform is applied
  13361. // before expression transform.
  13362. dir.exp,
  13363. context
  13364. );
  13365. if (!parseResult) {
  13366. context.onError(
  13367. createCompilerError(32, dir.loc)
  13368. );
  13369. return;
  13370. }
  13371. const { addIdentifiers, removeIdentifiers, scopes } = context;
  13372. const { source, value, key, index } = parseResult;
  13373. const forNode = {
  13374. type: 11,
  13375. loc: dir.loc,
  13376. source,
  13377. valueAlias: value,
  13378. keyAlias: key,
  13379. objectIndexAlias: index,
  13380. parseResult,
  13381. children: isTemplateNode(node) ? node.children : [node]
  13382. };
  13383. context.replaceNode(forNode);
  13384. scopes.vFor++;
  13385. const onExit = processCodegen && processCodegen(forNode);
  13386. return () => {
  13387. scopes.vFor--;
  13388. if (onExit)
  13389. onExit();
  13390. };
  13391. }
  13392. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  13393. const stripParensRE = /^\(|\)$/g;
  13394. function parseForExpression(input, context) {
  13395. const loc = input.loc;
  13396. const exp = input.content;
  13397. const inMatch = exp.match(forAliasRE);
  13398. if (!inMatch)
  13399. return;
  13400. const [, LHS, RHS] = inMatch;
  13401. const result = {
  13402. source: createAliasExpression(
  13403. loc,
  13404. RHS.trim(),
  13405. exp.indexOf(RHS, LHS.length)
  13406. ),
  13407. value: void 0,
  13408. key: void 0,
  13409. index: void 0
  13410. };
  13411. {
  13412. validateBrowserExpression(result.source, context);
  13413. }
  13414. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  13415. const trimmedOffset = LHS.indexOf(valueContent);
  13416. const iteratorMatch = valueContent.match(forIteratorRE);
  13417. if (iteratorMatch) {
  13418. valueContent = valueContent.replace(forIteratorRE, "").trim();
  13419. const keyContent = iteratorMatch[1].trim();
  13420. let keyOffset;
  13421. if (keyContent) {
  13422. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  13423. result.key = createAliasExpression(loc, keyContent, keyOffset);
  13424. {
  13425. validateBrowserExpression(
  13426. result.key,
  13427. context,
  13428. true
  13429. );
  13430. }
  13431. }
  13432. if (iteratorMatch[2]) {
  13433. const indexContent = iteratorMatch[2].trim();
  13434. if (indexContent) {
  13435. result.index = createAliasExpression(
  13436. loc,
  13437. indexContent,
  13438. exp.indexOf(
  13439. indexContent,
  13440. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  13441. )
  13442. );
  13443. {
  13444. validateBrowserExpression(
  13445. result.index,
  13446. context,
  13447. true
  13448. );
  13449. }
  13450. }
  13451. }
  13452. }
  13453. if (valueContent) {
  13454. result.value = createAliasExpression(loc, valueContent, trimmedOffset);
  13455. {
  13456. validateBrowserExpression(
  13457. result.value,
  13458. context,
  13459. true
  13460. );
  13461. }
  13462. }
  13463. return result;
  13464. }
  13465. function createAliasExpression(range, content, offset) {
  13466. return createSimpleExpression(
  13467. content,
  13468. false,
  13469. getInnerRange(range, offset, content.length)
  13470. );
  13471. }
  13472. function createForLoopParams({ value, key, index }, memoArgs = []) {
  13473. return createParamsList([value, key, index, ...memoArgs]);
  13474. }
  13475. function createParamsList(args) {
  13476. let i = args.length;
  13477. while (i--) {
  13478. if (args[i])
  13479. break;
  13480. }
  13481. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  13482. }
  13483. const defaultFallback = createSimpleExpression(`undefined`, false);
  13484. const trackSlotScopes = (node, context) => {
  13485. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  13486. const vSlot = findDir(node, "slot");
  13487. if (vSlot) {
  13488. vSlot.exp;
  13489. context.scopes.vSlot++;
  13490. return () => {
  13491. context.scopes.vSlot--;
  13492. };
  13493. }
  13494. }
  13495. };
  13496. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  13497. props,
  13498. children,
  13499. false,
  13500. true,
  13501. children.length ? children[0].loc : loc
  13502. );
  13503. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  13504. context.helper(WITH_CTX);
  13505. const { children, loc } = node;
  13506. const slotsProperties = [];
  13507. const dynamicSlots = [];
  13508. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  13509. const onComponentSlot = findDir(node, "slot", true);
  13510. if (onComponentSlot) {
  13511. const { arg, exp } = onComponentSlot;
  13512. if (arg && !isStaticExp(arg)) {
  13513. hasDynamicSlots = true;
  13514. }
  13515. slotsProperties.push(
  13516. createObjectProperty(
  13517. arg || createSimpleExpression("default", true),
  13518. buildSlotFn(exp, void 0, children, loc)
  13519. )
  13520. );
  13521. }
  13522. let hasTemplateSlots = false;
  13523. let hasNamedDefaultSlot = false;
  13524. const implicitDefaultChildren = [];
  13525. const seenSlotNames = /* @__PURE__ */ new Set();
  13526. let conditionalBranchIndex = 0;
  13527. for (let i = 0; i < children.length; i++) {
  13528. const slotElement = children[i];
  13529. let slotDir;
  13530. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  13531. if (slotElement.type !== 3) {
  13532. implicitDefaultChildren.push(slotElement);
  13533. }
  13534. continue;
  13535. }
  13536. if (onComponentSlot) {
  13537. context.onError(
  13538. createCompilerError(37, slotDir.loc)
  13539. );
  13540. break;
  13541. }
  13542. hasTemplateSlots = true;
  13543. const { children: slotChildren, loc: slotLoc } = slotElement;
  13544. const {
  13545. arg: slotName = createSimpleExpression(`default`, true),
  13546. exp: slotProps,
  13547. loc: dirLoc
  13548. } = slotDir;
  13549. let staticSlotName;
  13550. if (isStaticExp(slotName)) {
  13551. staticSlotName = slotName ? slotName.content : `default`;
  13552. } else {
  13553. hasDynamicSlots = true;
  13554. }
  13555. const vFor = findDir(slotElement, "for");
  13556. const slotFunction = buildSlotFn(
  13557. slotProps,
  13558. vFor == null ? void 0 : vFor.exp,
  13559. slotChildren,
  13560. slotLoc
  13561. );
  13562. let vIf;
  13563. let vElse;
  13564. if (vIf = findDir(slotElement, "if")) {
  13565. hasDynamicSlots = true;
  13566. dynamicSlots.push(
  13567. createConditionalExpression(
  13568. vIf.exp,
  13569. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  13570. defaultFallback
  13571. )
  13572. );
  13573. } else if (vElse = findDir(
  13574. slotElement,
  13575. /^else(-if)?$/,
  13576. true
  13577. /* allowEmpty */
  13578. )) {
  13579. let j = i;
  13580. let prev;
  13581. while (j--) {
  13582. prev = children[j];
  13583. if (prev.type !== 3) {
  13584. break;
  13585. }
  13586. }
  13587. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  13588. children.splice(i, 1);
  13589. i--;
  13590. let conditional = dynamicSlots[dynamicSlots.length - 1];
  13591. while (conditional.alternate.type === 19) {
  13592. conditional = conditional.alternate;
  13593. }
  13594. conditional.alternate = vElse.exp ? createConditionalExpression(
  13595. vElse.exp,
  13596. buildDynamicSlot(
  13597. slotName,
  13598. slotFunction,
  13599. conditionalBranchIndex++
  13600. ),
  13601. defaultFallback
  13602. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  13603. } else {
  13604. context.onError(
  13605. createCompilerError(30, vElse.loc)
  13606. );
  13607. }
  13608. } else if (vFor) {
  13609. hasDynamicSlots = true;
  13610. const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
  13611. if (parseResult) {
  13612. dynamicSlots.push(
  13613. createCallExpression(context.helper(RENDER_LIST), [
  13614. parseResult.source,
  13615. createFunctionExpression(
  13616. createForLoopParams(parseResult),
  13617. buildDynamicSlot(slotName, slotFunction),
  13618. true
  13619. /* force newline */
  13620. )
  13621. ])
  13622. );
  13623. } else {
  13624. context.onError(
  13625. createCompilerError(32, vFor.loc)
  13626. );
  13627. }
  13628. } else {
  13629. if (staticSlotName) {
  13630. if (seenSlotNames.has(staticSlotName)) {
  13631. context.onError(
  13632. createCompilerError(
  13633. 38,
  13634. dirLoc
  13635. )
  13636. );
  13637. continue;
  13638. }
  13639. seenSlotNames.add(staticSlotName);
  13640. if (staticSlotName === "default") {
  13641. hasNamedDefaultSlot = true;
  13642. }
  13643. }
  13644. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  13645. }
  13646. }
  13647. if (!onComponentSlot) {
  13648. const buildDefaultSlotProperty = (props, children2) => {
  13649. const fn = buildSlotFn(props, void 0, children2, loc);
  13650. return createObjectProperty(`default`, fn);
  13651. };
  13652. if (!hasTemplateSlots) {
  13653. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  13654. } else if (implicitDefaultChildren.length && // #3766
  13655. // with whitespace: 'preserve', whitespaces between slots will end up in
  13656. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  13657. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  13658. if (hasNamedDefaultSlot) {
  13659. context.onError(
  13660. createCompilerError(
  13661. 39,
  13662. implicitDefaultChildren[0].loc
  13663. )
  13664. );
  13665. } else {
  13666. slotsProperties.push(
  13667. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  13668. );
  13669. }
  13670. }
  13671. }
  13672. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  13673. let slots = createObjectExpression(
  13674. slotsProperties.concat(
  13675. createObjectProperty(
  13676. `_`,
  13677. // 2 = compiled but dynamic = can skip normalization, but must run diff
  13678. // 1 = compiled and static = can skip normalization AND diff as optimized
  13679. createSimpleExpression(
  13680. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  13681. false
  13682. )
  13683. )
  13684. ),
  13685. loc
  13686. );
  13687. if (dynamicSlots.length) {
  13688. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  13689. slots,
  13690. createArrayExpression(dynamicSlots)
  13691. ]);
  13692. }
  13693. return {
  13694. slots,
  13695. hasDynamicSlots
  13696. };
  13697. }
  13698. function buildDynamicSlot(name, fn, index) {
  13699. const props = [
  13700. createObjectProperty(`name`, name),
  13701. createObjectProperty(`fn`, fn)
  13702. ];
  13703. if (index != null) {
  13704. props.push(
  13705. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  13706. );
  13707. }
  13708. return createObjectExpression(props);
  13709. }
  13710. function hasForwardedSlots(children) {
  13711. for (let i = 0; i < children.length; i++) {
  13712. const child = children[i];
  13713. switch (child.type) {
  13714. case 1:
  13715. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  13716. return true;
  13717. }
  13718. break;
  13719. case 9:
  13720. if (hasForwardedSlots(child.branches))
  13721. return true;
  13722. break;
  13723. case 10:
  13724. case 11:
  13725. if (hasForwardedSlots(child.children))
  13726. return true;
  13727. break;
  13728. }
  13729. }
  13730. return false;
  13731. }
  13732. function isNonWhitespaceContent(node) {
  13733. if (node.type !== 2 && node.type !== 12)
  13734. return true;
  13735. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  13736. }
  13737. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  13738. const transformElement = (node, context) => {
  13739. return function postTransformElement() {
  13740. node = context.currentNode;
  13741. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  13742. return;
  13743. }
  13744. const { tag, props } = node;
  13745. const isComponent = node.tagType === 1;
  13746. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  13747. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  13748. let vnodeProps;
  13749. let vnodeChildren;
  13750. let vnodePatchFlag;
  13751. let patchFlag = 0;
  13752. let vnodeDynamicProps;
  13753. let dynamicPropNames;
  13754. let vnodeDirectives;
  13755. let shouldUseBlock = (
  13756. // dynamic component may resolve to plain elements
  13757. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  13758. // updates inside get proper isSVG flag at runtime. (#639, #643)
  13759. // This is technically web-specific, but splitting the logic out of core
  13760. // leads to too much unnecessary complexity.
  13761. (tag === "svg" || tag === "foreignObject")
  13762. );
  13763. if (props.length > 0) {
  13764. const propsBuildResult = buildProps(
  13765. node,
  13766. context,
  13767. void 0,
  13768. isComponent,
  13769. isDynamicComponent
  13770. );
  13771. vnodeProps = propsBuildResult.props;
  13772. patchFlag = propsBuildResult.patchFlag;
  13773. dynamicPropNames = propsBuildResult.dynamicPropNames;
  13774. const directives = propsBuildResult.directives;
  13775. vnodeDirectives = directives && directives.length ? createArrayExpression(
  13776. directives.map((dir) => buildDirectiveArgs(dir, context))
  13777. ) : void 0;
  13778. if (propsBuildResult.shouldUseBlock) {
  13779. shouldUseBlock = true;
  13780. }
  13781. }
  13782. if (node.children.length > 0) {
  13783. if (vnodeTag === KEEP_ALIVE) {
  13784. shouldUseBlock = true;
  13785. patchFlag |= 1024;
  13786. if (node.children.length > 1) {
  13787. context.onError(
  13788. createCompilerError(46, {
  13789. start: node.children[0].loc.start,
  13790. end: node.children[node.children.length - 1].loc.end,
  13791. source: ""
  13792. })
  13793. );
  13794. }
  13795. }
  13796. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  13797. vnodeTag !== TELEPORT && // explained above.
  13798. vnodeTag !== KEEP_ALIVE;
  13799. if (shouldBuildAsSlots) {
  13800. const { slots, hasDynamicSlots } = buildSlots(node, context);
  13801. vnodeChildren = slots;
  13802. if (hasDynamicSlots) {
  13803. patchFlag |= 1024;
  13804. }
  13805. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  13806. const child = node.children[0];
  13807. const type = child.type;
  13808. const hasDynamicTextChild = type === 5 || type === 8;
  13809. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  13810. patchFlag |= 1;
  13811. }
  13812. if (hasDynamicTextChild || type === 2) {
  13813. vnodeChildren = child;
  13814. } else {
  13815. vnodeChildren = node.children;
  13816. }
  13817. } else {
  13818. vnodeChildren = node.children;
  13819. }
  13820. }
  13821. if (patchFlag !== 0) {
  13822. {
  13823. if (patchFlag < 0) {
  13824. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  13825. } else {
  13826. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  13827. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  13828. }
  13829. }
  13830. if (dynamicPropNames && dynamicPropNames.length) {
  13831. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  13832. }
  13833. }
  13834. node.codegenNode = createVNodeCall(
  13835. context,
  13836. vnodeTag,
  13837. vnodeProps,
  13838. vnodeChildren,
  13839. vnodePatchFlag,
  13840. vnodeDynamicProps,
  13841. vnodeDirectives,
  13842. !!shouldUseBlock,
  13843. false,
  13844. isComponent,
  13845. node.loc
  13846. );
  13847. };
  13848. };
  13849. function resolveComponentType(node, context, ssr = false) {
  13850. let { tag } = node;
  13851. const isExplicitDynamic = isComponentTag(tag);
  13852. const isProp = findProp(node, "is");
  13853. if (isProp) {
  13854. if (isExplicitDynamic || false) {
  13855. const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
  13856. if (exp) {
  13857. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  13858. exp
  13859. ]);
  13860. }
  13861. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  13862. tag = isProp.value.content.slice(4);
  13863. }
  13864. }
  13865. const isDir = !isExplicitDynamic && findDir(node, "is");
  13866. if (isDir && isDir.exp) {
  13867. {
  13868. context.onWarn(
  13869. createCompilerError(52, isDir.loc)
  13870. );
  13871. }
  13872. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  13873. isDir.exp
  13874. ]);
  13875. }
  13876. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  13877. if (builtIn) {
  13878. if (!ssr)
  13879. context.helper(builtIn);
  13880. return builtIn;
  13881. }
  13882. context.helper(RESOLVE_COMPONENT);
  13883. context.components.add(tag);
  13884. return toValidAssetId(tag, `component`);
  13885. }
  13886. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  13887. const { tag, loc: elementLoc, children } = node;
  13888. let properties = [];
  13889. const mergeArgs = [];
  13890. const runtimeDirectives = [];
  13891. const hasChildren = children.length > 0;
  13892. let shouldUseBlock = false;
  13893. let patchFlag = 0;
  13894. let hasRef = false;
  13895. let hasClassBinding = false;
  13896. let hasStyleBinding = false;
  13897. let hasHydrationEventBinding = false;
  13898. let hasDynamicKeys = false;
  13899. let hasVnodeHook = false;
  13900. const dynamicPropNames = [];
  13901. const pushMergeArg = (arg) => {
  13902. if (properties.length) {
  13903. mergeArgs.push(
  13904. createObjectExpression(dedupeProperties(properties), elementLoc)
  13905. );
  13906. properties = [];
  13907. }
  13908. if (arg)
  13909. mergeArgs.push(arg);
  13910. };
  13911. const analyzePatchFlag = ({ key, value }) => {
  13912. if (isStaticExp(key)) {
  13913. const name = key.content;
  13914. const isEventHandler = isOn(name);
  13915. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  13916. // dedicated fast path.
  13917. name.toLowerCase() !== "onclick" && // omit v-model handlers
  13918. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  13919. !isReservedProp(name)) {
  13920. hasHydrationEventBinding = true;
  13921. }
  13922. if (isEventHandler && isReservedProp(name)) {
  13923. hasVnodeHook = true;
  13924. }
  13925. if (isEventHandler && value.type === 14) {
  13926. value = value.arguments[0];
  13927. }
  13928. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  13929. return;
  13930. }
  13931. if (name === "ref") {
  13932. hasRef = true;
  13933. } else if (name === "class") {
  13934. hasClassBinding = true;
  13935. } else if (name === "style") {
  13936. hasStyleBinding = true;
  13937. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  13938. dynamicPropNames.push(name);
  13939. }
  13940. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  13941. dynamicPropNames.push(name);
  13942. }
  13943. } else {
  13944. hasDynamicKeys = true;
  13945. }
  13946. };
  13947. for (let i = 0; i < props.length; i++) {
  13948. const prop = props[i];
  13949. if (prop.type === 6) {
  13950. const { loc, name, value } = prop;
  13951. let isStatic = true;
  13952. if (name === "ref") {
  13953. hasRef = true;
  13954. if (context.scopes.vFor > 0) {
  13955. properties.push(
  13956. createObjectProperty(
  13957. createSimpleExpression("ref_for", true),
  13958. createSimpleExpression("true")
  13959. )
  13960. );
  13961. }
  13962. }
  13963. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  13964. continue;
  13965. }
  13966. properties.push(
  13967. createObjectProperty(
  13968. createSimpleExpression(
  13969. name,
  13970. true,
  13971. getInnerRange(loc, 0, name.length)
  13972. ),
  13973. createSimpleExpression(
  13974. value ? value.content : "",
  13975. isStatic,
  13976. value ? value.loc : loc
  13977. )
  13978. )
  13979. );
  13980. } else {
  13981. const { name, arg, exp, loc, modifiers } = prop;
  13982. const isVBind = name === "bind";
  13983. const isVOn = name === "on";
  13984. if (name === "slot") {
  13985. if (!isComponent) {
  13986. context.onError(
  13987. createCompilerError(40, loc)
  13988. );
  13989. }
  13990. continue;
  13991. }
  13992. if (name === "once" || name === "memo") {
  13993. continue;
  13994. }
  13995. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  13996. continue;
  13997. }
  13998. if (isVOn && ssr) {
  13999. continue;
  14000. }
  14001. if (
  14002. // #938: elements with dynamic keys should be forced into blocks
  14003. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  14004. // before children
  14005. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  14006. ) {
  14007. shouldUseBlock = true;
  14008. }
  14009. if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
  14010. properties.push(
  14011. createObjectProperty(
  14012. createSimpleExpression("ref_for", true),
  14013. createSimpleExpression("true")
  14014. )
  14015. );
  14016. }
  14017. if (!arg && (isVBind || isVOn)) {
  14018. hasDynamicKeys = true;
  14019. if (exp) {
  14020. if (isVBind) {
  14021. pushMergeArg();
  14022. mergeArgs.push(exp);
  14023. } else {
  14024. pushMergeArg({
  14025. type: 14,
  14026. loc,
  14027. callee: context.helper(TO_HANDLERS),
  14028. arguments: isComponent ? [exp] : [exp, `true`]
  14029. });
  14030. }
  14031. } else {
  14032. context.onError(
  14033. createCompilerError(
  14034. isVBind ? 34 : 35,
  14035. loc
  14036. )
  14037. );
  14038. }
  14039. continue;
  14040. }
  14041. if (isVBind && modifiers.includes("prop")) {
  14042. patchFlag |= 32;
  14043. }
  14044. const directiveTransform = context.directiveTransforms[name];
  14045. if (directiveTransform) {
  14046. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  14047. !ssr && props2.forEach(analyzePatchFlag);
  14048. if (isVOn && arg && !isStaticExp(arg)) {
  14049. pushMergeArg(createObjectExpression(props2, elementLoc));
  14050. } else {
  14051. properties.push(...props2);
  14052. }
  14053. if (needRuntime) {
  14054. runtimeDirectives.push(prop);
  14055. if (isSymbol(needRuntime)) {
  14056. directiveImportMap.set(prop, needRuntime);
  14057. }
  14058. }
  14059. } else if (!isBuiltInDirective(name)) {
  14060. runtimeDirectives.push(prop);
  14061. if (hasChildren) {
  14062. shouldUseBlock = true;
  14063. }
  14064. }
  14065. }
  14066. }
  14067. let propsExpression = void 0;
  14068. if (mergeArgs.length) {
  14069. pushMergeArg();
  14070. if (mergeArgs.length > 1) {
  14071. propsExpression = createCallExpression(
  14072. context.helper(MERGE_PROPS),
  14073. mergeArgs,
  14074. elementLoc
  14075. );
  14076. } else {
  14077. propsExpression = mergeArgs[0];
  14078. }
  14079. } else if (properties.length) {
  14080. propsExpression = createObjectExpression(
  14081. dedupeProperties(properties),
  14082. elementLoc
  14083. );
  14084. }
  14085. if (hasDynamicKeys) {
  14086. patchFlag |= 16;
  14087. } else {
  14088. if (hasClassBinding && !isComponent) {
  14089. patchFlag |= 2;
  14090. }
  14091. if (hasStyleBinding && !isComponent) {
  14092. patchFlag |= 4;
  14093. }
  14094. if (dynamicPropNames.length) {
  14095. patchFlag |= 8;
  14096. }
  14097. if (hasHydrationEventBinding) {
  14098. patchFlag |= 32;
  14099. }
  14100. }
  14101. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  14102. patchFlag |= 512;
  14103. }
  14104. if (!context.inSSR && propsExpression) {
  14105. switch (propsExpression.type) {
  14106. case 15:
  14107. let classKeyIndex = -1;
  14108. let styleKeyIndex = -1;
  14109. let hasDynamicKey = false;
  14110. for (let i = 0; i < propsExpression.properties.length; i++) {
  14111. const key = propsExpression.properties[i].key;
  14112. if (isStaticExp(key)) {
  14113. if (key.content === "class") {
  14114. classKeyIndex = i;
  14115. } else if (key.content === "style") {
  14116. styleKeyIndex = i;
  14117. }
  14118. } else if (!key.isHandlerKey) {
  14119. hasDynamicKey = true;
  14120. }
  14121. }
  14122. const classProp = propsExpression.properties[classKeyIndex];
  14123. const styleProp = propsExpression.properties[styleKeyIndex];
  14124. if (!hasDynamicKey) {
  14125. if (classProp && !isStaticExp(classProp.value)) {
  14126. classProp.value = createCallExpression(
  14127. context.helper(NORMALIZE_CLASS),
  14128. [classProp.value]
  14129. );
  14130. }
  14131. if (styleProp && // the static style is compiled into an object,
  14132. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  14133. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  14134. // v-bind:style with static literal object
  14135. styleProp.value.type === 17)) {
  14136. styleProp.value = createCallExpression(
  14137. context.helper(NORMALIZE_STYLE),
  14138. [styleProp.value]
  14139. );
  14140. }
  14141. } else {
  14142. propsExpression = createCallExpression(
  14143. context.helper(NORMALIZE_PROPS),
  14144. [propsExpression]
  14145. );
  14146. }
  14147. break;
  14148. case 14:
  14149. break;
  14150. default:
  14151. propsExpression = createCallExpression(
  14152. context.helper(NORMALIZE_PROPS),
  14153. [
  14154. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  14155. propsExpression
  14156. ])
  14157. ]
  14158. );
  14159. break;
  14160. }
  14161. }
  14162. return {
  14163. props: propsExpression,
  14164. directives: runtimeDirectives,
  14165. patchFlag,
  14166. dynamicPropNames,
  14167. shouldUseBlock
  14168. };
  14169. }
  14170. function dedupeProperties(properties) {
  14171. const knownProps = /* @__PURE__ */ new Map();
  14172. const deduped = [];
  14173. for (let i = 0; i < properties.length; i++) {
  14174. const prop = properties[i];
  14175. if (prop.key.type === 8 || !prop.key.isStatic) {
  14176. deduped.push(prop);
  14177. continue;
  14178. }
  14179. const name = prop.key.content;
  14180. const existing = knownProps.get(name);
  14181. if (existing) {
  14182. if (name === "style" || name === "class" || isOn(name)) {
  14183. mergeAsArray(existing, prop);
  14184. }
  14185. } else {
  14186. knownProps.set(name, prop);
  14187. deduped.push(prop);
  14188. }
  14189. }
  14190. return deduped;
  14191. }
  14192. function mergeAsArray(existing, incoming) {
  14193. if (existing.value.type === 17) {
  14194. existing.value.elements.push(incoming.value);
  14195. } else {
  14196. existing.value = createArrayExpression(
  14197. [existing.value, incoming.value],
  14198. existing.loc
  14199. );
  14200. }
  14201. }
  14202. function buildDirectiveArgs(dir, context) {
  14203. const dirArgs = [];
  14204. const runtime = directiveImportMap.get(dir);
  14205. if (runtime) {
  14206. dirArgs.push(context.helperString(runtime));
  14207. } else {
  14208. {
  14209. context.helper(RESOLVE_DIRECTIVE);
  14210. context.directives.add(dir.name);
  14211. dirArgs.push(toValidAssetId(dir.name, `directive`));
  14212. }
  14213. }
  14214. const { loc } = dir;
  14215. if (dir.exp)
  14216. dirArgs.push(dir.exp);
  14217. if (dir.arg) {
  14218. if (!dir.exp) {
  14219. dirArgs.push(`void 0`);
  14220. }
  14221. dirArgs.push(dir.arg);
  14222. }
  14223. if (Object.keys(dir.modifiers).length) {
  14224. if (!dir.arg) {
  14225. if (!dir.exp) {
  14226. dirArgs.push(`void 0`);
  14227. }
  14228. dirArgs.push(`void 0`);
  14229. }
  14230. const trueExpression = createSimpleExpression(`true`, false, loc);
  14231. dirArgs.push(
  14232. createObjectExpression(
  14233. dir.modifiers.map(
  14234. (modifier) => createObjectProperty(modifier, trueExpression)
  14235. ),
  14236. loc
  14237. )
  14238. );
  14239. }
  14240. return createArrayExpression(dirArgs, dir.loc);
  14241. }
  14242. function stringifyDynamicPropNames(props) {
  14243. let propsNamesString = `[`;
  14244. for (let i = 0, l = props.length; i < l; i++) {
  14245. propsNamesString += JSON.stringify(props[i]);
  14246. if (i < l - 1)
  14247. propsNamesString += ", ";
  14248. }
  14249. return propsNamesString + `]`;
  14250. }
  14251. function isComponentTag(tag) {
  14252. return tag === "component" || tag === "Component";
  14253. }
  14254. const transformSlotOutlet = (node, context) => {
  14255. if (isSlotOutlet(node)) {
  14256. const { children, loc } = node;
  14257. const { slotName, slotProps } = processSlotOutlet(node, context);
  14258. const slotArgs = [
  14259. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  14260. slotName,
  14261. "{}",
  14262. "undefined",
  14263. "true"
  14264. ];
  14265. let expectedLen = 2;
  14266. if (slotProps) {
  14267. slotArgs[2] = slotProps;
  14268. expectedLen = 3;
  14269. }
  14270. if (children.length) {
  14271. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  14272. expectedLen = 4;
  14273. }
  14274. if (context.scopeId && !context.slotted) {
  14275. expectedLen = 5;
  14276. }
  14277. slotArgs.splice(expectedLen);
  14278. node.codegenNode = createCallExpression(
  14279. context.helper(RENDER_SLOT),
  14280. slotArgs,
  14281. loc
  14282. );
  14283. }
  14284. };
  14285. function processSlotOutlet(node, context) {
  14286. let slotName = `"default"`;
  14287. let slotProps = void 0;
  14288. const nonNameProps = [];
  14289. for (let i = 0; i < node.props.length; i++) {
  14290. const p = node.props[i];
  14291. if (p.type === 6) {
  14292. if (p.value) {
  14293. if (p.name === "name") {
  14294. slotName = JSON.stringify(p.value.content);
  14295. } else {
  14296. p.name = camelize(p.name);
  14297. nonNameProps.push(p);
  14298. }
  14299. }
  14300. } else {
  14301. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  14302. if (p.exp)
  14303. slotName = p.exp;
  14304. } else {
  14305. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  14306. p.arg.content = camelize(p.arg.content);
  14307. }
  14308. nonNameProps.push(p);
  14309. }
  14310. }
  14311. }
  14312. if (nonNameProps.length > 0) {
  14313. const { props, directives } = buildProps(
  14314. node,
  14315. context,
  14316. nonNameProps,
  14317. false,
  14318. false
  14319. );
  14320. slotProps = props;
  14321. if (directives.length) {
  14322. context.onError(
  14323. createCompilerError(
  14324. 36,
  14325. directives[0].loc
  14326. )
  14327. );
  14328. }
  14329. }
  14330. return {
  14331. slotName,
  14332. slotProps
  14333. };
  14334. }
  14335. const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  14336. const transformOn$1 = (dir, node, context, augmentor) => {
  14337. const { loc, modifiers, arg } = dir;
  14338. if (!dir.exp && !modifiers.length) {
  14339. context.onError(createCompilerError(35, loc));
  14340. }
  14341. let eventName;
  14342. if (arg.type === 4) {
  14343. if (arg.isStatic) {
  14344. let rawName = arg.content;
  14345. if (rawName.startsWith("vnode")) {
  14346. context.onWarn(
  14347. createCompilerError(51, arg.loc)
  14348. );
  14349. }
  14350. if (rawName.startsWith("vue:")) {
  14351. rawName = `vnode-${rawName.slice(4)}`;
  14352. }
  14353. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  14354. // for non-element and vnode lifecycle event listeners, auto convert
  14355. // it to camelCase. See issue #2249
  14356. toHandlerKey(camelize(rawName))
  14357. ) : (
  14358. // preserve case for plain element listeners that have uppercase
  14359. // letters, as these may be custom elements' custom events
  14360. `on:${rawName}`
  14361. );
  14362. eventName = createSimpleExpression(eventString, true, arg.loc);
  14363. } else {
  14364. eventName = createCompoundExpression([
  14365. `${context.helperString(TO_HANDLER_KEY)}(`,
  14366. arg,
  14367. `)`
  14368. ]);
  14369. }
  14370. } else {
  14371. eventName = arg;
  14372. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  14373. eventName.children.push(`)`);
  14374. }
  14375. let exp = dir.exp;
  14376. if (exp && !exp.content.trim()) {
  14377. exp = void 0;
  14378. }
  14379. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  14380. if (exp) {
  14381. const isMemberExp = isMemberExpression(exp.content);
  14382. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  14383. const hasMultipleStatements = exp.content.includes(`;`);
  14384. {
  14385. validateBrowserExpression(
  14386. exp,
  14387. context,
  14388. false,
  14389. hasMultipleStatements
  14390. );
  14391. }
  14392. if (isInlineStatement || shouldCache && isMemberExp) {
  14393. exp = createCompoundExpression([
  14394. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  14395. exp,
  14396. hasMultipleStatements ? `}` : `)`
  14397. ]);
  14398. }
  14399. }
  14400. let ret = {
  14401. props: [
  14402. createObjectProperty(
  14403. eventName,
  14404. exp || createSimpleExpression(`() => {}`, false, loc)
  14405. )
  14406. ]
  14407. };
  14408. if (augmentor) {
  14409. ret = augmentor(ret);
  14410. }
  14411. if (shouldCache) {
  14412. ret.props[0].value = context.cache(ret.props[0].value);
  14413. }
  14414. ret.props.forEach((p) => p.key.isHandlerKey = true);
  14415. return ret;
  14416. };
  14417. const transformBind = (dir, _node, context) => {
  14418. const { exp, modifiers, loc } = dir;
  14419. const arg = dir.arg;
  14420. if (arg.type !== 4) {
  14421. arg.children.unshift(`(`);
  14422. arg.children.push(`) || ""`);
  14423. } else if (!arg.isStatic) {
  14424. arg.content = `${arg.content} || ""`;
  14425. }
  14426. if (modifiers.includes("camel")) {
  14427. if (arg.type === 4) {
  14428. if (arg.isStatic) {
  14429. arg.content = camelize(arg.content);
  14430. } else {
  14431. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  14432. }
  14433. } else {
  14434. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  14435. arg.children.push(`)`);
  14436. }
  14437. }
  14438. if (!context.inSSR) {
  14439. if (modifiers.includes("prop")) {
  14440. injectPrefix(arg, ".");
  14441. }
  14442. if (modifiers.includes("attr")) {
  14443. injectPrefix(arg, "^");
  14444. }
  14445. }
  14446. if (!exp || exp.type === 4 && !exp.content.trim()) {
  14447. context.onError(createCompilerError(34, loc));
  14448. return {
  14449. props: [createObjectProperty(arg, createSimpleExpression("", true, loc))]
  14450. };
  14451. }
  14452. return {
  14453. props: [createObjectProperty(arg, exp)]
  14454. };
  14455. };
  14456. const injectPrefix = (arg, prefix) => {
  14457. if (arg.type === 4) {
  14458. if (arg.isStatic) {
  14459. arg.content = prefix + arg.content;
  14460. } else {
  14461. arg.content = `\`${prefix}\${${arg.content}}\``;
  14462. }
  14463. } else {
  14464. arg.children.unshift(`'${prefix}' + (`);
  14465. arg.children.push(`)`);
  14466. }
  14467. };
  14468. const transformText = (node, context) => {
  14469. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  14470. return () => {
  14471. const children = node.children;
  14472. let currentContainer = void 0;
  14473. let hasText = false;
  14474. for (let i = 0; i < children.length; i++) {
  14475. const child = children[i];
  14476. if (isText$1(child)) {
  14477. hasText = true;
  14478. for (let j = i + 1; j < children.length; j++) {
  14479. const next = children[j];
  14480. if (isText$1(next)) {
  14481. if (!currentContainer) {
  14482. currentContainer = children[i] = createCompoundExpression(
  14483. [child],
  14484. child.loc
  14485. );
  14486. }
  14487. currentContainer.children.push(` + `, next);
  14488. children.splice(j, 1);
  14489. j--;
  14490. } else {
  14491. currentContainer = void 0;
  14492. break;
  14493. }
  14494. }
  14495. }
  14496. }
  14497. if (!hasText || // if this is a plain element with a single text child, leave it
  14498. // as-is since the runtime has dedicated fast path for this by directly
  14499. // setting textContent of the element.
  14500. // for component root it's always normalized anyway.
  14501. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  14502. // custom directives can potentially add DOM elements arbitrarily,
  14503. // we need to avoid setting textContent of the element at runtime
  14504. // to avoid accidentally overwriting the DOM elements added
  14505. // by the user through custom directives.
  14506. !node.props.find(
  14507. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  14508. ) && // in compat mode, <template> tags with no special directives
  14509. // will be rendered as a fragment so its children must be
  14510. // converted into vnodes.
  14511. true)) {
  14512. return;
  14513. }
  14514. for (let i = 0; i < children.length; i++) {
  14515. const child = children[i];
  14516. if (isText$1(child) || child.type === 8) {
  14517. const callArgs = [];
  14518. if (child.type !== 2 || child.content !== " ") {
  14519. callArgs.push(child);
  14520. }
  14521. if (!context.ssr && getConstantType(child, context) === 0) {
  14522. callArgs.push(
  14523. 1 + (` /* ${PatchFlagNames[1]} */` )
  14524. );
  14525. }
  14526. children[i] = {
  14527. type: 12,
  14528. content: child,
  14529. loc: child.loc,
  14530. codegenNode: createCallExpression(
  14531. context.helper(CREATE_TEXT),
  14532. callArgs
  14533. )
  14534. };
  14535. }
  14536. }
  14537. };
  14538. }
  14539. };
  14540. const seen$1 = /* @__PURE__ */ new WeakSet();
  14541. const transformOnce = (node, context) => {
  14542. if (node.type === 1 && findDir(node, "once", true)) {
  14543. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  14544. return;
  14545. }
  14546. seen$1.add(node);
  14547. context.inVOnce = true;
  14548. context.helper(SET_BLOCK_TRACKING);
  14549. return () => {
  14550. context.inVOnce = false;
  14551. const cur = context.currentNode;
  14552. if (cur.codegenNode) {
  14553. cur.codegenNode = context.cache(
  14554. cur.codegenNode,
  14555. true
  14556. /* isVNode */
  14557. );
  14558. }
  14559. };
  14560. }
  14561. };
  14562. const transformModel$1 = (dir, node, context) => {
  14563. const { exp, arg } = dir;
  14564. if (!exp) {
  14565. context.onError(
  14566. createCompilerError(41, dir.loc)
  14567. );
  14568. return createTransformProps();
  14569. }
  14570. const rawExp = exp.loc.source;
  14571. const expString = exp.type === 4 ? exp.content : rawExp;
  14572. const bindingType = context.bindingMetadata[rawExp];
  14573. if (bindingType === "props" || bindingType === "props-aliased") {
  14574. context.onError(createCompilerError(44, exp.loc));
  14575. return createTransformProps();
  14576. }
  14577. const maybeRef = false;
  14578. if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
  14579. context.onError(
  14580. createCompilerError(42, exp.loc)
  14581. );
  14582. return createTransformProps();
  14583. }
  14584. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  14585. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  14586. let assignmentExp;
  14587. const eventArg = context.isTS ? `($event: any)` : `$event`;
  14588. {
  14589. assignmentExp = createCompoundExpression([
  14590. `${eventArg} => ((`,
  14591. exp,
  14592. `) = $event)`
  14593. ]);
  14594. }
  14595. const props = [
  14596. // modelValue: foo
  14597. createObjectProperty(propName, dir.exp),
  14598. // "onUpdate:modelValue": $event => (foo = $event)
  14599. createObjectProperty(eventName, assignmentExp)
  14600. ];
  14601. if (dir.modifiers.length && node.tagType === 1) {
  14602. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  14603. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  14604. props.push(
  14605. createObjectProperty(
  14606. modifiersKey,
  14607. createSimpleExpression(
  14608. `{ ${modifiers} }`,
  14609. false,
  14610. dir.loc,
  14611. 2
  14612. )
  14613. )
  14614. );
  14615. }
  14616. return createTransformProps(props);
  14617. };
  14618. function createTransformProps(props = []) {
  14619. return { props };
  14620. }
  14621. const seen = /* @__PURE__ */ new WeakSet();
  14622. const transformMemo = (node, context) => {
  14623. if (node.type === 1) {
  14624. const dir = findDir(node, "memo");
  14625. if (!dir || seen.has(node)) {
  14626. return;
  14627. }
  14628. seen.add(node);
  14629. return () => {
  14630. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  14631. if (codegenNode && codegenNode.type === 13) {
  14632. if (node.tagType !== 1) {
  14633. convertToBlock(codegenNode, context);
  14634. }
  14635. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  14636. dir.exp,
  14637. createFunctionExpression(void 0, codegenNode),
  14638. `_cache`,
  14639. String(context.cached++)
  14640. ]);
  14641. }
  14642. };
  14643. }
  14644. };
  14645. function getBaseTransformPreset(prefixIdentifiers) {
  14646. return [
  14647. [
  14648. transformOnce,
  14649. transformIf,
  14650. transformMemo,
  14651. transformFor,
  14652. ...[],
  14653. ...[transformExpression] ,
  14654. transformSlotOutlet,
  14655. transformElement,
  14656. trackSlotScopes,
  14657. transformText
  14658. ],
  14659. {
  14660. on: transformOn$1,
  14661. bind: transformBind,
  14662. model: transformModel$1
  14663. }
  14664. ];
  14665. }
  14666. function baseCompile(template, options = {}) {
  14667. const onError = options.onError || defaultOnError;
  14668. const isModuleMode = options.mode === "module";
  14669. {
  14670. if (options.prefixIdentifiers === true) {
  14671. onError(createCompilerError(47));
  14672. } else if (isModuleMode) {
  14673. onError(createCompilerError(48));
  14674. }
  14675. }
  14676. const prefixIdentifiers = false;
  14677. if (options.cacheHandlers) {
  14678. onError(createCompilerError(49));
  14679. }
  14680. if (options.scopeId && !isModuleMode) {
  14681. onError(createCompilerError(50));
  14682. }
  14683. const ast = isString(template) ? baseParse(template, options) : template;
  14684. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  14685. transform(
  14686. ast,
  14687. extend({}, options, {
  14688. prefixIdentifiers,
  14689. nodeTransforms: [
  14690. ...nodeTransforms,
  14691. ...options.nodeTransforms || []
  14692. // user transforms
  14693. ],
  14694. directiveTransforms: extend(
  14695. {},
  14696. directiveTransforms,
  14697. options.directiveTransforms || {}
  14698. // user transforms
  14699. )
  14700. })
  14701. );
  14702. return generate(
  14703. ast,
  14704. extend({}, options, {
  14705. prefixIdentifiers
  14706. })
  14707. );
  14708. }
  14709. const noopDirectiveTransform = () => ({ props: [] });
  14710. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  14711. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  14712. const V_MODEL_TEXT = Symbol(`vModelText` );
  14713. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  14714. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  14715. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  14716. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  14717. const V_SHOW = Symbol(`vShow` );
  14718. const TRANSITION = Symbol(`Transition` );
  14719. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  14720. registerRuntimeHelpers({
  14721. [V_MODEL_RADIO]: `vModelRadio`,
  14722. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  14723. [V_MODEL_TEXT]: `vModelText`,
  14724. [V_MODEL_SELECT]: `vModelSelect`,
  14725. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  14726. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  14727. [V_ON_WITH_KEYS]: `withKeys`,
  14728. [V_SHOW]: `vShow`,
  14729. [TRANSITION]: `Transition`,
  14730. [TRANSITION_GROUP]: `TransitionGroup`
  14731. });
  14732. let decoder;
  14733. function decodeHtmlBrowser(raw, asAttr = false) {
  14734. if (!decoder) {
  14735. decoder = document.createElement("div");
  14736. }
  14737. if (asAttr) {
  14738. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  14739. return decoder.children[0].getAttribute("foo");
  14740. } else {
  14741. decoder.innerHTML = raw;
  14742. return decoder.textContent;
  14743. }
  14744. }
  14745. const isRawTextContainer = /* @__PURE__ */ makeMap(
  14746. "style,iframe,script,noscript",
  14747. true
  14748. );
  14749. const parserOptions = {
  14750. isVoidTag,
  14751. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  14752. isPreTag: (tag) => tag === "pre",
  14753. decodeEntities: decodeHtmlBrowser ,
  14754. isBuiltInComponent: (tag) => {
  14755. if (isBuiltInType(tag, `Transition`)) {
  14756. return TRANSITION;
  14757. } else if (isBuiltInType(tag, `TransitionGroup`)) {
  14758. return TRANSITION_GROUP;
  14759. }
  14760. },
  14761. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  14762. getNamespace(tag, parent) {
  14763. let ns = parent ? parent.ns : 0;
  14764. if (parent && ns === 2) {
  14765. if (parent.tag === "annotation-xml") {
  14766. if (tag === "svg") {
  14767. return 1;
  14768. }
  14769. if (parent.props.some(
  14770. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  14771. )) {
  14772. ns = 0;
  14773. }
  14774. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  14775. ns = 0;
  14776. }
  14777. } else if (parent && ns === 1) {
  14778. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  14779. ns = 0;
  14780. }
  14781. }
  14782. if (ns === 0) {
  14783. if (tag === "svg") {
  14784. return 1;
  14785. }
  14786. if (tag === "math") {
  14787. return 2;
  14788. }
  14789. }
  14790. return ns;
  14791. },
  14792. // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
  14793. getTextMode({ tag, ns }) {
  14794. if (ns === 0) {
  14795. if (tag === "textarea" || tag === "title") {
  14796. return 1;
  14797. }
  14798. if (isRawTextContainer(tag)) {
  14799. return 2;
  14800. }
  14801. }
  14802. return 0;
  14803. }
  14804. };
  14805. const transformStyle = (node) => {
  14806. if (node.type === 1) {
  14807. node.props.forEach((p, i) => {
  14808. if (p.type === 6 && p.name === "style" && p.value) {
  14809. node.props[i] = {
  14810. type: 7,
  14811. name: `bind`,
  14812. arg: createSimpleExpression(`style`, true, p.loc),
  14813. exp: parseInlineCSS(p.value.content, p.loc),
  14814. modifiers: [],
  14815. loc: p.loc
  14816. };
  14817. }
  14818. });
  14819. }
  14820. };
  14821. const parseInlineCSS = (cssText, loc) => {
  14822. const normalized = parseStringStyle(cssText);
  14823. return createSimpleExpression(
  14824. JSON.stringify(normalized),
  14825. false,
  14826. loc,
  14827. 3
  14828. );
  14829. };
  14830. function createDOMCompilerError(code, loc) {
  14831. return createCompilerError(
  14832. code,
  14833. loc,
  14834. DOMErrorMessages
  14835. );
  14836. }
  14837. const DOMErrorMessages = {
  14838. [53]: `v-html is missing expression.`,
  14839. [54]: `v-html will override element children.`,
  14840. [55]: `v-text is missing expression.`,
  14841. [56]: `v-text will override element children.`,
  14842. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  14843. [58]: `v-model argument is not supported on plain elements.`,
  14844. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  14845. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  14846. [61]: `v-show is missing expression.`,
  14847. [62]: `<Transition> expects exactly one child element or component.`,
  14848. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  14849. };
  14850. const transformVHtml = (dir, node, context) => {
  14851. const { exp, loc } = dir;
  14852. if (!exp) {
  14853. context.onError(
  14854. createDOMCompilerError(53, loc)
  14855. );
  14856. }
  14857. if (node.children.length) {
  14858. context.onError(
  14859. createDOMCompilerError(54, loc)
  14860. );
  14861. node.children.length = 0;
  14862. }
  14863. return {
  14864. props: [
  14865. createObjectProperty(
  14866. createSimpleExpression(`innerHTML`, true, loc),
  14867. exp || createSimpleExpression("", true)
  14868. )
  14869. ]
  14870. };
  14871. };
  14872. const transformVText = (dir, node, context) => {
  14873. const { exp, loc } = dir;
  14874. if (!exp) {
  14875. context.onError(
  14876. createDOMCompilerError(55, loc)
  14877. );
  14878. }
  14879. if (node.children.length) {
  14880. context.onError(
  14881. createDOMCompilerError(56, loc)
  14882. );
  14883. node.children.length = 0;
  14884. }
  14885. return {
  14886. props: [
  14887. createObjectProperty(
  14888. createSimpleExpression(`textContent`, true),
  14889. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  14890. context.helperString(TO_DISPLAY_STRING),
  14891. [exp],
  14892. loc
  14893. ) : createSimpleExpression("", true)
  14894. )
  14895. ]
  14896. };
  14897. };
  14898. const transformModel = (dir, node, context) => {
  14899. const baseResult = transformModel$1(dir, node, context);
  14900. if (!baseResult.props.length || node.tagType === 1) {
  14901. return baseResult;
  14902. }
  14903. if (dir.arg) {
  14904. context.onError(
  14905. createDOMCompilerError(
  14906. 58,
  14907. dir.arg.loc
  14908. )
  14909. );
  14910. }
  14911. function checkDuplicatedValue() {
  14912. const value = findDir(node, "bind");
  14913. if (value && isStaticArgOf(value.arg, "value")) {
  14914. context.onError(
  14915. createDOMCompilerError(
  14916. 60,
  14917. value.loc
  14918. )
  14919. );
  14920. }
  14921. }
  14922. const { tag } = node;
  14923. const isCustomElement = context.isCustomElement(tag);
  14924. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  14925. let directiveToUse = V_MODEL_TEXT;
  14926. let isInvalidType = false;
  14927. if (tag === "input" || isCustomElement) {
  14928. const type = findProp(node, `type`);
  14929. if (type) {
  14930. if (type.type === 7) {
  14931. directiveToUse = V_MODEL_DYNAMIC;
  14932. } else if (type.value) {
  14933. switch (type.value.content) {
  14934. case "radio":
  14935. directiveToUse = V_MODEL_RADIO;
  14936. break;
  14937. case "checkbox":
  14938. directiveToUse = V_MODEL_CHECKBOX;
  14939. break;
  14940. case "file":
  14941. isInvalidType = true;
  14942. context.onError(
  14943. createDOMCompilerError(
  14944. 59,
  14945. dir.loc
  14946. )
  14947. );
  14948. break;
  14949. default:
  14950. checkDuplicatedValue();
  14951. break;
  14952. }
  14953. }
  14954. } else if (hasDynamicKeyVBind(node)) {
  14955. directiveToUse = V_MODEL_DYNAMIC;
  14956. } else {
  14957. checkDuplicatedValue();
  14958. }
  14959. } else if (tag === "select") {
  14960. directiveToUse = V_MODEL_SELECT;
  14961. } else {
  14962. checkDuplicatedValue();
  14963. }
  14964. if (!isInvalidType) {
  14965. baseResult.needRuntime = context.helper(directiveToUse);
  14966. }
  14967. } else {
  14968. context.onError(
  14969. createDOMCompilerError(
  14970. 57,
  14971. dir.loc
  14972. )
  14973. );
  14974. }
  14975. baseResult.props = baseResult.props.filter(
  14976. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  14977. );
  14978. return baseResult;
  14979. };
  14980. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  14981. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  14982. // event propagation management
  14983. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  14984. );
  14985. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  14986. const isKeyboardEvent = /* @__PURE__ */ makeMap(
  14987. `onkeyup,onkeydown,onkeypress`,
  14988. true
  14989. );
  14990. const resolveModifiers = (key, modifiers, context, loc) => {
  14991. const keyModifiers = [];
  14992. const nonKeyModifiers = [];
  14993. const eventOptionModifiers = [];
  14994. for (let i = 0; i < modifiers.length; i++) {
  14995. const modifier = modifiers[i];
  14996. if (isEventOptionModifier(modifier)) {
  14997. eventOptionModifiers.push(modifier);
  14998. } else {
  14999. if (maybeKeyModifier(modifier)) {
  15000. if (isStaticExp(key)) {
  15001. if (isKeyboardEvent(key.content)) {
  15002. keyModifiers.push(modifier);
  15003. } else {
  15004. nonKeyModifiers.push(modifier);
  15005. }
  15006. } else {
  15007. keyModifiers.push(modifier);
  15008. nonKeyModifiers.push(modifier);
  15009. }
  15010. } else {
  15011. if (isNonKeyModifier(modifier)) {
  15012. nonKeyModifiers.push(modifier);
  15013. } else {
  15014. keyModifiers.push(modifier);
  15015. }
  15016. }
  15017. }
  15018. }
  15019. return {
  15020. keyModifiers,
  15021. nonKeyModifiers,
  15022. eventOptionModifiers
  15023. };
  15024. };
  15025. const transformClick = (key, event) => {
  15026. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  15027. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  15028. `(`,
  15029. key,
  15030. `) === "onClick" ? "${event}" : (`,
  15031. key,
  15032. `)`
  15033. ]) : key;
  15034. };
  15035. const transformOn = (dir, node, context) => {
  15036. return transformOn$1(dir, node, context, (baseResult) => {
  15037. const { modifiers } = dir;
  15038. if (!modifiers.length)
  15039. return baseResult;
  15040. let { key, value: handlerExp } = baseResult.props[0];
  15041. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  15042. if (nonKeyModifiers.includes("right")) {
  15043. key = transformClick(key, `onContextmenu`);
  15044. }
  15045. if (nonKeyModifiers.includes("middle")) {
  15046. key = transformClick(key, `onMouseup`);
  15047. }
  15048. if (nonKeyModifiers.length) {
  15049. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  15050. handlerExp,
  15051. JSON.stringify(nonKeyModifiers)
  15052. ]);
  15053. }
  15054. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  15055. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  15056. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  15057. handlerExp,
  15058. JSON.stringify(keyModifiers)
  15059. ]);
  15060. }
  15061. if (eventOptionModifiers.length) {
  15062. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  15063. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  15064. }
  15065. return {
  15066. props: [createObjectProperty(key, handlerExp)]
  15067. };
  15068. });
  15069. };
  15070. const transformShow = (dir, node, context) => {
  15071. const { exp, loc } = dir;
  15072. if (!exp) {
  15073. context.onError(
  15074. createDOMCompilerError(61, loc)
  15075. );
  15076. }
  15077. return {
  15078. props: [],
  15079. needRuntime: context.helper(V_SHOW)
  15080. };
  15081. };
  15082. const transformTransition = (node, context) => {
  15083. if (node.type === 1 && node.tagType === 1) {
  15084. const component = context.isBuiltInComponent(node.tag);
  15085. if (component === TRANSITION) {
  15086. return () => {
  15087. if (!node.children.length) {
  15088. return;
  15089. }
  15090. if (hasMultipleChildren(node)) {
  15091. context.onError(
  15092. createDOMCompilerError(
  15093. 62,
  15094. {
  15095. start: node.children[0].loc.start,
  15096. end: node.children[node.children.length - 1].loc.end,
  15097. source: ""
  15098. }
  15099. )
  15100. );
  15101. }
  15102. const child = node.children[0];
  15103. if (child.type === 1) {
  15104. for (const p of child.props) {
  15105. if (p.type === 7 && p.name === "show") {
  15106. node.props.push({
  15107. type: 6,
  15108. name: "persisted",
  15109. value: void 0,
  15110. loc: node.loc
  15111. });
  15112. }
  15113. }
  15114. }
  15115. };
  15116. }
  15117. }
  15118. };
  15119. function hasMultipleChildren(node) {
  15120. const children = node.children = node.children.filter(
  15121. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  15122. );
  15123. const child = children[0];
  15124. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  15125. }
  15126. const ignoreSideEffectTags = (node, context) => {
  15127. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  15128. context.onError(
  15129. createDOMCompilerError(
  15130. 63,
  15131. node.loc
  15132. )
  15133. );
  15134. context.removeNode();
  15135. }
  15136. };
  15137. const DOMNodeTransforms = [
  15138. transformStyle,
  15139. ...[transformTransition]
  15140. ];
  15141. const DOMDirectiveTransforms = {
  15142. cloak: noopDirectiveTransform,
  15143. html: transformVHtml,
  15144. text: transformVText,
  15145. model: transformModel,
  15146. // override compiler-core
  15147. on: transformOn,
  15148. // override compiler-core
  15149. show: transformShow
  15150. };
  15151. function compile(template, options = {}) {
  15152. return baseCompile(
  15153. template,
  15154. extend({}, parserOptions, options, {
  15155. nodeTransforms: [
  15156. // ignore <script> and <tag>
  15157. // this is not put inside DOMNodeTransforms because that list is used
  15158. // by compiler-ssr to generate vnode fallback branches
  15159. ignoreSideEffectTags,
  15160. ...DOMNodeTransforms,
  15161. ...options.nodeTransforms || []
  15162. ],
  15163. directiveTransforms: extend(
  15164. {},
  15165. DOMDirectiveTransforms,
  15166. options.directiveTransforms || {}
  15167. ),
  15168. transformHoist: null
  15169. })
  15170. );
  15171. }
  15172. {
  15173. initDev();
  15174. }
  15175. const compileCache = /* @__PURE__ */ new WeakMap();
  15176. function getCache(options) {
  15177. let c = compileCache.get(options != null ? options : EMPTY_OBJ);
  15178. if (!c) {
  15179. c = /* @__PURE__ */ Object.create(null);
  15180. compileCache.set(options != null ? options : EMPTY_OBJ, c);
  15181. }
  15182. return c;
  15183. }
  15184. function compileToFunction(template, options) {
  15185. if (!isString(template)) {
  15186. if (template.nodeType) {
  15187. template = template.innerHTML;
  15188. } else {
  15189. warn(`invalid template option: `, template);
  15190. return NOOP;
  15191. }
  15192. }
  15193. const key = template;
  15194. const cache = getCache(options);
  15195. const cached = cache[key];
  15196. if (cached) {
  15197. return cached;
  15198. }
  15199. if (template[0] === "#") {
  15200. const el = document.querySelector(template);
  15201. if (!el) {
  15202. warn(`Template element not found or is empty: ${template}`);
  15203. }
  15204. template = el ? el.innerHTML : ``;
  15205. }
  15206. const opts = extend(
  15207. {
  15208. hoistStatic: true,
  15209. onError: onError ,
  15210. onWarn: (e) => onError(e, true)
  15211. },
  15212. options
  15213. );
  15214. if (!opts.isCustomElement && typeof customElements !== "undefined") {
  15215. opts.isCustomElement = (tag) => !!customElements.get(tag);
  15216. }
  15217. const { code } = compile(template, opts);
  15218. function onError(err, asWarning = false) {
  15219. const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
  15220. const codeFrame = err.loc && generateCodeFrame(
  15221. template,
  15222. err.loc.start.offset,
  15223. err.loc.end.offset
  15224. );
  15225. warn(codeFrame ? `${message}
  15226. ${codeFrame}` : message);
  15227. }
  15228. const render = new Function(code)() ;
  15229. render._rc = true;
  15230. return cache[key] = render;
  15231. }
  15232. registerRuntimeCompiler(compileToFunction);
  15233. exports.BaseTransition = BaseTransition;
  15234. exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
  15235. exports.Comment = Comment;
  15236. exports.EffectScope = EffectScope;
  15237. exports.Fragment = Fragment;
  15238. exports.KeepAlive = KeepAlive;
  15239. exports.ReactiveEffect = ReactiveEffect;
  15240. exports.Static = Static;
  15241. exports.Suspense = Suspense;
  15242. exports.Teleport = Teleport;
  15243. exports.Text = Text;
  15244. exports.Transition = Transition;
  15245. exports.TransitionGroup = TransitionGroup;
  15246. exports.VueElement = VueElement;
  15247. exports.assertNumber = assertNumber;
  15248. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  15249. exports.callWithErrorHandling = callWithErrorHandling;
  15250. exports.camelize = camelize;
  15251. exports.capitalize = capitalize;
  15252. exports.cloneVNode = cloneVNode;
  15253. exports.compatUtils = compatUtils;
  15254. exports.compile = compileToFunction;
  15255. exports.computed = computed;
  15256. exports.createApp = createApp;
  15257. exports.createBlock = createBlock;
  15258. exports.createCommentVNode = createCommentVNode;
  15259. exports.createElementBlock = createElementBlock;
  15260. exports.createElementVNode = createBaseVNode;
  15261. exports.createHydrationRenderer = createHydrationRenderer;
  15262. exports.createPropsRestProxy = createPropsRestProxy;
  15263. exports.createRenderer = createRenderer;
  15264. exports.createSSRApp = createSSRApp;
  15265. exports.createSlots = createSlots;
  15266. exports.createStaticVNode = createStaticVNode;
  15267. exports.createTextVNode = createTextVNode;
  15268. exports.createVNode = createVNode;
  15269. exports.customRef = customRef;
  15270. exports.defineAsyncComponent = defineAsyncComponent;
  15271. exports.defineComponent = defineComponent;
  15272. exports.defineCustomElement = defineCustomElement;
  15273. exports.defineEmits = defineEmits;
  15274. exports.defineExpose = defineExpose;
  15275. exports.defineModel = defineModel;
  15276. exports.defineOptions = defineOptions;
  15277. exports.defineProps = defineProps;
  15278. exports.defineSSRCustomElement = defineSSRCustomElement;
  15279. exports.defineSlots = defineSlots;
  15280. exports.effect = effect;
  15281. exports.effectScope = effectScope;
  15282. exports.getCurrentInstance = getCurrentInstance;
  15283. exports.getCurrentScope = getCurrentScope;
  15284. exports.getTransitionRawChildren = getTransitionRawChildren;
  15285. exports.guardReactiveProps = guardReactiveProps;
  15286. exports.h = h;
  15287. exports.handleError = handleError;
  15288. exports.hasInjectionContext = hasInjectionContext;
  15289. exports.hydrate = hydrate;
  15290. exports.initCustomFormatter = initCustomFormatter;
  15291. exports.initDirectivesForSSR = initDirectivesForSSR;
  15292. exports.inject = inject;
  15293. exports.isMemoSame = isMemoSame;
  15294. exports.isProxy = isProxy;
  15295. exports.isReactive = isReactive;
  15296. exports.isReadonly = isReadonly;
  15297. exports.isRef = isRef;
  15298. exports.isRuntimeOnly = isRuntimeOnly;
  15299. exports.isShallow = isShallow;
  15300. exports.isVNode = isVNode;
  15301. exports.markRaw = markRaw;
  15302. exports.mergeDefaults = mergeDefaults;
  15303. exports.mergeModels = mergeModels;
  15304. exports.mergeProps = mergeProps;
  15305. exports.nextTick = nextTick;
  15306. exports.normalizeClass = normalizeClass;
  15307. exports.normalizeProps = normalizeProps;
  15308. exports.normalizeStyle = normalizeStyle;
  15309. exports.onActivated = onActivated;
  15310. exports.onBeforeMount = onBeforeMount;
  15311. exports.onBeforeUnmount = onBeforeUnmount;
  15312. exports.onBeforeUpdate = onBeforeUpdate;
  15313. exports.onDeactivated = onDeactivated;
  15314. exports.onErrorCaptured = onErrorCaptured;
  15315. exports.onMounted = onMounted;
  15316. exports.onRenderTracked = onRenderTracked;
  15317. exports.onRenderTriggered = onRenderTriggered;
  15318. exports.onScopeDispose = onScopeDispose;
  15319. exports.onServerPrefetch = onServerPrefetch;
  15320. exports.onUnmounted = onUnmounted;
  15321. exports.onUpdated = onUpdated;
  15322. exports.openBlock = openBlock;
  15323. exports.popScopeId = popScopeId;
  15324. exports.provide = provide;
  15325. exports.proxyRefs = proxyRefs;
  15326. exports.pushScopeId = pushScopeId;
  15327. exports.queuePostFlushCb = queuePostFlushCb;
  15328. exports.reactive = reactive;
  15329. exports.readonly = readonly;
  15330. exports.ref = ref;
  15331. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  15332. exports.render = render;
  15333. exports.renderList = renderList;
  15334. exports.renderSlot = renderSlot;
  15335. exports.resolveComponent = resolveComponent;
  15336. exports.resolveDirective = resolveDirective;
  15337. exports.resolveDynamicComponent = resolveDynamicComponent;
  15338. exports.resolveFilter = resolveFilter;
  15339. exports.resolveTransitionHooks = resolveTransitionHooks;
  15340. exports.setBlockTracking = setBlockTracking;
  15341. exports.setDevtoolsHook = setDevtoolsHook;
  15342. exports.setTransitionHooks = setTransitionHooks;
  15343. exports.shallowReactive = shallowReactive;
  15344. exports.shallowReadonly = shallowReadonly;
  15345. exports.shallowRef = shallowRef;
  15346. exports.ssrContextKey = ssrContextKey;
  15347. exports.ssrUtils = ssrUtils;
  15348. exports.stop = stop;
  15349. exports.toDisplayString = toDisplayString;
  15350. exports.toHandlerKey = toHandlerKey;
  15351. exports.toHandlers = toHandlers;
  15352. exports.toRaw = toRaw;
  15353. exports.toRef = toRef;
  15354. exports.toRefs = toRefs;
  15355. exports.toValue = toValue;
  15356. exports.transformVNodeArgs = transformVNodeArgs;
  15357. exports.triggerRef = triggerRef;
  15358. exports.unref = unref;
  15359. exports.useAttrs = useAttrs;
  15360. exports.useCssModule = useCssModule;
  15361. exports.useCssVars = useCssVars;
  15362. exports.useModel = useModel;
  15363. exports.useSSRContext = useSSRContext;
  15364. exports.useSlots = useSlots;
  15365. exports.useTransitionState = useTransitionState;
  15366. exports.vModelCheckbox = vModelCheckbox;
  15367. exports.vModelDynamic = vModelDynamic;
  15368. exports.vModelRadio = vModelRadio;
  15369. exports.vModelSelect = vModelSelect;
  15370. exports.vModelText = vModelText;
  15371. exports.vShow = vShow;
  15372. exports.version = version;
  15373. exports.warn = warn;
  15374. exports.watch = watch;
  15375. exports.watchEffect = watchEffect;
  15376. exports.watchPostEffect = watchPostEffect;
  15377. exports.watchSyncEffect = watchSyncEffect;
  15378. exports.withAsyncContext = withAsyncContext;
  15379. exports.withCtx = withCtx;
  15380. exports.withDefaults = withDefaults;
  15381. exports.withDirectives = withDirectives;
  15382. exports.withKeys = withKeys;
  15383. exports.withMemo = withMemo;
  15384. exports.withModifiers = withModifiers;
  15385. exports.withScopeId = withScopeId;
  15386. return exports;
  15387. })({});