vue.esm-browser.js 538 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771
  1. /**
  2. * vue v3.5.35
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. // @__NO_SIDE_EFFECTS__
  7. function makeMap(str) {
  8. const map = /* @__PURE__ */ Object.create(null);
  9. for (const key of str.split(",")) map[key] = 1;
  10. return (val) => val in map;
  11. }
  12. const EMPTY_OBJ = Object.freeze({}) ;
  13. const EMPTY_ARR = Object.freeze([]) ;
  14. const NOOP = () => {
  15. };
  16. const NO = () => false;
  17. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  18. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  19. const isModelListener = (key) => key.startsWith("onUpdate:");
  20. const extend = Object.assign;
  21. const remove = (arr, el) => {
  22. const i = arr.indexOf(el);
  23. if (i > -1) {
  24. arr.splice(i, 1);
  25. }
  26. };
  27. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  28. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
  29. const isArray = Array.isArray;
  30. const isMap = (val) => toTypeString(val) === "[object Map]";
  31. const isSet = (val) => toTypeString(val) === "[object Set]";
  32. const isDate = (val) => toTypeString(val) === "[object Date]";
  33. const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
  34. const isFunction = (val) => typeof val === "function";
  35. const isString = (val) => typeof val === "string";
  36. const isSymbol = (val) => typeof val === "symbol";
  37. const isObject = (val) => val !== null && typeof val === "object";
  38. const isPromise = (val) => {
  39. return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
  40. };
  41. const objectToString = Object.prototype.toString;
  42. const toTypeString = (value) => objectToString.call(value);
  43. const toRawType = (value) => {
  44. return toTypeString(value).slice(8, -1);
  45. };
  46. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  47. const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  48. const isReservedProp = /* @__PURE__ */ makeMap(
  49. // the leading comma is intentional so empty string "" is also included
  50. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  51. );
  52. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  53. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  54. );
  55. const cacheStringFunction = (fn) => {
  56. const cache = /* @__PURE__ */ Object.create(null);
  57. return ((str) => {
  58. const hit = cache[str];
  59. return hit || (cache[str] = fn(str));
  60. });
  61. };
  62. const camelizeRE = /-\w/g;
  63. const camelize = cacheStringFunction(
  64. (str) => {
  65. return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
  66. }
  67. );
  68. const hyphenateRE = /\B([A-Z])/g;
  69. const hyphenate = cacheStringFunction(
  70. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  71. );
  72. const capitalize = cacheStringFunction((str) => {
  73. return str.charAt(0).toUpperCase() + str.slice(1);
  74. });
  75. const toHandlerKey = cacheStringFunction(
  76. (str) => {
  77. const s = str ? `on${capitalize(str)}` : ``;
  78. return s;
  79. }
  80. );
  81. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  82. const invokeArrayFns = (fns, ...arg) => {
  83. for (let i = 0; i < fns.length; i++) {
  84. fns[i](...arg);
  85. }
  86. };
  87. const def = (obj, key, value, writable = false) => {
  88. Object.defineProperty(obj, key, {
  89. configurable: true,
  90. enumerable: false,
  91. writable,
  92. value
  93. });
  94. };
  95. const looseToNumber = (val) => {
  96. const n = parseFloat(val);
  97. return isNaN(n) ? val : n;
  98. };
  99. const toNumber = (val) => {
  100. const n = isString(val) ? Number(val) : NaN;
  101. return isNaN(n) ? val : n;
  102. };
  103. let _globalThis;
  104. const getGlobalThis = () => {
  105. return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  106. };
  107. function genCacheKey(source, options) {
  108. return source + JSON.stringify(
  109. options,
  110. (_, val) => typeof val === "function" ? val.toString() : val
  111. );
  112. }
  113. const PatchFlagNames = {
  114. [1]: `TEXT`,
  115. [2]: `CLASS`,
  116. [4]: `STYLE`,
  117. [8]: `PROPS`,
  118. [16]: `FULL_PROPS`,
  119. [32]: `NEED_HYDRATION`,
  120. [64]: `STABLE_FRAGMENT`,
  121. [128]: `KEYED_FRAGMENT`,
  122. [256]: `UNKEYED_FRAGMENT`,
  123. [512]: `NEED_PATCH`,
  124. [1024]: `DYNAMIC_SLOTS`,
  125. [2048]: `DEV_ROOT_FRAGMENT`,
  126. [-1]: `CACHED`,
  127. [-2]: `BAIL`
  128. };
  129. const slotFlagsText = {
  130. [1]: "STABLE",
  131. [2]: "DYNAMIC",
  132. [3]: "FORWARDED"
  133. };
  134. 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,Error,Symbol";
  135. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  136. const range = 2;
  137. function generateCodeFrame(source, start = 0, end = source.length) {
  138. start = Math.max(0, Math.min(start, source.length));
  139. end = Math.max(0, Math.min(end, source.length));
  140. if (start > end) return "";
  141. let lines = source.split(/(\r?\n)/);
  142. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  143. lines = lines.filter((_, idx) => idx % 2 === 0);
  144. let count = 0;
  145. const res = [];
  146. for (let i = 0; i < lines.length; i++) {
  147. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  148. if (count >= start) {
  149. for (let j = i - range; j <= i + range || end > count; j++) {
  150. if (j < 0 || j >= lines.length) continue;
  151. const line = j + 1;
  152. res.push(
  153. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  154. );
  155. const lineLength = lines[j].length;
  156. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  157. if (j === i) {
  158. const pad = start - (count - (lineLength + newLineSeqLength));
  159. const length = Math.max(
  160. 1,
  161. end > count ? lineLength - pad : end - start
  162. );
  163. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  164. } else if (j > i) {
  165. if (end > count) {
  166. const length = Math.max(Math.min(end - count, lineLength), 1);
  167. res.push(` | ` + "^".repeat(length));
  168. }
  169. count += lineLength + newLineSeqLength;
  170. }
  171. }
  172. break;
  173. }
  174. }
  175. return res.join("\n");
  176. }
  177. function normalizeStyle(value) {
  178. if (isArray(value)) {
  179. const res = {};
  180. for (let i = 0; i < value.length; i++) {
  181. const item = value[i];
  182. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
  183. if (normalized) {
  184. for (const key in normalized) {
  185. res[key] = normalized[key];
  186. }
  187. }
  188. }
  189. return res;
  190. } else if (isString(value) || isObject(value)) {
  191. return value;
  192. }
  193. }
  194. const listDelimiterRE = /;(?![^(]*\))/g;
  195. const propertyDelimiterRE = /:([^]+)/;
  196. const styleCommentRE = /\/\*[^]*?\*\//g;
  197. function parseStringStyle(cssText) {
  198. const ret = {};
  199. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  200. if (item) {
  201. const tmp = item.split(propertyDelimiterRE);
  202. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  203. }
  204. });
  205. return ret;
  206. }
  207. function stringifyStyle(styles) {
  208. if (!styles) return "";
  209. if (isString(styles)) return styles;
  210. let ret = "";
  211. for (const key in styles) {
  212. const value = styles[key];
  213. if (isString(value) || typeof value === "number") {
  214. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  215. ret += `${normalizedKey}:${value};`;
  216. }
  217. }
  218. return ret;
  219. }
  220. function normalizeClass(value) {
  221. let res = "";
  222. if (isString(value)) {
  223. res = value;
  224. } else if (isArray(value)) {
  225. for (let i = 0; i < value.length; i++) {
  226. const normalized = normalizeClass(value[i]);
  227. if (normalized) {
  228. res += normalized + " ";
  229. }
  230. }
  231. } else if (isObject(value)) {
  232. for (const name in value) {
  233. if (value[name]) {
  234. res += name + " ";
  235. }
  236. }
  237. }
  238. return res.trim();
  239. }
  240. function normalizeProps(props) {
  241. if (!props) return null;
  242. let { class: klass, style } = props;
  243. if (klass && !isString(klass)) {
  244. props.class = normalizeClass(klass);
  245. }
  246. if (style) {
  247. props.style = normalizeStyle(style);
  248. }
  249. return props;
  250. }
  251. 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";
  252. 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";
  253. const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
  254. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  255. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  256. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  257. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  258. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  259. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  260. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
  261. const isBooleanAttr = /* @__PURE__ */ makeMap(
  262. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  263. );
  264. function includeBooleanAttr(value) {
  265. return !!value || value === "";
  266. }
  267. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  268. `accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
  269. );
  270. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  271. `xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
  272. );
  273. function isRenderableAttrValue(value) {
  274. if (value == null) {
  275. return false;
  276. }
  277. const type = typeof value;
  278. return type === "string" || type === "number" || type === "boolean";
  279. }
  280. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  281. function getEscapedCssVarName(key, doubleEscape) {
  282. return key.replace(
  283. cssVarNameEscapeSymbolsRE,
  284. (s) => `\\${s}`
  285. );
  286. }
  287. function looseCompareArrays(a, b) {
  288. if (a.length !== b.length) return false;
  289. let equal = true;
  290. for (let i = 0; equal && i < a.length; i++) {
  291. equal = looseEqual(a[i], b[i]);
  292. }
  293. return equal;
  294. }
  295. function looseEqual(a, b) {
  296. if (a === b) return true;
  297. let aValidType = isDate(a);
  298. let bValidType = isDate(b);
  299. if (aValidType || bValidType) {
  300. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  301. }
  302. aValidType = isSymbol(a);
  303. bValidType = isSymbol(b);
  304. if (aValidType || bValidType) {
  305. return a === b;
  306. }
  307. aValidType = isArray(a);
  308. bValidType = isArray(b);
  309. if (aValidType || bValidType) {
  310. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  311. }
  312. aValidType = isObject(a);
  313. bValidType = isObject(b);
  314. if (aValidType || bValidType) {
  315. if (!aValidType || !bValidType) {
  316. return false;
  317. }
  318. const aKeysCount = Object.keys(a).length;
  319. const bKeysCount = Object.keys(b).length;
  320. if (aKeysCount !== bKeysCount) {
  321. return false;
  322. }
  323. for (const key in a) {
  324. const aHasKey = a.hasOwnProperty(key);
  325. const bHasKey = b.hasOwnProperty(key);
  326. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
  327. return false;
  328. }
  329. }
  330. }
  331. return String(a) === String(b);
  332. }
  333. function looseIndexOf(arr, val) {
  334. return arr.findIndex((item) => looseEqual(item, val));
  335. }
  336. const isRef$1 = (val) => {
  337. return !!(val && val["__v_isRef"] === true);
  338. };
  339. const toDisplayString = (val) => {
  340. return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef$1(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
  341. };
  342. const replacer = (_key, val) => {
  343. if (isRef$1(val)) {
  344. return replacer(_key, val.value);
  345. } else if (isMap(val)) {
  346. return {
  347. [`Map(${val.size})`]: [...val.entries()].reduce(
  348. (entries, [key, val2], i) => {
  349. entries[stringifySymbol(key, i) + " =>"] = val2;
  350. return entries;
  351. },
  352. {}
  353. )
  354. };
  355. } else if (isSet(val)) {
  356. return {
  357. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  358. };
  359. } else if (isSymbol(val)) {
  360. return stringifySymbol(val);
  361. } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  362. return String(val);
  363. }
  364. return val;
  365. };
  366. const stringifySymbol = (v, i = "") => {
  367. var _a;
  368. return (
  369. // Symbol.description in es2019+ so we need to cast here to pass
  370. // the lib: es2016 check
  371. isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  372. );
  373. };
  374. function normalizeCssVarValue(value) {
  375. if (value == null) {
  376. return "initial";
  377. }
  378. if (typeof value === "string") {
  379. return value === "" ? " " : value;
  380. }
  381. if (typeof value !== "number" || !Number.isFinite(value)) {
  382. {
  383. console.warn(
  384. "[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:",
  385. value
  386. );
  387. }
  388. }
  389. return String(value);
  390. }
  391. function warn$2(msg, ...args) {
  392. console.warn(`[Vue warn] ${msg}`, ...args);
  393. }
  394. let activeEffectScope;
  395. class EffectScope {
  396. // TODO isolatedDeclarations "__v_skip"
  397. constructor(detached = false) {
  398. this.detached = detached;
  399. /**
  400. * @internal
  401. */
  402. this._active = true;
  403. /**
  404. * @internal track `on` calls, allow `on` call multiple times
  405. */
  406. this._on = 0;
  407. /**
  408. * @internal
  409. */
  410. this.effects = [];
  411. /**
  412. * @internal
  413. */
  414. this.cleanups = [];
  415. this._isPaused = false;
  416. this._warnOnRun = true;
  417. this.__v_skip = true;
  418. if (!detached && activeEffectScope) {
  419. if (activeEffectScope.active) {
  420. this.parent = activeEffectScope;
  421. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  422. this
  423. ) - 1;
  424. } else {
  425. this._active = false;
  426. this._warnOnRun = false;
  427. }
  428. }
  429. }
  430. get active() {
  431. return this._active;
  432. }
  433. pause() {
  434. if (this._active) {
  435. this._isPaused = true;
  436. let i, l;
  437. if (this.scopes) {
  438. for (i = 0, l = this.scopes.length; i < l; i++) {
  439. this.scopes[i].pause();
  440. }
  441. }
  442. for (i = 0, l = this.effects.length; i < l; i++) {
  443. this.effects[i].pause();
  444. }
  445. }
  446. }
  447. /**
  448. * Resumes the effect scope, including all child scopes and effects.
  449. */
  450. resume() {
  451. if (this._active) {
  452. if (this._isPaused) {
  453. this._isPaused = false;
  454. let i, l;
  455. if (this.scopes) {
  456. for (i = 0, l = this.scopes.length; i < l; i++) {
  457. this.scopes[i].resume();
  458. }
  459. }
  460. for (i = 0, l = this.effects.length; i < l; i++) {
  461. this.effects[i].resume();
  462. }
  463. }
  464. }
  465. }
  466. run(fn) {
  467. if (this._active) {
  468. const currentEffectScope = activeEffectScope;
  469. try {
  470. activeEffectScope = this;
  471. return fn();
  472. } finally {
  473. activeEffectScope = currentEffectScope;
  474. }
  475. } else if (this._warnOnRun) {
  476. warn$2(`cannot run an inactive effect scope.`);
  477. }
  478. }
  479. /**
  480. * This should only be called on non-detached scopes
  481. * @internal
  482. */
  483. on() {
  484. if (++this._on === 1) {
  485. this.prevScope = activeEffectScope;
  486. activeEffectScope = this;
  487. }
  488. }
  489. /**
  490. * This should only be called on non-detached scopes
  491. * @internal
  492. */
  493. off() {
  494. if (this._on > 0 && --this._on === 0) {
  495. if (activeEffectScope === this) {
  496. activeEffectScope = this.prevScope;
  497. } else {
  498. let current = activeEffectScope;
  499. while (current) {
  500. if (current.prevScope === this) {
  501. current.prevScope = this.prevScope;
  502. break;
  503. }
  504. current = current.prevScope;
  505. }
  506. }
  507. this.prevScope = void 0;
  508. }
  509. }
  510. stop(fromParent) {
  511. if (this._active) {
  512. this._active = false;
  513. let i, l;
  514. for (i = 0, l = this.effects.length; i < l; i++) {
  515. this.effects[i].stop();
  516. }
  517. this.effects.length = 0;
  518. for (i = 0, l = this.cleanups.length; i < l; i++) {
  519. this.cleanups[i]();
  520. }
  521. this.cleanups.length = 0;
  522. if (this.scopes) {
  523. for (i = 0, l = this.scopes.length; i < l; i++) {
  524. this.scopes[i].stop(true);
  525. }
  526. this.scopes.length = 0;
  527. }
  528. if (!this.detached && this.parent && !fromParent) {
  529. const last = this.parent.scopes.pop();
  530. if (last && last !== this) {
  531. this.parent.scopes[this.index] = last;
  532. last.index = this.index;
  533. }
  534. }
  535. this.parent = void 0;
  536. }
  537. }
  538. }
  539. function effectScope(detached) {
  540. return new EffectScope(detached);
  541. }
  542. function getCurrentScope() {
  543. return activeEffectScope;
  544. }
  545. function onScopeDispose(fn, failSilently = false) {
  546. if (activeEffectScope) {
  547. activeEffectScope.cleanups.push(fn);
  548. } else if (!failSilently) {
  549. warn$2(
  550. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  551. );
  552. }
  553. }
  554. let activeSub;
  555. const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
  556. class ReactiveEffect {
  557. constructor(fn) {
  558. this.fn = fn;
  559. /**
  560. * @internal
  561. */
  562. this.deps = void 0;
  563. /**
  564. * @internal
  565. */
  566. this.depsTail = void 0;
  567. /**
  568. * @internal
  569. */
  570. this.flags = 1 | 4;
  571. /**
  572. * @internal
  573. */
  574. this.next = void 0;
  575. /**
  576. * @internal
  577. */
  578. this.cleanup = void 0;
  579. this.scheduler = void 0;
  580. if (activeEffectScope) {
  581. if (activeEffectScope.active) {
  582. activeEffectScope.effects.push(this);
  583. } else {
  584. this.flags &= -2;
  585. }
  586. }
  587. }
  588. pause() {
  589. this.flags |= 64;
  590. }
  591. resume() {
  592. if (this.flags & 64) {
  593. this.flags &= -65;
  594. if (pausedQueueEffects.has(this)) {
  595. pausedQueueEffects.delete(this);
  596. this.trigger();
  597. }
  598. }
  599. }
  600. /**
  601. * @internal
  602. */
  603. notify() {
  604. if (this.flags & 2 && !(this.flags & 32)) {
  605. return;
  606. }
  607. if (!(this.flags & 8)) {
  608. batch(this);
  609. }
  610. }
  611. run() {
  612. if (!(this.flags & 1)) {
  613. return this.fn();
  614. }
  615. this.flags |= 2;
  616. cleanupEffect(this);
  617. prepareDeps(this);
  618. const prevEffect = activeSub;
  619. const prevShouldTrack = shouldTrack;
  620. activeSub = this;
  621. shouldTrack = true;
  622. try {
  623. return this.fn();
  624. } finally {
  625. if (activeSub !== this) {
  626. warn$2(
  627. "Active effect was not restored correctly - this is likely a Vue internal bug."
  628. );
  629. }
  630. cleanupDeps(this);
  631. activeSub = prevEffect;
  632. shouldTrack = prevShouldTrack;
  633. this.flags &= -3;
  634. }
  635. }
  636. stop() {
  637. if (this.flags & 1) {
  638. for (let link = this.deps; link; link = link.nextDep) {
  639. removeSub(link);
  640. }
  641. this.deps = this.depsTail = void 0;
  642. cleanupEffect(this);
  643. this.onStop && this.onStop();
  644. this.flags &= -2;
  645. }
  646. }
  647. trigger() {
  648. if (this.flags & 64) {
  649. pausedQueueEffects.add(this);
  650. } else if (this.scheduler) {
  651. this.scheduler();
  652. } else {
  653. this.runIfDirty();
  654. }
  655. }
  656. /**
  657. * @internal
  658. */
  659. runIfDirty() {
  660. if (isDirty(this)) {
  661. this.run();
  662. }
  663. }
  664. get dirty() {
  665. return isDirty(this);
  666. }
  667. }
  668. let batchDepth = 0;
  669. let batchedSub;
  670. let batchedComputed;
  671. function batch(sub, isComputed = false) {
  672. sub.flags |= 8;
  673. if (isComputed) {
  674. sub.next = batchedComputed;
  675. batchedComputed = sub;
  676. return;
  677. }
  678. sub.next = batchedSub;
  679. batchedSub = sub;
  680. }
  681. function startBatch() {
  682. batchDepth++;
  683. }
  684. function endBatch() {
  685. if (--batchDepth > 0) {
  686. return;
  687. }
  688. if (batchedComputed) {
  689. let e = batchedComputed;
  690. batchedComputed = void 0;
  691. while (e) {
  692. const next = e.next;
  693. e.next = void 0;
  694. e.flags &= -9;
  695. e = next;
  696. }
  697. }
  698. let error;
  699. while (batchedSub) {
  700. let e = batchedSub;
  701. batchedSub = void 0;
  702. while (e) {
  703. const next = e.next;
  704. e.next = void 0;
  705. e.flags &= -9;
  706. if (e.flags & 1) {
  707. try {
  708. ;
  709. e.trigger();
  710. } catch (err) {
  711. if (!error) error = err;
  712. }
  713. }
  714. e = next;
  715. }
  716. }
  717. if (error) throw error;
  718. }
  719. function prepareDeps(sub) {
  720. for (let link = sub.deps; link; link = link.nextDep) {
  721. link.version = -1;
  722. link.prevActiveLink = link.dep.activeLink;
  723. link.dep.activeLink = link;
  724. }
  725. }
  726. function cleanupDeps(sub) {
  727. let head;
  728. let tail = sub.depsTail;
  729. let link = tail;
  730. while (link) {
  731. const prev = link.prevDep;
  732. if (link.version === -1) {
  733. if (link === tail) tail = prev;
  734. removeSub(link);
  735. removeDep(link);
  736. } else {
  737. head = link;
  738. }
  739. link.dep.activeLink = link.prevActiveLink;
  740. link.prevActiveLink = void 0;
  741. link = prev;
  742. }
  743. sub.deps = head;
  744. sub.depsTail = tail;
  745. }
  746. function isDirty(sub) {
  747. for (let link = sub.deps; link; link = link.nextDep) {
  748. if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
  749. return true;
  750. }
  751. }
  752. if (sub._dirty) {
  753. return true;
  754. }
  755. return false;
  756. }
  757. function refreshComputed(computed) {
  758. if (computed.flags & 4 && !(computed.flags & 16)) {
  759. return;
  760. }
  761. computed.flags &= -17;
  762. if (computed.globalVersion === globalVersion) {
  763. return;
  764. }
  765. computed.globalVersion = globalVersion;
  766. if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
  767. return;
  768. }
  769. computed.flags |= 2;
  770. const dep = computed.dep;
  771. const prevSub = activeSub;
  772. const prevShouldTrack = shouldTrack;
  773. activeSub = computed;
  774. shouldTrack = true;
  775. try {
  776. prepareDeps(computed);
  777. const value = computed.fn(computed._value);
  778. if (dep.version === 0 || hasChanged(value, computed._value)) {
  779. computed.flags |= 128;
  780. computed._value = value;
  781. dep.version++;
  782. }
  783. } catch (err) {
  784. dep.version++;
  785. throw err;
  786. } finally {
  787. activeSub = prevSub;
  788. shouldTrack = prevShouldTrack;
  789. cleanupDeps(computed);
  790. computed.flags &= -3;
  791. }
  792. }
  793. function removeSub(link, soft = false) {
  794. const { dep, prevSub, nextSub } = link;
  795. if (prevSub) {
  796. prevSub.nextSub = nextSub;
  797. link.prevSub = void 0;
  798. }
  799. if (nextSub) {
  800. nextSub.prevSub = prevSub;
  801. link.nextSub = void 0;
  802. }
  803. if (dep.subsHead === link) {
  804. dep.subsHead = nextSub;
  805. }
  806. if (dep.subs === link) {
  807. dep.subs = prevSub;
  808. if (!prevSub && dep.computed) {
  809. dep.computed.flags &= -5;
  810. for (let l = dep.computed.deps; l; l = l.nextDep) {
  811. removeSub(l, true);
  812. }
  813. }
  814. }
  815. if (!soft && !--dep.sc && dep.map) {
  816. dep.map.delete(dep.key);
  817. }
  818. }
  819. function removeDep(link) {
  820. const { prevDep, nextDep } = link;
  821. if (prevDep) {
  822. prevDep.nextDep = nextDep;
  823. link.prevDep = void 0;
  824. }
  825. if (nextDep) {
  826. nextDep.prevDep = prevDep;
  827. link.nextDep = void 0;
  828. }
  829. }
  830. function effect(fn, options) {
  831. if (fn.effect instanceof ReactiveEffect) {
  832. fn = fn.effect.fn;
  833. }
  834. const e = new ReactiveEffect(fn);
  835. if (options) {
  836. extend(e, options);
  837. }
  838. try {
  839. e.run();
  840. } catch (err) {
  841. e.stop();
  842. throw err;
  843. }
  844. const runner = e.run.bind(e);
  845. runner.effect = e;
  846. return runner;
  847. }
  848. function stop(runner) {
  849. runner.effect.stop();
  850. }
  851. let shouldTrack = true;
  852. const trackStack = [];
  853. function pauseTracking() {
  854. trackStack.push(shouldTrack);
  855. shouldTrack = false;
  856. }
  857. function resetTracking() {
  858. const last = trackStack.pop();
  859. shouldTrack = last === void 0 ? true : last;
  860. }
  861. function cleanupEffect(e) {
  862. const { cleanup } = e;
  863. e.cleanup = void 0;
  864. if (cleanup) {
  865. const prevSub = activeSub;
  866. activeSub = void 0;
  867. try {
  868. cleanup();
  869. } finally {
  870. activeSub = prevSub;
  871. }
  872. }
  873. }
  874. let globalVersion = 0;
  875. class Link {
  876. constructor(sub, dep) {
  877. this.sub = sub;
  878. this.dep = dep;
  879. this.version = dep.version;
  880. this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
  881. }
  882. }
  883. class Dep {
  884. // TODO isolatedDeclarations "__v_skip"
  885. constructor(computed) {
  886. this.computed = computed;
  887. this.version = 0;
  888. /**
  889. * Link between this dep and the current active effect
  890. */
  891. this.activeLink = void 0;
  892. /**
  893. * Doubly linked list representing the subscribing effects (tail)
  894. */
  895. this.subs = void 0;
  896. /**
  897. * For object property deps cleanup
  898. */
  899. this.map = void 0;
  900. this.key = void 0;
  901. /**
  902. * Subscriber counter
  903. */
  904. this.sc = 0;
  905. /**
  906. * @internal
  907. */
  908. this.__v_skip = true;
  909. {
  910. this.subsHead = void 0;
  911. }
  912. }
  913. track(debugInfo) {
  914. if (!activeSub || !shouldTrack || activeSub === this.computed) {
  915. return;
  916. }
  917. let link = this.activeLink;
  918. if (link === void 0 || link.sub !== activeSub) {
  919. link = this.activeLink = new Link(activeSub, this);
  920. if (!activeSub.deps) {
  921. activeSub.deps = activeSub.depsTail = link;
  922. } else {
  923. link.prevDep = activeSub.depsTail;
  924. activeSub.depsTail.nextDep = link;
  925. activeSub.depsTail = link;
  926. }
  927. addSub(link);
  928. } else if (link.version === -1) {
  929. link.version = this.version;
  930. if (link.nextDep) {
  931. const next = link.nextDep;
  932. next.prevDep = link.prevDep;
  933. if (link.prevDep) {
  934. link.prevDep.nextDep = next;
  935. }
  936. link.prevDep = activeSub.depsTail;
  937. link.nextDep = void 0;
  938. activeSub.depsTail.nextDep = link;
  939. activeSub.depsTail = link;
  940. if (activeSub.deps === link) {
  941. activeSub.deps = next;
  942. }
  943. }
  944. }
  945. if (activeSub.onTrack) {
  946. activeSub.onTrack(
  947. extend(
  948. {
  949. effect: activeSub
  950. },
  951. debugInfo
  952. )
  953. );
  954. }
  955. return link;
  956. }
  957. trigger(debugInfo) {
  958. this.version++;
  959. globalVersion++;
  960. this.notify(debugInfo);
  961. }
  962. notify(debugInfo) {
  963. startBatch();
  964. try {
  965. if (true) {
  966. for (let head = this.subsHead; head; head = head.nextSub) {
  967. if (head.sub.onTrigger && !(head.sub.flags & 8)) {
  968. head.sub.onTrigger(
  969. extend(
  970. {
  971. effect: head.sub
  972. },
  973. debugInfo
  974. )
  975. );
  976. }
  977. }
  978. }
  979. for (let link = this.subs; link; link = link.prevSub) {
  980. if (link.sub.notify()) {
  981. ;
  982. link.sub.dep.notify();
  983. }
  984. }
  985. } finally {
  986. endBatch();
  987. }
  988. }
  989. }
  990. function addSub(link) {
  991. link.dep.sc++;
  992. if (link.sub.flags & 4) {
  993. const computed = link.dep.computed;
  994. if (computed && !link.dep.subs) {
  995. computed.flags |= 4 | 16;
  996. for (let l = computed.deps; l; l = l.nextDep) {
  997. addSub(l);
  998. }
  999. }
  1000. const currentTail = link.dep.subs;
  1001. if (currentTail !== link) {
  1002. link.prevSub = currentTail;
  1003. if (currentTail) currentTail.nextSub = link;
  1004. }
  1005. if (link.dep.subsHead === void 0) {
  1006. link.dep.subsHead = link;
  1007. }
  1008. link.dep.subs = link;
  1009. }
  1010. }
  1011. const targetMap = /* @__PURE__ */ new WeakMap();
  1012. const ITERATE_KEY = /* @__PURE__ */ Symbol(
  1013. "Object iterate"
  1014. );
  1015. const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  1016. "Map keys iterate"
  1017. );
  1018. const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  1019. "Array iterate"
  1020. );
  1021. function track(target, type, key) {
  1022. if (shouldTrack && activeSub) {
  1023. let depsMap = targetMap.get(target);
  1024. if (!depsMap) {
  1025. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  1026. }
  1027. let dep = depsMap.get(key);
  1028. if (!dep) {
  1029. depsMap.set(key, dep = new Dep());
  1030. dep.map = depsMap;
  1031. dep.key = key;
  1032. }
  1033. {
  1034. dep.track({
  1035. target,
  1036. type,
  1037. key
  1038. });
  1039. }
  1040. }
  1041. }
  1042. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  1043. const depsMap = targetMap.get(target);
  1044. if (!depsMap) {
  1045. globalVersion++;
  1046. return;
  1047. }
  1048. const run = (dep) => {
  1049. if (dep) {
  1050. {
  1051. dep.trigger({
  1052. target,
  1053. type,
  1054. key,
  1055. newValue,
  1056. oldValue,
  1057. oldTarget
  1058. });
  1059. }
  1060. }
  1061. };
  1062. startBatch();
  1063. if (type === "clear") {
  1064. depsMap.forEach(run);
  1065. } else {
  1066. const targetIsArray = isArray(target);
  1067. const isArrayIndex = targetIsArray && isIntegerKey(key);
  1068. if (targetIsArray && key === "length") {
  1069. const newLength = Number(newValue);
  1070. depsMap.forEach((dep, key2) => {
  1071. if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
  1072. run(dep);
  1073. }
  1074. });
  1075. } else {
  1076. if (key !== void 0 || depsMap.has(void 0)) {
  1077. run(depsMap.get(key));
  1078. }
  1079. if (isArrayIndex) {
  1080. run(depsMap.get(ARRAY_ITERATE_KEY));
  1081. }
  1082. switch (type) {
  1083. case "add":
  1084. if (!targetIsArray) {
  1085. run(depsMap.get(ITERATE_KEY));
  1086. if (isMap(target)) {
  1087. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  1088. }
  1089. } else if (isArrayIndex) {
  1090. run(depsMap.get("length"));
  1091. }
  1092. break;
  1093. case "delete":
  1094. if (!targetIsArray) {
  1095. run(depsMap.get(ITERATE_KEY));
  1096. if (isMap(target)) {
  1097. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  1098. }
  1099. }
  1100. break;
  1101. case "set":
  1102. if (isMap(target)) {
  1103. run(depsMap.get(ITERATE_KEY));
  1104. }
  1105. break;
  1106. }
  1107. }
  1108. }
  1109. endBatch();
  1110. }
  1111. function getDepFromReactive(object, key) {
  1112. const depMap = targetMap.get(object);
  1113. return depMap && depMap.get(key);
  1114. }
  1115. function reactiveReadArray(array) {
  1116. const raw = toRaw(array);
  1117. if (raw === array) return raw;
  1118. track(raw, "iterate", ARRAY_ITERATE_KEY);
  1119. return isShallow(array) ? raw : raw.map(toReactive);
  1120. }
  1121. function shallowReadArray(arr) {
  1122. track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
  1123. return arr;
  1124. }
  1125. function toWrapped(target, item) {
  1126. if (isReadonly(target)) {
  1127. return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
  1128. }
  1129. return toReactive(item);
  1130. }
  1131. const arrayInstrumentations = {
  1132. __proto__: null,
  1133. [Symbol.iterator]() {
  1134. return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
  1135. },
  1136. concat(...args) {
  1137. return reactiveReadArray(this).concat(
  1138. ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
  1139. );
  1140. },
  1141. entries() {
  1142. return iterator(this, "entries", (value) => {
  1143. value[1] = toWrapped(this, value[1]);
  1144. return value;
  1145. });
  1146. },
  1147. every(fn, thisArg) {
  1148. return apply(this, "every", fn, thisArg, void 0, arguments);
  1149. },
  1150. filter(fn, thisArg) {
  1151. return apply(
  1152. this,
  1153. "filter",
  1154. fn,
  1155. thisArg,
  1156. (v) => v.map((item) => toWrapped(this, item)),
  1157. arguments
  1158. );
  1159. },
  1160. find(fn, thisArg) {
  1161. return apply(
  1162. this,
  1163. "find",
  1164. fn,
  1165. thisArg,
  1166. (item) => toWrapped(this, item),
  1167. arguments
  1168. );
  1169. },
  1170. findIndex(fn, thisArg) {
  1171. return apply(this, "findIndex", fn, thisArg, void 0, arguments);
  1172. },
  1173. findLast(fn, thisArg) {
  1174. return apply(
  1175. this,
  1176. "findLast",
  1177. fn,
  1178. thisArg,
  1179. (item) => toWrapped(this, item),
  1180. arguments
  1181. );
  1182. },
  1183. findLastIndex(fn, thisArg) {
  1184. return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
  1185. },
  1186. // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
  1187. forEach(fn, thisArg) {
  1188. return apply(this, "forEach", fn, thisArg, void 0, arguments);
  1189. },
  1190. includes(...args) {
  1191. return searchProxy(this, "includes", args);
  1192. },
  1193. indexOf(...args) {
  1194. return searchProxy(this, "indexOf", args);
  1195. },
  1196. join(separator) {
  1197. return reactiveReadArray(this).join(separator);
  1198. },
  1199. // keys() iterator only reads `length`, no optimization required
  1200. lastIndexOf(...args) {
  1201. return searchProxy(this, "lastIndexOf", args);
  1202. },
  1203. map(fn, thisArg) {
  1204. return apply(this, "map", fn, thisArg, void 0, arguments);
  1205. },
  1206. pop() {
  1207. return noTracking(this, "pop");
  1208. },
  1209. push(...args) {
  1210. return noTracking(this, "push", args);
  1211. },
  1212. reduce(fn, ...args) {
  1213. return reduce(this, "reduce", fn, args);
  1214. },
  1215. reduceRight(fn, ...args) {
  1216. return reduce(this, "reduceRight", fn, args);
  1217. },
  1218. shift() {
  1219. return noTracking(this, "shift");
  1220. },
  1221. // slice could use ARRAY_ITERATE but also seems to beg for range tracking
  1222. some(fn, thisArg) {
  1223. return apply(this, "some", fn, thisArg, void 0, arguments);
  1224. },
  1225. splice(...args) {
  1226. return noTracking(this, "splice", args);
  1227. },
  1228. toReversed() {
  1229. return reactiveReadArray(this).toReversed();
  1230. },
  1231. toSorted(comparer) {
  1232. return reactiveReadArray(this).toSorted(comparer);
  1233. },
  1234. toSpliced(...args) {
  1235. return reactiveReadArray(this).toSpliced(...args);
  1236. },
  1237. unshift(...args) {
  1238. return noTracking(this, "unshift", args);
  1239. },
  1240. values() {
  1241. return iterator(this, "values", (item) => toWrapped(this, item));
  1242. }
  1243. };
  1244. function iterator(self, method, wrapValue) {
  1245. const arr = shallowReadArray(self);
  1246. const iter = arr[method]();
  1247. if (arr !== self && !isShallow(self)) {
  1248. iter._next = iter.next;
  1249. iter.next = () => {
  1250. const result = iter._next();
  1251. if (!result.done) {
  1252. result.value = wrapValue(result.value);
  1253. }
  1254. return result;
  1255. };
  1256. }
  1257. return iter;
  1258. }
  1259. const arrayProto = Array.prototype;
  1260. function apply(self, method, fn, thisArg, wrappedRetFn, args) {
  1261. const arr = shallowReadArray(self);
  1262. const needsWrap = arr !== self && !isShallow(self);
  1263. const methodFn = arr[method];
  1264. if (methodFn !== arrayProto[method]) {
  1265. const result2 = methodFn.apply(self, args);
  1266. return needsWrap ? toReactive(result2) : result2;
  1267. }
  1268. let wrappedFn = fn;
  1269. if (arr !== self) {
  1270. if (needsWrap) {
  1271. wrappedFn = function(item, index) {
  1272. return fn.call(this, toWrapped(self, item), index, self);
  1273. };
  1274. } else if (fn.length > 2) {
  1275. wrappedFn = function(item, index) {
  1276. return fn.call(this, item, index, self);
  1277. };
  1278. }
  1279. }
  1280. const result = methodFn.call(arr, wrappedFn, thisArg);
  1281. return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
  1282. }
  1283. function reduce(self, method, fn, args) {
  1284. const arr = shallowReadArray(self);
  1285. const needsWrap = arr !== self && !isShallow(self);
  1286. let wrappedFn = fn;
  1287. let wrapInitialAccumulator = false;
  1288. if (arr !== self) {
  1289. if (needsWrap) {
  1290. wrapInitialAccumulator = args.length === 0;
  1291. wrappedFn = function(acc, item, index) {
  1292. if (wrapInitialAccumulator) {
  1293. wrapInitialAccumulator = false;
  1294. acc = toWrapped(self, acc);
  1295. }
  1296. return fn.call(this, acc, toWrapped(self, item), index, self);
  1297. };
  1298. } else if (fn.length > 3) {
  1299. wrappedFn = function(acc, item, index) {
  1300. return fn.call(this, acc, item, index, self);
  1301. };
  1302. }
  1303. }
  1304. const result = arr[method](wrappedFn, ...args);
  1305. return wrapInitialAccumulator ? toWrapped(self, result) : result;
  1306. }
  1307. function searchProxy(self, method, args) {
  1308. const arr = toRaw(self);
  1309. track(arr, "iterate", ARRAY_ITERATE_KEY);
  1310. const res = arr[method](...args);
  1311. if ((res === -1 || res === false) && isProxy(args[0])) {
  1312. args[0] = toRaw(args[0]);
  1313. return arr[method](...args);
  1314. }
  1315. return res;
  1316. }
  1317. function noTracking(self, method, args = []) {
  1318. pauseTracking();
  1319. startBatch();
  1320. const res = toRaw(self)[method].apply(self, args);
  1321. endBatch();
  1322. resetTracking();
  1323. return res;
  1324. }
  1325. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  1326. const builtInSymbols = new Set(
  1327. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  1328. );
  1329. function hasOwnProperty(key) {
  1330. if (!isSymbol(key)) key = String(key);
  1331. const obj = toRaw(this);
  1332. track(obj, "has", key);
  1333. return obj.hasOwnProperty(key);
  1334. }
  1335. class BaseReactiveHandler {
  1336. constructor(_isReadonly = false, _isShallow = false) {
  1337. this._isReadonly = _isReadonly;
  1338. this._isShallow = _isShallow;
  1339. }
  1340. get(target, key, receiver) {
  1341. if (key === "__v_skip") return target["__v_skip"];
  1342. const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
  1343. if (key === "__v_isReactive") {
  1344. return !isReadonly2;
  1345. } else if (key === "__v_isReadonly") {
  1346. return isReadonly2;
  1347. } else if (key === "__v_isShallow") {
  1348. return isShallow2;
  1349. } else if (key === "__v_raw") {
  1350. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  1351. // this means the receiver is a user proxy of the reactive proxy
  1352. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  1353. return target;
  1354. }
  1355. return;
  1356. }
  1357. const targetIsArray = isArray(target);
  1358. if (!isReadonly2) {
  1359. let fn;
  1360. if (targetIsArray && (fn = arrayInstrumentations[key])) {
  1361. return fn;
  1362. }
  1363. if (key === "hasOwnProperty") {
  1364. return hasOwnProperty;
  1365. }
  1366. }
  1367. const res = Reflect.get(
  1368. target,
  1369. key,
  1370. // if this is a proxy wrapping a ref, return methods using the raw ref
  1371. // as receiver so that we don't have to call `toRaw` on the ref in all
  1372. // its class methods
  1373. isRef(target) ? target : receiver
  1374. );
  1375. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  1376. return res;
  1377. }
  1378. if (!isReadonly2) {
  1379. track(target, "get", key);
  1380. }
  1381. if (isShallow2) {
  1382. return res;
  1383. }
  1384. if (isRef(res)) {
  1385. const value = targetIsArray && isIntegerKey(key) ? res : res.value;
  1386. return isReadonly2 && isObject(value) ? readonly(value) : value;
  1387. }
  1388. if (isObject(res)) {
  1389. return isReadonly2 ? readonly(res) : reactive(res);
  1390. }
  1391. return res;
  1392. }
  1393. }
  1394. class MutableReactiveHandler extends BaseReactiveHandler {
  1395. constructor(isShallow2 = false) {
  1396. super(false, isShallow2);
  1397. }
  1398. set(target, key, value, receiver) {
  1399. let oldValue = target[key];
  1400. const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
  1401. if (!this._isShallow) {
  1402. const isOldValueReadonly = isReadonly(oldValue);
  1403. if (!isShallow(value) && !isReadonly(value)) {
  1404. oldValue = toRaw(oldValue);
  1405. value = toRaw(value);
  1406. }
  1407. if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
  1408. if (isOldValueReadonly) {
  1409. {
  1410. warn$2(
  1411. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1412. target[key]
  1413. );
  1414. }
  1415. return true;
  1416. } else {
  1417. oldValue.value = value;
  1418. return true;
  1419. }
  1420. }
  1421. }
  1422. const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
  1423. const result = Reflect.set(
  1424. target,
  1425. key,
  1426. value,
  1427. isRef(target) ? target : receiver
  1428. );
  1429. if (target === toRaw(receiver)) {
  1430. if (!hadKey) {
  1431. trigger(target, "add", key, value);
  1432. } else if (hasChanged(value, oldValue)) {
  1433. trigger(target, "set", key, value, oldValue);
  1434. }
  1435. }
  1436. return result;
  1437. }
  1438. deleteProperty(target, key) {
  1439. const hadKey = hasOwn(target, key);
  1440. const oldValue = target[key];
  1441. const result = Reflect.deleteProperty(target, key);
  1442. if (result && hadKey) {
  1443. trigger(target, "delete", key, void 0, oldValue);
  1444. }
  1445. return result;
  1446. }
  1447. has(target, key) {
  1448. const result = Reflect.has(target, key);
  1449. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  1450. track(target, "has", key);
  1451. }
  1452. return result;
  1453. }
  1454. ownKeys(target) {
  1455. track(
  1456. target,
  1457. "iterate",
  1458. isArray(target) ? "length" : ITERATE_KEY
  1459. );
  1460. return Reflect.ownKeys(target);
  1461. }
  1462. }
  1463. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  1464. constructor(isShallow2 = false) {
  1465. super(true, isShallow2);
  1466. }
  1467. set(target, key) {
  1468. {
  1469. warn$2(
  1470. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1471. target
  1472. );
  1473. }
  1474. return true;
  1475. }
  1476. deleteProperty(target, key) {
  1477. {
  1478. warn$2(
  1479. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  1480. target
  1481. );
  1482. }
  1483. return true;
  1484. }
  1485. }
  1486. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  1487. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  1488. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
  1489. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  1490. const toShallow = (value) => value;
  1491. const getProto = (v) => Reflect.getPrototypeOf(v);
  1492. function createIterableMethod(method, isReadonly2, isShallow2) {
  1493. return function(...args) {
  1494. const target = this["__v_raw"];
  1495. const rawTarget = toRaw(target);
  1496. const targetIsMap = isMap(rawTarget);
  1497. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  1498. const isKeyOnly = method === "keys" && targetIsMap;
  1499. const innerIterator = target[method](...args);
  1500. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  1501. !isReadonly2 && track(
  1502. rawTarget,
  1503. "iterate",
  1504. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  1505. );
  1506. return extend(
  1507. // inheriting all iterator properties
  1508. Object.create(innerIterator),
  1509. {
  1510. // iterator protocol
  1511. next() {
  1512. const { value, done } = innerIterator.next();
  1513. return done ? { value, done } : {
  1514. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1515. done
  1516. };
  1517. }
  1518. }
  1519. );
  1520. };
  1521. }
  1522. function createReadonlyMethod(type) {
  1523. return function(...args) {
  1524. {
  1525. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1526. warn$2(
  1527. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  1528. toRaw(this)
  1529. );
  1530. }
  1531. return type === "delete" ? false : type === "clear" ? void 0 : this;
  1532. };
  1533. }
  1534. function createInstrumentations(readonly, shallow) {
  1535. const instrumentations = {
  1536. get(key) {
  1537. const target = this["__v_raw"];
  1538. const rawTarget = toRaw(target);
  1539. const rawKey = toRaw(key);
  1540. if (!readonly) {
  1541. if (hasChanged(key, rawKey)) {
  1542. track(rawTarget, "get", key);
  1543. }
  1544. track(rawTarget, "get", rawKey);
  1545. }
  1546. const { has } = getProto(rawTarget);
  1547. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1548. if (has.call(rawTarget, key)) {
  1549. return wrap(target.get(key));
  1550. } else if (has.call(rawTarget, rawKey)) {
  1551. return wrap(target.get(rawKey));
  1552. } else if (target !== rawTarget) {
  1553. target.get(key);
  1554. }
  1555. },
  1556. get size() {
  1557. const target = this["__v_raw"];
  1558. !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
  1559. return target.size;
  1560. },
  1561. has(key) {
  1562. const target = this["__v_raw"];
  1563. const rawTarget = toRaw(target);
  1564. const rawKey = toRaw(key);
  1565. if (!readonly) {
  1566. if (hasChanged(key, rawKey)) {
  1567. track(rawTarget, "has", key);
  1568. }
  1569. track(rawTarget, "has", rawKey);
  1570. }
  1571. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  1572. },
  1573. forEach(callback, thisArg) {
  1574. const observed = this;
  1575. const target = observed["__v_raw"];
  1576. const rawTarget = toRaw(target);
  1577. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1578. !readonly && track(rawTarget, "iterate", ITERATE_KEY);
  1579. return target.forEach((value, key) => {
  1580. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1581. });
  1582. }
  1583. };
  1584. extend(
  1585. instrumentations,
  1586. readonly ? {
  1587. add: createReadonlyMethod("add"),
  1588. set: createReadonlyMethod("set"),
  1589. delete: createReadonlyMethod("delete"),
  1590. clear: createReadonlyMethod("clear")
  1591. } : {
  1592. add(value) {
  1593. const target = toRaw(this);
  1594. const proto = getProto(target);
  1595. const rawValue = toRaw(value);
  1596. const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
  1597. const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
  1598. if (!hadKey) {
  1599. target.add(valueToAdd);
  1600. trigger(target, "add", valueToAdd, valueToAdd);
  1601. }
  1602. return this;
  1603. },
  1604. set(key, value) {
  1605. if (!shallow && !isShallow(value) && !isReadonly(value)) {
  1606. value = toRaw(value);
  1607. }
  1608. const target = toRaw(this);
  1609. const { has, get } = getProto(target);
  1610. let hadKey = has.call(target, key);
  1611. if (!hadKey) {
  1612. key = toRaw(key);
  1613. hadKey = has.call(target, key);
  1614. } else {
  1615. checkIdentityKeys(target, has, key);
  1616. }
  1617. const oldValue = get.call(target, key);
  1618. target.set(key, value);
  1619. if (!hadKey) {
  1620. trigger(target, "add", key, value);
  1621. } else if (hasChanged(value, oldValue)) {
  1622. trigger(target, "set", key, value, oldValue);
  1623. }
  1624. return this;
  1625. },
  1626. delete(key) {
  1627. const target = toRaw(this);
  1628. const { has, get } = getProto(target);
  1629. let hadKey = has.call(target, key);
  1630. if (!hadKey) {
  1631. key = toRaw(key);
  1632. hadKey = has.call(target, key);
  1633. } else {
  1634. checkIdentityKeys(target, has, key);
  1635. }
  1636. const oldValue = get ? get.call(target, key) : void 0;
  1637. const result = target.delete(key);
  1638. if (hadKey) {
  1639. trigger(target, "delete", key, void 0, oldValue);
  1640. }
  1641. return result;
  1642. },
  1643. clear() {
  1644. const target = toRaw(this);
  1645. const hadItems = target.size !== 0;
  1646. const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
  1647. const result = target.clear();
  1648. if (hadItems) {
  1649. trigger(
  1650. target,
  1651. "clear",
  1652. void 0,
  1653. void 0,
  1654. oldTarget
  1655. );
  1656. }
  1657. return result;
  1658. }
  1659. }
  1660. );
  1661. const iteratorMethods = [
  1662. "keys",
  1663. "values",
  1664. "entries",
  1665. Symbol.iterator
  1666. ];
  1667. iteratorMethods.forEach((method) => {
  1668. instrumentations[method] = createIterableMethod(method, readonly, shallow);
  1669. });
  1670. return instrumentations;
  1671. }
  1672. function createInstrumentationGetter(isReadonly2, shallow) {
  1673. const instrumentations = createInstrumentations(isReadonly2, shallow);
  1674. return (target, key, receiver) => {
  1675. if (key === "__v_isReactive") {
  1676. return !isReadonly2;
  1677. } else if (key === "__v_isReadonly") {
  1678. return isReadonly2;
  1679. } else if (key === "__v_raw") {
  1680. return target;
  1681. }
  1682. return Reflect.get(
  1683. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1684. key,
  1685. receiver
  1686. );
  1687. };
  1688. }
  1689. const mutableCollectionHandlers = {
  1690. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1691. };
  1692. const shallowCollectionHandlers = {
  1693. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1694. };
  1695. const readonlyCollectionHandlers = {
  1696. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1697. };
  1698. const shallowReadonlyCollectionHandlers = {
  1699. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1700. };
  1701. function checkIdentityKeys(target, has, key) {
  1702. const rawKey = toRaw(key);
  1703. if (rawKey !== key && has.call(target, rawKey)) {
  1704. const type = toRawType(target);
  1705. warn$2(
  1706. `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.`
  1707. );
  1708. }
  1709. }
  1710. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1711. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1712. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1713. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1714. function targetTypeMap(rawType) {
  1715. switch (rawType) {
  1716. case "Object":
  1717. case "Array":
  1718. return 1 /* COMMON */;
  1719. case "Map":
  1720. case "Set":
  1721. case "WeakMap":
  1722. case "WeakSet":
  1723. return 2 /* COLLECTION */;
  1724. default:
  1725. return 0 /* INVALID */;
  1726. }
  1727. }
  1728. // @__NO_SIDE_EFFECTS__
  1729. function reactive(target) {
  1730. if (/* @__PURE__ */ isReadonly(target)) {
  1731. return target;
  1732. }
  1733. return createReactiveObject(
  1734. target,
  1735. false,
  1736. mutableHandlers,
  1737. mutableCollectionHandlers,
  1738. reactiveMap
  1739. );
  1740. }
  1741. // @__NO_SIDE_EFFECTS__
  1742. function shallowReactive(target) {
  1743. return createReactiveObject(
  1744. target,
  1745. false,
  1746. shallowReactiveHandlers,
  1747. shallowCollectionHandlers,
  1748. shallowReactiveMap
  1749. );
  1750. }
  1751. // @__NO_SIDE_EFFECTS__
  1752. function readonly(target) {
  1753. return createReactiveObject(
  1754. target,
  1755. true,
  1756. readonlyHandlers,
  1757. readonlyCollectionHandlers,
  1758. readonlyMap
  1759. );
  1760. }
  1761. // @__NO_SIDE_EFFECTS__
  1762. function shallowReadonly(target) {
  1763. return createReactiveObject(
  1764. target,
  1765. true,
  1766. shallowReadonlyHandlers,
  1767. shallowReadonlyCollectionHandlers,
  1768. shallowReadonlyMap
  1769. );
  1770. }
  1771. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1772. if (!isObject(target)) {
  1773. {
  1774. warn$2(
  1775. `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
  1776. target
  1777. )}`
  1778. );
  1779. }
  1780. return target;
  1781. }
  1782. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1783. return target;
  1784. }
  1785. if (target["__v_skip"] || !Object.isExtensible(target)) {
  1786. return target;
  1787. }
  1788. const existingProxy = proxyMap.get(target);
  1789. if (existingProxy) {
  1790. return existingProxy;
  1791. }
  1792. const targetType = targetTypeMap(toRawType(target));
  1793. if (targetType === 0 /* INVALID */) {
  1794. return target;
  1795. }
  1796. const proxy = new Proxy(
  1797. target,
  1798. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1799. );
  1800. proxyMap.set(target, proxy);
  1801. return proxy;
  1802. }
  1803. // @__NO_SIDE_EFFECTS__
  1804. function isReactive(value) {
  1805. if (/* @__PURE__ */ isReadonly(value)) {
  1806. return /* @__PURE__ */ isReactive(value["__v_raw"]);
  1807. }
  1808. return !!(value && value["__v_isReactive"]);
  1809. }
  1810. // @__NO_SIDE_EFFECTS__
  1811. function isReadonly(value) {
  1812. return !!(value && value["__v_isReadonly"]);
  1813. }
  1814. // @__NO_SIDE_EFFECTS__
  1815. function isShallow(value) {
  1816. return !!(value && value["__v_isShallow"]);
  1817. }
  1818. // @__NO_SIDE_EFFECTS__
  1819. function isProxy(value) {
  1820. return value ? !!value["__v_raw"] : false;
  1821. }
  1822. // @__NO_SIDE_EFFECTS__
  1823. function toRaw(observed) {
  1824. const raw = observed && observed["__v_raw"];
  1825. return raw ? /* @__PURE__ */ toRaw(raw) : observed;
  1826. }
  1827. function markRaw(value) {
  1828. if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
  1829. def(value, "__v_skip", true);
  1830. }
  1831. return value;
  1832. }
  1833. const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
  1834. const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
  1835. // @__NO_SIDE_EFFECTS__
  1836. function isRef(r) {
  1837. return r ? r["__v_isRef"] === true : false;
  1838. }
  1839. // @__NO_SIDE_EFFECTS__
  1840. function ref(value) {
  1841. return createRef(value, false);
  1842. }
  1843. // @__NO_SIDE_EFFECTS__
  1844. function shallowRef(value) {
  1845. return createRef(value, true);
  1846. }
  1847. function createRef(rawValue, shallow) {
  1848. if (/* @__PURE__ */ isRef(rawValue)) {
  1849. return rawValue;
  1850. }
  1851. return new RefImpl(rawValue, shallow);
  1852. }
  1853. class RefImpl {
  1854. constructor(value, isShallow2) {
  1855. this.dep = new Dep();
  1856. this["__v_isRef"] = true;
  1857. this["__v_isShallow"] = false;
  1858. this._rawValue = isShallow2 ? value : toRaw(value);
  1859. this._value = isShallow2 ? value : toReactive(value);
  1860. this["__v_isShallow"] = isShallow2;
  1861. }
  1862. get value() {
  1863. {
  1864. this.dep.track({
  1865. target: this,
  1866. type: "get",
  1867. key: "value"
  1868. });
  1869. }
  1870. return this._value;
  1871. }
  1872. set value(newValue) {
  1873. const oldValue = this._rawValue;
  1874. const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
  1875. newValue = useDirectValue ? newValue : toRaw(newValue);
  1876. if (hasChanged(newValue, oldValue)) {
  1877. this._rawValue = newValue;
  1878. this._value = useDirectValue ? newValue : toReactive(newValue);
  1879. {
  1880. this.dep.trigger({
  1881. target: this,
  1882. type: "set",
  1883. key: "value",
  1884. newValue,
  1885. oldValue
  1886. });
  1887. }
  1888. }
  1889. }
  1890. }
  1891. function triggerRef(ref2) {
  1892. if (ref2.dep) {
  1893. {
  1894. ref2.dep.trigger({
  1895. target: ref2,
  1896. type: "set",
  1897. key: "value",
  1898. newValue: ref2._value
  1899. });
  1900. }
  1901. }
  1902. }
  1903. function unref(ref2) {
  1904. return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
  1905. }
  1906. function toValue(source) {
  1907. return isFunction(source) ? source() : unref(source);
  1908. }
  1909. const shallowUnwrapHandlers = {
  1910. get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
  1911. set: (target, key, value, receiver) => {
  1912. const oldValue = target[key];
  1913. if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
  1914. oldValue.value = value;
  1915. return true;
  1916. } else {
  1917. return Reflect.set(target, key, value, receiver);
  1918. }
  1919. }
  1920. };
  1921. function proxyRefs(objectWithRefs) {
  1922. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1923. }
  1924. class CustomRefImpl {
  1925. constructor(factory) {
  1926. this["__v_isRef"] = true;
  1927. this._value = void 0;
  1928. const dep = this.dep = new Dep();
  1929. const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
  1930. this._get = get;
  1931. this._set = set;
  1932. }
  1933. get value() {
  1934. return this._value = this._get();
  1935. }
  1936. set value(newVal) {
  1937. this._set(newVal);
  1938. }
  1939. }
  1940. function customRef(factory) {
  1941. return new CustomRefImpl(factory);
  1942. }
  1943. // @__NO_SIDE_EFFECTS__
  1944. function toRefs(object) {
  1945. if (!isProxy(object)) {
  1946. warn$2(`toRefs() expects a reactive object but received a plain one.`);
  1947. }
  1948. const ret = isArray(object) ? new Array(object.length) : {};
  1949. for (const key in object) {
  1950. ret[key] = propertyToRef(object, key);
  1951. }
  1952. return ret;
  1953. }
  1954. class ObjectRefImpl {
  1955. constructor(_object, key, _defaultValue) {
  1956. this._object = _object;
  1957. this._defaultValue = _defaultValue;
  1958. this["__v_isRef"] = true;
  1959. this._value = void 0;
  1960. this._key = isSymbol(key) ? key : String(key);
  1961. this._raw = toRaw(_object);
  1962. let shallow = true;
  1963. let obj = _object;
  1964. if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
  1965. do {
  1966. shallow = !isProxy(obj) || isShallow(obj);
  1967. } while (shallow && (obj = obj["__v_raw"]));
  1968. }
  1969. this._shallow = shallow;
  1970. }
  1971. get value() {
  1972. let val = this._object[this._key];
  1973. if (this._shallow) {
  1974. val = unref(val);
  1975. }
  1976. return this._value = val === void 0 ? this._defaultValue : val;
  1977. }
  1978. set value(newVal) {
  1979. if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
  1980. const nestedRef = this._object[this._key];
  1981. if (/* @__PURE__ */ isRef(nestedRef)) {
  1982. nestedRef.value = newVal;
  1983. return;
  1984. }
  1985. }
  1986. this._object[this._key] = newVal;
  1987. }
  1988. get dep() {
  1989. return getDepFromReactive(this._raw, this._key);
  1990. }
  1991. }
  1992. class GetterRefImpl {
  1993. constructor(_getter) {
  1994. this._getter = _getter;
  1995. this["__v_isRef"] = true;
  1996. this["__v_isReadonly"] = true;
  1997. this._value = void 0;
  1998. }
  1999. get value() {
  2000. return this._value = this._getter();
  2001. }
  2002. }
  2003. // @__NO_SIDE_EFFECTS__
  2004. function toRef(source, key, defaultValue) {
  2005. if (/* @__PURE__ */ isRef(source)) {
  2006. return source;
  2007. } else if (isFunction(source)) {
  2008. return new GetterRefImpl(source);
  2009. } else if (isObject(source) && arguments.length > 1) {
  2010. return propertyToRef(source, key, defaultValue);
  2011. } else {
  2012. return /* @__PURE__ */ ref(source);
  2013. }
  2014. }
  2015. function propertyToRef(source, key, defaultValue) {
  2016. return new ObjectRefImpl(source, key, defaultValue);
  2017. }
  2018. class ComputedRefImpl {
  2019. constructor(fn, setter, isSSR) {
  2020. this.fn = fn;
  2021. this.setter = setter;
  2022. /**
  2023. * @internal
  2024. */
  2025. this._value = void 0;
  2026. /**
  2027. * @internal
  2028. */
  2029. this.dep = new Dep(this);
  2030. /**
  2031. * @internal
  2032. */
  2033. this.__v_isRef = true;
  2034. // TODO isolatedDeclarations "__v_isReadonly"
  2035. // A computed is also a subscriber that tracks other deps
  2036. /**
  2037. * @internal
  2038. */
  2039. this.deps = void 0;
  2040. /**
  2041. * @internal
  2042. */
  2043. this.depsTail = void 0;
  2044. /**
  2045. * @internal
  2046. */
  2047. this.flags = 16;
  2048. /**
  2049. * @internal
  2050. */
  2051. this.globalVersion = globalVersion - 1;
  2052. /**
  2053. * @internal
  2054. */
  2055. this.next = void 0;
  2056. // for backwards compat
  2057. this.effect = this;
  2058. this["__v_isReadonly"] = !setter;
  2059. this.isSSR = isSSR;
  2060. }
  2061. /**
  2062. * @internal
  2063. */
  2064. notify() {
  2065. this.flags |= 16;
  2066. if (!(this.flags & 8) && // avoid infinite self recursion
  2067. activeSub !== this) {
  2068. batch(this, true);
  2069. return true;
  2070. }
  2071. }
  2072. get value() {
  2073. const link = this.dep.track({
  2074. target: this,
  2075. type: "get",
  2076. key: "value"
  2077. }) ;
  2078. refreshComputed(this);
  2079. if (link) {
  2080. link.version = this.dep.version;
  2081. }
  2082. return this._value;
  2083. }
  2084. set value(newValue) {
  2085. if (this.setter) {
  2086. this.setter(newValue);
  2087. } else {
  2088. warn$2("Write operation failed: computed value is readonly");
  2089. }
  2090. }
  2091. }
  2092. // @__NO_SIDE_EFFECTS__
  2093. function computed$1(getterOrOptions, debugOptions, isSSR = false) {
  2094. let getter;
  2095. let setter;
  2096. if (isFunction(getterOrOptions)) {
  2097. getter = getterOrOptions;
  2098. } else {
  2099. getter = getterOrOptions.get;
  2100. setter = getterOrOptions.set;
  2101. }
  2102. const cRef = new ComputedRefImpl(getter, setter, isSSR);
  2103. if (debugOptions && !isSSR) {
  2104. cRef.onTrack = debugOptions.onTrack;
  2105. cRef.onTrigger = debugOptions.onTrigger;
  2106. }
  2107. return cRef;
  2108. }
  2109. const TrackOpTypes = {
  2110. "GET": "get",
  2111. "HAS": "has",
  2112. "ITERATE": "iterate"
  2113. };
  2114. const TriggerOpTypes = {
  2115. "SET": "set",
  2116. "ADD": "add",
  2117. "DELETE": "delete",
  2118. "CLEAR": "clear"
  2119. };
  2120. const INITIAL_WATCHER_VALUE = {};
  2121. const cleanupMap = /* @__PURE__ */ new WeakMap();
  2122. let activeWatcher = void 0;
  2123. function getCurrentWatcher() {
  2124. return activeWatcher;
  2125. }
  2126. function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
  2127. if (owner) {
  2128. let cleanups = cleanupMap.get(owner);
  2129. if (!cleanups) cleanupMap.set(owner, cleanups = []);
  2130. cleanups.push(cleanupFn);
  2131. } else if (!failSilently) {
  2132. warn$2(
  2133. `onWatcherCleanup() was called when there was no active watcher to associate with.`
  2134. );
  2135. }
  2136. }
  2137. function watch$1(source, cb, options = EMPTY_OBJ) {
  2138. const { immediate, deep, once, scheduler, augmentJob, call } = options;
  2139. const warnInvalidSource = (s) => {
  2140. (options.onWarn || warn$2)(
  2141. `Invalid watch source: `,
  2142. s,
  2143. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  2144. );
  2145. };
  2146. const reactiveGetter = (source2) => {
  2147. if (deep) return source2;
  2148. if (isShallow(source2) || deep === false || deep === 0)
  2149. return traverse(source2, 1);
  2150. return traverse(source2);
  2151. };
  2152. let effect;
  2153. let getter;
  2154. let cleanup;
  2155. let boundCleanup;
  2156. let forceTrigger = false;
  2157. let isMultiSource = false;
  2158. if (isRef(source)) {
  2159. getter = () => source.value;
  2160. forceTrigger = isShallow(source);
  2161. } else if (isReactive(source)) {
  2162. getter = () => reactiveGetter(source);
  2163. forceTrigger = true;
  2164. } else if (isArray(source)) {
  2165. isMultiSource = true;
  2166. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  2167. getter = () => source.map((s) => {
  2168. if (isRef(s)) {
  2169. return s.value;
  2170. } else if (isReactive(s)) {
  2171. return reactiveGetter(s);
  2172. } else if (isFunction(s)) {
  2173. return call ? call(s, 2) : s();
  2174. } else {
  2175. warnInvalidSource(s);
  2176. }
  2177. });
  2178. } else if (isFunction(source)) {
  2179. if (cb) {
  2180. getter = call ? () => call(source, 2) : source;
  2181. } else {
  2182. getter = () => {
  2183. if (cleanup) {
  2184. pauseTracking();
  2185. try {
  2186. cleanup();
  2187. } finally {
  2188. resetTracking();
  2189. }
  2190. }
  2191. const currentEffect = activeWatcher;
  2192. activeWatcher = effect;
  2193. try {
  2194. return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
  2195. } finally {
  2196. activeWatcher = currentEffect;
  2197. }
  2198. };
  2199. }
  2200. } else {
  2201. getter = NOOP;
  2202. warnInvalidSource(source);
  2203. }
  2204. if (cb && deep) {
  2205. const baseGetter = getter;
  2206. const depth = deep === true ? Infinity : deep;
  2207. getter = () => traverse(baseGetter(), depth);
  2208. }
  2209. const scope = getCurrentScope();
  2210. const watchHandle = () => {
  2211. effect.stop();
  2212. if (scope && scope.active) {
  2213. remove(scope.effects, effect);
  2214. }
  2215. };
  2216. if (once && cb) {
  2217. const _cb = cb;
  2218. cb = (...args) => {
  2219. _cb(...args);
  2220. watchHandle();
  2221. };
  2222. }
  2223. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  2224. const job = (immediateFirstRun) => {
  2225. if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
  2226. return;
  2227. }
  2228. if (cb) {
  2229. const newValue = effect.run();
  2230. if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
  2231. if (cleanup) {
  2232. cleanup();
  2233. }
  2234. const currentWatcher = activeWatcher;
  2235. activeWatcher = effect;
  2236. try {
  2237. const args = [
  2238. newValue,
  2239. // pass undefined as the old value when it's changed for the first time
  2240. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  2241. boundCleanup
  2242. ];
  2243. oldValue = newValue;
  2244. call ? call(cb, 3, args) : (
  2245. // @ts-expect-error
  2246. cb(...args)
  2247. );
  2248. } finally {
  2249. activeWatcher = currentWatcher;
  2250. }
  2251. }
  2252. } else {
  2253. effect.run();
  2254. }
  2255. };
  2256. if (augmentJob) {
  2257. augmentJob(job);
  2258. }
  2259. effect = new ReactiveEffect(getter);
  2260. effect.scheduler = scheduler ? () => scheduler(job, false) : job;
  2261. boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
  2262. cleanup = effect.onStop = () => {
  2263. const cleanups = cleanupMap.get(effect);
  2264. if (cleanups) {
  2265. if (call) {
  2266. call(cleanups, 4);
  2267. } else {
  2268. for (const cleanup2 of cleanups) cleanup2();
  2269. }
  2270. cleanupMap.delete(effect);
  2271. }
  2272. };
  2273. {
  2274. effect.onTrack = options.onTrack;
  2275. effect.onTrigger = options.onTrigger;
  2276. }
  2277. if (cb) {
  2278. if (immediate) {
  2279. job(true);
  2280. } else {
  2281. oldValue = effect.run();
  2282. }
  2283. } else if (scheduler) {
  2284. scheduler(job.bind(null, true), true);
  2285. } else {
  2286. effect.run();
  2287. }
  2288. watchHandle.pause = effect.pause.bind(effect);
  2289. watchHandle.resume = effect.resume.bind(effect);
  2290. watchHandle.stop = watchHandle;
  2291. return watchHandle;
  2292. }
  2293. function traverse(value, depth = Infinity, seen) {
  2294. if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
  2295. return value;
  2296. }
  2297. seen = seen || /* @__PURE__ */ new Map();
  2298. if ((seen.get(value) || 0) >= depth) {
  2299. return value;
  2300. }
  2301. seen.set(value, depth);
  2302. depth--;
  2303. if (isRef(value)) {
  2304. traverse(value.value, depth, seen);
  2305. } else if (isArray(value)) {
  2306. for (let i = 0; i < value.length; i++) {
  2307. traverse(value[i], depth, seen);
  2308. }
  2309. } else if (isSet(value) || isMap(value)) {
  2310. value.forEach((v) => {
  2311. traverse(v, depth, seen);
  2312. });
  2313. } else if (isPlainObject(value)) {
  2314. for (const key in value) {
  2315. traverse(value[key], depth, seen);
  2316. }
  2317. for (const key of Object.getOwnPropertySymbols(value)) {
  2318. if (Object.prototype.propertyIsEnumerable.call(value, key)) {
  2319. traverse(value[key], depth, seen);
  2320. }
  2321. }
  2322. }
  2323. return value;
  2324. }
  2325. const stack$1 = [];
  2326. function pushWarningContext(vnode) {
  2327. stack$1.push(vnode);
  2328. }
  2329. function popWarningContext() {
  2330. stack$1.pop();
  2331. }
  2332. let isWarning = false;
  2333. function warn$1(msg, ...args) {
  2334. if (isWarning) return;
  2335. isWarning = true;
  2336. pauseTracking();
  2337. const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
  2338. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  2339. const trace = getComponentTrace();
  2340. if (appWarnHandler) {
  2341. callWithErrorHandling(
  2342. appWarnHandler,
  2343. instance,
  2344. 11,
  2345. [
  2346. // eslint-disable-next-line no-restricted-syntax
  2347. msg + args.map((a) => {
  2348. var _a, _b;
  2349. return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
  2350. }).join(""),
  2351. instance && instance.proxy,
  2352. trace.map(
  2353. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
  2354. ).join("\n"),
  2355. trace
  2356. ]
  2357. );
  2358. } else {
  2359. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  2360. if (trace.length && // avoid spamming console during tests
  2361. true) {
  2362. warnArgs.push(`
  2363. `, ...formatTrace(trace));
  2364. }
  2365. console.warn(...warnArgs);
  2366. }
  2367. resetTracking();
  2368. isWarning = false;
  2369. }
  2370. function getComponentTrace() {
  2371. let currentVNode = stack$1[stack$1.length - 1];
  2372. if (!currentVNode) {
  2373. return [];
  2374. }
  2375. const normalizedStack = [];
  2376. while (currentVNode) {
  2377. const last = normalizedStack[0];
  2378. if (last && last.vnode === currentVNode) {
  2379. last.recurseCount++;
  2380. } else {
  2381. normalizedStack.push({
  2382. vnode: currentVNode,
  2383. recurseCount: 0
  2384. });
  2385. }
  2386. const parentInstance = currentVNode.component && currentVNode.component.parent;
  2387. currentVNode = parentInstance && parentInstance.vnode;
  2388. }
  2389. return normalizedStack;
  2390. }
  2391. function formatTrace(trace) {
  2392. const logs = [];
  2393. trace.forEach((entry, i) => {
  2394. logs.push(...i === 0 ? [] : [`
  2395. `], ...formatTraceEntry(entry));
  2396. });
  2397. return logs;
  2398. }
  2399. function formatTraceEntry({ vnode, recurseCount }) {
  2400. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  2401. const isRoot = vnode.component ? vnode.component.parent == null : false;
  2402. const open = ` at <${formatComponentName(
  2403. vnode.component,
  2404. vnode.type,
  2405. isRoot
  2406. )}`;
  2407. const close = `>` + postfix;
  2408. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
  2409. }
  2410. function formatProps(props) {
  2411. const res = [];
  2412. const keys = Object.keys(props);
  2413. keys.slice(0, 3).forEach((key) => {
  2414. res.push(...formatProp(key, props[key]));
  2415. });
  2416. if (keys.length > 3) {
  2417. res.push(` ...`);
  2418. }
  2419. return res;
  2420. }
  2421. function formatProp(key, value, raw) {
  2422. if (isString(value)) {
  2423. value = JSON.stringify(value);
  2424. return raw ? value : [`${key}=${value}`];
  2425. } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
  2426. return raw ? value : [`${key}=${value}`];
  2427. } else if (isRef(value)) {
  2428. value = formatProp(key, toRaw(value.value), true);
  2429. return raw ? value : [`${key}=Ref<`, value, `>`];
  2430. } else if (isFunction(value)) {
  2431. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  2432. } else {
  2433. value = toRaw(value);
  2434. return raw ? value : [`${key}=`, value];
  2435. }
  2436. }
  2437. function assertNumber(val, type) {
  2438. if (val === void 0) {
  2439. return;
  2440. } else if (typeof val !== "number") {
  2441. warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
  2442. } else if (isNaN(val)) {
  2443. warn$1(`${type} is NaN - the duration expression might be incorrect.`);
  2444. }
  2445. }
  2446. const ErrorCodes = {
  2447. "SETUP_FUNCTION": 0,
  2448. "0": "SETUP_FUNCTION",
  2449. "RENDER_FUNCTION": 1,
  2450. "1": "RENDER_FUNCTION",
  2451. "NATIVE_EVENT_HANDLER": 5,
  2452. "5": "NATIVE_EVENT_HANDLER",
  2453. "COMPONENT_EVENT_HANDLER": 6,
  2454. "6": "COMPONENT_EVENT_HANDLER",
  2455. "VNODE_HOOK": 7,
  2456. "7": "VNODE_HOOK",
  2457. "DIRECTIVE_HOOK": 8,
  2458. "8": "DIRECTIVE_HOOK",
  2459. "TRANSITION_HOOK": 9,
  2460. "9": "TRANSITION_HOOK",
  2461. "APP_ERROR_HANDLER": 10,
  2462. "10": "APP_ERROR_HANDLER",
  2463. "APP_WARN_HANDLER": 11,
  2464. "11": "APP_WARN_HANDLER",
  2465. "FUNCTION_REF": 12,
  2466. "12": "FUNCTION_REF",
  2467. "ASYNC_COMPONENT_LOADER": 13,
  2468. "13": "ASYNC_COMPONENT_LOADER",
  2469. "SCHEDULER": 14,
  2470. "14": "SCHEDULER",
  2471. "COMPONENT_UPDATE": 15,
  2472. "15": "COMPONENT_UPDATE",
  2473. "APP_UNMOUNT_CLEANUP": 16,
  2474. "16": "APP_UNMOUNT_CLEANUP"
  2475. };
  2476. const ErrorTypeStrings$1 = {
  2477. ["sp"]: "serverPrefetch hook",
  2478. ["bc"]: "beforeCreate hook",
  2479. ["c"]: "created hook",
  2480. ["bm"]: "beforeMount hook",
  2481. ["m"]: "mounted hook",
  2482. ["bu"]: "beforeUpdate hook",
  2483. ["u"]: "updated",
  2484. ["bum"]: "beforeUnmount hook",
  2485. ["um"]: "unmounted hook",
  2486. ["a"]: "activated hook",
  2487. ["da"]: "deactivated hook",
  2488. ["ec"]: "errorCaptured hook",
  2489. ["rtc"]: "renderTracked hook",
  2490. ["rtg"]: "renderTriggered hook",
  2491. [0]: "setup function",
  2492. [1]: "render function",
  2493. [2]: "watcher getter",
  2494. [3]: "watcher callback",
  2495. [4]: "watcher cleanup function",
  2496. [5]: "native event handler",
  2497. [6]: "component event handler",
  2498. [7]: "vnode hook",
  2499. [8]: "directive hook",
  2500. [9]: "transition hook",
  2501. [10]: "app errorHandler",
  2502. [11]: "app warnHandler",
  2503. [12]: "ref function",
  2504. [13]: "async component loader",
  2505. [14]: "scheduler flush",
  2506. [15]: "component update",
  2507. [16]: "app unmount cleanup function"
  2508. };
  2509. function callWithErrorHandling(fn, instance, type, args) {
  2510. try {
  2511. return args ? fn(...args) : fn();
  2512. } catch (err) {
  2513. handleError(err, instance, type);
  2514. }
  2515. }
  2516. function callWithAsyncErrorHandling(fn, instance, type, args) {
  2517. if (isFunction(fn)) {
  2518. const res = callWithErrorHandling(fn, instance, type, args);
  2519. if (res && isPromise(res)) {
  2520. res.catch((err) => {
  2521. handleError(err, instance, type);
  2522. });
  2523. }
  2524. return res;
  2525. }
  2526. if (isArray(fn)) {
  2527. const values = [];
  2528. for (let i = 0; i < fn.length; i++) {
  2529. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  2530. }
  2531. return values;
  2532. } else {
  2533. warn$1(
  2534. `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
  2535. );
  2536. }
  2537. }
  2538. function handleError(err, instance, type, throwInDev = true) {
  2539. const contextVNode = instance ? instance.vnode : null;
  2540. const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
  2541. if (instance) {
  2542. let cur = instance.parent;
  2543. const exposedInstance = instance.proxy;
  2544. const errorInfo = ErrorTypeStrings$1[type] ;
  2545. while (cur) {
  2546. const errorCapturedHooks = cur.ec;
  2547. if (errorCapturedHooks) {
  2548. for (let i = 0; i < errorCapturedHooks.length; i++) {
  2549. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  2550. return;
  2551. }
  2552. }
  2553. }
  2554. cur = cur.parent;
  2555. }
  2556. if (errorHandler) {
  2557. pauseTracking();
  2558. callWithErrorHandling(errorHandler, null, 10, [
  2559. err,
  2560. exposedInstance,
  2561. errorInfo
  2562. ]);
  2563. resetTracking();
  2564. return;
  2565. }
  2566. }
  2567. logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
  2568. }
  2569. function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
  2570. {
  2571. const info = ErrorTypeStrings$1[type];
  2572. if (contextVNode) {
  2573. pushWarningContext(contextVNode);
  2574. }
  2575. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  2576. if (contextVNode) {
  2577. popWarningContext();
  2578. }
  2579. if (throwInDev) {
  2580. throw err;
  2581. } else {
  2582. console.error(err);
  2583. }
  2584. }
  2585. }
  2586. const queue = [];
  2587. let flushIndex = -1;
  2588. const pendingPostFlushCbs = [];
  2589. let activePostFlushCbs = null;
  2590. let postFlushIndex = 0;
  2591. const resolvedPromise = /* @__PURE__ */ Promise.resolve();
  2592. let currentFlushPromise = null;
  2593. const RECURSION_LIMIT = 100;
  2594. function nextTick(fn) {
  2595. const p = currentFlushPromise || resolvedPromise;
  2596. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  2597. }
  2598. function findInsertionIndex(id) {
  2599. let start = flushIndex + 1;
  2600. let end = queue.length;
  2601. while (start < end) {
  2602. const middle = start + end >>> 1;
  2603. const middleJob = queue[middle];
  2604. const middleJobId = getId(middleJob);
  2605. if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
  2606. start = middle + 1;
  2607. } else {
  2608. end = middle;
  2609. }
  2610. }
  2611. return start;
  2612. }
  2613. function queueJob(job) {
  2614. if (!(job.flags & 1)) {
  2615. const jobId = getId(job);
  2616. const lastJob = queue[queue.length - 1];
  2617. if (!lastJob || // fast path when the job id is larger than the tail
  2618. !(job.flags & 2) && jobId >= getId(lastJob)) {
  2619. queue.push(job);
  2620. } else {
  2621. queue.splice(findInsertionIndex(jobId), 0, job);
  2622. }
  2623. job.flags |= 1;
  2624. queueFlush();
  2625. }
  2626. }
  2627. function queueFlush() {
  2628. if (!currentFlushPromise) {
  2629. currentFlushPromise = resolvedPromise.then(flushJobs);
  2630. }
  2631. }
  2632. function queuePostFlushCb(cb) {
  2633. if (!isArray(cb)) {
  2634. if (activePostFlushCbs && cb.id === -1) {
  2635. activePostFlushCbs.splice(postFlushIndex + 1, 0, cb);
  2636. } else if (!(cb.flags & 1)) {
  2637. pendingPostFlushCbs.push(cb);
  2638. cb.flags |= 1;
  2639. }
  2640. } else {
  2641. pendingPostFlushCbs.push(...cb);
  2642. }
  2643. queueFlush();
  2644. }
  2645. function flushPreFlushCbs(instance, seen, i = flushIndex + 1) {
  2646. {
  2647. seen = seen || /* @__PURE__ */ new Map();
  2648. }
  2649. for (; i < queue.length; i++) {
  2650. const cb = queue[i];
  2651. if (cb && cb.flags & 2) {
  2652. if (instance && cb.id !== instance.uid) {
  2653. continue;
  2654. }
  2655. if (checkRecursiveUpdates(seen, cb)) {
  2656. continue;
  2657. }
  2658. queue.splice(i, 1);
  2659. i--;
  2660. if (cb.flags & 4) {
  2661. cb.flags &= -2;
  2662. }
  2663. cb();
  2664. if (!(cb.flags & 4)) {
  2665. cb.flags &= -2;
  2666. }
  2667. }
  2668. }
  2669. }
  2670. function flushPostFlushCbs(seen) {
  2671. if (pendingPostFlushCbs.length) {
  2672. const deduped = [...new Set(pendingPostFlushCbs)].sort(
  2673. (a, b) => getId(a) - getId(b)
  2674. );
  2675. pendingPostFlushCbs.length = 0;
  2676. if (activePostFlushCbs) {
  2677. activePostFlushCbs.push(...deduped);
  2678. return;
  2679. }
  2680. activePostFlushCbs = deduped;
  2681. {
  2682. seen = seen || /* @__PURE__ */ new Map();
  2683. }
  2684. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  2685. const cb = activePostFlushCbs[postFlushIndex];
  2686. if (checkRecursiveUpdates(seen, cb)) {
  2687. continue;
  2688. }
  2689. if (cb.flags & 4) {
  2690. cb.flags &= -2;
  2691. }
  2692. if (!(cb.flags & 8)) cb();
  2693. cb.flags &= -2;
  2694. }
  2695. activePostFlushCbs = null;
  2696. postFlushIndex = 0;
  2697. }
  2698. }
  2699. const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
  2700. function flushJobs(seen) {
  2701. {
  2702. seen = seen || /* @__PURE__ */ new Map();
  2703. }
  2704. const check = (job) => checkRecursiveUpdates(seen, job) ;
  2705. try {
  2706. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  2707. const job = queue[flushIndex];
  2708. if (job && !(job.flags & 8)) {
  2709. if (check(job)) {
  2710. continue;
  2711. }
  2712. if (job.flags & 4) {
  2713. job.flags &= ~1;
  2714. }
  2715. callWithErrorHandling(
  2716. job,
  2717. job.i,
  2718. job.i ? 15 : 14
  2719. );
  2720. if (!(job.flags & 4)) {
  2721. job.flags &= ~1;
  2722. }
  2723. }
  2724. }
  2725. } finally {
  2726. for (; flushIndex < queue.length; flushIndex++) {
  2727. const job = queue[flushIndex];
  2728. if (job) {
  2729. job.flags &= -2;
  2730. }
  2731. }
  2732. flushIndex = -1;
  2733. queue.length = 0;
  2734. flushPostFlushCbs(seen);
  2735. currentFlushPromise = null;
  2736. if (queue.length || pendingPostFlushCbs.length) {
  2737. flushJobs(seen);
  2738. }
  2739. }
  2740. }
  2741. function checkRecursiveUpdates(seen, fn) {
  2742. const count = seen.get(fn) || 0;
  2743. if (count > RECURSION_LIMIT) {
  2744. const instance = fn.i;
  2745. const componentName = instance && getComponentName(instance.type);
  2746. handleError(
  2747. `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.`,
  2748. null,
  2749. 10
  2750. );
  2751. return true;
  2752. }
  2753. seen.set(fn, count + 1);
  2754. return false;
  2755. }
  2756. let isHmrUpdating = false;
  2757. const setHmrUpdating = (v) => {
  2758. try {
  2759. return isHmrUpdating;
  2760. } finally {
  2761. isHmrUpdating = v;
  2762. }
  2763. };
  2764. const hmrDirtyComponents = /* @__PURE__ */ new Map();
  2765. {
  2766. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  2767. createRecord: tryWrap(createRecord),
  2768. rerender: tryWrap(rerender),
  2769. reload: tryWrap(reload)
  2770. };
  2771. }
  2772. const map = /* @__PURE__ */ new Map();
  2773. function registerHMR(instance) {
  2774. const id = instance.type.__hmrId;
  2775. let record = map.get(id);
  2776. if (!record) {
  2777. createRecord(id, instance.type);
  2778. record = map.get(id);
  2779. }
  2780. record.instances.add(instance);
  2781. }
  2782. function unregisterHMR(instance) {
  2783. map.get(instance.type.__hmrId).instances.delete(instance);
  2784. }
  2785. function createRecord(id, initialDef) {
  2786. if (map.has(id)) {
  2787. return false;
  2788. }
  2789. map.set(id, {
  2790. initialDef: normalizeClassComponent(initialDef),
  2791. instances: /* @__PURE__ */ new Set()
  2792. });
  2793. return true;
  2794. }
  2795. function normalizeClassComponent(component) {
  2796. return isClassComponent(component) ? component.__vccOpts : component;
  2797. }
  2798. function rerender(id, newRender) {
  2799. const record = map.get(id);
  2800. if (!record) {
  2801. return;
  2802. }
  2803. record.initialDef.render = newRender;
  2804. [...record.instances].forEach((instance) => {
  2805. if (newRender) {
  2806. instance.render = newRender;
  2807. normalizeClassComponent(instance.type).render = newRender;
  2808. }
  2809. instance.renderCache = [];
  2810. isHmrUpdating = true;
  2811. if (!(instance.job.flags & 8)) {
  2812. instance.update();
  2813. }
  2814. isHmrUpdating = false;
  2815. });
  2816. }
  2817. function reload(id, newComp) {
  2818. const record = map.get(id);
  2819. if (!record) return;
  2820. newComp = normalizeClassComponent(newComp);
  2821. updateComponentDef(record.initialDef, newComp);
  2822. const instances = [...record.instances];
  2823. for (let i = 0; i < instances.length; i++) {
  2824. const instance = instances[i];
  2825. const oldComp = normalizeClassComponent(instance.type);
  2826. let dirtyInstances = hmrDirtyComponents.get(oldComp);
  2827. if (!dirtyInstances) {
  2828. if (oldComp !== record.initialDef) {
  2829. updateComponentDef(oldComp, newComp);
  2830. }
  2831. hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
  2832. }
  2833. dirtyInstances.add(instance);
  2834. instance.appContext.propsCache.delete(instance.type);
  2835. instance.appContext.emitsCache.delete(instance.type);
  2836. instance.appContext.optionsCache.delete(instance.type);
  2837. if (instance.ceReload) {
  2838. dirtyInstances.add(instance);
  2839. instance.ceReload(newComp.styles);
  2840. dirtyInstances.delete(instance);
  2841. } else if (instance.parent) {
  2842. queueJob(() => {
  2843. if (!(instance.job.flags & 8)) {
  2844. isHmrUpdating = true;
  2845. instance.parent.update();
  2846. isHmrUpdating = false;
  2847. dirtyInstances.delete(instance);
  2848. }
  2849. });
  2850. } else if (instance.appContext.reload) {
  2851. instance.appContext.reload();
  2852. } else if (typeof window !== "undefined") {
  2853. window.location.reload();
  2854. } else {
  2855. console.warn(
  2856. "[HMR] Root or manually mounted instance modified. Full reload required."
  2857. );
  2858. }
  2859. if (instance.root.ce && instance !== instance.root) {
  2860. instance.root.ce._removeChildStyle(oldComp);
  2861. }
  2862. }
  2863. queuePostFlushCb(() => {
  2864. hmrDirtyComponents.clear();
  2865. });
  2866. }
  2867. function updateComponentDef(oldComp, newComp) {
  2868. extend(oldComp, newComp);
  2869. for (const key in oldComp) {
  2870. if (key !== "__file" && !(key in newComp)) {
  2871. delete oldComp[key];
  2872. }
  2873. }
  2874. }
  2875. function tryWrap(fn) {
  2876. return (id, arg) => {
  2877. try {
  2878. return fn(id, arg);
  2879. } catch (e) {
  2880. console.error(e);
  2881. console.warn(
  2882. `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
  2883. );
  2884. }
  2885. };
  2886. }
  2887. let devtools$1;
  2888. let buffer = [];
  2889. let devtoolsNotInstalled = false;
  2890. function emit$1(event, ...args) {
  2891. if (devtools$1) {
  2892. devtools$1.emit(event, ...args);
  2893. } else if (!devtoolsNotInstalled) {
  2894. buffer.push({ event, args });
  2895. }
  2896. }
  2897. function setDevtoolsHook$1(hook, target) {
  2898. var _a, _b;
  2899. devtools$1 = hook;
  2900. if (devtools$1) {
  2901. devtools$1.enabled = true;
  2902. buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
  2903. buffer = [];
  2904. } else if (
  2905. // handle late devtools injection - only do this if we are in an actual
  2906. // browser environment to avoid the timer handle stalling test runner exit
  2907. // (#4815)
  2908. typeof window !== "undefined" && // some envs mock window but not fully
  2909. window.HTMLElement && // also exclude jsdom
  2910. // eslint-disable-next-line no-restricted-syntax
  2911. !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
  2912. ) {
  2913. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
  2914. replay.push((newHook) => {
  2915. setDevtoolsHook$1(newHook, target);
  2916. });
  2917. setTimeout(() => {
  2918. if (!devtools$1) {
  2919. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2920. devtoolsNotInstalled = true;
  2921. buffer = [];
  2922. }
  2923. }, 3e3);
  2924. } else {
  2925. devtoolsNotInstalled = true;
  2926. buffer = [];
  2927. }
  2928. }
  2929. function devtoolsInitApp(app, version) {
  2930. emit$1("app:init" /* APP_INIT */, app, version, {
  2931. Fragment,
  2932. Text,
  2933. Comment,
  2934. Static
  2935. });
  2936. }
  2937. function devtoolsUnmountApp(app) {
  2938. emit$1("app:unmount" /* APP_UNMOUNT */, app);
  2939. }
  2940. const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  2941. const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2942. const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
  2943. "component:removed" /* COMPONENT_REMOVED */
  2944. );
  2945. const devtoolsComponentRemoved = (component) => {
  2946. if (devtools$1 && typeof devtools$1.cleanupBuffer === "function" && // remove the component if it wasn't buffered
  2947. !devtools$1.cleanupBuffer(component)) {
  2948. _devtoolsComponentRemoved(component);
  2949. }
  2950. };
  2951. // @__NO_SIDE_EFFECTS__
  2952. function createDevtoolsComponentHook(hook) {
  2953. return (component) => {
  2954. emit$1(
  2955. hook,
  2956. component.appContext.app,
  2957. component.uid,
  2958. component.parent ? component.parent.uid : void 0,
  2959. component
  2960. );
  2961. };
  2962. }
  2963. const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
  2964. const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
  2965. function createDevtoolsPerformanceHook(hook) {
  2966. return (component, type, time) => {
  2967. emit$1(hook, component.appContext.app, component.uid, component, type, time);
  2968. };
  2969. }
  2970. function devtoolsComponentEmit(component, event, params) {
  2971. emit$1(
  2972. "component:emit" /* COMPONENT_EMIT */,
  2973. component.appContext.app,
  2974. component,
  2975. event,
  2976. params
  2977. );
  2978. }
  2979. let currentRenderingInstance = null;
  2980. let currentScopeId = null;
  2981. function setCurrentRenderingInstance(instance) {
  2982. const prev = currentRenderingInstance;
  2983. currentRenderingInstance = instance;
  2984. currentScopeId = instance && instance.type.__scopeId || null;
  2985. return prev;
  2986. }
  2987. function pushScopeId(id) {
  2988. currentScopeId = id;
  2989. }
  2990. function popScopeId() {
  2991. currentScopeId = null;
  2992. }
  2993. const withScopeId = (_id) => withCtx;
  2994. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
  2995. if (!ctx) return fn;
  2996. if (fn._n) {
  2997. return fn;
  2998. }
  2999. const renderFnWithContext = (...args) => {
  3000. if (renderFnWithContext._d) {
  3001. setBlockTracking(-1);
  3002. }
  3003. const prevInstance = setCurrentRenderingInstance(ctx);
  3004. let res;
  3005. try {
  3006. res = fn(...args);
  3007. } finally {
  3008. setCurrentRenderingInstance(prevInstance);
  3009. if (renderFnWithContext._d) {
  3010. setBlockTracking(1);
  3011. }
  3012. }
  3013. {
  3014. devtoolsComponentUpdated(ctx);
  3015. }
  3016. return res;
  3017. };
  3018. renderFnWithContext._n = true;
  3019. renderFnWithContext._c = true;
  3020. renderFnWithContext._d = true;
  3021. return renderFnWithContext;
  3022. }
  3023. function validateDirectiveName(name) {
  3024. if (isBuiltInDirective(name)) {
  3025. warn$1("Do not use built-in directive ids as custom directive id: " + name);
  3026. }
  3027. }
  3028. function withDirectives(vnode, directives) {
  3029. if (currentRenderingInstance === null) {
  3030. warn$1(`withDirectives can only be used inside render functions.`);
  3031. return vnode;
  3032. }
  3033. const instance = getComponentPublicInstance(currentRenderingInstance);
  3034. const bindings = vnode.dirs || (vnode.dirs = []);
  3035. for (let i = 0; i < directives.length; i++) {
  3036. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  3037. if (dir) {
  3038. if (isFunction(dir)) {
  3039. dir = {
  3040. mounted: dir,
  3041. updated: dir
  3042. };
  3043. }
  3044. if (dir.deep) {
  3045. traverse(value);
  3046. }
  3047. bindings.push({
  3048. dir,
  3049. instance,
  3050. value,
  3051. oldValue: void 0,
  3052. arg,
  3053. modifiers
  3054. });
  3055. }
  3056. }
  3057. return vnode;
  3058. }
  3059. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  3060. const bindings = vnode.dirs;
  3061. const oldBindings = prevVNode && prevVNode.dirs;
  3062. for (let i = 0; i < bindings.length; i++) {
  3063. const binding = bindings[i];
  3064. if (oldBindings) {
  3065. binding.oldValue = oldBindings[i].value;
  3066. }
  3067. let hook = binding.dir[name];
  3068. if (hook) {
  3069. pauseTracking();
  3070. callWithAsyncErrorHandling(hook, instance, 8, [
  3071. vnode.el,
  3072. binding,
  3073. vnode,
  3074. prevVNode
  3075. ]);
  3076. resetTracking();
  3077. }
  3078. }
  3079. }
  3080. function provide(key, value) {
  3081. {
  3082. if (!currentInstance || currentInstance.isMounted) {
  3083. warn$1(`provide() can only be used inside setup().`);
  3084. }
  3085. }
  3086. if (currentInstance) {
  3087. let provides = currentInstance.provides;
  3088. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  3089. if (parentProvides === provides) {
  3090. provides = currentInstance.provides = Object.create(parentProvides);
  3091. }
  3092. provides[key] = value;
  3093. }
  3094. }
  3095. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3096. const instance = getCurrentInstance();
  3097. if (instance || currentApp) {
  3098. let provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null || instance.ce ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
  3099. if (provides && key in provides) {
  3100. return provides[key];
  3101. } else if (arguments.length > 1) {
  3102. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
  3103. } else {
  3104. warn$1(`injection "${String(key)}" not found.`);
  3105. }
  3106. } else {
  3107. warn$1(`inject() can only be used inside setup() or functional components.`);
  3108. }
  3109. }
  3110. function hasInjectionContext() {
  3111. return !!(getCurrentInstance() || currentApp);
  3112. }
  3113. const ssrContextKey = /* @__PURE__ */ Symbol.for("v-scx");
  3114. const useSSRContext = () => {
  3115. {
  3116. const ctx = inject(ssrContextKey);
  3117. if (!ctx) {
  3118. warn$1(
  3119. `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
  3120. );
  3121. }
  3122. return ctx;
  3123. }
  3124. };
  3125. function watchEffect(effect, options) {
  3126. return doWatch(effect, null, options);
  3127. }
  3128. function watchPostEffect(effect, options) {
  3129. return doWatch(
  3130. effect,
  3131. null,
  3132. extend({}, options, { flush: "post" })
  3133. );
  3134. }
  3135. function watchSyncEffect(effect, options) {
  3136. return doWatch(
  3137. effect,
  3138. null,
  3139. extend({}, options, { flush: "sync" })
  3140. );
  3141. }
  3142. function watch(source, cb, options) {
  3143. if (!isFunction(cb)) {
  3144. warn$1(
  3145. `\`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.`
  3146. );
  3147. }
  3148. return doWatch(source, cb, options);
  3149. }
  3150. function doWatch(source, cb, options = EMPTY_OBJ) {
  3151. const { immediate, deep, flush, once } = options;
  3152. if (!cb) {
  3153. if (immediate !== void 0) {
  3154. warn$1(
  3155. `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
  3156. );
  3157. }
  3158. if (deep !== void 0) {
  3159. warn$1(
  3160. `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
  3161. );
  3162. }
  3163. if (once !== void 0) {
  3164. warn$1(
  3165. `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
  3166. );
  3167. }
  3168. }
  3169. const baseWatchOptions = extend({}, options);
  3170. baseWatchOptions.onWarn = warn$1;
  3171. const runsImmediately = cb && immediate || !cb && flush !== "post";
  3172. let ssrCleanup;
  3173. if (isInSSRComponentSetup) {
  3174. if (flush === "sync") {
  3175. const ctx = useSSRContext();
  3176. ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
  3177. } else if (!runsImmediately) {
  3178. const watchStopHandle = () => {
  3179. };
  3180. watchStopHandle.stop = NOOP;
  3181. watchStopHandle.resume = NOOP;
  3182. watchStopHandle.pause = NOOP;
  3183. return watchStopHandle;
  3184. }
  3185. }
  3186. const instance = currentInstance;
  3187. baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
  3188. let isPre = false;
  3189. if (flush === "post") {
  3190. baseWatchOptions.scheduler = (job) => {
  3191. queuePostRenderEffect(job, instance && instance.suspense);
  3192. };
  3193. } else if (flush !== "sync") {
  3194. isPre = true;
  3195. baseWatchOptions.scheduler = (job, isFirstRun) => {
  3196. if (isFirstRun) {
  3197. job();
  3198. } else {
  3199. queueJob(job);
  3200. }
  3201. };
  3202. }
  3203. baseWatchOptions.augmentJob = (job) => {
  3204. if (cb) {
  3205. job.flags |= 4;
  3206. }
  3207. if (isPre) {
  3208. job.flags |= 2;
  3209. if (instance) {
  3210. job.id = instance.uid;
  3211. job.i = instance;
  3212. }
  3213. }
  3214. };
  3215. const watchHandle = watch$1(source, cb, baseWatchOptions);
  3216. if (isInSSRComponentSetup) {
  3217. if (ssrCleanup) {
  3218. ssrCleanup.push(watchHandle);
  3219. } else if (runsImmediately) {
  3220. watchHandle();
  3221. }
  3222. }
  3223. return watchHandle;
  3224. }
  3225. function instanceWatch(source, value, options) {
  3226. const publicThis = this.proxy;
  3227. const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
  3228. let cb;
  3229. if (isFunction(value)) {
  3230. cb = value;
  3231. } else {
  3232. cb = value.handler;
  3233. options = value;
  3234. }
  3235. const reset = setCurrentInstance(this);
  3236. const res = doWatch(getter, cb.bind(publicThis), options);
  3237. reset();
  3238. return res;
  3239. }
  3240. function createPathGetter(ctx, path) {
  3241. const segments = path.split(".");
  3242. return () => {
  3243. let cur = ctx;
  3244. for (let i = 0; i < segments.length && cur; i++) {
  3245. cur = cur[segments[i]];
  3246. }
  3247. return cur;
  3248. };
  3249. }
  3250. const pendingMounts = /* @__PURE__ */ new WeakMap();
  3251. const TeleportEndKey = /* @__PURE__ */ Symbol("_vte");
  3252. const isTeleport = (type) => type.__isTeleport;
  3253. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
  3254. const isTeleportDeferred = (props) => props && (props.defer || props.defer === "");
  3255. const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
  3256. const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
  3257. const resolveTarget = (props, select) => {
  3258. const targetSelector = props && props.to;
  3259. if (isString(targetSelector)) {
  3260. if (!select) {
  3261. warn$1(
  3262. `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
  3263. );
  3264. return null;
  3265. } else {
  3266. const target = select(targetSelector);
  3267. if (!target && !isTeleportDisabled(props)) {
  3268. warn$1(
  3269. `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.`
  3270. );
  3271. }
  3272. return target;
  3273. }
  3274. } else {
  3275. if (!targetSelector && !isTeleportDisabled(props)) {
  3276. warn$1(`Invalid Teleport target: ${targetSelector}`);
  3277. }
  3278. return targetSelector;
  3279. }
  3280. };
  3281. const TeleportImpl = {
  3282. name: "Teleport",
  3283. __isTeleport: true,
  3284. process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
  3285. const {
  3286. mc: mountChildren,
  3287. pc: patchChildren,
  3288. pbc: patchBlockChildren,
  3289. o: { insert, querySelector, createText, createComment, parentNode }
  3290. } = internals;
  3291. const disabled = isTeleportDisabled(n2.props);
  3292. let { dynamicChildren } = n2;
  3293. if (isHmrUpdating) {
  3294. optimized = false;
  3295. dynamicChildren = null;
  3296. }
  3297. const mount = (vnode, container2, anchor2) => {
  3298. if (vnode.shapeFlag & 16) {
  3299. mountChildren(
  3300. vnode.children,
  3301. container2,
  3302. anchor2,
  3303. parentComponent,
  3304. parentSuspense,
  3305. namespace,
  3306. slotScopeIds,
  3307. optimized
  3308. );
  3309. }
  3310. };
  3311. const mountToTarget = (vnode = n2) => {
  3312. const disabled2 = isTeleportDisabled(vnode.props);
  3313. const target = vnode.target = resolveTarget(vnode.props, querySelector);
  3314. const targetAnchor = prepareAnchor(target, vnode, createText, insert);
  3315. if (target) {
  3316. if (namespace !== "svg" && isTargetSVG(target)) {
  3317. namespace = "svg";
  3318. } else if (namespace !== "mathml" && isTargetMathML(target)) {
  3319. namespace = "mathml";
  3320. }
  3321. if (parentComponent && parentComponent.isCE) {
  3322. (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
  3323. }
  3324. if (!disabled2) {
  3325. mount(vnode, target, targetAnchor);
  3326. updateCssVars(vnode, false);
  3327. }
  3328. } else if (!disabled2) {
  3329. warn$1("Invalid Teleport target on mount:", target, `(${typeof target})`);
  3330. }
  3331. };
  3332. const queuePendingMount = (vnode) => {
  3333. const mountJob = () => {
  3334. if (pendingMounts.get(vnode) !== mountJob) return;
  3335. pendingMounts.delete(vnode);
  3336. if (isTeleportDisabled(vnode.props)) {
  3337. const mountContainer = parentNode(vnode.el) || container;
  3338. mount(vnode, mountContainer, vnode.anchor);
  3339. updateCssVars(vnode, true);
  3340. }
  3341. mountToTarget(vnode);
  3342. };
  3343. pendingMounts.set(vnode, mountJob);
  3344. queuePostRenderEffect(mountJob, parentSuspense);
  3345. };
  3346. if (n1 == null) {
  3347. const placeholder = n2.el = createComment("teleport start") ;
  3348. const mainAnchor = n2.anchor = createComment("teleport end") ;
  3349. insert(placeholder, container, anchor);
  3350. insert(mainAnchor, container, anchor);
  3351. if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) {
  3352. queuePendingMount(n2);
  3353. return;
  3354. }
  3355. if (disabled) {
  3356. mount(n2, container, mainAnchor);
  3357. updateCssVars(n2, true);
  3358. }
  3359. mountToTarget();
  3360. } else {
  3361. n2.el = n1.el;
  3362. const mainAnchor = n2.anchor = n1.anchor;
  3363. const pendingMount = pendingMounts.get(n1);
  3364. if (pendingMount) {
  3365. pendingMount.flags |= 8;
  3366. pendingMounts.delete(n1);
  3367. queuePendingMount(n2);
  3368. return;
  3369. }
  3370. n2.targetStart = n1.targetStart;
  3371. const target = n2.target = n1.target;
  3372. const targetAnchor = n2.targetAnchor = n1.targetAnchor;
  3373. const wasDisabled = isTeleportDisabled(n1.props);
  3374. const currentContainer = wasDisabled ? container : target;
  3375. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  3376. if (namespace === "svg" || isTargetSVG(target)) {
  3377. namespace = "svg";
  3378. } else if (namespace === "mathml" || isTargetMathML(target)) {
  3379. namespace = "mathml";
  3380. }
  3381. if (dynamicChildren) {
  3382. patchBlockChildren(
  3383. n1.dynamicChildren,
  3384. dynamicChildren,
  3385. currentContainer,
  3386. parentComponent,
  3387. parentSuspense,
  3388. namespace,
  3389. slotScopeIds
  3390. );
  3391. traverseStaticChildren(n1, n2, false);
  3392. } else if (!optimized) {
  3393. patchChildren(
  3394. n1,
  3395. n2,
  3396. currentContainer,
  3397. currentAnchor,
  3398. parentComponent,
  3399. parentSuspense,
  3400. namespace,
  3401. slotScopeIds,
  3402. false
  3403. );
  3404. }
  3405. if (disabled) {
  3406. if (!wasDisabled) {
  3407. moveTeleport(
  3408. n2,
  3409. container,
  3410. mainAnchor,
  3411. internals,
  3412. 1
  3413. );
  3414. } else {
  3415. if (n2.props && n1.props && n2.props.to !== n1.props.to) {
  3416. n2.props.to = n1.props.to;
  3417. }
  3418. }
  3419. } else {
  3420. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  3421. const nextTarget = n2.target = resolveTarget(
  3422. n2.props,
  3423. querySelector
  3424. );
  3425. if (nextTarget) {
  3426. moveTeleport(
  3427. n2,
  3428. nextTarget,
  3429. null,
  3430. internals,
  3431. 0
  3432. );
  3433. } else {
  3434. warn$1(
  3435. "Invalid Teleport target on update:",
  3436. target,
  3437. `(${typeof target})`
  3438. );
  3439. }
  3440. } else if (wasDisabled) {
  3441. moveTeleport(
  3442. n2,
  3443. target,
  3444. targetAnchor,
  3445. internals,
  3446. 1
  3447. );
  3448. }
  3449. }
  3450. updateCssVars(n2, disabled);
  3451. }
  3452. },
  3453. remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  3454. const {
  3455. shapeFlag,
  3456. children,
  3457. anchor,
  3458. targetStart,
  3459. targetAnchor,
  3460. target,
  3461. props
  3462. } = vnode;
  3463. const shouldRemove = doRemove || !isTeleportDisabled(props);
  3464. const pendingMount = pendingMounts.get(vnode);
  3465. if (pendingMount) {
  3466. pendingMount.flags |= 8;
  3467. pendingMounts.delete(vnode);
  3468. }
  3469. if (target) {
  3470. hostRemove(targetStart);
  3471. hostRemove(targetAnchor);
  3472. }
  3473. doRemove && hostRemove(anchor);
  3474. if (!pendingMount && shapeFlag & 16) {
  3475. for (let i = 0; i < children.length; i++) {
  3476. const child = children[i];
  3477. unmount(
  3478. child,
  3479. parentComponent,
  3480. parentSuspense,
  3481. shouldRemove,
  3482. !!child.dynamicChildren
  3483. );
  3484. }
  3485. }
  3486. },
  3487. move: moveTeleport,
  3488. hydrate: hydrateTeleport
  3489. };
  3490. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
  3491. if (moveType === 0) {
  3492. insert(vnode.targetAnchor, container, parentAnchor);
  3493. }
  3494. const { el, anchor, shapeFlag, children, props } = vnode;
  3495. const isReorder = moveType === 2;
  3496. if (isReorder) {
  3497. insert(el, container, parentAnchor);
  3498. }
  3499. if (!pendingMounts.has(vnode) && (!isReorder || isTeleportDisabled(props))) {
  3500. if (shapeFlag & 16) {
  3501. for (let i = 0; i < children.length; i++) {
  3502. move(
  3503. children[i],
  3504. container,
  3505. parentAnchor,
  3506. 2
  3507. );
  3508. }
  3509. }
  3510. }
  3511. if (isReorder) {
  3512. insert(anchor, container, parentAnchor);
  3513. }
  3514. }
  3515. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
  3516. o: { nextSibling, parentNode, querySelector, insert, createText }
  3517. }, hydrateChildren) {
  3518. function hydrateAnchor(target2, targetNode) {
  3519. let targetAnchor = targetNode;
  3520. while (targetAnchor) {
  3521. if (targetAnchor && targetAnchor.nodeType === 8) {
  3522. if (targetAnchor.data === "teleport start anchor") {
  3523. vnode.targetStart = targetAnchor;
  3524. } else if (targetAnchor.data === "teleport anchor") {
  3525. vnode.targetAnchor = targetAnchor;
  3526. target2._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  3527. break;
  3528. }
  3529. }
  3530. targetAnchor = nextSibling(targetAnchor);
  3531. }
  3532. }
  3533. function hydrateDisabledTeleport(node2, vnode2) {
  3534. vnode2.anchor = hydrateChildren(
  3535. nextSibling(node2),
  3536. vnode2,
  3537. parentNode(node2),
  3538. parentComponent,
  3539. parentSuspense,
  3540. slotScopeIds,
  3541. optimized
  3542. );
  3543. }
  3544. const target = vnode.target = resolveTarget(
  3545. vnode.props,
  3546. querySelector
  3547. );
  3548. const disabled = isTeleportDisabled(vnode.props);
  3549. if (target) {
  3550. const targetNode = target._lpa || target.firstChild;
  3551. if (vnode.shapeFlag & 16) {
  3552. if (disabled) {
  3553. hydrateDisabledTeleport(node, vnode);
  3554. hydrateAnchor(target, targetNode);
  3555. if (!vnode.targetAnchor) {
  3556. prepareAnchor(
  3557. target,
  3558. vnode,
  3559. createText,
  3560. insert,
  3561. // if target is the same as the main view, insert anchors before current node
  3562. // to avoid hydrating mismatch
  3563. parentNode(node) === target ? node : null
  3564. );
  3565. }
  3566. } else {
  3567. vnode.anchor = nextSibling(node);
  3568. hydrateAnchor(target, targetNode);
  3569. if (!vnode.targetAnchor) {
  3570. prepareAnchor(target, vnode, createText, insert);
  3571. }
  3572. hydrateChildren(
  3573. targetNode && nextSibling(targetNode),
  3574. vnode,
  3575. target,
  3576. parentComponent,
  3577. parentSuspense,
  3578. slotScopeIds,
  3579. optimized
  3580. );
  3581. }
  3582. }
  3583. updateCssVars(vnode, disabled);
  3584. } else if (disabled) {
  3585. if (vnode.shapeFlag & 16) {
  3586. hydrateDisabledTeleport(node, vnode);
  3587. vnode.targetStart = node;
  3588. vnode.targetAnchor = nextSibling(node);
  3589. }
  3590. }
  3591. return vnode.anchor && nextSibling(vnode.anchor);
  3592. }
  3593. const Teleport = TeleportImpl;
  3594. function updateCssVars(vnode, isDisabled) {
  3595. const ctx = vnode.ctx;
  3596. if (ctx && ctx.ut) {
  3597. let node, anchor;
  3598. if (isDisabled) {
  3599. node = vnode.el;
  3600. anchor = vnode.anchor;
  3601. } else {
  3602. node = vnode.targetStart;
  3603. anchor = vnode.targetAnchor;
  3604. }
  3605. while (node && node !== anchor) {
  3606. if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
  3607. node = node.nextSibling;
  3608. }
  3609. ctx.ut();
  3610. }
  3611. }
  3612. function prepareAnchor(target, vnode, createText, insert, anchor = null) {
  3613. const targetStart = vnode.targetStart = createText("");
  3614. const targetAnchor = vnode.targetAnchor = createText("");
  3615. targetStart[TeleportEndKey] = targetAnchor;
  3616. if (target) {
  3617. insert(targetStart, target, anchor);
  3618. insert(targetAnchor, target, anchor);
  3619. }
  3620. return targetAnchor;
  3621. }
  3622. const leaveCbKey = /* @__PURE__ */ Symbol("_leaveCb");
  3623. const enterCbKey$1 = /* @__PURE__ */ Symbol("_enterCb");
  3624. function useTransitionState() {
  3625. const state = {
  3626. isMounted: false,
  3627. isLeaving: false,
  3628. isUnmounting: false,
  3629. leavingVNodes: /* @__PURE__ */ new Map()
  3630. };
  3631. onMounted(() => {
  3632. state.isMounted = true;
  3633. });
  3634. onBeforeUnmount(() => {
  3635. state.isUnmounting = true;
  3636. });
  3637. return state;
  3638. }
  3639. const TransitionHookValidator = [Function, Array];
  3640. const BaseTransitionPropsValidators = {
  3641. mode: String,
  3642. appear: Boolean,
  3643. persisted: Boolean,
  3644. // enter
  3645. onBeforeEnter: TransitionHookValidator,
  3646. onEnter: TransitionHookValidator,
  3647. onAfterEnter: TransitionHookValidator,
  3648. onEnterCancelled: TransitionHookValidator,
  3649. // leave
  3650. onBeforeLeave: TransitionHookValidator,
  3651. onLeave: TransitionHookValidator,
  3652. onAfterLeave: TransitionHookValidator,
  3653. onLeaveCancelled: TransitionHookValidator,
  3654. // appear
  3655. onBeforeAppear: TransitionHookValidator,
  3656. onAppear: TransitionHookValidator,
  3657. onAfterAppear: TransitionHookValidator,
  3658. onAppearCancelled: TransitionHookValidator
  3659. };
  3660. const recursiveGetSubtree = (instance) => {
  3661. const subTree = instance.subTree;
  3662. return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
  3663. };
  3664. const BaseTransitionImpl = {
  3665. name: `BaseTransition`,
  3666. props: BaseTransitionPropsValidators,
  3667. setup(props, { slots }) {
  3668. const instance = getCurrentInstance();
  3669. const state = useTransitionState();
  3670. return () => {
  3671. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3672. const child = children && children.length ? findNonCommentChild(children) : (
  3673. // Keep explicit default-slot conditionals on the same transition path
  3674. // as regular v-if branches, which render a comment placeholder.
  3675. instance.subTree ? createCommentVNode() : void 0
  3676. );
  3677. if (!child) {
  3678. return;
  3679. }
  3680. const rawProps = toRaw(props);
  3681. const { mode } = rawProps;
  3682. if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
  3683. warn$1(`invalid <transition> mode: ${mode}`);
  3684. }
  3685. if (state.isLeaving) {
  3686. return emptyPlaceholder(child);
  3687. }
  3688. const innerChild = getInnerChild$1(child);
  3689. if (!innerChild) {
  3690. return emptyPlaceholder(child);
  3691. }
  3692. let enterHooks = resolveTransitionHooks(
  3693. innerChild,
  3694. rawProps,
  3695. state,
  3696. instance,
  3697. // #11061, ensure enterHooks is fresh after clone
  3698. (hooks) => enterHooks = hooks
  3699. );
  3700. if (innerChild.type !== Comment) {
  3701. setTransitionHooks(innerChild, enterHooks);
  3702. }
  3703. let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree);
  3704. if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(oldInnerChild, innerChild) && recursiveGetSubtree(instance).type !== Comment) {
  3705. let leavingHooks = resolveTransitionHooks(
  3706. oldInnerChild,
  3707. rawProps,
  3708. state,
  3709. instance
  3710. );
  3711. setTransitionHooks(oldInnerChild, leavingHooks);
  3712. if (mode === "out-in" && innerChild.type !== Comment) {
  3713. state.isLeaving = true;
  3714. leavingHooks.afterLeave = () => {
  3715. state.isLeaving = false;
  3716. if (!(instance.job.flags & 8)) {
  3717. instance.update();
  3718. }
  3719. delete leavingHooks.afterLeave;
  3720. oldInnerChild = void 0;
  3721. };
  3722. return emptyPlaceholder(child);
  3723. } else if (mode === "in-out" && innerChild.type !== Comment) {
  3724. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3725. const leavingVNodesCache = getLeavingNodesForType(
  3726. state,
  3727. oldInnerChild
  3728. );
  3729. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3730. el[leaveCbKey] = () => {
  3731. earlyRemove();
  3732. el[leaveCbKey] = void 0;
  3733. delete enterHooks.delayedLeave;
  3734. oldInnerChild = void 0;
  3735. };
  3736. enterHooks.delayedLeave = () => {
  3737. delayedLeave();
  3738. delete enterHooks.delayedLeave;
  3739. oldInnerChild = void 0;
  3740. };
  3741. };
  3742. } else {
  3743. oldInnerChild = void 0;
  3744. }
  3745. } else if (oldInnerChild) {
  3746. oldInnerChild = void 0;
  3747. }
  3748. return child;
  3749. };
  3750. }
  3751. };
  3752. function findNonCommentChild(children) {
  3753. let child = children[0];
  3754. if (children.length > 1) {
  3755. let hasFound = false;
  3756. for (const c of children) {
  3757. if (c.type !== Comment) {
  3758. if (hasFound) {
  3759. warn$1(
  3760. "<transition> can only be used on a single element or component. Use <transition-group> for lists."
  3761. );
  3762. break;
  3763. }
  3764. child = c;
  3765. hasFound = true;
  3766. }
  3767. }
  3768. }
  3769. return child;
  3770. }
  3771. const BaseTransition = BaseTransitionImpl;
  3772. function getLeavingNodesForType(state, vnode) {
  3773. const { leavingVNodes } = state;
  3774. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3775. if (!leavingVNodesCache) {
  3776. leavingVNodesCache = /* @__PURE__ */ Object.create(null);
  3777. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3778. }
  3779. return leavingVNodesCache;
  3780. }
  3781. function resolveTransitionHooks(vnode, props, state, instance, postClone) {
  3782. const {
  3783. appear,
  3784. mode,
  3785. persisted = false,
  3786. onBeforeEnter,
  3787. onEnter,
  3788. onAfterEnter,
  3789. onEnterCancelled,
  3790. onBeforeLeave,
  3791. onLeave,
  3792. onAfterLeave,
  3793. onLeaveCancelled,
  3794. onBeforeAppear,
  3795. onAppear,
  3796. onAfterAppear,
  3797. onAppearCancelled
  3798. } = props;
  3799. const key = String(vnode.key);
  3800. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3801. const callHook = (hook, args) => {
  3802. hook && callWithAsyncErrorHandling(
  3803. hook,
  3804. instance,
  3805. 9,
  3806. args
  3807. );
  3808. };
  3809. const callAsyncHook = (hook, args) => {
  3810. const done = args[1];
  3811. callHook(hook, args);
  3812. if (isArray(hook)) {
  3813. if (hook.every((hook2) => hook2.length <= 1)) done();
  3814. } else if (hook.length <= 1) {
  3815. done();
  3816. }
  3817. };
  3818. const hooks = {
  3819. mode,
  3820. persisted,
  3821. beforeEnter(el) {
  3822. let hook = onBeforeEnter;
  3823. if (!state.isMounted) {
  3824. if (appear) {
  3825. hook = onBeforeAppear || onBeforeEnter;
  3826. } else {
  3827. return;
  3828. }
  3829. }
  3830. if (el[leaveCbKey]) {
  3831. el[leaveCbKey](
  3832. true
  3833. /* cancelled */
  3834. );
  3835. }
  3836. const leavingVNode = leavingVNodesCache[key];
  3837. if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
  3838. leavingVNode.el[leaveCbKey]();
  3839. }
  3840. callHook(hook, [el]);
  3841. },
  3842. enter(el) {
  3843. if (!isHmrUpdating && leavingVNodesCache[key] === vnode) return;
  3844. let hook = onEnter;
  3845. let afterHook = onAfterEnter;
  3846. let cancelHook = onEnterCancelled;
  3847. if (!state.isMounted) {
  3848. if (appear) {
  3849. hook = onAppear || onEnter;
  3850. afterHook = onAfterAppear || onAfterEnter;
  3851. cancelHook = onAppearCancelled || onEnterCancelled;
  3852. } else {
  3853. return;
  3854. }
  3855. }
  3856. let called = false;
  3857. el[enterCbKey$1] = (cancelled) => {
  3858. if (called) return;
  3859. called = true;
  3860. if (cancelled) {
  3861. callHook(cancelHook, [el]);
  3862. } else {
  3863. callHook(afterHook, [el]);
  3864. }
  3865. if (hooks.delayedLeave) {
  3866. hooks.delayedLeave();
  3867. }
  3868. el[enterCbKey$1] = void 0;
  3869. };
  3870. const done = el[enterCbKey$1].bind(null, false);
  3871. if (hook) {
  3872. callAsyncHook(hook, [el, done]);
  3873. } else {
  3874. done();
  3875. }
  3876. },
  3877. leave(el, remove) {
  3878. const key2 = String(vnode.key);
  3879. if (el[enterCbKey$1]) {
  3880. el[enterCbKey$1](
  3881. true
  3882. /* cancelled */
  3883. );
  3884. }
  3885. if (state.isUnmounting) {
  3886. return remove();
  3887. }
  3888. callHook(onBeforeLeave, [el]);
  3889. let called = false;
  3890. el[leaveCbKey] = (cancelled) => {
  3891. if (called) return;
  3892. called = true;
  3893. remove();
  3894. if (cancelled) {
  3895. callHook(onLeaveCancelled, [el]);
  3896. } else {
  3897. callHook(onAfterLeave, [el]);
  3898. }
  3899. el[leaveCbKey] = void 0;
  3900. if (leavingVNodesCache[key2] === vnode) {
  3901. delete leavingVNodesCache[key2];
  3902. }
  3903. };
  3904. const done = el[leaveCbKey].bind(null, false);
  3905. leavingVNodesCache[key2] = vnode;
  3906. if (onLeave) {
  3907. callAsyncHook(onLeave, [el, done]);
  3908. } else {
  3909. done();
  3910. }
  3911. },
  3912. clone(vnode2) {
  3913. const hooks2 = resolveTransitionHooks(
  3914. vnode2,
  3915. props,
  3916. state,
  3917. instance,
  3918. postClone
  3919. );
  3920. if (postClone) postClone(hooks2);
  3921. return hooks2;
  3922. }
  3923. };
  3924. return hooks;
  3925. }
  3926. function emptyPlaceholder(vnode) {
  3927. if (isKeepAlive(vnode)) {
  3928. vnode = cloneVNode(vnode);
  3929. vnode.children = null;
  3930. return vnode;
  3931. }
  3932. }
  3933. function getInnerChild$1(vnode) {
  3934. if (!isKeepAlive(vnode)) {
  3935. if (isTeleport(vnode.type) && vnode.children) {
  3936. return findNonCommentChild(vnode.children);
  3937. }
  3938. return vnode;
  3939. }
  3940. if (vnode.component) {
  3941. return vnode.component.subTree;
  3942. }
  3943. const { shapeFlag, children } = vnode;
  3944. if (children) {
  3945. if (shapeFlag & 16) {
  3946. return children[0];
  3947. }
  3948. if (shapeFlag & 32 && isFunction(children.default)) {
  3949. return children.default();
  3950. }
  3951. }
  3952. }
  3953. function setTransitionHooks(vnode, hooks) {
  3954. if (vnode.shapeFlag & 6 && vnode.component) {
  3955. vnode.transition = hooks;
  3956. setTransitionHooks(vnode.component.subTree, hooks);
  3957. } else if (vnode.shapeFlag & 128) {
  3958. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3959. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3960. } else {
  3961. vnode.transition = hooks;
  3962. }
  3963. }
  3964. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3965. let ret = [];
  3966. let keyedFragmentCount = 0;
  3967. for (let i = 0; i < children.length; i++) {
  3968. let child = children[i];
  3969. const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
  3970. if (child.type === Fragment) {
  3971. if (child.patchFlag & 128) keyedFragmentCount++;
  3972. ret = ret.concat(
  3973. getTransitionRawChildren(child.children, keepComment, key)
  3974. );
  3975. } else if (keepComment || child.type !== Comment) {
  3976. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3977. }
  3978. }
  3979. if (keyedFragmentCount > 1) {
  3980. for (let i = 0; i < ret.length; i++) {
  3981. ret[i].patchFlag = -2;
  3982. }
  3983. }
  3984. return ret;
  3985. }
  3986. // @__NO_SIDE_EFFECTS__
  3987. function defineComponent(options, extraOptions) {
  3988. return isFunction(options) ? (
  3989. // #8236: extend call and options.name access are considered side-effects
  3990. // by Rollup, so we have to wrap it in a pure-annotated IIFE.
  3991. /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
  3992. ) : options;
  3993. }
  3994. function useId() {
  3995. const i = getCurrentInstance();
  3996. if (i) {
  3997. return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
  3998. } else {
  3999. warn$1(
  4000. `useId() is called when there is no active component instance to be associated with.`
  4001. );
  4002. }
  4003. return "";
  4004. }
  4005. function markAsyncBoundary(instance) {
  4006. instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
  4007. }
  4008. const knownTemplateRefs = /* @__PURE__ */ new WeakSet();
  4009. function useTemplateRef(key) {
  4010. const i = getCurrentInstance();
  4011. const r = shallowRef(null);
  4012. if (i) {
  4013. const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs;
  4014. if (isTemplateRefKey(refs, key)) {
  4015. warn$1(`useTemplateRef('${key}') already exists.`);
  4016. } else {
  4017. Object.defineProperty(refs, key, {
  4018. enumerable: true,
  4019. get: () => r.value,
  4020. set: (val) => r.value = val
  4021. });
  4022. }
  4023. } else {
  4024. warn$1(
  4025. `useTemplateRef() is called when there is no active component instance to be associated with.`
  4026. );
  4027. }
  4028. const ret = readonly(r) ;
  4029. {
  4030. knownTemplateRefs.add(ret);
  4031. }
  4032. return ret;
  4033. }
  4034. function isTemplateRefKey(refs, key) {
  4035. let desc;
  4036. return !!((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable);
  4037. }
  4038. const pendingSetRefMap = /* @__PURE__ */ new WeakMap();
  4039. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  4040. if (isArray(rawRef)) {
  4041. rawRef.forEach(
  4042. (r, i) => setRef(
  4043. r,
  4044. oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
  4045. parentSuspense,
  4046. vnode,
  4047. isUnmount
  4048. )
  4049. );
  4050. return;
  4051. }
  4052. if (isAsyncWrapper(vnode) && !isUnmount) {
  4053. if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
  4054. setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
  4055. }
  4056. return;
  4057. }
  4058. const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
  4059. const value = isUnmount ? null : refValue;
  4060. const { i: owner, r: ref } = rawRef;
  4061. if (!owner) {
  4062. warn$1(
  4063. `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
  4064. );
  4065. return;
  4066. }
  4067. const oldRef = oldRawRef && oldRawRef.r;
  4068. const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
  4069. const setupState = owner.setupState;
  4070. const rawSetupState = toRaw(setupState);
  4071. const canSetSetupRef = setupState === EMPTY_OBJ ? NO : (key) => {
  4072. {
  4073. if (hasOwn(rawSetupState, key) && !isRef(rawSetupState[key])) {
  4074. warn$1(
  4075. `Template ref "${key}" used on a non-ref value. It will not work in the production build.`
  4076. );
  4077. }
  4078. if (knownTemplateRefs.has(rawSetupState[key])) {
  4079. return false;
  4080. }
  4081. }
  4082. if (isTemplateRefKey(refs, key)) {
  4083. return false;
  4084. }
  4085. return hasOwn(rawSetupState, key);
  4086. };
  4087. const canSetRef = (ref2, key) => {
  4088. if (knownTemplateRefs.has(ref2)) {
  4089. return false;
  4090. }
  4091. if (key && isTemplateRefKey(refs, key)) {
  4092. return false;
  4093. }
  4094. return true;
  4095. };
  4096. if (oldRef != null && oldRef !== ref) {
  4097. invalidatePendingSetRef(oldRawRef);
  4098. if (isString(oldRef)) {
  4099. refs[oldRef] = null;
  4100. if (canSetSetupRef(oldRef)) {
  4101. setupState[oldRef] = null;
  4102. }
  4103. } else if (isRef(oldRef)) {
  4104. const oldRawRefAtom = oldRawRef;
  4105. if (canSetRef(oldRef, oldRawRefAtom.k)) {
  4106. oldRef.value = null;
  4107. }
  4108. if (oldRawRefAtom.k) refs[oldRawRefAtom.k] = null;
  4109. }
  4110. }
  4111. if (isFunction(ref)) {
  4112. callWithErrorHandling(ref, owner, 12, [value, refs]);
  4113. } else {
  4114. const _isString = isString(ref);
  4115. const _isRef = isRef(ref);
  4116. if (_isString || _isRef) {
  4117. const doSet = () => {
  4118. if (rawRef.f) {
  4119. const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : canSetRef(ref) || !rawRef.k ? ref.value : refs[rawRef.k];
  4120. if (isUnmount) {
  4121. isArray(existing) && remove(existing, refValue);
  4122. } else {
  4123. if (!isArray(existing)) {
  4124. if (_isString) {
  4125. refs[ref] = [refValue];
  4126. if (canSetSetupRef(ref)) {
  4127. setupState[ref] = refs[ref];
  4128. }
  4129. } else {
  4130. const newVal = [refValue];
  4131. if (canSetRef(ref, rawRef.k)) {
  4132. ref.value = newVal;
  4133. }
  4134. if (rawRef.k) refs[rawRef.k] = newVal;
  4135. }
  4136. } else if (!existing.includes(refValue)) {
  4137. existing.push(refValue);
  4138. }
  4139. }
  4140. } else if (_isString) {
  4141. refs[ref] = value;
  4142. if (canSetSetupRef(ref)) {
  4143. setupState[ref] = value;
  4144. }
  4145. } else if (_isRef) {
  4146. if (canSetRef(ref, rawRef.k)) {
  4147. ref.value = value;
  4148. }
  4149. if (rawRef.k) refs[rawRef.k] = value;
  4150. } else {
  4151. warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
  4152. }
  4153. };
  4154. if (value) {
  4155. const job = () => {
  4156. doSet();
  4157. pendingSetRefMap.delete(rawRef);
  4158. };
  4159. job.id = -1;
  4160. pendingSetRefMap.set(rawRef, job);
  4161. queuePostRenderEffect(job, parentSuspense);
  4162. } else {
  4163. invalidatePendingSetRef(rawRef);
  4164. doSet();
  4165. }
  4166. } else {
  4167. warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
  4168. }
  4169. }
  4170. }
  4171. function invalidatePendingSetRef(rawRef) {
  4172. const pendingSetRef = pendingSetRefMap.get(rawRef);
  4173. if (pendingSetRef) {
  4174. pendingSetRef.flags |= 8;
  4175. pendingSetRefMap.delete(rawRef);
  4176. }
  4177. }
  4178. let hasLoggedMismatchError = false;
  4179. const logMismatchError = () => {
  4180. if (hasLoggedMismatchError) {
  4181. return;
  4182. }
  4183. console.error("Hydration completed but contains mismatches.");
  4184. hasLoggedMismatchError = true;
  4185. };
  4186. const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
  4187. const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
  4188. const getContainerType = (container) => {
  4189. if (container.nodeType !== 1) return void 0;
  4190. if (isSVGContainer(container)) return "svg";
  4191. if (isMathMLContainer(container)) return "mathml";
  4192. return void 0;
  4193. };
  4194. const isComment = (node) => node.nodeType === 8;
  4195. function createHydrationFunctions(rendererInternals) {
  4196. const {
  4197. mt: mountComponent,
  4198. p: patch,
  4199. o: {
  4200. patchProp,
  4201. createText,
  4202. nextSibling,
  4203. parentNode,
  4204. remove,
  4205. insert,
  4206. createComment
  4207. }
  4208. } = rendererInternals;
  4209. const hydrate = (vnode, container) => {
  4210. if (!container.hasChildNodes()) {
  4211. warn$1(
  4212. `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
  4213. );
  4214. patch(null, vnode, container);
  4215. flushPostFlushCbs();
  4216. container._vnode = vnode;
  4217. return;
  4218. }
  4219. hydrateNode(container.firstChild, vnode, null, null, null);
  4220. flushPostFlushCbs();
  4221. container._vnode = vnode;
  4222. };
  4223. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  4224. optimized = optimized || !!vnode.dynamicChildren;
  4225. const isFragmentStart = isComment(node) && node.data === "[";
  4226. const onMismatch = () => handleMismatch(
  4227. node,
  4228. vnode,
  4229. parentComponent,
  4230. parentSuspense,
  4231. slotScopeIds,
  4232. isFragmentStart
  4233. );
  4234. const { type, ref, shapeFlag, patchFlag } = vnode;
  4235. let domType = node.nodeType;
  4236. vnode.el = node;
  4237. {
  4238. def(node, "__vnode", vnode, true);
  4239. def(node, "__vueParentComponent", parentComponent, true);
  4240. }
  4241. if (patchFlag === -2) {
  4242. optimized = false;
  4243. vnode.dynamicChildren = null;
  4244. }
  4245. let nextNode = null;
  4246. switch (type) {
  4247. case Text:
  4248. if (domType !== 3) {
  4249. if (vnode.children === "") {
  4250. insert(vnode.el = createText(""), parentNode(node), node);
  4251. nextNode = node;
  4252. } else {
  4253. nextNode = onMismatch();
  4254. }
  4255. } else {
  4256. if (node.data !== vnode.children) {
  4257. warn$1(
  4258. `Hydration text mismatch in`,
  4259. node.parentNode,
  4260. `
  4261. - rendered on server: ${JSON.stringify(
  4262. node.data
  4263. )}
  4264. - expected on client: ${JSON.stringify(vnode.children)}`
  4265. );
  4266. logMismatchError();
  4267. node.data = vnode.children;
  4268. }
  4269. nextNode = nextSibling(node);
  4270. }
  4271. break;
  4272. case Comment:
  4273. if (isTemplateNode(node)) {
  4274. nextNode = nextSibling(node);
  4275. replaceNode(
  4276. vnode.el = node.content.firstChild,
  4277. node,
  4278. parentComponent
  4279. );
  4280. } else if (domType !== 8 || isFragmentStart) {
  4281. nextNode = onMismatch();
  4282. } else {
  4283. nextNode = nextSibling(node);
  4284. }
  4285. break;
  4286. case Static:
  4287. if (isFragmentStart) {
  4288. node = nextSibling(node);
  4289. domType = node.nodeType;
  4290. }
  4291. if (domType === 1 || domType === 3) {
  4292. nextNode = node;
  4293. const needToAdoptContent = !vnode.children.length;
  4294. for (let i = 0; i < vnode.staticCount; i++) {
  4295. if (needToAdoptContent)
  4296. vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
  4297. if (i === vnode.staticCount - 1) {
  4298. vnode.anchor = nextNode;
  4299. }
  4300. nextNode = nextSibling(nextNode);
  4301. }
  4302. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  4303. } else {
  4304. onMismatch();
  4305. }
  4306. break;
  4307. case Fragment:
  4308. if (!isFragmentStart) {
  4309. nextNode = onMismatch();
  4310. } else {
  4311. nextNode = hydrateFragment(
  4312. node,
  4313. vnode,
  4314. parentComponent,
  4315. parentSuspense,
  4316. slotScopeIds,
  4317. optimized
  4318. );
  4319. }
  4320. break;
  4321. default:
  4322. if (shapeFlag & 1) {
  4323. if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
  4324. nextNode = onMismatch();
  4325. } else {
  4326. nextNode = hydrateElement(
  4327. node,
  4328. vnode,
  4329. parentComponent,
  4330. parentSuspense,
  4331. slotScopeIds,
  4332. optimized
  4333. );
  4334. }
  4335. } else if (shapeFlag & 6) {
  4336. vnode.slotScopeIds = slotScopeIds;
  4337. const container = parentNode(node);
  4338. if (isFragmentStart) {
  4339. nextNode = locateClosingAnchor(node);
  4340. } else if (isComment(node) && node.data === "teleport start") {
  4341. nextNode = locateClosingAnchor(node, node.data, "teleport end");
  4342. } else {
  4343. nextNode = nextSibling(node);
  4344. }
  4345. mountComponent(
  4346. vnode,
  4347. container,
  4348. null,
  4349. parentComponent,
  4350. parentSuspense,
  4351. getContainerType(container),
  4352. optimized
  4353. );
  4354. if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
  4355. let subTree;
  4356. if (isFragmentStart) {
  4357. subTree = createVNode(Fragment);
  4358. subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
  4359. } else {
  4360. subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
  4361. }
  4362. subTree.el = node;
  4363. vnode.component.subTree = subTree;
  4364. }
  4365. } else if (shapeFlag & 64) {
  4366. if (domType !== 8) {
  4367. nextNode = onMismatch();
  4368. } else {
  4369. nextNode = vnode.type.hydrate(
  4370. node,
  4371. vnode,
  4372. parentComponent,
  4373. parentSuspense,
  4374. slotScopeIds,
  4375. optimized,
  4376. rendererInternals,
  4377. hydrateChildren
  4378. );
  4379. }
  4380. } else if (shapeFlag & 128) {
  4381. nextNode = vnode.type.hydrate(
  4382. node,
  4383. vnode,
  4384. parentComponent,
  4385. parentSuspense,
  4386. getContainerType(parentNode(node)),
  4387. slotScopeIds,
  4388. optimized,
  4389. rendererInternals,
  4390. hydrateNode
  4391. );
  4392. } else {
  4393. warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
  4394. }
  4395. }
  4396. if (ref != null) {
  4397. setRef(ref, null, parentSuspense, vnode);
  4398. }
  4399. return nextNode;
  4400. };
  4401. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  4402. optimized = optimized || !!vnode.dynamicChildren;
  4403. const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
  4404. const forcePatch = type === "input" || type === "option";
  4405. {
  4406. if (dirs) {
  4407. invokeDirectiveHook(vnode, null, parentComponent, "created");
  4408. }
  4409. let needCallTransitionHooks = false;
  4410. if (isTemplateNode(el)) {
  4411. needCallTransitionHooks = needTransition(
  4412. null,
  4413. // no need check parentSuspense in hydration
  4414. transition
  4415. ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
  4416. const content = el.content.firstChild;
  4417. if (needCallTransitionHooks) {
  4418. const cls = content.getAttribute("class");
  4419. if (cls) content.$cls = cls;
  4420. transition.beforeEnter(content);
  4421. }
  4422. replaceNode(content, el, parentComponent);
  4423. vnode.el = el = content;
  4424. }
  4425. if (shapeFlag & 16 && // skip if element has innerHTML / textContent
  4426. !(props && (props.innerHTML || props.textContent))) {
  4427. let next = hydrateChildren(
  4428. el.firstChild,
  4429. vnode,
  4430. el,
  4431. parentComponent,
  4432. parentSuspense,
  4433. slotScopeIds,
  4434. optimized
  4435. );
  4436. if (next && !isMismatchAllowed(el, 1 /* CHILDREN */)) {
  4437. warn$1(
  4438. `Hydration children mismatch on`,
  4439. el,
  4440. `
  4441. Server rendered element contains more child nodes than client vdom.`
  4442. );
  4443. logMismatchError();
  4444. }
  4445. while (next) {
  4446. const cur = next;
  4447. next = next.nextSibling;
  4448. remove(cur);
  4449. }
  4450. } else if (shapeFlag & 8) {
  4451. let clientText = vnode.children;
  4452. if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
  4453. clientText = clientText.slice(1);
  4454. }
  4455. const { textContent } = el;
  4456. if (textContent !== clientText && // innerHTML normalize \r\n or \r into a single \n in the DOM
  4457. textContent !== clientText.replace(/\r\n|\r/g, "\n")) {
  4458. if (!isMismatchAllowed(el, 0 /* TEXT */)) {
  4459. warn$1(
  4460. `Hydration text content mismatch on`,
  4461. el,
  4462. `
  4463. - rendered on server: ${textContent}
  4464. - expected on client: ${clientText}`
  4465. );
  4466. logMismatchError();
  4467. }
  4468. el.textContent = vnode.children;
  4469. }
  4470. }
  4471. if (props) {
  4472. {
  4473. const isCustomElement = el.tagName.includes("-");
  4474. for (const key in props) {
  4475. if (// #11189 skip if this node has directives that have created hooks
  4476. // as it could have mutated the DOM in any possible way
  4477. !(dirs && dirs.some((d) => d.dir.created)) && propHasMismatch(el, key, props[key], vnode, parentComponent)) {
  4478. logMismatchError();
  4479. }
  4480. if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
  4481. key[0] === "." || isCustomElement && !isReservedProp(key)) {
  4482. patchProp(el, key, null, props[key], void 0, parentComponent);
  4483. }
  4484. }
  4485. }
  4486. }
  4487. let vnodeHooks;
  4488. if (vnodeHooks = props && props.onVnodeBeforeMount) {
  4489. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  4490. }
  4491. if (dirs) {
  4492. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  4493. }
  4494. if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
  4495. queueEffectWithSuspense(() => {
  4496. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  4497. needCallTransitionHooks && transition.enter(el);
  4498. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  4499. }, parentSuspense);
  4500. }
  4501. }
  4502. return el.nextSibling;
  4503. };
  4504. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  4505. optimized = optimized || !!parentVNode.dynamicChildren;
  4506. const children = parentVNode.children;
  4507. const l = children.length;
  4508. let hasCheckedMismatch = false;
  4509. for (let i = 0; i < l; i++) {
  4510. const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
  4511. const isText = vnode.type === Text;
  4512. if (node) {
  4513. if (isText && !optimized) {
  4514. if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
  4515. insert(
  4516. createText(
  4517. node.data.slice(vnode.children.length)
  4518. ),
  4519. container,
  4520. nextSibling(node)
  4521. );
  4522. node.data = vnode.children;
  4523. }
  4524. }
  4525. node = hydrateNode(
  4526. node,
  4527. vnode,
  4528. parentComponent,
  4529. parentSuspense,
  4530. slotScopeIds,
  4531. optimized
  4532. );
  4533. } else if (isText && !vnode.children) {
  4534. insert(vnode.el = createText(""), container);
  4535. } else {
  4536. if (!hasCheckedMismatch) {
  4537. hasCheckedMismatch = true;
  4538. if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
  4539. warn$1(
  4540. `Hydration children mismatch on`,
  4541. container,
  4542. `
  4543. Server rendered element contains fewer child nodes than client vdom.`
  4544. );
  4545. logMismatchError();
  4546. }
  4547. }
  4548. patch(
  4549. null,
  4550. vnode,
  4551. container,
  4552. null,
  4553. parentComponent,
  4554. parentSuspense,
  4555. getContainerType(container),
  4556. slotScopeIds
  4557. );
  4558. }
  4559. }
  4560. return node;
  4561. };
  4562. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  4563. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  4564. if (fragmentSlotScopeIds) {
  4565. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  4566. }
  4567. const container = parentNode(node);
  4568. const next = hydrateChildren(
  4569. nextSibling(node),
  4570. vnode,
  4571. container,
  4572. parentComponent,
  4573. parentSuspense,
  4574. slotScopeIds,
  4575. optimized
  4576. );
  4577. if (next && isComment(next) && next.data === "]") {
  4578. return nextSibling(vnode.anchor = next);
  4579. } else {
  4580. logMismatchError();
  4581. insert(vnode.anchor = createComment(`]`), container, next);
  4582. return next;
  4583. }
  4584. };
  4585. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  4586. if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
  4587. warn$1(
  4588. `Hydration node mismatch:
  4589. - rendered on server:`,
  4590. node,
  4591. node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
  4592. `
  4593. - expected on client:`,
  4594. vnode.type
  4595. );
  4596. logMismatchError();
  4597. }
  4598. vnode.el = null;
  4599. if (isFragment) {
  4600. const end = locateClosingAnchor(node);
  4601. while (true) {
  4602. const next2 = nextSibling(node);
  4603. if (next2 && next2 !== end) {
  4604. remove(next2);
  4605. } else {
  4606. break;
  4607. }
  4608. }
  4609. }
  4610. const next = nextSibling(node);
  4611. const container = parentNode(node);
  4612. remove(node);
  4613. patch(
  4614. null,
  4615. vnode,
  4616. container,
  4617. next,
  4618. parentComponent,
  4619. parentSuspense,
  4620. getContainerType(container),
  4621. slotScopeIds
  4622. );
  4623. if (parentComponent) {
  4624. parentComponent.vnode.el = vnode.el;
  4625. updateHOCHostEl(parentComponent, vnode.el);
  4626. }
  4627. return next;
  4628. };
  4629. const locateClosingAnchor = (node, open = "[", close = "]") => {
  4630. let match = 0;
  4631. while (node) {
  4632. node = nextSibling(node);
  4633. if (node && isComment(node)) {
  4634. if (node.data === open) match++;
  4635. if (node.data === close) {
  4636. if (match === 0) {
  4637. return nextSibling(node);
  4638. } else {
  4639. match--;
  4640. }
  4641. }
  4642. }
  4643. }
  4644. return node;
  4645. };
  4646. const replaceNode = (newNode, oldNode, parentComponent) => {
  4647. const parentNode2 = oldNode.parentNode;
  4648. if (parentNode2) {
  4649. parentNode2.replaceChild(newNode, oldNode);
  4650. }
  4651. let parent = parentComponent;
  4652. while (parent) {
  4653. if (parent.vnode.el === oldNode) {
  4654. parent.vnode.el = parent.subTree.el = newNode;
  4655. }
  4656. parent = parent.parent;
  4657. }
  4658. };
  4659. const isTemplateNode = (node) => {
  4660. return node.nodeType === 1 && node.tagName === "TEMPLATE";
  4661. };
  4662. return [hydrate, hydrateNode];
  4663. }
  4664. function propHasMismatch(el, key, clientValue, vnode, instance) {
  4665. let mismatchType;
  4666. let mismatchKey;
  4667. let actual;
  4668. let expected;
  4669. if (key === "class") {
  4670. if (el.$cls) {
  4671. actual = el.$cls;
  4672. delete el.$cls;
  4673. } else {
  4674. actual = el.getAttribute("class");
  4675. }
  4676. expected = normalizeClass(clientValue);
  4677. if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
  4678. mismatchType = 2 /* CLASS */;
  4679. mismatchKey = `class`;
  4680. }
  4681. } else if (key === "style") {
  4682. actual = el.getAttribute("style") || "";
  4683. expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
  4684. const actualMap = toStyleMap(actual);
  4685. const expectedMap = toStyleMap(expected);
  4686. if (vnode.dirs) {
  4687. for (const { dir, value } of vnode.dirs) {
  4688. if (dir.name === "show" && !value) {
  4689. expectedMap.set("display", "none");
  4690. }
  4691. }
  4692. }
  4693. if (instance) {
  4694. resolveCssVars(instance, vnode, expectedMap);
  4695. }
  4696. if (!isMapEqual(actualMap, expectedMap)) {
  4697. mismatchType = 3 /* STYLE */;
  4698. mismatchKey = "style";
  4699. }
  4700. } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
  4701. if (isBooleanAttr(key)) {
  4702. actual = el.hasAttribute(key);
  4703. expected = includeBooleanAttr(clientValue);
  4704. } else if (clientValue == null) {
  4705. actual = el.hasAttribute(key);
  4706. expected = false;
  4707. } else {
  4708. if (el.hasAttribute(key)) {
  4709. actual = el.getAttribute(key);
  4710. } else if (key === "value" && el.tagName === "TEXTAREA") {
  4711. actual = el.value;
  4712. } else {
  4713. actual = false;
  4714. }
  4715. expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false;
  4716. }
  4717. if (actual !== expected) {
  4718. mismatchType = 4 /* ATTRIBUTE */;
  4719. mismatchKey = key;
  4720. }
  4721. }
  4722. if (mismatchType != null && !isMismatchAllowed(el, mismatchType)) {
  4723. const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
  4724. const preSegment = `Hydration ${MismatchTypeString[mismatchType]} mismatch on`;
  4725. const postSegment = `
  4726. - rendered on server: ${format(actual)}
  4727. - expected on client: ${format(expected)}
  4728. Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
  4729. You should fix the source of the mismatch.`;
  4730. {
  4731. warn$1(preSegment, el, postSegment);
  4732. }
  4733. return true;
  4734. }
  4735. return false;
  4736. }
  4737. function toClassSet(str) {
  4738. return new Set(str.trim().split(/\s+/));
  4739. }
  4740. function isSetEqual(a, b) {
  4741. if (a.size !== b.size) {
  4742. return false;
  4743. }
  4744. for (const s of a) {
  4745. if (!b.has(s)) {
  4746. return false;
  4747. }
  4748. }
  4749. return true;
  4750. }
  4751. function toStyleMap(str) {
  4752. const styleMap = /* @__PURE__ */ new Map();
  4753. for (const item of str.split(";")) {
  4754. let [key, value] = item.split(":");
  4755. key = key.trim();
  4756. value = value && value.trim();
  4757. if (key && value) {
  4758. styleMap.set(key, value);
  4759. }
  4760. }
  4761. return styleMap;
  4762. }
  4763. function isMapEqual(a, b) {
  4764. if (a.size !== b.size) {
  4765. return false;
  4766. }
  4767. for (const [key, value] of a) {
  4768. if (value !== b.get(key)) {
  4769. return false;
  4770. }
  4771. }
  4772. return true;
  4773. }
  4774. function resolveCssVars(instance, vnode, expectedMap) {
  4775. const root = instance.subTree;
  4776. if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
  4777. const cssVars = instance.getCssVars();
  4778. for (const key in cssVars) {
  4779. const value = normalizeCssVarValue(cssVars[key]);
  4780. expectedMap.set(`--${getEscapedCssVarName(key)}`, value);
  4781. }
  4782. }
  4783. if (vnode === root && instance.parent) {
  4784. resolveCssVars(instance.parent, instance.vnode, expectedMap);
  4785. }
  4786. }
  4787. const allowMismatchAttr = "data-allow-mismatch";
  4788. const MismatchTypeString = {
  4789. [0 /* TEXT */]: "text",
  4790. [1 /* CHILDREN */]: "children",
  4791. [2 /* CLASS */]: "class",
  4792. [3 /* STYLE */]: "style",
  4793. [4 /* ATTRIBUTE */]: "attribute"
  4794. };
  4795. function isMismatchAllowed(el, allowedType) {
  4796. if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
  4797. while (el && !el.hasAttribute(allowMismatchAttr)) {
  4798. el = el.parentElement;
  4799. }
  4800. }
  4801. const allowedAttr = el && el.getAttribute(allowMismatchAttr);
  4802. if (allowedAttr == null) {
  4803. return false;
  4804. } else if (allowedAttr === "") {
  4805. return true;
  4806. } else {
  4807. const list = allowedAttr.split(",");
  4808. if (allowedType === 0 /* TEXT */ && list.includes("children")) {
  4809. return true;
  4810. }
  4811. return list.includes(MismatchTypeString[allowedType]);
  4812. }
  4813. }
  4814. const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
  4815. const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
  4816. const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
  4817. const id = requestIdleCallback(hydrate, { timeout });
  4818. return () => cancelIdleCallback(id);
  4819. };
  4820. function elementIsVisibleInViewport(el) {
  4821. const { top, left, bottom, right } = el.getBoundingClientRect();
  4822. const { innerHeight, innerWidth } = window;
  4823. return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
  4824. }
  4825. const hydrateOnVisible = (opts) => (hydrate, forEach) => {
  4826. const ob = new IntersectionObserver((entries) => {
  4827. for (const e of entries) {
  4828. if (!e.isIntersecting) continue;
  4829. ob.disconnect();
  4830. hydrate();
  4831. break;
  4832. }
  4833. }, opts);
  4834. forEach((el) => {
  4835. if (!(el instanceof Element)) return;
  4836. if (elementIsVisibleInViewport(el)) {
  4837. hydrate();
  4838. ob.disconnect();
  4839. return false;
  4840. }
  4841. ob.observe(el);
  4842. });
  4843. return () => ob.disconnect();
  4844. };
  4845. const hydrateOnMediaQuery = (query) => (hydrate) => {
  4846. if (query) {
  4847. const mql = matchMedia(query);
  4848. if (mql.matches) {
  4849. hydrate();
  4850. } else {
  4851. mql.addEventListener("change", hydrate, { once: true });
  4852. return () => mql.removeEventListener("change", hydrate);
  4853. }
  4854. }
  4855. };
  4856. const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
  4857. if (isString(interactions)) interactions = [interactions];
  4858. let hasHydrated = false;
  4859. const doHydrate = (e) => {
  4860. if (!hasHydrated) {
  4861. hasHydrated = true;
  4862. teardown();
  4863. hydrate();
  4864. e.target.dispatchEvent(new e.constructor(e.type, e));
  4865. }
  4866. };
  4867. const teardown = () => {
  4868. forEach((el) => {
  4869. for (const i of interactions) {
  4870. el.removeEventListener(i, doHydrate);
  4871. }
  4872. });
  4873. };
  4874. forEach((el) => {
  4875. for (const i of interactions) {
  4876. el.addEventListener(i, doHydrate, { once: true });
  4877. }
  4878. });
  4879. return teardown;
  4880. };
  4881. function forEachElement(node, cb) {
  4882. if (isComment(node) && node.data === "[") {
  4883. let depth = 1;
  4884. let next = node.nextSibling;
  4885. while (next) {
  4886. if (next.nodeType === 1) {
  4887. const result = cb(next);
  4888. if (result === false) {
  4889. break;
  4890. }
  4891. } else if (isComment(next)) {
  4892. if (next.data === "]") {
  4893. if (--depth === 0) break;
  4894. } else if (next.data === "[") {
  4895. depth++;
  4896. }
  4897. }
  4898. next = next.nextSibling;
  4899. }
  4900. } else {
  4901. cb(node);
  4902. }
  4903. }
  4904. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  4905. // @__NO_SIDE_EFFECTS__
  4906. function defineAsyncComponent(source) {
  4907. if (isFunction(source)) {
  4908. source = { loader: source };
  4909. }
  4910. const {
  4911. loader,
  4912. loadingComponent,
  4913. errorComponent,
  4914. delay = 200,
  4915. hydrate: hydrateStrategy,
  4916. timeout,
  4917. // undefined = never times out
  4918. suspensible = true,
  4919. onError: userOnError
  4920. } = source;
  4921. let pendingRequest = null;
  4922. let resolvedComp;
  4923. let retries = 0;
  4924. const retry = () => {
  4925. retries++;
  4926. pendingRequest = null;
  4927. return load();
  4928. };
  4929. const load = () => {
  4930. let thisRequest;
  4931. return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
  4932. err = err instanceof Error ? err : new Error(String(err));
  4933. if (userOnError) {
  4934. return new Promise((resolve, reject) => {
  4935. const userRetry = () => resolve(retry());
  4936. const userFail = () => reject(err);
  4937. userOnError(err, userRetry, userFail, retries + 1);
  4938. });
  4939. } else {
  4940. throw err;
  4941. }
  4942. }).then((comp) => {
  4943. if (thisRequest !== pendingRequest && pendingRequest) {
  4944. return pendingRequest;
  4945. }
  4946. if (!comp) {
  4947. warn$1(
  4948. `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
  4949. );
  4950. }
  4951. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  4952. comp = comp.default;
  4953. }
  4954. if (comp && !isObject(comp) && !isFunction(comp)) {
  4955. throw new Error(`Invalid async component load result: ${comp}`);
  4956. }
  4957. resolvedComp = comp;
  4958. return comp;
  4959. }));
  4960. };
  4961. return defineComponent({
  4962. name: "AsyncComponentWrapper",
  4963. __asyncLoader: load,
  4964. __asyncHydrate(el, instance, hydrate) {
  4965. let patched = false;
  4966. (instance.bu || (instance.bu = [])).push(() => patched = true);
  4967. const performHydrate = () => {
  4968. if (patched) {
  4969. {
  4970. warn$1(
  4971. `Skipping lazy hydration for component '${getComponentName(resolvedComp) || resolvedComp.__file}': it was updated before lazy hydration performed.`
  4972. );
  4973. }
  4974. return;
  4975. }
  4976. hydrate();
  4977. };
  4978. const doHydrate = hydrateStrategy ? () => {
  4979. const teardown = hydrateStrategy(
  4980. performHydrate,
  4981. (cb) => forEachElement(el, cb)
  4982. );
  4983. if (teardown) {
  4984. (instance.bum || (instance.bum = [])).push(teardown);
  4985. }
  4986. } : performHydrate;
  4987. if (resolvedComp) {
  4988. doHydrate();
  4989. } else {
  4990. load().then(() => !instance.isUnmounted && doHydrate());
  4991. }
  4992. },
  4993. get __asyncResolved() {
  4994. return resolvedComp;
  4995. },
  4996. setup() {
  4997. const instance = currentInstance;
  4998. markAsyncBoundary(instance);
  4999. if (resolvedComp) {
  5000. return () => createInnerComp(resolvedComp, instance);
  5001. }
  5002. const onError = (err) => {
  5003. pendingRequest = null;
  5004. handleError(
  5005. err,
  5006. instance,
  5007. 13,
  5008. !errorComponent
  5009. );
  5010. };
  5011. if (suspensible && instance.suspense || isInSSRComponentSetup) {
  5012. return load().then((comp) => {
  5013. return () => createInnerComp(comp, instance);
  5014. }).catch((err) => {
  5015. onError(err);
  5016. return () => errorComponent ? createVNode(errorComponent, {
  5017. error: err
  5018. }) : null;
  5019. });
  5020. }
  5021. const loaded = ref(false);
  5022. const error = ref();
  5023. const delayed = ref(!!delay);
  5024. if (delay) {
  5025. setTimeout(() => {
  5026. delayed.value = false;
  5027. }, delay);
  5028. }
  5029. if (timeout != null) {
  5030. setTimeout(() => {
  5031. if (!loaded.value && !error.value) {
  5032. const err = new Error(
  5033. `Async component timed out after ${timeout}ms.`
  5034. );
  5035. onError(err);
  5036. error.value = err;
  5037. }
  5038. }, timeout);
  5039. }
  5040. load().then(() => {
  5041. loaded.value = true;
  5042. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  5043. instance.parent.update();
  5044. }
  5045. }).catch((err) => {
  5046. onError(err);
  5047. error.value = err;
  5048. });
  5049. return () => {
  5050. if (loaded.value && resolvedComp) {
  5051. return createInnerComp(resolvedComp, instance);
  5052. } else if (error.value && errorComponent) {
  5053. return createVNode(errorComponent, {
  5054. error: error.value
  5055. });
  5056. } else if (loadingComponent && !delayed.value) {
  5057. return createInnerComp(
  5058. loadingComponent,
  5059. instance
  5060. );
  5061. }
  5062. };
  5063. }
  5064. });
  5065. }
  5066. function createInnerComp(comp, parent) {
  5067. const { ref: ref2, props, children, ce } = parent.vnode;
  5068. const vnode = createVNode(comp, props, children);
  5069. vnode.ref = ref2;
  5070. vnode.ce = ce;
  5071. delete parent.vnode.ce;
  5072. return vnode;
  5073. }
  5074. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  5075. const KeepAliveImpl = {
  5076. name: `KeepAlive`,
  5077. // Marker for special handling inside the renderer. We are not using a ===
  5078. // check directly on KeepAlive in the renderer, because importing it directly
  5079. // would prevent it from being tree-shaken.
  5080. __isKeepAlive: true,
  5081. props: {
  5082. include: [String, RegExp, Array],
  5083. exclude: [String, RegExp, Array],
  5084. max: [String, Number]
  5085. },
  5086. setup(props, { slots }) {
  5087. const instance = getCurrentInstance();
  5088. const sharedContext = instance.ctx;
  5089. if (!sharedContext.renderer) {
  5090. return () => {
  5091. const children = slots.default && slots.default();
  5092. return children && children.length === 1 ? children[0] : children;
  5093. };
  5094. }
  5095. const cache = /* @__PURE__ */ new Map();
  5096. const keys = /* @__PURE__ */ new Set();
  5097. let current = null;
  5098. {
  5099. instance.__v_cache = cache;
  5100. }
  5101. const parentSuspense = instance.suspense;
  5102. const {
  5103. renderer: {
  5104. p: patch,
  5105. m: move,
  5106. um: _unmount,
  5107. o: { createElement }
  5108. }
  5109. } = sharedContext;
  5110. const storageContainer = createElement("div");
  5111. sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
  5112. const instance2 = vnode.component;
  5113. move(vnode, container, anchor, 0, parentSuspense);
  5114. patch(
  5115. instance2.vnode,
  5116. vnode,
  5117. container,
  5118. anchor,
  5119. instance2,
  5120. parentSuspense,
  5121. namespace,
  5122. vnode.slotScopeIds,
  5123. optimized
  5124. );
  5125. queuePostRenderEffect(() => {
  5126. instance2.isDeactivated = false;
  5127. if (instance2.a) {
  5128. invokeArrayFns(instance2.a);
  5129. }
  5130. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  5131. if (vnodeHook) {
  5132. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  5133. }
  5134. }, parentSuspense);
  5135. {
  5136. devtoolsComponentAdded(instance2);
  5137. }
  5138. };
  5139. sharedContext.deactivate = (vnode) => {
  5140. const instance2 = vnode.component;
  5141. invalidateMount(instance2.m);
  5142. invalidateMount(instance2.a);
  5143. move(vnode, storageContainer, null, 1, parentSuspense);
  5144. queuePostRenderEffect(() => {
  5145. if (instance2.da) {
  5146. invokeArrayFns(instance2.da);
  5147. }
  5148. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  5149. if (vnodeHook) {
  5150. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  5151. }
  5152. instance2.isDeactivated = true;
  5153. }, parentSuspense);
  5154. {
  5155. devtoolsComponentAdded(instance2);
  5156. }
  5157. {
  5158. instance2.__keepAliveStorageContainer = storageContainer;
  5159. }
  5160. };
  5161. function unmount(vnode) {
  5162. resetShapeFlag(vnode);
  5163. _unmount(vnode, instance, parentSuspense, true);
  5164. }
  5165. function pruneCache(filter) {
  5166. cache.forEach((vnode, key) => {
  5167. const name = getComponentName(
  5168. isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : vnode.type
  5169. );
  5170. if (name && !filter(name)) {
  5171. pruneCacheEntry(key);
  5172. }
  5173. });
  5174. }
  5175. function pruneCacheEntry(key) {
  5176. const cached = cache.get(key);
  5177. if (cached && (!current || !isSameVNodeType(cached, current))) {
  5178. unmount(cached);
  5179. } else if (current) {
  5180. resetShapeFlag(current);
  5181. }
  5182. cache.delete(key);
  5183. keys.delete(key);
  5184. }
  5185. watch(
  5186. () => [props.include, props.exclude],
  5187. ([include, exclude]) => {
  5188. include && pruneCache((name) => matches(include, name));
  5189. exclude && pruneCache((name) => !matches(exclude, name));
  5190. },
  5191. // prune post-render after `current` has been updated
  5192. { flush: "post", deep: true }
  5193. );
  5194. let pendingCacheKey = null;
  5195. const cacheSubtree = () => {
  5196. if (pendingCacheKey != null) {
  5197. if (isSuspense(instance.subTree.type)) {
  5198. queuePostRenderEffect(() => {
  5199. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  5200. }, instance.subTree.suspense);
  5201. } else {
  5202. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  5203. }
  5204. }
  5205. };
  5206. onMounted(cacheSubtree);
  5207. onUpdated(cacheSubtree);
  5208. onBeforeUnmount(() => {
  5209. cache.forEach((cached) => {
  5210. const { subTree, suspense } = instance;
  5211. const vnode = getInnerChild(subTree);
  5212. if (cached.type === vnode.type && cached.key === vnode.key) {
  5213. resetShapeFlag(vnode);
  5214. const da = vnode.component.da;
  5215. da && queuePostRenderEffect(da, suspense);
  5216. return;
  5217. }
  5218. unmount(cached);
  5219. });
  5220. });
  5221. return () => {
  5222. pendingCacheKey = null;
  5223. if (!slots.default) {
  5224. return current = null;
  5225. }
  5226. const children = slots.default();
  5227. const rawVNode = children[0];
  5228. if (children.length > 1) {
  5229. {
  5230. warn$1(`KeepAlive should contain exactly one component child.`);
  5231. }
  5232. current = null;
  5233. return children;
  5234. } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
  5235. current = null;
  5236. return rawVNode;
  5237. }
  5238. let vnode = getInnerChild(rawVNode);
  5239. if (vnode.type === Comment) {
  5240. current = null;
  5241. return vnode;
  5242. }
  5243. const comp = vnode.type;
  5244. const name = getComponentName(
  5245. isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
  5246. );
  5247. const { include, exclude, max } = props;
  5248. if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
  5249. vnode.shapeFlag &= -257;
  5250. current = vnode;
  5251. return rawVNode;
  5252. }
  5253. const key = vnode.key == null ? comp : vnode.key;
  5254. const cachedVNode = cache.get(key);
  5255. if (vnode.el) {
  5256. vnode = cloneVNode(vnode);
  5257. if (rawVNode.shapeFlag & 128) {
  5258. rawVNode.ssContent = vnode;
  5259. }
  5260. }
  5261. pendingCacheKey = key;
  5262. if (cachedVNode) {
  5263. vnode.el = cachedVNode.el;
  5264. vnode.component = cachedVNode.component;
  5265. if (vnode.transition) {
  5266. setTransitionHooks(vnode, vnode.transition);
  5267. }
  5268. vnode.shapeFlag |= 512;
  5269. keys.delete(key);
  5270. keys.add(key);
  5271. } else {
  5272. keys.add(key);
  5273. if (max && keys.size > parseInt(max, 10)) {
  5274. pruneCacheEntry(keys.values().next().value);
  5275. }
  5276. }
  5277. vnode.shapeFlag |= 256;
  5278. current = vnode;
  5279. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  5280. };
  5281. }
  5282. };
  5283. const KeepAlive = KeepAliveImpl;
  5284. function matches(pattern, name) {
  5285. if (isArray(pattern)) {
  5286. return pattern.some((p) => matches(p, name));
  5287. } else if (isString(pattern)) {
  5288. return pattern.split(",").includes(name);
  5289. } else if (isRegExp(pattern)) {
  5290. pattern.lastIndex = 0;
  5291. return pattern.test(name);
  5292. }
  5293. return false;
  5294. }
  5295. function onActivated(hook, target) {
  5296. registerKeepAliveHook(hook, "a", target);
  5297. }
  5298. function onDeactivated(hook, target) {
  5299. registerKeepAliveHook(hook, "da", target);
  5300. }
  5301. function registerKeepAliveHook(hook, type, target = currentInstance) {
  5302. const wrappedHook = hook.__wdc || (hook.__wdc = () => {
  5303. let current = target;
  5304. while (current) {
  5305. if (current.isDeactivated) {
  5306. return;
  5307. }
  5308. current = current.parent;
  5309. }
  5310. return hook();
  5311. });
  5312. injectHook(type, wrappedHook, target);
  5313. if (target) {
  5314. let current = target.parent;
  5315. while (current && current.parent) {
  5316. if (isKeepAlive(current.parent.vnode)) {
  5317. injectToKeepAliveRoot(wrappedHook, type, target, current);
  5318. }
  5319. current = current.parent;
  5320. }
  5321. }
  5322. }
  5323. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  5324. const injected = injectHook(
  5325. type,
  5326. hook,
  5327. keepAliveRoot,
  5328. true
  5329. /* prepend */
  5330. );
  5331. onUnmounted(() => {
  5332. remove(keepAliveRoot[type], injected);
  5333. }, target);
  5334. }
  5335. function resetShapeFlag(vnode) {
  5336. vnode.shapeFlag &= -257;
  5337. vnode.shapeFlag &= -513;
  5338. }
  5339. function getInnerChild(vnode) {
  5340. return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
  5341. }
  5342. function injectHook(type, hook, target = currentInstance, prepend = false) {
  5343. if (target) {
  5344. const hooks = target[type] || (target[type] = []);
  5345. const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
  5346. pauseTracking();
  5347. const reset = setCurrentInstance(target);
  5348. const res = callWithAsyncErrorHandling(hook, target, type, args);
  5349. reset();
  5350. resetTracking();
  5351. return res;
  5352. });
  5353. if (prepend) {
  5354. hooks.unshift(wrappedHook);
  5355. } else {
  5356. hooks.push(wrappedHook);
  5357. }
  5358. return wrappedHook;
  5359. } else {
  5360. const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
  5361. warn$1(
  5362. `${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.` )
  5363. );
  5364. }
  5365. }
  5366. const createHook = (lifecycle) => (hook, target = currentInstance) => {
  5367. if (!isInSSRComponentSetup || lifecycle === "sp") {
  5368. injectHook(lifecycle, (...args) => hook(...args), target);
  5369. }
  5370. };
  5371. const onBeforeMount = createHook("bm");
  5372. const onMounted = createHook("m");
  5373. const onBeforeUpdate = createHook(
  5374. "bu"
  5375. );
  5376. const onUpdated = createHook("u");
  5377. const onBeforeUnmount = createHook(
  5378. "bum"
  5379. );
  5380. const onUnmounted = createHook("um");
  5381. const onServerPrefetch = createHook(
  5382. "sp"
  5383. );
  5384. const onRenderTriggered = createHook("rtg");
  5385. const onRenderTracked = createHook("rtc");
  5386. function onErrorCaptured(hook, target = currentInstance) {
  5387. injectHook("ec", hook, target);
  5388. }
  5389. const COMPONENTS = "components";
  5390. const DIRECTIVES = "directives";
  5391. function resolveComponent(name, maybeSelfReference) {
  5392. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  5393. }
  5394. const NULL_DYNAMIC_COMPONENT = /* @__PURE__ */ Symbol.for("v-ndc");
  5395. function resolveDynamicComponent(component) {
  5396. if (isString(component)) {
  5397. return resolveAsset(COMPONENTS, component, false) || component;
  5398. } else {
  5399. return component || NULL_DYNAMIC_COMPONENT;
  5400. }
  5401. }
  5402. function resolveDirective(name) {
  5403. return resolveAsset(DIRECTIVES, name);
  5404. }
  5405. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  5406. const instance = currentRenderingInstance || currentInstance;
  5407. if (instance) {
  5408. const Component = instance.type;
  5409. if (type === COMPONENTS) {
  5410. const selfName = getComponentName(
  5411. Component,
  5412. false
  5413. );
  5414. if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
  5415. return Component;
  5416. }
  5417. }
  5418. const res = (
  5419. // local registration
  5420. // check instance[type] first which is resolved for options API
  5421. resolve(instance[type] || Component[type], name) || // global registration
  5422. resolve(instance.appContext[type], name)
  5423. );
  5424. if (!res && maybeSelfReference) {
  5425. return Component;
  5426. }
  5427. if (warnMissing && !res) {
  5428. const extra = type === COMPONENTS ? `
  5429. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
  5430. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  5431. }
  5432. return res;
  5433. } else {
  5434. warn$1(
  5435. `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
  5436. );
  5437. }
  5438. }
  5439. function resolve(registry, name) {
  5440. return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
  5441. }
  5442. function renderList(source, renderItem, cache, index) {
  5443. let ret;
  5444. const cached = cache && cache[index];
  5445. const sourceIsArray = isArray(source);
  5446. if (sourceIsArray || isString(source)) {
  5447. const sourceIsReactiveArray = sourceIsArray && isReactive(source);
  5448. let needsWrap = false;
  5449. let isReadonlySource = false;
  5450. if (sourceIsReactiveArray) {
  5451. needsWrap = !isShallow(source);
  5452. isReadonlySource = isReadonly(source);
  5453. source = shallowReadArray(source);
  5454. }
  5455. ret = new Array(source.length);
  5456. for (let i = 0, l = source.length; i < l; i++) {
  5457. ret[i] = renderItem(
  5458. needsWrap ? isReadonlySource ? toReadonly(toReactive(source[i])) : toReactive(source[i]) : source[i],
  5459. i,
  5460. void 0,
  5461. cached && cached[i]
  5462. );
  5463. }
  5464. } else if (typeof source === "number") {
  5465. if (!Number.isInteger(source) || source < 0) {
  5466. warn$1(
  5467. `The v-for range expects a positive integer value but got ${source}.`
  5468. );
  5469. ret = [];
  5470. } else {
  5471. ret = new Array(source);
  5472. for (let i = 0; i < source; i++) {
  5473. ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
  5474. }
  5475. }
  5476. } else if (isObject(source)) {
  5477. if (source[Symbol.iterator]) {
  5478. ret = Array.from(
  5479. source,
  5480. (item, i) => renderItem(item, i, void 0, cached && cached[i])
  5481. );
  5482. } else {
  5483. const keys = Object.keys(source);
  5484. ret = new Array(keys.length);
  5485. for (let i = 0, l = keys.length; i < l; i++) {
  5486. const key = keys[i];
  5487. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  5488. }
  5489. }
  5490. } else {
  5491. ret = [];
  5492. }
  5493. if (cache) {
  5494. cache[index] = ret;
  5495. }
  5496. return ret;
  5497. }
  5498. function createSlots(slots, dynamicSlots) {
  5499. for (let i = 0; i < dynamicSlots.length; i++) {
  5500. const slot = dynamicSlots[i];
  5501. if (isArray(slot)) {
  5502. for (let j = 0; j < slot.length; j++) {
  5503. slots[slot[j].name] = slot[j].fn;
  5504. }
  5505. } else if (slot) {
  5506. slots[slot.name] = slot.key ? (...args) => {
  5507. const res = slot.fn(...args);
  5508. if (res) res.key = slot.key;
  5509. return res;
  5510. } : slot.fn;
  5511. }
  5512. }
  5513. return slots;
  5514. }
  5515. function renderSlot(slots, name, props = {}, fallback, noSlotted) {
  5516. if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
  5517. const hasProps = Object.keys(props).length > 0;
  5518. if (name !== "default") props.name = name;
  5519. return openBlock(), createBlock(
  5520. Fragment,
  5521. null,
  5522. [createVNode("slot", props, fallback && fallback())],
  5523. hasProps ? -2 : 64
  5524. );
  5525. }
  5526. let slot = slots[name];
  5527. if (slot && slot.length > 1) {
  5528. warn$1(
  5529. `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.`
  5530. );
  5531. slot = () => [];
  5532. }
  5533. if (slot && slot._c) {
  5534. slot._d = false;
  5535. }
  5536. openBlock();
  5537. const validSlotContent = slot && ensureValidVNode(slot(props));
  5538. const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
  5539. // key attached in the `createSlots` helper, respect that
  5540. validSlotContent && validSlotContent.key;
  5541. const rendered = createBlock(
  5542. Fragment,
  5543. {
  5544. key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
  5545. (!validSlotContent && fallback ? "_fb" : "")
  5546. },
  5547. validSlotContent || (fallback ? fallback() : []),
  5548. validSlotContent && slots._ === 1 ? 64 : -2
  5549. );
  5550. if (!noSlotted && rendered.scopeId) {
  5551. rendered.slotScopeIds = [rendered.scopeId + "-s"];
  5552. }
  5553. if (slot && slot._c) {
  5554. slot._d = true;
  5555. }
  5556. return rendered;
  5557. }
  5558. function ensureValidVNode(vnodes) {
  5559. return vnodes.some((child) => {
  5560. if (!isVNode(child)) return true;
  5561. if (child.type === Comment) return false;
  5562. if (child.type === Fragment && !ensureValidVNode(child.children))
  5563. return false;
  5564. return true;
  5565. }) ? vnodes : null;
  5566. }
  5567. function toHandlers(obj, preserveCaseIfNecessary) {
  5568. const ret = {};
  5569. if (!isObject(obj)) {
  5570. warn$1(`v-on with no argument expects an object value.`);
  5571. return ret;
  5572. }
  5573. for (const key in obj) {
  5574. ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
  5575. }
  5576. return ret;
  5577. }
  5578. const getPublicInstance = (i) => {
  5579. if (!i) return null;
  5580. if (isStatefulComponent(i)) return getComponentPublicInstance(i);
  5581. return getPublicInstance(i.parent);
  5582. };
  5583. const publicPropertiesMap = (
  5584. // Move PURE marker to new line to workaround compiler discarding it
  5585. // due to type annotation
  5586. /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
  5587. $: (i) => i,
  5588. $el: (i) => i.vnode.el,
  5589. $data: (i) => i.data,
  5590. $props: (i) => shallowReadonly(i.props) ,
  5591. $attrs: (i) => shallowReadonly(i.attrs) ,
  5592. $slots: (i) => shallowReadonly(i.slots) ,
  5593. $refs: (i) => shallowReadonly(i.refs) ,
  5594. $parent: (i) => getPublicInstance(i.parent),
  5595. $root: (i) => getPublicInstance(i.root),
  5596. $host: (i) => i.ce,
  5597. $emit: (i) => i.emit,
  5598. $options: (i) => resolveMergedOptions(i) ,
  5599. $forceUpdate: (i) => i.f || (i.f = () => {
  5600. queueJob(i.update);
  5601. }),
  5602. $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
  5603. $watch: (i) => instanceWatch.bind(i)
  5604. })
  5605. );
  5606. const isReservedPrefix = (key) => key === "_" || key === "$";
  5607. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  5608. const PublicInstanceProxyHandlers = {
  5609. get({ _: instance }, key) {
  5610. if (key === "__v_skip") {
  5611. return true;
  5612. }
  5613. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  5614. if (key === "__isVue") {
  5615. return true;
  5616. }
  5617. if (key[0] !== "$") {
  5618. const n = accessCache[key];
  5619. if (n !== void 0) {
  5620. switch (n) {
  5621. case 1 /* SETUP */:
  5622. return setupState[key];
  5623. case 2 /* DATA */:
  5624. return data[key];
  5625. case 4 /* CONTEXT */:
  5626. return ctx[key];
  5627. case 3 /* PROPS */:
  5628. return props[key];
  5629. }
  5630. } else if (hasSetupBinding(setupState, key)) {
  5631. accessCache[key] = 1 /* SETUP */;
  5632. return setupState[key];
  5633. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  5634. accessCache[key] = 2 /* DATA */;
  5635. return data[key];
  5636. } else if (hasOwn(props, key)) {
  5637. accessCache[key] = 3 /* PROPS */;
  5638. return props[key];
  5639. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  5640. accessCache[key] = 4 /* CONTEXT */;
  5641. return ctx[key];
  5642. } else if (shouldCacheAccess) {
  5643. accessCache[key] = 0 /* OTHER */;
  5644. }
  5645. }
  5646. const publicGetter = publicPropertiesMap[key];
  5647. let cssModule, globalProperties;
  5648. if (publicGetter) {
  5649. if (key === "$attrs") {
  5650. track(instance.attrs, "get", "");
  5651. markAttrsAccessed();
  5652. } else if (key === "$slots") {
  5653. track(instance, "get", key);
  5654. }
  5655. return publicGetter(instance);
  5656. } else if (
  5657. // css module (injected by vue-loader)
  5658. (cssModule = type.__cssModules) && (cssModule = cssModule[key])
  5659. ) {
  5660. return cssModule;
  5661. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  5662. accessCache[key] = 4 /* CONTEXT */;
  5663. return ctx[key];
  5664. } else if (
  5665. // global properties
  5666. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
  5667. ) {
  5668. {
  5669. return globalProperties[key];
  5670. }
  5671. } else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
  5672. // to infinite warning loop
  5673. key.indexOf("__v") !== 0)) {
  5674. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  5675. warn$1(
  5676. `Property ${JSON.stringify(
  5677. key
  5678. )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
  5679. );
  5680. } else if (instance === currentRenderingInstance) {
  5681. warn$1(
  5682. `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
  5683. );
  5684. }
  5685. }
  5686. },
  5687. set({ _: instance }, key, value) {
  5688. const { data, setupState, ctx } = instance;
  5689. if (hasSetupBinding(setupState, key)) {
  5690. setupState[key] = value;
  5691. return true;
  5692. } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
  5693. warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
  5694. return false;
  5695. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  5696. data[key] = value;
  5697. return true;
  5698. } else if (hasOwn(instance.props, key)) {
  5699. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
  5700. return false;
  5701. }
  5702. if (key[0] === "$" && key.slice(1) in instance) {
  5703. warn$1(
  5704. `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
  5705. );
  5706. return false;
  5707. } else {
  5708. if (key in instance.appContext.config.globalProperties) {
  5709. Object.defineProperty(ctx, key, {
  5710. enumerable: true,
  5711. configurable: true,
  5712. value
  5713. });
  5714. } else {
  5715. ctx[key] = value;
  5716. }
  5717. }
  5718. return true;
  5719. },
  5720. has({
  5721. _: { data, setupState, accessCache, ctx, appContext, props, type }
  5722. }, key) {
  5723. let cssModules;
  5724. return !!(accessCache[key] || data !== EMPTY_OBJ && key[0] !== "$" && hasOwn(data, key) || hasSetupBinding(setupState, key) || hasOwn(props, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
  5725. },
  5726. defineProperty(target, key, descriptor) {
  5727. if (descriptor.get != null) {
  5728. target._.accessCache[key] = 0;
  5729. } else if (hasOwn(descriptor, "value")) {
  5730. this.set(target, key, descriptor.value, null);
  5731. }
  5732. return Reflect.defineProperty(target, key, descriptor);
  5733. }
  5734. };
  5735. {
  5736. PublicInstanceProxyHandlers.ownKeys = (target) => {
  5737. warn$1(
  5738. `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
  5739. );
  5740. return Reflect.ownKeys(target);
  5741. };
  5742. }
  5743. const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend({}, PublicInstanceProxyHandlers, {
  5744. get(target, key) {
  5745. if (key === Symbol.unscopables) {
  5746. return;
  5747. }
  5748. return PublicInstanceProxyHandlers.get(target, key, target);
  5749. },
  5750. has(_, key) {
  5751. const has = key[0] !== "_" && !isGloballyAllowed(key);
  5752. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  5753. warn$1(
  5754. `Property ${JSON.stringify(
  5755. key
  5756. )} should not start with _ which is a reserved prefix for Vue internals.`
  5757. );
  5758. }
  5759. return has;
  5760. }
  5761. });
  5762. function createDevRenderContext(instance) {
  5763. const target = {};
  5764. Object.defineProperty(target, `_`, {
  5765. configurable: true,
  5766. enumerable: false,
  5767. get: () => instance
  5768. });
  5769. Object.keys(publicPropertiesMap).forEach((key) => {
  5770. Object.defineProperty(target, key, {
  5771. configurable: true,
  5772. enumerable: false,
  5773. get: () => publicPropertiesMap[key](instance),
  5774. // intercepted by the proxy so no need for implementation,
  5775. // but needed to prevent set errors
  5776. set: NOOP
  5777. });
  5778. });
  5779. return target;
  5780. }
  5781. function exposePropsOnRenderContext(instance) {
  5782. const {
  5783. ctx,
  5784. propsOptions: [propsOptions]
  5785. } = instance;
  5786. if (propsOptions) {
  5787. Object.keys(propsOptions).forEach((key) => {
  5788. Object.defineProperty(ctx, key, {
  5789. enumerable: true,
  5790. configurable: true,
  5791. get: () => instance.props[key],
  5792. set: NOOP
  5793. });
  5794. });
  5795. }
  5796. }
  5797. function exposeSetupStateOnRenderContext(instance) {
  5798. const { ctx, setupState } = instance;
  5799. Object.keys(toRaw(setupState)).forEach((key) => {
  5800. if (!setupState.__isScriptSetup) {
  5801. if (isReservedPrefix(key[0])) {
  5802. warn$1(
  5803. `setup() return property ${JSON.stringify(
  5804. key
  5805. )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
  5806. );
  5807. return;
  5808. }
  5809. Object.defineProperty(ctx, key, {
  5810. enumerable: true,
  5811. configurable: true,
  5812. get: () => setupState[key],
  5813. set: NOOP
  5814. });
  5815. }
  5816. });
  5817. }
  5818. const warnRuntimeUsage = (method) => warn$1(
  5819. `${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.`
  5820. );
  5821. function defineProps() {
  5822. {
  5823. warnRuntimeUsage(`defineProps`);
  5824. }
  5825. return null;
  5826. }
  5827. function defineEmits() {
  5828. {
  5829. warnRuntimeUsage(`defineEmits`);
  5830. }
  5831. return null;
  5832. }
  5833. function defineExpose(exposed) {
  5834. {
  5835. warnRuntimeUsage(`defineExpose`);
  5836. }
  5837. }
  5838. function defineOptions(options) {
  5839. {
  5840. warnRuntimeUsage(`defineOptions`);
  5841. }
  5842. }
  5843. function defineSlots() {
  5844. {
  5845. warnRuntimeUsage(`defineSlots`);
  5846. }
  5847. return null;
  5848. }
  5849. function defineModel() {
  5850. {
  5851. warnRuntimeUsage("defineModel");
  5852. }
  5853. }
  5854. function withDefaults(props, defaults) {
  5855. {
  5856. warnRuntimeUsage(`withDefaults`);
  5857. }
  5858. return null;
  5859. }
  5860. function useSlots() {
  5861. return getContext("useSlots").slots;
  5862. }
  5863. function useAttrs() {
  5864. return getContext("useAttrs").attrs;
  5865. }
  5866. function getContext(calledFunctionName) {
  5867. const i = getCurrentInstance();
  5868. if (!i) {
  5869. warn$1(`${calledFunctionName}() called without active instance.`);
  5870. }
  5871. return i.setupContext || (i.setupContext = createSetupContext(i));
  5872. }
  5873. function normalizePropsOrEmits(props) {
  5874. return isArray(props) ? props.reduce(
  5875. (normalized, p) => (normalized[p] = null, normalized),
  5876. {}
  5877. ) : props;
  5878. }
  5879. function mergeDefaults(raw, defaults) {
  5880. const props = normalizePropsOrEmits(raw);
  5881. for (const key in defaults) {
  5882. if (key.startsWith("__skip")) continue;
  5883. let opt = props[key];
  5884. if (opt) {
  5885. if (isArray(opt) || isFunction(opt)) {
  5886. opt = props[key] = { type: opt, default: defaults[key] };
  5887. } else {
  5888. opt.default = defaults[key];
  5889. }
  5890. } else if (opt === null) {
  5891. opt = props[key] = { default: defaults[key] };
  5892. } else {
  5893. warn$1(`props default key "${key}" has no corresponding declaration.`);
  5894. }
  5895. if (opt && defaults[`__skip_${key}`]) {
  5896. opt.skipFactory = true;
  5897. }
  5898. }
  5899. return props;
  5900. }
  5901. function mergeModels(a, b) {
  5902. if (!a || !b) return a || b;
  5903. if (isArray(a) && isArray(b)) return a.concat(b);
  5904. return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
  5905. }
  5906. function createPropsRestProxy(props, excludedKeys) {
  5907. const ret = {};
  5908. for (const key in props) {
  5909. if (!excludedKeys.includes(key)) {
  5910. Object.defineProperty(ret, key, {
  5911. enumerable: true,
  5912. get: () => props[key]
  5913. });
  5914. }
  5915. }
  5916. return ret;
  5917. }
  5918. function withAsyncContext(getAwaitable) {
  5919. const ctx = getCurrentInstance();
  5920. const inSSRSetup = isInSSRComponentSetup;
  5921. if (!ctx) {
  5922. warn$1(
  5923. `withAsyncContext called without active current instance. This is likely a bug.`
  5924. );
  5925. }
  5926. let awaitable = getAwaitable();
  5927. unsetCurrentInstance();
  5928. if (inSSRSetup) {
  5929. setInSSRSetupState(false);
  5930. }
  5931. const restore = () => {
  5932. setCurrentInstance(ctx);
  5933. if (inSSRSetup) {
  5934. setInSSRSetupState(true);
  5935. }
  5936. };
  5937. const cleanup = () => {
  5938. if (getCurrentInstance() !== ctx) ctx.scope.off();
  5939. unsetCurrentInstance();
  5940. if (inSSRSetup) {
  5941. setInSSRSetupState(false);
  5942. }
  5943. };
  5944. if (isPromise(awaitable)) {
  5945. awaitable = awaitable.catch((e) => {
  5946. restore();
  5947. Promise.resolve().then(() => Promise.resolve().then(cleanup));
  5948. throw e;
  5949. });
  5950. }
  5951. return [
  5952. awaitable,
  5953. () => {
  5954. restore();
  5955. Promise.resolve().then(cleanup);
  5956. }
  5957. ];
  5958. }
  5959. function createDuplicateChecker() {
  5960. const cache = /* @__PURE__ */ Object.create(null);
  5961. return (type, key) => {
  5962. if (cache[key]) {
  5963. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  5964. } else {
  5965. cache[key] = type;
  5966. }
  5967. };
  5968. }
  5969. let shouldCacheAccess = true;
  5970. function applyOptions(instance) {
  5971. const options = resolveMergedOptions(instance);
  5972. const publicThis = instance.proxy;
  5973. const ctx = instance.ctx;
  5974. shouldCacheAccess = false;
  5975. if (options.beforeCreate) {
  5976. callHook$1(options.beforeCreate, instance, "bc");
  5977. }
  5978. const {
  5979. // state
  5980. data: dataOptions,
  5981. computed: computedOptions,
  5982. methods,
  5983. watch: watchOptions,
  5984. provide: provideOptions,
  5985. inject: injectOptions,
  5986. // lifecycle
  5987. created,
  5988. beforeMount,
  5989. mounted,
  5990. beforeUpdate,
  5991. updated,
  5992. activated,
  5993. deactivated,
  5994. beforeDestroy,
  5995. beforeUnmount,
  5996. destroyed,
  5997. unmounted,
  5998. render,
  5999. renderTracked,
  6000. renderTriggered,
  6001. errorCaptured,
  6002. serverPrefetch,
  6003. // public API
  6004. expose,
  6005. inheritAttrs,
  6006. // assets
  6007. components,
  6008. directives,
  6009. filters
  6010. } = options;
  6011. const checkDuplicateProperties = createDuplicateChecker() ;
  6012. {
  6013. const [propsOptions] = instance.propsOptions;
  6014. if (propsOptions) {
  6015. for (const key in propsOptions) {
  6016. checkDuplicateProperties("Props" /* PROPS */, key);
  6017. }
  6018. }
  6019. }
  6020. if (injectOptions) {
  6021. resolveInjections(injectOptions, ctx, checkDuplicateProperties);
  6022. }
  6023. if (methods) {
  6024. for (const key in methods) {
  6025. const methodHandler = methods[key];
  6026. if (isFunction(methodHandler)) {
  6027. {
  6028. Object.defineProperty(ctx, key, {
  6029. value: methodHandler.bind(publicThis),
  6030. configurable: true,
  6031. enumerable: true,
  6032. writable: true
  6033. });
  6034. }
  6035. {
  6036. checkDuplicateProperties("Methods" /* METHODS */, key);
  6037. }
  6038. } else {
  6039. warn$1(
  6040. `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
  6041. );
  6042. }
  6043. }
  6044. }
  6045. if (dataOptions) {
  6046. if (!isFunction(dataOptions)) {
  6047. warn$1(
  6048. `The data option must be a function. Plain object usage is no longer supported.`
  6049. );
  6050. }
  6051. const data = dataOptions.call(publicThis, publicThis);
  6052. if (isPromise(data)) {
  6053. warn$1(
  6054. `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
  6055. );
  6056. }
  6057. if (!isObject(data)) {
  6058. warn$1(`data() should return an object.`);
  6059. } else {
  6060. instance.data = reactive(data);
  6061. {
  6062. for (const key in data) {
  6063. checkDuplicateProperties("Data" /* DATA */, key);
  6064. if (!isReservedPrefix(key[0])) {
  6065. Object.defineProperty(ctx, key, {
  6066. configurable: true,
  6067. enumerable: true,
  6068. get: () => data[key],
  6069. set: NOOP
  6070. });
  6071. }
  6072. }
  6073. }
  6074. }
  6075. }
  6076. shouldCacheAccess = true;
  6077. if (computedOptions) {
  6078. for (const key in computedOptions) {
  6079. const opt = computedOptions[key];
  6080. const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
  6081. if (get === NOOP) {
  6082. warn$1(`Computed property "${key}" has no getter.`);
  6083. }
  6084. const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
  6085. warn$1(
  6086. `Write operation failed: computed property "${key}" is readonly.`
  6087. );
  6088. } ;
  6089. const c = computed({
  6090. get,
  6091. set
  6092. });
  6093. Object.defineProperty(ctx, key, {
  6094. enumerable: true,
  6095. configurable: true,
  6096. get: () => c.value,
  6097. set: (v) => c.value = v
  6098. });
  6099. {
  6100. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  6101. }
  6102. }
  6103. }
  6104. if (watchOptions) {
  6105. for (const key in watchOptions) {
  6106. createWatcher(watchOptions[key], ctx, publicThis, key);
  6107. }
  6108. }
  6109. if (provideOptions) {
  6110. const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
  6111. Reflect.ownKeys(provides).forEach((key) => {
  6112. provide(key, provides[key]);
  6113. });
  6114. }
  6115. if (created) {
  6116. callHook$1(created, instance, "c");
  6117. }
  6118. function registerLifecycleHook(register, hook) {
  6119. if (isArray(hook)) {
  6120. hook.forEach((_hook) => register(_hook.bind(publicThis)));
  6121. } else if (hook) {
  6122. register(hook.bind(publicThis));
  6123. }
  6124. }
  6125. registerLifecycleHook(onBeforeMount, beforeMount);
  6126. registerLifecycleHook(onMounted, mounted);
  6127. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  6128. registerLifecycleHook(onUpdated, updated);
  6129. registerLifecycleHook(onActivated, activated);
  6130. registerLifecycleHook(onDeactivated, deactivated);
  6131. registerLifecycleHook(onErrorCaptured, errorCaptured);
  6132. registerLifecycleHook(onRenderTracked, renderTracked);
  6133. registerLifecycleHook(onRenderTriggered, renderTriggered);
  6134. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  6135. registerLifecycleHook(onUnmounted, unmounted);
  6136. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  6137. if (isArray(expose)) {
  6138. if (expose.length) {
  6139. const exposed = instance.exposed || (instance.exposed = {});
  6140. expose.forEach((key) => {
  6141. Object.defineProperty(exposed, key, {
  6142. get: () => publicThis[key],
  6143. set: (val) => publicThis[key] = val,
  6144. enumerable: true
  6145. });
  6146. });
  6147. } else if (!instance.exposed) {
  6148. instance.exposed = {};
  6149. }
  6150. }
  6151. if (render && instance.render === NOOP) {
  6152. instance.render = render;
  6153. }
  6154. if (inheritAttrs != null) {
  6155. instance.inheritAttrs = inheritAttrs;
  6156. }
  6157. if (components) instance.components = components;
  6158. if (directives) instance.directives = directives;
  6159. if (serverPrefetch) {
  6160. markAsyncBoundary(instance);
  6161. }
  6162. }
  6163. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
  6164. if (isArray(injectOptions)) {
  6165. injectOptions = normalizeInject(injectOptions);
  6166. }
  6167. for (const key in injectOptions) {
  6168. const opt = injectOptions[key];
  6169. let injected;
  6170. if (isObject(opt)) {
  6171. if ("default" in opt) {
  6172. injected = inject(
  6173. opt.from || key,
  6174. opt.default,
  6175. true
  6176. );
  6177. } else {
  6178. injected = inject(opt.from || key);
  6179. }
  6180. } else {
  6181. injected = inject(opt);
  6182. }
  6183. if (isRef(injected)) {
  6184. Object.defineProperty(ctx, key, {
  6185. enumerable: true,
  6186. configurable: true,
  6187. get: () => injected.value,
  6188. set: (v) => injected.value = v
  6189. });
  6190. } else {
  6191. ctx[key] = injected;
  6192. }
  6193. {
  6194. checkDuplicateProperties("Inject" /* INJECT */, key);
  6195. }
  6196. }
  6197. }
  6198. function callHook$1(hook, instance, type) {
  6199. callWithAsyncErrorHandling(
  6200. isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
  6201. instance,
  6202. type
  6203. );
  6204. }
  6205. function createWatcher(raw, ctx, publicThis, key) {
  6206. let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
  6207. if (isString(raw)) {
  6208. const handler = ctx[raw];
  6209. if (isFunction(handler)) {
  6210. {
  6211. watch(getter, handler);
  6212. }
  6213. } else {
  6214. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  6215. }
  6216. } else if (isFunction(raw)) {
  6217. {
  6218. watch(getter, raw.bind(publicThis));
  6219. }
  6220. } else if (isObject(raw)) {
  6221. if (isArray(raw)) {
  6222. raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
  6223. } else {
  6224. const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
  6225. if (isFunction(handler)) {
  6226. watch(getter, handler, raw);
  6227. } else {
  6228. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  6229. }
  6230. }
  6231. } else {
  6232. warn$1(`Invalid watch option: "${key}"`, raw);
  6233. }
  6234. }
  6235. function resolveMergedOptions(instance) {
  6236. const base = instance.type;
  6237. const { mixins, extends: extendsOptions } = base;
  6238. const {
  6239. mixins: globalMixins,
  6240. optionsCache: cache,
  6241. config: { optionMergeStrategies }
  6242. } = instance.appContext;
  6243. const cached = cache.get(base);
  6244. let resolved;
  6245. if (cached) {
  6246. resolved = cached;
  6247. } else if (!globalMixins.length && !mixins && !extendsOptions) {
  6248. {
  6249. resolved = base;
  6250. }
  6251. } else {
  6252. resolved = {};
  6253. if (globalMixins.length) {
  6254. globalMixins.forEach(
  6255. (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
  6256. );
  6257. }
  6258. mergeOptions(resolved, base, optionMergeStrategies);
  6259. }
  6260. if (isObject(base)) {
  6261. cache.set(base, resolved);
  6262. }
  6263. return resolved;
  6264. }
  6265. function mergeOptions(to, from, strats, asMixin = false) {
  6266. const { mixins, extends: extendsOptions } = from;
  6267. if (extendsOptions) {
  6268. mergeOptions(to, extendsOptions, strats, true);
  6269. }
  6270. if (mixins) {
  6271. mixins.forEach(
  6272. (m) => mergeOptions(to, m, strats, true)
  6273. );
  6274. }
  6275. for (const key in from) {
  6276. if (asMixin && key === "expose") {
  6277. warn$1(
  6278. `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
  6279. );
  6280. } else {
  6281. const strat = internalOptionMergeStrats[key] || strats && strats[key];
  6282. to[key] = strat ? strat(to[key], from[key]) : from[key];
  6283. }
  6284. }
  6285. return to;
  6286. }
  6287. const internalOptionMergeStrats = {
  6288. data: mergeDataFn,
  6289. props: mergeEmitsOrPropsOptions,
  6290. emits: mergeEmitsOrPropsOptions,
  6291. // objects
  6292. methods: mergeObjectOptions,
  6293. computed: mergeObjectOptions,
  6294. // lifecycle
  6295. beforeCreate: mergeAsArray$1,
  6296. created: mergeAsArray$1,
  6297. beforeMount: mergeAsArray$1,
  6298. mounted: mergeAsArray$1,
  6299. beforeUpdate: mergeAsArray$1,
  6300. updated: mergeAsArray$1,
  6301. beforeDestroy: mergeAsArray$1,
  6302. beforeUnmount: mergeAsArray$1,
  6303. destroyed: mergeAsArray$1,
  6304. unmounted: mergeAsArray$1,
  6305. activated: mergeAsArray$1,
  6306. deactivated: mergeAsArray$1,
  6307. errorCaptured: mergeAsArray$1,
  6308. serverPrefetch: mergeAsArray$1,
  6309. // assets
  6310. components: mergeObjectOptions,
  6311. directives: mergeObjectOptions,
  6312. // watch
  6313. watch: mergeWatchOptions,
  6314. // provide / inject
  6315. provide: mergeDataFn,
  6316. inject: mergeInject
  6317. };
  6318. function mergeDataFn(to, from) {
  6319. if (!from) {
  6320. return to;
  6321. }
  6322. if (!to) {
  6323. return from;
  6324. }
  6325. return function mergedDataFn() {
  6326. return (extend)(
  6327. isFunction(to) ? to.call(this, this) : to,
  6328. isFunction(from) ? from.call(this, this) : from
  6329. );
  6330. };
  6331. }
  6332. function mergeInject(to, from) {
  6333. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  6334. }
  6335. function normalizeInject(raw) {
  6336. if (isArray(raw)) {
  6337. const res = {};
  6338. for (let i = 0; i < raw.length; i++) {
  6339. res[raw[i]] = raw[i];
  6340. }
  6341. return res;
  6342. }
  6343. return raw;
  6344. }
  6345. function mergeAsArray$1(to, from) {
  6346. return to ? [...new Set([].concat(to, from))] : from;
  6347. }
  6348. function mergeObjectOptions(to, from) {
  6349. return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
  6350. }
  6351. function mergeEmitsOrPropsOptions(to, from) {
  6352. if (to) {
  6353. if (isArray(to) && isArray(from)) {
  6354. return [.../* @__PURE__ */ new Set([...to, ...from])];
  6355. }
  6356. return extend(
  6357. /* @__PURE__ */ Object.create(null),
  6358. normalizePropsOrEmits(to),
  6359. normalizePropsOrEmits(from != null ? from : {})
  6360. );
  6361. } else {
  6362. return from;
  6363. }
  6364. }
  6365. function mergeWatchOptions(to, from) {
  6366. if (!to) return from;
  6367. if (!from) return to;
  6368. const merged = extend(/* @__PURE__ */ Object.create(null), to);
  6369. for (const key in from) {
  6370. merged[key] = mergeAsArray$1(to[key], from[key]);
  6371. }
  6372. return merged;
  6373. }
  6374. function createAppContext() {
  6375. return {
  6376. app: null,
  6377. config: {
  6378. isNativeTag: NO,
  6379. performance: false,
  6380. globalProperties: {},
  6381. optionMergeStrategies: {},
  6382. errorHandler: void 0,
  6383. warnHandler: void 0,
  6384. compilerOptions: {}
  6385. },
  6386. mixins: [],
  6387. components: {},
  6388. directives: {},
  6389. provides: /* @__PURE__ */ Object.create(null),
  6390. optionsCache: /* @__PURE__ */ new WeakMap(),
  6391. propsCache: /* @__PURE__ */ new WeakMap(),
  6392. emitsCache: /* @__PURE__ */ new WeakMap()
  6393. };
  6394. }
  6395. let uid$1 = 0;
  6396. function createAppAPI(render, hydrate) {
  6397. return function createApp(rootComponent, rootProps = null) {
  6398. if (!isFunction(rootComponent)) {
  6399. rootComponent = extend({}, rootComponent);
  6400. }
  6401. if (rootProps != null && !isObject(rootProps)) {
  6402. warn$1(`root props passed to app.mount() must be an object.`);
  6403. rootProps = null;
  6404. }
  6405. const context = createAppContext();
  6406. const installedPlugins = /* @__PURE__ */ new WeakSet();
  6407. const pluginCleanupFns = [];
  6408. let isMounted = false;
  6409. const app = context.app = {
  6410. _uid: uid$1++,
  6411. _component: rootComponent,
  6412. _props: rootProps,
  6413. _container: null,
  6414. _context: context,
  6415. _instance: null,
  6416. version,
  6417. get config() {
  6418. return context.config;
  6419. },
  6420. set config(v) {
  6421. {
  6422. warn$1(
  6423. `app.config cannot be replaced. Modify individual options instead.`
  6424. );
  6425. }
  6426. },
  6427. use(plugin, ...options) {
  6428. if (installedPlugins.has(plugin)) {
  6429. warn$1(`Plugin has already been applied to target app.`);
  6430. } else if (plugin && isFunction(plugin.install)) {
  6431. installedPlugins.add(plugin);
  6432. plugin.install(app, ...options);
  6433. } else if (isFunction(plugin)) {
  6434. installedPlugins.add(plugin);
  6435. plugin(app, ...options);
  6436. } else {
  6437. warn$1(
  6438. `A plugin must either be a function or an object with an "install" function.`
  6439. );
  6440. }
  6441. return app;
  6442. },
  6443. mixin(mixin) {
  6444. {
  6445. if (!context.mixins.includes(mixin)) {
  6446. context.mixins.push(mixin);
  6447. } else {
  6448. warn$1(
  6449. "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
  6450. );
  6451. }
  6452. }
  6453. return app;
  6454. },
  6455. component(name, component) {
  6456. {
  6457. validateComponentName(name, context.config);
  6458. }
  6459. if (!component) {
  6460. return context.components[name];
  6461. }
  6462. if (context.components[name]) {
  6463. warn$1(`Component "${name}" has already been registered in target app.`);
  6464. }
  6465. context.components[name] = component;
  6466. return app;
  6467. },
  6468. directive(name, directive) {
  6469. {
  6470. validateDirectiveName(name);
  6471. }
  6472. if (!directive) {
  6473. return context.directives[name];
  6474. }
  6475. if (context.directives[name]) {
  6476. warn$1(`Directive "${name}" has already been registered in target app.`);
  6477. }
  6478. context.directives[name] = directive;
  6479. return app;
  6480. },
  6481. mount(rootContainer, isHydrate, namespace) {
  6482. if (!isMounted) {
  6483. if (rootContainer.__vue_app__) {
  6484. warn$1(
  6485. `There is already an app instance mounted on the host container.
  6486. If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
  6487. );
  6488. }
  6489. const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
  6490. vnode.appContext = context;
  6491. if (namespace === true) {
  6492. namespace = "svg";
  6493. } else if (namespace === false) {
  6494. namespace = void 0;
  6495. }
  6496. {
  6497. context.reload = () => {
  6498. const cloned = cloneVNode(vnode);
  6499. cloned.el = null;
  6500. render(cloned, rootContainer, namespace);
  6501. };
  6502. }
  6503. if (isHydrate && hydrate) {
  6504. hydrate(vnode, rootContainer);
  6505. } else {
  6506. render(vnode, rootContainer, namespace);
  6507. }
  6508. isMounted = true;
  6509. app._container = rootContainer;
  6510. rootContainer.__vue_app__ = app;
  6511. {
  6512. app._instance = vnode.component;
  6513. devtoolsInitApp(app, version);
  6514. }
  6515. return getComponentPublicInstance(vnode.component);
  6516. } else {
  6517. warn$1(
  6518. `App has already been mounted.
  6519. 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)\``
  6520. );
  6521. }
  6522. },
  6523. onUnmount(cleanupFn) {
  6524. if (typeof cleanupFn !== "function") {
  6525. warn$1(
  6526. `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
  6527. );
  6528. }
  6529. pluginCleanupFns.push(cleanupFn);
  6530. },
  6531. unmount() {
  6532. if (isMounted) {
  6533. callWithAsyncErrorHandling(
  6534. pluginCleanupFns,
  6535. app._instance,
  6536. 16
  6537. );
  6538. render(null, app._container);
  6539. {
  6540. app._instance = null;
  6541. devtoolsUnmountApp(app);
  6542. }
  6543. delete app._container.__vue_app__;
  6544. } else {
  6545. warn$1(`Cannot unmount an app that is not mounted.`);
  6546. }
  6547. },
  6548. provide(key, value) {
  6549. if (key in context.provides) {
  6550. if (hasOwn(context.provides, key)) {
  6551. warn$1(
  6552. `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
  6553. );
  6554. } else {
  6555. warn$1(
  6556. `App already provides property with key "${String(key)}" inherited from its parent element. It will be overwritten with the new value.`
  6557. );
  6558. }
  6559. }
  6560. context.provides[key] = value;
  6561. return app;
  6562. },
  6563. runWithContext(fn) {
  6564. const lastApp = currentApp;
  6565. currentApp = app;
  6566. try {
  6567. return fn();
  6568. } finally {
  6569. currentApp = lastApp;
  6570. }
  6571. }
  6572. };
  6573. return app;
  6574. };
  6575. }
  6576. let currentApp = null;
  6577. function useModel(props, name, options = EMPTY_OBJ) {
  6578. const i = getCurrentInstance();
  6579. if (!i) {
  6580. warn$1(`useModel() called without active instance.`);
  6581. return ref();
  6582. }
  6583. const camelizedName = camelize(name);
  6584. if (!i.propsOptions[0][camelizedName]) {
  6585. warn$1(`useModel() called with prop "${name}" which is not declared.`);
  6586. return ref();
  6587. }
  6588. const hyphenatedName = hyphenate(name);
  6589. const modifiers = getModelModifiers(props, camelizedName);
  6590. const res = customRef((track, trigger) => {
  6591. let localValue;
  6592. let prevSetValue = EMPTY_OBJ;
  6593. let prevEmittedValue;
  6594. watchSyncEffect(() => {
  6595. const propValue = props[camelizedName];
  6596. if (hasChanged(localValue, propValue)) {
  6597. localValue = propValue;
  6598. trigger();
  6599. }
  6600. });
  6601. return {
  6602. get() {
  6603. track();
  6604. return options.get ? options.get(localValue) : localValue;
  6605. },
  6606. set(value) {
  6607. const emittedValue = options.set ? options.set(value) : value;
  6608. if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
  6609. return;
  6610. }
  6611. const rawProps = i.vnode.props;
  6612. if (!(rawProps && // check if parent has passed v-model
  6613. (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
  6614. localValue = value;
  6615. trigger();
  6616. }
  6617. i.emit(`update:${name}`, emittedValue);
  6618. if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
  6619. trigger();
  6620. }
  6621. prevSetValue = value;
  6622. prevEmittedValue = emittedValue;
  6623. }
  6624. };
  6625. });
  6626. res[Symbol.iterator] = () => {
  6627. let i2 = 0;
  6628. return {
  6629. next() {
  6630. if (i2 < 2) {
  6631. return { value: i2++ ? modifiers || EMPTY_OBJ : res, done: false };
  6632. } else {
  6633. return { done: true };
  6634. }
  6635. }
  6636. };
  6637. };
  6638. return res;
  6639. }
  6640. const getModelModifiers = (props, modelName) => {
  6641. return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize(modelName)}Modifiers`] || props[`${hyphenate(modelName)}Modifiers`];
  6642. };
  6643. function emit(instance, event, ...rawArgs) {
  6644. if (instance.isUnmounted) return;
  6645. const props = instance.vnode.props || EMPTY_OBJ;
  6646. {
  6647. const {
  6648. emitsOptions,
  6649. propsOptions: [propsOptions]
  6650. } = instance;
  6651. if (emitsOptions) {
  6652. if (!(event in emitsOptions) && true) {
  6653. if (!propsOptions || !(toHandlerKey(camelize(event)) in propsOptions)) {
  6654. warn$1(
  6655. `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(camelize(event))}" prop.`
  6656. );
  6657. }
  6658. } else {
  6659. const validator = emitsOptions[event];
  6660. if (isFunction(validator)) {
  6661. const isValid = validator(...rawArgs);
  6662. if (!isValid) {
  6663. warn$1(
  6664. `Invalid event arguments: event validation failed for event "${event}".`
  6665. );
  6666. }
  6667. }
  6668. }
  6669. }
  6670. }
  6671. let args = rawArgs;
  6672. const isModelListener = event.startsWith("update:");
  6673. const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
  6674. if (modifiers) {
  6675. if (modifiers.trim) {
  6676. args = rawArgs.map((a) => isString(a) ? a.trim() : a);
  6677. }
  6678. if (modifiers.number) {
  6679. args = rawArgs.map(looseToNumber);
  6680. }
  6681. }
  6682. {
  6683. devtoolsComponentEmit(instance, event, args);
  6684. }
  6685. {
  6686. const lowerCaseEvent = event.toLowerCase();
  6687. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  6688. warn$1(
  6689. `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
  6690. instance,
  6691. instance.type
  6692. )} 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(
  6693. event
  6694. )}" instead of "${event}".`
  6695. );
  6696. }
  6697. }
  6698. let handlerName;
  6699. let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
  6700. props[handlerName = toHandlerKey(camelize(event))];
  6701. if (!handler && isModelListener) {
  6702. handler = props[handlerName = toHandlerKey(hyphenate(event))];
  6703. }
  6704. if (handler) {
  6705. callWithAsyncErrorHandling(
  6706. handler,
  6707. instance,
  6708. 6,
  6709. args
  6710. );
  6711. }
  6712. const onceHandler = props[handlerName + `Once`];
  6713. if (onceHandler) {
  6714. if (!instance.emitted) {
  6715. instance.emitted = {};
  6716. } else if (instance.emitted[handlerName]) {
  6717. return;
  6718. }
  6719. instance.emitted[handlerName] = true;
  6720. callWithAsyncErrorHandling(
  6721. onceHandler,
  6722. instance,
  6723. 6,
  6724. args
  6725. );
  6726. }
  6727. }
  6728. const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
  6729. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  6730. const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
  6731. const cached = cache.get(comp);
  6732. if (cached !== void 0) {
  6733. return cached;
  6734. }
  6735. const raw = comp.emits;
  6736. let normalized = {};
  6737. let hasExtends = false;
  6738. if (!isFunction(comp)) {
  6739. const extendEmits = (raw2) => {
  6740. const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
  6741. if (normalizedFromExtend) {
  6742. hasExtends = true;
  6743. extend(normalized, normalizedFromExtend);
  6744. }
  6745. };
  6746. if (!asMixin && appContext.mixins.length) {
  6747. appContext.mixins.forEach(extendEmits);
  6748. }
  6749. if (comp.extends) {
  6750. extendEmits(comp.extends);
  6751. }
  6752. if (comp.mixins) {
  6753. comp.mixins.forEach(extendEmits);
  6754. }
  6755. }
  6756. if (!raw && !hasExtends) {
  6757. if (isObject(comp)) {
  6758. cache.set(comp, null);
  6759. }
  6760. return null;
  6761. }
  6762. if (isArray(raw)) {
  6763. raw.forEach((key) => normalized[key] = null);
  6764. } else {
  6765. extend(normalized, raw);
  6766. }
  6767. if (isObject(comp)) {
  6768. cache.set(comp, normalized);
  6769. }
  6770. return normalized;
  6771. }
  6772. function isEmitListener(options, key) {
  6773. if (!options || !isOn(key)) {
  6774. return false;
  6775. }
  6776. key = key.slice(2).replace(/Once$/, "");
  6777. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
  6778. }
  6779. let accessedAttrs = false;
  6780. function markAttrsAccessed() {
  6781. accessedAttrs = true;
  6782. }
  6783. function renderComponentRoot(instance) {
  6784. const {
  6785. type: Component,
  6786. vnode,
  6787. proxy,
  6788. withProxy,
  6789. propsOptions: [propsOptions],
  6790. slots,
  6791. attrs,
  6792. emit,
  6793. render,
  6794. renderCache,
  6795. props,
  6796. data,
  6797. setupState,
  6798. ctx,
  6799. inheritAttrs
  6800. } = instance;
  6801. const prev = setCurrentRenderingInstance(instance);
  6802. let result;
  6803. let fallthroughAttrs;
  6804. {
  6805. accessedAttrs = false;
  6806. }
  6807. try {
  6808. if (vnode.shapeFlag & 4) {
  6809. const proxyToUse = withProxy || proxy;
  6810. const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
  6811. get(target, key, receiver) {
  6812. warn$1(
  6813. `Property '${String(
  6814. key
  6815. )}' was accessed via 'this'. Avoid using 'this' in templates.`
  6816. );
  6817. return Reflect.get(target, key, receiver);
  6818. }
  6819. }) : proxyToUse;
  6820. result = normalizeVNode(
  6821. render.call(
  6822. thisProxy,
  6823. proxyToUse,
  6824. renderCache,
  6825. true ? shallowReadonly(props) : props,
  6826. setupState,
  6827. data,
  6828. ctx
  6829. )
  6830. );
  6831. fallthroughAttrs = attrs;
  6832. } else {
  6833. const render2 = Component;
  6834. if (attrs === props) {
  6835. markAttrsAccessed();
  6836. }
  6837. result = normalizeVNode(
  6838. render2.length > 1 ? render2(
  6839. true ? shallowReadonly(props) : props,
  6840. true ? {
  6841. get attrs() {
  6842. markAttrsAccessed();
  6843. return shallowReadonly(attrs);
  6844. },
  6845. slots,
  6846. emit
  6847. } : { attrs, slots, emit }
  6848. ) : render2(
  6849. true ? shallowReadonly(props) : props,
  6850. null
  6851. )
  6852. );
  6853. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
  6854. }
  6855. } catch (err) {
  6856. blockStack.length = 0;
  6857. handleError(err, instance, 1);
  6858. result = createVNode(Comment);
  6859. }
  6860. let root = result;
  6861. let setRoot = void 0;
  6862. if (result.patchFlag > 0 && result.patchFlag & 2048) {
  6863. [root, setRoot] = getChildRoot(result);
  6864. }
  6865. if (fallthroughAttrs && inheritAttrs !== false) {
  6866. const keys = Object.keys(fallthroughAttrs);
  6867. const { shapeFlag } = root;
  6868. if (keys.length) {
  6869. if (shapeFlag & (1 | 6)) {
  6870. if (propsOptions && keys.some(isModelListener)) {
  6871. fallthroughAttrs = filterModelListeners(
  6872. fallthroughAttrs,
  6873. propsOptions
  6874. );
  6875. }
  6876. root = cloneVNode(root, fallthroughAttrs, false, true);
  6877. } else if (!accessedAttrs && root.type !== Comment) {
  6878. const allAttrs = Object.keys(attrs);
  6879. const eventAttrs = [];
  6880. const extraAttrs = [];
  6881. for (let i = 0, l = allAttrs.length; i < l; i++) {
  6882. const key = allAttrs[i];
  6883. if (isOn(key)) {
  6884. if (!isModelListener(key)) {
  6885. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  6886. }
  6887. } else {
  6888. extraAttrs.push(key);
  6889. }
  6890. }
  6891. if (extraAttrs.length) {
  6892. warn$1(
  6893. `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text or teleport root nodes.`
  6894. );
  6895. }
  6896. if (eventAttrs.length) {
  6897. warn$1(
  6898. `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.`
  6899. );
  6900. }
  6901. }
  6902. }
  6903. }
  6904. if (vnode.dirs) {
  6905. if (!isElementRoot(root)) {
  6906. warn$1(
  6907. `Runtime directive used on component with non-element root node. The directives will not function as intended.`
  6908. );
  6909. }
  6910. root = cloneVNode(root, null, false, true);
  6911. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  6912. }
  6913. if (vnode.transition) {
  6914. if (!isElementRoot(root)) {
  6915. warn$1(
  6916. `Component inside <Transition> renders non-element root node that cannot be animated.`
  6917. );
  6918. }
  6919. setTransitionHooks(root, vnode.transition);
  6920. }
  6921. if (setRoot) {
  6922. setRoot(root);
  6923. } else {
  6924. result = root;
  6925. }
  6926. setCurrentRenderingInstance(prev);
  6927. return result;
  6928. }
  6929. const getChildRoot = (vnode) => {
  6930. const rawChildren = vnode.children;
  6931. const dynamicChildren = vnode.dynamicChildren;
  6932. const childRoot = filterSingleRoot(rawChildren, false);
  6933. if (!childRoot) {
  6934. return [vnode, void 0];
  6935. } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
  6936. return getChildRoot(childRoot);
  6937. }
  6938. const index = rawChildren.indexOf(childRoot);
  6939. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  6940. const setRoot = (updatedRoot) => {
  6941. rawChildren[index] = updatedRoot;
  6942. if (dynamicChildren) {
  6943. if (dynamicIndex > -1) {
  6944. dynamicChildren[dynamicIndex] = updatedRoot;
  6945. } else if (updatedRoot.patchFlag > 0) {
  6946. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  6947. }
  6948. }
  6949. };
  6950. return [normalizeVNode(childRoot), setRoot];
  6951. };
  6952. function filterSingleRoot(children, recurse = true) {
  6953. let singleRoot;
  6954. for (let i = 0; i < children.length; i++) {
  6955. const child = children[i];
  6956. if (isVNode(child)) {
  6957. if (child.type !== Comment || child.children === "v-if") {
  6958. if (singleRoot) {
  6959. return;
  6960. } else {
  6961. singleRoot = child;
  6962. if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
  6963. return filterSingleRoot(singleRoot.children);
  6964. }
  6965. }
  6966. }
  6967. } else {
  6968. return;
  6969. }
  6970. }
  6971. return singleRoot;
  6972. }
  6973. const getFunctionalFallthrough = (attrs) => {
  6974. let res;
  6975. for (const key in attrs) {
  6976. if (key === "class" || key === "style" || isOn(key)) {
  6977. (res || (res = {}))[key] = attrs[key];
  6978. }
  6979. }
  6980. return res;
  6981. };
  6982. const filterModelListeners = (attrs, props) => {
  6983. const res = {};
  6984. for (const key in attrs) {
  6985. if (!isModelListener(key) || !(key.slice(9) in props)) {
  6986. res[key] = attrs[key];
  6987. }
  6988. }
  6989. return res;
  6990. };
  6991. const isElementRoot = (vnode) => {
  6992. return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
  6993. };
  6994. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  6995. const { props: prevProps, children: prevChildren, component } = prevVNode;
  6996. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  6997. const emits = component.emitsOptions;
  6998. if ((prevChildren || nextChildren) && isHmrUpdating) {
  6999. return true;
  7000. }
  7001. if (nextVNode.dirs || nextVNode.transition) {
  7002. return true;
  7003. }
  7004. if (optimized && patchFlag >= 0) {
  7005. if (patchFlag & 1024) {
  7006. return true;
  7007. }
  7008. if (patchFlag & 16) {
  7009. if (!prevProps) {
  7010. return !!nextProps;
  7011. }
  7012. return hasPropsChanged(prevProps, nextProps, emits);
  7013. } else if (patchFlag & 8) {
  7014. const dynamicProps = nextVNode.dynamicProps;
  7015. for (let i = 0; i < dynamicProps.length; i++) {
  7016. const key = dynamicProps[i];
  7017. if (hasPropValueChanged(nextProps, prevProps, key) && !isEmitListener(emits, key)) {
  7018. return true;
  7019. }
  7020. }
  7021. }
  7022. } else {
  7023. if (prevChildren || nextChildren) {
  7024. if (!nextChildren || !nextChildren.$stable) {
  7025. return true;
  7026. }
  7027. }
  7028. if (prevProps === nextProps) {
  7029. return false;
  7030. }
  7031. if (!prevProps) {
  7032. return !!nextProps;
  7033. }
  7034. if (!nextProps) {
  7035. return true;
  7036. }
  7037. return hasPropsChanged(prevProps, nextProps, emits);
  7038. }
  7039. return false;
  7040. }
  7041. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  7042. const nextKeys = Object.keys(nextProps);
  7043. if (nextKeys.length !== Object.keys(prevProps).length) {
  7044. return true;
  7045. }
  7046. for (let i = 0; i < nextKeys.length; i++) {
  7047. const key = nextKeys[i];
  7048. if (hasPropValueChanged(nextProps, prevProps, key) && !isEmitListener(emitsOptions, key)) {
  7049. return true;
  7050. }
  7051. }
  7052. return false;
  7053. }
  7054. function hasPropValueChanged(nextProps, prevProps, key) {
  7055. const nextProp = nextProps[key];
  7056. const prevProp = prevProps[key];
  7057. if (key === "style" && isObject(nextProp) && isObject(prevProp)) {
  7058. return !looseEqual(nextProp, prevProp);
  7059. }
  7060. return nextProp !== prevProp;
  7061. }
  7062. function updateHOCHostEl({ vnode, parent, suspense }, el) {
  7063. while (parent) {
  7064. const root = parent.subTree;
  7065. if (root.suspense && root.suspense.activeBranch === vnode) {
  7066. root.suspense.vnode.el = root.el = el;
  7067. vnode = root;
  7068. }
  7069. if (root === vnode) {
  7070. (vnode = parent.vnode).el = el;
  7071. parent = parent.parent;
  7072. } else {
  7073. break;
  7074. }
  7075. }
  7076. if (suspense && suspense.activeBranch === vnode) {
  7077. suspense.vnode.el = el;
  7078. }
  7079. }
  7080. const internalObjectProto = {};
  7081. const createInternalObject = () => Object.create(internalObjectProto);
  7082. const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
  7083. function initProps(instance, rawProps, isStateful, isSSR = false) {
  7084. const props = {};
  7085. const attrs = createInternalObject();
  7086. instance.propsDefaults = /* @__PURE__ */ Object.create(null);
  7087. setFullProps(instance, rawProps, props, attrs);
  7088. for (const key in instance.propsOptions[0]) {
  7089. if (!(key in props)) {
  7090. props[key] = void 0;
  7091. }
  7092. }
  7093. {
  7094. validateProps(rawProps || {}, props, instance);
  7095. }
  7096. if (isStateful) {
  7097. instance.props = isSSR ? props : shallowReactive(props);
  7098. } else {
  7099. if (!instance.type.props) {
  7100. instance.props = attrs;
  7101. } else {
  7102. instance.props = props;
  7103. }
  7104. }
  7105. instance.attrs = attrs;
  7106. }
  7107. function isInHmrContext(instance) {
  7108. while (instance) {
  7109. if (instance.type.__hmrId) return true;
  7110. instance = instance.parent;
  7111. }
  7112. }
  7113. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  7114. const {
  7115. props,
  7116. attrs,
  7117. vnode: { patchFlag }
  7118. } = instance;
  7119. const rawCurrentProps = toRaw(props);
  7120. const [options] = instance.propsOptions;
  7121. let hasAttrsChanged = false;
  7122. if (
  7123. // always force full diff in dev
  7124. // - #1942 if hmr is enabled with sfc component
  7125. // - vite#872 non-sfc component used by sfc component
  7126. !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
  7127. ) {
  7128. if (patchFlag & 8) {
  7129. const propsToUpdate = instance.vnode.dynamicProps;
  7130. for (let i = 0; i < propsToUpdate.length; i++) {
  7131. let key = propsToUpdate[i];
  7132. if (isEmitListener(instance.emitsOptions, key)) {
  7133. continue;
  7134. }
  7135. const value = rawProps[key];
  7136. if (options) {
  7137. if (hasOwn(attrs, key)) {
  7138. if (value !== attrs[key]) {
  7139. attrs[key] = value;
  7140. hasAttrsChanged = true;
  7141. }
  7142. } else {
  7143. const camelizedKey = camelize(key);
  7144. props[camelizedKey] = resolvePropValue(
  7145. options,
  7146. rawCurrentProps,
  7147. camelizedKey,
  7148. value,
  7149. instance,
  7150. false
  7151. );
  7152. }
  7153. } else {
  7154. if (value !== attrs[key]) {
  7155. attrs[key] = value;
  7156. hasAttrsChanged = true;
  7157. }
  7158. }
  7159. }
  7160. }
  7161. } else {
  7162. if (setFullProps(instance, rawProps, props, attrs)) {
  7163. hasAttrsChanged = true;
  7164. }
  7165. let kebabKey;
  7166. for (const key in rawCurrentProps) {
  7167. if (!rawProps || // for camelCase
  7168. !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
  7169. // and converted to camelCase (#955)
  7170. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
  7171. if (options) {
  7172. if (rawPrevProps && // for camelCase
  7173. (rawPrevProps[key] !== void 0 || // for kebab-case
  7174. rawPrevProps[kebabKey] !== void 0)) {
  7175. props[key] = resolvePropValue(
  7176. options,
  7177. rawCurrentProps,
  7178. key,
  7179. void 0,
  7180. instance,
  7181. true
  7182. );
  7183. }
  7184. } else {
  7185. delete props[key];
  7186. }
  7187. }
  7188. }
  7189. if (attrs !== rawCurrentProps) {
  7190. for (const key in attrs) {
  7191. if (!rawProps || !hasOwn(rawProps, key) && true) {
  7192. delete attrs[key];
  7193. hasAttrsChanged = true;
  7194. }
  7195. }
  7196. }
  7197. }
  7198. if (hasAttrsChanged) {
  7199. trigger(instance.attrs, "set", "");
  7200. }
  7201. {
  7202. validateProps(rawProps || {}, props, instance);
  7203. }
  7204. }
  7205. function setFullProps(instance, rawProps, props, attrs) {
  7206. const [options, needCastKeys] = instance.propsOptions;
  7207. let hasAttrsChanged = false;
  7208. let rawCastValues;
  7209. if (rawProps) {
  7210. for (let key in rawProps) {
  7211. if (isReservedProp(key)) {
  7212. continue;
  7213. }
  7214. const value = rawProps[key];
  7215. let camelKey;
  7216. if (options && hasOwn(options, camelKey = camelize(key))) {
  7217. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  7218. props[camelKey] = value;
  7219. } else {
  7220. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  7221. }
  7222. } else if (!isEmitListener(instance.emitsOptions, key)) {
  7223. if (!(key in attrs) || value !== attrs[key]) {
  7224. attrs[key] = value;
  7225. hasAttrsChanged = true;
  7226. }
  7227. }
  7228. }
  7229. }
  7230. if (needCastKeys) {
  7231. const rawCurrentProps = toRaw(props);
  7232. const castValues = rawCastValues || EMPTY_OBJ;
  7233. for (let i = 0; i < needCastKeys.length; i++) {
  7234. const key = needCastKeys[i];
  7235. props[key] = resolvePropValue(
  7236. options,
  7237. rawCurrentProps,
  7238. key,
  7239. castValues[key],
  7240. instance,
  7241. !hasOwn(castValues, key)
  7242. );
  7243. }
  7244. }
  7245. return hasAttrsChanged;
  7246. }
  7247. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  7248. const opt = options[key];
  7249. if (opt != null) {
  7250. const hasDefault = hasOwn(opt, "default");
  7251. if (hasDefault && value === void 0) {
  7252. const defaultValue = opt.default;
  7253. if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
  7254. const { propsDefaults } = instance;
  7255. if (key in propsDefaults) {
  7256. value = propsDefaults[key];
  7257. } else {
  7258. const reset = setCurrentInstance(instance);
  7259. value = propsDefaults[key] = defaultValue.call(
  7260. null,
  7261. props
  7262. );
  7263. reset();
  7264. }
  7265. } else {
  7266. value = defaultValue;
  7267. }
  7268. if (instance.ce) {
  7269. instance.ce._setProp(key, value);
  7270. }
  7271. }
  7272. if (opt[0 /* shouldCast */]) {
  7273. if (isAbsent && !hasDefault) {
  7274. value = false;
  7275. } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
  7276. value = true;
  7277. }
  7278. }
  7279. }
  7280. return value;
  7281. }
  7282. const mixinPropsCache = /* @__PURE__ */ new WeakMap();
  7283. function normalizePropsOptions(comp, appContext, asMixin = false) {
  7284. const cache = asMixin ? mixinPropsCache : appContext.propsCache;
  7285. const cached = cache.get(comp);
  7286. if (cached) {
  7287. return cached;
  7288. }
  7289. const raw = comp.props;
  7290. const normalized = {};
  7291. const needCastKeys = [];
  7292. let hasExtends = false;
  7293. if (!isFunction(comp)) {
  7294. const extendProps = (raw2) => {
  7295. hasExtends = true;
  7296. const [props, keys] = normalizePropsOptions(raw2, appContext, true);
  7297. extend(normalized, props);
  7298. if (keys) needCastKeys.push(...keys);
  7299. };
  7300. if (!asMixin && appContext.mixins.length) {
  7301. appContext.mixins.forEach(extendProps);
  7302. }
  7303. if (comp.extends) {
  7304. extendProps(comp.extends);
  7305. }
  7306. if (comp.mixins) {
  7307. comp.mixins.forEach(extendProps);
  7308. }
  7309. }
  7310. if (!raw && !hasExtends) {
  7311. if (isObject(comp)) {
  7312. cache.set(comp, EMPTY_ARR);
  7313. }
  7314. return EMPTY_ARR;
  7315. }
  7316. if (isArray(raw)) {
  7317. for (let i = 0; i < raw.length; i++) {
  7318. if (!isString(raw[i])) {
  7319. warn$1(`props must be strings when using array syntax.`, raw[i]);
  7320. }
  7321. const normalizedKey = camelize(raw[i]);
  7322. if (validatePropName(normalizedKey)) {
  7323. normalized[normalizedKey] = EMPTY_OBJ;
  7324. }
  7325. }
  7326. } else if (raw) {
  7327. if (!isObject(raw)) {
  7328. warn$1(`invalid props options`, raw);
  7329. }
  7330. for (const key in raw) {
  7331. const normalizedKey = camelize(key);
  7332. if (validatePropName(normalizedKey)) {
  7333. const opt = raw[key];
  7334. const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
  7335. const propType = prop.type;
  7336. let shouldCast = false;
  7337. let shouldCastTrue = true;
  7338. if (isArray(propType)) {
  7339. for (let index = 0; index < propType.length; ++index) {
  7340. const type = propType[index];
  7341. const typeName = isFunction(type) && type.name;
  7342. if (typeName === "Boolean") {
  7343. shouldCast = true;
  7344. break;
  7345. } else if (typeName === "String") {
  7346. shouldCastTrue = false;
  7347. }
  7348. }
  7349. } else {
  7350. shouldCast = isFunction(propType) && propType.name === "Boolean";
  7351. }
  7352. prop[0 /* shouldCast */] = shouldCast;
  7353. prop[1 /* shouldCastTrue */] = shouldCastTrue;
  7354. if (shouldCast || hasOwn(prop, "default")) {
  7355. needCastKeys.push(normalizedKey);
  7356. }
  7357. }
  7358. }
  7359. }
  7360. const res = [normalized, needCastKeys];
  7361. if (isObject(comp)) {
  7362. cache.set(comp, res);
  7363. }
  7364. return res;
  7365. }
  7366. function validatePropName(key) {
  7367. if (key[0] !== "$" && !isReservedProp(key)) {
  7368. return true;
  7369. } else {
  7370. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  7371. }
  7372. return false;
  7373. }
  7374. function getType(ctor) {
  7375. if (ctor === null) {
  7376. return "null";
  7377. }
  7378. if (typeof ctor === "function") {
  7379. return ctor.name || "";
  7380. } else if (typeof ctor === "object") {
  7381. const name = ctor.constructor && ctor.constructor.name;
  7382. return name || "";
  7383. }
  7384. return "";
  7385. }
  7386. function validateProps(rawProps, props, instance) {
  7387. const resolvedValues = toRaw(props);
  7388. const options = instance.propsOptions[0];
  7389. const camelizePropsKey = Object.keys(rawProps).map((key) => camelize(key));
  7390. for (const key in options) {
  7391. let opt = options[key];
  7392. if (opt == null) continue;
  7393. validateProp(
  7394. key,
  7395. resolvedValues[key],
  7396. opt,
  7397. shallowReadonly(resolvedValues) ,
  7398. !camelizePropsKey.includes(key)
  7399. );
  7400. }
  7401. }
  7402. function validateProp(name, value, prop, props, isAbsent) {
  7403. const { type, required, validator, skipCheck } = prop;
  7404. if (required && isAbsent) {
  7405. warn$1('Missing required prop: "' + name + '"');
  7406. return;
  7407. }
  7408. if (value == null && !required) {
  7409. return;
  7410. }
  7411. if (type != null && type !== true && !skipCheck) {
  7412. let isValid = false;
  7413. const types = isArray(type) ? type : [type];
  7414. const expectedTypes = [];
  7415. for (let i = 0; i < types.length && !isValid; i++) {
  7416. const { valid, expectedType } = assertType(value, types[i]);
  7417. expectedTypes.push(expectedType || "");
  7418. isValid = valid;
  7419. }
  7420. if (!isValid) {
  7421. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  7422. return;
  7423. }
  7424. }
  7425. if (validator && !validator(value, props)) {
  7426. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  7427. }
  7428. }
  7429. const isSimpleType = /* @__PURE__ */ makeMap(
  7430. "String,Number,Boolean,Function,Symbol,BigInt"
  7431. );
  7432. function assertType(value, type) {
  7433. let valid;
  7434. const expectedType = getType(type);
  7435. if (expectedType === "null") {
  7436. valid = value === null;
  7437. } else if (isSimpleType(expectedType)) {
  7438. const t = typeof value;
  7439. valid = t === expectedType.toLowerCase();
  7440. if (!valid && t === "object") {
  7441. valid = value instanceof type;
  7442. }
  7443. } else if (expectedType === "Object") {
  7444. valid = isObject(value);
  7445. } else if (expectedType === "Array") {
  7446. valid = isArray(value);
  7447. } else {
  7448. valid = value instanceof type;
  7449. }
  7450. return {
  7451. valid,
  7452. expectedType
  7453. };
  7454. }
  7455. function getInvalidTypeMessage(name, value, expectedTypes) {
  7456. if (expectedTypes.length === 0) {
  7457. return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
  7458. }
  7459. let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
  7460. const expectedType = expectedTypes[0];
  7461. const receivedType = toRawType(value);
  7462. const expectedValue = styleValue(value, expectedType);
  7463. const receivedValue = styleValue(value, receivedType);
  7464. if (expectedTypes.length === 1 && isExplicable(expectedType) && isCoercible(expectedType, receivedType)) {
  7465. message += ` with value ${expectedValue}`;
  7466. }
  7467. message += `, got ${receivedType} `;
  7468. if (isExplicable(receivedType)) {
  7469. message += `with value ${receivedValue}.`;
  7470. }
  7471. return message;
  7472. }
  7473. function styleValue(value, type) {
  7474. if (isSymbol(value)) {
  7475. return value.toString();
  7476. } else if (type === "String") {
  7477. return `"${value}"`;
  7478. } else if (type === "Number") {
  7479. return `${Number(value)}`;
  7480. } else {
  7481. return `${value}`;
  7482. }
  7483. }
  7484. function isExplicable(type) {
  7485. const explicitTypes = ["string", "number", "boolean"];
  7486. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  7487. }
  7488. function isCoercible(...args) {
  7489. return args.every((elem) => {
  7490. const value = elem.toLowerCase();
  7491. return value !== "boolean" && value !== "symbol";
  7492. });
  7493. }
  7494. const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
  7495. const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
  7496. const normalizeSlot = (key, rawSlot, ctx) => {
  7497. if (rawSlot._n) {
  7498. return rawSlot;
  7499. }
  7500. const normalized = withCtx((...args) => {
  7501. if (currentInstance && !(ctx === null && currentRenderingInstance) && !(ctx && ctx.root !== currentInstance.root)) {
  7502. warn$1(
  7503. `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.`
  7504. );
  7505. }
  7506. return normalizeSlotValue(rawSlot(...args));
  7507. }, ctx);
  7508. normalized._c = false;
  7509. return normalized;
  7510. };
  7511. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  7512. const ctx = rawSlots._ctx;
  7513. for (const key in rawSlots) {
  7514. if (isInternalKey(key)) continue;
  7515. const value = rawSlots[key];
  7516. if (isFunction(value)) {
  7517. slots[key] = normalizeSlot(key, value, ctx);
  7518. } else if (value != null) {
  7519. {
  7520. warn$1(
  7521. `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
  7522. );
  7523. }
  7524. const normalized = normalizeSlotValue(value);
  7525. slots[key] = () => normalized;
  7526. }
  7527. }
  7528. };
  7529. const normalizeVNodeSlots = (instance, children) => {
  7530. if (!isKeepAlive(instance.vnode) && true) {
  7531. warn$1(
  7532. `Non-function value encountered for default slot. Prefer function slots for better performance.`
  7533. );
  7534. }
  7535. const normalized = normalizeSlotValue(children);
  7536. instance.slots.default = () => normalized;
  7537. };
  7538. const assignSlots = (slots, children, optimized) => {
  7539. for (const key in children) {
  7540. if (optimized || !isInternalKey(key)) {
  7541. slots[key] = children[key];
  7542. }
  7543. }
  7544. };
  7545. const initSlots = (instance, children, optimized) => {
  7546. const slots = instance.slots = createInternalObject();
  7547. if (instance.vnode.shapeFlag & 32) {
  7548. const type = children._;
  7549. if (type) {
  7550. assignSlots(slots, children, optimized);
  7551. if (optimized) {
  7552. def(slots, "_", type, true);
  7553. }
  7554. } else {
  7555. normalizeObjectSlots(children, slots);
  7556. }
  7557. } else if (children) {
  7558. normalizeVNodeSlots(instance, children);
  7559. }
  7560. };
  7561. const updateSlots = (instance, children, optimized) => {
  7562. const { vnode, slots } = instance;
  7563. let needDeletionCheck = true;
  7564. let deletionComparisonTarget = EMPTY_OBJ;
  7565. if (vnode.shapeFlag & 32) {
  7566. const type = children._;
  7567. if (type) {
  7568. if (isHmrUpdating) {
  7569. assignSlots(slots, children, optimized);
  7570. trigger(instance, "set", "$slots");
  7571. } else if (optimized && type === 1) {
  7572. needDeletionCheck = false;
  7573. } else {
  7574. assignSlots(slots, children, optimized);
  7575. }
  7576. } else {
  7577. needDeletionCheck = !children.$stable;
  7578. normalizeObjectSlots(children, slots);
  7579. }
  7580. deletionComparisonTarget = children;
  7581. } else if (children) {
  7582. normalizeVNodeSlots(instance, children);
  7583. deletionComparisonTarget = { default: 1 };
  7584. }
  7585. if (needDeletionCheck) {
  7586. for (const key in slots) {
  7587. if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
  7588. delete slots[key];
  7589. }
  7590. }
  7591. }
  7592. };
  7593. let supported;
  7594. let perf;
  7595. function startMeasure(instance, type) {
  7596. if (instance.appContext.config.performance && isSupported()) {
  7597. perf.mark(`vue-${type}-${instance.uid}`);
  7598. }
  7599. {
  7600. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  7601. }
  7602. }
  7603. function endMeasure(instance, type) {
  7604. if (instance.appContext.config.performance && isSupported()) {
  7605. const startTag = `vue-${type}-${instance.uid}`;
  7606. const endTag = startTag + `:end`;
  7607. const measureName = `<${formatComponentName(instance, instance.type)}> ${type}`;
  7608. perf.mark(endTag);
  7609. perf.measure(measureName, startTag, endTag);
  7610. perf.clearMeasures(measureName);
  7611. perf.clearMarks(startTag);
  7612. perf.clearMarks(endTag);
  7613. }
  7614. {
  7615. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  7616. }
  7617. }
  7618. function isSupported() {
  7619. if (supported !== void 0) {
  7620. return supported;
  7621. }
  7622. if (typeof window !== "undefined" && window.performance) {
  7623. supported = true;
  7624. perf = window.performance;
  7625. } else {
  7626. supported = false;
  7627. }
  7628. return supported;
  7629. }
  7630. const queuePostRenderEffect = queueEffectWithSuspense ;
  7631. function createRenderer(options) {
  7632. return baseCreateRenderer(options);
  7633. }
  7634. function createHydrationRenderer(options) {
  7635. return baseCreateRenderer(options, createHydrationFunctions);
  7636. }
  7637. function baseCreateRenderer(options, createHydrationFns) {
  7638. const target = getGlobalThis();
  7639. target.__VUE__ = true;
  7640. {
  7641. setDevtoolsHook$1(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  7642. }
  7643. const {
  7644. insert: hostInsert,
  7645. remove: hostRemove,
  7646. patchProp: hostPatchProp,
  7647. createElement: hostCreateElement,
  7648. createText: hostCreateText,
  7649. createComment: hostCreateComment,
  7650. setText: hostSetText,
  7651. setElementText: hostSetElementText,
  7652. parentNode: hostParentNode,
  7653. nextSibling: hostNextSibling,
  7654. setScopeId: hostSetScopeId = NOOP,
  7655. insertStaticContent: hostInsertStaticContent
  7656. } = options;
  7657. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  7658. if (n1 === n2) {
  7659. return;
  7660. }
  7661. if (n1 && !isSameVNodeType(n1, n2)) {
  7662. anchor = getNextHostNode(n1);
  7663. unmount(n1, parentComponent, parentSuspense, true);
  7664. n1 = null;
  7665. }
  7666. if (n2.patchFlag === -2) {
  7667. optimized = false;
  7668. n2.dynamicChildren = null;
  7669. }
  7670. const { type, ref, shapeFlag } = n2;
  7671. switch (type) {
  7672. case Text:
  7673. processText(n1, n2, container, anchor);
  7674. break;
  7675. case Comment:
  7676. processCommentNode(n1, n2, container, anchor);
  7677. break;
  7678. case Static:
  7679. if (n1 == null) {
  7680. mountStaticNode(n2, container, anchor, namespace);
  7681. } else {
  7682. patchStaticNode(n1, n2, container, namespace);
  7683. }
  7684. break;
  7685. case Fragment:
  7686. processFragment(
  7687. n1,
  7688. n2,
  7689. container,
  7690. anchor,
  7691. parentComponent,
  7692. parentSuspense,
  7693. namespace,
  7694. slotScopeIds,
  7695. optimized
  7696. );
  7697. break;
  7698. default:
  7699. if (shapeFlag & 1) {
  7700. processElement(
  7701. n1,
  7702. n2,
  7703. container,
  7704. anchor,
  7705. parentComponent,
  7706. parentSuspense,
  7707. namespace,
  7708. slotScopeIds,
  7709. optimized
  7710. );
  7711. } else if (shapeFlag & 6) {
  7712. processComponent(
  7713. n1,
  7714. n2,
  7715. container,
  7716. anchor,
  7717. parentComponent,
  7718. parentSuspense,
  7719. namespace,
  7720. slotScopeIds,
  7721. optimized
  7722. );
  7723. } else if (shapeFlag & 64) {
  7724. type.process(
  7725. n1,
  7726. n2,
  7727. container,
  7728. anchor,
  7729. parentComponent,
  7730. parentSuspense,
  7731. namespace,
  7732. slotScopeIds,
  7733. optimized,
  7734. internals
  7735. );
  7736. } else if (shapeFlag & 128) {
  7737. type.process(
  7738. n1,
  7739. n2,
  7740. container,
  7741. anchor,
  7742. parentComponent,
  7743. parentSuspense,
  7744. namespace,
  7745. slotScopeIds,
  7746. optimized,
  7747. internals
  7748. );
  7749. } else {
  7750. warn$1("Invalid VNode type:", type, `(${typeof type})`);
  7751. }
  7752. }
  7753. if (ref != null && parentComponent) {
  7754. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  7755. } else if (ref == null && n1 && n1.ref != null) {
  7756. setRef(n1.ref, null, parentSuspense, n1, true);
  7757. }
  7758. };
  7759. const processText = (n1, n2, container, anchor) => {
  7760. if (n1 == null) {
  7761. hostInsert(
  7762. n2.el = hostCreateText(n2.children),
  7763. container,
  7764. anchor
  7765. );
  7766. } else {
  7767. const el = n2.el = n1.el;
  7768. if (n2.children !== n1.children) {
  7769. hostSetText(el, n2.children);
  7770. }
  7771. }
  7772. };
  7773. const processCommentNode = (n1, n2, container, anchor) => {
  7774. if (n1 == null) {
  7775. hostInsert(
  7776. n2.el = hostCreateComment(n2.children || ""),
  7777. container,
  7778. anchor
  7779. );
  7780. } else {
  7781. n2.el = n1.el;
  7782. }
  7783. };
  7784. const mountStaticNode = (n2, container, anchor, namespace) => {
  7785. [n2.el, n2.anchor] = hostInsertStaticContent(
  7786. n2.children,
  7787. container,
  7788. anchor,
  7789. namespace,
  7790. n2.el,
  7791. n2.anchor
  7792. );
  7793. };
  7794. const patchStaticNode = (n1, n2, container, namespace) => {
  7795. if (n2.children !== n1.children) {
  7796. const anchor = hostNextSibling(n1.anchor);
  7797. removeStaticNode(n1);
  7798. [n2.el, n2.anchor] = hostInsertStaticContent(
  7799. n2.children,
  7800. container,
  7801. anchor,
  7802. namespace
  7803. );
  7804. } else {
  7805. n2.el = n1.el;
  7806. n2.anchor = n1.anchor;
  7807. }
  7808. };
  7809. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  7810. let next;
  7811. while (el && el !== anchor) {
  7812. next = hostNextSibling(el);
  7813. hostInsert(el, container, nextSibling);
  7814. el = next;
  7815. }
  7816. hostInsert(anchor, container, nextSibling);
  7817. };
  7818. const removeStaticNode = ({ el, anchor }) => {
  7819. let next;
  7820. while (el && el !== anchor) {
  7821. next = hostNextSibling(el);
  7822. hostRemove(el);
  7823. el = next;
  7824. }
  7825. hostRemove(anchor);
  7826. };
  7827. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7828. if (n2.type === "svg") {
  7829. namespace = "svg";
  7830. } else if (n2.type === "math") {
  7831. namespace = "mathml";
  7832. }
  7833. if (n1 == null) {
  7834. mountElement(
  7835. n2,
  7836. container,
  7837. anchor,
  7838. parentComponent,
  7839. parentSuspense,
  7840. namespace,
  7841. slotScopeIds,
  7842. optimized
  7843. );
  7844. } else {
  7845. const customElement = n1.el && n1.el._isVueCE ? n1.el : null;
  7846. try {
  7847. if (customElement) {
  7848. customElement._beginPatch();
  7849. }
  7850. patchElement(
  7851. n1,
  7852. n2,
  7853. parentComponent,
  7854. parentSuspense,
  7855. namespace,
  7856. slotScopeIds,
  7857. optimized
  7858. );
  7859. } finally {
  7860. if (customElement) {
  7861. customElement._endPatch();
  7862. }
  7863. }
  7864. }
  7865. };
  7866. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7867. let el;
  7868. let vnodeHook;
  7869. const { props, shapeFlag, transition, dirs } = vnode;
  7870. el = vnode.el = hostCreateElement(
  7871. vnode.type,
  7872. namespace,
  7873. props && props.is,
  7874. props
  7875. );
  7876. if (shapeFlag & 8) {
  7877. hostSetElementText(el, vnode.children);
  7878. } else if (shapeFlag & 16) {
  7879. mountChildren(
  7880. vnode.children,
  7881. el,
  7882. null,
  7883. parentComponent,
  7884. parentSuspense,
  7885. resolveChildrenNamespace(vnode, namespace),
  7886. slotScopeIds,
  7887. optimized
  7888. );
  7889. }
  7890. if (dirs) {
  7891. invokeDirectiveHook(vnode, null, parentComponent, "created");
  7892. }
  7893. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  7894. if (props) {
  7895. for (const key in props) {
  7896. if (key !== "value" && !isReservedProp(key)) {
  7897. hostPatchProp(el, key, null, props[key], namespace, parentComponent);
  7898. }
  7899. }
  7900. if ("value" in props) {
  7901. hostPatchProp(el, "value", null, props.value, namespace);
  7902. }
  7903. if (vnodeHook = props.onVnodeBeforeMount) {
  7904. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7905. }
  7906. }
  7907. {
  7908. def(el, "__vnode", vnode, true);
  7909. def(el, "__vueParentComponent", parentComponent, true);
  7910. }
  7911. if (dirs) {
  7912. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  7913. }
  7914. const needCallTransitionHooks = needTransition(parentSuspense, transition);
  7915. if (needCallTransitionHooks) {
  7916. transition.beforeEnter(el);
  7917. }
  7918. hostInsert(el, container, anchor);
  7919. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  7920. const isHmr = isHmrUpdating;
  7921. queuePostRenderEffect(() => {
  7922. let prev;
  7923. prev = setHmrUpdating(isHmr);
  7924. try {
  7925. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7926. needCallTransitionHooks && transition.enter(el);
  7927. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  7928. } finally {
  7929. setHmrUpdating(prev);
  7930. }
  7931. }, parentSuspense);
  7932. }
  7933. };
  7934. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  7935. if (scopeId) {
  7936. hostSetScopeId(el, scopeId);
  7937. }
  7938. if (slotScopeIds) {
  7939. for (let i = 0; i < slotScopeIds.length; i++) {
  7940. hostSetScopeId(el, slotScopeIds[i]);
  7941. }
  7942. }
  7943. if (parentComponent) {
  7944. let subTree = parentComponent.subTree;
  7945. if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
  7946. subTree = filterSingleRoot(subTree.children) || subTree;
  7947. }
  7948. if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
  7949. const parentVNode = parentComponent.vnode;
  7950. setScopeId(
  7951. el,
  7952. parentVNode,
  7953. parentVNode.scopeId,
  7954. parentVNode.slotScopeIds,
  7955. parentComponent.parent
  7956. );
  7957. }
  7958. }
  7959. };
  7960. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
  7961. for (let i = start; i < children.length; i++) {
  7962. const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
  7963. patch(
  7964. null,
  7965. child,
  7966. container,
  7967. anchor,
  7968. parentComponent,
  7969. parentSuspense,
  7970. namespace,
  7971. slotScopeIds,
  7972. optimized
  7973. );
  7974. }
  7975. };
  7976. const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  7977. const el = n2.el = n1.el;
  7978. {
  7979. el.__vnode = n2;
  7980. }
  7981. let { patchFlag, dynamicChildren, dirs } = n2;
  7982. patchFlag |= n1.patchFlag & 16;
  7983. const oldProps = n1.props || EMPTY_OBJ;
  7984. const newProps = n2.props || EMPTY_OBJ;
  7985. let vnodeHook;
  7986. parentComponent && toggleRecurse(parentComponent, false);
  7987. if (vnodeHook = newProps.onVnodeBeforeUpdate) {
  7988. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  7989. }
  7990. if (dirs) {
  7991. invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
  7992. }
  7993. parentComponent && toggleRecurse(parentComponent, true);
  7994. if (isHmrUpdating) {
  7995. patchFlag = 0;
  7996. optimized = false;
  7997. dynamicChildren = null;
  7998. }
  7999. if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
  8000. hostSetElementText(el, "");
  8001. }
  8002. if (dynamicChildren) {
  8003. patchBlockChildren(
  8004. n1.dynamicChildren,
  8005. dynamicChildren,
  8006. el,
  8007. parentComponent,
  8008. parentSuspense,
  8009. resolveChildrenNamespace(n2, namespace),
  8010. slotScopeIds
  8011. );
  8012. {
  8013. traverseStaticChildren(n1, n2);
  8014. }
  8015. } else if (!optimized) {
  8016. patchChildren(
  8017. n1,
  8018. n2,
  8019. el,
  8020. null,
  8021. parentComponent,
  8022. parentSuspense,
  8023. resolveChildrenNamespace(n2, namespace),
  8024. slotScopeIds,
  8025. false
  8026. );
  8027. }
  8028. if (patchFlag > 0) {
  8029. if (patchFlag & 16) {
  8030. patchProps(el, oldProps, newProps, parentComponent, namespace);
  8031. } else {
  8032. if (patchFlag & 2) {
  8033. if (oldProps.class !== newProps.class) {
  8034. hostPatchProp(el, "class", null, newProps.class, namespace);
  8035. }
  8036. }
  8037. if (patchFlag & 4) {
  8038. hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
  8039. }
  8040. if (patchFlag & 8) {
  8041. const propsToUpdate = n2.dynamicProps;
  8042. for (let i = 0; i < propsToUpdate.length; i++) {
  8043. const key = propsToUpdate[i];
  8044. const prev = oldProps[key];
  8045. const next = newProps[key];
  8046. if (next !== prev || key === "value") {
  8047. hostPatchProp(el, key, prev, next, namespace, parentComponent);
  8048. }
  8049. }
  8050. }
  8051. }
  8052. if (patchFlag & 1) {
  8053. if (n1.children !== n2.children) {
  8054. hostSetElementText(el, n2.children);
  8055. }
  8056. }
  8057. } else if (!optimized && dynamicChildren == null) {
  8058. patchProps(el, oldProps, newProps, parentComponent, namespace);
  8059. }
  8060. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  8061. queuePostRenderEffect(() => {
  8062. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  8063. dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
  8064. }, parentSuspense);
  8065. }
  8066. };
  8067. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
  8068. for (let i = 0; i < newChildren.length; i++) {
  8069. const oldVNode = oldChildren[i];
  8070. const newVNode = newChildren[i];
  8071. const container = (
  8072. // oldVNode may be an errored async setup() component inside Suspense
  8073. // which will not have a mounted element
  8074. oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
  8075. // of the Fragment itself so it can move its children.
  8076. (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
  8077. // which also requires the correct parent container
  8078. !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
  8079. oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
  8080. // In other cases, the parent container is not actually used so we
  8081. // just pass the block element here to avoid a DOM parentNode call.
  8082. fallbackContainer
  8083. )
  8084. );
  8085. patch(
  8086. oldVNode,
  8087. newVNode,
  8088. container,
  8089. null,
  8090. parentComponent,
  8091. parentSuspense,
  8092. namespace,
  8093. slotScopeIds,
  8094. true
  8095. );
  8096. }
  8097. };
  8098. const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
  8099. if (oldProps !== newProps) {
  8100. if (oldProps !== EMPTY_OBJ) {
  8101. for (const key in oldProps) {
  8102. if (!isReservedProp(key) && !(key in newProps)) {
  8103. hostPatchProp(
  8104. el,
  8105. key,
  8106. oldProps[key],
  8107. null,
  8108. namespace,
  8109. parentComponent
  8110. );
  8111. }
  8112. }
  8113. }
  8114. for (const key in newProps) {
  8115. if (isReservedProp(key)) continue;
  8116. const next = newProps[key];
  8117. const prev = oldProps[key];
  8118. if (next !== prev && key !== "value") {
  8119. hostPatchProp(el, key, prev, next, namespace, parentComponent);
  8120. }
  8121. }
  8122. if ("value" in newProps) {
  8123. hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
  8124. }
  8125. }
  8126. };
  8127. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  8128. const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
  8129. const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
  8130. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  8131. if (
  8132. // #5523 dev root fragment may inherit directives
  8133. isHmrUpdating || patchFlag & 2048
  8134. ) {
  8135. patchFlag = 0;
  8136. optimized = false;
  8137. dynamicChildren = null;
  8138. }
  8139. if (fragmentSlotScopeIds) {
  8140. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  8141. }
  8142. if (n1 == null) {
  8143. hostInsert(fragmentStartAnchor, container, anchor);
  8144. hostInsert(fragmentEndAnchor, container, anchor);
  8145. mountChildren(
  8146. // #10007
  8147. // such fragment like `<></>` will be compiled into
  8148. // a fragment which doesn't have a children.
  8149. // In this case fallback to an empty array
  8150. n2.children || [],
  8151. container,
  8152. fragmentEndAnchor,
  8153. parentComponent,
  8154. parentSuspense,
  8155. namespace,
  8156. slotScopeIds,
  8157. optimized
  8158. );
  8159. } else {
  8160. if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
  8161. // of renderSlot() with no valid children
  8162. n1.dynamicChildren && n1.dynamicChildren.length === dynamicChildren.length) {
  8163. patchBlockChildren(
  8164. n1.dynamicChildren,
  8165. dynamicChildren,
  8166. container,
  8167. parentComponent,
  8168. parentSuspense,
  8169. namespace,
  8170. slotScopeIds
  8171. );
  8172. {
  8173. traverseStaticChildren(n1, n2);
  8174. }
  8175. } else {
  8176. patchChildren(
  8177. n1,
  8178. n2,
  8179. container,
  8180. fragmentEndAnchor,
  8181. parentComponent,
  8182. parentSuspense,
  8183. namespace,
  8184. slotScopeIds,
  8185. optimized
  8186. );
  8187. }
  8188. }
  8189. };
  8190. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  8191. n2.slotScopeIds = slotScopeIds;
  8192. if (n1 == null) {
  8193. if (n2.shapeFlag & 512) {
  8194. parentComponent.ctx.activate(
  8195. n2,
  8196. container,
  8197. anchor,
  8198. namespace,
  8199. optimized
  8200. );
  8201. } else {
  8202. mountComponent(
  8203. n2,
  8204. container,
  8205. anchor,
  8206. parentComponent,
  8207. parentSuspense,
  8208. namespace,
  8209. optimized
  8210. );
  8211. }
  8212. } else {
  8213. updateComponent(n1, n2, optimized);
  8214. }
  8215. };
  8216. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
  8217. const instance = (initialVNode.component = createComponentInstance(
  8218. initialVNode,
  8219. parentComponent,
  8220. parentSuspense
  8221. ));
  8222. if (instance.type.__hmrId) {
  8223. registerHMR(instance);
  8224. }
  8225. {
  8226. pushWarningContext(initialVNode);
  8227. startMeasure(instance, `mount`);
  8228. }
  8229. if (isKeepAlive(initialVNode)) {
  8230. instance.ctx.renderer = internals;
  8231. }
  8232. {
  8233. {
  8234. startMeasure(instance, `init`);
  8235. }
  8236. setupComponent(instance, false, optimized);
  8237. {
  8238. endMeasure(instance, `init`);
  8239. }
  8240. }
  8241. if (isHmrUpdating) initialVNode.el = null;
  8242. if (instance.asyncDep) {
  8243. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
  8244. if (!initialVNode.el) {
  8245. const placeholder = instance.subTree = createVNode(Comment);
  8246. processCommentNode(null, placeholder, container, anchor);
  8247. initialVNode.placeholder = placeholder.el;
  8248. }
  8249. } else {
  8250. setupRenderEffect(
  8251. instance,
  8252. initialVNode,
  8253. container,
  8254. anchor,
  8255. parentSuspense,
  8256. namespace,
  8257. optimized
  8258. );
  8259. }
  8260. {
  8261. popWarningContext();
  8262. endMeasure(instance, `mount`);
  8263. }
  8264. };
  8265. const updateComponent = (n1, n2, optimized) => {
  8266. const instance = n2.component = n1.component;
  8267. if (shouldUpdateComponent(n1, n2, optimized)) {
  8268. if (instance.asyncDep && !instance.asyncResolved) {
  8269. {
  8270. pushWarningContext(n2);
  8271. }
  8272. updateComponentPreRender(instance, n2, optimized);
  8273. {
  8274. popWarningContext();
  8275. }
  8276. return;
  8277. } else {
  8278. instance.next = n2;
  8279. instance.update();
  8280. }
  8281. } else {
  8282. n2.el = n1.el;
  8283. instance.vnode = n2;
  8284. }
  8285. };
  8286. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
  8287. const componentUpdateFn = () => {
  8288. if (!instance.isMounted) {
  8289. let vnodeHook;
  8290. const { el, props } = initialVNode;
  8291. const { bm, m, parent, root, type } = instance;
  8292. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  8293. toggleRecurse(instance, false);
  8294. if (bm) {
  8295. invokeArrayFns(bm);
  8296. }
  8297. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
  8298. invokeVNodeHook(vnodeHook, parent, initialVNode);
  8299. }
  8300. toggleRecurse(instance, true);
  8301. if (el && hydrateNode) {
  8302. const hydrateSubTree = () => {
  8303. {
  8304. startMeasure(instance, `render`);
  8305. }
  8306. instance.subTree = renderComponentRoot(instance);
  8307. {
  8308. endMeasure(instance, `render`);
  8309. }
  8310. {
  8311. startMeasure(instance, `hydrate`);
  8312. }
  8313. hydrateNode(
  8314. el,
  8315. instance.subTree,
  8316. instance,
  8317. parentSuspense,
  8318. null
  8319. );
  8320. {
  8321. endMeasure(instance, `hydrate`);
  8322. }
  8323. };
  8324. if (isAsyncWrapperVNode && type.__asyncHydrate) {
  8325. type.__asyncHydrate(
  8326. el,
  8327. instance,
  8328. hydrateSubTree
  8329. );
  8330. } else {
  8331. hydrateSubTree();
  8332. }
  8333. } else {
  8334. if (root.ce && root.ce._hasShadowRoot()) {
  8335. root.ce._injectChildStyle(
  8336. type,
  8337. instance.parent ? instance.parent.type : void 0
  8338. );
  8339. }
  8340. {
  8341. startMeasure(instance, `render`);
  8342. }
  8343. const subTree = instance.subTree = renderComponentRoot(instance);
  8344. {
  8345. endMeasure(instance, `render`);
  8346. }
  8347. {
  8348. startMeasure(instance, `patch`);
  8349. }
  8350. patch(
  8351. null,
  8352. subTree,
  8353. container,
  8354. anchor,
  8355. instance,
  8356. parentSuspense,
  8357. namespace
  8358. );
  8359. {
  8360. endMeasure(instance, `patch`);
  8361. }
  8362. initialVNode.el = subTree.el;
  8363. }
  8364. if (m) {
  8365. queuePostRenderEffect(m, parentSuspense);
  8366. }
  8367. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  8368. const scopedInitialVNode = initialVNode;
  8369. queuePostRenderEffect(
  8370. () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
  8371. parentSuspense
  8372. );
  8373. }
  8374. if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
  8375. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  8376. }
  8377. instance.isMounted = true;
  8378. {
  8379. devtoolsComponentAdded(instance);
  8380. }
  8381. initialVNode = container = anchor = null;
  8382. } else {
  8383. let { next, bu, u, parent, vnode } = instance;
  8384. {
  8385. const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
  8386. if (nonHydratedAsyncRoot) {
  8387. if (next) {
  8388. next.el = vnode.el;
  8389. updateComponentPreRender(instance, next, optimized);
  8390. }
  8391. nonHydratedAsyncRoot.asyncDep.then(() => {
  8392. queuePostRenderEffect(() => {
  8393. if (!instance.isUnmounted) update();
  8394. }, parentSuspense);
  8395. });
  8396. return;
  8397. }
  8398. }
  8399. let originNext = next;
  8400. let vnodeHook;
  8401. {
  8402. pushWarningContext(next || instance.vnode);
  8403. }
  8404. toggleRecurse(instance, false);
  8405. if (next) {
  8406. next.el = vnode.el;
  8407. updateComponentPreRender(instance, next, optimized);
  8408. } else {
  8409. next = vnode;
  8410. }
  8411. if (bu) {
  8412. invokeArrayFns(bu);
  8413. }
  8414. if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
  8415. invokeVNodeHook(vnodeHook, parent, next, vnode);
  8416. }
  8417. toggleRecurse(instance, true);
  8418. {
  8419. startMeasure(instance, `render`);
  8420. }
  8421. const nextTree = renderComponentRoot(instance);
  8422. {
  8423. endMeasure(instance, `render`);
  8424. }
  8425. const prevTree = instance.subTree;
  8426. instance.subTree = nextTree;
  8427. {
  8428. startMeasure(instance, `patch`);
  8429. }
  8430. patch(
  8431. prevTree,
  8432. nextTree,
  8433. // parent may have changed if it's in a teleport
  8434. hostParentNode(prevTree.el),
  8435. // anchor may have changed if it's in a fragment
  8436. getNextHostNode(prevTree),
  8437. instance,
  8438. parentSuspense,
  8439. namespace
  8440. );
  8441. {
  8442. endMeasure(instance, `patch`);
  8443. }
  8444. next.el = nextTree.el;
  8445. if (originNext === null) {
  8446. updateHOCHostEl(instance, nextTree.el);
  8447. }
  8448. if (u) {
  8449. queuePostRenderEffect(u, parentSuspense);
  8450. }
  8451. if (vnodeHook = next.props && next.props.onVnodeUpdated) {
  8452. queuePostRenderEffect(
  8453. () => invokeVNodeHook(vnodeHook, parent, next, vnode),
  8454. parentSuspense
  8455. );
  8456. }
  8457. {
  8458. devtoolsComponentUpdated(instance);
  8459. }
  8460. {
  8461. popWarningContext();
  8462. }
  8463. }
  8464. };
  8465. instance.scope.on();
  8466. const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
  8467. instance.scope.off();
  8468. const update = instance.update = effect.run.bind(effect);
  8469. const job = instance.job = effect.runIfDirty.bind(effect);
  8470. job.i = instance;
  8471. job.id = instance.uid;
  8472. effect.scheduler = () => queueJob(job);
  8473. toggleRecurse(instance, true);
  8474. {
  8475. effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
  8476. effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
  8477. }
  8478. update();
  8479. };
  8480. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  8481. nextVNode.component = instance;
  8482. const prevProps = instance.vnode.props;
  8483. instance.vnode = nextVNode;
  8484. instance.next = null;
  8485. updateProps(instance, nextVNode.props, prevProps, optimized);
  8486. updateSlots(instance, nextVNode.children, optimized);
  8487. pauseTracking();
  8488. flushPreFlushCbs(instance);
  8489. resetTracking();
  8490. };
  8491. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
  8492. const c1 = n1 && n1.children;
  8493. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  8494. const c2 = n2.children;
  8495. const { patchFlag, shapeFlag } = n2;
  8496. if (patchFlag > 0) {
  8497. if (patchFlag & 128) {
  8498. patchKeyedChildren(
  8499. c1,
  8500. c2,
  8501. container,
  8502. anchor,
  8503. parentComponent,
  8504. parentSuspense,
  8505. namespace,
  8506. slotScopeIds,
  8507. optimized
  8508. );
  8509. return;
  8510. } else if (patchFlag & 256) {
  8511. patchUnkeyedChildren(
  8512. c1,
  8513. c2,
  8514. container,
  8515. anchor,
  8516. parentComponent,
  8517. parentSuspense,
  8518. namespace,
  8519. slotScopeIds,
  8520. optimized
  8521. );
  8522. return;
  8523. }
  8524. }
  8525. if (shapeFlag & 8) {
  8526. if (prevShapeFlag & 16) {
  8527. unmountChildren(c1, parentComponent, parentSuspense);
  8528. }
  8529. if (c2 !== c1) {
  8530. hostSetElementText(container, c2);
  8531. }
  8532. } else {
  8533. if (prevShapeFlag & 16) {
  8534. if (shapeFlag & 16) {
  8535. patchKeyedChildren(
  8536. c1,
  8537. c2,
  8538. container,
  8539. anchor,
  8540. parentComponent,
  8541. parentSuspense,
  8542. namespace,
  8543. slotScopeIds,
  8544. optimized
  8545. );
  8546. } else {
  8547. unmountChildren(c1, parentComponent, parentSuspense, true);
  8548. }
  8549. } else {
  8550. if (prevShapeFlag & 8) {
  8551. hostSetElementText(container, "");
  8552. }
  8553. if (shapeFlag & 16) {
  8554. mountChildren(
  8555. c2,
  8556. container,
  8557. anchor,
  8558. parentComponent,
  8559. parentSuspense,
  8560. namespace,
  8561. slotScopeIds,
  8562. optimized
  8563. );
  8564. }
  8565. }
  8566. }
  8567. };
  8568. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  8569. c1 = c1 || EMPTY_ARR;
  8570. c2 = c2 || EMPTY_ARR;
  8571. const oldLength = c1.length;
  8572. const newLength = c2.length;
  8573. const commonLength = Math.min(oldLength, newLength);
  8574. let i;
  8575. for (i = 0; i < commonLength; i++) {
  8576. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  8577. patch(
  8578. c1[i],
  8579. nextChild,
  8580. container,
  8581. null,
  8582. parentComponent,
  8583. parentSuspense,
  8584. namespace,
  8585. slotScopeIds,
  8586. optimized
  8587. );
  8588. }
  8589. if (oldLength > newLength) {
  8590. unmountChildren(
  8591. c1,
  8592. parentComponent,
  8593. parentSuspense,
  8594. true,
  8595. false,
  8596. commonLength
  8597. );
  8598. } else {
  8599. mountChildren(
  8600. c2,
  8601. container,
  8602. anchor,
  8603. parentComponent,
  8604. parentSuspense,
  8605. namespace,
  8606. slotScopeIds,
  8607. optimized,
  8608. commonLength
  8609. );
  8610. }
  8611. };
  8612. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
  8613. let i = 0;
  8614. const l2 = c2.length;
  8615. let e1 = c1.length - 1;
  8616. let e2 = l2 - 1;
  8617. while (i <= e1 && i <= e2) {
  8618. const n1 = c1[i];
  8619. const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  8620. if (isSameVNodeType(n1, n2)) {
  8621. patch(
  8622. n1,
  8623. n2,
  8624. container,
  8625. null,
  8626. parentComponent,
  8627. parentSuspense,
  8628. namespace,
  8629. slotScopeIds,
  8630. optimized
  8631. );
  8632. } else {
  8633. break;
  8634. }
  8635. i++;
  8636. }
  8637. while (i <= e1 && i <= e2) {
  8638. const n1 = c1[e1];
  8639. const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
  8640. if (isSameVNodeType(n1, n2)) {
  8641. patch(
  8642. n1,
  8643. n2,
  8644. container,
  8645. null,
  8646. parentComponent,
  8647. parentSuspense,
  8648. namespace,
  8649. slotScopeIds,
  8650. optimized
  8651. );
  8652. } else {
  8653. break;
  8654. }
  8655. e1--;
  8656. e2--;
  8657. }
  8658. if (i > e1) {
  8659. if (i <= e2) {
  8660. const nextPos = e2 + 1;
  8661. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  8662. while (i <= e2) {
  8663. patch(
  8664. null,
  8665. c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
  8666. container,
  8667. anchor,
  8668. parentComponent,
  8669. parentSuspense,
  8670. namespace,
  8671. slotScopeIds,
  8672. optimized
  8673. );
  8674. i++;
  8675. }
  8676. }
  8677. } else if (i > e2) {
  8678. while (i <= e1) {
  8679. unmount(c1[i], parentComponent, parentSuspense, true);
  8680. i++;
  8681. }
  8682. } else {
  8683. const s1 = i;
  8684. const s2 = i;
  8685. const keyToNewIndexMap = /* @__PURE__ */ new Map();
  8686. for (i = s2; i <= e2; i++) {
  8687. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  8688. if (nextChild.key != null) {
  8689. if (keyToNewIndexMap.has(nextChild.key)) {
  8690. warn$1(
  8691. `Duplicate keys found during update:`,
  8692. JSON.stringify(nextChild.key),
  8693. `Make sure keys are unique.`
  8694. );
  8695. }
  8696. keyToNewIndexMap.set(nextChild.key, i);
  8697. }
  8698. }
  8699. let j;
  8700. let patched = 0;
  8701. const toBePatched = e2 - s2 + 1;
  8702. let moved = false;
  8703. let maxNewIndexSoFar = 0;
  8704. const newIndexToOldIndexMap = new Array(toBePatched);
  8705. for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
  8706. for (i = s1; i <= e1; i++) {
  8707. const prevChild = c1[i];
  8708. if (patched >= toBePatched) {
  8709. unmount(prevChild, parentComponent, parentSuspense, true);
  8710. continue;
  8711. }
  8712. let newIndex;
  8713. if (prevChild.key != null) {
  8714. newIndex = keyToNewIndexMap.get(prevChild.key);
  8715. } else {
  8716. for (j = s2; j <= e2; j++) {
  8717. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  8718. newIndex = j;
  8719. break;
  8720. }
  8721. }
  8722. }
  8723. if (newIndex === void 0) {
  8724. unmount(prevChild, parentComponent, parentSuspense, true);
  8725. } else {
  8726. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  8727. if (newIndex >= maxNewIndexSoFar) {
  8728. maxNewIndexSoFar = newIndex;
  8729. } else {
  8730. moved = true;
  8731. }
  8732. patch(
  8733. prevChild,
  8734. c2[newIndex],
  8735. container,
  8736. null,
  8737. parentComponent,
  8738. parentSuspense,
  8739. namespace,
  8740. slotScopeIds,
  8741. optimized
  8742. );
  8743. patched++;
  8744. }
  8745. }
  8746. const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
  8747. j = increasingNewIndexSequence.length - 1;
  8748. for (i = toBePatched - 1; i >= 0; i--) {
  8749. const nextIndex = s2 + i;
  8750. const nextChild = c2[nextIndex];
  8751. const anchorVNode = c2[nextIndex + 1];
  8752. const anchor = nextIndex + 1 < l2 ? (
  8753. // #13559, #14173 fallback to el placeholder for unresolved async component
  8754. anchorVNode.el || resolveAsyncComponentPlaceholder(anchorVNode)
  8755. ) : parentAnchor;
  8756. if (newIndexToOldIndexMap[i] === 0) {
  8757. patch(
  8758. null,
  8759. nextChild,
  8760. container,
  8761. anchor,
  8762. parentComponent,
  8763. parentSuspense,
  8764. namespace,
  8765. slotScopeIds,
  8766. optimized
  8767. );
  8768. } else if (moved) {
  8769. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  8770. move(nextChild, container, anchor, 2);
  8771. } else {
  8772. j--;
  8773. }
  8774. }
  8775. }
  8776. }
  8777. };
  8778. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  8779. const { el, type, transition, children, shapeFlag } = vnode;
  8780. if (shapeFlag & 6) {
  8781. move(vnode.component.subTree, container, anchor, moveType);
  8782. return;
  8783. }
  8784. if (shapeFlag & 128) {
  8785. vnode.suspense.move(container, anchor, moveType);
  8786. return;
  8787. }
  8788. if (shapeFlag & 64) {
  8789. type.move(vnode, container, anchor, internals);
  8790. return;
  8791. }
  8792. if (type === Fragment) {
  8793. hostInsert(el, container, anchor);
  8794. for (let i = 0; i < children.length; i++) {
  8795. move(children[i], container, anchor, moveType);
  8796. }
  8797. hostInsert(vnode.anchor, container, anchor);
  8798. return;
  8799. }
  8800. if (type === Static) {
  8801. moveStaticNode(vnode, container, anchor);
  8802. return;
  8803. }
  8804. const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
  8805. if (needTransition2) {
  8806. if (moveType === 0) {
  8807. if (transition.persisted && !el[leaveCbKey]) {
  8808. hostInsert(el, container, anchor);
  8809. } else {
  8810. transition.beforeEnter(el);
  8811. hostInsert(el, container, anchor);
  8812. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  8813. }
  8814. } else {
  8815. const { leave, delayLeave, afterLeave } = transition;
  8816. const remove2 = () => {
  8817. if (vnode.ctx.isUnmounted) {
  8818. hostRemove(el);
  8819. } else {
  8820. hostInsert(el, container, anchor);
  8821. }
  8822. };
  8823. const performLeave = () => {
  8824. const wasLeaving = el._isLeaving || !!el[leaveCbKey];
  8825. if (el._isLeaving) {
  8826. el[leaveCbKey](
  8827. true
  8828. /* cancelled */
  8829. );
  8830. }
  8831. if (transition.persisted && !wasLeaving) {
  8832. remove2();
  8833. } else {
  8834. leave(el, () => {
  8835. remove2();
  8836. afterLeave && afterLeave();
  8837. });
  8838. }
  8839. };
  8840. if (delayLeave) {
  8841. delayLeave(el, remove2, performLeave);
  8842. } else {
  8843. performLeave();
  8844. }
  8845. }
  8846. } else {
  8847. hostInsert(el, container, anchor);
  8848. }
  8849. };
  8850. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  8851. const {
  8852. type,
  8853. props,
  8854. ref,
  8855. children,
  8856. dynamicChildren,
  8857. shapeFlag,
  8858. patchFlag,
  8859. dirs,
  8860. cacheIndex,
  8861. memo
  8862. } = vnode;
  8863. if (patchFlag === -2) {
  8864. optimized = false;
  8865. }
  8866. if (ref != null) {
  8867. pauseTracking();
  8868. setRef(ref, null, parentSuspense, vnode, true);
  8869. resetTracking();
  8870. }
  8871. if (cacheIndex != null) {
  8872. parentComponent.renderCache[cacheIndex] = void 0;
  8873. }
  8874. if (shapeFlag & 256) {
  8875. parentComponent.ctx.deactivate(vnode);
  8876. return;
  8877. }
  8878. const shouldInvokeDirs = shapeFlag & 1 && dirs;
  8879. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  8880. let vnodeHook;
  8881. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  8882. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  8883. }
  8884. if (shapeFlag & 6) {
  8885. unmountComponent(vnode.component, parentSuspense, doRemove);
  8886. } else {
  8887. if (shapeFlag & 128) {
  8888. vnode.suspense.unmount(parentSuspense, doRemove);
  8889. return;
  8890. }
  8891. if (shouldInvokeDirs) {
  8892. invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
  8893. }
  8894. if (shapeFlag & 64) {
  8895. vnode.type.remove(
  8896. vnode,
  8897. parentComponent,
  8898. parentSuspense,
  8899. internals,
  8900. doRemove
  8901. );
  8902. } else if (dynamicChildren && // #5154
  8903. // when v-once is used inside a block, setBlockTracking(-1) marks the
  8904. // parent block with hasOnce: true
  8905. // so that it doesn't take the fast path during unmount - otherwise
  8906. // components nested in v-once are never unmounted.
  8907. !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
  8908. (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
  8909. unmountChildren(
  8910. dynamicChildren,
  8911. parentComponent,
  8912. parentSuspense,
  8913. false,
  8914. true
  8915. );
  8916. } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
  8917. unmountChildren(children, parentComponent, parentSuspense);
  8918. }
  8919. if (doRemove) {
  8920. remove(vnode);
  8921. }
  8922. }
  8923. const shouldInvalidateMemo = memo != null && cacheIndex == null;
  8924. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs || shouldInvalidateMemo) {
  8925. queuePostRenderEffect(() => {
  8926. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  8927. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
  8928. if (shouldInvalidateMemo) {
  8929. vnode.el = null;
  8930. }
  8931. }, parentSuspense);
  8932. }
  8933. };
  8934. const remove = (vnode) => {
  8935. const { type, el, anchor, transition } = vnode;
  8936. if (type === Fragment) {
  8937. if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
  8938. vnode.children.forEach((child) => {
  8939. if (child.type === Comment) {
  8940. hostRemove(child.el);
  8941. } else {
  8942. remove(child);
  8943. }
  8944. });
  8945. } else {
  8946. removeFragment(el, anchor);
  8947. }
  8948. return;
  8949. }
  8950. if (type === Static) {
  8951. removeStaticNode(vnode);
  8952. return;
  8953. }
  8954. const performRemove = () => {
  8955. hostRemove(el);
  8956. if (transition && !transition.persisted && transition.afterLeave) {
  8957. transition.afterLeave();
  8958. }
  8959. };
  8960. if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
  8961. const { leave, delayLeave } = transition;
  8962. const performLeave = () => leave(el, performRemove);
  8963. if (delayLeave) {
  8964. delayLeave(vnode.el, performRemove, performLeave);
  8965. } else {
  8966. performLeave();
  8967. }
  8968. } else {
  8969. performRemove();
  8970. }
  8971. };
  8972. const removeFragment = (cur, end) => {
  8973. let next;
  8974. while (cur !== end) {
  8975. next = hostNextSibling(cur);
  8976. hostRemove(cur);
  8977. cur = next;
  8978. }
  8979. hostRemove(end);
  8980. };
  8981. const unmountComponent = (instance, parentSuspense, doRemove) => {
  8982. if (instance.type.__hmrId) {
  8983. unregisterHMR(instance);
  8984. }
  8985. const { bum, scope, job, subTree, um, m, a } = instance;
  8986. invalidateMount(m);
  8987. invalidateMount(a);
  8988. if (bum) {
  8989. invokeArrayFns(bum);
  8990. }
  8991. scope.stop();
  8992. if (job) {
  8993. job.flags |= 8;
  8994. unmount(subTree, instance, parentSuspense, doRemove);
  8995. }
  8996. if (um) {
  8997. queuePostRenderEffect(um, parentSuspense);
  8998. }
  8999. queuePostRenderEffect(() => {
  9000. instance.isUnmounted = true;
  9001. }, parentSuspense);
  9002. {
  9003. devtoolsComponentRemoved(instance);
  9004. }
  9005. };
  9006. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  9007. for (let i = start; i < children.length; i++) {
  9008. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  9009. }
  9010. };
  9011. const getNextHostNode = (vnode) => {
  9012. if (vnode.shapeFlag & 6) {
  9013. return getNextHostNode(vnode.component.subTree);
  9014. }
  9015. if (vnode.shapeFlag & 128) {
  9016. return vnode.suspense.next();
  9017. }
  9018. const el = hostNextSibling(vnode.anchor || vnode.el);
  9019. const teleportEnd = el && el[TeleportEndKey];
  9020. return teleportEnd ? hostNextSibling(teleportEnd) : el;
  9021. };
  9022. let isFlushing = false;
  9023. const render = (vnode, container, namespace) => {
  9024. let instance;
  9025. if (vnode == null) {
  9026. if (container._vnode) {
  9027. unmount(container._vnode, null, null, true);
  9028. instance = container._vnode.component;
  9029. }
  9030. } else {
  9031. patch(
  9032. container._vnode || null,
  9033. vnode,
  9034. container,
  9035. null,
  9036. null,
  9037. null,
  9038. namespace
  9039. );
  9040. }
  9041. container._vnode = vnode;
  9042. if (!isFlushing) {
  9043. isFlushing = true;
  9044. flushPreFlushCbs(instance);
  9045. flushPostFlushCbs();
  9046. isFlushing = false;
  9047. }
  9048. };
  9049. const internals = {
  9050. p: patch,
  9051. um: unmount,
  9052. m: move,
  9053. r: remove,
  9054. mt: mountComponent,
  9055. mc: mountChildren,
  9056. pc: patchChildren,
  9057. pbc: patchBlockChildren,
  9058. n: getNextHostNode,
  9059. o: options
  9060. };
  9061. let hydrate;
  9062. let hydrateNode;
  9063. if (createHydrationFns) {
  9064. [hydrate, hydrateNode] = createHydrationFns(
  9065. internals
  9066. );
  9067. }
  9068. return {
  9069. render,
  9070. hydrate,
  9071. createApp: createAppAPI(render, hydrate)
  9072. };
  9073. }
  9074. function resolveChildrenNamespace({ type, props }, currentNamespace) {
  9075. return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
  9076. }
  9077. function toggleRecurse({ effect, job }, allowed) {
  9078. if (allowed) {
  9079. effect.flags |= 32;
  9080. job.flags |= 4;
  9081. } else {
  9082. effect.flags &= -33;
  9083. job.flags &= -5;
  9084. }
  9085. }
  9086. function needTransition(parentSuspense, transition) {
  9087. return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
  9088. }
  9089. function traverseStaticChildren(n1, n2, shallow = false) {
  9090. const ch1 = n1.children;
  9091. const ch2 = n2.children;
  9092. if (isArray(ch1) && isArray(ch2)) {
  9093. for (let i = 0; i < ch1.length; i++) {
  9094. const c1 = ch1[i];
  9095. let c2 = ch2[i];
  9096. if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
  9097. if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
  9098. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  9099. c2.el = c1.el;
  9100. }
  9101. if (!shallow && c2.patchFlag !== -2)
  9102. traverseStaticChildren(c1, c2);
  9103. }
  9104. if (c2.type === Text) {
  9105. if (c2.patchFlag === -1) {
  9106. c2 = ch2[i] = cloneIfMounted(c2);
  9107. }
  9108. c2.el = c1.el;
  9109. }
  9110. if (c2.type === Comment && !c2.el) {
  9111. c2.el = c1.el;
  9112. }
  9113. {
  9114. c2.el && (c2.el.__vnode = c2);
  9115. }
  9116. }
  9117. }
  9118. }
  9119. function getSequence(arr) {
  9120. const p = arr.slice();
  9121. const result = [0];
  9122. let i, j, u, v, c;
  9123. const len = arr.length;
  9124. for (i = 0; i < len; i++) {
  9125. const arrI = arr[i];
  9126. if (arrI !== 0) {
  9127. j = result[result.length - 1];
  9128. if (arr[j] < arrI) {
  9129. p[i] = j;
  9130. result.push(i);
  9131. continue;
  9132. }
  9133. u = 0;
  9134. v = result.length - 1;
  9135. while (u < v) {
  9136. c = u + v >> 1;
  9137. if (arr[result[c]] < arrI) {
  9138. u = c + 1;
  9139. } else {
  9140. v = c;
  9141. }
  9142. }
  9143. if (arrI < arr[result[u]]) {
  9144. if (u > 0) {
  9145. p[i] = result[u - 1];
  9146. }
  9147. result[u] = i;
  9148. }
  9149. }
  9150. }
  9151. u = result.length;
  9152. v = result[u - 1];
  9153. while (u-- > 0) {
  9154. result[u] = v;
  9155. v = p[v];
  9156. }
  9157. return result;
  9158. }
  9159. function locateNonHydratedAsyncRoot(instance) {
  9160. const subComponent = instance.subTree.component;
  9161. if (subComponent) {
  9162. if (subComponent.asyncDep && !subComponent.asyncResolved) {
  9163. return subComponent;
  9164. } else {
  9165. return locateNonHydratedAsyncRoot(subComponent);
  9166. }
  9167. }
  9168. }
  9169. function invalidateMount(hooks) {
  9170. if (hooks) {
  9171. for (let i = 0; i < hooks.length; i++)
  9172. hooks[i].flags |= 8;
  9173. }
  9174. }
  9175. function resolveAsyncComponentPlaceholder(anchorVnode) {
  9176. if (anchorVnode.placeholder) {
  9177. return anchorVnode.placeholder;
  9178. }
  9179. const instance = anchorVnode.component;
  9180. if (instance) {
  9181. return resolveAsyncComponentPlaceholder(instance.subTree);
  9182. }
  9183. return null;
  9184. }
  9185. const isSuspense = (type) => type.__isSuspense;
  9186. let suspenseId = 0;
  9187. const SuspenseImpl = {
  9188. name: "Suspense",
  9189. // In order to make Suspense tree-shakable, we need to avoid importing it
  9190. // directly in the renderer. The renderer checks for the __isSuspense flag
  9191. // on a vnode's type and calls the `process` method, passing in renderer
  9192. // internals.
  9193. __isSuspense: true,
  9194. process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
  9195. if (n1 == null) {
  9196. mountSuspense(
  9197. n2,
  9198. container,
  9199. anchor,
  9200. parentComponent,
  9201. parentSuspense,
  9202. namespace,
  9203. slotScopeIds,
  9204. optimized,
  9205. rendererInternals
  9206. );
  9207. } else {
  9208. if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
  9209. n2.suspense = n1.suspense;
  9210. n2.suspense.vnode = n2;
  9211. n2.el = n1.el;
  9212. return;
  9213. }
  9214. patchSuspense(
  9215. n1,
  9216. n2,
  9217. container,
  9218. anchor,
  9219. parentComponent,
  9220. namespace,
  9221. slotScopeIds,
  9222. optimized,
  9223. rendererInternals
  9224. );
  9225. }
  9226. },
  9227. hydrate: hydrateSuspense,
  9228. normalize: normalizeSuspenseChildren
  9229. };
  9230. const Suspense = SuspenseImpl ;
  9231. function triggerEvent(vnode, name) {
  9232. const eventListener = vnode.props && vnode.props[name];
  9233. if (isFunction(eventListener)) {
  9234. eventListener();
  9235. }
  9236. }
  9237. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
  9238. const {
  9239. p: patch,
  9240. o: { createElement }
  9241. } = rendererInternals;
  9242. const hiddenContainer = createElement("div");
  9243. const suspense = vnode.suspense = createSuspenseBoundary(
  9244. vnode,
  9245. parentSuspense,
  9246. parentComponent,
  9247. container,
  9248. hiddenContainer,
  9249. anchor,
  9250. namespace,
  9251. slotScopeIds,
  9252. optimized,
  9253. rendererInternals
  9254. );
  9255. patch(
  9256. null,
  9257. suspense.pendingBranch = vnode.ssContent,
  9258. hiddenContainer,
  9259. null,
  9260. parentComponent,
  9261. suspense,
  9262. namespace,
  9263. slotScopeIds
  9264. );
  9265. if (suspense.deps > 0) {
  9266. triggerEvent(vnode, "onPending");
  9267. triggerEvent(vnode, "onFallback");
  9268. patch(
  9269. null,
  9270. vnode.ssFallback,
  9271. container,
  9272. anchor,
  9273. parentComponent,
  9274. null,
  9275. // fallback tree will not have suspense context
  9276. namespace,
  9277. slotScopeIds
  9278. );
  9279. setActiveBranch(suspense, vnode.ssFallback);
  9280. } else {
  9281. suspense.resolve(false, true);
  9282. }
  9283. }
  9284. function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  9285. const suspense = n2.suspense = n1.suspense;
  9286. suspense.vnode = n2;
  9287. n2.el = n1.el;
  9288. const newBranch = n2.ssContent;
  9289. const newFallback = n2.ssFallback;
  9290. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  9291. if (pendingBranch) {
  9292. suspense.pendingBranch = newBranch;
  9293. if (isSameVNodeType(pendingBranch, newBranch)) {
  9294. patch(
  9295. pendingBranch,
  9296. newBranch,
  9297. suspense.hiddenContainer,
  9298. null,
  9299. parentComponent,
  9300. suspense,
  9301. namespace,
  9302. slotScopeIds,
  9303. optimized
  9304. );
  9305. if (suspense.deps <= 0) {
  9306. suspense.resolve();
  9307. } else if (isInFallback) {
  9308. if (!isHydrating) {
  9309. patch(
  9310. activeBranch,
  9311. newFallback,
  9312. container,
  9313. anchor,
  9314. parentComponent,
  9315. null,
  9316. // fallback tree will not have suspense context
  9317. namespace,
  9318. slotScopeIds,
  9319. optimized
  9320. );
  9321. setActiveBranch(suspense, newFallback);
  9322. }
  9323. }
  9324. } else {
  9325. suspense.pendingId = suspenseId++;
  9326. if (isHydrating) {
  9327. suspense.isHydrating = false;
  9328. suspense.activeBranch = pendingBranch;
  9329. } else {
  9330. unmount(pendingBranch, parentComponent, suspense);
  9331. }
  9332. suspense.deps = 0;
  9333. suspense.effects.length = 0;
  9334. suspense.hiddenContainer = createElement("div");
  9335. if (isInFallback) {
  9336. patch(
  9337. null,
  9338. newBranch,
  9339. suspense.hiddenContainer,
  9340. null,
  9341. parentComponent,
  9342. suspense,
  9343. namespace,
  9344. slotScopeIds,
  9345. optimized
  9346. );
  9347. if (suspense.deps <= 0) {
  9348. suspense.resolve();
  9349. } else {
  9350. patch(
  9351. activeBranch,
  9352. newFallback,
  9353. container,
  9354. anchor,
  9355. parentComponent,
  9356. null,
  9357. // fallback tree will not have suspense context
  9358. namespace,
  9359. slotScopeIds,
  9360. optimized
  9361. );
  9362. setActiveBranch(suspense, newFallback);
  9363. }
  9364. } else if (activeBranch && isSameVNodeType(activeBranch, newBranch)) {
  9365. patch(
  9366. activeBranch,
  9367. newBranch,
  9368. container,
  9369. anchor,
  9370. parentComponent,
  9371. suspense,
  9372. namespace,
  9373. slotScopeIds,
  9374. optimized
  9375. );
  9376. suspense.resolve(true);
  9377. } else {
  9378. patch(
  9379. null,
  9380. newBranch,
  9381. suspense.hiddenContainer,
  9382. null,
  9383. parentComponent,
  9384. suspense,
  9385. namespace,
  9386. slotScopeIds,
  9387. optimized
  9388. );
  9389. if (suspense.deps <= 0) {
  9390. suspense.resolve();
  9391. }
  9392. }
  9393. }
  9394. } else {
  9395. if (activeBranch && isSameVNodeType(activeBranch, newBranch)) {
  9396. patch(
  9397. activeBranch,
  9398. newBranch,
  9399. container,
  9400. anchor,
  9401. parentComponent,
  9402. suspense,
  9403. namespace,
  9404. slotScopeIds,
  9405. optimized
  9406. );
  9407. setActiveBranch(suspense, newBranch);
  9408. } else {
  9409. triggerEvent(n2, "onPending");
  9410. suspense.pendingBranch = newBranch;
  9411. if (newBranch.shapeFlag & 512) {
  9412. suspense.pendingId = newBranch.component.suspenseId;
  9413. } else {
  9414. suspense.pendingId = suspenseId++;
  9415. }
  9416. patch(
  9417. null,
  9418. newBranch,
  9419. suspense.hiddenContainer,
  9420. null,
  9421. parentComponent,
  9422. suspense,
  9423. namespace,
  9424. slotScopeIds,
  9425. optimized
  9426. );
  9427. if (suspense.deps <= 0) {
  9428. suspense.resolve();
  9429. } else {
  9430. const { timeout, pendingId } = suspense;
  9431. if (timeout > 0) {
  9432. setTimeout(() => {
  9433. if (suspense.pendingId === pendingId) {
  9434. suspense.fallback(newFallback);
  9435. }
  9436. }, timeout);
  9437. } else if (timeout === 0) {
  9438. suspense.fallback(newFallback);
  9439. }
  9440. }
  9441. }
  9442. }
  9443. }
  9444. let hasWarned = false;
  9445. function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  9446. if (!hasWarned) {
  9447. hasWarned = true;
  9448. console[console.info ? "info" : "log"](
  9449. `<Suspense> is an experimental feature and its API will likely change.`
  9450. );
  9451. }
  9452. const {
  9453. p: patch,
  9454. m: move,
  9455. um: unmount,
  9456. n: next,
  9457. o: { parentNode, remove }
  9458. } = rendererInternals;
  9459. let parentSuspenseId;
  9460. const isSuspensible = isVNodeSuspensible(vnode);
  9461. if (isSuspensible) {
  9462. if (parentSuspense && parentSuspense.pendingBranch) {
  9463. parentSuspenseId = parentSuspense.pendingId;
  9464. parentSuspense.deps++;
  9465. }
  9466. }
  9467. const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
  9468. {
  9469. assertNumber(timeout, `Suspense timeout`);
  9470. }
  9471. const initialAnchor = anchor;
  9472. const suspense = {
  9473. vnode,
  9474. parent: parentSuspense,
  9475. parentComponent,
  9476. namespace,
  9477. container,
  9478. hiddenContainer,
  9479. deps: 0,
  9480. pendingId: suspenseId++,
  9481. timeout: typeof timeout === "number" ? timeout : -1,
  9482. activeBranch: null,
  9483. isFallbackMountPending: false,
  9484. pendingBranch: null,
  9485. isInFallback: !isHydrating,
  9486. isHydrating,
  9487. isUnmounted: false,
  9488. effects: [],
  9489. resolve(resume = false, sync = false) {
  9490. {
  9491. if (!resume && !suspense.pendingBranch) {
  9492. throw new Error(
  9493. `suspense.resolve() is called without a pending branch.`
  9494. );
  9495. }
  9496. if (suspense.isUnmounted) {
  9497. throw new Error(
  9498. `suspense.resolve() is called on an already unmounted suspense boundary.`
  9499. );
  9500. }
  9501. }
  9502. const {
  9503. vnode: vnode2,
  9504. activeBranch,
  9505. pendingBranch,
  9506. pendingId,
  9507. effects,
  9508. parentComponent: parentComponent2,
  9509. container: container2,
  9510. isInFallback
  9511. } = suspense;
  9512. let delayEnter = false;
  9513. if (suspense.isHydrating) {
  9514. suspense.isHydrating = false;
  9515. } else if (!resume) {
  9516. delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
  9517. let hasUpdatedAnchor = false;
  9518. if (delayEnter) {
  9519. activeBranch.transition.afterLeave = () => {
  9520. if (pendingId === suspense.pendingId) {
  9521. move(
  9522. pendingBranch,
  9523. container2,
  9524. anchor === initialAnchor && !hasUpdatedAnchor ? next(activeBranch) : anchor,
  9525. 0
  9526. );
  9527. queuePostFlushCb(effects);
  9528. if (isInFallback && vnode2.ssFallback) {
  9529. vnode2.ssFallback.el = null;
  9530. }
  9531. }
  9532. };
  9533. }
  9534. if (activeBranch && !suspense.isFallbackMountPending) {
  9535. if (parentNode(activeBranch.el) === container2) {
  9536. anchor = next(activeBranch);
  9537. hasUpdatedAnchor = true;
  9538. }
  9539. unmount(activeBranch, parentComponent2, suspense, true);
  9540. if (!delayEnter && isInFallback && vnode2.ssFallback) {
  9541. queuePostRenderEffect(() => vnode2.ssFallback.el = null, suspense);
  9542. }
  9543. }
  9544. if (!delayEnter) {
  9545. move(pendingBranch, container2, anchor, 0);
  9546. }
  9547. }
  9548. suspense.isFallbackMountPending = false;
  9549. setActiveBranch(suspense, pendingBranch);
  9550. suspense.pendingBranch = null;
  9551. suspense.isInFallback = false;
  9552. let parent = suspense.parent;
  9553. let hasUnresolvedAncestor = false;
  9554. while (parent) {
  9555. if (parent.pendingBranch) {
  9556. parent.effects.push(...effects);
  9557. hasUnresolvedAncestor = true;
  9558. break;
  9559. }
  9560. parent = parent.parent;
  9561. }
  9562. if (!hasUnresolvedAncestor && !delayEnter) {
  9563. queuePostFlushCb(effects);
  9564. }
  9565. suspense.effects = [];
  9566. if (isSuspensible) {
  9567. if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
  9568. parentSuspense.deps--;
  9569. if (parentSuspense.deps === 0 && !sync) {
  9570. parentSuspense.resolve();
  9571. }
  9572. }
  9573. }
  9574. triggerEvent(vnode2, "onResolve");
  9575. },
  9576. fallback(fallbackVNode) {
  9577. if (!suspense.pendingBranch) {
  9578. return;
  9579. }
  9580. const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
  9581. triggerEvent(vnode2, "onFallback");
  9582. const anchor2 = next(activeBranch);
  9583. const mountFallback = () => {
  9584. suspense.isFallbackMountPending = false;
  9585. if (!suspense.isInFallback) {
  9586. return;
  9587. }
  9588. patch(
  9589. null,
  9590. fallbackVNode,
  9591. container2,
  9592. anchor2,
  9593. parentComponent2,
  9594. null,
  9595. // fallback tree will not have suspense context
  9596. namespace2,
  9597. slotScopeIds,
  9598. optimized
  9599. );
  9600. setActiveBranch(suspense, fallbackVNode);
  9601. };
  9602. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
  9603. if (delayEnter) {
  9604. suspense.isFallbackMountPending = true;
  9605. activeBranch.transition.afterLeave = mountFallback;
  9606. }
  9607. suspense.isInFallback = true;
  9608. unmount(
  9609. activeBranch,
  9610. parentComponent2,
  9611. null,
  9612. // no suspense so unmount hooks fire now
  9613. true
  9614. // shouldRemove
  9615. );
  9616. if (!delayEnter) {
  9617. mountFallback();
  9618. }
  9619. },
  9620. move(container2, anchor2, type) {
  9621. suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
  9622. suspense.container = container2;
  9623. },
  9624. next() {
  9625. return suspense.activeBranch && next(suspense.activeBranch);
  9626. },
  9627. registerDep(instance, setupRenderEffect, optimized2) {
  9628. const isInPendingSuspense = !!suspense.pendingBranch;
  9629. if (isInPendingSuspense) {
  9630. suspense.deps++;
  9631. }
  9632. const hydratedEl = instance.vnode.el;
  9633. instance.asyncDep.catch((err) => {
  9634. handleError(err, instance, 0);
  9635. }).then((asyncSetupResult) => {
  9636. if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
  9637. return;
  9638. }
  9639. unsetCurrentInstance();
  9640. instance.asyncResolved = true;
  9641. const { vnode: vnode2 } = instance;
  9642. {
  9643. pushWarningContext(vnode2);
  9644. }
  9645. handleSetupResult(instance, asyncSetupResult, false);
  9646. if (hydratedEl) {
  9647. vnode2.el = hydratedEl;
  9648. }
  9649. const placeholder = !hydratedEl && instance.subTree.el;
  9650. setupRenderEffect(
  9651. instance,
  9652. vnode2,
  9653. // component may have been moved before resolve.
  9654. // if this is not a hydration, instance.subTree will be the comment
  9655. // placeholder.
  9656. parentNode(hydratedEl || instance.subTree.el),
  9657. // anchor will not be used if this is hydration, so only need to
  9658. // consider the comment placeholder case.
  9659. hydratedEl ? null : next(instance.subTree),
  9660. suspense,
  9661. namespace,
  9662. optimized2
  9663. );
  9664. if (placeholder) {
  9665. vnode2.placeholder = null;
  9666. remove(placeholder);
  9667. }
  9668. updateHOCHostEl(instance, vnode2.el);
  9669. {
  9670. popWarningContext();
  9671. }
  9672. if (isInPendingSuspense && --suspense.deps === 0) {
  9673. suspense.resolve();
  9674. }
  9675. });
  9676. },
  9677. unmount(parentSuspense2, doRemove) {
  9678. suspense.isUnmounted = true;
  9679. if (suspense.activeBranch) {
  9680. unmount(
  9681. suspense.activeBranch,
  9682. parentComponent,
  9683. parentSuspense2,
  9684. doRemove
  9685. );
  9686. }
  9687. if (suspense.pendingBranch) {
  9688. unmount(
  9689. suspense.pendingBranch,
  9690. parentComponent,
  9691. parentSuspense2,
  9692. doRemove
  9693. );
  9694. }
  9695. }
  9696. };
  9697. return suspense;
  9698. }
  9699. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  9700. const suspense = vnode.suspense = createSuspenseBoundary(
  9701. vnode,
  9702. parentSuspense,
  9703. parentComponent,
  9704. node.parentNode,
  9705. // eslint-disable-next-line no-restricted-globals
  9706. document.createElement("div"),
  9707. null,
  9708. namespace,
  9709. slotScopeIds,
  9710. optimized,
  9711. rendererInternals,
  9712. true
  9713. );
  9714. const result = hydrateNode(
  9715. node,
  9716. suspense.pendingBranch = vnode.ssContent,
  9717. parentComponent,
  9718. suspense,
  9719. slotScopeIds,
  9720. optimized
  9721. );
  9722. if (suspense.deps === 0) {
  9723. suspense.resolve(false, true);
  9724. }
  9725. return result;
  9726. }
  9727. function normalizeSuspenseChildren(vnode) {
  9728. const { shapeFlag, children } = vnode;
  9729. const isSlotChildren = shapeFlag & 32;
  9730. vnode.ssContent = normalizeSuspenseSlot(
  9731. isSlotChildren ? children.default : children
  9732. );
  9733. vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
  9734. }
  9735. function normalizeSuspenseSlot(s) {
  9736. let block;
  9737. if (isFunction(s)) {
  9738. const trackBlock = isBlockTreeEnabled && s._c;
  9739. if (trackBlock) {
  9740. s._d = false;
  9741. openBlock();
  9742. }
  9743. s = s();
  9744. if (trackBlock) {
  9745. s._d = true;
  9746. block = currentBlock;
  9747. closeBlock();
  9748. }
  9749. }
  9750. if (isArray(s)) {
  9751. const singleChild = filterSingleRoot(s);
  9752. if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
  9753. warn$1(`<Suspense> slots expect a single root node.`);
  9754. }
  9755. s = singleChild;
  9756. }
  9757. s = normalizeVNode(s);
  9758. if (block && !s.dynamicChildren) {
  9759. s.dynamicChildren = block.filter((c) => c !== s);
  9760. }
  9761. return s;
  9762. }
  9763. function queueEffectWithSuspense(fn, suspense) {
  9764. if (suspense && suspense.pendingBranch) {
  9765. if (isArray(fn)) {
  9766. suspense.effects.push(...fn);
  9767. } else {
  9768. suspense.effects.push(fn);
  9769. }
  9770. } else {
  9771. queuePostFlushCb(fn);
  9772. }
  9773. }
  9774. function setActiveBranch(suspense, branch) {
  9775. suspense.activeBranch = branch;
  9776. const { vnode, parentComponent } = suspense;
  9777. let el = branch.el;
  9778. while (!el && branch.component) {
  9779. branch = branch.component.subTree;
  9780. el = branch.el;
  9781. }
  9782. vnode.el = el;
  9783. if (parentComponent && parentComponent.subTree === vnode) {
  9784. parentComponent.vnode.el = el;
  9785. updateHOCHostEl(parentComponent, el);
  9786. }
  9787. }
  9788. function isVNodeSuspensible(vnode) {
  9789. const suspensible = vnode.props && vnode.props.suspensible;
  9790. return suspensible != null && suspensible !== false;
  9791. }
  9792. const Fragment = /* @__PURE__ */ Symbol.for("v-fgt");
  9793. const Text = /* @__PURE__ */ Symbol.for("v-txt");
  9794. const Comment = /* @__PURE__ */ Symbol.for("v-cmt");
  9795. const Static = /* @__PURE__ */ Symbol.for("v-stc");
  9796. const blockStack = [];
  9797. let currentBlock = null;
  9798. function openBlock(disableTracking = false) {
  9799. blockStack.push(currentBlock = disableTracking ? null : []);
  9800. }
  9801. function closeBlock() {
  9802. blockStack.pop();
  9803. currentBlock = blockStack[blockStack.length - 1] || null;
  9804. }
  9805. let isBlockTreeEnabled = 1;
  9806. function setBlockTracking(value, inVOnce = false) {
  9807. isBlockTreeEnabled += value;
  9808. if (value < 0 && currentBlock && inVOnce) {
  9809. currentBlock.hasOnce = true;
  9810. }
  9811. }
  9812. function setupBlock(vnode) {
  9813. vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  9814. closeBlock();
  9815. if (isBlockTreeEnabled > 0 && currentBlock) {
  9816. currentBlock.push(vnode);
  9817. }
  9818. return vnode;
  9819. }
  9820. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  9821. return setupBlock(
  9822. createBaseVNode(
  9823. type,
  9824. props,
  9825. children,
  9826. patchFlag,
  9827. dynamicProps,
  9828. shapeFlag,
  9829. true
  9830. )
  9831. );
  9832. }
  9833. function createBlock(type, props, children, patchFlag, dynamicProps) {
  9834. return setupBlock(
  9835. createVNode(
  9836. type,
  9837. props,
  9838. children,
  9839. patchFlag,
  9840. dynamicProps,
  9841. true
  9842. )
  9843. );
  9844. }
  9845. function isVNode(value) {
  9846. return value ? value.__v_isVNode === true : false;
  9847. }
  9848. function isSameVNodeType(n1, n2) {
  9849. if (n2.shapeFlag & 6 && n1.component) {
  9850. const dirtyInstances = hmrDirtyComponents.get(n2.type);
  9851. if (dirtyInstances && dirtyInstances.has(n1.component)) {
  9852. n1.shapeFlag &= -257;
  9853. n2.shapeFlag &= -513;
  9854. return false;
  9855. }
  9856. }
  9857. return n1.type === n2.type && n1.key === n2.key;
  9858. }
  9859. let vnodeArgsTransformer;
  9860. function transformVNodeArgs(transformer) {
  9861. vnodeArgsTransformer = transformer;
  9862. }
  9863. const createVNodeWithArgsTransform = (...args) => {
  9864. return _createVNode(
  9865. ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
  9866. );
  9867. };
  9868. const normalizeKey = ({ key }) => key != null ? key : null;
  9869. const normalizeRef = ({
  9870. ref,
  9871. ref_key,
  9872. ref_for
  9873. }) => {
  9874. if (typeof ref === "number") {
  9875. ref = "" + ref;
  9876. }
  9877. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
  9878. };
  9879. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
  9880. const vnode = {
  9881. __v_isVNode: true,
  9882. __v_skip: true,
  9883. type,
  9884. props,
  9885. key: props && normalizeKey(props),
  9886. ref: props && normalizeRef(props),
  9887. scopeId: currentScopeId,
  9888. slotScopeIds: null,
  9889. children,
  9890. component: null,
  9891. suspense: null,
  9892. ssContent: null,
  9893. ssFallback: null,
  9894. dirs: null,
  9895. transition: null,
  9896. el: null,
  9897. anchor: null,
  9898. target: null,
  9899. targetStart: null,
  9900. targetAnchor: null,
  9901. staticCount: 0,
  9902. shapeFlag,
  9903. patchFlag,
  9904. dynamicProps,
  9905. dynamicChildren: null,
  9906. appContext: null,
  9907. ctx: currentRenderingInstance
  9908. };
  9909. if (needFullChildrenNormalization) {
  9910. normalizeChildren(vnode, children);
  9911. if (shapeFlag & 128) {
  9912. type.normalize(vnode);
  9913. }
  9914. } else if (children) {
  9915. vnode.shapeFlag |= isString(children) ? 8 : 16;
  9916. }
  9917. if (vnode.key !== vnode.key) {
  9918. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  9919. }
  9920. if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
  9921. !isBlockNode && // has current parent block
  9922. currentBlock && // presence of a patch flag indicates this node needs patching on updates.
  9923. // component nodes also should always be patched, because even if the
  9924. // component doesn't need to update, it needs to persist the instance on to
  9925. // the next vnode so that it can be properly unmounted later.
  9926. (vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
  9927. // vnode should not be considered dynamic due to handler caching.
  9928. vnode.patchFlag !== 32) {
  9929. currentBlock.push(vnode);
  9930. }
  9931. return vnode;
  9932. }
  9933. const createVNode = createVNodeWithArgsTransform ;
  9934. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  9935. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  9936. if (!type) {
  9937. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  9938. }
  9939. type = Comment;
  9940. }
  9941. if (isVNode(type)) {
  9942. const cloned = cloneVNode(
  9943. type,
  9944. props,
  9945. true
  9946. /* mergeRef: true */
  9947. );
  9948. if (children) {
  9949. normalizeChildren(cloned, children);
  9950. }
  9951. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  9952. if (cloned.shapeFlag & 6) {
  9953. currentBlock[currentBlock.indexOf(type)] = cloned;
  9954. } else {
  9955. currentBlock.push(cloned);
  9956. }
  9957. }
  9958. cloned.patchFlag = -2;
  9959. return cloned;
  9960. }
  9961. if (isClassComponent(type)) {
  9962. type = type.__vccOpts;
  9963. }
  9964. if (props) {
  9965. props = guardReactiveProps(props);
  9966. let { class: klass, style } = props;
  9967. if (klass && !isString(klass)) {
  9968. props.class = normalizeClass(klass);
  9969. }
  9970. if (isObject(style)) {
  9971. if (isProxy(style) && !isArray(style)) {
  9972. style = extend({}, style);
  9973. }
  9974. props.style = normalizeStyle(style);
  9975. }
  9976. }
  9977. const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
  9978. if (shapeFlag & 4 && isProxy(type)) {
  9979. type = toRaw(type);
  9980. warn$1(
  9981. `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\`.`,
  9982. `
  9983. Component that was made reactive: `,
  9984. type
  9985. );
  9986. }
  9987. return createBaseVNode(
  9988. type,
  9989. props,
  9990. children,
  9991. patchFlag,
  9992. dynamicProps,
  9993. shapeFlag,
  9994. isBlockNode,
  9995. true
  9996. );
  9997. }
  9998. function guardReactiveProps(props) {
  9999. if (!props) return null;
  10000. return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
  10001. }
  10002. function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
  10003. const { props, ref, patchFlag, children, transition } = vnode;
  10004. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  10005. const cloned = {
  10006. __v_isVNode: true,
  10007. __v_skip: true,
  10008. type: vnode.type,
  10009. props: mergedProps,
  10010. key: mergedProps && normalizeKey(mergedProps),
  10011. ref: extraProps && extraProps.ref ? (
  10012. // #2078 in the case of <component :is="vnode" ref="extra"/>
  10013. // if the vnode itself already has a ref, cloneVNode will need to merge
  10014. // the refs so the single vnode can be set on multiple refs
  10015. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
  10016. ) : ref,
  10017. scopeId: vnode.scopeId,
  10018. slotScopeIds: vnode.slotScopeIds,
  10019. children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
  10020. target: vnode.target,
  10021. targetStart: vnode.targetStart,
  10022. targetAnchor: vnode.targetAnchor,
  10023. staticCount: vnode.staticCount,
  10024. shapeFlag: vnode.shapeFlag,
  10025. // if the vnode is cloned with extra props, we can no longer assume its
  10026. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  10027. // note: preserve flag for fragments since they use the flag for children
  10028. // fast paths only.
  10029. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
  10030. dynamicProps: vnode.dynamicProps,
  10031. dynamicChildren: vnode.dynamicChildren,
  10032. appContext: vnode.appContext,
  10033. dirs: vnode.dirs,
  10034. transition,
  10035. // These should technically only be non-null on mounted VNodes. However,
  10036. // they *should* be copied for kept-alive vnodes. So we just always copy
  10037. // them since them being non-null during a mount doesn't affect the logic as
  10038. // they will simply be overwritten.
  10039. component: vnode.component,
  10040. suspense: vnode.suspense,
  10041. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  10042. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  10043. placeholder: vnode.placeholder,
  10044. el: vnode.el,
  10045. anchor: vnode.anchor,
  10046. ctx: vnode.ctx,
  10047. ce: vnode.ce
  10048. };
  10049. if (transition && cloneTransition) {
  10050. setTransitionHooks(
  10051. cloned,
  10052. transition.clone(cloned)
  10053. );
  10054. }
  10055. return cloned;
  10056. }
  10057. function deepCloneVNode(vnode) {
  10058. const cloned = cloneVNode(vnode);
  10059. if (isArray(vnode.children)) {
  10060. cloned.children = vnode.children.map(deepCloneVNode);
  10061. }
  10062. return cloned;
  10063. }
  10064. function createTextVNode(text = " ", flag = 0) {
  10065. return createVNode(Text, null, text, flag);
  10066. }
  10067. function createStaticVNode(content, numberOfNodes) {
  10068. const vnode = createVNode(Static, null, content);
  10069. vnode.staticCount = numberOfNodes;
  10070. return vnode;
  10071. }
  10072. function createCommentVNode(text = "", asBlock = false) {
  10073. return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
  10074. }
  10075. function normalizeVNode(child) {
  10076. if (child == null || typeof child === "boolean") {
  10077. return createVNode(Comment);
  10078. } else if (isArray(child)) {
  10079. return createVNode(
  10080. Fragment,
  10081. null,
  10082. // #3666, avoid reference pollution when reusing vnode
  10083. child.slice()
  10084. );
  10085. } else if (isVNode(child)) {
  10086. return cloneIfMounted(child);
  10087. } else {
  10088. return createVNode(Text, null, String(child));
  10089. }
  10090. }
  10091. function cloneIfMounted(child) {
  10092. return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
  10093. }
  10094. function normalizeChildren(vnode, children) {
  10095. let type = 0;
  10096. const { shapeFlag } = vnode;
  10097. if (children == null) {
  10098. children = null;
  10099. } else if (isArray(children)) {
  10100. type = 16;
  10101. } else if (typeof children === "object") {
  10102. if (shapeFlag & (1 | 64)) {
  10103. const slot = children.default;
  10104. if (slot) {
  10105. slot._c && (slot._d = false);
  10106. normalizeChildren(vnode, slot());
  10107. slot._c && (slot._d = true);
  10108. }
  10109. return;
  10110. } else {
  10111. type = 32;
  10112. const slotFlag = children._;
  10113. if (!slotFlag && !isInternalObject(children)) {
  10114. children._ctx = currentRenderingInstance;
  10115. } else if (slotFlag === 3 && currentRenderingInstance) {
  10116. if (currentRenderingInstance.slots._ === 1) {
  10117. children._ = 1;
  10118. } else {
  10119. children._ = 2;
  10120. vnode.patchFlag |= 1024;
  10121. }
  10122. }
  10123. }
  10124. } else if (isFunction(children)) {
  10125. children = { default: children, _ctx: currentRenderingInstance };
  10126. type = 32;
  10127. } else {
  10128. children = String(children);
  10129. if (shapeFlag & 64) {
  10130. type = 16;
  10131. children = [createTextVNode(children)];
  10132. } else {
  10133. type = 8;
  10134. }
  10135. }
  10136. vnode.children = children;
  10137. vnode.shapeFlag |= type;
  10138. }
  10139. function mergeProps(...args) {
  10140. const ret = {};
  10141. for (let i = 0; i < args.length; i++) {
  10142. const toMerge = args[i];
  10143. for (const key in toMerge) {
  10144. if (key === "class") {
  10145. if (ret.class !== toMerge.class) {
  10146. ret.class = normalizeClass([ret.class, toMerge.class]);
  10147. }
  10148. } else if (key === "style") {
  10149. ret.style = normalizeStyle([ret.style, toMerge.style]);
  10150. } else if (isOn(key)) {
  10151. const existing = ret[key];
  10152. const incoming = toMerge[key];
  10153. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
  10154. ret[key] = existing ? [].concat(existing, incoming) : incoming;
  10155. } else if (incoming == null && existing == null && // mergeProps({ 'onUpdate:modelValue': undefined }) should not retain
  10156. // the model listener.
  10157. !isModelListener(key)) {
  10158. ret[key] = incoming;
  10159. }
  10160. } else if (key !== "") {
  10161. ret[key] = toMerge[key];
  10162. }
  10163. }
  10164. }
  10165. return ret;
  10166. }
  10167. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  10168. callWithAsyncErrorHandling(hook, instance, 7, [
  10169. vnode,
  10170. prevVNode
  10171. ]);
  10172. }
  10173. const emptyAppContext = createAppContext();
  10174. let uid = 0;
  10175. function createComponentInstance(vnode, parent, suspense) {
  10176. const type = vnode.type;
  10177. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  10178. const instance = {
  10179. uid: uid++,
  10180. vnode,
  10181. type,
  10182. parent,
  10183. appContext,
  10184. root: null,
  10185. // to be immediately set
  10186. next: null,
  10187. subTree: null,
  10188. // will be set synchronously right after creation
  10189. effect: null,
  10190. update: null,
  10191. // will be set synchronously right after creation
  10192. job: null,
  10193. scope: new EffectScope(
  10194. true
  10195. /* detached */
  10196. ),
  10197. render: null,
  10198. proxy: null,
  10199. exposed: null,
  10200. exposeProxy: null,
  10201. withProxy: null,
  10202. provides: parent ? parent.provides : Object.create(appContext.provides),
  10203. ids: parent ? parent.ids : ["", 0, 0],
  10204. accessCache: null,
  10205. renderCache: [],
  10206. // local resolved assets
  10207. components: null,
  10208. directives: null,
  10209. // resolved props and emits options
  10210. propsOptions: normalizePropsOptions(type, appContext),
  10211. emitsOptions: normalizeEmitsOptions(type, appContext),
  10212. // emit
  10213. emit: null,
  10214. // to be set immediately
  10215. emitted: null,
  10216. // props default value
  10217. propsDefaults: EMPTY_OBJ,
  10218. // inheritAttrs
  10219. inheritAttrs: type.inheritAttrs,
  10220. // state
  10221. ctx: EMPTY_OBJ,
  10222. data: EMPTY_OBJ,
  10223. props: EMPTY_OBJ,
  10224. attrs: EMPTY_OBJ,
  10225. slots: EMPTY_OBJ,
  10226. refs: EMPTY_OBJ,
  10227. setupState: EMPTY_OBJ,
  10228. setupContext: null,
  10229. // suspense related
  10230. suspense,
  10231. suspenseId: suspense ? suspense.pendingId : 0,
  10232. asyncDep: null,
  10233. asyncResolved: false,
  10234. // lifecycle hooks
  10235. // not using enums here because it results in computed properties
  10236. isMounted: false,
  10237. isUnmounted: false,
  10238. isDeactivated: false,
  10239. bc: null,
  10240. c: null,
  10241. bm: null,
  10242. m: null,
  10243. bu: null,
  10244. u: null,
  10245. um: null,
  10246. bum: null,
  10247. da: null,
  10248. a: null,
  10249. rtg: null,
  10250. rtc: null,
  10251. ec: null,
  10252. sp: null
  10253. };
  10254. {
  10255. instance.ctx = createDevRenderContext(instance);
  10256. }
  10257. instance.root = parent ? parent.root : instance;
  10258. instance.emit = emit.bind(null, instance);
  10259. if (vnode.ce) {
  10260. vnode.ce(instance);
  10261. }
  10262. return instance;
  10263. }
  10264. let currentInstance = null;
  10265. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  10266. let internalSetCurrentInstance;
  10267. let setInSSRSetupState;
  10268. {
  10269. const g = getGlobalThis();
  10270. const registerGlobalSetter = (key, setter) => {
  10271. let setters;
  10272. if (!(setters = g[key])) setters = g[key] = [];
  10273. setters.push(setter);
  10274. return (v) => {
  10275. if (setters.length > 1) setters.forEach((set) => set(v));
  10276. else setters[0](v);
  10277. };
  10278. };
  10279. internalSetCurrentInstance = registerGlobalSetter(
  10280. `__VUE_INSTANCE_SETTERS__`,
  10281. (v) => currentInstance = v
  10282. );
  10283. setInSSRSetupState = registerGlobalSetter(
  10284. `__VUE_SSR_SETTERS__`,
  10285. (v) => isInSSRComponentSetup = v
  10286. );
  10287. }
  10288. const setCurrentInstance = (instance) => {
  10289. const prev = currentInstance;
  10290. internalSetCurrentInstance(instance);
  10291. instance.scope.on();
  10292. return () => {
  10293. instance.scope.off();
  10294. internalSetCurrentInstance(prev);
  10295. };
  10296. };
  10297. const unsetCurrentInstance = () => {
  10298. currentInstance && currentInstance.scope.off();
  10299. internalSetCurrentInstance(null);
  10300. };
  10301. const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
  10302. function validateComponentName(name, { isNativeTag }) {
  10303. if (isBuiltInTag(name) || isNativeTag(name)) {
  10304. warn$1(
  10305. "Do not use built-in or reserved HTML elements as component id: " + name
  10306. );
  10307. }
  10308. }
  10309. function isStatefulComponent(instance) {
  10310. return instance.vnode.shapeFlag & 4;
  10311. }
  10312. let isInSSRComponentSetup = false;
  10313. function setupComponent(instance, isSSR = false, optimized = false) {
  10314. isSSR && setInSSRSetupState(isSSR);
  10315. const { props, children } = instance.vnode;
  10316. const isStateful = isStatefulComponent(instance);
  10317. initProps(instance, props, isStateful, isSSR);
  10318. initSlots(instance, children, optimized || isSSR);
  10319. const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
  10320. isSSR && setInSSRSetupState(false);
  10321. return setupResult;
  10322. }
  10323. function setupStatefulComponent(instance, isSSR) {
  10324. const Component = instance.type;
  10325. {
  10326. if (Component.name) {
  10327. validateComponentName(Component.name, instance.appContext.config);
  10328. }
  10329. if (Component.components) {
  10330. const names = Object.keys(Component.components);
  10331. for (let i = 0; i < names.length; i++) {
  10332. validateComponentName(names[i], instance.appContext.config);
  10333. }
  10334. }
  10335. if (Component.directives) {
  10336. const names = Object.keys(Component.directives);
  10337. for (let i = 0; i < names.length; i++) {
  10338. validateDirectiveName(names[i]);
  10339. }
  10340. }
  10341. if (Component.compilerOptions && isRuntimeOnly()) {
  10342. warn$1(
  10343. `"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.`
  10344. );
  10345. }
  10346. }
  10347. instance.accessCache = /* @__PURE__ */ Object.create(null);
  10348. instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
  10349. {
  10350. exposePropsOnRenderContext(instance);
  10351. }
  10352. const { setup } = Component;
  10353. if (setup) {
  10354. pauseTracking();
  10355. const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
  10356. const reset = setCurrentInstance(instance);
  10357. const setupResult = callWithErrorHandling(
  10358. setup,
  10359. instance,
  10360. 0,
  10361. [
  10362. shallowReadonly(instance.props) ,
  10363. setupContext
  10364. ]
  10365. );
  10366. const isAsyncSetup = isPromise(setupResult);
  10367. resetTracking();
  10368. reset();
  10369. if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) {
  10370. markAsyncBoundary(instance);
  10371. }
  10372. if (isAsyncSetup) {
  10373. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  10374. if (isSSR) {
  10375. return setupResult.then((resolvedResult) => {
  10376. handleSetupResult(instance, resolvedResult, isSSR);
  10377. }).catch((e) => {
  10378. handleError(e, instance, 0);
  10379. });
  10380. } else {
  10381. instance.asyncDep = setupResult;
  10382. if (!instance.suspense) {
  10383. const name = formatComponentName(instance, Component);
  10384. warn$1(
  10385. `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.`
  10386. );
  10387. }
  10388. }
  10389. } else {
  10390. handleSetupResult(instance, setupResult, isSSR);
  10391. }
  10392. } else {
  10393. finishComponentSetup(instance, isSSR);
  10394. }
  10395. }
  10396. function handleSetupResult(instance, setupResult, isSSR) {
  10397. if (isFunction(setupResult)) {
  10398. if (instance.type.__ssrInlineRender) {
  10399. instance.ssrRender = setupResult;
  10400. } else {
  10401. instance.render = setupResult;
  10402. }
  10403. } else if (isObject(setupResult)) {
  10404. if (isVNode(setupResult)) {
  10405. warn$1(
  10406. `setup() should not return VNodes directly - return a render function instead.`
  10407. );
  10408. }
  10409. {
  10410. instance.devtoolsRawSetupState = setupResult;
  10411. }
  10412. instance.setupState = proxyRefs(setupResult);
  10413. {
  10414. exposeSetupStateOnRenderContext(instance);
  10415. }
  10416. } else if (setupResult !== void 0) {
  10417. warn$1(
  10418. `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
  10419. );
  10420. }
  10421. finishComponentSetup(instance, isSSR);
  10422. }
  10423. let compile$1;
  10424. let installWithProxy;
  10425. function registerRuntimeCompiler(_compile) {
  10426. compile$1 = _compile;
  10427. installWithProxy = (i) => {
  10428. if (i.render._rc) {
  10429. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  10430. }
  10431. };
  10432. }
  10433. const isRuntimeOnly = () => !compile$1;
  10434. function finishComponentSetup(instance, isSSR, skipOptions) {
  10435. const Component = instance.type;
  10436. if (!instance.render) {
  10437. if (!isSSR && compile$1 && !Component.render) {
  10438. const template = Component.template || resolveMergedOptions(instance).template;
  10439. if (template) {
  10440. {
  10441. startMeasure(instance, `compile`);
  10442. }
  10443. const { isCustomElement, compilerOptions } = instance.appContext.config;
  10444. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  10445. const finalCompilerOptions = extend(
  10446. extend(
  10447. {
  10448. isCustomElement,
  10449. delimiters
  10450. },
  10451. compilerOptions
  10452. ),
  10453. componentCompilerOptions
  10454. );
  10455. Component.render = compile$1(template, finalCompilerOptions);
  10456. {
  10457. endMeasure(instance, `compile`);
  10458. }
  10459. }
  10460. }
  10461. instance.render = Component.render || NOOP;
  10462. if (installWithProxy) {
  10463. installWithProxy(instance);
  10464. }
  10465. }
  10466. {
  10467. const reset = setCurrentInstance(instance);
  10468. pauseTracking();
  10469. try {
  10470. applyOptions(instance);
  10471. } finally {
  10472. resetTracking();
  10473. reset();
  10474. }
  10475. }
  10476. if (!Component.render && instance.render === NOOP && !isSSR) {
  10477. if (!compile$1 && Component.template) {
  10478. warn$1(
  10479. `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.` )
  10480. );
  10481. } else {
  10482. warn$1(`Component is missing template or render function: `, Component);
  10483. }
  10484. }
  10485. }
  10486. const attrsProxyHandlers = {
  10487. get(target, key) {
  10488. markAttrsAccessed();
  10489. track(target, "get", "");
  10490. return target[key];
  10491. },
  10492. set() {
  10493. warn$1(`setupContext.attrs is readonly.`);
  10494. return false;
  10495. },
  10496. deleteProperty() {
  10497. warn$1(`setupContext.attrs is readonly.`);
  10498. return false;
  10499. }
  10500. } ;
  10501. function getSlotsProxy(instance) {
  10502. return new Proxy(instance.slots, {
  10503. get(target, key) {
  10504. track(instance, "get", "$slots");
  10505. return target[key];
  10506. }
  10507. });
  10508. }
  10509. function createSetupContext(instance) {
  10510. const expose = (exposed) => {
  10511. {
  10512. if (instance.exposed) {
  10513. warn$1(`expose() should be called only once per setup().`);
  10514. }
  10515. if (exposed != null) {
  10516. let exposedType = typeof exposed;
  10517. if (exposedType === "object") {
  10518. if (isArray(exposed)) {
  10519. exposedType = "array";
  10520. } else if (isRef(exposed)) {
  10521. exposedType = "ref";
  10522. }
  10523. }
  10524. if (exposedType !== "object") {
  10525. warn$1(
  10526. `expose() should be passed a plain object, received ${exposedType}.`
  10527. );
  10528. }
  10529. }
  10530. }
  10531. instance.exposed = exposed || {};
  10532. };
  10533. {
  10534. let attrsProxy;
  10535. let slotsProxy;
  10536. return Object.freeze({
  10537. get attrs() {
  10538. return attrsProxy || (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers));
  10539. },
  10540. get slots() {
  10541. return slotsProxy || (slotsProxy = getSlotsProxy(instance));
  10542. },
  10543. get emit() {
  10544. return (event, ...args) => instance.emit(event, ...args);
  10545. },
  10546. expose
  10547. });
  10548. }
  10549. }
  10550. function getComponentPublicInstance(instance) {
  10551. if (instance.exposed) {
  10552. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  10553. get(target, key) {
  10554. if (key in target) {
  10555. return target[key];
  10556. } else if (key in publicPropertiesMap) {
  10557. return publicPropertiesMap[key](instance);
  10558. }
  10559. },
  10560. has(target, key) {
  10561. return key in target || key in publicPropertiesMap;
  10562. }
  10563. }));
  10564. } else {
  10565. return instance.proxy;
  10566. }
  10567. }
  10568. const classifyRE = /(?:^|[-_])\w/g;
  10569. const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
  10570. function getComponentName(Component, includeInferred = true) {
  10571. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
  10572. }
  10573. function formatComponentName(instance, Component, isRoot = false) {
  10574. let name = getComponentName(Component);
  10575. if (!name && Component.__file) {
  10576. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  10577. if (match) {
  10578. name = match[1];
  10579. }
  10580. }
  10581. if (!name && instance) {
  10582. const inferFromRegistry = (registry) => {
  10583. for (const key in registry) {
  10584. if (registry[key] === Component) {
  10585. return key;
  10586. }
  10587. }
  10588. };
  10589. name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(
  10590. instance.parent.type.components
  10591. ) || inferFromRegistry(instance.appContext.components);
  10592. }
  10593. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  10594. }
  10595. function isClassComponent(value) {
  10596. return isFunction(value) && "__vccOpts" in value;
  10597. }
  10598. const computed = (getterOrOptions, debugOptions) => {
  10599. const c = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
  10600. {
  10601. const i = getCurrentInstance();
  10602. if (i && i.appContext.config.warnRecursiveComputed) {
  10603. c._warnRecursive = true;
  10604. }
  10605. }
  10606. return c;
  10607. };
  10608. function h(type, propsOrChildren, children) {
  10609. try {
  10610. setBlockTracking(-1);
  10611. const l = arguments.length;
  10612. if (l === 2) {
  10613. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  10614. if (isVNode(propsOrChildren)) {
  10615. return createVNode(type, null, [propsOrChildren]);
  10616. }
  10617. return createVNode(type, propsOrChildren);
  10618. } else {
  10619. return createVNode(type, null, propsOrChildren);
  10620. }
  10621. } else {
  10622. if (l > 3) {
  10623. children = Array.prototype.slice.call(arguments, 2);
  10624. } else if (l === 3 && isVNode(children)) {
  10625. children = [children];
  10626. }
  10627. return createVNode(type, propsOrChildren, children);
  10628. }
  10629. } finally {
  10630. setBlockTracking(1);
  10631. }
  10632. }
  10633. function initCustomFormatter() {
  10634. if (typeof window === "undefined") {
  10635. return;
  10636. }
  10637. const vueStyle = { style: "color:#3ba776" };
  10638. const numberStyle = { style: "color:#1677ff" };
  10639. const stringStyle = { style: "color:#f5222d" };
  10640. const keywordStyle = { style: "color:#eb2f96" };
  10641. const formatter = {
  10642. __vue_custom_formatter: true,
  10643. header(obj) {
  10644. if (!isObject(obj)) {
  10645. return null;
  10646. }
  10647. if (obj.__isVue) {
  10648. return ["div", vueStyle, `VueInstance`];
  10649. } else if (isRef(obj)) {
  10650. pauseTracking();
  10651. const value = obj.value;
  10652. resetTracking();
  10653. return [
  10654. "div",
  10655. {},
  10656. ["span", vueStyle, genRefFlag(obj)],
  10657. "<",
  10658. formatValue(value),
  10659. `>`
  10660. ];
  10661. } else if (isReactive(obj)) {
  10662. return [
  10663. "div",
  10664. {},
  10665. ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
  10666. "<",
  10667. formatValue(obj),
  10668. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  10669. ];
  10670. } else if (isReadonly(obj)) {
  10671. return [
  10672. "div",
  10673. {},
  10674. ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
  10675. "<",
  10676. formatValue(obj),
  10677. ">"
  10678. ];
  10679. }
  10680. return null;
  10681. },
  10682. hasBody(obj) {
  10683. return obj && obj.__isVue;
  10684. },
  10685. body(obj) {
  10686. if (obj && obj.__isVue) {
  10687. return [
  10688. "div",
  10689. {},
  10690. ...formatInstance(obj.$)
  10691. ];
  10692. }
  10693. }
  10694. };
  10695. function formatInstance(instance) {
  10696. const blocks = [];
  10697. if (instance.type.props && instance.props) {
  10698. blocks.push(createInstanceBlock("props", toRaw(instance.props)));
  10699. }
  10700. if (instance.setupState !== EMPTY_OBJ) {
  10701. blocks.push(createInstanceBlock("setup", instance.setupState));
  10702. }
  10703. if (instance.data !== EMPTY_OBJ) {
  10704. blocks.push(createInstanceBlock("data", toRaw(instance.data)));
  10705. }
  10706. const computed = extractKeys(instance, "computed");
  10707. if (computed) {
  10708. blocks.push(createInstanceBlock("computed", computed));
  10709. }
  10710. const injected = extractKeys(instance, "inject");
  10711. if (injected) {
  10712. blocks.push(createInstanceBlock("injected", injected));
  10713. }
  10714. blocks.push([
  10715. "div",
  10716. {},
  10717. [
  10718. "span",
  10719. {
  10720. style: keywordStyle.style + ";opacity:0.66"
  10721. },
  10722. "$ (internal): "
  10723. ],
  10724. ["object", { object: instance }]
  10725. ]);
  10726. return blocks;
  10727. }
  10728. function createInstanceBlock(type, target) {
  10729. target = extend({}, target);
  10730. if (!Object.keys(target).length) {
  10731. return ["span", {}];
  10732. }
  10733. return [
  10734. "div",
  10735. { style: "line-height:1.25em;margin-bottom:0.6em" },
  10736. [
  10737. "div",
  10738. {
  10739. style: "color:#476582"
  10740. },
  10741. type
  10742. ],
  10743. [
  10744. "div",
  10745. {
  10746. style: "padding-left:1.25em"
  10747. },
  10748. ...Object.keys(target).map((key) => {
  10749. return [
  10750. "div",
  10751. {},
  10752. ["span", keywordStyle, key + ": "],
  10753. formatValue(target[key], false)
  10754. ];
  10755. })
  10756. ]
  10757. ];
  10758. }
  10759. function formatValue(v, asRaw = true) {
  10760. if (typeof v === "number") {
  10761. return ["span", numberStyle, v];
  10762. } else if (typeof v === "string") {
  10763. return ["span", stringStyle, JSON.stringify(v)];
  10764. } else if (typeof v === "boolean") {
  10765. return ["span", keywordStyle, v];
  10766. } else if (isObject(v)) {
  10767. return ["object", { object: asRaw ? toRaw(v) : v }];
  10768. } else {
  10769. return ["span", stringStyle, String(v)];
  10770. }
  10771. }
  10772. function extractKeys(instance, type) {
  10773. const Comp = instance.type;
  10774. if (isFunction(Comp)) {
  10775. return;
  10776. }
  10777. const extracted = {};
  10778. for (const key in instance.ctx) {
  10779. if (isKeyOfType(Comp, key, type)) {
  10780. extracted[key] = instance.ctx[key];
  10781. }
  10782. }
  10783. return extracted;
  10784. }
  10785. function isKeyOfType(Comp, key, type) {
  10786. const opts = Comp[type];
  10787. if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
  10788. return true;
  10789. }
  10790. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  10791. return true;
  10792. }
  10793. if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
  10794. return true;
  10795. }
  10796. }
  10797. function genRefFlag(v) {
  10798. if (isShallow(v)) {
  10799. return `ShallowRef`;
  10800. }
  10801. if (v.effect) {
  10802. return `ComputedRef`;
  10803. }
  10804. return `Ref`;
  10805. }
  10806. if (window.devtoolsFormatters) {
  10807. window.devtoolsFormatters.push(formatter);
  10808. } else {
  10809. window.devtoolsFormatters = [formatter];
  10810. }
  10811. }
  10812. function withMemo(memo, render, cache, index) {
  10813. const cached = cache[index];
  10814. if (cached && isMemoSame(cached, memo)) {
  10815. return cached;
  10816. }
  10817. const ret = render();
  10818. ret.memo = memo.slice();
  10819. ret.cacheIndex = index;
  10820. return cache[index] = ret;
  10821. }
  10822. function isMemoSame(cached, memo) {
  10823. const prev = cached.memo;
  10824. if (prev.length != memo.length) {
  10825. return false;
  10826. }
  10827. for (let i = 0; i < prev.length; i++) {
  10828. if (hasChanged(prev[i], memo[i])) {
  10829. return false;
  10830. }
  10831. }
  10832. if (isBlockTreeEnabled > 0 && currentBlock) {
  10833. currentBlock.push(cached);
  10834. }
  10835. return true;
  10836. }
  10837. const version = "3.5.35";
  10838. const warn = warn$1 ;
  10839. const ErrorTypeStrings = ErrorTypeStrings$1 ;
  10840. const devtools = devtools$1 ;
  10841. const setDevtoolsHook = setDevtoolsHook$1 ;
  10842. const _ssrUtils = {
  10843. createComponentInstance,
  10844. setupComponent,
  10845. renderComponentRoot,
  10846. setCurrentRenderingInstance,
  10847. isVNode: isVNode,
  10848. normalizeVNode,
  10849. getComponentPublicInstance,
  10850. ensureValidVNode,
  10851. pushWarningContext,
  10852. popWarningContext
  10853. };
  10854. const ssrUtils = _ssrUtils ;
  10855. const resolveFilter = null;
  10856. const compatUtils = null;
  10857. const DeprecationTypes = null;
  10858. let policy = void 0;
  10859. const tt = typeof window !== "undefined" && window.trustedTypes;
  10860. if (tt) {
  10861. try {
  10862. policy = /* @__PURE__ */ tt.createPolicy("vue", {
  10863. createHTML: (val) => val
  10864. });
  10865. } catch (e) {
  10866. warn(`Error creating trusted types policy: ${e}`);
  10867. }
  10868. }
  10869. const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
  10870. const svgNS = "http://www.w3.org/2000/svg";
  10871. const mathmlNS = "http://www.w3.org/1998/Math/MathML";
  10872. const doc = typeof document !== "undefined" ? document : null;
  10873. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  10874. const nodeOps = {
  10875. insert: (child, parent, anchor) => {
  10876. parent.insertBefore(child, anchor || null);
  10877. },
  10878. remove: (child) => {
  10879. const parent = child.parentNode;
  10880. if (parent) {
  10881. parent.removeChild(child);
  10882. }
  10883. },
  10884. createElement: (tag, namespace, is, props) => {
  10885. const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
  10886. if (tag === "select" && props && props.multiple != null) {
  10887. el.setAttribute("multiple", props.multiple);
  10888. }
  10889. return el;
  10890. },
  10891. createText: (text) => doc.createTextNode(text),
  10892. createComment: (text) => doc.createComment(text),
  10893. setText: (node, text) => {
  10894. node.nodeValue = text;
  10895. },
  10896. setElementText: (el, text) => {
  10897. el.textContent = text;
  10898. },
  10899. parentNode: (node) => node.parentNode,
  10900. nextSibling: (node) => node.nextSibling,
  10901. querySelector: (selector) => doc.querySelector(selector),
  10902. setScopeId(el, id) {
  10903. el.setAttribute(id, "");
  10904. },
  10905. // __UNSAFE__
  10906. // Reason: innerHTML.
  10907. // Static content here can only come from compiled templates.
  10908. // As long as the user only uses trusted templates, this is safe.
  10909. insertStaticContent(content, parent, anchor, namespace, start, end) {
  10910. const before = anchor ? anchor.previousSibling : parent.lastChild;
  10911. if (start && (start === end || start.nextSibling)) {
  10912. while (true) {
  10913. parent.insertBefore(start.cloneNode(true), anchor);
  10914. if (start === end || !(start = start.nextSibling)) break;
  10915. }
  10916. } else {
  10917. templateContainer.innerHTML = unsafeToTrustedHTML(
  10918. namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
  10919. );
  10920. const template = templateContainer.content;
  10921. if (namespace === "svg" || namespace === "mathml") {
  10922. const wrapper = template.firstChild;
  10923. while (wrapper.firstChild) {
  10924. template.appendChild(wrapper.firstChild);
  10925. }
  10926. template.removeChild(wrapper);
  10927. }
  10928. parent.insertBefore(template, anchor);
  10929. }
  10930. return [
  10931. // first
  10932. before ? before.nextSibling : parent.firstChild,
  10933. // last
  10934. anchor ? anchor.previousSibling : parent.lastChild
  10935. ];
  10936. }
  10937. };
  10938. const TRANSITION$1 = "transition";
  10939. const ANIMATION = "animation";
  10940. const vtcKey = /* @__PURE__ */ Symbol("_vtc");
  10941. const DOMTransitionPropsValidators = {
  10942. name: String,
  10943. type: String,
  10944. css: {
  10945. type: Boolean,
  10946. default: true
  10947. },
  10948. duration: [String, Number, Object],
  10949. enterFromClass: String,
  10950. enterActiveClass: String,
  10951. enterToClass: String,
  10952. appearFromClass: String,
  10953. appearActiveClass: String,
  10954. appearToClass: String,
  10955. leaveFromClass: String,
  10956. leaveActiveClass: String,
  10957. leaveToClass: String
  10958. };
  10959. const TransitionPropsValidators = /* @__PURE__ */ extend(
  10960. {},
  10961. BaseTransitionPropsValidators,
  10962. DOMTransitionPropsValidators
  10963. );
  10964. const decorate$1 = (t) => {
  10965. t.displayName = "Transition";
  10966. t.props = TransitionPropsValidators;
  10967. return t;
  10968. };
  10969. const Transition = /* @__PURE__ */ decorate$1(
  10970. (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots)
  10971. );
  10972. const callHook = (hook, args = []) => {
  10973. if (isArray(hook)) {
  10974. hook.forEach((h2) => h2(...args));
  10975. } else if (hook) {
  10976. hook(...args);
  10977. }
  10978. };
  10979. const hasExplicitCallback = (hook) => {
  10980. return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  10981. };
  10982. function resolveTransitionProps(rawProps) {
  10983. const baseProps = {};
  10984. for (const key in rawProps) {
  10985. if (!(key in DOMTransitionPropsValidators)) {
  10986. baseProps[key] = rawProps[key];
  10987. }
  10988. }
  10989. if (rawProps.css === false) {
  10990. return baseProps;
  10991. }
  10992. const {
  10993. name = "v",
  10994. type,
  10995. duration,
  10996. enterFromClass = `${name}-enter-from`,
  10997. enterActiveClass = `${name}-enter-active`,
  10998. enterToClass = `${name}-enter-to`,
  10999. appearFromClass = enterFromClass,
  11000. appearActiveClass = enterActiveClass,
  11001. appearToClass = enterToClass,
  11002. leaveFromClass = `${name}-leave-from`,
  11003. leaveActiveClass = `${name}-leave-active`,
  11004. leaveToClass = `${name}-leave-to`
  11005. } = rawProps;
  11006. const durations = normalizeDuration(duration);
  11007. const enterDuration = durations && durations[0];
  11008. const leaveDuration = durations && durations[1];
  11009. const {
  11010. onBeforeEnter,
  11011. onEnter,
  11012. onEnterCancelled,
  11013. onLeave,
  11014. onLeaveCancelled,
  11015. onBeforeAppear = onBeforeEnter,
  11016. onAppear = onEnter,
  11017. onAppearCancelled = onEnterCancelled
  11018. } = baseProps;
  11019. const finishEnter = (el, isAppear, done, isCancelled) => {
  11020. el._enterCancelled = isCancelled;
  11021. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  11022. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  11023. done && done();
  11024. };
  11025. const finishLeave = (el, done) => {
  11026. el._isLeaving = false;
  11027. removeTransitionClass(el, leaveFromClass);
  11028. removeTransitionClass(el, leaveToClass);
  11029. removeTransitionClass(el, leaveActiveClass);
  11030. done && done();
  11031. };
  11032. const makeEnterHook = (isAppear) => {
  11033. return (el, done) => {
  11034. const hook = isAppear ? onAppear : onEnter;
  11035. const resolve = () => finishEnter(el, isAppear, done);
  11036. callHook(hook, [el, resolve]);
  11037. nextFrame(() => {
  11038. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  11039. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  11040. if (!hasExplicitCallback(hook)) {
  11041. whenTransitionEnds(el, type, enterDuration, resolve);
  11042. }
  11043. });
  11044. };
  11045. };
  11046. return extend(baseProps, {
  11047. onBeforeEnter(el) {
  11048. callHook(onBeforeEnter, [el]);
  11049. addTransitionClass(el, enterFromClass);
  11050. addTransitionClass(el, enterActiveClass);
  11051. },
  11052. onBeforeAppear(el) {
  11053. callHook(onBeforeAppear, [el]);
  11054. addTransitionClass(el, appearFromClass);
  11055. addTransitionClass(el, appearActiveClass);
  11056. },
  11057. onEnter: makeEnterHook(false),
  11058. onAppear: makeEnterHook(true),
  11059. onLeave(el, done) {
  11060. el._isLeaving = true;
  11061. const resolve = () => finishLeave(el, done);
  11062. addTransitionClass(el, leaveFromClass);
  11063. if (!el._enterCancelled) {
  11064. forceReflow(el);
  11065. addTransitionClass(el, leaveActiveClass);
  11066. } else {
  11067. addTransitionClass(el, leaveActiveClass);
  11068. forceReflow(el);
  11069. }
  11070. nextFrame(() => {
  11071. if (!el._isLeaving) {
  11072. return;
  11073. }
  11074. removeTransitionClass(el, leaveFromClass);
  11075. addTransitionClass(el, leaveToClass);
  11076. if (!hasExplicitCallback(onLeave)) {
  11077. whenTransitionEnds(el, type, leaveDuration, resolve);
  11078. }
  11079. });
  11080. callHook(onLeave, [el, resolve]);
  11081. },
  11082. onEnterCancelled(el) {
  11083. finishEnter(el, false, void 0, true);
  11084. callHook(onEnterCancelled, [el]);
  11085. },
  11086. onAppearCancelled(el) {
  11087. finishEnter(el, true, void 0, true);
  11088. callHook(onAppearCancelled, [el]);
  11089. },
  11090. onLeaveCancelled(el) {
  11091. finishLeave(el);
  11092. callHook(onLeaveCancelled, [el]);
  11093. }
  11094. });
  11095. }
  11096. function normalizeDuration(duration) {
  11097. if (duration == null) {
  11098. return null;
  11099. } else if (isObject(duration)) {
  11100. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  11101. } else {
  11102. const n = NumberOf(duration);
  11103. return [n, n];
  11104. }
  11105. }
  11106. function NumberOf(val) {
  11107. const res = toNumber(val);
  11108. {
  11109. assertNumber(res, "<transition> explicit duration");
  11110. }
  11111. return res;
  11112. }
  11113. function addTransitionClass(el, cls) {
  11114. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  11115. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
  11116. }
  11117. function removeTransitionClass(el, cls) {
  11118. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  11119. const _vtc = el[vtcKey];
  11120. if (_vtc) {
  11121. _vtc.delete(cls);
  11122. if (!_vtc.size) {
  11123. el[vtcKey] = void 0;
  11124. }
  11125. }
  11126. }
  11127. function nextFrame(cb) {
  11128. requestAnimationFrame(() => {
  11129. requestAnimationFrame(cb);
  11130. });
  11131. }
  11132. let endId = 0;
  11133. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  11134. const id = el._endId = ++endId;
  11135. const resolveIfNotStale = () => {
  11136. if (id === el._endId) {
  11137. resolve();
  11138. }
  11139. };
  11140. if (explicitTimeout != null) {
  11141. return setTimeout(resolveIfNotStale, explicitTimeout);
  11142. }
  11143. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  11144. if (!type) {
  11145. return resolve();
  11146. }
  11147. const endEvent = type + "end";
  11148. let ended = 0;
  11149. const end = () => {
  11150. el.removeEventListener(endEvent, onEnd);
  11151. resolveIfNotStale();
  11152. };
  11153. const onEnd = (e) => {
  11154. if (e.target === el && ++ended >= propCount) {
  11155. end();
  11156. }
  11157. };
  11158. setTimeout(() => {
  11159. if (ended < propCount) {
  11160. end();
  11161. }
  11162. }, timeout + 1);
  11163. el.addEventListener(endEvent, onEnd);
  11164. }
  11165. function getTransitionInfo(el, expectedType) {
  11166. const styles = window.getComputedStyle(el);
  11167. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  11168. const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
  11169. const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
  11170. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  11171. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  11172. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  11173. const animationTimeout = getTimeout(animationDelays, animationDurations);
  11174. let type = null;
  11175. let timeout = 0;
  11176. let propCount = 0;
  11177. if (expectedType === TRANSITION$1) {
  11178. if (transitionTimeout > 0) {
  11179. type = TRANSITION$1;
  11180. timeout = transitionTimeout;
  11181. propCount = transitionDurations.length;
  11182. }
  11183. } else if (expectedType === ANIMATION) {
  11184. if (animationTimeout > 0) {
  11185. type = ANIMATION;
  11186. timeout = animationTimeout;
  11187. propCount = animationDurations.length;
  11188. }
  11189. } else {
  11190. timeout = Math.max(transitionTimeout, animationTimeout);
  11191. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
  11192. propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
  11193. }
  11194. const hasTransform = type === TRANSITION$1 && /\b(?:transform|all)(?:,|$)/.test(
  11195. getStyleProperties(`${TRANSITION$1}Property`).toString()
  11196. );
  11197. return {
  11198. type,
  11199. timeout,
  11200. propCount,
  11201. hasTransform
  11202. };
  11203. }
  11204. function getTimeout(delays, durations) {
  11205. while (delays.length < durations.length) {
  11206. delays = delays.concat(delays);
  11207. }
  11208. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  11209. }
  11210. function toMs(s) {
  11211. if (s === "auto") return 0;
  11212. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  11213. }
  11214. function forceReflow(el) {
  11215. const targetDocument = el ? el.ownerDocument : document;
  11216. return targetDocument.body.offsetHeight;
  11217. }
  11218. function patchClass(el, value, isSVG) {
  11219. const transitionClasses = el[vtcKey];
  11220. if (transitionClasses) {
  11221. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  11222. }
  11223. if (value == null) {
  11224. el.removeAttribute("class");
  11225. } else if (isSVG) {
  11226. el.setAttribute("class", value);
  11227. } else {
  11228. el.className = value;
  11229. }
  11230. }
  11231. const vShowOriginalDisplay = /* @__PURE__ */ Symbol("_vod");
  11232. const vShowHidden = /* @__PURE__ */ Symbol("_vsh");
  11233. const vShow = {
  11234. // used for prop mismatch check during hydration
  11235. name: "show",
  11236. beforeMount(el, { value }, { transition }) {
  11237. el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
  11238. if (transition && value) {
  11239. transition.beforeEnter(el);
  11240. } else {
  11241. setDisplay(el, value);
  11242. }
  11243. },
  11244. mounted(el, { value }, { transition }) {
  11245. if (transition && value) {
  11246. transition.enter(el);
  11247. }
  11248. },
  11249. updated(el, { value, oldValue }, { transition }) {
  11250. if (!value === !oldValue) return;
  11251. if (transition) {
  11252. if (value) {
  11253. transition.beforeEnter(el);
  11254. setDisplay(el, true);
  11255. transition.enter(el);
  11256. } else {
  11257. transition.leave(el, () => {
  11258. setDisplay(el, false);
  11259. });
  11260. }
  11261. } else {
  11262. setDisplay(el, value);
  11263. }
  11264. },
  11265. beforeUnmount(el, { value }) {
  11266. setDisplay(el, value);
  11267. }
  11268. };
  11269. function setDisplay(el, value) {
  11270. el.style.display = value ? el[vShowOriginalDisplay] : "none";
  11271. el[vShowHidden] = !value;
  11272. }
  11273. function initVShowForSSR() {
  11274. vShow.getSSRProps = ({ value }) => {
  11275. if (!value) {
  11276. return { style: { display: "none" } };
  11277. }
  11278. };
  11279. }
  11280. const CSS_VAR_TEXT = /* @__PURE__ */ Symbol("CSS_VAR_TEXT" );
  11281. function useCssVars(getter) {
  11282. const instance = getCurrentInstance();
  11283. if (!instance) {
  11284. warn(`useCssVars is called without current active component instance.`);
  11285. return;
  11286. }
  11287. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  11288. Array.from(
  11289. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
  11290. ).forEach((node) => setVarsOnNode(node, vars));
  11291. };
  11292. {
  11293. instance.getCssVars = () => getter(instance.proxy);
  11294. }
  11295. const setVars = () => {
  11296. const vars = getter(instance.proxy);
  11297. if (instance.ce) {
  11298. setVarsOnNode(instance.ce, vars);
  11299. } else {
  11300. setVarsOnVNode(instance.subTree, vars);
  11301. }
  11302. updateTeleports(vars);
  11303. };
  11304. onBeforeUpdate(() => {
  11305. queuePostFlushCb(setVars);
  11306. });
  11307. onMounted(() => {
  11308. watch(setVars, NOOP, { flush: "post" });
  11309. const ob = new MutationObserver(setVars);
  11310. ob.observe(instance.subTree.el.parentNode, { childList: true });
  11311. onUnmounted(() => ob.disconnect());
  11312. });
  11313. }
  11314. function setVarsOnVNode(vnode, vars) {
  11315. if (vnode.shapeFlag & 128) {
  11316. const suspense = vnode.suspense;
  11317. vnode = suspense.activeBranch;
  11318. if (suspense.pendingBranch && !suspense.isHydrating) {
  11319. suspense.effects.push(() => {
  11320. setVarsOnVNode(suspense.activeBranch, vars);
  11321. });
  11322. }
  11323. }
  11324. while (vnode.component) {
  11325. vnode = vnode.component.subTree;
  11326. }
  11327. if (vnode.shapeFlag & 1 && vnode.el) {
  11328. setVarsOnNode(vnode.el, vars);
  11329. } else if (vnode.type === Fragment) {
  11330. vnode.children.forEach((c) => setVarsOnVNode(c, vars));
  11331. } else if (vnode.type === Static) {
  11332. let { el, anchor } = vnode;
  11333. while (el) {
  11334. setVarsOnNode(el, vars);
  11335. if (el === anchor) break;
  11336. el = el.nextSibling;
  11337. }
  11338. }
  11339. }
  11340. function setVarsOnNode(el, vars) {
  11341. if (el.nodeType === 1) {
  11342. const style = el.style;
  11343. let cssText = "";
  11344. for (const key in vars) {
  11345. const value = normalizeCssVarValue(vars[key]);
  11346. style.setProperty(`--${key}`, value);
  11347. cssText += `--${key}: ${value};`;
  11348. }
  11349. style[CSS_VAR_TEXT] = cssText;
  11350. }
  11351. }
  11352. const displayRE = /(?:^|;)\s*display\s*:/;
  11353. function patchStyle(el, prev, next) {
  11354. const style = el.style;
  11355. const isCssString = isString(next);
  11356. let hasControlledDisplay = false;
  11357. if (next && !isCssString) {
  11358. if (prev) {
  11359. if (!isString(prev)) {
  11360. for (const key in prev) {
  11361. if (next[key] == null) {
  11362. setStyle(style, key, "");
  11363. }
  11364. }
  11365. } else {
  11366. for (const prevStyle of prev.split(";")) {
  11367. const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
  11368. if (next[key] == null) {
  11369. setStyle(style, key, "");
  11370. }
  11371. }
  11372. }
  11373. }
  11374. for (const key in next) {
  11375. if (key === "display") {
  11376. hasControlledDisplay = true;
  11377. }
  11378. const value = next[key];
  11379. if (value != null) {
  11380. if (!shouldPreserveTextareaResizeStyle(
  11381. el,
  11382. key,
  11383. !isString(prev) && prev ? prev[key] : void 0,
  11384. value
  11385. )) {
  11386. setStyle(style, key, value);
  11387. }
  11388. } else {
  11389. setStyle(style, key, "");
  11390. }
  11391. }
  11392. } else {
  11393. if (isCssString) {
  11394. if (prev !== next) {
  11395. const cssVarText = style[CSS_VAR_TEXT];
  11396. if (cssVarText) {
  11397. next += ";" + cssVarText;
  11398. }
  11399. style.cssText = next;
  11400. hasControlledDisplay = displayRE.test(next);
  11401. }
  11402. } else if (prev) {
  11403. el.removeAttribute("style");
  11404. }
  11405. }
  11406. if (vShowOriginalDisplay in el) {
  11407. el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
  11408. if (el[vShowHidden]) {
  11409. style.display = "none";
  11410. }
  11411. }
  11412. }
  11413. const semicolonRE = /[^\\];\s*$/;
  11414. const importantRE = /\s*!important$/;
  11415. function setStyle(style, name, val) {
  11416. if (isArray(val)) {
  11417. val.forEach((v) => setStyle(style, name, v));
  11418. } else {
  11419. if (val == null) val = "";
  11420. {
  11421. if (semicolonRE.test(val)) {
  11422. warn(
  11423. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  11424. );
  11425. }
  11426. }
  11427. if (name.startsWith("--")) {
  11428. style.setProperty(name, val);
  11429. } else {
  11430. const prefixed = autoPrefix(style, name);
  11431. if (importantRE.test(val)) {
  11432. style.setProperty(
  11433. hyphenate(prefixed),
  11434. val.replace(importantRE, ""),
  11435. "important"
  11436. );
  11437. } else {
  11438. style[prefixed] = val;
  11439. }
  11440. }
  11441. }
  11442. }
  11443. const prefixes = ["Webkit", "Moz", "ms"];
  11444. const prefixCache = {};
  11445. function autoPrefix(style, rawName) {
  11446. const cached = prefixCache[rawName];
  11447. if (cached) {
  11448. return cached;
  11449. }
  11450. let name = camelize(rawName);
  11451. if (name !== "filter" && name in style) {
  11452. return prefixCache[rawName] = name;
  11453. }
  11454. name = capitalize(name);
  11455. for (let i = 0; i < prefixes.length; i++) {
  11456. const prefixed = prefixes[i] + name;
  11457. if (prefixed in style) {
  11458. return prefixCache[rawName] = prefixed;
  11459. }
  11460. }
  11461. return rawName;
  11462. }
  11463. function shouldPreserveTextareaResizeStyle(el, key, prev, next) {
  11464. return el.tagName === "TEXTAREA" && (key === "width" || key === "height") && isString(next) && prev === next;
  11465. }
  11466. const xlinkNS = "http://www.w3.org/1999/xlink";
  11467. function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) {
  11468. if (isSVG && key.startsWith("xlink:")) {
  11469. if (value == null) {
  11470. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  11471. } else {
  11472. el.setAttributeNS(xlinkNS, key, value);
  11473. }
  11474. } else {
  11475. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  11476. el.removeAttribute(key);
  11477. } else {
  11478. el.setAttribute(
  11479. key,
  11480. isBoolean ? "" : isSymbol(value) ? String(value) : value
  11481. );
  11482. }
  11483. }
  11484. }
  11485. function patchDOMProp(el, key, value, parentComponent, attrName) {
  11486. if (key === "innerHTML" || key === "textContent") {
  11487. if (value != null) {
  11488. el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
  11489. }
  11490. return;
  11491. }
  11492. const tag = el.tagName;
  11493. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  11494. !tag.includes("-")) {
  11495. const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
  11496. const newValue = value == null ? (
  11497. // #11647: value should be set as empty string for null and undefined,
  11498. // but <input type="checkbox"> should be set as 'on'.
  11499. el.type === "checkbox" ? "on" : ""
  11500. ) : String(value);
  11501. if (oldValue !== newValue || !("_value" in el)) {
  11502. el.value = newValue;
  11503. }
  11504. if (value == null) {
  11505. el.removeAttribute(key);
  11506. }
  11507. el._value = value;
  11508. return;
  11509. }
  11510. let needRemove = false;
  11511. if (value === "" || value == null) {
  11512. const type = typeof el[key];
  11513. if (type === "boolean") {
  11514. value = includeBooleanAttr(value);
  11515. } else if (value == null && type === "string") {
  11516. value = "";
  11517. needRemove = true;
  11518. } else if (type === "number") {
  11519. value = 0;
  11520. needRemove = true;
  11521. }
  11522. }
  11523. try {
  11524. el[key] = value;
  11525. } catch (e) {
  11526. if (!needRemove) {
  11527. warn(
  11528. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  11529. e
  11530. );
  11531. }
  11532. }
  11533. needRemove && el.removeAttribute(attrName || key);
  11534. }
  11535. function addEventListener(el, event, handler, options) {
  11536. el.addEventListener(event, handler, options);
  11537. }
  11538. function removeEventListener(el, event, handler, options) {
  11539. el.removeEventListener(event, handler, options);
  11540. }
  11541. const veiKey = /* @__PURE__ */ Symbol("_vei");
  11542. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  11543. const invokers = el[veiKey] || (el[veiKey] = {});
  11544. const existingInvoker = invokers[rawName];
  11545. if (nextValue && existingInvoker) {
  11546. existingInvoker.value = sanitizeEventValue(nextValue, rawName) ;
  11547. } else {
  11548. const [name, options] = parseName(rawName);
  11549. if (nextValue) {
  11550. const invoker = invokers[rawName] = createInvoker(
  11551. sanitizeEventValue(nextValue, rawName) ,
  11552. instance
  11553. );
  11554. addEventListener(el, name, invoker, options);
  11555. } else if (existingInvoker) {
  11556. removeEventListener(el, name, existingInvoker, options);
  11557. invokers[rawName] = void 0;
  11558. }
  11559. }
  11560. }
  11561. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  11562. function parseName(name) {
  11563. let options;
  11564. if (optionsModifierRE.test(name)) {
  11565. options = {};
  11566. let m;
  11567. while (m = name.match(optionsModifierRE)) {
  11568. name = name.slice(0, name.length - m[0].length);
  11569. options[m[0].toLowerCase()] = true;
  11570. }
  11571. }
  11572. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  11573. return [event, options];
  11574. }
  11575. let cachedNow = 0;
  11576. const p = /* @__PURE__ */ Promise.resolve();
  11577. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  11578. function createInvoker(initialValue, instance) {
  11579. const invoker = (e) => {
  11580. if (!e._vts) {
  11581. e._vts = Date.now();
  11582. } else if (e._vts <= invoker.attached) {
  11583. return;
  11584. }
  11585. const value = invoker.value;
  11586. if (isArray(value)) {
  11587. const originalStop = e.stopImmediatePropagation;
  11588. e.stopImmediatePropagation = () => {
  11589. originalStop.call(e);
  11590. e._stopped = true;
  11591. };
  11592. const handlers = value.slice();
  11593. const args = [e];
  11594. for (let i = 0; i < handlers.length; i++) {
  11595. if (e._stopped) {
  11596. break;
  11597. }
  11598. const handler = handlers[i];
  11599. if (handler) {
  11600. callWithAsyncErrorHandling(
  11601. handler,
  11602. instance,
  11603. 5,
  11604. args
  11605. );
  11606. }
  11607. }
  11608. } else {
  11609. callWithAsyncErrorHandling(
  11610. value,
  11611. instance,
  11612. 5,
  11613. [e]
  11614. );
  11615. }
  11616. };
  11617. invoker.value = initialValue;
  11618. invoker.attached = getNow();
  11619. return invoker;
  11620. }
  11621. function sanitizeEventValue(value, propName) {
  11622. if (isFunction(value) || isArray(value)) {
  11623. return value;
  11624. }
  11625. warn(
  11626. `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
  11627. Expected function or array of functions, received type ${typeof value}.`
  11628. );
  11629. return NOOP;
  11630. }
  11631. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  11632. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  11633. const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
  11634. const isSVG = namespace === "svg";
  11635. if (key === "class") {
  11636. patchClass(el, nextValue, isSVG);
  11637. } else if (key === "style") {
  11638. patchStyle(el, prevValue, nextValue);
  11639. } else if (isOn(key)) {
  11640. if (!isModelListener(key)) {
  11641. patchEvent(el, key, prevValue, nextValue, parentComponent);
  11642. }
  11643. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  11644. patchDOMProp(el, key, nextValue);
  11645. if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
  11646. patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
  11647. }
  11648. } else if (
  11649. // #11081 force set props for possible async custom element
  11650. el._isVueCE && // #12408 check if it's declared prop or it's async custom element
  11651. (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
  11652. el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
  11653. ) {
  11654. patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
  11655. } else {
  11656. if (key === "true-value") {
  11657. el._trueValue = nextValue;
  11658. } else if (key === "false-value") {
  11659. el._falseValue = nextValue;
  11660. }
  11661. patchAttr(el, key, nextValue, isSVG);
  11662. }
  11663. };
  11664. function shouldSetAsProp(el, key, value, isSVG) {
  11665. if (isSVG) {
  11666. if (key === "innerHTML" || key === "textContent") {
  11667. return true;
  11668. }
  11669. if (key in el && isNativeOn(key) && isFunction(value)) {
  11670. return true;
  11671. }
  11672. return false;
  11673. }
  11674. if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
  11675. return false;
  11676. }
  11677. if (key === "sandbox" && el.tagName === "IFRAME") {
  11678. return false;
  11679. }
  11680. if (key === "form") {
  11681. return false;
  11682. }
  11683. if (key === "list" && el.tagName === "INPUT") {
  11684. return false;
  11685. }
  11686. if (key === "type" && el.tagName === "TEXTAREA") {
  11687. return false;
  11688. }
  11689. if (key === "width" || key === "height") {
  11690. const tag = el.tagName;
  11691. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  11692. return false;
  11693. }
  11694. }
  11695. if (isNativeOn(key) && isString(value)) {
  11696. return false;
  11697. }
  11698. return key in el;
  11699. }
  11700. function shouldSetAsPropForVueCE(el, key) {
  11701. const props = (
  11702. // @ts-expect-error _def is private
  11703. el._def.props
  11704. );
  11705. if (!props) {
  11706. return false;
  11707. }
  11708. const camelKey = camelize(key);
  11709. return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
  11710. }
  11711. const REMOVAL = {};
  11712. // @__NO_SIDE_EFFECTS__
  11713. function defineCustomElement(options, extraOptions, _createApp) {
  11714. let Comp = defineComponent(options, extraOptions);
  11715. if (isPlainObject(Comp)) Comp = extend({}, Comp, extraOptions);
  11716. class VueCustomElement extends VueElement {
  11717. constructor(initialProps) {
  11718. super(Comp, initialProps, _createApp);
  11719. }
  11720. }
  11721. VueCustomElement.def = Comp;
  11722. return VueCustomElement;
  11723. }
  11724. const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
  11725. return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
  11726. });
  11727. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  11728. };
  11729. class VueElement extends BaseClass {
  11730. constructor(_def, _props = {}, _createApp = createApp) {
  11731. super();
  11732. this._def = _def;
  11733. this._props = _props;
  11734. this._createApp = _createApp;
  11735. this._isVueCE = true;
  11736. /**
  11737. * @internal
  11738. */
  11739. this._instance = null;
  11740. /**
  11741. * @internal
  11742. */
  11743. this._app = null;
  11744. /**
  11745. * @internal
  11746. */
  11747. this._nonce = this._def.nonce;
  11748. this._connected = false;
  11749. this._resolved = false;
  11750. this._patching = false;
  11751. this._dirty = false;
  11752. this._numberProps = null;
  11753. this._styleChildren = /* @__PURE__ */ new WeakSet();
  11754. this._styleAnchors = /* @__PURE__ */ new WeakMap();
  11755. this._ob = null;
  11756. if (this.shadowRoot && _createApp !== createApp) {
  11757. this._root = this.shadowRoot;
  11758. } else {
  11759. if (this.shadowRoot) {
  11760. warn(
  11761. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  11762. );
  11763. }
  11764. if (_def.shadowRoot !== false) {
  11765. this.attachShadow(
  11766. extend({}, _def.shadowRootOptions, {
  11767. mode: "open"
  11768. })
  11769. );
  11770. this._root = this.shadowRoot;
  11771. } else {
  11772. this._root = this;
  11773. }
  11774. }
  11775. }
  11776. connectedCallback() {
  11777. if (!this.isConnected) return;
  11778. if (!this.shadowRoot && !this._resolved) {
  11779. this._parseSlots();
  11780. }
  11781. this._connected = true;
  11782. let parent = this;
  11783. while (parent = parent && // #12479 should check assignedSlot first to get correct parent
  11784. (parent.assignedSlot || parent.parentNode || parent.host)) {
  11785. if (parent instanceof VueElement) {
  11786. this._parent = parent;
  11787. break;
  11788. }
  11789. }
  11790. if (!this._instance) {
  11791. if (this._resolved) {
  11792. this._mount(this._def);
  11793. } else {
  11794. if (parent && parent._pendingResolve) {
  11795. this._pendingResolve = parent._pendingResolve.then(() => {
  11796. this._pendingResolve = void 0;
  11797. this._resolveDef();
  11798. });
  11799. } else {
  11800. this._resolveDef();
  11801. }
  11802. }
  11803. }
  11804. }
  11805. _setParent(parent = this._parent) {
  11806. if (parent) {
  11807. this._instance.parent = parent._instance;
  11808. this._inheritParentContext(parent);
  11809. }
  11810. }
  11811. _inheritParentContext(parent = this._parent) {
  11812. if (parent && this._app) {
  11813. Object.setPrototypeOf(
  11814. this._app._context.provides,
  11815. parent._instance.provides
  11816. );
  11817. }
  11818. }
  11819. disconnectedCallback() {
  11820. this._connected = false;
  11821. nextTick(() => {
  11822. if (!this._connected) {
  11823. if (this._ob) {
  11824. this._ob.disconnect();
  11825. this._ob = null;
  11826. }
  11827. this._app && this._app.unmount();
  11828. if (this._instance) this._instance.ce = void 0;
  11829. this._app = this._instance = null;
  11830. if (this._teleportTargets) {
  11831. this._teleportTargets.clear();
  11832. this._teleportTargets = void 0;
  11833. }
  11834. }
  11835. });
  11836. }
  11837. _processMutations(mutations) {
  11838. for (const m of mutations) {
  11839. this._setAttr(m.attributeName);
  11840. }
  11841. }
  11842. /**
  11843. * resolve inner component definition (handle possible async component)
  11844. */
  11845. _resolveDef() {
  11846. if (this._pendingResolve) {
  11847. return;
  11848. }
  11849. for (let i = 0; i < this.attributes.length; i++) {
  11850. this._setAttr(this.attributes[i].name);
  11851. }
  11852. this._ob = new MutationObserver(this._processMutations.bind(this));
  11853. this._ob.observe(this, { attributes: true });
  11854. const resolve = (def, isAsync = false) => {
  11855. this._resolved = true;
  11856. this._pendingResolve = void 0;
  11857. const { props, styles } = def;
  11858. let numberProps;
  11859. if (props && !isArray(props)) {
  11860. for (const key in props) {
  11861. const opt = props[key];
  11862. if (opt === Number || opt && opt.type === Number) {
  11863. if (key in this._props) {
  11864. this._props[key] = toNumber(this._props[key]);
  11865. }
  11866. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize(key)] = true;
  11867. }
  11868. }
  11869. }
  11870. this._numberProps = numberProps;
  11871. this._resolveProps(def);
  11872. if (this.shadowRoot) {
  11873. this._applyStyles(styles);
  11874. } else if (styles) {
  11875. warn(
  11876. "Custom element style injection is not supported when using shadowRoot: false"
  11877. );
  11878. }
  11879. this._mount(def);
  11880. };
  11881. const asyncDef = this._def.__asyncLoader;
  11882. if (asyncDef) {
  11883. this._pendingResolve = asyncDef().then((def) => {
  11884. def.configureApp = this._def.configureApp;
  11885. resolve(this._def = def, true);
  11886. });
  11887. } else {
  11888. resolve(this._def);
  11889. }
  11890. }
  11891. _mount(def) {
  11892. if (!def.name) {
  11893. def.name = "VueElement";
  11894. }
  11895. this._app = this._createApp(def);
  11896. this._inheritParentContext();
  11897. if (def.configureApp) {
  11898. def.configureApp(this._app);
  11899. }
  11900. this._app._ceVNode = this._createVNode();
  11901. this._app.mount(this._root);
  11902. const exposed = this._instance && this._instance.exposed;
  11903. if (!exposed) return;
  11904. for (const key in exposed) {
  11905. if (!hasOwn(this, key)) {
  11906. Object.defineProperty(this, key, {
  11907. // unwrap ref to be consistent with public instance behavior
  11908. get: () => unref(exposed[key])
  11909. });
  11910. } else {
  11911. warn(`Exposed property "${key}" already exists on custom element.`);
  11912. }
  11913. }
  11914. }
  11915. _resolveProps(def) {
  11916. const { props } = def;
  11917. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  11918. for (const key of Object.keys(this)) {
  11919. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  11920. this._setProp(key, this[key]);
  11921. }
  11922. }
  11923. for (const key of declaredPropKeys.map(camelize)) {
  11924. Object.defineProperty(this, key, {
  11925. get() {
  11926. return this._getProp(key);
  11927. },
  11928. set(val) {
  11929. this._setProp(key, val, true, !this._patching);
  11930. }
  11931. });
  11932. }
  11933. }
  11934. _setAttr(key) {
  11935. if (key.startsWith("data-v-")) return;
  11936. const has = this.hasAttribute(key);
  11937. let value = has ? this.getAttribute(key) : REMOVAL;
  11938. const camelKey = camelize(key);
  11939. if (has && this._numberProps && this._numberProps[camelKey]) {
  11940. value = toNumber(value);
  11941. }
  11942. this._setProp(camelKey, value, false, true);
  11943. }
  11944. /**
  11945. * @internal
  11946. */
  11947. _getProp(key) {
  11948. return this._props[key];
  11949. }
  11950. /**
  11951. * @internal
  11952. */
  11953. _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
  11954. if (val !== this._props[key]) {
  11955. this._dirty = true;
  11956. if (val === REMOVAL) {
  11957. delete this._props[key];
  11958. } else {
  11959. this._props[key] = val;
  11960. if (key === "key" && this._app) {
  11961. this._app._ceVNode.key = val;
  11962. }
  11963. }
  11964. if (shouldUpdate && this._instance) {
  11965. this._update();
  11966. }
  11967. if (shouldReflect) {
  11968. const ob = this._ob;
  11969. if (ob) {
  11970. this._processMutations(ob.takeRecords());
  11971. ob.disconnect();
  11972. }
  11973. if (val === true) {
  11974. this.setAttribute(hyphenate(key), "");
  11975. } else if (typeof val === "string" || typeof val === "number") {
  11976. this.setAttribute(hyphenate(key), val + "");
  11977. } else if (!val) {
  11978. this.removeAttribute(hyphenate(key));
  11979. }
  11980. ob && ob.observe(this, { attributes: true });
  11981. }
  11982. }
  11983. }
  11984. _update() {
  11985. const vnode = this._createVNode();
  11986. if (this._app) vnode.appContext = this._app._context;
  11987. render(vnode, this._root);
  11988. }
  11989. _createVNode() {
  11990. const baseProps = {};
  11991. if (!this.shadowRoot) {
  11992. baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
  11993. }
  11994. const vnode = createVNode(this._def, extend(baseProps, this._props));
  11995. if (!this._instance) {
  11996. vnode.ce = (instance) => {
  11997. this._instance = instance;
  11998. instance.ce = this;
  11999. instance.isCE = true;
  12000. {
  12001. instance.ceReload = (newStyles) => {
  12002. if (this._styles) {
  12003. this._styles.forEach((s) => this._root.removeChild(s));
  12004. this._styles.length = 0;
  12005. }
  12006. this._styleAnchors.delete(this._def);
  12007. this._applyStyles(newStyles);
  12008. this._instance = null;
  12009. this._update();
  12010. };
  12011. }
  12012. const dispatch = (event, args) => {
  12013. this.dispatchEvent(
  12014. new CustomEvent(
  12015. event,
  12016. isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
  12017. )
  12018. );
  12019. };
  12020. instance.emit = (event, ...args) => {
  12021. dispatch(event, args);
  12022. if (hyphenate(event) !== event) {
  12023. dispatch(hyphenate(event), args);
  12024. }
  12025. };
  12026. this._setParent();
  12027. };
  12028. }
  12029. return vnode;
  12030. }
  12031. _applyStyles(styles, owner, parentComp) {
  12032. if (!styles) return;
  12033. if (owner) {
  12034. if (owner === this._def || this._styleChildren.has(owner)) {
  12035. return;
  12036. }
  12037. this._styleChildren.add(owner);
  12038. }
  12039. const nonce = this._nonce;
  12040. const root = this.shadowRoot;
  12041. const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
  12042. let last = null;
  12043. for (let i = styles.length - 1; i >= 0; i--) {
  12044. const s = document.createElement("style");
  12045. if (nonce) s.setAttribute("nonce", nonce);
  12046. s.textContent = styles[i];
  12047. root.insertBefore(s, last || insertionAnchor);
  12048. last = s;
  12049. if (i === 0) {
  12050. if (!parentComp) this._styleAnchors.set(this._def, s);
  12051. if (owner) this._styleAnchors.set(owner, s);
  12052. }
  12053. {
  12054. if (owner) {
  12055. if (owner.__hmrId) {
  12056. if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
  12057. let entry = this._childStyles.get(owner.__hmrId);
  12058. if (!entry) {
  12059. this._childStyles.set(owner.__hmrId, entry = []);
  12060. }
  12061. entry.push(s);
  12062. }
  12063. } else {
  12064. (this._styles || (this._styles = [])).push(s);
  12065. }
  12066. }
  12067. }
  12068. }
  12069. _getStyleAnchor(comp) {
  12070. if (!comp) {
  12071. return null;
  12072. }
  12073. const anchor = this._styleAnchors.get(comp);
  12074. if (anchor && anchor.parentNode === this.shadowRoot) {
  12075. return anchor;
  12076. }
  12077. if (anchor) {
  12078. this._styleAnchors.delete(comp);
  12079. }
  12080. return null;
  12081. }
  12082. _getRootStyleInsertionAnchor(root) {
  12083. for (let i = 0; i < root.childNodes.length; i++) {
  12084. const node = root.childNodes[i];
  12085. if (!(node instanceof HTMLStyleElement)) {
  12086. return node;
  12087. }
  12088. }
  12089. return null;
  12090. }
  12091. /**
  12092. * Only called when shadowRoot is false
  12093. */
  12094. _parseSlots() {
  12095. const slots = this._slots = {};
  12096. let n;
  12097. while (n = this.firstChild) {
  12098. const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
  12099. (slots[slotName] || (slots[slotName] = [])).push(n);
  12100. this.removeChild(n);
  12101. }
  12102. }
  12103. /**
  12104. * Only called when shadowRoot is false
  12105. */
  12106. _renderSlots() {
  12107. const outlets = this._getSlots();
  12108. const scopeId = this._instance.type.__scopeId;
  12109. for (let i = 0; i < outlets.length; i++) {
  12110. const o = outlets[i];
  12111. const slotName = o.getAttribute("name") || "default";
  12112. const content = this._slots[slotName];
  12113. const parent = o.parentNode;
  12114. if (content) {
  12115. for (const n of content) {
  12116. if (scopeId && n.nodeType === 1) {
  12117. const id = scopeId + "-s";
  12118. const walker = document.createTreeWalker(n, 1);
  12119. n.setAttribute(id, "");
  12120. let child;
  12121. while (child = walker.nextNode()) {
  12122. child.setAttribute(id, "");
  12123. }
  12124. }
  12125. parent.insertBefore(n, o);
  12126. }
  12127. } else {
  12128. while (o.firstChild) parent.insertBefore(o.firstChild, o);
  12129. }
  12130. parent.removeChild(o);
  12131. }
  12132. }
  12133. /**
  12134. * @internal
  12135. */
  12136. _getSlots() {
  12137. const roots = [this];
  12138. if (this._teleportTargets) {
  12139. roots.push(...this._teleportTargets);
  12140. }
  12141. const slots = /* @__PURE__ */ new Set();
  12142. for (const root of roots) {
  12143. const found = root.querySelectorAll("slot");
  12144. for (let i = 0; i < found.length; i++) {
  12145. slots.add(found[i]);
  12146. }
  12147. }
  12148. return Array.from(slots);
  12149. }
  12150. /**
  12151. * @internal
  12152. */
  12153. _injectChildStyle(comp, parentComp) {
  12154. this._applyStyles(comp.styles, comp, parentComp);
  12155. }
  12156. /**
  12157. * @internal
  12158. */
  12159. _beginPatch() {
  12160. this._patching = true;
  12161. this._dirty = false;
  12162. }
  12163. /**
  12164. * @internal
  12165. */
  12166. _endPatch() {
  12167. this._patching = false;
  12168. if (this._dirty && this._instance) {
  12169. this._update();
  12170. }
  12171. }
  12172. /**
  12173. * @internal
  12174. */
  12175. _hasShadowRoot() {
  12176. return this._def.shadowRoot !== false;
  12177. }
  12178. /**
  12179. * @internal
  12180. */
  12181. _removeChildStyle(comp) {
  12182. {
  12183. this._styleChildren.delete(comp);
  12184. this._styleAnchors.delete(comp);
  12185. if (this._childStyles && comp.__hmrId) {
  12186. const oldStyles = this._childStyles.get(comp.__hmrId);
  12187. if (oldStyles) {
  12188. oldStyles.forEach((s) => this._root.removeChild(s));
  12189. oldStyles.length = 0;
  12190. }
  12191. }
  12192. }
  12193. }
  12194. }
  12195. function useHost(caller) {
  12196. const instance = getCurrentInstance();
  12197. const el = instance && instance.ce;
  12198. if (el) {
  12199. return el;
  12200. } else {
  12201. if (!instance) {
  12202. warn(
  12203. `${caller || "useHost"} called without an active component instance.`
  12204. );
  12205. } else {
  12206. warn(
  12207. `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
  12208. );
  12209. }
  12210. }
  12211. return null;
  12212. }
  12213. function useShadowRoot() {
  12214. const el = useHost("useShadowRoot") ;
  12215. return el && el.shadowRoot;
  12216. }
  12217. function useCssModule(name = "$style") {
  12218. {
  12219. const instance = getCurrentInstance();
  12220. if (!instance) {
  12221. warn(`useCssModule must be called inside setup()`);
  12222. return EMPTY_OBJ;
  12223. }
  12224. const modules = instance.type.__cssModules;
  12225. if (!modules) {
  12226. warn(`Current instance does not have CSS modules injected.`);
  12227. return EMPTY_OBJ;
  12228. }
  12229. const mod = modules[name];
  12230. if (!mod) {
  12231. warn(`Current instance does not have CSS module named "${name}".`);
  12232. return EMPTY_OBJ;
  12233. }
  12234. return mod;
  12235. }
  12236. }
  12237. const positionMap = /* @__PURE__ */ new WeakMap();
  12238. const newPositionMap = /* @__PURE__ */ new WeakMap();
  12239. const moveCbKey = /* @__PURE__ */ Symbol("_moveCb");
  12240. const enterCbKey = /* @__PURE__ */ Symbol("_enterCb");
  12241. const decorate = (t) => {
  12242. delete t.props.mode;
  12243. return t;
  12244. };
  12245. const TransitionGroupImpl = /* @__PURE__ */ decorate({
  12246. name: "TransitionGroup",
  12247. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  12248. tag: String,
  12249. moveClass: String
  12250. }),
  12251. setup(props, { slots }) {
  12252. const instance = getCurrentInstance();
  12253. const state = useTransitionState();
  12254. let prevChildren;
  12255. let children;
  12256. onUpdated(() => {
  12257. if (!prevChildren.length) {
  12258. return;
  12259. }
  12260. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  12261. if (!hasCSSTransform(
  12262. prevChildren[0].el,
  12263. instance.vnode.el,
  12264. moveClass
  12265. )) {
  12266. prevChildren = [];
  12267. return;
  12268. }
  12269. prevChildren.forEach(callPendingCbs);
  12270. prevChildren.forEach(recordPosition);
  12271. const movedChildren = prevChildren.filter(applyTranslation);
  12272. forceReflow(instance.vnode.el);
  12273. movedChildren.forEach((c) => {
  12274. const el = c.el;
  12275. const style = el.style;
  12276. addTransitionClass(el, moveClass);
  12277. style.transform = style.webkitTransform = style.transitionDuration = "";
  12278. const cb = el[moveCbKey] = (e) => {
  12279. if (e && e.target !== el) {
  12280. return;
  12281. }
  12282. if (!e || e.propertyName.endsWith("transform")) {
  12283. el.removeEventListener("transitionend", cb);
  12284. el[moveCbKey] = null;
  12285. removeTransitionClass(el, moveClass);
  12286. }
  12287. };
  12288. el.addEventListener("transitionend", cb);
  12289. });
  12290. prevChildren = [];
  12291. });
  12292. return () => {
  12293. const rawProps = toRaw(props);
  12294. const cssTransitionProps = resolveTransitionProps(rawProps);
  12295. let tag = rawProps.tag || Fragment;
  12296. prevChildren = [];
  12297. if (children) {
  12298. for (let i = 0; i < children.length; i++) {
  12299. const child = children[i];
  12300. if (child.el && child.el instanceof Element) {
  12301. prevChildren.push(child);
  12302. setTransitionHooks(
  12303. child,
  12304. resolveTransitionHooks(
  12305. child,
  12306. cssTransitionProps,
  12307. state,
  12308. instance
  12309. )
  12310. );
  12311. positionMap.set(child, getPosition(child.el));
  12312. }
  12313. }
  12314. }
  12315. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  12316. for (let i = 0; i < children.length; i++) {
  12317. const child = children[i];
  12318. if (child.key != null) {
  12319. setTransitionHooks(
  12320. child,
  12321. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  12322. );
  12323. } else if (child.type !== Text) {
  12324. warn(`<TransitionGroup> children must be keyed.`);
  12325. }
  12326. }
  12327. return createVNode(tag, null, children);
  12328. };
  12329. }
  12330. });
  12331. const TransitionGroup = TransitionGroupImpl;
  12332. function callPendingCbs(c) {
  12333. const el = c.el;
  12334. if (el[moveCbKey]) {
  12335. el[moveCbKey]();
  12336. }
  12337. if (el[enterCbKey]) {
  12338. el[enterCbKey]();
  12339. }
  12340. }
  12341. function recordPosition(c) {
  12342. newPositionMap.set(c, getPosition(c.el));
  12343. }
  12344. function applyTranslation(c) {
  12345. const oldPos = positionMap.get(c);
  12346. const newPos = newPositionMap.get(c);
  12347. const dx = oldPos.left - newPos.left;
  12348. const dy = oldPos.top - newPos.top;
  12349. if (dx || dy) {
  12350. const el = c.el;
  12351. const s = el.style;
  12352. const rect = el.getBoundingClientRect();
  12353. let scaleX = 1;
  12354. let scaleY = 1;
  12355. if (el.offsetWidth) scaleX = rect.width / el.offsetWidth;
  12356. if (el.offsetHeight) scaleY = rect.height / el.offsetHeight;
  12357. if (!Number.isFinite(scaleX) || scaleX === 0) scaleX = 1;
  12358. if (!Number.isFinite(scaleY) || scaleY === 0) scaleY = 1;
  12359. if (Math.abs(scaleX - 1) < 0.01) scaleX = 1;
  12360. if (Math.abs(scaleY - 1) < 0.01) scaleY = 1;
  12361. s.transform = s.webkitTransform = `translate(${dx / scaleX}px,${dy / scaleY}px)`;
  12362. s.transitionDuration = "0s";
  12363. return c;
  12364. }
  12365. }
  12366. function getPosition(el) {
  12367. const rect = el.getBoundingClientRect();
  12368. return {
  12369. left: rect.left,
  12370. top: rect.top
  12371. };
  12372. }
  12373. function hasCSSTransform(el, root, moveClass) {
  12374. const clone = el.cloneNode();
  12375. const _vtc = el[vtcKey];
  12376. if (_vtc) {
  12377. _vtc.forEach((cls) => {
  12378. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  12379. });
  12380. }
  12381. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  12382. clone.style.display = "none";
  12383. const container = root.nodeType === 1 ? root : root.parentNode;
  12384. container.appendChild(clone);
  12385. const { hasTransform } = getTransitionInfo(clone);
  12386. container.removeChild(clone);
  12387. return hasTransform;
  12388. }
  12389. const getModelAssigner = (vnode) => {
  12390. const fn = vnode.props["onUpdate:modelValue"] || false;
  12391. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  12392. };
  12393. function onCompositionStart(e) {
  12394. e.target.composing = true;
  12395. }
  12396. function onCompositionEnd(e) {
  12397. const target = e.target;
  12398. if (target.composing) {
  12399. target.composing = false;
  12400. target.dispatchEvent(new Event("input"));
  12401. }
  12402. }
  12403. const assignKey = /* @__PURE__ */ Symbol("_assign");
  12404. function castValue(value, trim, number) {
  12405. if (trim) value = value.trim();
  12406. if (number) value = looseToNumber(value);
  12407. return value;
  12408. }
  12409. const vModelText = {
  12410. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  12411. el[assignKey] = getModelAssigner(vnode);
  12412. const castToNumber = number || vnode.props && vnode.props.type === "number";
  12413. addEventListener(el, lazy ? "change" : "input", (e) => {
  12414. if (e.target.composing) return;
  12415. el[assignKey](castValue(el.value, trim, castToNumber));
  12416. });
  12417. if (trim || castToNumber) {
  12418. addEventListener(el, "change", () => {
  12419. el.value = castValue(el.value, trim, castToNumber);
  12420. });
  12421. }
  12422. if (!lazy) {
  12423. addEventListener(el, "compositionstart", onCompositionStart);
  12424. addEventListener(el, "compositionend", onCompositionEnd);
  12425. addEventListener(el, "change", onCompositionEnd);
  12426. }
  12427. },
  12428. // set value on mounted so it's after min/max for type="range"
  12429. mounted(el, { value }) {
  12430. el.value = value == null ? "" : value;
  12431. },
  12432. beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
  12433. el[assignKey] = getModelAssigner(vnode);
  12434. if (el.composing) return;
  12435. const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
  12436. const newValue = value == null ? "" : value;
  12437. if (elValue === newValue) {
  12438. return;
  12439. }
  12440. const rootNode = el.getRootNode();
  12441. if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
  12442. if (lazy && value === oldValue) {
  12443. return;
  12444. }
  12445. if (trim && el.value.trim() === newValue) {
  12446. return;
  12447. }
  12448. }
  12449. el.value = newValue;
  12450. }
  12451. };
  12452. const vModelCheckbox = {
  12453. // #4096 array checkboxes need to be deep traversed
  12454. deep: true,
  12455. created(el, _, vnode) {
  12456. el[assignKey] = getModelAssigner(vnode);
  12457. addEventListener(el, "change", () => {
  12458. const modelValue = el._modelValue;
  12459. const elementValue = getValue(el);
  12460. const checked = el.checked;
  12461. const assign = el[assignKey];
  12462. if (isArray(modelValue)) {
  12463. const index = looseIndexOf(modelValue, elementValue);
  12464. const found = index !== -1;
  12465. if (checked && !found) {
  12466. assign(modelValue.concat(elementValue));
  12467. } else if (!checked && found) {
  12468. const filtered = [...modelValue];
  12469. filtered.splice(index, 1);
  12470. assign(filtered);
  12471. }
  12472. } else if (isSet(modelValue)) {
  12473. const cloned = new Set(modelValue);
  12474. if (checked) {
  12475. cloned.add(elementValue);
  12476. } else {
  12477. cloned.delete(elementValue);
  12478. }
  12479. assign(cloned);
  12480. } else {
  12481. assign(getCheckboxValue(el, checked));
  12482. }
  12483. });
  12484. },
  12485. // set initial checked on mount to wait for true-value/false-value
  12486. mounted: setChecked,
  12487. beforeUpdate(el, binding, vnode) {
  12488. el[assignKey] = getModelAssigner(vnode);
  12489. setChecked(el, binding, vnode);
  12490. }
  12491. };
  12492. function setChecked(el, { value, oldValue }, vnode) {
  12493. el._modelValue = value;
  12494. let checked;
  12495. if (isArray(value)) {
  12496. checked = looseIndexOf(value, vnode.props.value) > -1;
  12497. } else if (isSet(value)) {
  12498. checked = value.has(vnode.props.value);
  12499. } else {
  12500. if (value === oldValue) return;
  12501. checked = looseEqual(value, getCheckboxValue(el, true));
  12502. }
  12503. if (el.checked !== checked) {
  12504. el.checked = checked;
  12505. }
  12506. }
  12507. const vModelRadio = {
  12508. created(el, { value }, vnode) {
  12509. el.checked = looseEqual(value, vnode.props.value);
  12510. el[assignKey] = getModelAssigner(vnode);
  12511. addEventListener(el, "change", () => {
  12512. el[assignKey](getValue(el));
  12513. });
  12514. },
  12515. beforeUpdate(el, { value, oldValue }, vnode) {
  12516. el[assignKey] = getModelAssigner(vnode);
  12517. if (value !== oldValue) {
  12518. el.checked = looseEqual(value, vnode.props.value);
  12519. }
  12520. }
  12521. };
  12522. const vModelSelect = {
  12523. // <select multiple> value need to be deep traversed
  12524. deep: true,
  12525. created(el, { value, modifiers: { number } }, vnode) {
  12526. const isSetModel = isSet(value);
  12527. addEventListener(el, "change", () => {
  12528. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  12529. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  12530. );
  12531. el[assignKey](
  12532. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  12533. );
  12534. el._assigning = true;
  12535. nextTick(() => {
  12536. el._assigning = false;
  12537. });
  12538. });
  12539. el[assignKey] = getModelAssigner(vnode);
  12540. },
  12541. // set value in mounted & updated because <select> relies on its children
  12542. // <option>s.
  12543. mounted(el, { value }) {
  12544. setSelected(el, value);
  12545. },
  12546. beforeUpdate(el, _binding, vnode) {
  12547. el[assignKey] = getModelAssigner(vnode);
  12548. },
  12549. updated(el, { value }) {
  12550. if (!el._assigning) {
  12551. setSelected(el, value);
  12552. }
  12553. }
  12554. };
  12555. function setSelected(el, value) {
  12556. const isMultiple = el.multiple;
  12557. const isArrayValue = isArray(value);
  12558. if (isMultiple && !isArrayValue && !isSet(value)) {
  12559. warn(
  12560. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  12561. );
  12562. return;
  12563. }
  12564. for (let i = 0, l = el.options.length; i < l; i++) {
  12565. const option = el.options[i];
  12566. const optionValue = getValue(option);
  12567. if (isMultiple) {
  12568. if (isArrayValue) {
  12569. const optionType = typeof optionValue;
  12570. if (optionType === "string" || optionType === "number") {
  12571. option.selected = value.some((v) => String(v) === String(optionValue));
  12572. } else {
  12573. option.selected = looseIndexOf(value, optionValue) > -1;
  12574. }
  12575. } else {
  12576. option.selected = value.has(optionValue);
  12577. }
  12578. } else if (looseEqual(getValue(option), value)) {
  12579. if (el.selectedIndex !== i) el.selectedIndex = i;
  12580. return;
  12581. }
  12582. }
  12583. if (!isMultiple && el.selectedIndex !== -1) {
  12584. el.selectedIndex = -1;
  12585. }
  12586. }
  12587. function getValue(el) {
  12588. return "_value" in el ? el._value : el.value;
  12589. }
  12590. function getCheckboxValue(el, checked) {
  12591. const key = checked ? "_trueValue" : "_falseValue";
  12592. return key in el ? el[key] : checked;
  12593. }
  12594. const vModelDynamic = {
  12595. created(el, binding, vnode) {
  12596. callModelHook(el, binding, vnode, null, "created");
  12597. },
  12598. mounted(el, binding, vnode) {
  12599. callModelHook(el, binding, vnode, null, "mounted");
  12600. },
  12601. beforeUpdate(el, binding, vnode, prevVNode) {
  12602. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  12603. },
  12604. updated(el, binding, vnode, prevVNode) {
  12605. callModelHook(el, binding, vnode, prevVNode, "updated");
  12606. }
  12607. };
  12608. function resolveDynamicModel(tagName, type) {
  12609. switch (tagName) {
  12610. case "SELECT":
  12611. return vModelSelect;
  12612. case "TEXTAREA":
  12613. return vModelText;
  12614. default:
  12615. switch (type) {
  12616. case "checkbox":
  12617. return vModelCheckbox;
  12618. case "radio":
  12619. return vModelRadio;
  12620. default:
  12621. return vModelText;
  12622. }
  12623. }
  12624. }
  12625. function callModelHook(el, binding, vnode, prevVNode, hook) {
  12626. const modelToUse = resolveDynamicModel(
  12627. el.tagName,
  12628. vnode.props && vnode.props.type
  12629. );
  12630. const fn = modelToUse[hook];
  12631. fn && fn(el, binding, vnode, prevVNode);
  12632. }
  12633. function initVModelForSSR() {
  12634. vModelText.getSSRProps = ({ value }) => ({ value });
  12635. vModelRadio.getSSRProps = ({ value }, vnode) => {
  12636. if (vnode.props && looseEqual(vnode.props.value, value)) {
  12637. return { checked: true };
  12638. }
  12639. };
  12640. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  12641. if (isArray(value)) {
  12642. if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
  12643. return { checked: true };
  12644. }
  12645. } else if (isSet(value)) {
  12646. if (vnode.props && value.has(vnode.props.value)) {
  12647. return { checked: true };
  12648. }
  12649. } else if (value) {
  12650. return { checked: true };
  12651. }
  12652. };
  12653. vModelDynamic.getSSRProps = (binding, vnode) => {
  12654. if (typeof vnode.type !== "string") {
  12655. return;
  12656. }
  12657. const modelToUse = resolveDynamicModel(
  12658. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  12659. vnode.type.toUpperCase(),
  12660. vnode.props && vnode.props.type
  12661. );
  12662. if (modelToUse.getSSRProps) {
  12663. return modelToUse.getSSRProps(binding, vnode);
  12664. }
  12665. };
  12666. }
  12667. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  12668. const modifierGuards = {
  12669. stop: (e) => e.stopPropagation(),
  12670. prevent: (e) => e.preventDefault(),
  12671. self: (e) => e.target !== e.currentTarget,
  12672. ctrl: (e) => !e.ctrlKey,
  12673. shift: (e) => !e.shiftKey,
  12674. alt: (e) => !e.altKey,
  12675. meta: (e) => !e.metaKey,
  12676. left: (e) => "button" in e && e.button !== 0,
  12677. middle: (e) => "button" in e && e.button !== 1,
  12678. right: (e) => "button" in e && e.button !== 2,
  12679. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  12680. };
  12681. const withModifiers = (fn, modifiers) => {
  12682. if (!fn) return fn;
  12683. const cache = fn._withMods || (fn._withMods = {});
  12684. const cacheKey = modifiers.join(".");
  12685. return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
  12686. for (let i = 0; i < modifiers.length; i++) {
  12687. const guard = modifierGuards[modifiers[i]];
  12688. if (guard && guard(event, modifiers)) return;
  12689. }
  12690. return fn(event, ...args);
  12691. }));
  12692. };
  12693. const keyNames = {
  12694. esc: "escape",
  12695. space: " ",
  12696. up: "arrow-up",
  12697. left: "arrow-left",
  12698. right: "arrow-right",
  12699. down: "arrow-down",
  12700. delete: "backspace"
  12701. };
  12702. const withKeys = (fn, modifiers) => {
  12703. const cache = fn._withKeys || (fn._withKeys = {});
  12704. const cacheKey = modifiers.join(".");
  12705. return cache[cacheKey] || (cache[cacheKey] = ((event) => {
  12706. if (!("key" in event)) {
  12707. return;
  12708. }
  12709. const eventKey = hyphenate(event.key);
  12710. if (modifiers.some(
  12711. (k) => k === eventKey || keyNames[k] === eventKey
  12712. )) {
  12713. return fn(event);
  12714. }
  12715. }));
  12716. };
  12717. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  12718. let renderer;
  12719. let enabledHydration = false;
  12720. function ensureRenderer() {
  12721. return renderer || (renderer = createRenderer(rendererOptions));
  12722. }
  12723. function ensureHydrationRenderer() {
  12724. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  12725. enabledHydration = true;
  12726. return renderer;
  12727. }
  12728. const render = ((...args) => {
  12729. ensureRenderer().render(...args);
  12730. });
  12731. const hydrate = ((...args) => {
  12732. ensureHydrationRenderer().hydrate(...args);
  12733. });
  12734. const createApp = ((...args) => {
  12735. const app = ensureRenderer().createApp(...args);
  12736. {
  12737. injectNativeTagCheck(app);
  12738. injectCompilerOptionsCheck(app);
  12739. }
  12740. const { mount } = app;
  12741. app.mount = (containerOrSelector) => {
  12742. const container = normalizeContainer(containerOrSelector);
  12743. if (!container) return;
  12744. const component = app._component;
  12745. if (!isFunction(component) && !component.render && !component.template) {
  12746. component.template = container.innerHTML;
  12747. }
  12748. if (container.nodeType === 1) {
  12749. container.textContent = "";
  12750. }
  12751. const proxy = mount(container, false, resolveRootNamespace(container));
  12752. if (container instanceof Element) {
  12753. container.removeAttribute("v-cloak");
  12754. container.setAttribute("data-v-app", "");
  12755. }
  12756. return proxy;
  12757. };
  12758. return app;
  12759. });
  12760. const createSSRApp = ((...args) => {
  12761. const app = ensureHydrationRenderer().createApp(...args);
  12762. {
  12763. injectNativeTagCheck(app);
  12764. injectCompilerOptionsCheck(app);
  12765. }
  12766. const { mount } = app;
  12767. app.mount = (containerOrSelector) => {
  12768. const container = normalizeContainer(containerOrSelector);
  12769. if (container) {
  12770. return mount(container, true, resolveRootNamespace(container));
  12771. }
  12772. };
  12773. return app;
  12774. });
  12775. function resolveRootNamespace(container) {
  12776. if (container instanceof SVGElement) {
  12777. return "svg";
  12778. }
  12779. if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
  12780. return "mathml";
  12781. }
  12782. }
  12783. function injectNativeTagCheck(app) {
  12784. Object.defineProperty(app.config, "isNativeTag", {
  12785. value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  12786. writable: false
  12787. });
  12788. }
  12789. function injectCompilerOptionsCheck(app) {
  12790. if (isRuntimeOnly()) {
  12791. const isCustomElement = app.config.isCustomElement;
  12792. Object.defineProperty(app.config, "isCustomElement", {
  12793. get() {
  12794. return isCustomElement;
  12795. },
  12796. set() {
  12797. warn(
  12798. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  12799. );
  12800. }
  12801. });
  12802. const compilerOptions = app.config.compilerOptions;
  12803. 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.
  12804. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  12805. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  12806. - 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`;
  12807. Object.defineProperty(app.config, "compilerOptions", {
  12808. get() {
  12809. warn(msg);
  12810. return compilerOptions;
  12811. },
  12812. set() {
  12813. warn(msg);
  12814. }
  12815. });
  12816. }
  12817. }
  12818. function normalizeContainer(container) {
  12819. if (isString(container)) {
  12820. const res = document.querySelector(container);
  12821. if (!res) {
  12822. warn(
  12823. `Failed to mount app: mount target selector "${container}" returned null.`
  12824. );
  12825. }
  12826. return res;
  12827. }
  12828. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  12829. warn(
  12830. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  12831. );
  12832. }
  12833. return container;
  12834. }
  12835. let ssrDirectiveInitialized = false;
  12836. const initDirectivesForSSR = () => {
  12837. if (!ssrDirectiveInitialized) {
  12838. ssrDirectiveInitialized = true;
  12839. initVModelForSSR();
  12840. initVShowForSSR();
  12841. }
  12842. } ;
  12843. var runtimeDom = /*#__PURE__*/Object.freeze({
  12844. __proto__: null,
  12845. BaseTransition: BaseTransition,
  12846. BaseTransitionPropsValidators: BaseTransitionPropsValidators,
  12847. Comment: Comment,
  12848. DeprecationTypes: DeprecationTypes,
  12849. EffectScope: EffectScope,
  12850. ErrorCodes: ErrorCodes,
  12851. ErrorTypeStrings: ErrorTypeStrings,
  12852. Fragment: Fragment,
  12853. KeepAlive: KeepAlive,
  12854. ReactiveEffect: ReactiveEffect,
  12855. Static: Static,
  12856. Suspense: Suspense,
  12857. Teleport: Teleport,
  12858. Text: Text,
  12859. TrackOpTypes: TrackOpTypes,
  12860. Transition: Transition,
  12861. TransitionGroup: TransitionGroup,
  12862. TriggerOpTypes: TriggerOpTypes,
  12863. VueElement: VueElement,
  12864. assertNumber: assertNumber,
  12865. callWithAsyncErrorHandling: callWithAsyncErrorHandling,
  12866. callWithErrorHandling: callWithErrorHandling,
  12867. camelize: camelize,
  12868. capitalize: capitalize,
  12869. cloneVNode: cloneVNode,
  12870. compatUtils: compatUtils,
  12871. computed: computed,
  12872. createApp: createApp,
  12873. createBlock: createBlock,
  12874. createCommentVNode: createCommentVNode,
  12875. createElementBlock: createElementBlock,
  12876. createElementVNode: createBaseVNode,
  12877. createHydrationRenderer: createHydrationRenderer,
  12878. createPropsRestProxy: createPropsRestProxy,
  12879. createRenderer: createRenderer,
  12880. createSSRApp: createSSRApp,
  12881. createSlots: createSlots,
  12882. createStaticVNode: createStaticVNode,
  12883. createTextVNode: createTextVNode,
  12884. createVNode: createVNode,
  12885. customRef: customRef,
  12886. defineAsyncComponent: defineAsyncComponent,
  12887. defineComponent: defineComponent,
  12888. defineCustomElement: defineCustomElement,
  12889. defineEmits: defineEmits,
  12890. defineExpose: defineExpose,
  12891. defineModel: defineModel,
  12892. defineOptions: defineOptions,
  12893. defineProps: defineProps,
  12894. defineSSRCustomElement: defineSSRCustomElement,
  12895. defineSlots: defineSlots,
  12896. devtools: devtools,
  12897. effect: effect,
  12898. effectScope: effectScope,
  12899. getCurrentInstance: getCurrentInstance,
  12900. getCurrentScope: getCurrentScope,
  12901. getCurrentWatcher: getCurrentWatcher,
  12902. getTransitionRawChildren: getTransitionRawChildren,
  12903. guardReactiveProps: guardReactiveProps,
  12904. h: h,
  12905. handleError: handleError,
  12906. hasInjectionContext: hasInjectionContext,
  12907. hydrate: hydrate,
  12908. hydrateOnIdle: hydrateOnIdle,
  12909. hydrateOnInteraction: hydrateOnInteraction,
  12910. hydrateOnMediaQuery: hydrateOnMediaQuery,
  12911. hydrateOnVisible: hydrateOnVisible,
  12912. initCustomFormatter: initCustomFormatter,
  12913. initDirectivesForSSR: initDirectivesForSSR,
  12914. inject: inject,
  12915. isMemoSame: isMemoSame,
  12916. isProxy: isProxy,
  12917. isReactive: isReactive,
  12918. isReadonly: isReadonly,
  12919. isRef: isRef,
  12920. isRuntimeOnly: isRuntimeOnly,
  12921. isShallow: isShallow,
  12922. isVNode: isVNode,
  12923. markRaw: markRaw,
  12924. mergeDefaults: mergeDefaults,
  12925. mergeModels: mergeModels,
  12926. mergeProps: mergeProps,
  12927. nextTick: nextTick,
  12928. nodeOps: nodeOps,
  12929. normalizeClass: normalizeClass,
  12930. normalizeProps: normalizeProps,
  12931. normalizeStyle: normalizeStyle,
  12932. onActivated: onActivated,
  12933. onBeforeMount: onBeforeMount,
  12934. onBeforeUnmount: onBeforeUnmount,
  12935. onBeforeUpdate: onBeforeUpdate,
  12936. onDeactivated: onDeactivated,
  12937. onErrorCaptured: onErrorCaptured,
  12938. onMounted: onMounted,
  12939. onRenderTracked: onRenderTracked,
  12940. onRenderTriggered: onRenderTriggered,
  12941. onScopeDispose: onScopeDispose,
  12942. onServerPrefetch: onServerPrefetch,
  12943. onUnmounted: onUnmounted,
  12944. onUpdated: onUpdated,
  12945. onWatcherCleanup: onWatcherCleanup,
  12946. openBlock: openBlock,
  12947. patchProp: patchProp,
  12948. popScopeId: popScopeId,
  12949. provide: provide,
  12950. proxyRefs: proxyRefs,
  12951. pushScopeId: pushScopeId,
  12952. queuePostFlushCb: queuePostFlushCb,
  12953. reactive: reactive,
  12954. readonly: readonly,
  12955. ref: ref,
  12956. registerRuntimeCompiler: registerRuntimeCompiler,
  12957. render: render,
  12958. renderList: renderList,
  12959. renderSlot: renderSlot,
  12960. resolveComponent: resolveComponent,
  12961. resolveDirective: resolveDirective,
  12962. resolveDynamicComponent: resolveDynamicComponent,
  12963. resolveFilter: resolveFilter,
  12964. resolveTransitionHooks: resolveTransitionHooks,
  12965. setBlockTracking: setBlockTracking,
  12966. setDevtoolsHook: setDevtoolsHook,
  12967. setTransitionHooks: setTransitionHooks,
  12968. shallowReactive: shallowReactive,
  12969. shallowReadonly: shallowReadonly,
  12970. shallowRef: shallowRef,
  12971. ssrContextKey: ssrContextKey,
  12972. ssrUtils: ssrUtils,
  12973. stop: stop,
  12974. toDisplayString: toDisplayString,
  12975. toHandlerKey: toHandlerKey,
  12976. toHandlers: toHandlers,
  12977. toRaw: toRaw,
  12978. toRef: toRef,
  12979. toRefs: toRefs,
  12980. toValue: toValue,
  12981. transformVNodeArgs: transformVNodeArgs,
  12982. triggerRef: triggerRef,
  12983. unref: unref,
  12984. useAttrs: useAttrs,
  12985. useCssModule: useCssModule,
  12986. useCssVars: useCssVars,
  12987. useHost: useHost,
  12988. useId: useId,
  12989. useModel: useModel,
  12990. useSSRContext: useSSRContext,
  12991. useShadowRoot: useShadowRoot,
  12992. useSlots: useSlots,
  12993. useTemplateRef: useTemplateRef,
  12994. useTransitionState: useTransitionState,
  12995. vModelCheckbox: vModelCheckbox,
  12996. vModelDynamic: vModelDynamic,
  12997. vModelRadio: vModelRadio,
  12998. vModelSelect: vModelSelect,
  12999. vModelText: vModelText,
  13000. vShow: vShow,
  13001. version: version,
  13002. warn: warn,
  13003. watch: watch,
  13004. watchEffect: watchEffect,
  13005. watchPostEffect: watchPostEffect,
  13006. watchSyncEffect: watchSyncEffect,
  13007. withAsyncContext: withAsyncContext,
  13008. withCtx: withCtx,
  13009. withDefaults: withDefaults,
  13010. withDirectives: withDirectives,
  13011. withKeys: withKeys,
  13012. withMemo: withMemo,
  13013. withModifiers: withModifiers,
  13014. withScopeId: withScopeId
  13015. });
  13016. function initDev() {
  13017. {
  13018. {
  13019. console.info(
  13020. `You are running a development build of Vue.
  13021. Make sure to use the production build (*.prod.js) when deploying for production.`
  13022. );
  13023. }
  13024. initCustomFormatter();
  13025. }
  13026. }
  13027. const FRAGMENT = /* @__PURE__ */ Symbol(`Fragment` );
  13028. const TELEPORT = /* @__PURE__ */ Symbol(`Teleport` );
  13029. const SUSPENSE = /* @__PURE__ */ Symbol(`Suspense` );
  13030. const KEEP_ALIVE = /* @__PURE__ */ Symbol(`KeepAlive` );
  13031. const BASE_TRANSITION = /* @__PURE__ */ Symbol(
  13032. `BaseTransition`
  13033. );
  13034. const OPEN_BLOCK = /* @__PURE__ */ Symbol(`openBlock` );
  13035. const CREATE_BLOCK = /* @__PURE__ */ Symbol(`createBlock` );
  13036. const CREATE_ELEMENT_BLOCK = /* @__PURE__ */ Symbol(
  13037. `createElementBlock`
  13038. );
  13039. const CREATE_VNODE = /* @__PURE__ */ Symbol(`createVNode` );
  13040. const CREATE_ELEMENT_VNODE = /* @__PURE__ */ Symbol(
  13041. `createElementVNode`
  13042. );
  13043. const CREATE_COMMENT = /* @__PURE__ */ Symbol(
  13044. `createCommentVNode`
  13045. );
  13046. const CREATE_TEXT = /* @__PURE__ */ Symbol(
  13047. `createTextVNode`
  13048. );
  13049. const CREATE_STATIC = /* @__PURE__ */ Symbol(
  13050. `createStaticVNode`
  13051. );
  13052. const RESOLVE_COMPONENT = /* @__PURE__ */ Symbol(
  13053. `resolveComponent`
  13054. );
  13055. const RESOLVE_DYNAMIC_COMPONENT = /* @__PURE__ */ Symbol(
  13056. `resolveDynamicComponent`
  13057. );
  13058. const RESOLVE_DIRECTIVE = /* @__PURE__ */ Symbol(
  13059. `resolveDirective`
  13060. );
  13061. const RESOLVE_FILTER = /* @__PURE__ */ Symbol(
  13062. `resolveFilter`
  13063. );
  13064. const WITH_DIRECTIVES = /* @__PURE__ */ Symbol(
  13065. `withDirectives`
  13066. );
  13067. const RENDER_LIST = /* @__PURE__ */ Symbol(`renderList` );
  13068. const RENDER_SLOT = /* @__PURE__ */ Symbol(`renderSlot` );
  13069. const CREATE_SLOTS = /* @__PURE__ */ Symbol(`createSlots` );
  13070. const TO_DISPLAY_STRING = /* @__PURE__ */ Symbol(
  13071. `toDisplayString`
  13072. );
  13073. const MERGE_PROPS = /* @__PURE__ */ Symbol(`mergeProps` );
  13074. const NORMALIZE_CLASS = /* @__PURE__ */ Symbol(
  13075. `normalizeClass`
  13076. );
  13077. const NORMALIZE_STYLE = /* @__PURE__ */ Symbol(
  13078. `normalizeStyle`
  13079. );
  13080. const NORMALIZE_PROPS = /* @__PURE__ */ Symbol(
  13081. `normalizeProps`
  13082. );
  13083. const GUARD_REACTIVE_PROPS = /* @__PURE__ */ Symbol(
  13084. `guardReactiveProps`
  13085. );
  13086. const TO_HANDLERS = /* @__PURE__ */ Symbol(`toHandlers` );
  13087. const CAMELIZE = /* @__PURE__ */ Symbol(`camelize` );
  13088. const CAPITALIZE = /* @__PURE__ */ Symbol(`capitalize` );
  13089. const TO_HANDLER_KEY = /* @__PURE__ */ Symbol(
  13090. `toHandlerKey`
  13091. );
  13092. const SET_BLOCK_TRACKING = /* @__PURE__ */ Symbol(
  13093. `setBlockTracking`
  13094. );
  13095. const PUSH_SCOPE_ID = /* @__PURE__ */ Symbol(`pushScopeId` );
  13096. const POP_SCOPE_ID = /* @__PURE__ */ Symbol(`popScopeId` );
  13097. const WITH_CTX = /* @__PURE__ */ Symbol(`withCtx` );
  13098. const UNREF = /* @__PURE__ */ Symbol(`unref` );
  13099. const IS_REF = /* @__PURE__ */ Symbol(`isRef` );
  13100. const WITH_MEMO = /* @__PURE__ */ Symbol(`withMemo` );
  13101. const IS_MEMO_SAME = /* @__PURE__ */ Symbol(`isMemoSame` );
  13102. const helperNameMap = {
  13103. [FRAGMENT]: `Fragment`,
  13104. [TELEPORT]: `Teleport`,
  13105. [SUSPENSE]: `Suspense`,
  13106. [KEEP_ALIVE]: `KeepAlive`,
  13107. [BASE_TRANSITION]: `BaseTransition`,
  13108. [OPEN_BLOCK]: `openBlock`,
  13109. [CREATE_BLOCK]: `createBlock`,
  13110. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  13111. [CREATE_VNODE]: `createVNode`,
  13112. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  13113. [CREATE_COMMENT]: `createCommentVNode`,
  13114. [CREATE_TEXT]: `createTextVNode`,
  13115. [CREATE_STATIC]: `createStaticVNode`,
  13116. [RESOLVE_COMPONENT]: `resolveComponent`,
  13117. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  13118. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  13119. [RESOLVE_FILTER]: `resolveFilter`,
  13120. [WITH_DIRECTIVES]: `withDirectives`,
  13121. [RENDER_LIST]: `renderList`,
  13122. [RENDER_SLOT]: `renderSlot`,
  13123. [CREATE_SLOTS]: `createSlots`,
  13124. [TO_DISPLAY_STRING]: `toDisplayString`,
  13125. [MERGE_PROPS]: `mergeProps`,
  13126. [NORMALIZE_CLASS]: `normalizeClass`,
  13127. [NORMALIZE_STYLE]: `normalizeStyle`,
  13128. [NORMALIZE_PROPS]: `normalizeProps`,
  13129. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  13130. [TO_HANDLERS]: `toHandlers`,
  13131. [CAMELIZE]: `camelize`,
  13132. [CAPITALIZE]: `capitalize`,
  13133. [TO_HANDLER_KEY]: `toHandlerKey`,
  13134. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  13135. [PUSH_SCOPE_ID]: `pushScopeId`,
  13136. [POP_SCOPE_ID]: `popScopeId`,
  13137. [WITH_CTX]: `withCtx`,
  13138. [UNREF]: `unref`,
  13139. [IS_REF]: `isRef`,
  13140. [WITH_MEMO]: `withMemo`,
  13141. [IS_MEMO_SAME]: `isMemoSame`
  13142. };
  13143. function registerRuntimeHelpers(helpers) {
  13144. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  13145. helperNameMap[s] = helpers[s];
  13146. });
  13147. }
  13148. const locStub = {
  13149. start: { line: 1, column: 1, offset: 0 },
  13150. end: { line: 1, column: 1, offset: 0 },
  13151. source: ""
  13152. };
  13153. function createRoot(children, source = "") {
  13154. return {
  13155. type: 0,
  13156. source,
  13157. children,
  13158. helpers: /* @__PURE__ */ new Set(),
  13159. components: [],
  13160. directives: [],
  13161. hoists: [],
  13162. imports: [],
  13163. cached: [],
  13164. temps: 0,
  13165. codegenNode: void 0,
  13166. loc: locStub
  13167. };
  13168. }
  13169. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  13170. if (context) {
  13171. if (isBlock) {
  13172. context.helper(OPEN_BLOCK);
  13173. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  13174. } else {
  13175. context.helper(getVNodeHelper(context.inSSR, isComponent));
  13176. }
  13177. if (directives) {
  13178. context.helper(WITH_DIRECTIVES);
  13179. }
  13180. }
  13181. return {
  13182. type: 13,
  13183. tag,
  13184. props,
  13185. children,
  13186. patchFlag,
  13187. dynamicProps,
  13188. directives,
  13189. isBlock,
  13190. disableTracking,
  13191. isComponent,
  13192. loc
  13193. };
  13194. }
  13195. function createArrayExpression(elements, loc = locStub) {
  13196. return {
  13197. type: 17,
  13198. loc,
  13199. elements
  13200. };
  13201. }
  13202. function createObjectExpression(properties, loc = locStub) {
  13203. return {
  13204. type: 15,
  13205. loc,
  13206. properties
  13207. };
  13208. }
  13209. function createObjectProperty(key, value) {
  13210. return {
  13211. type: 16,
  13212. loc: locStub,
  13213. key: isString(key) ? createSimpleExpression(key, true) : key,
  13214. value
  13215. };
  13216. }
  13217. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  13218. return {
  13219. type: 4,
  13220. loc,
  13221. content,
  13222. isStatic,
  13223. constType: isStatic ? 3 : constType
  13224. };
  13225. }
  13226. function createCompoundExpression(children, loc = locStub) {
  13227. return {
  13228. type: 8,
  13229. loc,
  13230. children
  13231. };
  13232. }
  13233. function createCallExpression(callee, args = [], loc = locStub) {
  13234. return {
  13235. type: 14,
  13236. loc,
  13237. callee,
  13238. arguments: args
  13239. };
  13240. }
  13241. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  13242. return {
  13243. type: 18,
  13244. params,
  13245. returns,
  13246. newline,
  13247. isSlot,
  13248. loc
  13249. };
  13250. }
  13251. function createConditionalExpression(test, consequent, alternate, newline = true) {
  13252. return {
  13253. type: 19,
  13254. test,
  13255. consequent,
  13256. alternate,
  13257. newline,
  13258. loc: locStub
  13259. };
  13260. }
  13261. function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
  13262. return {
  13263. type: 20,
  13264. index,
  13265. value,
  13266. needPauseTracking,
  13267. inVOnce,
  13268. needArraySpread: false,
  13269. loc: locStub
  13270. };
  13271. }
  13272. function createBlockStatement(body) {
  13273. return {
  13274. type: 21,
  13275. body,
  13276. loc: locStub
  13277. };
  13278. }
  13279. function getVNodeHelper(ssr, isComponent) {
  13280. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  13281. }
  13282. function getVNodeBlockHelper(ssr, isComponent) {
  13283. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  13284. }
  13285. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  13286. if (!node.isBlock) {
  13287. node.isBlock = true;
  13288. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  13289. helper(OPEN_BLOCK);
  13290. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  13291. }
  13292. }
  13293. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  13294. const defaultDelimitersClose = new Uint8Array([125, 125]);
  13295. function isTagStartChar(c) {
  13296. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  13297. }
  13298. function isWhitespace(c) {
  13299. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  13300. }
  13301. function isEndOfTagSection(c) {
  13302. return c === 47 || c === 62 || isWhitespace(c);
  13303. }
  13304. function toCharCodes(str) {
  13305. const ret = new Uint8Array(str.length);
  13306. for (let i = 0; i < str.length; i++) {
  13307. ret[i] = str.charCodeAt(i);
  13308. }
  13309. return ret;
  13310. }
  13311. const Sequences = {
  13312. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  13313. // CDATA[
  13314. CdataEnd: new Uint8Array([93, 93, 62]),
  13315. // ]]>
  13316. CommentEnd: new Uint8Array([45, 45, 62]),
  13317. // `-->`
  13318. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  13319. // `<\/script`
  13320. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  13321. // `</style`
  13322. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  13323. // `</title`
  13324. TextareaEnd: new Uint8Array([
  13325. 60,
  13326. 47,
  13327. 116,
  13328. 101,
  13329. 120,
  13330. 116,
  13331. 97,
  13332. 114,
  13333. 101,
  13334. 97
  13335. ])
  13336. // `</textarea
  13337. };
  13338. class Tokenizer {
  13339. constructor(stack, cbs) {
  13340. this.stack = stack;
  13341. this.cbs = cbs;
  13342. /** The current state the tokenizer is in. */
  13343. this.state = 1;
  13344. /** The read buffer. */
  13345. this.buffer = "";
  13346. /** The beginning of the section that is currently being read. */
  13347. this.sectionStart = 0;
  13348. /** The index within the buffer that we are currently looking at. */
  13349. this.index = 0;
  13350. /** The start of the last entity. */
  13351. this.entityStart = 0;
  13352. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  13353. this.baseState = 1;
  13354. /** For special parsing behavior inside of script and style tags. */
  13355. this.inRCDATA = false;
  13356. /** For disabling RCDATA tags handling */
  13357. this.inXML = false;
  13358. /** For disabling interpolation parsing in v-pre */
  13359. this.inVPre = false;
  13360. /** Record newline positions for fast line / column calculation */
  13361. this.newlines = [];
  13362. this.mode = 0;
  13363. this.delimiterOpen = defaultDelimitersOpen;
  13364. this.delimiterClose = defaultDelimitersClose;
  13365. this.delimiterIndex = -1;
  13366. this.currentSequence = void 0;
  13367. this.sequenceIndex = 0;
  13368. }
  13369. get inSFCRoot() {
  13370. return this.mode === 2 && this.stack.length === 0;
  13371. }
  13372. reset() {
  13373. this.state = 1;
  13374. this.mode = 0;
  13375. this.buffer = "";
  13376. this.sectionStart = 0;
  13377. this.index = 0;
  13378. this.baseState = 1;
  13379. this.inRCDATA = false;
  13380. this.currentSequence = void 0;
  13381. this.newlines.length = 0;
  13382. this.delimiterOpen = defaultDelimitersOpen;
  13383. this.delimiterClose = defaultDelimitersClose;
  13384. }
  13385. /**
  13386. * Generate Position object with line / column information using recorded
  13387. * newline positions. We know the index is always going to be an already
  13388. * processed index, so all the newlines up to this index should have been
  13389. * recorded.
  13390. */
  13391. getPos(index) {
  13392. let line = 1;
  13393. let column = index + 1;
  13394. const length = this.newlines.length;
  13395. let j = -1;
  13396. if (length > 100) {
  13397. let l = -1;
  13398. let r = length;
  13399. while (l + 1 < r) {
  13400. const m = l + r >>> 1;
  13401. this.newlines[m] < index ? l = m : r = m;
  13402. }
  13403. j = l;
  13404. } else {
  13405. for (let i = length - 1; i >= 0; i--) {
  13406. if (index > this.newlines[i]) {
  13407. j = i;
  13408. break;
  13409. }
  13410. }
  13411. }
  13412. if (j >= 0) {
  13413. line = j + 2;
  13414. column = index - this.newlines[j];
  13415. }
  13416. return {
  13417. column,
  13418. line,
  13419. offset: index
  13420. };
  13421. }
  13422. peek() {
  13423. return this.buffer.charCodeAt(this.index + 1);
  13424. }
  13425. stateText(c) {
  13426. if (c === 60) {
  13427. if (this.index > this.sectionStart) {
  13428. this.cbs.ontext(this.sectionStart, this.index);
  13429. }
  13430. this.state = 5;
  13431. this.sectionStart = this.index;
  13432. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  13433. this.state = 2;
  13434. this.delimiterIndex = 0;
  13435. this.stateInterpolationOpen(c);
  13436. }
  13437. }
  13438. stateInterpolationOpen(c) {
  13439. if (c === this.delimiterOpen[this.delimiterIndex]) {
  13440. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  13441. const start = this.index + 1 - this.delimiterOpen.length;
  13442. if (start > this.sectionStart) {
  13443. this.cbs.ontext(this.sectionStart, start);
  13444. }
  13445. this.state = 3;
  13446. this.sectionStart = start;
  13447. } else {
  13448. this.delimiterIndex++;
  13449. }
  13450. } else if (this.inRCDATA) {
  13451. this.state = 32;
  13452. this.stateInRCDATA(c);
  13453. } else {
  13454. this.state = 1;
  13455. this.stateText(c);
  13456. }
  13457. }
  13458. stateInterpolation(c) {
  13459. if (c === this.delimiterClose[0]) {
  13460. this.state = 4;
  13461. this.delimiterIndex = 0;
  13462. this.stateInterpolationClose(c);
  13463. }
  13464. }
  13465. stateInterpolationClose(c) {
  13466. if (c === this.delimiterClose[this.delimiterIndex]) {
  13467. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  13468. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  13469. if (this.inRCDATA) {
  13470. this.state = 32;
  13471. } else {
  13472. this.state = 1;
  13473. }
  13474. this.sectionStart = this.index + 1;
  13475. } else {
  13476. this.delimiterIndex++;
  13477. }
  13478. } else {
  13479. this.state = 3;
  13480. this.stateInterpolation(c);
  13481. }
  13482. }
  13483. stateSpecialStartSequence(c) {
  13484. const isEnd = this.sequenceIndex === this.currentSequence.length;
  13485. const isMatch = isEnd ? (
  13486. // If we are at the end of the sequence, make sure the tag name has ended
  13487. isEndOfTagSection(c)
  13488. ) : (
  13489. // Otherwise, do a case-insensitive comparison
  13490. (c | 32) === this.currentSequence[this.sequenceIndex]
  13491. );
  13492. if (!isMatch) {
  13493. this.inRCDATA = false;
  13494. } else if (!isEnd) {
  13495. this.sequenceIndex++;
  13496. return;
  13497. }
  13498. this.sequenceIndex = 0;
  13499. this.state = 6;
  13500. this.stateInTagName(c);
  13501. }
  13502. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  13503. stateInRCDATA(c) {
  13504. if (this.sequenceIndex === this.currentSequence.length) {
  13505. if (c === 62 || isWhitespace(c)) {
  13506. const endOfText = this.index - this.currentSequence.length;
  13507. if (this.sectionStart < endOfText) {
  13508. const actualIndex = this.index;
  13509. this.index = endOfText;
  13510. this.cbs.ontext(this.sectionStart, endOfText);
  13511. this.index = actualIndex;
  13512. }
  13513. this.sectionStart = endOfText + 2;
  13514. this.stateInClosingTagName(c);
  13515. this.inRCDATA = false;
  13516. return;
  13517. }
  13518. this.sequenceIndex = 0;
  13519. }
  13520. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  13521. this.sequenceIndex += 1;
  13522. } else if (this.sequenceIndex === 0) {
  13523. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  13524. if (!this.inVPre && c === this.delimiterOpen[0]) {
  13525. this.state = 2;
  13526. this.delimiterIndex = 0;
  13527. this.stateInterpolationOpen(c);
  13528. }
  13529. } else if (this.fastForwardTo(60)) {
  13530. this.sequenceIndex = 1;
  13531. }
  13532. } else {
  13533. this.sequenceIndex = Number(c === 60);
  13534. }
  13535. }
  13536. stateCDATASequence(c) {
  13537. if (c === Sequences.Cdata[this.sequenceIndex]) {
  13538. if (++this.sequenceIndex === Sequences.Cdata.length) {
  13539. this.state = 28;
  13540. this.currentSequence = Sequences.CdataEnd;
  13541. this.sequenceIndex = 0;
  13542. this.sectionStart = this.index + 1;
  13543. }
  13544. } else {
  13545. this.sequenceIndex = 0;
  13546. this.state = 23;
  13547. this.stateInDeclaration(c);
  13548. }
  13549. }
  13550. /**
  13551. * When we wait for one specific character, we can speed things up
  13552. * by skipping through the buffer until we find it.
  13553. *
  13554. * @returns Whether the character was found.
  13555. */
  13556. fastForwardTo(c) {
  13557. while (++this.index < this.buffer.length) {
  13558. const cc = this.buffer.charCodeAt(this.index);
  13559. if (cc === 10) {
  13560. this.newlines.push(this.index);
  13561. }
  13562. if (cc === c) {
  13563. return true;
  13564. }
  13565. }
  13566. this.index = this.buffer.length - 1;
  13567. return false;
  13568. }
  13569. /**
  13570. * Comments and CDATA end with `-->` and `]]>`.
  13571. *
  13572. * Their common qualities are:
  13573. * - Their end sequences have a distinct character they start with.
  13574. * - That character is then repeated, so we have to check multiple repeats.
  13575. * - All characters but the start character of the sequence can be skipped.
  13576. */
  13577. stateInCommentLike(c) {
  13578. if (c === this.currentSequence[this.sequenceIndex]) {
  13579. if (++this.sequenceIndex === this.currentSequence.length) {
  13580. if (this.currentSequence === Sequences.CdataEnd) {
  13581. this.cbs.oncdata(this.sectionStart, this.index - 2);
  13582. } else {
  13583. this.cbs.oncomment(this.sectionStart, this.index - 2);
  13584. }
  13585. this.sequenceIndex = 0;
  13586. this.sectionStart = this.index + 1;
  13587. this.state = 1;
  13588. }
  13589. } else if (this.sequenceIndex === 0) {
  13590. if (this.fastForwardTo(this.currentSequence[0])) {
  13591. this.sequenceIndex = 1;
  13592. }
  13593. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  13594. this.sequenceIndex = 0;
  13595. }
  13596. }
  13597. startSpecial(sequence, offset) {
  13598. this.enterRCDATA(sequence, offset);
  13599. this.state = 31;
  13600. }
  13601. enterRCDATA(sequence, offset) {
  13602. this.inRCDATA = true;
  13603. this.currentSequence = sequence;
  13604. this.sequenceIndex = offset;
  13605. }
  13606. stateBeforeTagName(c) {
  13607. if (c === 33) {
  13608. this.state = 22;
  13609. this.sectionStart = this.index + 1;
  13610. } else if (c === 63) {
  13611. this.state = 24;
  13612. this.sectionStart = this.index + 1;
  13613. } else if (isTagStartChar(c)) {
  13614. this.sectionStart = this.index;
  13615. if (this.mode === 0) {
  13616. this.state = 6;
  13617. } else if (this.inSFCRoot) {
  13618. this.state = 34;
  13619. } else if (!this.inXML) {
  13620. if (c === 116) {
  13621. this.state = 30;
  13622. } else {
  13623. this.state = c === 115 ? 29 : 6;
  13624. }
  13625. } else {
  13626. this.state = 6;
  13627. }
  13628. } else if (c === 47) {
  13629. this.state = 8;
  13630. } else {
  13631. this.state = 1;
  13632. this.stateText(c);
  13633. }
  13634. }
  13635. stateInTagName(c) {
  13636. if (isEndOfTagSection(c)) {
  13637. this.handleTagName(c);
  13638. }
  13639. }
  13640. stateInSFCRootTagName(c) {
  13641. if (isEndOfTagSection(c)) {
  13642. const tag = this.buffer.slice(this.sectionStart, this.index);
  13643. if (tag !== "template") {
  13644. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  13645. }
  13646. this.handleTagName(c);
  13647. }
  13648. }
  13649. handleTagName(c) {
  13650. this.cbs.onopentagname(this.sectionStart, this.index);
  13651. this.sectionStart = -1;
  13652. this.state = 11;
  13653. this.stateBeforeAttrName(c);
  13654. }
  13655. stateBeforeClosingTagName(c) {
  13656. if (isWhitespace(c)) ; else if (c === 62) {
  13657. {
  13658. this.cbs.onerr(14, this.index);
  13659. }
  13660. this.state = 1;
  13661. this.sectionStart = this.index + 1;
  13662. } else {
  13663. this.state = isTagStartChar(c) ? 9 : 27;
  13664. this.sectionStart = this.index;
  13665. }
  13666. }
  13667. stateInClosingTagName(c) {
  13668. if (c === 62 || isWhitespace(c)) {
  13669. this.cbs.onclosetag(this.sectionStart, this.index);
  13670. this.sectionStart = -1;
  13671. this.state = 10;
  13672. this.stateAfterClosingTagName(c);
  13673. }
  13674. }
  13675. stateAfterClosingTagName(c) {
  13676. if (c === 62) {
  13677. this.state = 1;
  13678. this.sectionStart = this.index + 1;
  13679. }
  13680. }
  13681. stateBeforeAttrName(c) {
  13682. if (c === 62) {
  13683. this.cbs.onopentagend(this.index);
  13684. if (this.inRCDATA) {
  13685. this.state = 32;
  13686. } else {
  13687. this.state = 1;
  13688. }
  13689. this.sectionStart = this.index + 1;
  13690. } else if (c === 47) {
  13691. this.state = 7;
  13692. if (this.peek() !== 62) {
  13693. this.cbs.onerr(22, this.index);
  13694. }
  13695. } else if (c === 60 && this.peek() === 47) {
  13696. this.cbs.onopentagend(this.index);
  13697. this.state = 5;
  13698. this.sectionStart = this.index;
  13699. } else if (!isWhitespace(c)) {
  13700. if (c === 61) {
  13701. this.cbs.onerr(
  13702. 19,
  13703. this.index
  13704. );
  13705. }
  13706. this.handleAttrStart(c);
  13707. }
  13708. }
  13709. handleAttrStart(c) {
  13710. if (c === 118 && this.peek() === 45) {
  13711. this.state = 13;
  13712. this.sectionStart = this.index;
  13713. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  13714. this.cbs.ondirname(this.index, this.index + 1);
  13715. this.state = 14;
  13716. this.sectionStart = this.index + 1;
  13717. } else {
  13718. this.state = 12;
  13719. this.sectionStart = this.index;
  13720. }
  13721. }
  13722. stateInSelfClosingTag(c) {
  13723. if (c === 62) {
  13724. this.cbs.onselfclosingtag(this.index);
  13725. this.state = 1;
  13726. this.sectionStart = this.index + 1;
  13727. this.inRCDATA = false;
  13728. } else if (!isWhitespace(c)) {
  13729. this.state = 11;
  13730. this.stateBeforeAttrName(c);
  13731. }
  13732. }
  13733. stateInAttrName(c) {
  13734. if (c === 61 || isEndOfTagSection(c)) {
  13735. this.cbs.onattribname(this.sectionStart, this.index);
  13736. this.handleAttrNameEnd(c);
  13737. } else if (c === 34 || c === 39 || c === 60) {
  13738. this.cbs.onerr(
  13739. 17,
  13740. this.index
  13741. );
  13742. }
  13743. }
  13744. stateInDirName(c) {
  13745. if (c === 61 || isEndOfTagSection(c)) {
  13746. this.cbs.ondirname(this.sectionStart, this.index);
  13747. this.handleAttrNameEnd(c);
  13748. } else if (c === 58) {
  13749. this.cbs.ondirname(this.sectionStart, this.index);
  13750. this.state = 14;
  13751. this.sectionStart = this.index + 1;
  13752. } else if (c === 46) {
  13753. this.cbs.ondirname(this.sectionStart, this.index);
  13754. this.state = 16;
  13755. this.sectionStart = this.index + 1;
  13756. }
  13757. }
  13758. stateInDirArg(c) {
  13759. if (c === 61 || isEndOfTagSection(c)) {
  13760. this.cbs.ondirarg(this.sectionStart, this.index);
  13761. this.handleAttrNameEnd(c);
  13762. } else if (c === 91) {
  13763. this.state = 15;
  13764. } else if (c === 46) {
  13765. this.cbs.ondirarg(this.sectionStart, this.index);
  13766. this.state = 16;
  13767. this.sectionStart = this.index + 1;
  13768. }
  13769. }
  13770. stateInDynamicDirArg(c) {
  13771. if (c === 93) {
  13772. this.state = 14;
  13773. } else if (c === 61 || isEndOfTagSection(c)) {
  13774. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  13775. this.handleAttrNameEnd(c);
  13776. {
  13777. this.cbs.onerr(
  13778. 27,
  13779. this.index
  13780. );
  13781. }
  13782. }
  13783. }
  13784. stateInDirModifier(c) {
  13785. if (c === 61 || isEndOfTagSection(c)) {
  13786. this.cbs.ondirmodifier(this.sectionStart, this.index);
  13787. this.handleAttrNameEnd(c);
  13788. } else if (c === 46) {
  13789. this.cbs.ondirmodifier(this.sectionStart, this.index);
  13790. this.sectionStart = this.index + 1;
  13791. }
  13792. }
  13793. handleAttrNameEnd(c) {
  13794. this.sectionStart = this.index;
  13795. this.state = 17;
  13796. this.cbs.onattribnameend(this.index);
  13797. this.stateAfterAttrName(c);
  13798. }
  13799. stateAfterAttrName(c) {
  13800. if (c === 61) {
  13801. this.state = 18;
  13802. } else if (c === 47 || c === 62) {
  13803. this.cbs.onattribend(0, this.sectionStart);
  13804. this.sectionStart = -1;
  13805. this.state = 11;
  13806. this.stateBeforeAttrName(c);
  13807. } else if (!isWhitespace(c)) {
  13808. this.cbs.onattribend(0, this.sectionStart);
  13809. this.handleAttrStart(c);
  13810. }
  13811. }
  13812. stateBeforeAttrValue(c) {
  13813. if (c === 34) {
  13814. this.state = 19;
  13815. this.sectionStart = this.index + 1;
  13816. } else if (c === 39) {
  13817. this.state = 20;
  13818. this.sectionStart = this.index + 1;
  13819. } else if (!isWhitespace(c)) {
  13820. this.sectionStart = this.index;
  13821. this.state = 21;
  13822. this.stateInAttrValueNoQuotes(c);
  13823. }
  13824. }
  13825. handleInAttrValue(c, quote) {
  13826. if (c === quote || this.fastForwardTo(quote)) {
  13827. this.cbs.onattribdata(this.sectionStart, this.index);
  13828. this.sectionStart = -1;
  13829. this.cbs.onattribend(
  13830. quote === 34 ? 3 : 2,
  13831. this.index + 1
  13832. );
  13833. this.state = 11;
  13834. }
  13835. }
  13836. stateInAttrValueDoubleQuotes(c) {
  13837. this.handleInAttrValue(c, 34);
  13838. }
  13839. stateInAttrValueSingleQuotes(c) {
  13840. this.handleInAttrValue(c, 39);
  13841. }
  13842. stateInAttrValueNoQuotes(c) {
  13843. if (isWhitespace(c) || c === 62) {
  13844. this.cbs.onattribdata(this.sectionStart, this.index);
  13845. this.sectionStart = -1;
  13846. this.cbs.onattribend(1, this.index);
  13847. this.state = 11;
  13848. this.stateBeforeAttrName(c);
  13849. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  13850. this.cbs.onerr(
  13851. 18,
  13852. this.index
  13853. );
  13854. } else ;
  13855. }
  13856. stateBeforeDeclaration(c) {
  13857. if (c === 91) {
  13858. this.state = 26;
  13859. this.sequenceIndex = 0;
  13860. } else {
  13861. this.state = c === 45 ? 25 : 23;
  13862. }
  13863. }
  13864. stateInDeclaration(c) {
  13865. if (c === 62 || this.fastForwardTo(62)) {
  13866. this.state = 1;
  13867. this.sectionStart = this.index + 1;
  13868. }
  13869. }
  13870. stateInProcessingInstruction(c) {
  13871. if (c === 62 || this.fastForwardTo(62)) {
  13872. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  13873. this.state = 1;
  13874. this.sectionStart = this.index + 1;
  13875. }
  13876. }
  13877. stateBeforeComment(c) {
  13878. if (c === 45) {
  13879. this.state = 28;
  13880. this.currentSequence = Sequences.CommentEnd;
  13881. this.sequenceIndex = 2;
  13882. this.sectionStart = this.index + 1;
  13883. } else {
  13884. this.state = 23;
  13885. }
  13886. }
  13887. stateInSpecialComment(c) {
  13888. if (c === 62 || this.fastForwardTo(62)) {
  13889. this.cbs.oncomment(this.sectionStart, this.index);
  13890. this.state = 1;
  13891. this.sectionStart = this.index + 1;
  13892. }
  13893. }
  13894. stateBeforeSpecialS(c) {
  13895. if (c === Sequences.ScriptEnd[3]) {
  13896. this.startSpecial(Sequences.ScriptEnd, 4);
  13897. } else if (c === Sequences.StyleEnd[3]) {
  13898. this.startSpecial(Sequences.StyleEnd, 4);
  13899. } else {
  13900. this.state = 6;
  13901. this.stateInTagName(c);
  13902. }
  13903. }
  13904. stateBeforeSpecialT(c) {
  13905. if (c === Sequences.TitleEnd[3]) {
  13906. this.startSpecial(Sequences.TitleEnd, 4);
  13907. } else if (c === Sequences.TextareaEnd[3]) {
  13908. this.startSpecial(Sequences.TextareaEnd, 4);
  13909. } else {
  13910. this.state = 6;
  13911. this.stateInTagName(c);
  13912. }
  13913. }
  13914. startEntity() {
  13915. }
  13916. stateInEntity() {
  13917. }
  13918. /**
  13919. * Iterates through the buffer, calling the function corresponding to the current state.
  13920. *
  13921. * States that are more likely to be hit are higher up, as a performance improvement.
  13922. */
  13923. parse(input) {
  13924. this.buffer = input;
  13925. while (this.index < this.buffer.length) {
  13926. const c = this.buffer.charCodeAt(this.index);
  13927. if (c === 10 && this.state !== 33) {
  13928. this.newlines.push(this.index);
  13929. }
  13930. switch (this.state) {
  13931. case 1: {
  13932. this.stateText(c);
  13933. break;
  13934. }
  13935. case 2: {
  13936. this.stateInterpolationOpen(c);
  13937. break;
  13938. }
  13939. case 3: {
  13940. this.stateInterpolation(c);
  13941. break;
  13942. }
  13943. case 4: {
  13944. this.stateInterpolationClose(c);
  13945. break;
  13946. }
  13947. case 31: {
  13948. this.stateSpecialStartSequence(c);
  13949. break;
  13950. }
  13951. case 32: {
  13952. this.stateInRCDATA(c);
  13953. break;
  13954. }
  13955. case 26: {
  13956. this.stateCDATASequence(c);
  13957. break;
  13958. }
  13959. case 19: {
  13960. this.stateInAttrValueDoubleQuotes(c);
  13961. break;
  13962. }
  13963. case 12: {
  13964. this.stateInAttrName(c);
  13965. break;
  13966. }
  13967. case 13: {
  13968. this.stateInDirName(c);
  13969. break;
  13970. }
  13971. case 14: {
  13972. this.stateInDirArg(c);
  13973. break;
  13974. }
  13975. case 15: {
  13976. this.stateInDynamicDirArg(c);
  13977. break;
  13978. }
  13979. case 16: {
  13980. this.stateInDirModifier(c);
  13981. break;
  13982. }
  13983. case 28: {
  13984. this.stateInCommentLike(c);
  13985. break;
  13986. }
  13987. case 27: {
  13988. this.stateInSpecialComment(c);
  13989. break;
  13990. }
  13991. case 11: {
  13992. this.stateBeforeAttrName(c);
  13993. break;
  13994. }
  13995. case 6: {
  13996. this.stateInTagName(c);
  13997. break;
  13998. }
  13999. case 34: {
  14000. this.stateInSFCRootTagName(c);
  14001. break;
  14002. }
  14003. case 9: {
  14004. this.stateInClosingTagName(c);
  14005. break;
  14006. }
  14007. case 5: {
  14008. this.stateBeforeTagName(c);
  14009. break;
  14010. }
  14011. case 17: {
  14012. this.stateAfterAttrName(c);
  14013. break;
  14014. }
  14015. case 20: {
  14016. this.stateInAttrValueSingleQuotes(c);
  14017. break;
  14018. }
  14019. case 18: {
  14020. this.stateBeforeAttrValue(c);
  14021. break;
  14022. }
  14023. case 8: {
  14024. this.stateBeforeClosingTagName(c);
  14025. break;
  14026. }
  14027. case 10: {
  14028. this.stateAfterClosingTagName(c);
  14029. break;
  14030. }
  14031. case 29: {
  14032. this.stateBeforeSpecialS(c);
  14033. break;
  14034. }
  14035. case 30: {
  14036. this.stateBeforeSpecialT(c);
  14037. break;
  14038. }
  14039. case 21: {
  14040. this.stateInAttrValueNoQuotes(c);
  14041. break;
  14042. }
  14043. case 7: {
  14044. this.stateInSelfClosingTag(c);
  14045. break;
  14046. }
  14047. case 23: {
  14048. this.stateInDeclaration(c);
  14049. break;
  14050. }
  14051. case 22: {
  14052. this.stateBeforeDeclaration(c);
  14053. break;
  14054. }
  14055. case 25: {
  14056. this.stateBeforeComment(c);
  14057. break;
  14058. }
  14059. case 24: {
  14060. this.stateInProcessingInstruction(c);
  14061. break;
  14062. }
  14063. case 33: {
  14064. this.stateInEntity();
  14065. break;
  14066. }
  14067. }
  14068. this.index++;
  14069. }
  14070. this.cleanup();
  14071. this.finish();
  14072. }
  14073. /**
  14074. * Remove data that has already been consumed from the buffer.
  14075. */
  14076. cleanup() {
  14077. if (this.sectionStart !== this.index) {
  14078. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  14079. this.cbs.ontext(this.sectionStart, this.index);
  14080. this.sectionStart = this.index;
  14081. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  14082. this.cbs.onattribdata(this.sectionStart, this.index);
  14083. this.sectionStart = this.index;
  14084. }
  14085. }
  14086. }
  14087. finish() {
  14088. this.handleTrailingData();
  14089. this.cbs.onend();
  14090. }
  14091. /** Handle any trailing data. */
  14092. handleTrailingData() {
  14093. const endIndex = this.buffer.length;
  14094. if (this.sectionStart >= endIndex) {
  14095. return;
  14096. }
  14097. if (this.state === 28) {
  14098. if (this.currentSequence === Sequences.CdataEnd) {
  14099. this.cbs.oncdata(this.sectionStart, endIndex);
  14100. } else {
  14101. this.cbs.oncomment(this.sectionStart, endIndex);
  14102. }
  14103. } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
  14104. this.cbs.ontext(this.sectionStart, endIndex);
  14105. }
  14106. }
  14107. emitCodePoint(cp, consumed) {
  14108. }
  14109. }
  14110. function defaultOnError(error) {
  14111. throw error;
  14112. }
  14113. function defaultOnWarn(msg) {
  14114. console.warn(`[Vue warn] ${msg.message}`);
  14115. }
  14116. function createCompilerError(code, loc, messages, additionalMessage) {
  14117. const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
  14118. const error = new SyntaxError(String(msg));
  14119. error.code = code;
  14120. error.loc = loc;
  14121. return error;
  14122. }
  14123. const errorMessages = {
  14124. // parse errors
  14125. [0]: "Illegal comment.",
  14126. [1]: "CDATA section is allowed only in XML context.",
  14127. [2]: "Duplicate attribute.",
  14128. [3]: "End tag cannot have attributes.",
  14129. [4]: "Illegal '/' in tags.",
  14130. [5]: "Unexpected EOF in tag.",
  14131. [6]: "Unexpected EOF in CDATA section.",
  14132. [7]: "Unexpected EOF in comment.",
  14133. [8]: "Unexpected EOF in script.",
  14134. [9]: "Unexpected EOF in tag.",
  14135. [10]: "Incorrectly closed comment.",
  14136. [11]: "Incorrectly opened comment.",
  14137. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  14138. [13]: "Attribute value was expected.",
  14139. [14]: "End tag name was expected.",
  14140. [15]: "Whitespace was expected.",
  14141. [16]: "Unexpected '<!--' in comment.",
  14142. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  14143. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  14144. [19]: "Attribute name cannot start with '='.",
  14145. [21]: "'<?' is allowed only in XML context.",
  14146. [20]: `Unexpected null character.`,
  14147. [22]: "Illegal '/' in tags.",
  14148. // Vue-specific parse errors
  14149. [23]: "Invalid end tag.",
  14150. [24]: "Element is missing end tag.",
  14151. [25]: "Interpolation end sign was not found.",
  14152. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  14153. [26]: "Legal directive name was expected.",
  14154. // transform errors
  14155. [28]: `v-if/v-else-if is missing expression.`,
  14156. [29]: `v-if/else branches must use unique keys.`,
  14157. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  14158. [31]: `v-for is missing expression.`,
  14159. [32]: `v-for has invalid expression.`,
  14160. [33]: `<template v-for> key should be placed on the <template> tag.`,
  14161. [34]: `v-bind is missing expression.`,
  14162. [53]: `v-bind with same-name shorthand only allows static argument.`,
  14163. [35]: `v-on is missing expression.`,
  14164. [36]: `Unexpected custom directive on <slot> outlet.`,
  14165. [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.`,
  14166. [38]: `Duplicate slot names found. `,
  14167. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  14168. [40]: `v-slot can only be used on components or <template> tags.`,
  14169. [41]: `v-model is missing expression.`,
  14170. [42]: `v-model value must be a valid JavaScript member expression.`,
  14171. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  14172. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  14173. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  14174. [45]: `v-model cannot be used on a const binding because it is not writable.`,
  14175. [46]: `Error parsing JavaScript expression: `,
  14176. [47]: `<KeepAlive> expects exactly one child component.`,
  14177. [52]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
  14178. // generic errors
  14179. [48]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  14180. [49]: `ES module mode is not supported in this build of compiler.`,
  14181. [50]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  14182. [51]: `"scopeId" option is only supported in module mode.`,
  14183. // just to fulfill types
  14184. [54]: ``
  14185. };
  14186. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  14187. function isCoreComponent(tag) {
  14188. switch (tag) {
  14189. case "Teleport":
  14190. case "teleport":
  14191. return TELEPORT;
  14192. case "Suspense":
  14193. case "suspense":
  14194. return SUSPENSE;
  14195. case "KeepAlive":
  14196. case "keep-alive":
  14197. return KEEP_ALIVE;
  14198. case "BaseTransition":
  14199. case "base-transition":
  14200. return BASE_TRANSITION;
  14201. }
  14202. }
  14203. const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
  14204. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  14205. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  14206. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  14207. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  14208. const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
  14209. const isMemberExpressionBrowser = (exp) => {
  14210. const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
  14211. let state = 0 /* inMemberExp */;
  14212. let stateStack = [];
  14213. let currentOpenBracketCount = 0;
  14214. let currentOpenParensCount = 0;
  14215. let currentStringType = null;
  14216. for (let i = 0; i < path.length; i++) {
  14217. const char = path.charAt(i);
  14218. switch (state) {
  14219. case 0 /* inMemberExp */:
  14220. if (char === "[") {
  14221. stateStack.push(state);
  14222. state = 1 /* inBrackets */;
  14223. currentOpenBracketCount++;
  14224. } else if (char === "(") {
  14225. stateStack.push(state);
  14226. state = 2 /* inParens */;
  14227. currentOpenParensCount++;
  14228. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  14229. return false;
  14230. }
  14231. break;
  14232. case 1 /* inBrackets */:
  14233. if (char === `'` || char === `"` || char === "`") {
  14234. stateStack.push(state);
  14235. state = 3 /* inString */;
  14236. currentStringType = char;
  14237. } else if (char === `[`) {
  14238. currentOpenBracketCount++;
  14239. } else if (char === `]`) {
  14240. if (!--currentOpenBracketCount) {
  14241. state = stateStack.pop();
  14242. }
  14243. }
  14244. break;
  14245. case 2 /* inParens */:
  14246. if (char === `'` || char === `"` || char === "`") {
  14247. stateStack.push(state);
  14248. state = 3 /* inString */;
  14249. currentStringType = char;
  14250. } else if (char === `(`) {
  14251. currentOpenParensCount++;
  14252. } else if (char === `)`) {
  14253. if (i === path.length - 1) {
  14254. return false;
  14255. }
  14256. if (!--currentOpenParensCount) {
  14257. state = stateStack.pop();
  14258. }
  14259. }
  14260. break;
  14261. case 3 /* inString */:
  14262. if (char === currentStringType) {
  14263. state = stateStack.pop();
  14264. currentStringType = null;
  14265. }
  14266. break;
  14267. }
  14268. }
  14269. return !currentOpenBracketCount && !currentOpenParensCount;
  14270. };
  14271. const isMemberExpression = isMemberExpressionBrowser ;
  14272. const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  14273. const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
  14274. const isFnExpression = isFnExpressionBrowser ;
  14275. function assert(condition, msg) {
  14276. if (!condition) {
  14277. throw new Error(msg || `unexpected compiler condition`);
  14278. }
  14279. }
  14280. function findDir(node, name, allowEmpty = false) {
  14281. for (let i = 0; i < node.props.length; i++) {
  14282. const p = node.props[i];
  14283. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  14284. return p;
  14285. }
  14286. }
  14287. }
  14288. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  14289. for (let i = 0; i < node.props.length; i++) {
  14290. const p = node.props[i];
  14291. if (p.type === 6) {
  14292. if (dynamicOnly) continue;
  14293. if (p.name === name && (p.value || allowEmpty)) {
  14294. return p;
  14295. }
  14296. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  14297. return p;
  14298. }
  14299. }
  14300. }
  14301. function isStaticArgOf(arg, name) {
  14302. return !!(arg && isStaticExp(arg) && arg.content === name);
  14303. }
  14304. function hasDynamicKeyVBind(node) {
  14305. return node.props.some(
  14306. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  14307. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  14308. !p.arg.isStatic)
  14309. // v-bind:[foo]
  14310. );
  14311. }
  14312. function isText$1(node) {
  14313. return node.type === 5 || node.type === 2;
  14314. }
  14315. function isVPre(p) {
  14316. return p.type === 7 && p.name === "pre";
  14317. }
  14318. function isVSlot(p) {
  14319. return p.type === 7 && p.name === "slot";
  14320. }
  14321. function isTemplateNode(node) {
  14322. return node.type === 1 && node.tagType === 3;
  14323. }
  14324. function isSlotOutlet(node) {
  14325. return node.type === 1 && node.tagType === 2;
  14326. }
  14327. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  14328. function getUnnormalizedProps(props, callPath = []) {
  14329. if (props && !isString(props) && props.type === 14) {
  14330. const callee = props.callee;
  14331. if (!isString(callee) && propsHelperSet.has(callee)) {
  14332. return getUnnormalizedProps(
  14333. props.arguments[0],
  14334. callPath.concat(props)
  14335. );
  14336. }
  14337. }
  14338. return [props, callPath];
  14339. }
  14340. function injectProp(node, prop, context) {
  14341. let propsWithInjection;
  14342. let props = node.type === 13 ? node.props : node.arguments[2];
  14343. let callPath = [];
  14344. let parentCall;
  14345. if (props && !isString(props) && props.type === 14) {
  14346. const ret = getUnnormalizedProps(props);
  14347. props = ret[0];
  14348. callPath = ret[1];
  14349. parentCall = callPath[callPath.length - 1];
  14350. }
  14351. if (props == null || isString(props)) {
  14352. propsWithInjection = createObjectExpression([prop]);
  14353. } else if (props.type === 14) {
  14354. const first = props.arguments[0];
  14355. if (!isString(first) && first.type === 15) {
  14356. if (!hasProp(prop, first)) {
  14357. first.properties.unshift(prop);
  14358. }
  14359. } else {
  14360. if (props.callee === TO_HANDLERS) {
  14361. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  14362. createObjectExpression([prop]),
  14363. props
  14364. ]);
  14365. } else {
  14366. props.arguments.unshift(createObjectExpression([prop]));
  14367. }
  14368. }
  14369. !propsWithInjection && (propsWithInjection = props);
  14370. } else if (props.type === 15) {
  14371. if (!hasProp(prop, props)) {
  14372. props.properties.unshift(prop);
  14373. }
  14374. propsWithInjection = props;
  14375. } else {
  14376. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  14377. createObjectExpression([prop]),
  14378. props
  14379. ]);
  14380. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  14381. parentCall = callPath[callPath.length - 2];
  14382. }
  14383. }
  14384. if (node.type === 13) {
  14385. if (parentCall) {
  14386. parentCall.arguments[0] = propsWithInjection;
  14387. } else {
  14388. node.props = propsWithInjection;
  14389. }
  14390. } else {
  14391. if (parentCall) {
  14392. parentCall.arguments[0] = propsWithInjection;
  14393. } else {
  14394. node.arguments[2] = propsWithInjection;
  14395. }
  14396. }
  14397. }
  14398. function hasProp(prop, props) {
  14399. let result = false;
  14400. if (prop.key.type === 4) {
  14401. const propKeyName = prop.key.content;
  14402. result = props.properties.some(
  14403. (p) => p.key.type === 4 && p.key.content === propKeyName
  14404. );
  14405. }
  14406. return result;
  14407. }
  14408. function toValidAssetId(name, type) {
  14409. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  14410. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  14411. })}`;
  14412. }
  14413. function getMemoedVNodeCall(node) {
  14414. if (node.type === 14 && node.callee === WITH_MEMO) {
  14415. return node.arguments[1].returns;
  14416. } else {
  14417. return node;
  14418. }
  14419. }
  14420. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
  14421. function isAllWhitespace(str) {
  14422. for (let i = 0; i < str.length; i++) {
  14423. if (!isWhitespace(str.charCodeAt(i))) {
  14424. return false;
  14425. }
  14426. }
  14427. return true;
  14428. }
  14429. function isWhitespaceText(node) {
  14430. return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
  14431. }
  14432. function isCommentOrWhitespace(node) {
  14433. return node.type === 3 || isWhitespaceText(node);
  14434. }
  14435. const defaultParserOptions = {
  14436. parseMode: "base",
  14437. ns: 0,
  14438. delimiters: [`{{`, `}}`],
  14439. getNamespace: () => 0,
  14440. isVoidTag: NO,
  14441. isPreTag: NO,
  14442. isIgnoreNewlineTag: NO,
  14443. isCustomElement: NO,
  14444. onError: defaultOnError,
  14445. onWarn: defaultOnWarn,
  14446. comments: true,
  14447. prefixIdentifiers: false
  14448. };
  14449. let currentOptions = defaultParserOptions;
  14450. let currentRoot = null;
  14451. let currentInput = "";
  14452. let currentOpenTag = null;
  14453. let currentProp = null;
  14454. let currentAttrValue = "";
  14455. let currentAttrStartIndex = -1;
  14456. let currentAttrEndIndex = -1;
  14457. let inPre = 0;
  14458. let inVPre = false;
  14459. let currentVPreBoundary = null;
  14460. const stack = [];
  14461. const tokenizer = new Tokenizer(stack, {
  14462. onerr: emitError,
  14463. ontext(start, end) {
  14464. onText(getSlice(start, end), start, end);
  14465. },
  14466. ontextentity(char, start, end) {
  14467. onText(char, start, end);
  14468. },
  14469. oninterpolation(start, end) {
  14470. if (inVPre) {
  14471. return onText(getSlice(start, end), start, end);
  14472. }
  14473. let innerStart = start + tokenizer.delimiterOpen.length;
  14474. let innerEnd = end - tokenizer.delimiterClose.length;
  14475. while (isWhitespace(currentInput.charCodeAt(innerStart))) {
  14476. innerStart++;
  14477. }
  14478. while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
  14479. innerEnd--;
  14480. }
  14481. let exp = getSlice(innerStart, innerEnd);
  14482. if (exp.includes("&")) {
  14483. {
  14484. exp = currentOptions.decodeEntities(exp, false);
  14485. }
  14486. }
  14487. addNode({
  14488. type: 5,
  14489. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  14490. loc: getLoc(start, end)
  14491. });
  14492. },
  14493. onopentagname(start, end) {
  14494. const name = getSlice(start, end);
  14495. currentOpenTag = {
  14496. type: 1,
  14497. tag: name,
  14498. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  14499. tagType: 0,
  14500. // will be refined on tag close
  14501. props: [],
  14502. children: [],
  14503. loc: getLoc(start - 1, end),
  14504. codegenNode: void 0
  14505. };
  14506. },
  14507. onopentagend(end) {
  14508. endOpenTag(end);
  14509. },
  14510. onclosetag(start, end) {
  14511. const name = getSlice(start, end);
  14512. if (!currentOptions.isVoidTag(name)) {
  14513. let found = false;
  14514. for (let i = 0; i < stack.length; i++) {
  14515. const e = stack[i];
  14516. if (e.tag.toLowerCase() === name.toLowerCase()) {
  14517. found = true;
  14518. if (i > 0) {
  14519. emitError(24, stack[0].loc.start.offset);
  14520. }
  14521. for (let j = 0; j <= i; j++) {
  14522. const el = stack.shift();
  14523. onCloseTag(el, end, j < i);
  14524. }
  14525. break;
  14526. }
  14527. }
  14528. if (!found) {
  14529. emitError(23, backTrack(start, 60));
  14530. }
  14531. }
  14532. },
  14533. onselfclosingtag(end) {
  14534. const name = currentOpenTag.tag;
  14535. currentOpenTag.isSelfClosing = true;
  14536. endOpenTag(end);
  14537. if (stack[0] && stack[0].tag === name) {
  14538. onCloseTag(stack.shift(), end);
  14539. }
  14540. },
  14541. onattribname(start, end) {
  14542. currentProp = {
  14543. type: 6,
  14544. name: getSlice(start, end),
  14545. nameLoc: getLoc(start, end),
  14546. value: void 0,
  14547. loc: getLoc(start)
  14548. };
  14549. },
  14550. ondirname(start, end) {
  14551. const raw = getSlice(start, end);
  14552. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  14553. if (!inVPre && name === "") {
  14554. emitError(26, start);
  14555. }
  14556. if (inVPre || name === "") {
  14557. currentProp = {
  14558. type: 6,
  14559. name: raw,
  14560. nameLoc: getLoc(start, end),
  14561. value: void 0,
  14562. loc: getLoc(start)
  14563. };
  14564. } else {
  14565. currentProp = {
  14566. type: 7,
  14567. name,
  14568. rawName: raw,
  14569. exp: void 0,
  14570. arg: void 0,
  14571. modifiers: raw === "." ? [createSimpleExpression("prop")] : [],
  14572. loc: getLoc(start)
  14573. };
  14574. if (name === "pre") {
  14575. inVPre = tokenizer.inVPre = true;
  14576. currentVPreBoundary = currentOpenTag;
  14577. const props = currentOpenTag.props;
  14578. for (let i = 0; i < props.length; i++) {
  14579. if (props[i].type === 7) {
  14580. props[i] = dirToAttr(props[i]);
  14581. }
  14582. }
  14583. }
  14584. }
  14585. },
  14586. ondirarg(start, end) {
  14587. if (start === end) return;
  14588. const arg = getSlice(start, end);
  14589. if (inVPre && !isVPre(currentProp)) {
  14590. currentProp.name += arg;
  14591. setLocEnd(currentProp.nameLoc, end);
  14592. } else {
  14593. const isStatic = arg[0] !== `[`;
  14594. currentProp.arg = createExp(
  14595. isStatic ? arg : arg.slice(1, -1),
  14596. isStatic,
  14597. getLoc(start, end),
  14598. isStatic ? 3 : 0
  14599. );
  14600. }
  14601. },
  14602. ondirmodifier(start, end) {
  14603. const mod = getSlice(start, end);
  14604. if (inVPre && !isVPre(currentProp)) {
  14605. currentProp.name += "." + mod;
  14606. setLocEnd(currentProp.nameLoc, end);
  14607. } else if (currentProp.name === "slot") {
  14608. const arg = currentProp.arg;
  14609. if (arg) {
  14610. arg.content += "." + mod;
  14611. setLocEnd(arg.loc, end);
  14612. }
  14613. } else {
  14614. const exp = createSimpleExpression(mod, true, getLoc(start, end));
  14615. currentProp.modifiers.push(exp);
  14616. }
  14617. },
  14618. onattribdata(start, end) {
  14619. currentAttrValue += getSlice(start, end);
  14620. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  14621. currentAttrEndIndex = end;
  14622. },
  14623. onattribentity(char, start, end) {
  14624. currentAttrValue += char;
  14625. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  14626. currentAttrEndIndex = end;
  14627. },
  14628. onattribnameend(end) {
  14629. const start = currentProp.loc.start.offset;
  14630. const name = getSlice(start, end);
  14631. if (currentProp.type === 7) {
  14632. currentProp.rawName = name;
  14633. }
  14634. if (currentOpenTag.props.some(
  14635. (p) => (p.type === 7 ? p.rawName : p.name) === name
  14636. )) {
  14637. emitError(2, start);
  14638. }
  14639. },
  14640. onattribend(quote, end) {
  14641. if (currentOpenTag && currentProp) {
  14642. setLocEnd(currentProp.loc, end);
  14643. if (quote !== 0) {
  14644. if (currentAttrValue.includes("&")) {
  14645. currentAttrValue = currentOptions.decodeEntities(
  14646. currentAttrValue,
  14647. true
  14648. );
  14649. }
  14650. if (currentProp.type === 6) {
  14651. if (currentProp.name === "class") {
  14652. currentAttrValue = condense(currentAttrValue).trim();
  14653. }
  14654. if (quote === 1 && !currentAttrValue) {
  14655. emitError(13, end);
  14656. }
  14657. currentProp.value = {
  14658. type: 2,
  14659. content: currentAttrValue,
  14660. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  14661. };
  14662. if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  14663. tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
  14664. }
  14665. } else {
  14666. let expParseMode = 0 /* Normal */;
  14667. currentProp.exp = createExp(
  14668. currentAttrValue,
  14669. false,
  14670. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  14671. 0,
  14672. expParseMode
  14673. );
  14674. if (currentProp.name === "for") {
  14675. currentProp.forParseResult = parseForExpression(currentProp.exp);
  14676. }
  14677. }
  14678. }
  14679. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  14680. currentOpenTag.props.push(currentProp);
  14681. }
  14682. }
  14683. currentAttrValue = "";
  14684. currentAttrStartIndex = currentAttrEndIndex = -1;
  14685. },
  14686. oncomment(start, end) {
  14687. if (currentOptions.comments) {
  14688. addNode({
  14689. type: 3,
  14690. content: getSlice(start, end),
  14691. loc: getLoc(start - 4, end + 3)
  14692. });
  14693. }
  14694. },
  14695. onend() {
  14696. const end = currentInput.length;
  14697. if (tokenizer.state !== 1) {
  14698. switch (tokenizer.state) {
  14699. case 5:
  14700. case 8:
  14701. emitError(5, end);
  14702. break;
  14703. case 3:
  14704. case 4:
  14705. emitError(
  14706. 25,
  14707. tokenizer.sectionStart
  14708. );
  14709. break;
  14710. case 28:
  14711. if (tokenizer.currentSequence === Sequences.CdataEnd) {
  14712. emitError(6, end);
  14713. } else {
  14714. emitError(7, end);
  14715. }
  14716. break;
  14717. case 6:
  14718. case 7:
  14719. case 9:
  14720. case 11:
  14721. case 12:
  14722. case 13:
  14723. case 14:
  14724. case 15:
  14725. case 16:
  14726. case 17:
  14727. case 18:
  14728. case 19:
  14729. // "
  14730. case 20:
  14731. // '
  14732. case 21:
  14733. emitError(9, end);
  14734. break;
  14735. }
  14736. }
  14737. for (let index = 0; index < stack.length; index++) {
  14738. onCloseTag(stack[index], end - 1);
  14739. emitError(24, stack[index].loc.start.offset);
  14740. }
  14741. },
  14742. oncdata(start, end) {
  14743. if (stack[0].ns !== 0) {
  14744. onText(getSlice(start, end), start, end);
  14745. } else {
  14746. emitError(1, start - 9);
  14747. }
  14748. },
  14749. onprocessinginstruction(start) {
  14750. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  14751. emitError(
  14752. 21,
  14753. start - 1
  14754. );
  14755. }
  14756. }
  14757. });
  14758. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  14759. const stripParensRE = /^\(|\)$/g;
  14760. function parseForExpression(input) {
  14761. const loc = input.loc;
  14762. const exp = input.content;
  14763. const inMatch = exp.match(forAliasRE);
  14764. if (!inMatch) return;
  14765. const [, LHS, RHS] = inMatch;
  14766. const createAliasExpression = (content, offset, asParam = false) => {
  14767. const start = loc.start.offset + offset;
  14768. const end = start + content.length;
  14769. return createExp(
  14770. content,
  14771. false,
  14772. getLoc(start, end),
  14773. 0,
  14774. asParam ? 1 /* Params */ : 0 /* Normal */
  14775. );
  14776. };
  14777. const result = {
  14778. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  14779. value: void 0,
  14780. key: void 0,
  14781. index: void 0,
  14782. finalized: false
  14783. };
  14784. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  14785. const trimmedOffset = LHS.indexOf(valueContent);
  14786. const iteratorMatch = valueContent.match(forIteratorRE);
  14787. if (iteratorMatch) {
  14788. valueContent = valueContent.replace(forIteratorRE, "").trim();
  14789. const keyContent = iteratorMatch[1].trim();
  14790. let keyOffset;
  14791. if (keyContent) {
  14792. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  14793. result.key = createAliasExpression(keyContent, keyOffset, true);
  14794. }
  14795. if (iteratorMatch[2]) {
  14796. const indexContent = iteratorMatch[2].trim();
  14797. if (indexContent) {
  14798. result.index = createAliasExpression(
  14799. indexContent,
  14800. exp.indexOf(
  14801. indexContent,
  14802. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  14803. ),
  14804. true
  14805. );
  14806. }
  14807. }
  14808. }
  14809. if (valueContent) {
  14810. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  14811. }
  14812. return result;
  14813. }
  14814. function getSlice(start, end) {
  14815. return currentInput.slice(start, end);
  14816. }
  14817. function endOpenTag(end) {
  14818. if (tokenizer.inSFCRoot) {
  14819. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  14820. }
  14821. addNode(currentOpenTag);
  14822. const { tag, ns } = currentOpenTag;
  14823. if (ns === 0 && currentOptions.isPreTag(tag)) {
  14824. inPre++;
  14825. }
  14826. if (currentOptions.isVoidTag(tag)) {
  14827. onCloseTag(currentOpenTag, end);
  14828. } else {
  14829. stack.unshift(currentOpenTag);
  14830. if (ns === 1 || ns === 2) {
  14831. tokenizer.inXML = true;
  14832. }
  14833. }
  14834. currentOpenTag = null;
  14835. }
  14836. function onText(content, start, end) {
  14837. {
  14838. const tag = stack[0] && stack[0].tag;
  14839. if (tag !== "script" && tag !== "style" && content.includes("&")) {
  14840. content = currentOptions.decodeEntities(content, false);
  14841. }
  14842. }
  14843. const parent = stack[0] || currentRoot;
  14844. const lastNode = parent.children[parent.children.length - 1];
  14845. if (lastNode && lastNode.type === 2) {
  14846. lastNode.content += content;
  14847. setLocEnd(lastNode.loc, end);
  14848. } else {
  14849. parent.children.push({
  14850. type: 2,
  14851. content,
  14852. loc: getLoc(start, end)
  14853. });
  14854. }
  14855. }
  14856. function onCloseTag(el, end, isImplied = false) {
  14857. if (isImplied) {
  14858. setLocEnd(el.loc, backTrack(end, 60));
  14859. } else {
  14860. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  14861. }
  14862. if (tokenizer.inSFCRoot) {
  14863. if (el.children.length) {
  14864. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  14865. } else {
  14866. el.innerLoc.end = extend({}, el.innerLoc.start);
  14867. }
  14868. el.innerLoc.source = getSlice(
  14869. el.innerLoc.start.offset,
  14870. el.innerLoc.end.offset
  14871. );
  14872. }
  14873. const { tag, ns, children } = el;
  14874. if (!inVPre) {
  14875. if (tag === "slot") {
  14876. el.tagType = 2;
  14877. } else if (isFragmentTemplate(el)) {
  14878. el.tagType = 3;
  14879. } else if (isComponent(el)) {
  14880. el.tagType = 1;
  14881. }
  14882. }
  14883. if (!tokenizer.inRCDATA) {
  14884. el.children = condenseWhitespace(children);
  14885. }
  14886. if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
  14887. const first = children[0];
  14888. if (first && first.type === 2) {
  14889. first.content = first.content.replace(/^\r?\n/, "");
  14890. }
  14891. }
  14892. if (ns === 0 && currentOptions.isPreTag(tag)) {
  14893. inPre--;
  14894. }
  14895. if (currentVPreBoundary === el) {
  14896. inVPre = tokenizer.inVPre = false;
  14897. currentVPreBoundary = null;
  14898. }
  14899. if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  14900. tokenizer.inXML = false;
  14901. }
  14902. }
  14903. function lookAhead(index, c) {
  14904. let i = index;
  14905. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
  14906. return i;
  14907. }
  14908. function backTrack(index, c) {
  14909. let i = index;
  14910. while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
  14911. return i;
  14912. }
  14913. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  14914. function isFragmentTemplate({ tag, props }) {
  14915. if (tag === "template") {
  14916. for (let i = 0; i < props.length; i++) {
  14917. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  14918. return true;
  14919. }
  14920. }
  14921. }
  14922. return false;
  14923. }
  14924. function isComponent({ tag, props }) {
  14925. if (currentOptions.isCustomElement(tag)) {
  14926. return false;
  14927. }
  14928. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  14929. return true;
  14930. }
  14931. for (let i = 0; i < props.length; i++) {
  14932. const p = props[i];
  14933. if (p.type === 6) {
  14934. if (p.name === "is" && p.value) {
  14935. if (p.value.content.startsWith("vue:")) {
  14936. return true;
  14937. }
  14938. }
  14939. }
  14940. }
  14941. return false;
  14942. }
  14943. function isUpperCase(c) {
  14944. return c > 64 && c < 91;
  14945. }
  14946. const windowsNewlineRE = /\r\n/g;
  14947. function condenseWhitespace(nodes) {
  14948. const shouldCondense = currentOptions.whitespace !== "preserve";
  14949. let removedWhitespace = false;
  14950. for (let i = 0; i < nodes.length; i++) {
  14951. const node = nodes[i];
  14952. if (node.type === 2) {
  14953. if (!inPre) {
  14954. if (isAllWhitespace(node.content)) {
  14955. const prev = nodes[i - 1] && nodes[i - 1].type;
  14956. const next = nodes[i + 1] && nodes[i + 1].type;
  14957. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  14958. removedWhitespace = true;
  14959. nodes[i] = null;
  14960. } else {
  14961. node.content = " ";
  14962. }
  14963. } else if (shouldCondense) {
  14964. node.content = condense(node.content);
  14965. }
  14966. } else {
  14967. node.content = node.content.replace(windowsNewlineRE, "\n");
  14968. }
  14969. }
  14970. }
  14971. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  14972. }
  14973. function hasNewlineChar(str) {
  14974. for (let i = 0; i < str.length; i++) {
  14975. const c = str.charCodeAt(i);
  14976. if (c === 10 || c === 13) {
  14977. return true;
  14978. }
  14979. }
  14980. return false;
  14981. }
  14982. function condense(str) {
  14983. let ret = "";
  14984. let prevCharIsWhitespace = false;
  14985. for (let i = 0; i < str.length; i++) {
  14986. if (isWhitespace(str.charCodeAt(i))) {
  14987. if (!prevCharIsWhitespace) {
  14988. ret += " ";
  14989. prevCharIsWhitespace = true;
  14990. }
  14991. } else {
  14992. ret += str[i];
  14993. prevCharIsWhitespace = false;
  14994. }
  14995. }
  14996. return ret;
  14997. }
  14998. function addNode(node) {
  14999. (stack[0] || currentRoot).children.push(node);
  15000. }
  15001. function getLoc(start, end) {
  15002. return {
  15003. start: tokenizer.getPos(start),
  15004. // @ts-expect-error allow late attachment
  15005. end: end == null ? end : tokenizer.getPos(end),
  15006. // @ts-expect-error allow late attachment
  15007. source: end == null ? end : getSlice(start, end)
  15008. };
  15009. }
  15010. function cloneLoc(loc) {
  15011. return getLoc(loc.start.offset, loc.end.offset);
  15012. }
  15013. function setLocEnd(loc, end) {
  15014. loc.end = tokenizer.getPos(end);
  15015. loc.source = getSlice(loc.start.offset, end);
  15016. }
  15017. function dirToAttr(dir) {
  15018. const attr = {
  15019. type: 6,
  15020. name: dir.rawName,
  15021. nameLoc: getLoc(
  15022. dir.loc.start.offset,
  15023. dir.loc.start.offset + dir.rawName.length
  15024. ),
  15025. value: void 0,
  15026. loc: dir.loc
  15027. };
  15028. if (dir.exp) {
  15029. const loc = dir.exp.loc;
  15030. if (loc.end.offset < dir.loc.end.offset) {
  15031. loc.start.offset--;
  15032. loc.start.column--;
  15033. loc.end.offset++;
  15034. loc.end.column++;
  15035. }
  15036. attr.value = {
  15037. type: 2,
  15038. content: dir.exp.content,
  15039. loc
  15040. };
  15041. }
  15042. return attr;
  15043. }
  15044. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  15045. const exp = createSimpleExpression(content, isStatic, loc, constType);
  15046. return exp;
  15047. }
  15048. function emitError(code, index, message) {
  15049. currentOptions.onError(
  15050. createCompilerError(code, getLoc(index, index), void 0, message)
  15051. );
  15052. }
  15053. function reset() {
  15054. tokenizer.reset();
  15055. currentOpenTag = null;
  15056. currentProp = null;
  15057. currentAttrValue = "";
  15058. currentAttrStartIndex = -1;
  15059. currentAttrEndIndex = -1;
  15060. stack.length = 0;
  15061. }
  15062. function baseParse(input, options) {
  15063. reset();
  15064. currentInput = input;
  15065. currentOptions = extend({}, defaultParserOptions);
  15066. if (options) {
  15067. let key;
  15068. for (key in options) {
  15069. if (options[key] != null) {
  15070. currentOptions[key] = options[key];
  15071. }
  15072. }
  15073. }
  15074. {
  15075. if (!currentOptions.decodeEntities) {
  15076. throw new Error(
  15077. `[@vue/compiler-core] decodeEntities option is required in browser builds.`
  15078. );
  15079. }
  15080. }
  15081. tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  15082. tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  15083. const delimiters = options && options.delimiters;
  15084. if (delimiters) {
  15085. tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
  15086. tokenizer.delimiterClose = toCharCodes(delimiters[1]);
  15087. }
  15088. const root = currentRoot = createRoot([], input);
  15089. tokenizer.parse(currentInput);
  15090. root.loc = getLoc(0, input.length);
  15091. root.children = condenseWhitespace(root.children);
  15092. currentRoot = null;
  15093. return root;
  15094. }
  15095. function cacheStatic(root, context) {
  15096. walk(
  15097. root,
  15098. void 0,
  15099. context,
  15100. // Root node is unfortunately non-hoistable due to potential parent
  15101. // fallthrough attributes.
  15102. !!getSingleElementRoot(root)
  15103. );
  15104. }
  15105. function getSingleElementRoot(root) {
  15106. const children = root.children.filter((x) => x.type !== 3);
  15107. return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
  15108. }
  15109. function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
  15110. const { children } = node;
  15111. const toCache = [];
  15112. for (let i = 0; i < children.length; i++) {
  15113. const child = children[i];
  15114. if (child.type === 1 && child.tagType === 0) {
  15115. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  15116. if (constantType > 0) {
  15117. if (constantType >= 2) {
  15118. child.codegenNode.patchFlag = -1;
  15119. toCache.push(child);
  15120. continue;
  15121. }
  15122. } else {
  15123. const codegenNode = child.codegenNode;
  15124. if (codegenNode.type === 13) {
  15125. const flag = codegenNode.patchFlag;
  15126. if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  15127. const props = getNodeProps(child);
  15128. if (props) {
  15129. codegenNode.props = context.hoist(props);
  15130. }
  15131. }
  15132. if (codegenNode.dynamicProps) {
  15133. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  15134. }
  15135. }
  15136. }
  15137. } else if (child.type === 12) {
  15138. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  15139. if (constantType >= 2) {
  15140. if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
  15141. child.codegenNode.arguments.push(
  15142. -1 + (` /* ${PatchFlagNames[-1]} */` )
  15143. );
  15144. }
  15145. toCache.push(child);
  15146. continue;
  15147. }
  15148. }
  15149. if (child.type === 1) {
  15150. const isComponent = child.tagType === 1;
  15151. if (isComponent) {
  15152. context.scopes.vSlot++;
  15153. }
  15154. walk(child, node, context, false, inFor);
  15155. if (isComponent) {
  15156. context.scopes.vSlot--;
  15157. }
  15158. } else if (child.type === 11) {
  15159. walk(child, node, context, child.children.length === 1, true);
  15160. } else if (child.type === 9) {
  15161. for (let i2 = 0; i2 < child.branches.length; i2++) {
  15162. walk(
  15163. child.branches[i2],
  15164. node,
  15165. context,
  15166. child.branches[i2].children.length === 1,
  15167. inFor
  15168. );
  15169. }
  15170. }
  15171. }
  15172. let cachedAsArray = false;
  15173. if (toCache.length === children.length && node.type === 1) {
  15174. if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  15175. node.codegenNode.children = getCacheExpression(
  15176. createArrayExpression(node.codegenNode.children)
  15177. );
  15178. cachedAsArray = true;
  15179. } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
  15180. const slot = getSlotNode(node.codegenNode, "default");
  15181. if (slot) {
  15182. slot.returns = getCacheExpression(
  15183. createArrayExpression(slot.returns)
  15184. );
  15185. cachedAsArray = true;
  15186. }
  15187. } else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
  15188. const slotName = findDir(node, "slot", true);
  15189. const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
  15190. if (slot) {
  15191. slot.returns = getCacheExpression(
  15192. createArrayExpression(slot.returns)
  15193. );
  15194. cachedAsArray = true;
  15195. }
  15196. }
  15197. }
  15198. if (!cachedAsArray) {
  15199. for (const child of toCache) {
  15200. child.codegenNode = context.cache(child.codegenNode);
  15201. }
  15202. }
  15203. function getCacheExpression(value) {
  15204. const exp = context.cache(value);
  15205. exp.needArraySpread = true;
  15206. return exp;
  15207. }
  15208. function getSlotNode(node2, name) {
  15209. if (node2.children && !isArray(node2.children) && node2.children.type === 15) {
  15210. const slot = node2.children.properties.find(
  15211. (p) => p.key === name || p.key.content === name
  15212. );
  15213. return slot && slot.value;
  15214. }
  15215. }
  15216. if (toCache.length && context.transformHoist) {
  15217. context.transformHoist(children, context, node);
  15218. }
  15219. }
  15220. function getConstantType(node, context) {
  15221. const { constantCache } = context;
  15222. switch (node.type) {
  15223. case 1:
  15224. if (node.tagType !== 0) {
  15225. return 0;
  15226. }
  15227. const cached = constantCache.get(node);
  15228. if (cached !== void 0) {
  15229. return cached;
  15230. }
  15231. const codegenNode = node.codegenNode;
  15232. if (codegenNode.type !== 13) {
  15233. return 0;
  15234. }
  15235. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
  15236. return 0;
  15237. }
  15238. if (codegenNode.patchFlag === void 0) {
  15239. let returnType2 = 3;
  15240. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  15241. if (generatedPropsType === 0) {
  15242. constantCache.set(node, 0);
  15243. return 0;
  15244. }
  15245. if (generatedPropsType < returnType2) {
  15246. returnType2 = generatedPropsType;
  15247. }
  15248. for (let i = 0; i < node.children.length; i++) {
  15249. const childType = getConstantType(node.children[i], context);
  15250. if (childType === 0) {
  15251. constantCache.set(node, 0);
  15252. return 0;
  15253. }
  15254. if (childType < returnType2) {
  15255. returnType2 = childType;
  15256. }
  15257. }
  15258. if (returnType2 > 1) {
  15259. for (let i = 0; i < node.props.length; i++) {
  15260. const p = node.props[i];
  15261. if (p.type === 7 && p.name === "bind" && p.exp) {
  15262. const expType = getConstantType(p.exp, context);
  15263. if (expType === 0) {
  15264. constantCache.set(node, 0);
  15265. return 0;
  15266. }
  15267. if (expType < returnType2) {
  15268. returnType2 = expType;
  15269. }
  15270. }
  15271. }
  15272. }
  15273. if (codegenNode.isBlock) {
  15274. for (let i = 0; i < node.props.length; i++) {
  15275. const p = node.props[i];
  15276. if (p.type === 7) {
  15277. constantCache.set(node, 0);
  15278. return 0;
  15279. }
  15280. }
  15281. context.removeHelper(OPEN_BLOCK);
  15282. context.removeHelper(
  15283. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  15284. );
  15285. codegenNode.isBlock = false;
  15286. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  15287. }
  15288. constantCache.set(node, returnType2);
  15289. return returnType2;
  15290. } else {
  15291. constantCache.set(node, 0);
  15292. return 0;
  15293. }
  15294. case 2:
  15295. case 3:
  15296. return 3;
  15297. case 9:
  15298. case 11:
  15299. case 10:
  15300. return 0;
  15301. case 5:
  15302. case 12:
  15303. return getConstantType(node.content, context);
  15304. case 4:
  15305. return node.constType;
  15306. case 8:
  15307. let returnType = 3;
  15308. for (let i = 0; i < node.children.length; i++) {
  15309. const child = node.children[i];
  15310. if (isString(child) || isSymbol(child)) {
  15311. continue;
  15312. }
  15313. const childType = getConstantType(child, context);
  15314. if (childType === 0) {
  15315. return 0;
  15316. } else if (childType < returnType) {
  15317. returnType = childType;
  15318. }
  15319. }
  15320. return returnType;
  15321. case 20:
  15322. return 2;
  15323. default:
  15324. return 0;
  15325. }
  15326. }
  15327. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  15328. NORMALIZE_CLASS,
  15329. NORMALIZE_STYLE,
  15330. NORMALIZE_PROPS,
  15331. GUARD_REACTIVE_PROPS
  15332. ]);
  15333. function getConstantTypeOfHelperCall(value, context) {
  15334. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  15335. const arg = value.arguments[0];
  15336. if (arg.type === 4) {
  15337. return getConstantType(arg, context);
  15338. } else if (arg.type === 14) {
  15339. return getConstantTypeOfHelperCall(arg, context);
  15340. }
  15341. }
  15342. return 0;
  15343. }
  15344. function getGeneratedPropsConstantType(node, context) {
  15345. let returnType = 3;
  15346. const props = getNodeProps(node);
  15347. if (props && props.type === 15) {
  15348. const { properties } = props;
  15349. for (let i = 0; i < properties.length; i++) {
  15350. const { key, value } = properties[i];
  15351. const keyType = getConstantType(key, context);
  15352. if (keyType === 0) {
  15353. return keyType;
  15354. }
  15355. if (keyType < returnType) {
  15356. returnType = keyType;
  15357. }
  15358. let valueType;
  15359. if (value.type === 4) {
  15360. valueType = getConstantType(value, context);
  15361. } else if (value.type === 14) {
  15362. valueType = getConstantTypeOfHelperCall(value, context);
  15363. } else {
  15364. valueType = 0;
  15365. }
  15366. if (valueType === 0) {
  15367. return valueType;
  15368. }
  15369. if (valueType < returnType) {
  15370. returnType = valueType;
  15371. }
  15372. }
  15373. }
  15374. return returnType;
  15375. }
  15376. function getNodeProps(node) {
  15377. const codegenNode = node.codegenNode;
  15378. if (codegenNode.type === 13) {
  15379. return codegenNode.props;
  15380. }
  15381. }
  15382. function createTransformContext(root, {
  15383. filename = "",
  15384. prefixIdentifiers = false,
  15385. hoistStatic = false,
  15386. hmr = false,
  15387. cacheHandlers = false,
  15388. nodeTransforms = [],
  15389. directiveTransforms = {},
  15390. transformHoist = null,
  15391. isBuiltInComponent = NOOP,
  15392. isCustomElement = NOOP,
  15393. expressionPlugins = [],
  15394. scopeId = null,
  15395. slotted = true,
  15396. ssr = false,
  15397. inSSR = false,
  15398. ssrCssVars = ``,
  15399. bindingMetadata = EMPTY_OBJ,
  15400. inline = false,
  15401. isTS = false,
  15402. onError = defaultOnError,
  15403. onWarn = defaultOnWarn,
  15404. compatConfig
  15405. }) {
  15406. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  15407. const context = {
  15408. // options
  15409. filename,
  15410. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  15411. prefixIdentifiers,
  15412. hoistStatic,
  15413. hmr,
  15414. cacheHandlers,
  15415. nodeTransforms,
  15416. directiveTransforms,
  15417. transformHoist,
  15418. isBuiltInComponent,
  15419. isCustomElement,
  15420. expressionPlugins,
  15421. scopeId,
  15422. slotted,
  15423. ssr,
  15424. inSSR,
  15425. ssrCssVars,
  15426. bindingMetadata,
  15427. inline,
  15428. isTS,
  15429. onError,
  15430. onWarn,
  15431. compatConfig,
  15432. // state
  15433. root,
  15434. helpers: /* @__PURE__ */ new Map(),
  15435. components: /* @__PURE__ */ new Set(),
  15436. directives: /* @__PURE__ */ new Set(),
  15437. hoists: [],
  15438. imports: [],
  15439. cached: [],
  15440. constantCache: /* @__PURE__ */ new WeakMap(),
  15441. temps: 0,
  15442. identifiers: /* @__PURE__ */ Object.create(null),
  15443. scopes: {
  15444. vFor: 0,
  15445. vSlot: 0,
  15446. vPre: 0,
  15447. vOnce: 0
  15448. },
  15449. parent: null,
  15450. grandParent: null,
  15451. currentNode: root,
  15452. childIndex: 0,
  15453. inVOnce: false,
  15454. // methods
  15455. helper(name) {
  15456. const count = context.helpers.get(name) || 0;
  15457. context.helpers.set(name, count + 1);
  15458. return name;
  15459. },
  15460. removeHelper(name) {
  15461. const count = context.helpers.get(name);
  15462. if (count) {
  15463. const currentCount = count - 1;
  15464. if (!currentCount) {
  15465. context.helpers.delete(name);
  15466. } else {
  15467. context.helpers.set(name, currentCount);
  15468. }
  15469. }
  15470. },
  15471. helperString(name) {
  15472. return `_${helperNameMap[context.helper(name)]}`;
  15473. },
  15474. replaceNode(node) {
  15475. {
  15476. if (!context.currentNode) {
  15477. throw new Error(`Node being replaced is already removed.`);
  15478. }
  15479. if (!context.parent) {
  15480. throw new Error(`Cannot replace root node.`);
  15481. }
  15482. }
  15483. context.parent.children[context.childIndex] = context.currentNode = node;
  15484. },
  15485. removeNode(node) {
  15486. if (!context.parent) {
  15487. throw new Error(`Cannot remove root node.`);
  15488. }
  15489. const list = context.parent.children;
  15490. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  15491. if (removalIndex < 0) {
  15492. throw new Error(`node being removed is not a child of current parent`);
  15493. }
  15494. if (!node || node === context.currentNode) {
  15495. context.currentNode = null;
  15496. context.onNodeRemoved();
  15497. } else {
  15498. if (context.childIndex > removalIndex) {
  15499. context.childIndex--;
  15500. context.onNodeRemoved();
  15501. }
  15502. }
  15503. context.parent.children.splice(removalIndex, 1);
  15504. },
  15505. onNodeRemoved: NOOP,
  15506. addIdentifiers(exp) {
  15507. },
  15508. removeIdentifiers(exp) {
  15509. },
  15510. hoist(exp) {
  15511. if (isString(exp)) exp = createSimpleExpression(exp);
  15512. context.hoists.push(exp);
  15513. const identifier = createSimpleExpression(
  15514. `_hoisted_${context.hoists.length}`,
  15515. false,
  15516. exp.loc,
  15517. 2
  15518. );
  15519. identifier.hoisted = exp;
  15520. return identifier;
  15521. },
  15522. cache(exp, isVNode = false, inVOnce = false) {
  15523. const cacheExp = createCacheExpression(
  15524. context.cached.length,
  15525. exp,
  15526. isVNode,
  15527. inVOnce
  15528. );
  15529. context.cached.push(cacheExp);
  15530. return cacheExp;
  15531. }
  15532. };
  15533. return context;
  15534. }
  15535. function transform(root, options) {
  15536. const context = createTransformContext(root, options);
  15537. traverseNode(root, context);
  15538. if (options.hoistStatic) {
  15539. cacheStatic(root, context);
  15540. }
  15541. if (!options.ssr) {
  15542. createRootCodegen(root, context);
  15543. }
  15544. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  15545. root.components = [...context.components];
  15546. root.directives = [...context.directives];
  15547. root.imports = context.imports;
  15548. root.hoists = context.hoists;
  15549. root.temps = context.temps;
  15550. root.cached = context.cached;
  15551. root.transformed = true;
  15552. }
  15553. function createRootCodegen(root, context) {
  15554. const { helper } = context;
  15555. const { children } = root;
  15556. if (children.length === 1) {
  15557. const singleElementRootChild = getSingleElementRoot(root);
  15558. if (singleElementRootChild && singleElementRootChild.codegenNode) {
  15559. const codegenNode = singleElementRootChild.codegenNode;
  15560. if (codegenNode.type === 13) {
  15561. convertToBlock(codegenNode, context);
  15562. }
  15563. root.codegenNode = codegenNode;
  15564. } else {
  15565. root.codegenNode = children[0];
  15566. }
  15567. } else if (children.length > 1) {
  15568. let patchFlag = 64;
  15569. if (children.filter((c) => c.type !== 3).length === 1) {
  15570. patchFlag |= 2048;
  15571. }
  15572. root.codegenNode = createVNodeCall(
  15573. context,
  15574. helper(FRAGMENT),
  15575. void 0,
  15576. root.children,
  15577. patchFlag,
  15578. void 0,
  15579. void 0,
  15580. true,
  15581. void 0,
  15582. false
  15583. );
  15584. } else ;
  15585. }
  15586. function traverseChildren(parent, context) {
  15587. let i = 0;
  15588. const nodeRemoved = () => {
  15589. i--;
  15590. };
  15591. for (; i < parent.children.length; i++) {
  15592. const child = parent.children[i];
  15593. if (isString(child)) continue;
  15594. context.grandParent = context.parent;
  15595. context.parent = parent;
  15596. context.childIndex = i;
  15597. context.onNodeRemoved = nodeRemoved;
  15598. traverseNode(child, context);
  15599. }
  15600. }
  15601. function traverseNode(node, context) {
  15602. context.currentNode = node;
  15603. const { nodeTransforms } = context;
  15604. const exitFns = [];
  15605. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  15606. const onExit = nodeTransforms[i2](node, context);
  15607. if (onExit) {
  15608. if (isArray(onExit)) {
  15609. exitFns.push(...onExit);
  15610. } else {
  15611. exitFns.push(onExit);
  15612. }
  15613. }
  15614. if (!context.currentNode) {
  15615. return;
  15616. } else {
  15617. node = context.currentNode;
  15618. }
  15619. }
  15620. switch (node.type) {
  15621. case 3:
  15622. if (!context.ssr) {
  15623. context.helper(CREATE_COMMENT);
  15624. }
  15625. break;
  15626. case 5:
  15627. if (!context.ssr) {
  15628. context.helper(TO_DISPLAY_STRING);
  15629. }
  15630. break;
  15631. // for container types, further traverse downwards
  15632. case 9:
  15633. for (let i2 = 0; i2 < node.branches.length; i2++) {
  15634. traverseNode(node.branches[i2], context);
  15635. }
  15636. break;
  15637. case 10:
  15638. case 11:
  15639. case 1:
  15640. case 0:
  15641. traverseChildren(node, context);
  15642. break;
  15643. }
  15644. context.currentNode = node;
  15645. let i = exitFns.length;
  15646. while (i--) {
  15647. exitFns[i]();
  15648. }
  15649. }
  15650. function createStructuralDirectiveTransform(name, fn) {
  15651. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  15652. return (node, context) => {
  15653. if (node.type === 1) {
  15654. const { props } = node;
  15655. if (node.tagType === 3 && props.some(isVSlot)) {
  15656. return;
  15657. }
  15658. const exitFns = [];
  15659. for (let i = 0; i < props.length; i++) {
  15660. const prop = props[i];
  15661. if (prop.type === 7 && matches(prop.name)) {
  15662. props.splice(i, 1);
  15663. i--;
  15664. const onExit = fn(node, prop, context);
  15665. if (onExit) exitFns.push(onExit);
  15666. }
  15667. }
  15668. return exitFns;
  15669. }
  15670. };
  15671. }
  15672. const PURE_ANNOTATION = `/*@__PURE__*/`;
  15673. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  15674. function createCodegenContext(ast, {
  15675. mode = "function",
  15676. prefixIdentifiers = mode === "module",
  15677. sourceMap = false,
  15678. filename = `template.vue.html`,
  15679. scopeId = null,
  15680. optimizeImports = false,
  15681. runtimeGlobalName = `Vue`,
  15682. runtimeModuleName = `vue`,
  15683. ssrRuntimeModuleName = "vue/server-renderer",
  15684. ssr = false,
  15685. isTS = false,
  15686. inSSR = false
  15687. }) {
  15688. const context = {
  15689. mode,
  15690. prefixIdentifiers,
  15691. sourceMap,
  15692. filename,
  15693. scopeId,
  15694. optimizeImports,
  15695. runtimeGlobalName,
  15696. runtimeModuleName,
  15697. ssrRuntimeModuleName,
  15698. ssr,
  15699. isTS,
  15700. inSSR,
  15701. source: ast.source,
  15702. code: ``,
  15703. column: 1,
  15704. line: 1,
  15705. offset: 0,
  15706. indentLevel: 0,
  15707. pure: false,
  15708. map: void 0,
  15709. helper(key) {
  15710. return `_${helperNameMap[key]}`;
  15711. },
  15712. push(code, newlineIndex = -2 /* None */, node) {
  15713. context.code += code;
  15714. },
  15715. indent() {
  15716. newline(++context.indentLevel);
  15717. },
  15718. deindent(withoutNewLine = false) {
  15719. if (withoutNewLine) {
  15720. --context.indentLevel;
  15721. } else {
  15722. newline(--context.indentLevel);
  15723. }
  15724. },
  15725. newline() {
  15726. newline(context.indentLevel);
  15727. }
  15728. };
  15729. function newline(n) {
  15730. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  15731. }
  15732. return context;
  15733. }
  15734. function generate(ast, options = {}) {
  15735. const context = createCodegenContext(ast, options);
  15736. if (options.onContextCreated) options.onContextCreated(context);
  15737. const {
  15738. mode,
  15739. push,
  15740. prefixIdentifiers,
  15741. indent,
  15742. deindent,
  15743. newline,
  15744. scopeId,
  15745. ssr
  15746. } = context;
  15747. const helpers = Array.from(ast.helpers);
  15748. const hasHelpers = helpers.length > 0;
  15749. const useWithBlock = !prefixIdentifiers && mode !== "module";
  15750. const preambleContext = context;
  15751. {
  15752. genFunctionPreamble(ast, preambleContext);
  15753. }
  15754. const functionName = ssr ? `ssrRender` : `render`;
  15755. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  15756. const signature = args.join(", ");
  15757. {
  15758. push(`function ${functionName}(${signature}) {`);
  15759. }
  15760. indent();
  15761. if (useWithBlock) {
  15762. push(`with (_ctx) {`);
  15763. indent();
  15764. if (hasHelpers) {
  15765. push(
  15766. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  15767. `,
  15768. -1 /* End */
  15769. );
  15770. newline();
  15771. }
  15772. }
  15773. if (ast.components.length) {
  15774. genAssets(ast.components, "component", context);
  15775. if (ast.directives.length || ast.temps > 0) {
  15776. newline();
  15777. }
  15778. }
  15779. if (ast.directives.length) {
  15780. genAssets(ast.directives, "directive", context);
  15781. if (ast.temps > 0) {
  15782. newline();
  15783. }
  15784. }
  15785. if (ast.temps > 0) {
  15786. push(`let `);
  15787. for (let i = 0; i < ast.temps; i++) {
  15788. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  15789. }
  15790. }
  15791. if (ast.components.length || ast.directives.length || ast.temps) {
  15792. push(`
  15793. `, 0 /* Start */);
  15794. newline();
  15795. }
  15796. if (!ssr) {
  15797. push(`return `);
  15798. }
  15799. if (ast.codegenNode) {
  15800. genNode(ast.codegenNode, context);
  15801. } else {
  15802. push(`null`);
  15803. }
  15804. if (useWithBlock) {
  15805. deindent();
  15806. push(`}`);
  15807. }
  15808. deindent();
  15809. push(`}`);
  15810. return {
  15811. ast,
  15812. code: context.code,
  15813. preamble: ``,
  15814. map: context.map ? context.map.toJSON() : void 0
  15815. };
  15816. }
  15817. function genFunctionPreamble(ast, context) {
  15818. const {
  15819. ssr,
  15820. prefixIdentifiers,
  15821. push,
  15822. newline,
  15823. runtimeModuleName,
  15824. runtimeGlobalName,
  15825. ssrRuntimeModuleName
  15826. } = context;
  15827. const VueBinding = runtimeGlobalName;
  15828. const helpers = Array.from(ast.helpers);
  15829. if (helpers.length > 0) {
  15830. {
  15831. push(`const _Vue = ${VueBinding}
  15832. `, -1 /* End */);
  15833. if (ast.hoists.length) {
  15834. const staticHelpers = [
  15835. CREATE_VNODE,
  15836. CREATE_ELEMENT_VNODE,
  15837. CREATE_COMMENT,
  15838. CREATE_TEXT,
  15839. CREATE_STATIC
  15840. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  15841. push(`const { ${staticHelpers} } = _Vue
  15842. `, -1 /* End */);
  15843. }
  15844. }
  15845. }
  15846. genHoists(ast.hoists, context);
  15847. newline();
  15848. push(`return `);
  15849. }
  15850. function genAssets(assets, type, { helper, push, newline, isTS }) {
  15851. const resolver = helper(
  15852. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  15853. );
  15854. for (let i = 0; i < assets.length; i++) {
  15855. let id = assets[i];
  15856. const maybeSelfReference = id.endsWith("__self");
  15857. if (maybeSelfReference) {
  15858. id = id.slice(0, -6);
  15859. }
  15860. push(
  15861. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  15862. );
  15863. if (i < assets.length - 1) {
  15864. newline();
  15865. }
  15866. }
  15867. }
  15868. function genHoists(hoists, context) {
  15869. if (!hoists.length) {
  15870. return;
  15871. }
  15872. context.pure = true;
  15873. const { push, newline } = context;
  15874. newline();
  15875. for (let i = 0; i < hoists.length; i++) {
  15876. const exp = hoists[i];
  15877. if (exp) {
  15878. push(`const _hoisted_${i + 1} = `);
  15879. genNode(exp, context);
  15880. newline();
  15881. }
  15882. }
  15883. context.pure = false;
  15884. }
  15885. function isText(n) {
  15886. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  15887. }
  15888. function genNodeListAsArray(nodes, context) {
  15889. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
  15890. context.push(`[`);
  15891. multilines && context.indent();
  15892. genNodeList(nodes, context, multilines);
  15893. multilines && context.deindent();
  15894. context.push(`]`);
  15895. }
  15896. function genNodeList(nodes, context, multilines = false, comma = true) {
  15897. const { push, newline } = context;
  15898. for (let i = 0; i < nodes.length; i++) {
  15899. const node = nodes[i];
  15900. if (isString(node)) {
  15901. push(node, -3 /* Unknown */);
  15902. } else if (isArray(node)) {
  15903. genNodeListAsArray(node, context);
  15904. } else {
  15905. genNode(node, context);
  15906. }
  15907. if (i < nodes.length - 1) {
  15908. if (multilines) {
  15909. comma && push(",");
  15910. newline();
  15911. } else {
  15912. comma && push(", ");
  15913. }
  15914. }
  15915. }
  15916. }
  15917. function genNode(node, context) {
  15918. if (isString(node)) {
  15919. context.push(node, -3 /* Unknown */);
  15920. return;
  15921. }
  15922. if (isSymbol(node)) {
  15923. context.push(context.helper(node));
  15924. return;
  15925. }
  15926. switch (node.type) {
  15927. case 1:
  15928. case 9:
  15929. case 11:
  15930. assert(
  15931. node.codegenNode != null,
  15932. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  15933. );
  15934. genNode(node.codegenNode, context);
  15935. break;
  15936. case 2:
  15937. genText(node, context);
  15938. break;
  15939. case 4:
  15940. genExpression(node, context);
  15941. break;
  15942. case 5:
  15943. genInterpolation(node, context);
  15944. break;
  15945. case 12:
  15946. genNode(node.codegenNode, context);
  15947. break;
  15948. case 8:
  15949. genCompoundExpression(node, context);
  15950. break;
  15951. case 3:
  15952. genComment(node, context);
  15953. break;
  15954. case 13:
  15955. genVNodeCall(node, context);
  15956. break;
  15957. case 14:
  15958. genCallExpression(node, context);
  15959. break;
  15960. case 15:
  15961. genObjectExpression(node, context);
  15962. break;
  15963. case 17:
  15964. genArrayExpression(node, context);
  15965. break;
  15966. case 18:
  15967. genFunctionExpression(node, context);
  15968. break;
  15969. case 19:
  15970. genConditionalExpression(node, context);
  15971. break;
  15972. case 20:
  15973. genCacheExpression(node, context);
  15974. break;
  15975. case 21:
  15976. genNodeList(node.body, context, true, false);
  15977. break;
  15978. // SSR only types
  15979. case 22:
  15980. break;
  15981. case 23:
  15982. break;
  15983. case 24:
  15984. break;
  15985. case 25:
  15986. break;
  15987. case 26:
  15988. break;
  15989. /* v8 ignore start */
  15990. case 10:
  15991. break;
  15992. default:
  15993. {
  15994. assert(false, `unhandled codegen node type: ${node.type}`);
  15995. const exhaustiveCheck = node;
  15996. return exhaustiveCheck;
  15997. }
  15998. }
  15999. }
  16000. function genText(node, context) {
  16001. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  16002. }
  16003. function genExpression(node, context) {
  16004. const { content, isStatic } = node;
  16005. context.push(
  16006. isStatic ? JSON.stringify(content) : content,
  16007. -3 /* Unknown */,
  16008. node
  16009. );
  16010. }
  16011. function genInterpolation(node, context) {
  16012. const { push, helper, pure } = context;
  16013. if (pure) push(PURE_ANNOTATION);
  16014. push(`${helper(TO_DISPLAY_STRING)}(`);
  16015. genNode(node.content, context);
  16016. push(`)`);
  16017. }
  16018. function genCompoundExpression(node, context) {
  16019. for (let i = 0; i < node.children.length; i++) {
  16020. const child = node.children[i];
  16021. if (isString(child)) {
  16022. context.push(child, -3 /* Unknown */);
  16023. } else {
  16024. genNode(child, context);
  16025. }
  16026. }
  16027. }
  16028. function genExpressionAsPropertyKey(node, context) {
  16029. const { push } = context;
  16030. if (node.type === 8) {
  16031. push(`[`);
  16032. genCompoundExpression(node, context);
  16033. push(`]`);
  16034. } else if (node.isStatic) {
  16035. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  16036. push(text, -2 /* None */, node);
  16037. } else {
  16038. push(`[${node.content}]`, -3 /* Unknown */, node);
  16039. }
  16040. }
  16041. function genComment(node, context) {
  16042. const { push, helper, pure } = context;
  16043. if (pure) {
  16044. push(PURE_ANNOTATION);
  16045. }
  16046. push(
  16047. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  16048. -3 /* Unknown */,
  16049. node
  16050. );
  16051. }
  16052. function genVNodeCall(node, context) {
  16053. const { push, helper, pure } = context;
  16054. const {
  16055. tag,
  16056. props,
  16057. children,
  16058. patchFlag,
  16059. dynamicProps,
  16060. directives,
  16061. isBlock,
  16062. disableTracking,
  16063. isComponent
  16064. } = node;
  16065. let patchFlagString;
  16066. if (patchFlag) {
  16067. {
  16068. if (patchFlag < 0) {
  16069. patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  16070. } else {
  16071. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  16072. patchFlagString = patchFlag + ` /* ${flagNames} */`;
  16073. }
  16074. }
  16075. }
  16076. if (directives) {
  16077. push(helper(WITH_DIRECTIVES) + `(`);
  16078. }
  16079. if (isBlock) {
  16080. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  16081. }
  16082. if (pure) {
  16083. push(PURE_ANNOTATION);
  16084. }
  16085. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  16086. push(helper(callHelper) + `(`, -2 /* None */, node);
  16087. genNodeList(
  16088. genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
  16089. context
  16090. );
  16091. push(`)`);
  16092. if (isBlock) {
  16093. push(`)`);
  16094. }
  16095. if (directives) {
  16096. push(`, `);
  16097. genNode(directives, context);
  16098. push(`)`);
  16099. }
  16100. }
  16101. function genNullableArgs(args) {
  16102. let i = args.length;
  16103. while (i--) {
  16104. if (args[i] != null) break;
  16105. }
  16106. return args.slice(0, i + 1).map((arg) => arg || `null`);
  16107. }
  16108. function genCallExpression(node, context) {
  16109. const { push, helper, pure } = context;
  16110. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  16111. if (pure) {
  16112. push(PURE_ANNOTATION);
  16113. }
  16114. push(callee + `(`, -2 /* None */, node);
  16115. genNodeList(node.arguments, context);
  16116. push(`)`);
  16117. }
  16118. function genObjectExpression(node, context) {
  16119. const { push, indent, deindent, newline } = context;
  16120. const { properties } = node;
  16121. if (!properties.length) {
  16122. push(`{}`, -2 /* None */, node);
  16123. return;
  16124. }
  16125. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  16126. push(multilines ? `{` : `{ `);
  16127. multilines && indent();
  16128. for (let i = 0; i < properties.length; i++) {
  16129. const { key, value } = properties[i];
  16130. genExpressionAsPropertyKey(key, context);
  16131. push(`: `);
  16132. genNode(value, context);
  16133. if (i < properties.length - 1) {
  16134. push(`,`);
  16135. newline();
  16136. }
  16137. }
  16138. multilines && deindent();
  16139. push(multilines ? `}` : ` }`);
  16140. }
  16141. function genArrayExpression(node, context) {
  16142. genNodeListAsArray(node.elements, context);
  16143. }
  16144. function genFunctionExpression(node, context) {
  16145. const { push, indent, deindent } = context;
  16146. const { params, returns, body, newline, isSlot } = node;
  16147. if (isSlot) {
  16148. push(`_${helperNameMap[WITH_CTX]}(`);
  16149. }
  16150. push(`(`, -2 /* None */, node);
  16151. if (isArray(params)) {
  16152. genNodeList(params, context);
  16153. } else if (params) {
  16154. genNode(params, context);
  16155. }
  16156. push(`) => `);
  16157. if (newline || body) {
  16158. push(`{`);
  16159. indent();
  16160. }
  16161. if (returns) {
  16162. if (newline) {
  16163. push(`return `);
  16164. }
  16165. if (isArray(returns)) {
  16166. genNodeListAsArray(returns, context);
  16167. } else {
  16168. genNode(returns, context);
  16169. }
  16170. } else if (body) {
  16171. genNode(body, context);
  16172. }
  16173. if (newline || body) {
  16174. deindent();
  16175. push(`}`);
  16176. }
  16177. if (isSlot) {
  16178. push(`)`);
  16179. }
  16180. }
  16181. function genConditionalExpression(node, context) {
  16182. const { test, consequent, alternate, newline: needNewline } = node;
  16183. const { push, indent, deindent, newline } = context;
  16184. if (test.type === 4) {
  16185. const needsParens = !isSimpleIdentifier(test.content);
  16186. needsParens && push(`(`);
  16187. genExpression(test, context);
  16188. needsParens && push(`)`);
  16189. } else {
  16190. push(`(`);
  16191. genNode(test, context);
  16192. push(`)`);
  16193. }
  16194. needNewline && indent();
  16195. context.indentLevel++;
  16196. needNewline || push(` `);
  16197. push(`? `);
  16198. genNode(consequent, context);
  16199. context.indentLevel--;
  16200. needNewline && newline();
  16201. needNewline || push(` `);
  16202. push(`: `);
  16203. const isNested = alternate.type === 19;
  16204. if (!isNested) {
  16205. context.indentLevel++;
  16206. }
  16207. genNode(alternate, context);
  16208. if (!isNested) {
  16209. context.indentLevel--;
  16210. }
  16211. needNewline && deindent(
  16212. true
  16213. /* without newline */
  16214. );
  16215. }
  16216. function genCacheExpression(node, context) {
  16217. const { push, helper, indent, deindent, newline } = context;
  16218. const { needPauseTracking, needArraySpread } = node;
  16219. if (needArraySpread) {
  16220. push(`[...(`);
  16221. }
  16222. push(`_cache[${node.index}] || (`);
  16223. if (needPauseTracking) {
  16224. indent();
  16225. push(`${helper(SET_BLOCK_TRACKING)}(-1`);
  16226. if (node.inVOnce) push(`, true`);
  16227. push(`),`);
  16228. newline();
  16229. push(`(`);
  16230. }
  16231. push(`_cache[${node.index}] = `);
  16232. genNode(node.value, context);
  16233. if (needPauseTracking) {
  16234. push(`).cacheIndex = ${node.index},`);
  16235. newline();
  16236. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  16237. newline();
  16238. push(`_cache[${node.index}]`);
  16239. deindent();
  16240. }
  16241. push(`)`);
  16242. if (needArraySpread) {
  16243. push(`)]`);
  16244. }
  16245. }
  16246. const prohibitedKeywordRE = new RegExp(
  16247. "\\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"
  16248. );
  16249. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  16250. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  16251. const exp = node.content;
  16252. if (!exp.trim()) {
  16253. return;
  16254. }
  16255. try {
  16256. new Function(
  16257. asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
  16258. );
  16259. } catch (e) {
  16260. let message = e.message;
  16261. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  16262. if (keywordMatch) {
  16263. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  16264. }
  16265. context.onError(
  16266. createCompilerError(
  16267. 46,
  16268. node.loc,
  16269. void 0,
  16270. message
  16271. )
  16272. );
  16273. }
  16274. }
  16275. const transformExpression = (node, context) => {
  16276. if (node.type === 5) {
  16277. node.content = processExpression(
  16278. node.content,
  16279. context
  16280. );
  16281. } else if (node.type === 1) {
  16282. const memo = findDir(node, "memo");
  16283. for (let i = 0; i < node.props.length; i++) {
  16284. const dir = node.props[i];
  16285. if (dir.type === 7 && dir.name !== "for") {
  16286. const exp = dir.exp;
  16287. const arg = dir.arg;
  16288. if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
  16289. !(memo && arg && arg.type === 4 && arg.content === "key")) {
  16290. dir.exp = processExpression(
  16291. exp,
  16292. context,
  16293. // slot args must be processed as function params
  16294. dir.name === "slot"
  16295. );
  16296. }
  16297. if (arg && arg.type === 4 && !arg.isStatic) {
  16298. dir.arg = processExpression(arg, context);
  16299. }
  16300. }
  16301. }
  16302. }
  16303. };
  16304. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  16305. {
  16306. {
  16307. validateBrowserExpression(node, context, asParams, asRawStatements);
  16308. }
  16309. return node;
  16310. }
  16311. }
  16312. const transformIf = createStructuralDirectiveTransform(
  16313. /^(?:if|else|else-if)$/,
  16314. (node, dir, context) => {
  16315. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  16316. const siblings = context.parent.children;
  16317. let i = siblings.indexOf(ifNode);
  16318. let key = 0;
  16319. while (i-- >= 0) {
  16320. const sibling = siblings[i];
  16321. if (sibling && sibling.type === 9) {
  16322. key += sibling.branches.length;
  16323. }
  16324. }
  16325. return () => {
  16326. if (isRoot) {
  16327. ifNode.codegenNode = createCodegenNodeForBranch(
  16328. branch,
  16329. key,
  16330. context
  16331. );
  16332. } else {
  16333. const parentCondition = getParentCondition(ifNode.codegenNode);
  16334. parentCondition.alternate = createCodegenNodeForBranch(
  16335. branch,
  16336. key + ifNode.branches.length - 1,
  16337. context
  16338. );
  16339. }
  16340. };
  16341. });
  16342. }
  16343. );
  16344. function processIf(node, dir, context, processCodegen) {
  16345. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  16346. const loc = dir.exp ? dir.exp.loc : node.loc;
  16347. context.onError(
  16348. createCompilerError(28, dir.loc)
  16349. );
  16350. dir.exp = createSimpleExpression(`true`, false, loc);
  16351. }
  16352. if (dir.exp) {
  16353. validateBrowserExpression(dir.exp, context);
  16354. }
  16355. if (dir.name === "if") {
  16356. const branch = createIfBranch(node, dir);
  16357. const ifNode = {
  16358. type: 9,
  16359. loc: cloneLoc(node.loc),
  16360. branches: [branch]
  16361. };
  16362. context.replaceNode(ifNode);
  16363. if (processCodegen) {
  16364. return processCodegen(ifNode, branch, true);
  16365. }
  16366. } else {
  16367. const siblings = context.parent.children;
  16368. const comments = [];
  16369. let i = siblings.indexOf(node);
  16370. while (i-- >= -1) {
  16371. const sibling = siblings[i];
  16372. if (sibling && isCommentOrWhitespace(sibling)) {
  16373. context.removeNode(sibling);
  16374. if (sibling.type === 3) {
  16375. comments.unshift(sibling);
  16376. }
  16377. continue;
  16378. }
  16379. if (sibling && sibling.type === 9) {
  16380. if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  16381. context.onError(
  16382. createCompilerError(30, node.loc)
  16383. );
  16384. }
  16385. context.removeNode();
  16386. const branch = createIfBranch(node, dir);
  16387. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  16388. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  16389. branch.children = [...comments, ...branch.children];
  16390. }
  16391. {
  16392. const key = branch.userKey;
  16393. if (key) {
  16394. sibling.branches.forEach(({ userKey }) => {
  16395. if (isSameKey(userKey, key)) {
  16396. context.onError(
  16397. createCompilerError(
  16398. 29,
  16399. branch.userKey.loc
  16400. )
  16401. );
  16402. }
  16403. });
  16404. }
  16405. }
  16406. sibling.branches.push(branch);
  16407. const onExit = processCodegen && processCodegen(sibling, branch, false);
  16408. traverseNode(branch, context);
  16409. if (onExit) onExit();
  16410. context.currentNode = null;
  16411. } else {
  16412. context.onError(
  16413. createCompilerError(30, node.loc)
  16414. );
  16415. }
  16416. break;
  16417. }
  16418. }
  16419. }
  16420. function createIfBranch(node, dir) {
  16421. const isTemplateIf = node.tagType === 3;
  16422. return {
  16423. type: 10,
  16424. loc: node.loc,
  16425. condition: dir.name === "else" ? void 0 : dir.exp,
  16426. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  16427. userKey: findProp(node, `key`),
  16428. isTemplateIf
  16429. };
  16430. }
  16431. function createCodegenNodeForBranch(branch, keyIndex, context) {
  16432. if (branch.condition) {
  16433. return createConditionalExpression(
  16434. branch.condition,
  16435. createChildrenCodegenNode(branch, keyIndex, context),
  16436. // make sure to pass in asBlock: true so that the comment node call
  16437. // closes the current block.
  16438. createCallExpression(context.helper(CREATE_COMMENT), [
  16439. '"v-if"' ,
  16440. "true"
  16441. ])
  16442. );
  16443. } else {
  16444. return createChildrenCodegenNode(branch, keyIndex, context);
  16445. }
  16446. }
  16447. function createChildrenCodegenNode(branch, keyIndex, context) {
  16448. const { helper } = context;
  16449. const keyProperty = createObjectProperty(
  16450. `key`,
  16451. createSimpleExpression(
  16452. `${keyIndex}`,
  16453. false,
  16454. locStub,
  16455. 2
  16456. )
  16457. );
  16458. const { children } = branch;
  16459. const firstChild = children[0];
  16460. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  16461. if (needFragmentWrapper) {
  16462. if (children.length === 1 && firstChild.type === 11) {
  16463. const vnodeCall = firstChild.codegenNode;
  16464. injectProp(vnodeCall, keyProperty, context);
  16465. return vnodeCall;
  16466. } else {
  16467. let patchFlag = 64;
  16468. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  16469. patchFlag |= 2048;
  16470. }
  16471. return createVNodeCall(
  16472. context,
  16473. helper(FRAGMENT),
  16474. createObjectExpression([keyProperty]),
  16475. children,
  16476. patchFlag,
  16477. void 0,
  16478. void 0,
  16479. true,
  16480. false,
  16481. false,
  16482. branch.loc
  16483. );
  16484. }
  16485. } else {
  16486. const ret = firstChild.codegenNode;
  16487. const vnodeCall = getMemoedVNodeCall(ret);
  16488. if (vnodeCall.type === 13) {
  16489. convertToBlock(vnodeCall, context);
  16490. }
  16491. injectProp(vnodeCall, keyProperty, context);
  16492. return ret;
  16493. }
  16494. }
  16495. function isSameKey(a, b) {
  16496. if (!a || a.type !== b.type) {
  16497. return false;
  16498. }
  16499. if (a.type === 6) {
  16500. if (a.value.content !== b.value.content) {
  16501. return false;
  16502. }
  16503. } else {
  16504. const exp = a.exp;
  16505. const branchExp = b.exp;
  16506. if (exp.type !== branchExp.type) {
  16507. return false;
  16508. }
  16509. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  16510. return false;
  16511. }
  16512. }
  16513. return true;
  16514. }
  16515. function getParentCondition(node) {
  16516. while (true) {
  16517. if (node.type === 19) {
  16518. if (node.alternate.type === 19) {
  16519. node = node.alternate;
  16520. } else {
  16521. return node;
  16522. }
  16523. } else if (node.type === 20) {
  16524. node = node.value;
  16525. }
  16526. }
  16527. }
  16528. const transformFor = createStructuralDirectiveTransform(
  16529. "for",
  16530. (node, dir, context) => {
  16531. const { helper, removeHelper } = context;
  16532. return processFor(node, dir, context, (forNode) => {
  16533. const renderExp = createCallExpression(helper(RENDER_LIST), [
  16534. forNode.source
  16535. ]);
  16536. const isTemplate = isTemplateNode(node);
  16537. const memo = findDir(node, "memo");
  16538. const keyProp = findProp(node, `key`, false, true);
  16539. keyProp && keyProp.type === 7;
  16540. let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
  16541. const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
  16542. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  16543. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  16544. forNode.codegenNode = createVNodeCall(
  16545. context,
  16546. helper(FRAGMENT),
  16547. void 0,
  16548. renderExp,
  16549. fragmentFlag,
  16550. void 0,
  16551. void 0,
  16552. true,
  16553. !isStableFragment,
  16554. false,
  16555. node.loc
  16556. );
  16557. return () => {
  16558. let childBlock;
  16559. const { children } = forNode;
  16560. if (isTemplate) {
  16561. node.children.some((c) => {
  16562. if (c.type === 1) {
  16563. const key = findProp(c, "key");
  16564. if (key) {
  16565. context.onError(
  16566. createCompilerError(
  16567. 33,
  16568. key.loc
  16569. )
  16570. );
  16571. return true;
  16572. }
  16573. }
  16574. });
  16575. }
  16576. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  16577. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  16578. if (slotOutlet) {
  16579. childBlock = slotOutlet.codegenNode;
  16580. if (isTemplate && keyProperty) {
  16581. injectProp(childBlock, keyProperty, context);
  16582. }
  16583. } else if (needFragmentWrapper) {
  16584. childBlock = createVNodeCall(
  16585. context,
  16586. helper(FRAGMENT),
  16587. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  16588. node.children,
  16589. 64,
  16590. void 0,
  16591. void 0,
  16592. true,
  16593. void 0,
  16594. false
  16595. );
  16596. } else {
  16597. childBlock = children[0].codegenNode;
  16598. if (isTemplate && keyProperty) {
  16599. injectProp(childBlock, keyProperty, context);
  16600. }
  16601. if (childBlock.isBlock !== !isStableFragment) {
  16602. if (childBlock.isBlock) {
  16603. removeHelper(OPEN_BLOCK);
  16604. removeHelper(
  16605. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  16606. );
  16607. } else {
  16608. removeHelper(
  16609. getVNodeHelper(context.inSSR, childBlock.isComponent)
  16610. );
  16611. }
  16612. }
  16613. childBlock.isBlock = !isStableFragment;
  16614. if (childBlock.isBlock) {
  16615. helper(OPEN_BLOCK);
  16616. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  16617. } else {
  16618. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  16619. }
  16620. }
  16621. if (memo) {
  16622. const loop = createFunctionExpression(
  16623. createForLoopParams(forNode.parseResult, [
  16624. createSimpleExpression(`_cached`)
  16625. ])
  16626. );
  16627. loop.body = createBlockStatement([
  16628. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  16629. createCompoundExpression([
  16630. `if (_cached && _cached.el`,
  16631. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  16632. ` && ${context.helperString(
  16633. IS_MEMO_SAME
  16634. )}(_cached, _memo)) return _cached`
  16635. ]),
  16636. createCompoundExpression([`const _item = `, childBlock]),
  16637. createSimpleExpression(`_item.memo = _memo`),
  16638. createSimpleExpression(`return _item`)
  16639. ]);
  16640. renderExp.arguments.push(
  16641. loop,
  16642. createSimpleExpression(`_cache`),
  16643. createSimpleExpression(String(context.cached.length))
  16644. );
  16645. context.cached.push(null);
  16646. } else {
  16647. renderExp.arguments.push(
  16648. createFunctionExpression(
  16649. createForLoopParams(forNode.parseResult),
  16650. childBlock,
  16651. true
  16652. )
  16653. );
  16654. }
  16655. };
  16656. });
  16657. }
  16658. );
  16659. function processFor(node, dir, context, processCodegen) {
  16660. if (!dir.exp) {
  16661. context.onError(
  16662. createCompilerError(31, dir.loc)
  16663. );
  16664. return;
  16665. }
  16666. const parseResult = dir.forParseResult;
  16667. if (!parseResult) {
  16668. context.onError(
  16669. createCompilerError(32, dir.loc)
  16670. );
  16671. return;
  16672. }
  16673. finalizeForParseResult(parseResult, context);
  16674. const { addIdentifiers, removeIdentifiers, scopes } = context;
  16675. const { source, value, key, index } = parseResult;
  16676. const forNode = {
  16677. type: 11,
  16678. loc: dir.loc,
  16679. source,
  16680. valueAlias: value,
  16681. keyAlias: key,
  16682. objectIndexAlias: index,
  16683. parseResult,
  16684. children: isTemplateNode(node) ? node.children : [node]
  16685. };
  16686. context.replaceNode(forNode);
  16687. scopes.vFor++;
  16688. const onExit = processCodegen && processCodegen(forNode);
  16689. return () => {
  16690. scopes.vFor--;
  16691. if (onExit) onExit();
  16692. };
  16693. }
  16694. function finalizeForParseResult(result, context) {
  16695. if (result.finalized) return;
  16696. {
  16697. validateBrowserExpression(result.source, context);
  16698. if (result.key) {
  16699. validateBrowserExpression(
  16700. result.key,
  16701. context,
  16702. true
  16703. );
  16704. }
  16705. if (result.index) {
  16706. validateBrowserExpression(
  16707. result.index,
  16708. context,
  16709. true
  16710. );
  16711. }
  16712. if (result.value) {
  16713. validateBrowserExpression(
  16714. result.value,
  16715. context,
  16716. true
  16717. );
  16718. }
  16719. }
  16720. result.finalized = true;
  16721. }
  16722. function createForLoopParams({ value, key, index }, memoArgs = []) {
  16723. return createParamsList([value, key, index, ...memoArgs]);
  16724. }
  16725. function createParamsList(args) {
  16726. let i = args.length;
  16727. while (i--) {
  16728. if (args[i]) break;
  16729. }
  16730. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  16731. }
  16732. const defaultFallback = createSimpleExpression(`undefined`, false);
  16733. const trackSlotScopes = (node, context) => {
  16734. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  16735. const vSlot = findDir(node, "slot");
  16736. if (vSlot) {
  16737. vSlot.exp;
  16738. context.scopes.vSlot++;
  16739. return () => {
  16740. context.scopes.vSlot--;
  16741. };
  16742. }
  16743. }
  16744. };
  16745. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  16746. props,
  16747. children,
  16748. false,
  16749. true,
  16750. children.length ? children[0].loc : loc
  16751. );
  16752. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  16753. context.helper(WITH_CTX);
  16754. const { children, loc } = node;
  16755. const slotsProperties = [];
  16756. const dynamicSlots = [];
  16757. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  16758. const onComponentSlot = findDir(node, "slot", true);
  16759. if (onComponentSlot) {
  16760. const { arg, exp } = onComponentSlot;
  16761. if (arg && !isStaticExp(arg)) {
  16762. hasDynamicSlots = true;
  16763. }
  16764. slotsProperties.push(
  16765. createObjectProperty(
  16766. arg || createSimpleExpression("default", true),
  16767. buildSlotFn(exp, void 0, children, loc)
  16768. )
  16769. );
  16770. }
  16771. let hasTemplateSlots = false;
  16772. let hasNamedDefaultSlot = false;
  16773. const implicitDefaultChildren = [];
  16774. const seenSlotNames = /* @__PURE__ */ new Set();
  16775. let conditionalBranchIndex = 0;
  16776. for (let i = 0; i < children.length; i++) {
  16777. const slotElement = children[i];
  16778. let slotDir;
  16779. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  16780. if (slotElement.type !== 3) {
  16781. implicitDefaultChildren.push(slotElement);
  16782. }
  16783. continue;
  16784. }
  16785. if (onComponentSlot) {
  16786. context.onError(
  16787. createCompilerError(37, slotDir.loc)
  16788. );
  16789. break;
  16790. }
  16791. hasTemplateSlots = true;
  16792. const { children: slotChildren, loc: slotLoc } = slotElement;
  16793. const {
  16794. arg: slotName = createSimpleExpression(`default`, true),
  16795. exp: slotProps,
  16796. loc: dirLoc
  16797. } = slotDir;
  16798. let staticSlotName;
  16799. if (isStaticExp(slotName)) {
  16800. staticSlotName = slotName ? slotName.content : `default`;
  16801. } else {
  16802. hasDynamicSlots = true;
  16803. }
  16804. const vFor = findDir(slotElement, "for");
  16805. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  16806. let vIf;
  16807. let vElse;
  16808. if (vIf = findDir(slotElement, "if")) {
  16809. hasDynamicSlots = true;
  16810. dynamicSlots.push(
  16811. createConditionalExpression(
  16812. vIf.exp,
  16813. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  16814. defaultFallback
  16815. )
  16816. );
  16817. } else if (vElse = findDir(
  16818. slotElement,
  16819. /^else(?:-if)?$/,
  16820. true
  16821. /* allowEmpty */
  16822. )) {
  16823. let j = i;
  16824. let prev;
  16825. while (j--) {
  16826. prev = children[j];
  16827. if (!isCommentOrWhitespace(prev)) {
  16828. break;
  16829. }
  16830. }
  16831. if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
  16832. let conditional = dynamicSlots[dynamicSlots.length - 1];
  16833. while (conditional.alternate.type === 19) {
  16834. conditional = conditional.alternate;
  16835. }
  16836. conditional.alternate = vElse.exp ? createConditionalExpression(
  16837. vElse.exp,
  16838. buildDynamicSlot(
  16839. slotName,
  16840. slotFunction,
  16841. conditionalBranchIndex++
  16842. ),
  16843. defaultFallback
  16844. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  16845. } else {
  16846. context.onError(
  16847. createCompilerError(30, vElse.loc)
  16848. );
  16849. }
  16850. } else if (vFor) {
  16851. hasDynamicSlots = true;
  16852. const parseResult = vFor.forParseResult;
  16853. if (parseResult) {
  16854. finalizeForParseResult(parseResult, context);
  16855. dynamicSlots.push(
  16856. createCallExpression(context.helper(RENDER_LIST), [
  16857. parseResult.source,
  16858. createFunctionExpression(
  16859. createForLoopParams(parseResult),
  16860. buildDynamicSlot(slotName, slotFunction),
  16861. true
  16862. )
  16863. ])
  16864. );
  16865. } else {
  16866. context.onError(
  16867. createCompilerError(
  16868. 32,
  16869. vFor.loc
  16870. )
  16871. );
  16872. }
  16873. } else {
  16874. if (staticSlotName) {
  16875. if (seenSlotNames.has(staticSlotName)) {
  16876. context.onError(
  16877. createCompilerError(
  16878. 38,
  16879. dirLoc
  16880. )
  16881. );
  16882. continue;
  16883. }
  16884. seenSlotNames.add(staticSlotName);
  16885. if (staticSlotName === "default") {
  16886. hasNamedDefaultSlot = true;
  16887. }
  16888. }
  16889. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  16890. }
  16891. }
  16892. if (!onComponentSlot) {
  16893. const buildDefaultSlotProperty = (props, children2) => {
  16894. const fn = buildSlotFn(props, void 0, children2, loc);
  16895. return createObjectProperty(`default`, fn);
  16896. };
  16897. if (!hasTemplateSlots) {
  16898. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  16899. } else if (implicitDefaultChildren.length && // #3766
  16900. // with whitespace: 'preserve', whitespaces between slots will end up in
  16901. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  16902. !implicitDefaultChildren.every(isWhitespaceText)) {
  16903. if (hasNamedDefaultSlot) {
  16904. context.onError(
  16905. createCompilerError(
  16906. 39,
  16907. implicitDefaultChildren[0].loc
  16908. )
  16909. );
  16910. } else {
  16911. slotsProperties.push(
  16912. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  16913. );
  16914. }
  16915. }
  16916. }
  16917. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  16918. let slots = createObjectExpression(
  16919. slotsProperties.concat(
  16920. createObjectProperty(
  16921. `_`,
  16922. // 2 = compiled but dynamic = can skip normalization, but must run diff
  16923. // 1 = compiled and static = can skip normalization AND diff as optimized
  16924. createSimpleExpression(
  16925. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  16926. false
  16927. )
  16928. )
  16929. ),
  16930. loc
  16931. );
  16932. if (dynamicSlots.length) {
  16933. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  16934. slots,
  16935. createArrayExpression(dynamicSlots)
  16936. ]);
  16937. }
  16938. return {
  16939. slots,
  16940. hasDynamicSlots
  16941. };
  16942. }
  16943. function buildDynamicSlot(name, fn, index) {
  16944. const props = [
  16945. createObjectProperty(`name`, name),
  16946. createObjectProperty(`fn`, fn)
  16947. ];
  16948. if (index != null) {
  16949. props.push(
  16950. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  16951. );
  16952. }
  16953. return createObjectExpression(props);
  16954. }
  16955. function hasForwardedSlots(children) {
  16956. for (let i = 0; i < children.length; i++) {
  16957. const child = children[i];
  16958. switch (child.type) {
  16959. case 1:
  16960. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  16961. return true;
  16962. }
  16963. break;
  16964. case 9:
  16965. if (hasForwardedSlots(child.branches)) return true;
  16966. break;
  16967. case 10:
  16968. case 11:
  16969. if (hasForwardedSlots(child.children)) return true;
  16970. break;
  16971. }
  16972. }
  16973. return false;
  16974. }
  16975. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  16976. const transformElement = (node, context) => {
  16977. return function postTransformElement() {
  16978. node = context.currentNode;
  16979. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  16980. return;
  16981. }
  16982. const { tag, props } = node;
  16983. const isComponent = node.tagType === 1;
  16984. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  16985. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  16986. let vnodeProps;
  16987. let vnodeChildren;
  16988. let patchFlag = 0;
  16989. let vnodeDynamicProps;
  16990. let dynamicPropNames;
  16991. let vnodeDirectives;
  16992. let shouldUseBlock = (
  16993. // dynamic component may resolve to plain elements
  16994. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  16995. // updates inside get proper isSVG flag at runtime. (#639, #643)
  16996. // This is technically web-specific, but splitting the logic out of core
  16997. // leads to too much unnecessary complexity.
  16998. (tag === "svg" || tag === "foreignObject" || tag === "math")
  16999. );
  17000. if (props.length > 0) {
  17001. const propsBuildResult = buildProps(
  17002. node,
  17003. context,
  17004. void 0,
  17005. isComponent,
  17006. isDynamicComponent
  17007. );
  17008. vnodeProps = propsBuildResult.props;
  17009. patchFlag = propsBuildResult.patchFlag;
  17010. dynamicPropNames = propsBuildResult.dynamicPropNames;
  17011. const directives = propsBuildResult.directives;
  17012. vnodeDirectives = directives && directives.length ? createArrayExpression(
  17013. directives.map((dir) => buildDirectiveArgs(dir, context))
  17014. ) : void 0;
  17015. if (propsBuildResult.shouldUseBlock) {
  17016. shouldUseBlock = true;
  17017. }
  17018. }
  17019. if (node.children.length > 0) {
  17020. if (vnodeTag === KEEP_ALIVE) {
  17021. shouldUseBlock = true;
  17022. patchFlag |= 1024;
  17023. if (node.children.length > 1) {
  17024. context.onError(
  17025. createCompilerError(47, {
  17026. start: node.children[0].loc.start,
  17027. end: node.children[node.children.length - 1].loc.end,
  17028. source: ""
  17029. })
  17030. );
  17031. }
  17032. }
  17033. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  17034. vnodeTag !== TELEPORT && // explained above.
  17035. vnodeTag !== KEEP_ALIVE;
  17036. if (shouldBuildAsSlots) {
  17037. const { slots, hasDynamicSlots } = buildSlots(node, context);
  17038. vnodeChildren = slots;
  17039. if (hasDynamicSlots) {
  17040. patchFlag |= 1024;
  17041. }
  17042. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  17043. const child = node.children[0];
  17044. const type = child.type;
  17045. const hasDynamicTextChild = type === 5 || type === 8;
  17046. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  17047. patchFlag |= 1;
  17048. }
  17049. if (hasDynamicTextChild || type === 2) {
  17050. vnodeChildren = child;
  17051. } else {
  17052. vnodeChildren = node.children;
  17053. }
  17054. } else {
  17055. vnodeChildren = node.children;
  17056. }
  17057. }
  17058. if (dynamicPropNames && dynamicPropNames.length) {
  17059. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  17060. }
  17061. node.codegenNode = createVNodeCall(
  17062. context,
  17063. vnodeTag,
  17064. vnodeProps,
  17065. vnodeChildren,
  17066. patchFlag === 0 ? void 0 : patchFlag,
  17067. vnodeDynamicProps,
  17068. vnodeDirectives,
  17069. !!shouldUseBlock,
  17070. false,
  17071. isComponent,
  17072. node.loc
  17073. );
  17074. };
  17075. };
  17076. function resolveComponentType(node, context, ssr = false) {
  17077. let { tag } = node;
  17078. const isExplicitDynamic = isComponentTag(tag);
  17079. const isProp = findProp(
  17080. node,
  17081. "is",
  17082. false,
  17083. true
  17084. /* allow empty */
  17085. );
  17086. if (isProp) {
  17087. if (isExplicitDynamic || false) {
  17088. let exp;
  17089. if (isProp.type === 6) {
  17090. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  17091. } else {
  17092. exp = isProp.exp;
  17093. if (!exp) {
  17094. exp = createSimpleExpression(`is`, false, isProp.arg.loc);
  17095. }
  17096. }
  17097. if (exp) {
  17098. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  17099. exp
  17100. ]);
  17101. }
  17102. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  17103. tag = isProp.value.content.slice(4);
  17104. }
  17105. }
  17106. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  17107. if (builtIn) {
  17108. if (!ssr) context.helper(builtIn);
  17109. return builtIn;
  17110. }
  17111. context.helper(RESOLVE_COMPONENT);
  17112. context.components.add(tag);
  17113. return toValidAssetId(tag, `component`);
  17114. }
  17115. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  17116. const { tag, loc: elementLoc, children } = node;
  17117. let properties = [];
  17118. const mergeArgs = [];
  17119. const runtimeDirectives = [];
  17120. const hasChildren = children.length > 0;
  17121. let shouldUseBlock = false;
  17122. let patchFlag = 0;
  17123. let hasRef = false;
  17124. let hasClassBinding = false;
  17125. let hasStyleBinding = false;
  17126. let hasHydrationEventBinding = false;
  17127. let hasDynamicKeys = false;
  17128. let hasVnodeHook = false;
  17129. const dynamicPropNames = [];
  17130. const pushMergeArg = (arg) => {
  17131. if (properties.length) {
  17132. mergeArgs.push(
  17133. createObjectExpression(dedupeProperties(properties), elementLoc)
  17134. );
  17135. properties = [];
  17136. }
  17137. if (arg) mergeArgs.push(arg);
  17138. };
  17139. const pushRefVForMarker = () => {
  17140. if (context.scopes.vFor > 0) {
  17141. properties.push(
  17142. createObjectProperty(
  17143. createSimpleExpression("ref_for", true),
  17144. createSimpleExpression("true")
  17145. )
  17146. );
  17147. }
  17148. };
  17149. const analyzePatchFlag = ({ key, value }) => {
  17150. if (isStaticExp(key)) {
  17151. const name = key.content;
  17152. const isEventHandler = isOn(name);
  17153. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  17154. // dedicated fast path.
  17155. name.toLowerCase() !== "onclick" && // omit v-model handlers
  17156. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  17157. !isReservedProp(name)) {
  17158. hasHydrationEventBinding = true;
  17159. }
  17160. if (isEventHandler && isReservedProp(name)) {
  17161. hasVnodeHook = true;
  17162. }
  17163. if (isEventHandler && value.type === 14) {
  17164. value = value.arguments[0];
  17165. }
  17166. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  17167. return;
  17168. }
  17169. if (name === "ref") {
  17170. hasRef = true;
  17171. } else if (name === "class") {
  17172. hasClassBinding = true;
  17173. } else if (name === "style") {
  17174. hasStyleBinding = true;
  17175. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  17176. dynamicPropNames.push(name);
  17177. }
  17178. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  17179. dynamicPropNames.push(name);
  17180. }
  17181. } else {
  17182. hasDynamicKeys = true;
  17183. }
  17184. };
  17185. for (let i = 0; i < props.length; i++) {
  17186. const prop = props[i];
  17187. if (prop.type === 6) {
  17188. const { loc, name, nameLoc, value } = prop;
  17189. let isStatic = true;
  17190. if (name === "ref") {
  17191. hasRef = true;
  17192. pushRefVForMarker();
  17193. }
  17194. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  17195. continue;
  17196. }
  17197. properties.push(
  17198. createObjectProperty(
  17199. createSimpleExpression(name, true, nameLoc),
  17200. createSimpleExpression(
  17201. value ? value.content : "",
  17202. isStatic,
  17203. value ? value.loc : loc
  17204. )
  17205. )
  17206. );
  17207. } else {
  17208. const { name, arg, exp, loc, modifiers } = prop;
  17209. const isVBind = name === "bind";
  17210. const isVOn = name === "on";
  17211. if (name === "slot") {
  17212. if (!isComponent) {
  17213. context.onError(
  17214. createCompilerError(40, loc)
  17215. );
  17216. }
  17217. continue;
  17218. }
  17219. if (name === "once" || name === "memo") {
  17220. continue;
  17221. }
  17222. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  17223. continue;
  17224. }
  17225. if (isVOn && ssr) {
  17226. continue;
  17227. }
  17228. if (
  17229. // #938: elements with dynamic keys should be forced into blocks
  17230. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  17231. // before children
  17232. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  17233. ) {
  17234. shouldUseBlock = true;
  17235. }
  17236. if (isVBind && isStaticArgOf(arg, "ref")) {
  17237. pushRefVForMarker();
  17238. }
  17239. if (!arg && (isVBind || isVOn)) {
  17240. hasDynamicKeys = true;
  17241. if (exp) {
  17242. if (isVBind) {
  17243. pushRefVForMarker();
  17244. pushMergeArg();
  17245. mergeArgs.push(exp);
  17246. } else {
  17247. pushMergeArg({
  17248. type: 14,
  17249. loc,
  17250. callee: context.helper(TO_HANDLERS),
  17251. arguments: isComponent ? [exp] : [exp, `true`]
  17252. });
  17253. }
  17254. } else {
  17255. context.onError(
  17256. createCompilerError(
  17257. isVBind ? 34 : 35,
  17258. loc
  17259. )
  17260. );
  17261. }
  17262. continue;
  17263. }
  17264. if (isVBind && modifiers.some((mod) => mod.content === "prop")) {
  17265. patchFlag |= 32;
  17266. }
  17267. const directiveTransform = context.directiveTransforms[name];
  17268. if (directiveTransform) {
  17269. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  17270. !ssr && props2.forEach(analyzePatchFlag);
  17271. if (isVOn && arg && !isStaticExp(arg)) {
  17272. pushMergeArg(createObjectExpression(props2, elementLoc));
  17273. } else {
  17274. properties.push(...props2);
  17275. }
  17276. if (needRuntime) {
  17277. runtimeDirectives.push(prop);
  17278. if (isSymbol(needRuntime)) {
  17279. directiveImportMap.set(prop, needRuntime);
  17280. }
  17281. }
  17282. } else if (!isBuiltInDirective(name)) {
  17283. runtimeDirectives.push(prop);
  17284. if (hasChildren) {
  17285. shouldUseBlock = true;
  17286. }
  17287. }
  17288. }
  17289. }
  17290. let propsExpression = void 0;
  17291. if (mergeArgs.length) {
  17292. pushMergeArg();
  17293. if (mergeArgs.length > 1) {
  17294. propsExpression = createCallExpression(
  17295. context.helper(MERGE_PROPS),
  17296. mergeArgs,
  17297. elementLoc
  17298. );
  17299. } else {
  17300. propsExpression = mergeArgs[0];
  17301. }
  17302. } else if (properties.length) {
  17303. propsExpression = createObjectExpression(
  17304. dedupeProperties(properties),
  17305. elementLoc
  17306. );
  17307. }
  17308. if (hasDynamicKeys) {
  17309. patchFlag |= 16;
  17310. } else {
  17311. if (hasClassBinding && !isComponent) {
  17312. patchFlag |= 2;
  17313. }
  17314. if (hasStyleBinding && !isComponent) {
  17315. patchFlag |= 4;
  17316. }
  17317. if (dynamicPropNames.length) {
  17318. patchFlag |= 8;
  17319. }
  17320. if (hasHydrationEventBinding) {
  17321. patchFlag |= 32;
  17322. }
  17323. }
  17324. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  17325. patchFlag |= 512;
  17326. }
  17327. if (!context.inSSR && propsExpression) {
  17328. switch (propsExpression.type) {
  17329. case 15:
  17330. let classKeyIndex = -1;
  17331. let styleKeyIndex = -1;
  17332. let hasDynamicKey = false;
  17333. for (let i = 0; i < propsExpression.properties.length; i++) {
  17334. const key = propsExpression.properties[i].key;
  17335. if (isStaticExp(key)) {
  17336. if (key.content === "class") {
  17337. classKeyIndex = i;
  17338. } else if (key.content === "style") {
  17339. styleKeyIndex = i;
  17340. }
  17341. } else if (!key.isHandlerKey) {
  17342. hasDynamicKey = true;
  17343. }
  17344. }
  17345. const classProp = propsExpression.properties[classKeyIndex];
  17346. const styleProp = propsExpression.properties[styleKeyIndex];
  17347. if (!hasDynamicKey) {
  17348. if (classProp && !isStaticExp(classProp.value)) {
  17349. classProp.value = createCallExpression(
  17350. context.helper(NORMALIZE_CLASS),
  17351. [classProp.value]
  17352. );
  17353. }
  17354. if (styleProp && // the static style is compiled into an object,
  17355. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  17356. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  17357. // v-bind:style with static literal object
  17358. styleProp.value.type === 17)) {
  17359. styleProp.value = createCallExpression(
  17360. context.helper(NORMALIZE_STYLE),
  17361. [styleProp.value]
  17362. );
  17363. }
  17364. } else {
  17365. propsExpression = createCallExpression(
  17366. context.helper(NORMALIZE_PROPS),
  17367. [propsExpression]
  17368. );
  17369. }
  17370. break;
  17371. case 14:
  17372. break;
  17373. default:
  17374. propsExpression = createCallExpression(
  17375. context.helper(NORMALIZE_PROPS),
  17376. [
  17377. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  17378. propsExpression
  17379. ])
  17380. ]
  17381. );
  17382. break;
  17383. }
  17384. }
  17385. return {
  17386. props: propsExpression,
  17387. directives: runtimeDirectives,
  17388. patchFlag,
  17389. dynamicPropNames,
  17390. shouldUseBlock
  17391. };
  17392. }
  17393. function dedupeProperties(properties) {
  17394. const knownProps = /* @__PURE__ */ new Map();
  17395. const deduped = [];
  17396. for (let i = 0; i < properties.length; i++) {
  17397. const prop = properties[i];
  17398. if (prop.key.type === 8 || !prop.key.isStatic) {
  17399. deduped.push(prop);
  17400. continue;
  17401. }
  17402. const name = prop.key.content;
  17403. const existing = knownProps.get(name);
  17404. if (existing) {
  17405. if (name === "style" || name === "class" || isOn(name)) {
  17406. mergeAsArray(existing, prop);
  17407. }
  17408. } else {
  17409. knownProps.set(name, prop);
  17410. deduped.push(prop);
  17411. }
  17412. }
  17413. return deduped;
  17414. }
  17415. function mergeAsArray(existing, incoming) {
  17416. if (existing.value.type === 17) {
  17417. existing.value.elements.push(incoming.value);
  17418. } else {
  17419. existing.value = createArrayExpression(
  17420. [existing.value, incoming.value],
  17421. existing.loc
  17422. );
  17423. }
  17424. }
  17425. function buildDirectiveArgs(dir, context) {
  17426. const dirArgs = [];
  17427. const runtime = directiveImportMap.get(dir);
  17428. if (runtime) {
  17429. dirArgs.push(context.helperString(runtime));
  17430. } else {
  17431. {
  17432. context.helper(RESOLVE_DIRECTIVE);
  17433. context.directives.add(dir.name);
  17434. dirArgs.push(toValidAssetId(dir.name, `directive`));
  17435. }
  17436. }
  17437. const { loc } = dir;
  17438. if (dir.exp) dirArgs.push(dir.exp);
  17439. if (dir.arg) {
  17440. if (!dir.exp) {
  17441. dirArgs.push(`void 0`);
  17442. }
  17443. dirArgs.push(dir.arg);
  17444. }
  17445. if (Object.keys(dir.modifiers).length) {
  17446. if (!dir.arg) {
  17447. if (!dir.exp) {
  17448. dirArgs.push(`void 0`);
  17449. }
  17450. dirArgs.push(`void 0`);
  17451. }
  17452. const trueExpression = createSimpleExpression(`true`, false, loc);
  17453. dirArgs.push(
  17454. createObjectExpression(
  17455. dir.modifiers.map(
  17456. (modifier) => createObjectProperty(modifier, trueExpression)
  17457. ),
  17458. loc
  17459. )
  17460. );
  17461. }
  17462. return createArrayExpression(dirArgs, dir.loc);
  17463. }
  17464. function stringifyDynamicPropNames(props) {
  17465. let propsNamesString = `[`;
  17466. for (let i = 0, l = props.length; i < l; i++) {
  17467. propsNamesString += JSON.stringify(props[i]);
  17468. if (i < l - 1) propsNamesString += ", ";
  17469. }
  17470. return propsNamesString + `]`;
  17471. }
  17472. function isComponentTag(tag) {
  17473. return tag === "component" || tag === "Component";
  17474. }
  17475. const transformSlotOutlet = (node, context) => {
  17476. if (isSlotOutlet(node)) {
  17477. const { children, loc } = node;
  17478. const { slotName, slotProps } = processSlotOutlet(node, context);
  17479. const slotArgs = [
  17480. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  17481. slotName,
  17482. "{}",
  17483. "undefined",
  17484. "true"
  17485. ];
  17486. let expectedLen = 2;
  17487. if (slotProps) {
  17488. slotArgs[2] = slotProps;
  17489. expectedLen = 3;
  17490. }
  17491. if (children.length) {
  17492. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  17493. expectedLen = 4;
  17494. }
  17495. if (context.scopeId && !context.slotted) {
  17496. expectedLen = 5;
  17497. }
  17498. slotArgs.splice(expectedLen);
  17499. node.codegenNode = createCallExpression(
  17500. context.helper(RENDER_SLOT),
  17501. slotArgs,
  17502. loc
  17503. );
  17504. }
  17505. };
  17506. function processSlotOutlet(node, context) {
  17507. let slotName = `"default"`;
  17508. let slotProps = void 0;
  17509. const nonNameProps = [];
  17510. for (let i = 0; i < node.props.length; i++) {
  17511. const p = node.props[i];
  17512. if (p.type === 6) {
  17513. if (p.value) {
  17514. if (p.name === "name") {
  17515. slotName = JSON.stringify(p.value.content);
  17516. } else {
  17517. p.name = camelize(p.name);
  17518. nonNameProps.push(p);
  17519. }
  17520. }
  17521. } else {
  17522. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  17523. if (p.exp) {
  17524. slotName = p.exp;
  17525. } else if (p.arg && p.arg.type === 4) {
  17526. const name = camelize(p.arg.content);
  17527. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  17528. }
  17529. } else {
  17530. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  17531. p.arg.content = camelize(p.arg.content);
  17532. }
  17533. nonNameProps.push(p);
  17534. }
  17535. }
  17536. }
  17537. if (nonNameProps.length > 0) {
  17538. const { props, directives } = buildProps(
  17539. node,
  17540. context,
  17541. nonNameProps,
  17542. false,
  17543. false
  17544. );
  17545. slotProps = props;
  17546. if (directives.length) {
  17547. context.onError(
  17548. createCompilerError(
  17549. 36,
  17550. directives[0].loc
  17551. )
  17552. );
  17553. }
  17554. }
  17555. return {
  17556. slotName,
  17557. slotProps
  17558. };
  17559. }
  17560. const transformOn$1 = (dir, node, context, augmentor) => {
  17561. const { loc, modifiers, arg } = dir;
  17562. if (!dir.exp && !modifiers.length) {
  17563. context.onError(createCompilerError(35, loc));
  17564. }
  17565. let eventName;
  17566. if (arg.type === 4) {
  17567. if (arg.isStatic) {
  17568. let rawName = arg.content;
  17569. if (rawName.startsWith("vnode")) {
  17570. context.onError(createCompilerError(52, arg.loc));
  17571. }
  17572. if (rawName.startsWith("vue:")) {
  17573. rawName = `vnode-${rawName.slice(4)}`;
  17574. }
  17575. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  17576. // for non-element and vnode lifecycle event listeners, auto convert
  17577. // it to camelCase. See issue #2249
  17578. toHandlerKey(camelize(rawName))
  17579. ) : (
  17580. // preserve case for plain element listeners that have uppercase
  17581. // letters, as these may be custom elements' custom events
  17582. `on:${rawName}`
  17583. );
  17584. eventName = createSimpleExpression(eventString, true, arg.loc);
  17585. } else {
  17586. eventName = createCompoundExpression([
  17587. `${context.helperString(TO_HANDLER_KEY)}(`,
  17588. arg,
  17589. `)`
  17590. ]);
  17591. }
  17592. } else {
  17593. eventName = arg;
  17594. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  17595. eventName.children.push(`)`);
  17596. }
  17597. let exp = dir.exp;
  17598. if (exp && !exp.content.trim()) {
  17599. exp = void 0;
  17600. }
  17601. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  17602. if (exp) {
  17603. const isMemberExp = isMemberExpression(exp);
  17604. const isInlineStatement = !(isMemberExp || isFnExpression(exp));
  17605. const hasMultipleStatements = exp.content.includes(`;`);
  17606. {
  17607. validateBrowserExpression(
  17608. exp,
  17609. context,
  17610. false,
  17611. hasMultipleStatements
  17612. );
  17613. }
  17614. if (isInlineStatement || shouldCache && isMemberExp) {
  17615. exp = createCompoundExpression([
  17616. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  17617. exp,
  17618. hasMultipleStatements ? `}` : `)`
  17619. ]);
  17620. }
  17621. }
  17622. let ret = {
  17623. props: [
  17624. createObjectProperty(
  17625. eventName,
  17626. exp || createSimpleExpression(`() => {}`, false, loc)
  17627. )
  17628. ]
  17629. };
  17630. if (augmentor) {
  17631. ret = augmentor(ret);
  17632. }
  17633. if (shouldCache) {
  17634. ret.props[0].value = context.cache(ret.props[0].value);
  17635. }
  17636. ret.props.forEach((p) => p.key.isHandlerKey = true);
  17637. return ret;
  17638. };
  17639. const transformBind = (dir, _node, context) => {
  17640. const { modifiers, loc } = dir;
  17641. const arg = dir.arg;
  17642. let { exp } = dir;
  17643. if (exp && exp.type === 4 && !exp.content.trim()) {
  17644. {
  17645. exp = void 0;
  17646. }
  17647. }
  17648. if (arg.type !== 4) {
  17649. arg.children.unshift(`(`);
  17650. arg.children.push(`) || ""`);
  17651. } else if (!arg.isStatic) {
  17652. arg.content = arg.content ? `${arg.content} || ""` : `""`;
  17653. }
  17654. if (modifiers.some((mod) => mod.content === "camel")) {
  17655. if (arg.type === 4) {
  17656. if (arg.isStatic) {
  17657. arg.content = camelize(arg.content);
  17658. } else {
  17659. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  17660. }
  17661. } else {
  17662. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  17663. arg.children.push(`)`);
  17664. }
  17665. }
  17666. if (!context.inSSR) {
  17667. if (modifiers.some((mod) => mod.content === "prop")) {
  17668. injectPrefix(arg, ".");
  17669. }
  17670. if (modifiers.some((mod) => mod.content === "attr")) {
  17671. injectPrefix(arg, "^");
  17672. }
  17673. }
  17674. return {
  17675. props: [createObjectProperty(arg, exp)]
  17676. };
  17677. };
  17678. const injectPrefix = (arg, prefix) => {
  17679. if (arg.type === 4) {
  17680. if (arg.isStatic) {
  17681. arg.content = prefix + arg.content;
  17682. } else {
  17683. arg.content = `\`${prefix}\${${arg.content}}\``;
  17684. }
  17685. } else {
  17686. arg.children.unshift(`'${prefix}' + (`);
  17687. arg.children.push(`)`);
  17688. }
  17689. };
  17690. const transformText = (node, context) => {
  17691. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  17692. return () => {
  17693. const children = node.children;
  17694. let currentContainer = void 0;
  17695. let hasText = false;
  17696. for (let i = 0; i < children.length; i++) {
  17697. const child = children[i];
  17698. if (isText$1(child)) {
  17699. hasText = true;
  17700. for (let j = i + 1; j < children.length; j++) {
  17701. const next = children[j];
  17702. if (isText$1(next)) {
  17703. if (!currentContainer) {
  17704. currentContainer = children[i] = createCompoundExpression(
  17705. [child],
  17706. child.loc
  17707. );
  17708. }
  17709. currentContainer.children.push(` + `, next);
  17710. children.splice(j, 1);
  17711. j--;
  17712. } else {
  17713. currentContainer = void 0;
  17714. break;
  17715. }
  17716. }
  17717. }
  17718. }
  17719. if (!hasText || // if this is a plain element with a single text child, leave it
  17720. // as-is since the runtime has dedicated fast path for this by directly
  17721. // setting textContent of the element.
  17722. // for component root it's always normalized anyway.
  17723. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  17724. // custom directives can potentially add DOM elements arbitrarily,
  17725. // we need to avoid setting textContent of the element at runtime
  17726. // to avoid accidentally overwriting the DOM elements added
  17727. // by the user through custom directives.
  17728. !node.props.find(
  17729. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  17730. ) && // in compat mode, <template> tags with no special directives
  17731. // will be rendered as a fragment so its children must be
  17732. // converted into vnodes.
  17733. true)) {
  17734. return;
  17735. }
  17736. for (let i = 0; i < children.length; i++) {
  17737. const child = children[i];
  17738. if (isText$1(child) || child.type === 8) {
  17739. const callArgs = [];
  17740. if (child.type !== 2 || child.content !== " ") {
  17741. callArgs.push(child);
  17742. }
  17743. if (!context.ssr && getConstantType(child, context) === 0) {
  17744. callArgs.push(
  17745. 1 + (` /* ${PatchFlagNames[1]} */` )
  17746. );
  17747. }
  17748. children[i] = {
  17749. type: 12,
  17750. content: child,
  17751. loc: child.loc,
  17752. codegenNode: createCallExpression(
  17753. context.helper(CREATE_TEXT),
  17754. callArgs
  17755. )
  17756. };
  17757. }
  17758. }
  17759. };
  17760. }
  17761. };
  17762. const seen$1 = /* @__PURE__ */ new WeakSet();
  17763. const transformOnce = (node, context) => {
  17764. if (node.type === 1 && findDir(node, "once", true)) {
  17765. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  17766. return;
  17767. }
  17768. seen$1.add(node);
  17769. context.inVOnce = true;
  17770. context.helper(SET_BLOCK_TRACKING);
  17771. return () => {
  17772. context.inVOnce = false;
  17773. const cur = context.currentNode;
  17774. if (cur.codegenNode) {
  17775. cur.codegenNode = context.cache(
  17776. cur.codegenNode,
  17777. true,
  17778. true
  17779. );
  17780. }
  17781. };
  17782. }
  17783. };
  17784. const transformModel$1 = (dir, node, context) => {
  17785. const { exp, arg } = dir;
  17786. if (!exp) {
  17787. context.onError(
  17788. createCompilerError(41, dir.loc)
  17789. );
  17790. return createTransformProps();
  17791. }
  17792. const rawExp = exp.loc.source.trim();
  17793. const expString = exp.type === 4 ? exp.content : rawExp;
  17794. const bindingType = context.bindingMetadata[rawExp];
  17795. if (bindingType === "props" || bindingType === "props-aliased") {
  17796. context.onError(createCompilerError(44, exp.loc));
  17797. return createTransformProps();
  17798. }
  17799. if (bindingType === "literal-const" || bindingType === "setup-const") {
  17800. context.onError(createCompilerError(45, exp.loc));
  17801. return createTransformProps();
  17802. }
  17803. if (!expString.trim() || !isMemberExpression(exp) && true) {
  17804. context.onError(
  17805. createCompilerError(42, exp.loc)
  17806. );
  17807. return createTransformProps();
  17808. }
  17809. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  17810. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  17811. let assignmentExp;
  17812. const eventArg = context.isTS ? `($event: any)` : `$event`;
  17813. {
  17814. assignmentExp = createCompoundExpression([
  17815. `${eventArg} => ((`,
  17816. exp,
  17817. `) = $event)`
  17818. ]);
  17819. }
  17820. const props = [
  17821. // modelValue: foo
  17822. createObjectProperty(propName, dir.exp),
  17823. // "onUpdate:modelValue": $event => (foo = $event)
  17824. createObjectProperty(eventName, assignmentExp)
  17825. ];
  17826. if (dir.modifiers.length && node.tagType === 1) {
  17827. const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  17828. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  17829. props.push(
  17830. createObjectProperty(
  17831. modifiersKey,
  17832. createSimpleExpression(
  17833. `{ ${modifiers} }`,
  17834. false,
  17835. dir.loc,
  17836. 2
  17837. )
  17838. )
  17839. );
  17840. }
  17841. return createTransformProps(props);
  17842. };
  17843. function createTransformProps(props = []) {
  17844. return { props };
  17845. }
  17846. const seen = /* @__PURE__ */ new WeakSet();
  17847. const transformMemo = (node, context) => {
  17848. if (node.type === 1) {
  17849. const dir = findDir(node, "memo");
  17850. if (!dir || seen.has(node) || context.inSSR) {
  17851. return;
  17852. }
  17853. seen.add(node);
  17854. return () => {
  17855. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  17856. if (codegenNode && codegenNode.type === 13) {
  17857. if (node.tagType !== 1) {
  17858. convertToBlock(codegenNode, context);
  17859. }
  17860. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  17861. dir.exp,
  17862. createFunctionExpression(void 0, codegenNode),
  17863. `_cache`,
  17864. String(context.cached.length)
  17865. ]);
  17866. context.cached.push(null);
  17867. }
  17868. };
  17869. }
  17870. };
  17871. const transformVBindShorthand = (node, context) => {
  17872. if (node.type === 1) {
  17873. for (const prop of node.props) {
  17874. if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
  17875. prop.exp.type === 4 && !prop.exp.content.trim()) && prop.arg) {
  17876. const arg = prop.arg;
  17877. if (arg.type !== 4 || !arg.isStatic) {
  17878. context.onError(
  17879. createCompilerError(
  17880. 53,
  17881. arg.loc
  17882. )
  17883. );
  17884. prop.exp = createSimpleExpression("", true, arg.loc);
  17885. } else {
  17886. const propName = camelize(arg.content);
  17887. if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
  17888. propName[0] === "-") {
  17889. prop.exp = createSimpleExpression(propName, false, arg.loc);
  17890. }
  17891. }
  17892. }
  17893. }
  17894. }
  17895. };
  17896. function getBaseTransformPreset(prefixIdentifiers) {
  17897. return [
  17898. [
  17899. transformVBindShorthand,
  17900. transformOnce,
  17901. transformIf,
  17902. transformMemo,
  17903. transformFor,
  17904. ...[],
  17905. ...[transformExpression] ,
  17906. transformSlotOutlet,
  17907. transformElement,
  17908. trackSlotScopes,
  17909. transformText
  17910. ],
  17911. {
  17912. on: transformOn$1,
  17913. bind: transformBind,
  17914. model: transformModel$1
  17915. }
  17916. ];
  17917. }
  17918. function baseCompile(source, options = {}) {
  17919. const onError = options.onError || defaultOnError;
  17920. const isModuleMode = options.mode === "module";
  17921. {
  17922. if (options.prefixIdentifiers === true) {
  17923. onError(createCompilerError(48));
  17924. } else if (isModuleMode) {
  17925. onError(createCompilerError(49));
  17926. }
  17927. }
  17928. const prefixIdentifiers = false;
  17929. if (options.cacheHandlers) {
  17930. onError(createCompilerError(50));
  17931. }
  17932. if (options.scopeId && !isModuleMode) {
  17933. onError(createCompilerError(51));
  17934. }
  17935. const resolvedOptions = extend({}, options, {
  17936. prefixIdentifiers
  17937. });
  17938. const ast = isString(source) ? baseParse(source, resolvedOptions) : source;
  17939. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  17940. transform(
  17941. ast,
  17942. extend({}, resolvedOptions, {
  17943. nodeTransforms: [
  17944. ...nodeTransforms,
  17945. ...options.nodeTransforms || []
  17946. // user transforms
  17947. ],
  17948. directiveTransforms: extend(
  17949. {},
  17950. directiveTransforms,
  17951. options.directiveTransforms || {}
  17952. // user transforms
  17953. )
  17954. })
  17955. );
  17956. return generate(ast, resolvedOptions);
  17957. }
  17958. const noopDirectiveTransform = () => ({ props: [] });
  17959. const V_MODEL_RADIO = /* @__PURE__ */ Symbol(`vModelRadio` );
  17960. const V_MODEL_CHECKBOX = /* @__PURE__ */ Symbol(
  17961. `vModelCheckbox`
  17962. );
  17963. const V_MODEL_TEXT = /* @__PURE__ */ Symbol(`vModelText` );
  17964. const V_MODEL_SELECT = /* @__PURE__ */ Symbol(
  17965. `vModelSelect`
  17966. );
  17967. const V_MODEL_DYNAMIC = /* @__PURE__ */ Symbol(
  17968. `vModelDynamic`
  17969. );
  17970. const V_ON_WITH_MODIFIERS = /* @__PURE__ */ Symbol(
  17971. `vOnModifiersGuard`
  17972. );
  17973. const V_ON_WITH_KEYS = /* @__PURE__ */ Symbol(
  17974. `vOnKeysGuard`
  17975. );
  17976. const V_SHOW = /* @__PURE__ */ Symbol(`vShow` );
  17977. const TRANSITION = /* @__PURE__ */ Symbol(`Transition` );
  17978. const TRANSITION_GROUP = /* @__PURE__ */ Symbol(
  17979. `TransitionGroup`
  17980. );
  17981. registerRuntimeHelpers({
  17982. [V_MODEL_RADIO]: `vModelRadio`,
  17983. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  17984. [V_MODEL_TEXT]: `vModelText`,
  17985. [V_MODEL_SELECT]: `vModelSelect`,
  17986. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  17987. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  17988. [V_ON_WITH_KEYS]: `withKeys`,
  17989. [V_SHOW]: `vShow`,
  17990. [TRANSITION]: `Transition`,
  17991. [TRANSITION_GROUP]: `TransitionGroup`
  17992. });
  17993. let decoder;
  17994. function decodeHtmlBrowser(raw, asAttr = false) {
  17995. if (!decoder) {
  17996. decoder = document.createElement("div");
  17997. }
  17998. if (asAttr) {
  17999. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  18000. return decoder.children[0].getAttribute("foo");
  18001. } else {
  18002. decoder.innerHTML = raw;
  18003. return decoder.textContent;
  18004. }
  18005. }
  18006. const parserOptions = {
  18007. parseMode: "html",
  18008. isVoidTag,
  18009. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  18010. isPreTag: (tag) => tag === "pre",
  18011. isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
  18012. decodeEntities: decodeHtmlBrowser ,
  18013. isBuiltInComponent: (tag) => {
  18014. if (tag === "Transition" || tag === "transition") {
  18015. return TRANSITION;
  18016. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  18017. return TRANSITION_GROUP;
  18018. }
  18019. },
  18020. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  18021. getNamespace(tag, parent, rootNamespace) {
  18022. let ns = parent ? parent.ns : rootNamespace;
  18023. if (parent && ns === 2) {
  18024. if (parent.tag === "annotation-xml") {
  18025. if (tag === "svg") {
  18026. return 1;
  18027. }
  18028. if (parent.props.some(
  18029. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  18030. )) {
  18031. ns = 0;
  18032. }
  18033. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  18034. ns = 0;
  18035. }
  18036. } else if (parent && ns === 1) {
  18037. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  18038. ns = 0;
  18039. }
  18040. }
  18041. if (ns === 0) {
  18042. if (tag === "svg") {
  18043. return 1;
  18044. }
  18045. if (tag === "math") {
  18046. return 2;
  18047. }
  18048. }
  18049. return ns;
  18050. }
  18051. };
  18052. const transformStyle = (node) => {
  18053. if (node.type === 1) {
  18054. node.props.forEach((p, i) => {
  18055. if (p.type === 6 && p.name === "style" && p.value) {
  18056. node.props[i] = {
  18057. type: 7,
  18058. name: `bind`,
  18059. arg: createSimpleExpression(`style`, true, p.loc),
  18060. exp: parseInlineCSS(p.value.content, p.loc),
  18061. modifiers: [],
  18062. loc: p.loc
  18063. };
  18064. }
  18065. });
  18066. }
  18067. };
  18068. const parseInlineCSS = (cssText, loc) => {
  18069. const normalized = parseStringStyle(cssText);
  18070. return createSimpleExpression(
  18071. JSON.stringify(normalized),
  18072. false,
  18073. loc,
  18074. 3
  18075. );
  18076. };
  18077. function createDOMCompilerError(code, loc) {
  18078. return createCompilerError(
  18079. code,
  18080. loc,
  18081. DOMErrorMessages
  18082. );
  18083. }
  18084. const DOMErrorMessages = {
  18085. [54]: `v-html is missing expression.`,
  18086. [55]: `v-html will override element children.`,
  18087. [56]: `v-text is missing expression.`,
  18088. [57]: `v-text will override element children.`,
  18089. [58]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  18090. [59]: `v-model argument is not supported on plain elements.`,
  18091. [60]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  18092. [61]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  18093. [62]: `v-show is missing expression.`,
  18094. [63]: `<Transition> expects exactly one child element or component.`,
  18095. [64]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  18096. };
  18097. const transformVHtml = (dir, node, context) => {
  18098. const { exp, loc } = dir;
  18099. if (!exp) {
  18100. context.onError(
  18101. createDOMCompilerError(54, loc)
  18102. );
  18103. }
  18104. if (node.children.length) {
  18105. context.onError(
  18106. createDOMCompilerError(55, loc)
  18107. );
  18108. node.children.length = 0;
  18109. }
  18110. return {
  18111. props: [
  18112. createObjectProperty(
  18113. createSimpleExpression(`innerHTML`, true, loc),
  18114. exp || createSimpleExpression("", true)
  18115. )
  18116. ]
  18117. };
  18118. };
  18119. const transformVText = (dir, node, context) => {
  18120. const { exp, loc } = dir;
  18121. if (!exp) {
  18122. context.onError(
  18123. createDOMCompilerError(56, loc)
  18124. );
  18125. }
  18126. if (node.children.length) {
  18127. context.onError(
  18128. createDOMCompilerError(57, loc)
  18129. );
  18130. node.children.length = 0;
  18131. }
  18132. return {
  18133. props: [
  18134. createObjectProperty(
  18135. createSimpleExpression(`textContent`, true),
  18136. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  18137. context.helperString(TO_DISPLAY_STRING),
  18138. [exp],
  18139. loc
  18140. ) : createSimpleExpression("", true)
  18141. )
  18142. ]
  18143. };
  18144. };
  18145. const transformModel = (dir, node, context) => {
  18146. const baseResult = transformModel$1(dir, node, context);
  18147. if (!baseResult.props.length || node.tagType === 1) {
  18148. return baseResult;
  18149. }
  18150. if (dir.arg) {
  18151. context.onError(
  18152. createDOMCompilerError(
  18153. 59,
  18154. dir.arg.loc
  18155. )
  18156. );
  18157. }
  18158. function checkDuplicatedValue() {
  18159. const value = findDir(node, "bind");
  18160. if (value && isStaticArgOf(value.arg, "value")) {
  18161. context.onError(
  18162. createDOMCompilerError(
  18163. 61,
  18164. value.loc
  18165. )
  18166. );
  18167. }
  18168. }
  18169. const { tag } = node;
  18170. const isCustomElement = context.isCustomElement(tag);
  18171. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  18172. let directiveToUse = V_MODEL_TEXT;
  18173. let isInvalidType = false;
  18174. if (tag === "input" || isCustomElement) {
  18175. const type = findProp(node, `type`);
  18176. if (type) {
  18177. if (type.type === 7) {
  18178. directiveToUse = V_MODEL_DYNAMIC;
  18179. } else if (type.value) {
  18180. switch (type.value.content) {
  18181. case "radio":
  18182. directiveToUse = V_MODEL_RADIO;
  18183. break;
  18184. case "checkbox":
  18185. directiveToUse = V_MODEL_CHECKBOX;
  18186. break;
  18187. case "file":
  18188. isInvalidType = true;
  18189. context.onError(
  18190. createDOMCompilerError(
  18191. 60,
  18192. dir.loc
  18193. )
  18194. );
  18195. break;
  18196. default:
  18197. checkDuplicatedValue();
  18198. break;
  18199. }
  18200. }
  18201. } else if (hasDynamicKeyVBind(node)) {
  18202. directiveToUse = V_MODEL_DYNAMIC;
  18203. } else {
  18204. checkDuplicatedValue();
  18205. }
  18206. } else if (tag === "select") {
  18207. directiveToUse = V_MODEL_SELECT;
  18208. } else {
  18209. checkDuplicatedValue();
  18210. }
  18211. if (!isInvalidType) {
  18212. baseResult.needRuntime = context.helper(directiveToUse);
  18213. }
  18214. } else {
  18215. context.onError(
  18216. createDOMCompilerError(
  18217. 58,
  18218. dir.loc
  18219. )
  18220. );
  18221. }
  18222. baseResult.props = baseResult.props.filter(
  18223. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  18224. );
  18225. return baseResult;
  18226. };
  18227. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  18228. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  18229. // event propagation management
  18230. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  18231. );
  18232. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  18233. const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
  18234. const resolveModifiers = (key, modifiers, context, loc) => {
  18235. const keyModifiers = [];
  18236. const nonKeyModifiers = [];
  18237. const eventOptionModifiers = [];
  18238. for (let i = 0; i < modifiers.length; i++) {
  18239. const modifier = modifiers[i].content;
  18240. if (isEventOptionModifier(modifier)) {
  18241. eventOptionModifiers.push(modifier);
  18242. } else {
  18243. if (maybeKeyModifier(modifier)) {
  18244. if (isStaticExp(key)) {
  18245. if (isKeyboardEvent(key.content.toLowerCase())) {
  18246. keyModifiers.push(modifier);
  18247. } else {
  18248. nonKeyModifiers.push(modifier);
  18249. }
  18250. } else {
  18251. keyModifiers.push(modifier);
  18252. nonKeyModifiers.push(modifier);
  18253. }
  18254. } else {
  18255. if (isNonKeyModifier(modifier)) {
  18256. nonKeyModifiers.push(modifier);
  18257. } else {
  18258. keyModifiers.push(modifier);
  18259. }
  18260. }
  18261. }
  18262. }
  18263. return {
  18264. keyModifiers,
  18265. nonKeyModifiers,
  18266. eventOptionModifiers
  18267. };
  18268. };
  18269. const transformClick = (key, event) => {
  18270. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  18271. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  18272. `(`,
  18273. key,
  18274. `) === "onClick" ? "${event}" : (`,
  18275. key,
  18276. `)`
  18277. ]) : key;
  18278. };
  18279. const transformOn = (dir, node, context) => {
  18280. return transformOn$1(dir, node, context, (baseResult) => {
  18281. const { modifiers } = dir;
  18282. if (!modifiers.length) return baseResult;
  18283. let { key, value: handlerExp } = baseResult.props[0];
  18284. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  18285. if (nonKeyModifiers.includes("right")) {
  18286. key = transformClick(key, `onContextmenu`);
  18287. }
  18288. if (nonKeyModifiers.includes("middle")) {
  18289. key = transformClick(key, `onMouseup`);
  18290. }
  18291. if (nonKeyModifiers.length) {
  18292. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  18293. handlerExp,
  18294. JSON.stringify(nonKeyModifiers)
  18295. ]);
  18296. }
  18297. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  18298. (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
  18299. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  18300. handlerExp,
  18301. JSON.stringify(keyModifiers)
  18302. ]);
  18303. }
  18304. if (eventOptionModifiers.length) {
  18305. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  18306. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  18307. }
  18308. return {
  18309. props: [createObjectProperty(key, handlerExp)]
  18310. };
  18311. });
  18312. };
  18313. const transformShow = (dir, node, context) => {
  18314. const { exp, loc } = dir;
  18315. if (!exp) {
  18316. context.onError(
  18317. createDOMCompilerError(62, loc)
  18318. );
  18319. }
  18320. return {
  18321. props: [],
  18322. needRuntime: context.helper(V_SHOW)
  18323. };
  18324. };
  18325. const transformTransition = (node, context) => {
  18326. if (node.type === 1 && node.tagType === 1) {
  18327. const component = context.isBuiltInComponent(node.tag);
  18328. if (component === TRANSITION) {
  18329. return () => {
  18330. if (!node.children.length) {
  18331. return;
  18332. }
  18333. if (hasMultipleChildren(node)) {
  18334. context.onError(
  18335. createDOMCompilerError(
  18336. 63,
  18337. {
  18338. start: node.children[0].loc.start,
  18339. end: node.children[node.children.length - 1].loc.end,
  18340. source: ""
  18341. }
  18342. )
  18343. );
  18344. }
  18345. const child = node.children[0];
  18346. if (child.type === 1) {
  18347. for (const p of child.props) {
  18348. if (p.type === 7 && p.name === "show") {
  18349. node.props.push({
  18350. type: 6,
  18351. name: "persisted",
  18352. nameLoc: node.loc,
  18353. value: void 0,
  18354. loc: node.loc
  18355. });
  18356. }
  18357. }
  18358. }
  18359. };
  18360. }
  18361. }
  18362. };
  18363. function hasMultipleChildren(node) {
  18364. const children = node.children = node.children.filter(
  18365. (c) => !isCommentOrWhitespace(c)
  18366. );
  18367. const child = children[0];
  18368. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  18369. }
  18370. const ignoreSideEffectTags = (node, context) => {
  18371. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  18372. context.onError(
  18373. createDOMCompilerError(
  18374. 64,
  18375. node.loc
  18376. )
  18377. );
  18378. context.removeNode();
  18379. }
  18380. };
  18381. function isValidHTMLNesting(parent, child) {
  18382. if (parent === "template") {
  18383. return true;
  18384. }
  18385. if (parent in onlyValidChildren) {
  18386. return onlyValidChildren[parent].has(child);
  18387. }
  18388. if (child in onlyValidParents) {
  18389. return onlyValidParents[child].has(parent);
  18390. }
  18391. if (parent in knownInvalidChildren) {
  18392. if (knownInvalidChildren[parent].has(child)) return false;
  18393. }
  18394. if (child in knownInvalidParents) {
  18395. if (knownInvalidParents[child].has(parent)) return false;
  18396. }
  18397. return true;
  18398. }
  18399. const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
  18400. const emptySet = /* @__PURE__ */ new Set([]);
  18401. const onlyValidChildren = {
  18402. head: /* @__PURE__ */ new Set([
  18403. "base",
  18404. "basefront",
  18405. "bgsound",
  18406. "link",
  18407. "meta",
  18408. "title",
  18409. "noscript",
  18410. "noframes",
  18411. "style",
  18412. "script",
  18413. "template"
  18414. ]),
  18415. optgroup: /* @__PURE__ */ new Set(["option"]),
  18416. select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
  18417. // table
  18418. table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
  18419. tr: /* @__PURE__ */ new Set(["td", "th"]),
  18420. colgroup: /* @__PURE__ */ new Set(["col"]),
  18421. tbody: /* @__PURE__ */ new Set(["tr"]),
  18422. thead: /* @__PURE__ */ new Set(["tr"]),
  18423. tfoot: /* @__PURE__ */ new Set(["tr"]),
  18424. // these elements can not have any children elements
  18425. script: emptySet,
  18426. iframe: emptySet,
  18427. option: emptySet,
  18428. textarea: emptySet,
  18429. style: emptySet,
  18430. title: emptySet
  18431. };
  18432. const onlyValidParents = {
  18433. // sections
  18434. html: emptySet,
  18435. body: /* @__PURE__ */ new Set(["html"]),
  18436. head: /* @__PURE__ */ new Set(["html"]),
  18437. // table
  18438. td: /* @__PURE__ */ new Set(["tr"]),
  18439. colgroup: /* @__PURE__ */ new Set(["table"]),
  18440. caption: /* @__PURE__ */ new Set(["table"]),
  18441. tbody: /* @__PURE__ */ new Set(["table"]),
  18442. tfoot: /* @__PURE__ */ new Set(["table"]),
  18443. col: /* @__PURE__ */ new Set(["colgroup"]),
  18444. th: /* @__PURE__ */ new Set(["tr"]),
  18445. thead: /* @__PURE__ */ new Set(["table"]),
  18446. tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
  18447. // data list
  18448. dd: /* @__PURE__ */ new Set(["dl", "div"]),
  18449. dt: /* @__PURE__ */ new Set(["dl", "div"]),
  18450. // other
  18451. figcaption: /* @__PURE__ */ new Set(["figure"]),
  18452. // li: new Set(["ul", "ol"]),
  18453. summary: /* @__PURE__ */ new Set(["details"]),
  18454. area: /* @__PURE__ */ new Set(["map"])
  18455. };
  18456. const knownInvalidChildren = {
  18457. p: /* @__PURE__ */ new Set([
  18458. "address",
  18459. "article",
  18460. "aside",
  18461. "blockquote",
  18462. "center",
  18463. "details",
  18464. "dialog",
  18465. "dir",
  18466. "div",
  18467. "dl",
  18468. "fieldset",
  18469. "figure",
  18470. "footer",
  18471. "form",
  18472. "h1",
  18473. "h2",
  18474. "h3",
  18475. "h4",
  18476. "h5",
  18477. "h6",
  18478. "header",
  18479. "hgroup",
  18480. "hr",
  18481. "li",
  18482. "main",
  18483. "nav",
  18484. "menu",
  18485. "ol",
  18486. "p",
  18487. "pre",
  18488. "section",
  18489. "table",
  18490. "ul"
  18491. ]),
  18492. svg: /* @__PURE__ */ new Set([
  18493. "b",
  18494. "blockquote",
  18495. "br",
  18496. "code",
  18497. "dd",
  18498. "div",
  18499. "dl",
  18500. "dt",
  18501. "em",
  18502. "embed",
  18503. "h1",
  18504. "h2",
  18505. "h3",
  18506. "h4",
  18507. "h5",
  18508. "h6",
  18509. "hr",
  18510. "i",
  18511. "img",
  18512. "li",
  18513. "menu",
  18514. "meta",
  18515. "ol",
  18516. "p",
  18517. "pre",
  18518. "ruby",
  18519. "s",
  18520. "small",
  18521. "span",
  18522. "strong",
  18523. "sub",
  18524. "sup",
  18525. "table",
  18526. "u",
  18527. "ul",
  18528. "var"
  18529. ])
  18530. };
  18531. const knownInvalidParents = {
  18532. a: /* @__PURE__ */ new Set(["a"]),
  18533. button: /* @__PURE__ */ new Set(["button"]),
  18534. dd: /* @__PURE__ */ new Set(["dd", "dt"]),
  18535. dt: /* @__PURE__ */ new Set(["dd", "dt"]),
  18536. form: /* @__PURE__ */ new Set(["form"]),
  18537. li: /* @__PURE__ */ new Set(["li"]),
  18538. h1: headings,
  18539. h2: headings,
  18540. h3: headings,
  18541. h4: headings,
  18542. h5: headings,
  18543. h6: headings
  18544. };
  18545. const validateHtmlNesting = (node, context) => {
  18546. if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
  18547. const error = new SyntaxError(
  18548. `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
  18549. );
  18550. error.loc = node.loc;
  18551. context.onWarn(error);
  18552. }
  18553. };
  18554. const DOMNodeTransforms = [
  18555. transformStyle,
  18556. ...[transformTransition, validateHtmlNesting]
  18557. ];
  18558. const DOMDirectiveTransforms = {
  18559. cloak: noopDirectiveTransform,
  18560. html: transformVHtml,
  18561. text: transformVText,
  18562. model: transformModel,
  18563. // override compiler-core
  18564. on: transformOn,
  18565. // override compiler-core
  18566. show: transformShow
  18567. };
  18568. function compile(src, options = {}) {
  18569. return baseCompile(
  18570. src,
  18571. extend({}, parserOptions, options, {
  18572. nodeTransforms: [
  18573. // ignore <script> and <tag>
  18574. // this is not put inside DOMNodeTransforms because that list is used
  18575. // by compiler-ssr to generate vnode fallback branches
  18576. ignoreSideEffectTags,
  18577. ...DOMNodeTransforms,
  18578. ...options.nodeTransforms || []
  18579. ],
  18580. directiveTransforms: extend(
  18581. {},
  18582. DOMDirectiveTransforms,
  18583. options.directiveTransforms || {}
  18584. ),
  18585. transformHoist: null
  18586. })
  18587. );
  18588. }
  18589. {
  18590. initDev();
  18591. }
  18592. const compileCache = /* @__PURE__ */ Object.create(null);
  18593. function compileToFunction(template, options) {
  18594. if (!isString(template)) {
  18595. if (template.nodeType) {
  18596. template = template.innerHTML;
  18597. } else {
  18598. warn(`invalid template option: `, template);
  18599. return NOOP;
  18600. }
  18601. }
  18602. const key = genCacheKey(template, options);
  18603. const cached = compileCache[key];
  18604. if (cached) {
  18605. return cached;
  18606. }
  18607. if (template[0] === "#") {
  18608. const el = document.querySelector(template);
  18609. if (!el) {
  18610. warn(`Template element not found or is empty: ${template}`);
  18611. }
  18612. template = el ? el.innerHTML : ``;
  18613. }
  18614. const opts = extend(
  18615. {
  18616. hoistStatic: true,
  18617. onError: onError ,
  18618. onWarn: (e) => onError(e, true)
  18619. },
  18620. options
  18621. );
  18622. if (!opts.isCustomElement && typeof customElements !== "undefined") {
  18623. opts.isCustomElement = (tag) => !!customElements.get(tag);
  18624. }
  18625. const { code } = compile(template, opts);
  18626. function onError(err, asWarning = false) {
  18627. const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
  18628. const codeFrame = err.loc && generateCodeFrame(
  18629. template,
  18630. err.loc.start.offset,
  18631. err.loc.end.offset
  18632. );
  18633. warn(codeFrame ? `${message}
  18634. ${codeFrame}` : message);
  18635. }
  18636. const render = new Function("Vue", code)(runtimeDom);
  18637. render._rc = true;
  18638. return compileCache[key] = render;
  18639. }
  18640. registerRuntimeCompiler(compileToFunction);
  18641. export { BaseTransition, BaseTransitionPropsValidators, Comment, DeprecationTypes, EffectScope, ErrorCodes, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, TrackOpTypes, Transition, TransitionGroup, TriggerOpTypes, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getCurrentWatcher, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, hydrateOnIdle, hydrateOnInteraction, hydrateOnMediaQuery, hydrateOnVisible, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, nodeOps, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, onWatcherCleanup, openBlock, patchProp, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useHost, useId, useModel, useSSRContext, useShadowRoot, useSlots, useTemplateRef, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };