vue-i18n.js 378 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920
  1. import {
  2. EMPTY_OBJ,
  3. NO,
  4. NOOP,
  5. PatchFlagNames,
  6. camelize,
  7. capitalize,
  8. extend,
  9. generateCodeFrame,
  10. hyphenate,
  11. init_runtime_dom_esm_bundler,
  12. init_shared_esm_bundler,
  13. isArray,
  14. isBuiltInDirective,
  15. isHTMLTag,
  16. isObject,
  17. isOn,
  18. isReservedProp,
  19. isSVGTag,
  20. isString,
  21. isSymbol,
  22. isVoidTag,
  23. makeMap,
  24. parseStringStyle,
  25. runtime_dom_esm_bundler_exports,
  26. shared_esm_bundler_exports,
  27. slotFlagsText,
  28. toHandlerKey
  29. } from "./chunk-O27RRWJC.js";
  30. import {
  31. __async,
  32. __commonJS,
  33. __esm,
  34. __export,
  35. __toCommonJS,
  36. init_define_APP_INFO
  37. } from "./chunk-XY75H3MP.js";
  38. // node_modules/@intlify/shared/dist/shared.cjs.js
  39. var require_shared_cjs = __commonJS({
  40. "node_modules/@intlify/shared/dist/shared.cjs.js"(exports) {
  41. "use strict";
  42. init_define_APP_INFO();
  43. Object.defineProperty(exports, "__esModule", { value: true });
  44. var inBrowser = typeof window !== "undefined";
  45. exports.mark = void 0;
  46. exports.measure = void 0;
  47. {
  48. const perf = inBrowser && window.performance;
  49. if (perf && perf.mark && perf.measure && perf.clearMarks && perf.clearMeasures) {
  50. exports.mark = (tag) => perf.mark(tag);
  51. exports.measure = (name, startTag, endTag) => {
  52. perf.measure(name, startTag, endTag);
  53. perf.clearMarks(startTag);
  54. perf.clearMarks(endTag);
  55. };
  56. }
  57. }
  58. var RE_ARGS = /\{([0-9a-zA-Z]+)\}/g;
  59. function format(message, ...args) {
  60. if (args.length === 1 && isObject2(args[0])) {
  61. args = args[0];
  62. }
  63. if (!args || !args.hasOwnProperty) {
  64. args = {};
  65. }
  66. return message.replace(RE_ARGS, (match, identifier) => {
  67. return args.hasOwnProperty(identifier) ? args[identifier] : "";
  68. });
  69. }
  70. var hasSymbol = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";
  71. var makeSymbol = (name) => hasSymbol ? Symbol(name) : name;
  72. var generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source });
  73. var friendlyJSONstringify = (json) => JSON.stringify(json).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\u0027/g, "\\u0027");
  74. var isNumber = (val) => typeof val === "number" && isFinite(val);
  75. var isDate = (val) => toTypeString(val) === "[object Date]";
  76. var isRegExp = (val) => toTypeString(val) === "[object RegExp]";
  77. var isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0;
  78. function warn(msg, err) {
  79. if (typeof console !== "undefined") {
  80. console.warn(`[intlify] ` + msg);
  81. if (err) {
  82. console.warn(err.stack);
  83. }
  84. }
  85. }
  86. var assign = Object.assign;
  87. var _globalThis;
  88. var getGlobalThis = () => {
  89. return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  90. };
  91. function escapeHtml(rawText) {
  92. return rawText.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
  93. }
  94. var hasOwnProperty = Object.prototype.hasOwnProperty;
  95. function hasOwn(obj, key) {
  96. return hasOwnProperty.call(obj, key);
  97. }
  98. var isArray2 = Array.isArray;
  99. var isFunction = (val) => typeof val === "function";
  100. var isString2 = (val) => typeof val === "string";
  101. var isBoolean = (val) => typeof val === "boolean";
  102. var isSymbol2 = (val) => typeof val === "symbol";
  103. var isObject2 = (val) => val !== null && typeof val === "object";
  104. var isPromise = (val) => {
  105. return isObject2(val) && isFunction(val.then) && isFunction(val.catch);
  106. };
  107. var objectToString = Object.prototype.toString;
  108. var toTypeString = (value) => objectToString.call(value);
  109. var isPlainObject = (val) => toTypeString(val) === "[object Object]";
  110. var toDisplayString = (val) => {
  111. return val == null ? "" : isArray2(val) || isPlainObject(val) && val.toString === objectToString ? JSON.stringify(val, null, 2) : String(val);
  112. };
  113. var RANGE = 2;
  114. function generateCodeFrame2(source, start = 0, end = source.length) {
  115. const lines = source.split(/\r?\n/);
  116. let count = 0;
  117. const res = [];
  118. for (let i = 0; i < lines.length; i++) {
  119. count += lines[i].length + 1;
  120. if (count >= start) {
  121. for (let j = i - RANGE; j <= i + RANGE || end > count; j++) {
  122. if (j < 0 || j >= lines.length)
  123. continue;
  124. const line = j + 1;
  125. res.push(`${line}${" ".repeat(3 - String(line).length)}| ${lines[j]}`);
  126. const lineLength = lines[j].length;
  127. if (j === i) {
  128. const pad = start - (count - lineLength) + 1;
  129. const length = Math.max(1, end > count ? lineLength - pad : end - start);
  130. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  131. } else if (j > i) {
  132. if (end > count) {
  133. const length = Math.max(Math.min(end - count, lineLength), 1);
  134. res.push(` | ` + "^".repeat(length));
  135. }
  136. count += lineLength + 1;
  137. }
  138. }
  139. break;
  140. }
  141. }
  142. return res.join("\n");
  143. }
  144. function createEmitter() {
  145. const events = /* @__PURE__ */ new Map();
  146. const emitter = {
  147. events,
  148. on(event, handler) {
  149. const handlers = events.get(event);
  150. const added = handlers && handlers.push(handler);
  151. if (!added) {
  152. events.set(event, [handler]);
  153. }
  154. },
  155. off(event, handler) {
  156. const handlers = events.get(event);
  157. if (handlers) {
  158. handlers.splice(handlers.indexOf(handler) >>> 0, 1);
  159. }
  160. },
  161. emit(event, payload) {
  162. (events.get(event) || []).slice().map((handler) => handler(payload));
  163. (events.get("*") || []).slice().map((handler) => handler(event, payload));
  164. }
  165. };
  166. return emitter;
  167. }
  168. exports.assign = assign;
  169. exports.createEmitter = createEmitter;
  170. exports.escapeHtml = escapeHtml;
  171. exports.format = format;
  172. exports.friendlyJSONstringify = friendlyJSONstringify;
  173. exports.generateCodeFrame = generateCodeFrame2;
  174. exports.generateFormatCacheKey = generateFormatCacheKey;
  175. exports.getGlobalThis = getGlobalThis;
  176. exports.hasOwn = hasOwn;
  177. exports.inBrowser = inBrowser;
  178. exports.isArray = isArray2;
  179. exports.isBoolean = isBoolean;
  180. exports.isDate = isDate;
  181. exports.isEmptyObject = isEmptyObject;
  182. exports.isFunction = isFunction;
  183. exports.isNumber = isNumber;
  184. exports.isObject = isObject2;
  185. exports.isPlainObject = isPlainObject;
  186. exports.isPromise = isPromise;
  187. exports.isRegExp = isRegExp;
  188. exports.isString = isString2;
  189. exports.isSymbol = isSymbol2;
  190. exports.makeSymbol = makeSymbol;
  191. exports.objectToString = objectToString;
  192. exports.toDisplayString = toDisplayString;
  193. exports.toTypeString = toTypeString;
  194. exports.warn = warn;
  195. }
  196. });
  197. // node_modules/@intlify/shared/index.js
  198. var require_shared = __commonJS({
  199. "node_modules/@intlify/shared/index.js"(exports, module) {
  200. "use strict";
  201. init_define_APP_INFO();
  202. if (false) {
  203. module.exports = null;
  204. } else {
  205. module.exports = require_shared_cjs();
  206. }
  207. }
  208. });
  209. // node_modules/source-map/lib/base64.js
  210. var require_base64 = __commonJS({
  211. "node_modules/source-map/lib/base64.js"(exports) {
  212. init_define_APP_INFO();
  213. var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
  214. exports.encode = function(number) {
  215. if (0 <= number && number < intToCharMap.length) {
  216. return intToCharMap[number];
  217. }
  218. throw new TypeError("Must be between 0 and 63: " + number);
  219. };
  220. exports.decode = function(charCode) {
  221. var bigA = 65;
  222. var bigZ = 90;
  223. var littleA = 97;
  224. var littleZ = 122;
  225. var zero = 48;
  226. var nine = 57;
  227. var plus = 43;
  228. var slash = 47;
  229. var littleOffset = 26;
  230. var numberOffset = 52;
  231. if (bigA <= charCode && charCode <= bigZ) {
  232. return charCode - bigA;
  233. }
  234. if (littleA <= charCode && charCode <= littleZ) {
  235. return charCode - littleA + littleOffset;
  236. }
  237. if (zero <= charCode && charCode <= nine) {
  238. return charCode - zero + numberOffset;
  239. }
  240. if (charCode == plus) {
  241. return 62;
  242. }
  243. if (charCode == slash) {
  244. return 63;
  245. }
  246. return -1;
  247. };
  248. }
  249. });
  250. // node_modules/source-map/lib/base64-vlq.js
  251. var require_base64_vlq = __commonJS({
  252. "node_modules/source-map/lib/base64-vlq.js"(exports) {
  253. init_define_APP_INFO();
  254. var base64 = require_base64();
  255. var VLQ_BASE_SHIFT = 5;
  256. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  257. var VLQ_BASE_MASK = VLQ_BASE - 1;
  258. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  259. function toVLQSigned(aValue) {
  260. return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
  261. }
  262. function fromVLQSigned(aValue) {
  263. var isNegative = (aValue & 1) === 1;
  264. var shifted = aValue >> 1;
  265. return isNegative ? -shifted : shifted;
  266. }
  267. exports.encode = function base64VLQ_encode(aValue) {
  268. var encoded = "";
  269. var digit;
  270. var vlq = toVLQSigned(aValue);
  271. do {
  272. digit = vlq & VLQ_BASE_MASK;
  273. vlq >>>= VLQ_BASE_SHIFT;
  274. if (vlq > 0) {
  275. digit |= VLQ_CONTINUATION_BIT;
  276. }
  277. encoded += base64.encode(digit);
  278. } while (vlq > 0);
  279. return encoded;
  280. };
  281. exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  282. var strLen = aStr.length;
  283. var result = 0;
  284. var shift = 0;
  285. var continuation, digit;
  286. do {
  287. if (aIndex >= strLen) {
  288. throw new Error("Expected more digits in base 64 VLQ value.");
  289. }
  290. digit = base64.decode(aStr.charCodeAt(aIndex++));
  291. if (digit === -1) {
  292. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  293. }
  294. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  295. digit &= VLQ_BASE_MASK;
  296. result = result + (digit << shift);
  297. shift += VLQ_BASE_SHIFT;
  298. } while (continuation);
  299. aOutParam.value = fromVLQSigned(result);
  300. aOutParam.rest = aIndex;
  301. };
  302. }
  303. });
  304. // node_modules/source-map/lib/util.js
  305. var require_util = __commonJS({
  306. "node_modules/source-map/lib/util.js"(exports) {
  307. init_define_APP_INFO();
  308. function getArg(aArgs, aName, aDefaultValue) {
  309. if (aName in aArgs) {
  310. return aArgs[aName];
  311. } else if (arguments.length === 3) {
  312. return aDefaultValue;
  313. } else {
  314. throw new Error('"' + aName + '" is a required argument.');
  315. }
  316. }
  317. exports.getArg = getArg;
  318. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  319. var dataUrlRegexp = /^data:.+\,.+$/;
  320. function urlParse(aUrl) {
  321. var match = aUrl.match(urlRegexp);
  322. if (!match) {
  323. return null;
  324. }
  325. return {
  326. scheme: match[1],
  327. auth: match[2],
  328. host: match[3],
  329. port: match[4],
  330. path: match[5]
  331. };
  332. }
  333. exports.urlParse = urlParse;
  334. function urlGenerate(aParsedUrl) {
  335. var url = "";
  336. if (aParsedUrl.scheme) {
  337. url += aParsedUrl.scheme + ":";
  338. }
  339. url += "//";
  340. if (aParsedUrl.auth) {
  341. url += aParsedUrl.auth + "@";
  342. }
  343. if (aParsedUrl.host) {
  344. url += aParsedUrl.host;
  345. }
  346. if (aParsedUrl.port) {
  347. url += ":" + aParsedUrl.port;
  348. }
  349. if (aParsedUrl.path) {
  350. url += aParsedUrl.path;
  351. }
  352. return url;
  353. }
  354. exports.urlGenerate = urlGenerate;
  355. function normalize(aPath) {
  356. var path = aPath;
  357. var url = urlParse(aPath);
  358. if (url) {
  359. if (!url.path) {
  360. return aPath;
  361. }
  362. path = url.path;
  363. }
  364. var isAbsolute = exports.isAbsolute(path);
  365. var parts = path.split(/\/+/);
  366. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  367. part = parts[i];
  368. if (part === ".") {
  369. parts.splice(i, 1);
  370. } else if (part === "..") {
  371. up++;
  372. } else if (up > 0) {
  373. if (part === "") {
  374. parts.splice(i + 1, up);
  375. up = 0;
  376. } else {
  377. parts.splice(i, 2);
  378. up--;
  379. }
  380. }
  381. }
  382. path = parts.join("/");
  383. if (path === "") {
  384. path = isAbsolute ? "/" : ".";
  385. }
  386. if (url) {
  387. url.path = path;
  388. return urlGenerate(url);
  389. }
  390. return path;
  391. }
  392. exports.normalize = normalize;
  393. function join(aRoot, aPath) {
  394. if (aRoot === "") {
  395. aRoot = ".";
  396. }
  397. if (aPath === "") {
  398. aPath = ".";
  399. }
  400. var aPathUrl = urlParse(aPath);
  401. var aRootUrl = urlParse(aRoot);
  402. if (aRootUrl) {
  403. aRoot = aRootUrl.path || "/";
  404. }
  405. if (aPathUrl && !aPathUrl.scheme) {
  406. if (aRootUrl) {
  407. aPathUrl.scheme = aRootUrl.scheme;
  408. }
  409. return urlGenerate(aPathUrl);
  410. }
  411. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  412. return aPath;
  413. }
  414. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  415. aRootUrl.host = aPath;
  416. return urlGenerate(aRootUrl);
  417. }
  418. var joined = aPath.charAt(0) === "/" ? aPath : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
  419. if (aRootUrl) {
  420. aRootUrl.path = joined;
  421. return urlGenerate(aRootUrl);
  422. }
  423. return joined;
  424. }
  425. exports.join = join;
  426. exports.isAbsolute = function(aPath) {
  427. return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
  428. };
  429. function relative(aRoot, aPath) {
  430. if (aRoot === "") {
  431. aRoot = ".";
  432. }
  433. aRoot = aRoot.replace(/\/$/, "");
  434. var level = 0;
  435. while (aPath.indexOf(aRoot + "/") !== 0) {
  436. var index = aRoot.lastIndexOf("/");
  437. if (index < 0) {
  438. return aPath;
  439. }
  440. aRoot = aRoot.slice(0, index);
  441. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  442. return aPath;
  443. }
  444. ++level;
  445. }
  446. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  447. }
  448. exports.relative = relative;
  449. var supportsNullProto = function() {
  450. var obj = /* @__PURE__ */ Object.create(null);
  451. return !("__proto__" in obj);
  452. }();
  453. function identity(s) {
  454. return s;
  455. }
  456. function toSetString(aStr) {
  457. if (isProtoString(aStr)) {
  458. return "$" + aStr;
  459. }
  460. return aStr;
  461. }
  462. exports.toSetString = supportsNullProto ? identity : toSetString;
  463. function fromSetString(aStr) {
  464. if (isProtoString(aStr)) {
  465. return aStr.slice(1);
  466. }
  467. return aStr;
  468. }
  469. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  470. function isProtoString(s) {
  471. if (!s) {
  472. return false;
  473. }
  474. var length = s.length;
  475. if (length < 9) {
  476. return false;
  477. }
  478. if (s.charCodeAt(length - 1) !== 95 || s.charCodeAt(length - 2) !== 95 || s.charCodeAt(length - 3) !== 111 || s.charCodeAt(length - 4) !== 116 || s.charCodeAt(length - 5) !== 111 || s.charCodeAt(length - 6) !== 114 || s.charCodeAt(length - 7) !== 112 || s.charCodeAt(length - 8) !== 95 || s.charCodeAt(length - 9) !== 95) {
  479. return false;
  480. }
  481. for (var i = length - 10; i >= 0; i--) {
  482. if (s.charCodeAt(i) !== 36) {
  483. return false;
  484. }
  485. }
  486. return true;
  487. }
  488. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  489. var cmp = strcmp(mappingA.source, mappingB.source);
  490. if (cmp !== 0) {
  491. return cmp;
  492. }
  493. cmp = mappingA.originalLine - mappingB.originalLine;
  494. if (cmp !== 0) {
  495. return cmp;
  496. }
  497. cmp = mappingA.originalColumn - mappingB.originalColumn;
  498. if (cmp !== 0 || onlyCompareOriginal) {
  499. return cmp;
  500. }
  501. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  502. if (cmp !== 0) {
  503. return cmp;
  504. }
  505. cmp = mappingA.generatedLine - mappingB.generatedLine;
  506. if (cmp !== 0) {
  507. return cmp;
  508. }
  509. return strcmp(mappingA.name, mappingB.name);
  510. }
  511. exports.compareByOriginalPositions = compareByOriginalPositions;
  512. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  513. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  514. if (cmp !== 0) {
  515. return cmp;
  516. }
  517. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  518. if (cmp !== 0 || onlyCompareGenerated) {
  519. return cmp;
  520. }
  521. cmp = strcmp(mappingA.source, mappingB.source);
  522. if (cmp !== 0) {
  523. return cmp;
  524. }
  525. cmp = mappingA.originalLine - mappingB.originalLine;
  526. if (cmp !== 0) {
  527. return cmp;
  528. }
  529. cmp = mappingA.originalColumn - mappingB.originalColumn;
  530. if (cmp !== 0) {
  531. return cmp;
  532. }
  533. return strcmp(mappingA.name, mappingB.name);
  534. }
  535. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  536. function strcmp(aStr1, aStr2) {
  537. if (aStr1 === aStr2) {
  538. return 0;
  539. }
  540. if (aStr1 === null) {
  541. return 1;
  542. }
  543. if (aStr2 === null) {
  544. return -1;
  545. }
  546. if (aStr1 > aStr2) {
  547. return 1;
  548. }
  549. return -1;
  550. }
  551. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  552. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  553. if (cmp !== 0) {
  554. return cmp;
  555. }
  556. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  557. if (cmp !== 0) {
  558. return cmp;
  559. }
  560. cmp = strcmp(mappingA.source, mappingB.source);
  561. if (cmp !== 0) {
  562. return cmp;
  563. }
  564. cmp = mappingA.originalLine - mappingB.originalLine;
  565. if (cmp !== 0) {
  566. return cmp;
  567. }
  568. cmp = mappingA.originalColumn - mappingB.originalColumn;
  569. if (cmp !== 0) {
  570. return cmp;
  571. }
  572. return strcmp(mappingA.name, mappingB.name);
  573. }
  574. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  575. function parseSourceMapInput(str) {
  576. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
  577. }
  578. exports.parseSourceMapInput = parseSourceMapInput;
  579. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  580. sourceURL = sourceURL || "";
  581. if (sourceRoot) {
  582. if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") {
  583. sourceRoot += "/";
  584. }
  585. sourceURL = sourceRoot + sourceURL;
  586. }
  587. if (sourceMapURL) {
  588. var parsed = urlParse(sourceMapURL);
  589. if (!parsed) {
  590. throw new Error("sourceMapURL could not be parsed");
  591. }
  592. if (parsed.path) {
  593. var index = parsed.path.lastIndexOf("/");
  594. if (index >= 0) {
  595. parsed.path = parsed.path.substring(0, index + 1);
  596. }
  597. }
  598. sourceURL = join(urlGenerate(parsed), sourceURL);
  599. }
  600. return normalize(sourceURL);
  601. }
  602. exports.computeSourceURL = computeSourceURL;
  603. }
  604. });
  605. // node_modules/source-map/lib/array-set.js
  606. var require_array_set = __commonJS({
  607. "node_modules/source-map/lib/array-set.js"(exports) {
  608. init_define_APP_INFO();
  609. var util = require_util();
  610. var has = Object.prototype.hasOwnProperty;
  611. var hasNativeMap = typeof Map !== "undefined";
  612. function ArraySet() {
  613. this._array = [];
  614. this._set = hasNativeMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
  615. }
  616. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  617. var set = new ArraySet();
  618. for (var i = 0, len = aArray.length; i < len; i++) {
  619. set.add(aArray[i], aAllowDuplicates);
  620. }
  621. return set;
  622. };
  623. ArraySet.prototype.size = function ArraySet_size() {
  624. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  625. };
  626. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  627. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  628. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  629. var idx = this._array.length;
  630. if (!isDuplicate || aAllowDuplicates) {
  631. this._array.push(aStr);
  632. }
  633. if (!isDuplicate) {
  634. if (hasNativeMap) {
  635. this._set.set(aStr, idx);
  636. } else {
  637. this._set[sStr] = idx;
  638. }
  639. }
  640. };
  641. ArraySet.prototype.has = function ArraySet_has(aStr) {
  642. if (hasNativeMap) {
  643. return this._set.has(aStr);
  644. } else {
  645. var sStr = util.toSetString(aStr);
  646. return has.call(this._set, sStr);
  647. }
  648. };
  649. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  650. if (hasNativeMap) {
  651. var idx = this._set.get(aStr);
  652. if (idx >= 0) {
  653. return idx;
  654. }
  655. } else {
  656. var sStr = util.toSetString(aStr);
  657. if (has.call(this._set, sStr)) {
  658. return this._set[sStr];
  659. }
  660. }
  661. throw new Error('"' + aStr + '" is not in the set.');
  662. };
  663. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  664. if (aIdx >= 0 && aIdx < this._array.length) {
  665. return this._array[aIdx];
  666. }
  667. throw new Error("No element indexed by " + aIdx);
  668. };
  669. ArraySet.prototype.toArray = function ArraySet_toArray() {
  670. return this._array.slice();
  671. };
  672. exports.ArraySet = ArraySet;
  673. }
  674. });
  675. // node_modules/source-map/lib/mapping-list.js
  676. var require_mapping_list = __commonJS({
  677. "node_modules/source-map/lib/mapping-list.js"(exports) {
  678. init_define_APP_INFO();
  679. var util = require_util();
  680. function generatedPositionAfter(mappingA, mappingB) {
  681. var lineA = mappingA.generatedLine;
  682. var lineB = mappingB.generatedLine;
  683. var columnA = mappingA.generatedColumn;
  684. var columnB = mappingB.generatedColumn;
  685. return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  686. }
  687. function MappingList() {
  688. this._array = [];
  689. this._sorted = true;
  690. this._last = { generatedLine: -1, generatedColumn: 0 };
  691. }
  692. MappingList.prototype.unsortedForEach = function MappingList_forEach(aCallback, aThisArg) {
  693. this._array.forEach(aCallback, aThisArg);
  694. };
  695. MappingList.prototype.add = function MappingList_add(aMapping) {
  696. if (generatedPositionAfter(this._last, aMapping)) {
  697. this._last = aMapping;
  698. this._array.push(aMapping);
  699. } else {
  700. this._sorted = false;
  701. this._array.push(aMapping);
  702. }
  703. };
  704. MappingList.prototype.toArray = function MappingList_toArray() {
  705. if (!this._sorted) {
  706. this._array.sort(util.compareByGeneratedPositionsInflated);
  707. this._sorted = true;
  708. }
  709. return this._array;
  710. };
  711. exports.MappingList = MappingList;
  712. }
  713. });
  714. // node_modules/source-map/lib/source-map-generator.js
  715. var require_source_map_generator = __commonJS({
  716. "node_modules/source-map/lib/source-map-generator.js"(exports) {
  717. init_define_APP_INFO();
  718. var base64VLQ = require_base64_vlq();
  719. var util = require_util();
  720. var ArraySet = require_array_set().ArraySet;
  721. var MappingList = require_mapping_list().MappingList;
  722. function SourceMapGenerator(aArgs) {
  723. if (!aArgs) {
  724. aArgs = {};
  725. }
  726. this._file = util.getArg(aArgs, "file", null);
  727. this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
  728. this._skipValidation = util.getArg(aArgs, "skipValidation", false);
  729. this._sources = new ArraySet();
  730. this._names = new ArraySet();
  731. this._mappings = new MappingList();
  732. this._sourcesContents = null;
  733. }
  734. SourceMapGenerator.prototype._version = 3;
  735. SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  736. var sourceRoot = aSourceMapConsumer.sourceRoot;
  737. var generator = new SourceMapGenerator({
  738. file: aSourceMapConsumer.file,
  739. sourceRoot
  740. });
  741. aSourceMapConsumer.eachMapping(function(mapping) {
  742. var newMapping = {
  743. generated: {
  744. line: mapping.generatedLine,
  745. column: mapping.generatedColumn
  746. }
  747. };
  748. if (mapping.source != null) {
  749. newMapping.source = mapping.source;
  750. if (sourceRoot != null) {
  751. newMapping.source = util.relative(sourceRoot, newMapping.source);
  752. }
  753. newMapping.original = {
  754. line: mapping.originalLine,
  755. column: mapping.originalColumn
  756. };
  757. if (mapping.name != null) {
  758. newMapping.name = mapping.name;
  759. }
  760. }
  761. generator.addMapping(newMapping);
  762. });
  763. aSourceMapConsumer.sources.forEach(function(sourceFile) {
  764. var sourceRelative = sourceFile;
  765. if (sourceRoot !== null) {
  766. sourceRelative = util.relative(sourceRoot, sourceFile);
  767. }
  768. if (!generator._sources.has(sourceRelative)) {
  769. generator._sources.add(sourceRelative);
  770. }
  771. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  772. if (content != null) {
  773. generator.setSourceContent(sourceFile, content);
  774. }
  775. });
  776. return generator;
  777. };
  778. SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) {
  779. var generated = util.getArg(aArgs, "generated");
  780. var original = util.getArg(aArgs, "original", null);
  781. var source = util.getArg(aArgs, "source", null);
  782. var name = util.getArg(aArgs, "name", null);
  783. if (!this._skipValidation) {
  784. this._validateMapping(generated, original, source, name);
  785. }
  786. if (source != null) {
  787. source = String(source);
  788. if (!this._sources.has(source)) {
  789. this._sources.add(source);
  790. }
  791. }
  792. if (name != null) {
  793. name = String(name);
  794. if (!this._names.has(name)) {
  795. this._names.add(name);
  796. }
  797. }
  798. this._mappings.add({
  799. generatedLine: generated.line,
  800. generatedColumn: generated.column,
  801. originalLine: original != null && original.line,
  802. originalColumn: original != null && original.column,
  803. source,
  804. name
  805. });
  806. };
  807. SourceMapGenerator.prototype.setSourceContent = function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  808. var source = aSourceFile;
  809. if (this._sourceRoot != null) {
  810. source = util.relative(this._sourceRoot, source);
  811. }
  812. if (aSourceContent != null) {
  813. if (!this._sourcesContents) {
  814. this._sourcesContents = /* @__PURE__ */ Object.create(null);
  815. }
  816. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  817. } else if (this._sourcesContents) {
  818. delete this._sourcesContents[util.toSetString(source)];
  819. if (Object.keys(this._sourcesContents).length === 0) {
  820. this._sourcesContents = null;
  821. }
  822. }
  823. };
  824. SourceMapGenerator.prototype.applySourceMap = function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  825. var sourceFile = aSourceFile;
  826. if (aSourceFile == null) {
  827. if (aSourceMapConsumer.file == null) {
  828. throw new Error(
  829. `SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`
  830. );
  831. }
  832. sourceFile = aSourceMapConsumer.file;
  833. }
  834. var sourceRoot = this._sourceRoot;
  835. if (sourceRoot != null) {
  836. sourceFile = util.relative(sourceRoot, sourceFile);
  837. }
  838. var newSources = new ArraySet();
  839. var newNames = new ArraySet();
  840. this._mappings.unsortedForEach(function(mapping) {
  841. if (mapping.source === sourceFile && mapping.originalLine != null) {
  842. var original = aSourceMapConsumer.originalPositionFor({
  843. line: mapping.originalLine,
  844. column: mapping.originalColumn
  845. });
  846. if (original.source != null) {
  847. mapping.source = original.source;
  848. if (aSourceMapPath != null) {
  849. mapping.source = util.join(aSourceMapPath, mapping.source);
  850. }
  851. if (sourceRoot != null) {
  852. mapping.source = util.relative(sourceRoot, mapping.source);
  853. }
  854. mapping.originalLine = original.line;
  855. mapping.originalColumn = original.column;
  856. if (original.name != null) {
  857. mapping.name = original.name;
  858. }
  859. }
  860. }
  861. var source = mapping.source;
  862. if (source != null && !newSources.has(source)) {
  863. newSources.add(source);
  864. }
  865. var name = mapping.name;
  866. if (name != null && !newNames.has(name)) {
  867. newNames.add(name);
  868. }
  869. }, this);
  870. this._sources = newSources;
  871. this._names = newNames;
  872. aSourceMapConsumer.sources.forEach(function(sourceFile2) {
  873. var content = aSourceMapConsumer.sourceContentFor(sourceFile2);
  874. if (content != null) {
  875. if (aSourceMapPath != null) {
  876. sourceFile2 = util.join(aSourceMapPath, sourceFile2);
  877. }
  878. if (sourceRoot != null) {
  879. sourceFile2 = util.relative(sourceRoot, sourceFile2);
  880. }
  881. this.setSourceContent(sourceFile2, content);
  882. }
  883. }, this);
  884. };
  885. SourceMapGenerator.prototype._validateMapping = function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, aName) {
  886. if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
  887. throw new Error(
  888. "original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values."
  889. );
  890. }
  891. if (aGenerated && "line" in aGenerated && "column" in aGenerated && aGenerated.line > 0 && aGenerated.column >= 0 && !aOriginal && !aSource && !aName) {
  892. return;
  893. } else if (aGenerated && "line" in aGenerated && "column" in aGenerated && aOriginal && "line" in aOriginal && "column" in aOriginal && aGenerated.line > 0 && aGenerated.column >= 0 && aOriginal.line > 0 && aOriginal.column >= 0 && aSource) {
  894. return;
  895. } else {
  896. throw new Error("Invalid mapping: " + JSON.stringify({
  897. generated: aGenerated,
  898. source: aSource,
  899. original: aOriginal,
  900. name: aName
  901. }));
  902. }
  903. };
  904. SourceMapGenerator.prototype._serializeMappings = function SourceMapGenerator_serializeMappings() {
  905. var previousGeneratedColumn = 0;
  906. var previousGeneratedLine = 1;
  907. var previousOriginalColumn = 0;
  908. var previousOriginalLine = 0;
  909. var previousName = 0;
  910. var previousSource = 0;
  911. var result = "";
  912. var next;
  913. var mapping;
  914. var nameIdx;
  915. var sourceIdx;
  916. var mappings = this._mappings.toArray();
  917. for (var i = 0, len = mappings.length; i < len; i++) {
  918. mapping = mappings[i];
  919. next = "";
  920. if (mapping.generatedLine !== previousGeneratedLine) {
  921. previousGeneratedColumn = 0;
  922. while (mapping.generatedLine !== previousGeneratedLine) {
  923. next += ";";
  924. previousGeneratedLine++;
  925. }
  926. } else {
  927. if (i > 0) {
  928. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  929. continue;
  930. }
  931. next += ",";
  932. }
  933. }
  934. next += base64VLQ.encode(mapping.generatedColumn - previousGeneratedColumn);
  935. previousGeneratedColumn = mapping.generatedColumn;
  936. if (mapping.source != null) {
  937. sourceIdx = this._sources.indexOf(mapping.source);
  938. next += base64VLQ.encode(sourceIdx - previousSource);
  939. previousSource = sourceIdx;
  940. next += base64VLQ.encode(mapping.originalLine - 1 - previousOriginalLine);
  941. previousOriginalLine = mapping.originalLine - 1;
  942. next += base64VLQ.encode(mapping.originalColumn - previousOriginalColumn);
  943. previousOriginalColumn = mapping.originalColumn;
  944. if (mapping.name != null) {
  945. nameIdx = this._names.indexOf(mapping.name);
  946. next += base64VLQ.encode(nameIdx - previousName);
  947. previousName = nameIdx;
  948. }
  949. }
  950. result += next;
  951. }
  952. return result;
  953. };
  954. SourceMapGenerator.prototype._generateSourcesContent = function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  955. return aSources.map(function(source) {
  956. if (!this._sourcesContents) {
  957. return null;
  958. }
  959. if (aSourceRoot != null) {
  960. source = util.relative(aSourceRoot, source);
  961. }
  962. var key = util.toSetString(source);
  963. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) ? this._sourcesContents[key] : null;
  964. }, this);
  965. };
  966. SourceMapGenerator.prototype.toJSON = function SourceMapGenerator_toJSON() {
  967. var map = {
  968. version: this._version,
  969. sources: this._sources.toArray(),
  970. names: this._names.toArray(),
  971. mappings: this._serializeMappings()
  972. };
  973. if (this._file != null) {
  974. map.file = this._file;
  975. }
  976. if (this._sourceRoot != null) {
  977. map.sourceRoot = this._sourceRoot;
  978. }
  979. if (this._sourcesContents) {
  980. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  981. }
  982. return map;
  983. };
  984. SourceMapGenerator.prototype.toString = function SourceMapGenerator_toString() {
  985. return JSON.stringify(this.toJSON());
  986. };
  987. exports.SourceMapGenerator = SourceMapGenerator;
  988. }
  989. });
  990. // node_modules/source-map/lib/binary-search.js
  991. var require_binary_search = __commonJS({
  992. "node_modules/source-map/lib/binary-search.js"(exports) {
  993. init_define_APP_INFO();
  994. exports.GREATEST_LOWER_BOUND = 1;
  995. exports.LEAST_UPPER_BOUND = 2;
  996. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  997. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  998. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  999. if (cmp === 0) {
  1000. return mid;
  1001. } else if (cmp > 0) {
  1002. if (aHigh - mid > 1) {
  1003. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  1004. }
  1005. if (aBias == exports.LEAST_UPPER_BOUND) {
  1006. return aHigh < aHaystack.length ? aHigh : -1;
  1007. } else {
  1008. return mid;
  1009. }
  1010. } else {
  1011. if (mid - aLow > 1) {
  1012. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  1013. }
  1014. if (aBias == exports.LEAST_UPPER_BOUND) {
  1015. return mid;
  1016. } else {
  1017. return aLow < 0 ? -1 : aLow;
  1018. }
  1019. }
  1020. }
  1021. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  1022. if (aHaystack.length === 0) {
  1023. return -1;
  1024. }
  1025. var index = recursiveSearch(
  1026. -1,
  1027. aHaystack.length,
  1028. aNeedle,
  1029. aHaystack,
  1030. aCompare,
  1031. aBias || exports.GREATEST_LOWER_BOUND
  1032. );
  1033. if (index < 0) {
  1034. return -1;
  1035. }
  1036. while (index - 1 >= 0) {
  1037. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  1038. break;
  1039. }
  1040. --index;
  1041. }
  1042. return index;
  1043. };
  1044. }
  1045. });
  1046. // node_modules/source-map/lib/quick-sort.js
  1047. var require_quick_sort = __commonJS({
  1048. "node_modules/source-map/lib/quick-sort.js"(exports) {
  1049. init_define_APP_INFO();
  1050. function swap(ary, x, y) {
  1051. var temp = ary[x];
  1052. ary[x] = ary[y];
  1053. ary[y] = temp;
  1054. }
  1055. function randomIntInRange(low, high) {
  1056. return Math.round(low + Math.random() * (high - low));
  1057. }
  1058. function doQuickSort(ary, comparator, p, r) {
  1059. if (p < r) {
  1060. var pivotIndex = randomIntInRange(p, r);
  1061. var i = p - 1;
  1062. swap(ary, pivotIndex, r);
  1063. var pivot = ary[r];
  1064. for (var j = p; j < r; j++) {
  1065. if (comparator(ary[j], pivot) <= 0) {
  1066. i += 1;
  1067. swap(ary, i, j);
  1068. }
  1069. }
  1070. swap(ary, i + 1, j);
  1071. var q = i + 1;
  1072. doQuickSort(ary, comparator, p, q - 1);
  1073. doQuickSort(ary, comparator, q + 1, r);
  1074. }
  1075. }
  1076. exports.quickSort = function(ary, comparator) {
  1077. doQuickSort(ary, comparator, 0, ary.length - 1);
  1078. };
  1079. }
  1080. });
  1081. // node_modules/source-map/lib/source-map-consumer.js
  1082. var require_source_map_consumer = __commonJS({
  1083. "node_modules/source-map/lib/source-map-consumer.js"(exports) {
  1084. init_define_APP_INFO();
  1085. var util = require_util();
  1086. var binarySearch = require_binary_search();
  1087. var ArraySet = require_array_set().ArraySet;
  1088. var base64VLQ = require_base64_vlq();
  1089. var quickSort = require_quick_sort().quickSort;
  1090. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  1091. var sourceMap = aSourceMap;
  1092. if (typeof aSourceMap === "string") {
  1093. sourceMap = util.parseSourceMapInput(aSourceMap);
  1094. }
  1095. return sourceMap.sections != null ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  1096. }
  1097. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  1098. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  1099. };
  1100. SourceMapConsumer.prototype._version = 3;
  1101. SourceMapConsumer.prototype.__generatedMappings = null;
  1102. Object.defineProperty(SourceMapConsumer.prototype, "_generatedMappings", {
  1103. configurable: true,
  1104. enumerable: true,
  1105. get: function() {
  1106. if (!this.__generatedMappings) {
  1107. this._parseMappings(this._mappings, this.sourceRoot);
  1108. }
  1109. return this.__generatedMappings;
  1110. }
  1111. });
  1112. SourceMapConsumer.prototype.__originalMappings = null;
  1113. Object.defineProperty(SourceMapConsumer.prototype, "_originalMappings", {
  1114. configurable: true,
  1115. enumerable: true,
  1116. get: function() {
  1117. if (!this.__originalMappings) {
  1118. this._parseMappings(this._mappings, this.sourceRoot);
  1119. }
  1120. return this.__originalMappings;
  1121. }
  1122. });
  1123. SourceMapConsumer.prototype._charIsMappingSeparator = function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  1124. var c = aStr.charAt(index);
  1125. return c === ";" || c === ",";
  1126. };
  1127. SourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  1128. throw new Error("Subclasses must implement _parseMappings");
  1129. };
  1130. SourceMapConsumer.GENERATED_ORDER = 1;
  1131. SourceMapConsumer.ORIGINAL_ORDER = 2;
  1132. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  1133. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  1134. SourceMapConsumer.prototype.eachMapping = function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  1135. var context = aContext || null;
  1136. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  1137. var mappings;
  1138. switch (order) {
  1139. case SourceMapConsumer.GENERATED_ORDER:
  1140. mappings = this._generatedMappings;
  1141. break;
  1142. case SourceMapConsumer.ORIGINAL_ORDER:
  1143. mappings = this._originalMappings;
  1144. break;
  1145. default:
  1146. throw new Error("Unknown order of iteration.");
  1147. }
  1148. var sourceRoot = this.sourceRoot;
  1149. mappings.map(function(mapping) {
  1150. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  1151. source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  1152. return {
  1153. source,
  1154. generatedLine: mapping.generatedLine,
  1155. generatedColumn: mapping.generatedColumn,
  1156. originalLine: mapping.originalLine,
  1157. originalColumn: mapping.originalColumn,
  1158. name: mapping.name === null ? null : this._names.at(mapping.name)
  1159. };
  1160. }, this).forEach(aCallback, context);
  1161. };
  1162. SourceMapConsumer.prototype.allGeneratedPositionsFor = function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  1163. var line = util.getArg(aArgs, "line");
  1164. var needle = {
  1165. source: util.getArg(aArgs, "source"),
  1166. originalLine: line,
  1167. originalColumn: util.getArg(aArgs, "column", 0)
  1168. };
  1169. needle.source = this._findSourceIndex(needle.source);
  1170. if (needle.source < 0) {
  1171. return [];
  1172. }
  1173. var mappings = [];
  1174. var index = this._findMapping(
  1175. needle,
  1176. this._originalMappings,
  1177. "originalLine",
  1178. "originalColumn",
  1179. util.compareByOriginalPositions,
  1180. binarySearch.LEAST_UPPER_BOUND
  1181. );
  1182. if (index >= 0) {
  1183. var mapping = this._originalMappings[index];
  1184. if (aArgs.column === void 0) {
  1185. var originalLine = mapping.originalLine;
  1186. while (mapping && mapping.originalLine === originalLine) {
  1187. mappings.push({
  1188. line: util.getArg(mapping, "generatedLine", null),
  1189. column: util.getArg(mapping, "generatedColumn", null),
  1190. lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
  1191. });
  1192. mapping = this._originalMappings[++index];
  1193. }
  1194. } else {
  1195. var originalColumn = mapping.originalColumn;
  1196. while (mapping && mapping.originalLine === line && mapping.originalColumn == originalColumn) {
  1197. mappings.push({
  1198. line: util.getArg(mapping, "generatedLine", null),
  1199. column: util.getArg(mapping, "generatedColumn", null),
  1200. lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
  1201. });
  1202. mapping = this._originalMappings[++index];
  1203. }
  1204. }
  1205. }
  1206. return mappings;
  1207. };
  1208. exports.SourceMapConsumer = SourceMapConsumer;
  1209. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  1210. var sourceMap = aSourceMap;
  1211. if (typeof aSourceMap === "string") {
  1212. sourceMap = util.parseSourceMapInput(aSourceMap);
  1213. }
  1214. var version = util.getArg(sourceMap, "version");
  1215. var sources = util.getArg(sourceMap, "sources");
  1216. var names = util.getArg(sourceMap, "names", []);
  1217. var sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
  1218. var sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
  1219. var mappings = util.getArg(sourceMap, "mappings");
  1220. var file = util.getArg(sourceMap, "file", null);
  1221. if (version != this._version) {
  1222. throw new Error("Unsupported version: " + version);
  1223. }
  1224. if (sourceRoot) {
  1225. sourceRoot = util.normalize(sourceRoot);
  1226. }
  1227. sources = sources.map(String).map(util.normalize).map(function(source) {
  1228. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) ? util.relative(sourceRoot, source) : source;
  1229. });
  1230. this._names = ArraySet.fromArray(names.map(String), true);
  1231. this._sources = ArraySet.fromArray(sources, true);
  1232. this._absoluteSources = this._sources.toArray().map(function(s) {
  1233. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  1234. });
  1235. this.sourceRoot = sourceRoot;
  1236. this.sourcesContent = sourcesContent;
  1237. this._mappings = mappings;
  1238. this._sourceMapURL = aSourceMapURL;
  1239. this.file = file;
  1240. }
  1241. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  1242. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  1243. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  1244. var relativeSource = aSource;
  1245. if (this.sourceRoot != null) {
  1246. relativeSource = util.relative(this.sourceRoot, relativeSource);
  1247. }
  1248. if (this._sources.has(relativeSource)) {
  1249. return this._sources.indexOf(relativeSource);
  1250. }
  1251. var i;
  1252. for (i = 0; i < this._absoluteSources.length; ++i) {
  1253. if (this._absoluteSources[i] == aSource) {
  1254. return i;
  1255. }
  1256. }
  1257. return -1;
  1258. };
  1259. BasicSourceMapConsumer.fromSourceMap = function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  1260. var smc = Object.create(BasicSourceMapConsumer.prototype);
  1261. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  1262. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  1263. smc.sourceRoot = aSourceMap._sourceRoot;
  1264. smc.sourcesContent = aSourceMap._generateSourcesContent(
  1265. smc._sources.toArray(),
  1266. smc.sourceRoot
  1267. );
  1268. smc.file = aSourceMap._file;
  1269. smc._sourceMapURL = aSourceMapURL;
  1270. smc._absoluteSources = smc._sources.toArray().map(function(s) {
  1271. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  1272. });
  1273. var generatedMappings = aSourceMap._mappings.toArray().slice();
  1274. var destGeneratedMappings = smc.__generatedMappings = [];
  1275. var destOriginalMappings = smc.__originalMappings = [];
  1276. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  1277. var srcMapping = generatedMappings[i];
  1278. var destMapping = new Mapping();
  1279. destMapping.generatedLine = srcMapping.generatedLine;
  1280. destMapping.generatedColumn = srcMapping.generatedColumn;
  1281. if (srcMapping.source) {
  1282. destMapping.source = sources.indexOf(srcMapping.source);
  1283. destMapping.originalLine = srcMapping.originalLine;
  1284. destMapping.originalColumn = srcMapping.originalColumn;
  1285. if (srcMapping.name) {
  1286. destMapping.name = names.indexOf(srcMapping.name);
  1287. }
  1288. destOriginalMappings.push(destMapping);
  1289. }
  1290. destGeneratedMappings.push(destMapping);
  1291. }
  1292. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  1293. return smc;
  1294. };
  1295. BasicSourceMapConsumer.prototype._version = 3;
  1296. Object.defineProperty(BasicSourceMapConsumer.prototype, "sources", {
  1297. get: function() {
  1298. return this._absoluteSources.slice();
  1299. }
  1300. });
  1301. function Mapping() {
  1302. this.generatedLine = 0;
  1303. this.generatedColumn = 0;
  1304. this.source = null;
  1305. this.originalLine = null;
  1306. this.originalColumn = null;
  1307. this.name = null;
  1308. }
  1309. BasicSourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  1310. var generatedLine = 1;
  1311. var previousGeneratedColumn = 0;
  1312. var previousOriginalLine = 0;
  1313. var previousOriginalColumn = 0;
  1314. var previousSource = 0;
  1315. var previousName = 0;
  1316. var length = aStr.length;
  1317. var index = 0;
  1318. var cachedSegments = {};
  1319. var temp = {};
  1320. var originalMappings = [];
  1321. var generatedMappings = [];
  1322. var mapping, str, segment, end, value;
  1323. while (index < length) {
  1324. if (aStr.charAt(index) === ";") {
  1325. generatedLine++;
  1326. index++;
  1327. previousGeneratedColumn = 0;
  1328. } else if (aStr.charAt(index) === ",") {
  1329. index++;
  1330. } else {
  1331. mapping = new Mapping();
  1332. mapping.generatedLine = generatedLine;
  1333. for (end = index; end < length; end++) {
  1334. if (this._charIsMappingSeparator(aStr, end)) {
  1335. break;
  1336. }
  1337. }
  1338. str = aStr.slice(index, end);
  1339. segment = cachedSegments[str];
  1340. if (segment) {
  1341. index += str.length;
  1342. } else {
  1343. segment = [];
  1344. while (index < end) {
  1345. base64VLQ.decode(aStr, index, temp);
  1346. value = temp.value;
  1347. index = temp.rest;
  1348. segment.push(value);
  1349. }
  1350. if (segment.length === 2) {
  1351. throw new Error("Found a source, but no line and column");
  1352. }
  1353. if (segment.length === 3) {
  1354. throw new Error("Found a source and line, but no column");
  1355. }
  1356. cachedSegments[str] = segment;
  1357. }
  1358. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  1359. previousGeneratedColumn = mapping.generatedColumn;
  1360. if (segment.length > 1) {
  1361. mapping.source = previousSource + segment[1];
  1362. previousSource += segment[1];
  1363. mapping.originalLine = previousOriginalLine + segment[2];
  1364. previousOriginalLine = mapping.originalLine;
  1365. mapping.originalLine += 1;
  1366. mapping.originalColumn = previousOriginalColumn + segment[3];
  1367. previousOriginalColumn = mapping.originalColumn;
  1368. if (segment.length > 4) {
  1369. mapping.name = previousName + segment[4];
  1370. previousName += segment[4];
  1371. }
  1372. }
  1373. generatedMappings.push(mapping);
  1374. if (typeof mapping.originalLine === "number") {
  1375. originalMappings.push(mapping);
  1376. }
  1377. }
  1378. }
  1379. quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
  1380. this.__generatedMappings = generatedMappings;
  1381. quickSort(originalMappings, util.compareByOriginalPositions);
  1382. this.__originalMappings = originalMappings;
  1383. };
  1384. BasicSourceMapConsumer.prototype._findMapping = function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, aColumnName, aComparator, aBias) {
  1385. if (aNeedle[aLineName] <= 0) {
  1386. throw new TypeError("Line must be greater than or equal to 1, got " + aNeedle[aLineName]);
  1387. }
  1388. if (aNeedle[aColumnName] < 0) {
  1389. throw new TypeError("Column must be greater than or equal to 0, got " + aNeedle[aColumnName]);
  1390. }
  1391. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  1392. };
  1393. BasicSourceMapConsumer.prototype.computeColumnSpans = function SourceMapConsumer_computeColumnSpans() {
  1394. for (var index = 0; index < this._generatedMappings.length; ++index) {
  1395. var mapping = this._generatedMappings[index];
  1396. if (index + 1 < this._generatedMappings.length) {
  1397. var nextMapping = this._generatedMappings[index + 1];
  1398. if (mapping.generatedLine === nextMapping.generatedLine) {
  1399. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  1400. continue;
  1401. }
  1402. }
  1403. mapping.lastGeneratedColumn = Infinity;
  1404. }
  1405. };
  1406. BasicSourceMapConsumer.prototype.originalPositionFor = function SourceMapConsumer_originalPositionFor(aArgs) {
  1407. var needle = {
  1408. generatedLine: util.getArg(aArgs, "line"),
  1409. generatedColumn: util.getArg(aArgs, "column")
  1410. };
  1411. var index = this._findMapping(
  1412. needle,
  1413. this._generatedMappings,
  1414. "generatedLine",
  1415. "generatedColumn",
  1416. util.compareByGeneratedPositionsDeflated,
  1417. util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND)
  1418. );
  1419. if (index >= 0) {
  1420. var mapping = this._generatedMappings[index];
  1421. if (mapping.generatedLine === needle.generatedLine) {
  1422. var source = util.getArg(mapping, "source", null);
  1423. if (source !== null) {
  1424. source = this._sources.at(source);
  1425. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  1426. }
  1427. var name = util.getArg(mapping, "name", null);
  1428. if (name !== null) {
  1429. name = this._names.at(name);
  1430. }
  1431. return {
  1432. source,
  1433. line: util.getArg(mapping, "originalLine", null),
  1434. column: util.getArg(mapping, "originalColumn", null),
  1435. name
  1436. };
  1437. }
  1438. }
  1439. return {
  1440. source: null,
  1441. line: null,
  1442. column: null,
  1443. name: null
  1444. };
  1445. };
  1446. BasicSourceMapConsumer.prototype.hasContentsOfAllSources = function BasicSourceMapConsumer_hasContentsOfAllSources() {
  1447. if (!this.sourcesContent) {
  1448. return false;
  1449. }
  1450. return this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function(sc) {
  1451. return sc == null;
  1452. });
  1453. };
  1454. BasicSourceMapConsumer.prototype.sourceContentFor = function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  1455. if (!this.sourcesContent) {
  1456. return null;
  1457. }
  1458. var index = this._findSourceIndex(aSource);
  1459. if (index >= 0) {
  1460. return this.sourcesContent[index];
  1461. }
  1462. var relativeSource = aSource;
  1463. if (this.sourceRoot != null) {
  1464. relativeSource = util.relative(this.sourceRoot, relativeSource);
  1465. }
  1466. var url;
  1467. if (this.sourceRoot != null && (url = util.urlParse(this.sourceRoot))) {
  1468. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  1469. if (url.scheme == "file" && this._sources.has(fileUriAbsPath)) {
  1470. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
  1471. }
  1472. if ((!url.path || url.path == "/") && this._sources.has("/" + relativeSource)) {
  1473. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  1474. }
  1475. }
  1476. if (nullOnMissing) {
  1477. return null;
  1478. } else {
  1479. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  1480. }
  1481. };
  1482. BasicSourceMapConsumer.prototype.generatedPositionFor = function SourceMapConsumer_generatedPositionFor(aArgs) {
  1483. var source = util.getArg(aArgs, "source");
  1484. source = this._findSourceIndex(source);
  1485. if (source < 0) {
  1486. return {
  1487. line: null,
  1488. column: null,
  1489. lastColumn: null
  1490. };
  1491. }
  1492. var needle = {
  1493. source,
  1494. originalLine: util.getArg(aArgs, "line"),
  1495. originalColumn: util.getArg(aArgs, "column")
  1496. };
  1497. var index = this._findMapping(
  1498. needle,
  1499. this._originalMappings,
  1500. "originalLine",
  1501. "originalColumn",
  1502. util.compareByOriginalPositions,
  1503. util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND)
  1504. );
  1505. if (index >= 0) {
  1506. var mapping = this._originalMappings[index];
  1507. if (mapping.source === needle.source) {
  1508. return {
  1509. line: util.getArg(mapping, "generatedLine", null),
  1510. column: util.getArg(mapping, "generatedColumn", null),
  1511. lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
  1512. };
  1513. }
  1514. }
  1515. return {
  1516. line: null,
  1517. column: null,
  1518. lastColumn: null
  1519. };
  1520. };
  1521. exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
  1522. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  1523. var sourceMap = aSourceMap;
  1524. if (typeof aSourceMap === "string") {
  1525. sourceMap = util.parseSourceMapInput(aSourceMap);
  1526. }
  1527. var version = util.getArg(sourceMap, "version");
  1528. var sections = util.getArg(sourceMap, "sections");
  1529. if (version != this._version) {
  1530. throw new Error("Unsupported version: " + version);
  1531. }
  1532. this._sources = new ArraySet();
  1533. this._names = new ArraySet();
  1534. var lastOffset = {
  1535. line: -1,
  1536. column: 0
  1537. };
  1538. this._sections = sections.map(function(s) {
  1539. if (s.url) {
  1540. throw new Error("Support for url field in sections not implemented.");
  1541. }
  1542. var offset = util.getArg(s, "offset");
  1543. var offsetLine = util.getArg(offset, "line");
  1544. var offsetColumn = util.getArg(offset, "column");
  1545. if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
  1546. throw new Error("Section offsets must be ordered and non-overlapping.");
  1547. }
  1548. lastOffset = offset;
  1549. return {
  1550. generatedOffset: {
  1551. generatedLine: offsetLine + 1,
  1552. generatedColumn: offsetColumn + 1
  1553. },
  1554. consumer: new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL)
  1555. };
  1556. });
  1557. }
  1558. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  1559. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  1560. IndexedSourceMapConsumer.prototype._version = 3;
  1561. Object.defineProperty(IndexedSourceMapConsumer.prototype, "sources", {
  1562. get: function() {
  1563. var sources = [];
  1564. for (var i = 0; i < this._sections.length; i++) {
  1565. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  1566. sources.push(this._sections[i].consumer.sources[j]);
  1567. }
  1568. }
  1569. return sources;
  1570. }
  1571. });
  1572. IndexedSourceMapConsumer.prototype.originalPositionFor = function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  1573. var needle = {
  1574. generatedLine: util.getArg(aArgs, "line"),
  1575. generatedColumn: util.getArg(aArgs, "column")
  1576. };
  1577. var sectionIndex = binarySearch.search(
  1578. needle,
  1579. this._sections,
  1580. function(needle2, section2) {
  1581. var cmp = needle2.generatedLine - section2.generatedOffset.generatedLine;
  1582. if (cmp) {
  1583. return cmp;
  1584. }
  1585. return needle2.generatedColumn - section2.generatedOffset.generatedColumn;
  1586. }
  1587. );
  1588. var section = this._sections[sectionIndex];
  1589. if (!section) {
  1590. return {
  1591. source: null,
  1592. line: null,
  1593. column: null,
  1594. name: null
  1595. };
  1596. }
  1597. return section.consumer.originalPositionFor({
  1598. line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
  1599. column: needle.generatedColumn - (section.generatedOffset.generatedLine === needle.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0),
  1600. bias: aArgs.bias
  1601. });
  1602. };
  1603. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  1604. return this._sections.every(function(s) {
  1605. return s.consumer.hasContentsOfAllSources();
  1606. });
  1607. };
  1608. IndexedSourceMapConsumer.prototype.sourceContentFor = function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  1609. for (var i = 0; i < this._sections.length; i++) {
  1610. var section = this._sections[i];
  1611. var content = section.consumer.sourceContentFor(aSource, true);
  1612. if (content) {
  1613. return content;
  1614. }
  1615. }
  1616. if (nullOnMissing) {
  1617. return null;
  1618. } else {
  1619. throw new Error('"' + aSource + '" is not in the SourceMap.');
  1620. }
  1621. };
  1622. IndexedSourceMapConsumer.prototype.generatedPositionFor = function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  1623. for (var i = 0; i < this._sections.length; i++) {
  1624. var section = this._sections[i];
  1625. if (section.consumer._findSourceIndex(util.getArg(aArgs, "source")) === -1) {
  1626. continue;
  1627. }
  1628. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  1629. if (generatedPosition) {
  1630. var ret = {
  1631. line: generatedPosition.line + (section.generatedOffset.generatedLine - 1),
  1632. column: generatedPosition.column + (section.generatedOffset.generatedLine === generatedPosition.line ? section.generatedOffset.generatedColumn - 1 : 0)
  1633. };
  1634. return ret;
  1635. }
  1636. }
  1637. return {
  1638. line: null,
  1639. column: null
  1640. };
  1641. };
  1642. IndexedSourceMapConsumer.prototype._parseMappings = function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  1643. this.__generatedMappings = [];
  1644. this.__originalMappings = [];
  1645. for (var i = 0; i < this._sections.length; i++) {
  1646. var section = this._sections[i];
  1647. var sectionMappings = section.consumer._generatedMappings;
  1648. for (var j = 0; j < sectionMappings.length; j++) {
  1649. var mapping = sectionMappings[j];
  1650. var source = section.consumer._sources.at(mapping.source);
  1651. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  1652. this._sources.add(source);
  1653. source = this._sources.indexOf(source);
  1654. var name = null;
  1655. if (mapping.name) {
  1656. name = section.consumer._names.at(mapping.name);
  1657. this._names.add(name);
  1658. name = this._names.indexOf(name);
  1659. }
  1660. var adjustedMapping = {
  1661. source,
  1662. generatedLine: mapping.generatedLine + (section.generatedOffset.generatedLine - 1),
  1663. generatedColumn: mapping.generatedColumn + (section.generatedOffset.generatedLine === mapping.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0),
  1664. originalLine: mapping.originalLine,
  1665. originalColumn: mapping.originalColumn,
  1666. name
  1667. };
  1668. this.__generatedMappings.push(adjustedMapping);
  1669. if (typeof adjustedMapping.originalLine === "number") {
  1670. this.__originalMappings.push(adjustedMapping);
  1671. }
  1672. }
  1673. }
  1674. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  1675. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  1676. };
  1677. exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  1678. }
  1679. });
  1680. // node_modules/source-map/lib/source-node.js
  1681. var require_source_node = __commonJS({
  1682. "node_modules/source-map/lib/source-node.js"(exports) {
  1683. init_define_APP_INFO();
  1684. var SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
  1685. var util = require_util();
  1686. var REGEX_NEWLINE = /(\r?\n)/;
  1687. var NEWLINE_CODE = 10;
  1688. var isSourceNode = "$$$isSourceNode$$$";
  1689. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  1690. this.children = [];
  1691. this.sourceContents = {};
  1692. this.line = aLine == null ? null : aLine;
  1693. this.column = aColumn == null ? null : aColumn;
  1694. this.source = aSource == null ? null : aSource;
  1695. this.name = aName == null ? null : aName;
  1696. this[isSourceNode] = true;
  1697. if (aChunks != null)
  1698. this.add(aChunks);
  1699. }
  1700. SourceNode.fromStringWithSourceMap = function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  1701. var node = new SourceNode();
  1702. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  1703. var remainingLinesIndex = 0;
  1704. var shiftNextLine = function() {
  1705. var lineContents = getNextLine();
  1706. var newLine = getNextLine() || "";
  1707. return lineContents + newLine;
  1708. function getNextLine() {
  1709. return remainingLinesIndex < remainingLines.length ? remainingLines[remainingLinesIndex++] : void 0;
  1710. }
  1711. };
  1712. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  1713. var lastMapping = null;
  1714. aSourceMapConsumer.eachMapping(function(mapping) {
  1715. if (lastMapping !== null) {
  1716. if (lastGeneratedLine < mapping.generatedLine) {
  1717. addMappingWithCode(lastMapping, shiftNextLine());
  1718. lastGeneratedLine++;
  1719. lastGeneratedColumn = 0;
  1720. } else {
  1721. var nextLine = remainingLines[remainingLinesIndex] || "";
  1722. var code = nextLine.substr(0, mapping.generatedColumn - lastGeneratedColumn);
  1723. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - lastGeneratedColumn);
  1724. lastGeneratedColumn = mapping.generatedColumn;
  1725. addMappingWithCode(lastMapping, code);
  1726. lastMapping = mapping;
  1727. return;
  1728. }
  1729. }
  1730. while (lastGeneratedLine < mapping.generatedLine) {
  1731. node.add(shiftNextLine());
  1732. lastGeneratedLine++;
  1733. }
  1734. if (lastGeneratedColumn < mapping.generatedColumn) {
  1735. var nextLine = remainingLines[remainingLinesIndex] || "";
  1736. node.add(nextLine.substr(0, mapping.generatedColumn));
  1737. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  1738. lastGeneratedColumn = mapping.generatedColumn;
  1739. }
  1740. lastMapping = mapping;
  1741. }, this);
  1742. if (remainingLinesIndex < remainingLines.length) {
  1743. if (lastMapping) {
  1744. addMappingWithCode(lastMapping, shiftNextLine());
  1745. }
  1746. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  1747. }
  1748. aSourceMapConsumer.sources.forEach(function(sourceFile) {
  1749. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  1750. if (content != null) {
  1751. if (aRelativePath != null) {
  1752. sourceFile = util.join(aRelativePath, sourceFile);
  1753. }
  1754. node.setSourceContent(sourceFile, content);
  1755. }
  1756. });
  1757. return node;
  1758. function addMappingWithCode(mapping, code) {
  1759. if (mapping === null || mapping.source === void 0) {
  1760. node.add(code);
  1761. } else {
  1762. var source = aRelativePath ? util.join(aRelativePath, mapping.source) : mapping.source;
  1763. node.add(new SourceNode(
  1764. mapping.originalLine,
  1765. mapping.originalColumn,
  1766. source,
  1767. code,
  1768. mapping.name
  1769. ));
  1770. }
  1771. }
  1772. };
  1773. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  1774. if (Array.isArray(aChunk)) {
  1775. aChunk.forEach(function(chunk) {
  1776. this.add(chunk);
  1777. }, this);
  1778. } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  1779. if (aChunk) {
  1780. this.children.push(aChunk);
  1781. }
  1782. } else {
  1783. throw new TypeError(
  1784. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  1785. );
  1786. }
  1787. return this;
  1788. };
  1789. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  1790. if (Array.isArray(aChunk)) {
  1791. for (var i = aChunk.length - 1; i >= 0; i--) {
  1792. this.prepend(aChunk[i]);
  1793. }
  1794. } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  1795. this.children.unshift(aChunk);
  1796. } else {
  1797. throw new TypeError(
  1798. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  1799. );
  1800. }
  1801. return this;
  1802. };
  1803. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  1804. var chunk;
  1805. for (var i = 0, len = this.children.length; i < len; i++) {
  1806. chunk = this.children[i];
  1807. if (chunk[isSourceNode]) {
  1808. chunk.walk(aFn);
  1809. } else {
  1810. if (chunk !== "") {
  1811. aFn(chunk, {
  1812. source: this.source,
  1813. line: this.line,
  1814. column: this.column,
  1815. name: this.name
  1816. });
  1817. }
  1818. }
  1819. }
  1820. };
  1821. SourceNode.prototype.join = function SourceNode_join(aSep) {
  1822. var newChildren;
  1823. var i;
  1824. var len = this.children.length;
  1825. if (len > 0) {
  1826. newChildren = [];
  1827. for (i = 0; i < len - 1; i++) {
  1828. newChildren.push(this.children[i]);
  1829. newChildren.push(aSep);
  1830. }
  1831. newChildren.push(this.children[i]);
  1832. this.children = newChildren;
  1833. }
  1834. return this;
  1835. };
  1836. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  1837. var lastChild = this.children[this.children.length - 1];
  1838. if (lastChild[isSourceNode]) {
  1839. lastChild.replaceRight(aPattern, aReplacement);
  1840. } else if (typeof lastChild === "string") {
  1841. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  1842. } else {
  1843. this.children.push("".replace(aPattern, aReplacement));
  1844. }
  1845. return this;
  1846. };
  1847. SourceNode.prototype.setSourceContent = function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  1848. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  1849. };
  1850. SourceNode.prototype.walkSourceContents = function SourceNode_walkSourceContents(aFn) {
  1851. for (var i = 0, len = this.children.length; i < len; i++) {
  1852. if (this.children[i][isSourceNode]) {
  1853. this.children[i].walkSourceContents(aFn);
  1854. }
  1855. }
  1856. var sources = Object.keys(this.sourceContents);
  1857. for (var i = 0, len = sources.length; i < len; i++) {
  1858. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  1859. }
  1860. };
  1861. SourceNode.prototype.toString = function SourceNode_toString() {
  1862. var str = "";
  1863. this.walk(function(chunk) {
  1864. str += chunk;
  1865. });
  1866. return str;
  1867. };
  1868. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  1869. var generated = {
  1870. code: "",
  1871. line: 1,
  1872. column: 0
  1873. };
  1874. var map = new SourceMapGenerator(aArgs);
  1875. var sourceMappingActive = false;
  1876. var lastOriginalSource = null;
  1877. var lastOriginalLine = null;
  1878. var lastOriginalColumn = null;
  1879. var lastOriginalName = null;
  1880. this.walk(function(chunk, original) {
  1881. generated.code += chunk;
  1882. if (original.source !== null && original.line !== null && original.column !== null) {
  1883. if (lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) {
  1884. map.addMapping({
  1885. source: original.source,
  1886. original: {
  1887. line: original.line,
  1888. column: original.column
  1889. },
  1890. generated: {
  1891. line: generated.line,
  1892. column: generated.column
  1893. },
  1894. name: original.name
  1895. });
  1896. }
  1897. lastOriginalSource = original.source;
  1898. lastOriginalLine = original.line;
  1899. lastOriginalColumn = original.column;
  1900. lastOriginalName = original.name;
  1901. sourceMappingActive = true;
  1902. } else if (sourceMappingActive) {
  1903. map.addMapping({
  1904. generated: {
  1905. line: generated.line,
  1906. column: generated.column
  1907. }
  1908. });
  1909. lastOriginalSource = null;
  1910. sourceMappingActive = false;
  1911. }
  1912. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  1913. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  1914. generated.line++;
  1915. generated.column = 0;
  1916. if (idx + 1 === length) {
  1917. lastOriginalSource = null;
  1918. sourceMappingActive = false;
  1919. } else if (sourceMappingActive) {
  1920. map.addMapping({
  1921. source: original.source,
  1922. original: {
  1923. line: original.line,
  1924. column: original.column
  1925. },
  1926. generated: {
  1927. line: generated.line,
  1928. column: generated.column
  1929. },
  1930. name: original.name
  1931. });
  1932. }
  1933. } else {
  1934. generated.column++;
  1935. }
  1936. }
  1937. });
  1938. this.walkSourceContents(function(sourceFile, sourceContent) {
  1939. map.setSourceContent(sourceFile, sourceContent);
  1940. });
  1941. return { code: generated.code, map };
  1942. };
  1943. exports.SourceNode = SourceNode;
  1944. }
  1945. });
  1946. // node_modules/source-map/source-map.js
  1947. var require_source_map = __commonJS({
  1948. "node_modules/source-map/source-map.js"(exports) {
  1949. init_define_APP_INFO();
  1950. exports.SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
  1951. exports.SourceMapConsumer = require_source_map_consumer().SourceMapConsumer;
  1952. exports.SourceNode = require_source_node().SourceNode;
  1953. }
  1954. });
  1955. // node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js
  1956. var require_message_compiler_cjs = __commonJS({
  1957. "node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js"(exports) {
  1958. "use strict";
  1959. init_define_APP_INFO();
  1960. Object.defineProperty(exports, "__esModule", { value: true });
  1961. var shared = require_shared();
  1962. var sourceMap = require_source_map();
  1963. var CompileErrorCodes = {
  1964. EXPECTED_TOKEN: 1,
  1965. INVALID_TOKEN_IN_PLACEHOLDER: 2,
  1966. UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
  1967. UNKNOWN_ESCAPE_SEQUENCE: 4,
  1968. INVALID_UNICODE_ESCAPE_SEQUENCE: 5,
  1969. UNBALANCED_CLOSING_BRACE: 6,
  1970. UNTERMINATED_CLOSING_BRACE: 7,
  1971. EMPTY_PLACEHOLDER: 8,
  1972. NOT_ALLOW_NEST_PLACEHOLDER: 9,
  1973. INVALID_LINKED_FORMAT: 10,
  1974. MUST_HAVE_MESSAGES_IN_PLURAL: 11,
  1975. UNEXPECTED_EMPTY_LINKED_MODIFIER: 12,
  1976. UNEXPECTED_EMPTY_LINKED_KEY: 13,
  1977. UNEXPECTED_LEXICAL_ANALYSIS: 14,
  1978. __EXTEND_POINT__: 15
  1979. };
  1980. var errorMessages2 = {
  1981. [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`,
  1982. [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`,
  1983. [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`,
  1984. [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`,
  1985. [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`,
  1986. [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`,
  1987. [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`,
  1988. [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`,
  1989. [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`,
  1990. [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`,
  1991. [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`,
  1992. [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`,
  1993. [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`,
  1994. [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`
  1995. };
  1996. function createCompileError(code, loc, options = {}) {
  1997. const { domain, messages, args } = options;
  1998. const msg = shared.format((messages || errorMessages2)[code] || "", ...args || []);
  1999. const error = new SyntaxError(String(msg));
  2000. error.code = code;
  2001. if (loc) {
  2002. error.location = loc;
  2003. }
  2004. error.domain = domain;
  2005. return error;
  2006. }
  2007. function defaultOnError2(error) {
  2008. throw error;
  2009. }
  2010. var LocationStub = {
  2011. start: { line: 1, column: 1, offset: 0 },
  2012. end: { line: 1, column: 1, offset: 0 }
  2013. };
  2014. function createPosition(line, column, offset) {
  2015. return { line, column, offset };
  2016. }
  2017. function createLocation(start, end, source) {
  2018. const loc = { start, end };
  2019. if (source != null) {
  2020. loc.source = source;
  2021. }
  2022. return loc;
  2023. }
  2024. var CHAR_SP = " ";
  2025. var CHAR_CR = "\r";
  2026. var CHAR_LF = "\n";
  2027. var CHAR_LS = String.fromCharCode(8232);
  2028. var CHAR_PS = String.fromCharCode(8233);
  2029. function createScanner(str) {
  2030. const _buf = str;
  2031. let _index = 0;
  2032. let _line = 1;
  2033. let _column = 1;
  2034. let _peekOffset = 0;
  2035. const isCRLF = (index2) => _buf[index2] === CHAR_CR && _buf[index2 + 1] === CHAR_LF;
  2036. const isLF = (index2) => _buf[index2] === CHAR_LF;
  2037. const isPS = (index2) => _buf[index2] === CHAR_PS;
  2038. const isLS = (index2) => _buf[index2] === CHAR_LS;
  2039. const isLineEnd = (index2) => isCRLF(index2) || isLF(index2) || isPS(index2) || isLS(index2);
  2040. const index = () => _index;
  2041. const line = () => _line;
  2042. const column = () => _column;
  2043. const peekOffset = () => _peekOffset;
  2044. const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset];
  2045. const currentChar = () => charAt(_index);
  2046. const currentPeek = () => charAt(_index + _peekOffset);
  2047. function next() {
  2048. _peekOffset = 0;
  2049. if (isLineEnd(_index)) {
  2050. _line++;
  2051. _column = 0;
  2052. }
  2053. if (isCRLF(_index)) {
  2054. _index++;
  2055. }
  2056. _index++;
  2057. _column++;
  2058. return _buf[_index];
  2059. }
  2060. function peek() {
  2061. if (isCRLF(_index + _peekOffset)) {
  2062. _peekOffset++;
  2063. }
  2064. _peekOffset++;
  2065. return _buf[_index + _peekOffset];
  2066. }
  2067. function reset() {
  2068. _index = 0;
  2069. _line = 1;
  2070. _column = 1;
  2071. _peekOffset = 0;
  2072. }
  2073. function resetPeek(offset = 0) {
  2074. _peekOffset = offset;
  2075. }
  2076. function skipToPeek() {
  2077. const target = _index + _peekOffset;
  2078. while (target !== _index) {
  2079. next();
  2080. }
  2081. _peekOffset = 0;
  2082. }
  2083. return {
  2084. index,
  2085. line,
  2086. column,
  2087. peekOffset,
  2088. charAt,
  2089. currentChar,
  2090. currentPeek,
  2091. next,
  2092. peek,
  2093. reset,
  2094. resetPeek,
  2095. skipToPeek
  2096. };
  2097. }
  2098. var EOF = void 0;
  2099. var LITERAL_DELIMITER = "'";
  2100. var ERROR_DOMAIN$1 = "tokenizer";
  2101. function createTokenizer(source, options = {}) {
  2102. const location = options.location !== false;
  2103. const _scnr = createScanner(source);
  2104. const currentOffset = () => _scnr.index();
  2105. const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index());
  2106. const _initLoc = currentPosition();
  2107. const _initOffset = currentOffset();
  2108. const _context = {
  2109. currentType: 14,
  2110. offset: _initOffset,
  2111. startLoc: _initLoc,
  2112. endLoc: _initLoc,
  2113. lastType: 14,
  2114. lastOffset: _initOffset,
  2115. lastStartLoc: _initLoc,
  2116. lastEndLoc: _initLoc,
  2117. braceNest: 0,
  2118. inLinked: false,
  2119. text: ""
  2120. };
  2121. const context = () => _context;
  2122. const { onError } = options;
  2123. function emitError2(code, pos, offset, ...args) {
  2124. const ctx = context();
  2125. pos.column += offset;
  2126. pos.offset += offset;
  2127. if (onError) {
  2128. const loc = createLocation(ctx.startLoc, pos);
  2129. const err = createCompileError(code, loc, {
  2130. domain: ERROR_DOMAIN$1,
  2131. args
  2132. });
  2133. onError(err);
  2134. }
  2135. }
  2136. function getToken(context2, type, value) {
  2137. context2.endLoc = currentPosition();
  2138. context2.currentType = type;
  2139. const token = { type };
  2140. if (location) {
  2141. token.loc = createLocation(context2.startLoc, context2.endLoc);
  2142. }
  2143. if (value != null) {
  2144. token.value = value;
  2145. }
  2146. return token;
  2147. }
  2148. const getEndToken = (context2) => getToken(context2, 14);
  2149. function eat(scnr, ch) {
  2150. if (scnr.currentChar() === ch) {
  2151. scnr.next();
  2152. return ch;
  2153. } else {
  2154. emitError2(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch);
  2155. return "";
  2156. }
  2157. }
  2158. function peekSpaces(scnr) {
  2159. let buf = "";
  2160. while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) {
  2161. buf += scnr.currentPeek();
  2162. scnr.peek();
  2163. }
  2164. return buf;
  2165. }
  2166. function skipSpaces(scnr) {
  2167. const buf = peekSpaces(scnr);
  2168. scnr.skipToPeek();
  2169. return buf;
  2170. }
  2171. function isIdentifierStart(ch) {
  2172. if (ch === EOF) {
  2173. return false;
  2174. }
  2175. const cc = ch.charCodeAt(0);
  2176. return cc >= 97 && cc <= 122 || cc >= 65 && cc <= 90 || cc === 95;
  2177. }
  2178. function isNumberStart(ch) {
  2179. if (ch === EOF) {
  2180. return false;
  2181. }
  2182. const cc = ch.charCodeAt(0);
  2183. return cc >= 48 && cc <= 57;
  2184. }
  2185. function isNamedIdentifierStart(scnr, context2) {
  2186. const { currentType } = context2;
  2187. if (currentType !== 2) {
  2188. return false;
  2189. }
  2190. peekSpaces(scnr);
  2191. const ret = isIdentifierStart(scnr.currentPeek());
  2192. scnr.resetPeek();
  2193. return ret;
  2194. }
  2195. function isListIdentifierStart(scnr, context2) {
  2196. const { currentType } = context2;
  2197. if (currentType !== 2) {
  2198. return false;
  2199. }
  2200. peekSpaces(scnr);
  2201. const ch = scnr.currentPeek() === "-" ? scnr.peek() : scnr.currentPeek();
  2202. const ret = isNumberStart(ch);
  2203. scnr.resetPeek();
  2204. return ret;
  2205. }
  2206. function isLiteralStart(scnr, context2) {
  2207. const { currentType } = context2;
  2208. if (currentType !== 2) {
  2209. return false;
  2210. }
  2211. peekSpaces(scnr);
  2212. const ret = scnr.currentPeek() === LITERAL_DELIMITER;
  2213. scnr.resetPeek();
  2214. return ret;
  2215. }
  2216. function isLinkedDotStart(scnr, context2) {
  2217. const { currentType } = context2;
  2218. if (currentType !== 8) {
  2219. return false;
  2220. }
  2221. peekSpaces(scnr);
  2222. const ret = scnr.currentPeek() === ".";
  2223. scnr.resetPeek();
  2224. return ret;
  2225. }
  2226. function isLinkedModifierStart(scnr, context2) {
  2227. const { currentType } = context2;
  2228. if (currentType !== 9) {
  2229. return false;
  2230. }
  2231. peekSpaces(scnr);
  2232. const ret = isIdentifierStart(scnr.currentPeek());
  2233. scnr.resetPeek();
  2234. return ret;
  2235. }
  2236. function isLinkedDelimiterStart(scnr, context2) {
  2237. const { currentType } = context2;
  2238. if (!(currentType === 8 || currentType === 12)) {
  2239. return false;
  2240. }
  2241. peekSpaces(scnr);
  2242. const ret = scnr.currentPeek() === ":";
  2243. scnr.resetPeek();
  2244. return ret;
  2245. }
  2246. function isLinkedReferStart(scnr, context2) {
  2247. const { currentType } = context2;
  2248. if (currentType !== 10) {
  2249. return false;
  2250. }
  2251. const fn = () => {
  2252. const ch = scnr.currentPeek();
  2253. if (ch === "{") {
  2254. return isIdentifierStart(scnr.peek());
  2255. } else if (ch === "@" || ch === "%" || ch === "|" || ch === ":" || ch === "." || ch === CHAR_SP || !ch) {
  2256. return false;
  2257. } else if (ch === CHAR_LF) {
  2258. scnr.peek();
  2259. return fn();
  2260. } else {
  2261. return isIdentifierStart(ch);
  2262. }
  2263. };
  2264. const ret = fn();
  2265. scnr.resetPeek();
  2266. return ret;
  2267. }
  2268. function isPluralStart(scnr) {
  2269. peekSpaces(scnr);
  2270. const ret = scnr.currentPeek() === "|";
  2271. scnr.resetPeek();
  2272. return ret;
  2273. }
  2274. function detectModuloStart(scnr) {
  2275. const spaces = peekSpaces(scnr);
  2276. const ret = scnr.currentPeek() === "%" && scnr.peek() === "{";
  2277. scnr.resetPeek();
  2278. return {
  2279. isModulo: ret,
  2280. hasSpace: spaces.length > 0
  2281. };
  2282. }
  2283. function isTextStart(scnr, reset = true) {
  2284. const fn = (hasSpace = false, prev = "", detectModulo = false) => {
  2285. const ch = scnr.currentPeek();
  2286. if (ch === "{") {
  2287. return prev === "%" ? false : hasSpace;
  2288. } else if (ch === "@" || !ch) {
  2289. return prev === "%" ? true : hasSpace;
  2290. } else if (ch === "%") {
  2291. scnr.peek();
  2292. return fn(hasSpace, "%", true);
  2293. } else if (ch === "|") {
  2294. return prev === "%" || detectModulo ? true : !(prev === CHAR_SP || prev === CHAR_LF);
  2295. } else if (ch === CHAR_SP) {
  2296. scnr.peek();
  2297. return fn(true, CHAR_SP, detectModulo);
  2298. } else if (ch === CHAR_LF) {
  2299. scnr.peek();
  2300. return fn(true, CHAR_LF, detectModulo);
  2301. } else {
  2302. return true;
  2303. }
  2304. };
  2305. const ret = fn();
  2306. reset && scnr.resetPeek();
  2307. return ret;
  2308. }
  2309. function takeChar(scnr, fn) {
  2310. const ch = scnr.currentChar();
  2311. if (ch === EOF) {
  2312. return EOF;
  2313. }
  2314. if (fn(ch)) {
  2315. scnr.next();
  2316. return ch;
  2317. }
  2318. return null;
  2319. }
  2320. function takeIdentifierChar(scnr) {
  2321. const closure = (ch) => {
  2322. const cc = ch.charCodeAt(0);
  2323. return cc >= 97 && cc <= 122 || cc >= 65 && cc <= 90 || cc >= 48 && cc <= 57 || cc === 95 || cc === 36;
  2324. };
  2325. return takeChar(scnr, closure);
  2326. }
  2327. function takeDigit(scnr) {
  2328. const closure = (ch) => {
  2329. const cc = ch.charCodeAt(0);
  2330. return cc >= 48 && cc <= 57;
  2331. };
  2332. return takeChar(scnr, closure);
  2333. }
  2334. function takeHexDigit(scnr) {
  2335. const closure = (ch) => {
  2336. const cc = ch.charCodeAt(0);
  2337. return cc >= 48 && cc <= 57 || cc >= 65 && cc <= 70 || cc >= 97 && cc <= 102;
  2338. };
  2339. return takeChar(scnr, closure);
  2340. }
  2341. function getDigits(scnr) {
  2342. let ch = "";
  2343. let num = "";
  2344. while (ch = takeDigit(scnr)) {
  2345. num += ch;
  2346. }
  2347. return num;
  2348. }
  2349. function readModulo(scnr) {
  2350. skipSpaces(scnr);
  2351. const ch = scnr.currentChar();
  2352. if (ch !== "%") {
  2353. emitError2(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch);
  2354. }
  2355. scnr.next();
  2356. return "%";
  2357. }
  2358. function readText(scnr) {
  2359. let buf = "";
  2360. while (true) {
  2361. const ch = scnr.currentChar();
  2362. if (ch === "{" || ch === "}" || ch === "@" || ch === "|" || !ch) {
  2363. break;
  2364. } else if (ch === "%") {
  2365. if (isTextStart(scnr)) {
  2366. buf += ch;
  2367. scnr.next();
  2368. } else {
  2369. break;
  2370. }
  2371. } else if (ch === CHAR_SP || ch === CHAR_LF) {
  2372. if (isTextStart(scnr)) {
  2373. buf += ch;
  2374. scnr.next();
  2375. } else if (isPluralStart(scnr)) {
  2376. break;
  2377. } else {
  2378. buf += ch;
  2379. scnr.next();
  2380. }
  2381. } else {
  2382. buf += ch;
  2383. scnr.next();
  2384. }
  2385. }
  2386. return buf;
  2387. }
  2388. function readNamedIdentifier(scnr) {
  2389. skipSpaces(scnr);
  2390. let ch = "";
  2391. let name = "";
  2392. while (ch = takeIdentifierChar(scnr)) {
  2393. name += ch;
  2394. }
  2395. if (scnr.currentChar() === EOF) {
  2396. emitError2(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
  2397. }
  2398. return name;
  2399. }
  2400. function readListIdentifier(scnr) {
  2401. skipSpaces(scnr);
  2402. let value = "";
  2403. if (scnr.currentChar() === "-") {
  2404. scnr.next();
  2405. value += `-${getDigits(scnr)}`;
  2406. } else {
  2407. value += getDigits(scnr);
  2408. }
  2409. if (scnr.currentChar() === EOF) {
  2410. emitError2(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
  2411. }
  2412. return value;
  2413. }
  2414. function readLiteral(scnr) {
  2415. skipSpaces(scnr);
  2416. eat(scnr, `'`);
  2417. let ch = "";
  2418. let literal = "";
  2419. const fn = (x) => x !== LITERAL_DELIMITER && x !== CHAR_LF;
  2420. while (ch = takeChar(scnr, fn)) {
  2421. if (ch === "\\") {
  2422. literal += readEscapeSequence(scnr);
  2423. } else {
  2424. literal += ch;
  2425. }
  2426. }
  2427. const current = scnr.currentChar();
  2428. if (current === CHAR_LF || current === EOF) {
  2429. emitError2(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0);
  2430. if (current === CHAR_LF) {
  2431. scnr.next();
  2432. eat(scnr, `'`);
  2433. }
  2434. return literal;
  2435. }
  2436. eat(scnr, `'`);
  2437. return literal;
  2438. }
  2439. function readEscapeSequence(scnr) {
  2440. const ch = scnr.currentChar();
  2441. switch (ch) {
  2442. case "\\":
  2443. case `'`:
  2444. scnr.next();
  2445. return `\\${ch}`;
  2446. case "u":
  2447. return readUnicodeEscapeSequence(scnr, ch, 4);
  2448. case "U":
  2449. return readUnicodeEscapeSequence(scnr, ch, 6);
  2450. default:
  2451. emitError2(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch);
  2452. return "";
  2453. }
  2454. }
  2455. function readUnicodeEscapeSequence(scnr, unicode, digits) {
  2456. eat(scnr, unicode);
  2457. let sequence = "";
  2458. for (let i = 0; i < digits; i++) {
  2459. const ch = takeHexDigit(scnr);
  2460. if (!ch) {
  2461. emitError2(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`);
  2462. break;
  2463. }
  2464. sequence += ch;
  2465. }
  2466. return `\\${unicode}${sequence}`;
  2467. }
  2468. function readInvalidIdentifier(scnr) {
  2469. skipSpaces(scnr);
  2470. let ch = "";
  2471. let identifiers = "";
  2472. const closure = (ch2) => ch2 !== "{" && ch2 !== "}" && ch2 !== CHAR_SP && ch2 !== CHAR_LF;
  2473. while (ch = takeChar(scnr, closure)) {
  2474. identifiers += ch;
  2475. }
  2476. return identifiers;
  2477. }
  2478. function readLinkedModifier(scnr) {
  2479. let ch = "";
  2480. let name = "";
  2481. while (ch = takeIdentifierChar(scnr)) {
  2482. name += ch;
  2483. }
  2484. return name;
  2485. }
  2486. function readLinkedRefer(scnr) {
  2487. const fn = (detect = false, buf) => {
  2488. const ch = scnr.currentChar();
  2489. if (ch === "{" || ch === "%" || ch === "@" || ch === "|" || !ch) {
  2490. return buf;
  2491. } else if (ch === CHAR_SP) {
  2492. return buf;
  2493. } else if (ch === CHAR_LF) {
  2494. buf += ch;
  2495. scnr.next();
  2496. return fn(detect, buf);
  2497. } else {
  2498. buf += ch;
  2499. scnr.next();
  2500. return fn(true, buf);
  2501. }
  2502. };
  2503. return fn(false, "");
  2504. }
  2505. function readPlural(scnr) {
  2506. skipSpaces(scnr);
  2507. const plural = eat(scnr, "|");
  2508. skipSpaces(scnr);
  2509. return plural;
  2510. }
  2511. function readTokenInPlaceholder(scnr, context2) {
  2512. let token = null;
  2513. const ch = scnr.currentChar();
  2514. switch (ch) {
  2515. case "{":
  2516. if (context2.braceNest >= 1) {
  2517. emitError2(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0);
  2518. }
  2519. scnr.next();
  2520. token = getToken(context2, 2, "{");
  2521. skipSpaces(scnr);
  2522. context2.braceNest++;
  2523. return token;
  2524. case "}":
  2525. if (context2.braceNest > 0 && context2.currentType === 2) {
  2526. emitError2(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0);
  2527. }
  2528. scnr.next();
  2529. token = getToken(context2, 3, "}");
  2530. context2.braceNest--;
  2531. context2.braceNest > 0 && skipSpaces(scnr);
  2532. if (context2.inLinked && context2.braceNest === 0) {
  2533. context2.inLinked = false;
  2534. }
  2535. return token;
  2536. case "@":
  2537. if (context2.braceNest > 0) {
  2538. emitError2(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
  2539. }
  2540. token = readTokenInLinked(scnr, context2) || getEndToken(context2);
  2541. context2.braceNest = 0;
  2542. return token;
  2543. default:
  2544. let validNamedIdentifier = true;
  2545. let validListIdentifier = true;
  2546. let validLiteral = true;
  2547. if (isPluralStart(scnr)) {
  2548. if (context2.braceNest > 0) {
  2549. emitError2(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
  2550. }
  2551. token = getToken(context2, 1, readPlural(scnr));
  2552. context2.braceNest = 0;
  2553. context2.inLinked = false;
  2554. return token;
  2555. }
  2556. if (context2.braceNest > 0 && (context2.currentType === 5 || context2.currentType === 6 || context2.currentType === 7)) {
  2557. emitError2(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
  2558. context2.braceNest = 0;
  2559. return readToken(scnr, context2);
  2560. }
  2561. if (validNamedIdentifier = isNamedIdentifierStart(scnr, context2)) {
  2562. token = getToken(context2, 5, readNamedIdentifier(scnr));
  2563. skipSpaces(scnr);
  2564. return token;
  2565. }
  2566. if (validListIdentifier = isListIdentifierStart(scnr, context2)) {
  2567. token = getToken(context2, 6, readListIdentifier(scnr));
  2568. skipSpaces(scnr);
  2569. return token;
  2570. }
  2571. if (validLiteral = isLiteralStart(scnr, context2)) {
  2572. token = getToken(context2, 7, readLiteral(scnr));
  2573. skipSpaces(scnr);
  2574. return token;
  2575. }
  2576. if (!validNamedIdentifier && !validListIdentifier && !validLiteral) {
  2577. token = getToken(context2, 13, readInvalidIdentifier(scnr));
  2578. emitError2(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value);
  2579. skipSpaces(scnr);
  2580. return token;
  2581. }
  2582. break;
  2583. }
  2584. return token;
  2585. }
  2586. function readTokenInLinked(scnr, context2) {
  2587. const { currentType } = context2;
  2588. let token = null;
  2589. const ch = scnr.currentChar();
  2590. if ((currentType === 8 || currentType === 9 || currentType === 12 || currentType === 10) && (ch === CHAR_LF || ch === CHAR_SP)) {
  2591. emitError2(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
  2592. }
  2593. switch (ch) {
  2594. case "@":
  2595. scnr.next();
  2596. token = getToken(context2, 8, "@");
  2597. context2.inLinked = true;
  2598. return token;
  2599. case ".":
  2600. skipSpaces(scnr);
  2601. scnr.next();
  2602. return getToken(context2, 9, ".");
  2603. case ":":
  2604. skipSpaces(scnr);
  2605. scnr.next();
  2606. return getToken(context2, 10, ":");
  2607. default:
  2608. if (isPluralStart(scnr)) {
  2609. token = getToken(context2, 1, readPlural(scnr));
  2610. context2.braceNest = 0;
  2611. context2.inLinked = false;
  2612. return token;
  2613. }
  2614. if (isLinkedDotStart(scnr, context2) || isLinkedDelimiterStart(scnr, context2)) {
  2615. skipSpaces(scnr);
  2616. return readTokenInLinked(scnr, context2);
  2617. }
  2618. if (isLinkedModifierStart(scnr, context2)) {
  2619. skipSpaces(scnr);
  2620. return getToken(context2, 12, readLinkedModifier(scnr));
  2621. }
  2622. if (isLinkedReferStart(scnr, context2)) {
  2623. skipSpaces(scnr);
  2624. if (ch === "{") {
  2625. return readTokenInPlaceholder(scnr, context2) || token;
  2626. } else {
  2627. return getToken(context2, 11, readLinkedRefer(scnr));
  2628. }
  2629. }
  2630. if (currentType === 8) {
  2631. emitError2(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
  2632. }
  2633. context2.braceNest = 0;
  2634. context2.inLinked = false;
  2635. return readToken(scnr, context2);
  2636. }
  2637. }
  2638. function readToken(scnr, context2) {
  2639. let token = { type: 14 };
  2640. if (context2.braceNest > 0) {
  2641. return readTokenInPlaceholder(scnr, context2) || getEndToken(context2);
  2642. }
  2643. if (context2.inLinked) {
  2644. return readTokenInLinked(scnr, context2) || getEndToken(context2);
  2645. }
  2646. const ch = scnr.currentChar();
  2647. switch (ch) {
  2648. case "{":
  2649. return readTokenInPlaceholder(scnr, context2) || getEndToken(context2);
  2650. case "}":
  2651. emitError2(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0);
  2652. scnr.next();
  2653. return getToken(context2, 3, "}");
  2654. case "@":
  2655. return readTokenInLinked(scnr, context2) || getEndToken(context2);
  2656. default:
  2657. if (isPluralStart(scnr)) {
  2658. token = getToken(context2, 1, readPlural(scnr));
  2659. context2.braceNest = 0;
  2660. context2.inLinked = false;
  2661. return token;
  2662. }
  2663. const { isModulo, hasSpace } = detectModuloStart(scnr);
  2664. if (isModulo) {
  2665. return hasSpace ? getToken(context2, 0, readText(scnr)) : getToken(context2, 4, readModulo(scnr));
  2666. }
  2667. if (isTextStart(scnr)) {
  2668. return getToken(context2, 0, readText(scnr));
  2669. }
  2670. break;
  2671. }
  2672. return token;
  2673. }
  2674. function nextToken() {
  2675. const { currentType, offset, startLoc, endLoc } = _context;
  2676. _context.lastType = currentType;
  2677. _context.lastOffset = offset;
  2678. _context.lastStartLoc = startLoc;
  2679. _context.lastEndLoc = endLoc;
  2680. _context.offset = currentOffset();
  2681. _context.startLoc = currentPosition();
  2682. if (_scnr.currentChar() === EOF) {
  2683. return getToken(_context, 14);
  2684. }
  2685. return readToken(_scnr, _context);
  2686. }
  2687. return {
  2688. nextToken,
  2689. currentOffset,
  2690. currentPosition,
  2691. context
  2692. };
  2693. }
  2694. var ERROR_DOMAIN = "parser";
  2695. var KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;
  2696. function fromEscapeSequence(match, codePoint4, codePoint6) {
  2697. switch (match) {
  2698. case `\\\\`:
  2699. return `\\`;
  2700. case `\\'`:
  2701. return `'`;
  2702. default: {
  2703. const codePoint = parseInt(codePoint4 || codePoint6, 16);
  2704. if (codePoint <= 55295 || codePoint >= 57344) {
  2705. return String.fromCodePoint(codePoint);
  2706. }
  2707. return "\uFFFD";
  2708. }
  2709. }
  2710. }
  2711. function createParser(options = {}) {
  2712. const location = options.location !== false;
  2713. const { onError } = options;
  2714. function emitError2(tokenzer, code, start, offset, ...args) {
  2715. const end = tokenzer.currentPosition();
  2716. end.offset += offset;
  2717. end.column += offset;
  2718. if (onError) {
  2719. const loc = createLocation(start, end);
  2720. const err = createCompileError(code, loc, {
  2721. domain: ERROR_DOMAIN,
  2722. args
  2723. });
  2724. onError(err);
  2725. }
  2726. }
  2727. function startNode(type, offset, loc) {
  2728. const node = {
  2729. type,
  2730. start: offset,
  2731. end: offset
  2732. };
  2733. if (location) {
  2734. node.loc = { start: loc, end: loc };
  2735. }
  2736. return node;
  2737. }
  2738. function endNode(node, offset, pos, type) {
  2739. node.end = offset;
  2740. if (type) {
  2741. node.type = type;
  2742. }
  2743. if (location && node.loc) {
  2744. node.loc.end = pos;
  2745. }
  2746. }
  2747. function parseText2(tokenizer, value) {
  2748. const context = tokenizer.context();
  2749. const node = startNode(3, context.offset, context.startLoc);
  2750. node.value = value;
  2751. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2752. return node;
  2753. }
  2754. function parseList(tokenizer, index) {
  2755. const context = tokenizer.context();
  2756. const { lastOffset: offset, lastStartLoc: loc } = context;
  2757. const node = startNode(5, offset, loc);
  2758. node.index = parseInt(index, 10);
  2759. tokenizer.nextToken();
  2760. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2761. return node;
  2762. }
  2763. function parseNamed(tokenizer, key) {
  2764. const context = tokenizer.context();
  2765. const { lastOffset: offset, lastStartLoc: loc } = context;
  2766. const node = startNode(4, offset, loc);
  2767. node.key = key;
  2768. tokenizer.nextToken();
  2769. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2770. return node;
  2771. }
  2772. function parseLiteral(tokenizer, value) {
  2773. const context = tokenizer.context();
  2774. const { lastOffset: offset, lastStartLoc: loc } = context;
  2775. const node = startNode(9, offset, loc);
  2776. node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence);
  2777. tokenizer.nextToken();
  2778. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2779. return node;
  2780. }
  2781. function parseLinkedModifier(tokenizer) {
  2782. const token = tokenizer.nextToken();
  2783. const context = tokenizer.context();
  2784. const { lastOffset: offset, lastStartLoc: loc } = context;
  2785. const node = startNode(8, offset, loc);
  2786. if (token.type !== 12) {
  2787. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0);
  2788. node.value = "";
  2789. endNode(node, offset, loc);
  2790. return {
  2791. nextConsumeToken: token,
  2792. node
  2793. };
  2794. }
  2795. if (token.value == null) {
  2796. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2797. }
  2798. node.value = token.value || "";
  2799. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2800. return {
  2801. node
  2802. };
  2803. }
  2804. function parseLinkedKey(tokenizer, value) {
  2805. const context = tokenizer.context();
  2806. const node = startNode(7, context.offset, context.startLoc);
  2807. node.value = value;
  2808. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2809. return node;
  2810. }
  2811. function parseLinked(tokenizer) {
  2812. const context = tokenizer.context();
  2813. const linkedNode = startNode(6, context.offset, context.startLoc);
  2814. let token = tokenizer.nextToken();
  2815. if (token.type === 9) {
  2816. const parsed = parseLinkedModifier(tokenizer);
  2817. linkedNode.modifier = parsed.node;
  2818. token = parsed.nextConsumeToken || tokenizer.nextToken();
  2819. }
  2820. if (token.type !== 10) {
  2821. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2822. }
  2823. token = tokenizer.nextToken();
  2824. if (token.type === 2) {
  2825. token = tokenizer.nextToken();
  2826. }
  2827. switch (token.type) {
  2828. case 11:
  2829. if (token.value == null) {
  2830. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2831. }
  2832. linkedNode.key = parseLinkedKey(tokenizer, token.value || "");
  2833. break;
  2834. case 5:
  2835. if (token.value == null) {
  2836. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2837. }
  2838. linkedNode.key = parseNamed(tokenizer, token.value || "");
  2839. break;
  2840. case 6:
  2841. if (token.value == null) {
  2842. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2843. }
  2844. linkedNode.key = parseList(tokenizer, token.value || "");
  2845. break;
  2846. case 7:
  2847. if (token.value == null) {
  2848. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2849. }
  2850. linkedNode.key = parseLiteral(tokenizer, token.value || "");
  2851. break;
  2852. default:
  2853. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0);
  2854. const nextContext = tokenizer.context();
  2855. const emptyLinkedKeyNode = startNode(7, nextContext.offset, nextContext.startLoc);
  2856. emptyLinkedKeyNode.value = "";
  2857. endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc);
  2858. linkedNode.key = emptyLinkedKeyNode;
  2859. endNode(linkedNode, nextContext.offset, nextContext.startLoc);
  2860. return {
  2861. nextConsumeToken: token,
  2862. node: linkedNode
  2863. };
  2864. }
  2865. endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition());
  2866. return {
  2867. node: linkedNode
  2868. };
  2869. }
  2870. function parseMessage(tokenizer) {
  2871. const context = tokenizer.context();
  2872. const startOffset = context.currentType === 1 ? tokenizer.currentOffset() : context.offset;
  2873. const startLoc = context.currentType === 1 ? context.endLoc : context.startLoc;
  2874. const node = startNode(2, startOffset, startLoc);
  2875. node.items = [];
  2876. let nextToken = null;
  2877. do {
  2878. const token = nextToken || tokenizer.nextToken();
  2879. nextToken = null;
  2880. switch (token.type) {
  2881. case 0:
  2882. if (token.value == null) {
  2883. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2884. }
  2885. node.items.push(parseText2(tokenizer, token.value || ""));
  2886. break;
  2887. case 6:
  2888. if (token.value == null) {
  2889. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2890. }
  2891. node.items.push(parseList(tokenizer, token.value || ""));
  2892. break;
  2893. case 5:
  2894. if (token.value == null) {
  2895. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2896. }
  2897. node.items.push(parseNamed(tokenizer, token.value || ""));
  2898. break;
  2899. case 7:
  2900. if (token.value == null) {
  2901. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
  2902. }
  2903. node.items.push(parseLiteral(tokenizer, token.value || ""));
  2904. break;
  2905. case 8:
  2906. const parsed = parseLinked(tokenizer);
  2907. node.items.push(parsed.node);
  2908. nextToken = parsed.nextConsumeToken || null;
  2909. break;
  2910. }
  2911. } while (context.currentType !== 14 && context.currentType !== 1);
  2912. const endOffset = context.currentType === 1 ? context.lastOffset : tokenizer.currentOffset();
  2913. const endLoc = context.currentType === 1 ? context.lastEndLoc : tokenizer.currentPosition();
  2914. endNode(node, endOffset, endLoc);
  2915. return node;
  2916. }
  2917. function parsePlural(tokenizer, offset, loc, msgNode) {
  2918. const context = tokenizer.context();
  2919. let hasEmptyMessage = msgNode.items.length === 0;
  2920. const node = startNode(1, offset, loc);
  2921. node.cases = [];
  2922. node.cases.push(msgNode);
  2923. do {
  2924. const msg = parseMessage(tokenizer);
  2925. if (!hasEmptyMessage) {
  2926. hasEmptyMessage = msg.items.length === 0;
  2927. }
  2928. node.cases.push(msg);
  2929. } while (context.currentType !== 14);
  2930. if (hasEmptyMessage) {
  2931. emitError2(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0);
  2932. }
  2933. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2934. return node;
  2935. }
  2936. function parseResource(tokenizer) {
  2937. const context = tokenizer.context();
  2938. const { offset, startLoc } = context;
  2939. const msgNode = parseMessage(tokenizer);
  2940. if (context.currentType === 14) {
  2941. return msgNode;
  2942. } else {
  2943. return parsePlural(tokenizer, offset, startLoc, msgNode);
  2944. }
  2945. }
  2946. function parse2(source) {
  2947. const tokenizer = createTokenizer(source, shared.assign({}, options));
  2948. const context = tokenizer.context();
  2949. const node = startNode(0, context.offset, context.startLoc);
  2950. if (location && node.loc) {
  2951. node.loc.source = source;
  2952. }
  2953. node.body = parseResource(tokenizer);
  2954. if (context.currentType !== 14) {
  2955. emitError2(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || "");
  2956. }
  2957. endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
  2958. return node;
  2959. }
  2960. return { parse: parse2 };
  2961. }
  2962. function getTokenCaption(token) {
  2963. if (token.type === 14) {
  2964. return "EOF";
  2965. }
  2966. const name = (token.value || "").replace(/\r?\n/gu, "\\n");
  2967. return name.length > 10 ? name.slice(0, 9) + "\u2026" : name;
  2968. }
  2969. function createTransformer(ast, options = {}) {
  2970. const _context = {
  2971. ast,
  2972. helpers: /* @__PURE__ */ new Set()
  2973. };
  2974. const context = () => _context;
  2975. const helper = (name) => {
  2976. _context.helpers.add(name);
  2977. return name;
  2978. };
  2979. return { context, helper };
  2980. }
  2981. function traverseNodes(nodes, transformer) {
  2982. for (let i = 0; i < nodes.length; i++) {
  2983. traverseNode2(nodes[i], transformer);
  2984. }
  2985. }
  2986. function traverseNode2(node, transformer) {
  2987. switch (node.type) {
  2988. case 1:
  2989. traverseNodes(node.cases, transformer);
  2990. transformer.helper("plural");
  2991. break;
  2992. case 2:
  2993. traverseNodes(node.items, transformer);
  2994. break;
  2995. case 6:
  2996. const linked = node;
  2997. traverseNode2(linked.key, transformer);
  2998. transformer.helper("linked");
  2999. transformer.helper("type");
  3000. break;
  3001. case 5:
  3002. transformer.helper("interpolate");
  3003. transformer.helper("list");
  3004. break;
  3005. case 4:
  3006. transformer.helper("interpolate");
  3007. transformer.helper("named");
  3008. break;
  3009. }
  3010. }
  3011. function transform2(ast, options = {}) {
  3012. const transformer = createTransformer(ast);
  3013. transformer.helper("normalize");
  3014. ast.body && traverseNode2(ast.body, transformer);
  3015. const context = transformer.context();
  3016. ast.helpers = Array.from(context.helpers);
  3017. }
  3018. function createCodeGenerator(ast, options) {
  3019. const { sourceMap: sourceMap$1, filename, breakLineCode, needIndent: _needIndent } = options;
  3020. const _context = {
  3021. source: ast.loc.source,
  3022. filename,
  3023. code: "",
  3024. column: 1,
  3025. line: 1,
  3026. offset: 0,
  3027. map: void 0,
  3028. breakLineCode,
  3029. needIndent: _needIndent,
  3030. indentLevel: 0
  3031. };
  3032. const context = () => _context;
  3033. function push(code, node) {
  3034. _context.code += code;
  3035. if (_context.map) {
  3036. if (node && node.loc && node.loc !== LocationStub) {
  3037. addMapping(node.loc.start, getMappingName(node));
  3038. }
  3039. advancePositionWithSource(_context, code);
  3040. }
  3041. }
  3042. function _newline(n, withBreakLine = true) {
  3043. const _breakLineCode = withBreakLine ? breakLineCode : "";
  3044. push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode);
  3045. }
  3046. function indent(withNewLine = true) {
  3047. const level = ++_context.indentLevel;
  3048. withNewLine && _newline(level);
  3049. }
  3050. function deindent(withNewLine = true) {
  3051. const level = --_context.indentLevel;
  3052. withNewLine && _newline(level);
  3053. }
  3054. function newline() {
  3055. _newline(_context.indentLevel);
  3056. }
  3057. const helper = (key) => `_${key}`;
  3058. const needIndent = () => _context.needIndent;
  3059. function addMapping(loc, name) {
  3060. _context.map.addMapping({
  3061. name,
  3062. source: _context.filename,
  3063. original: {
  3064. line: loc.line,
  3065. column: loc.column - 1
  3066. },
  3067. generated: {
  3068. line: _context.line,
  3069. column: _context.column - 1
  3070. }
  3071. });
  3072. }
  3073. if (sourceMap$1) {
  3074. _context.map = new sourceMap.SourceMapGenerator();
  3075. _context.map.setSourceContent(filename, _context.source);
  3076. }
  3077. return {
  3078. context,
  3079. push,
  3080. indent,
  3081. deindent,
  3082. newline,
  3083. helper,
  3084. needIndent
  3085. };
  3086. }
  3087. function generateLinkedNode(generator, node) {
  3088. const { helper } = generator;
  3089. generator.push(`${helper("linked")}(`);
  3090. generateNode(generator, node.key);
  3091. if (node.modifier) {
  3092. generator.push(`, `);
  3093. generateNode(generator, node.modifier);
  3094. generator.push(`, _type`);
  3095. } else {
  3096. generator.push(`, undefined, _type`);
  3097. }
  3098. generator.push(`)`);
  3099. }
  3100. function generateMessageNode(generator, node) {
  3101. const { helper, needIndent } = generator;
  3102. generator.push(`${helper("normalize")}([`);
  3103. generator.indent(needIndent());
  3104. const length = node.items.length;
  3105. for (let i = 0; i < length; i++) {
  3106. generateNode(generator, node.items[i]);
  3107. if (i === length - 1) {
  3108. break;
  3109. }
  3110. generator.push(", ");
  3111. }
  3112. generator.deindent(needIndent());
  3113. generator.push("])");
  3114. }
  3115. function generatePluralNode(generator, node) {
  3116. const { helper, needIndent } = generator;
  3117. if (node.cases.length > 1) {
  3118. generator.push(`${helper("plural")}([`);
  3119. generator.indent(needIndent());
  3120. const length = node.cases.length;
  3121. for (let i = 0; i < length; i++) {
  3122. generateNode(generator, node.cases[i]);
  3123. if (i === length - 1) {
  3124. break;
  3125. }
  3126. generator.push(", ");
  3127. }
  3128. generator.deindent(needIndent());
  3129. generator.push(`])`);
  3130. }
  3131. }
  3132. function generateResource(generator, node) {
  3133. if (node.body) {
  3134. generateNode(generator, node.body);
  3135. } else {
  3136. generator.push("null");
  3137. }
  3138. }
  3139. function generateNode(generator, node) {
  3140. const { helper } = generator;
  3141. switch (node.type) {
  3142. case 0:
  3143. generateResource(generator, node);
  3144. break;
  3145. case 1:
  3146. generatePluralNode(generator, node);
  3147. break;
  3148. case 2:
  3149. generateMessageNode(generator, node);
  3150. break;
  3151. case 6:
  3152. generateLinkedNode(generator, node);
  3153. break;
  3154. case 8:
  3155. generator.push(JSON.stringify(node.value), node);
  3156. break;
  3157. case 7:
  3158. generator.push(JSON.stringify(node.value), node);
  3159. break;
  3160. case 5:
  3161. generator.push(`${helper("interpolate")}(${helper("list")}(${node.index}))`, node);
  3162. break;
  3163. case 4:
  3164. generator.push(`${helper("interpolate")}(${helper("named")}(${JSON.stringify(node.key)}))`, node);
  3165. break;
  3166. case 9:
  3167. generator.push(JSON.stringify(node.value), node);
  3168. break;
  3169. case 3:
  3170. generator.push(JSON.stringify(node.value), node);
  3171. break;
  3172. default: {
  3173. throw new Error(`unhandled codegen node type: ${node.type}`);
  3174. }
  3175. }
  3176. }
  3177. var generate2 = (ast, options = {}) => {
  3178. const mode = shared.isString(options.mode) ? options.mode : "normal";
  3179. const filename = shared.isString(options.filename) ? options.filename : "message.intl";
  3180. const sourceMap2 = !!options.sourceMap;
  3181. const breakLineCode = options.breakLineCode != null ? options.breakLineCode : mode === "arrow" ? ";" : "\n";
  3182. const needIndent = options.needIndent ? options.needIndent : mode !== "arrow";
  3183. const helpers = ast.helpers || [];
  3184. const generator = createCodeGenerator(ast, {
  3185. mode,
  3186. filename,
  3187. sourceMap: sourceMap2,
  3188. breakLineCode,
  3189. needIndent
  3190. });
  3191. generator.push(mode === "normal" ? `function __msg__ (ctx) {` : `(ctx) => {`);
  3192. generator.indent(needIndent);
  3193. if (helpers.length > 0) {
  3194. generator.push(`const { ${helpers.map((s) => `${s}: _${s}`).join(", ")} } = ctx`);
  3195. generator.newline();
  3196. }
  3197. generator.push(`return `);
  3198. generateNode(generator, ast);
  3199. generator.deindent(needIndent);
  3200. generator.push(`}`);
  3201. const { code, map } = generator.context();
  3202. return {
  3203. ast,
  3204. code,
  3205. map: map ? map.toJSON() : void 0
  3206. };
  3207. };
  3208. function getMappingName(node) {
  3209. switch (node.type) {
  3210. case 3:
  3211. case 9:
  3212. case 8:
  3213. case 7:
  3214. return node.value;
  3215. case 5:
  3216. return node.index.toString();
  3217. case 4:
  3218. return node.key;
  3219. default:
  3220. return void 0;
  3221. }
  3222. }
  3223. function advancePositionWithSource(pos, source, numberOfCharacters = source.length) {
  3224. let linesCount = 0;
  3225. let lastNewLinePos = -1;
  3226. for (let i = 0; i < numberOfCharacters; i++) {
  3227. if (source.charCodeAt(i) === 10) {
  3228. linesCount++;
  3229. lastNewLinePos = i;
  3230. }
  3231. }
  3232. pos.offset += numberOfCharacters;
  3233. pos.line += linesCount;
  3234. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  3235. return pos;
  3236. }
  3237. function baseCompile2(source, options = {}) {
  3238. const assignedOptions = shared.assign({}, options);
  3239. const parser = createParser(assignedOptions);
  3240. const ast = parser.parse(source);
  3241. transform2(ast, assignedOptions);
  3242. return generate2(ast, assignedOptions);
  3243. }
  3244. exports.CompileErrorCodes = CompileErrorCodes;
  3245. exports.ERROR_DOMAIN = ERROR_DOMAIN;
  3246. exports.LocationStub = LocationStub;
  3247. exports.baseCompile = baseCompile2;
  3248. exports.createCompileError = createCompileError;
  3249. exports.createLocation = createLocation;
  3250. exports.createParser = createParser;
  3251. exports.createPosition = createPosition;
  3252. exports.defaultOnError = defaultOnError2;
  3253. exports.errorMessages = errorMessages2;
  3254. }
  3255. });
  3256. // node_modules/@intlify/message-compiler/index.js
  3257. var require_message_compiler = __commonJS({
  3258. "node_modules/@intlify/message-compiler/index.js"(exports, module) {
  3259. "use strict";
  3260. init_define_APP_INFO();
  3261. if (false) {
  3262. module.exports = null;
  3263. } else {
  3264. module.exports = require_message_compiler_cjs();
  3265. }
  3266. }
  3267. });
  3268. // node_modules/@intlify/devtools-if/dist/devtools-if.cjs.js
  3269. var require_devtools_if_cjs = __commonJS({
  3270. "node_modules/@intlify/devtools-if/dist/devtools-if.cjs.js"(exports) {
  3271. "use strict";
  3272. init_define_APP_INFO();
  3273. Object.defineProperty(exports, "__esModule", { value: true });
  3274. var IntlifyDevToolsHooks = {
  3275. I18nInit: "i18n:init",
  3276. FunctionTranslate: "function:translate"
  3277. };
  3278. exports.IntlifyDevToolsHooks = IntlifyDevToolsHooks;
  3279. }
  3280. });
  3281. // node_modules/@intlify/devtools-if/index.js
  3282. var require_devtools_if = __commonJS({
  3283. "node_modules/@intlify/devtools-if/index.js"(exports, module) {
  3284. "use strict";
  3285. init_define_APP_INFO();
  3286. if (false) {
  3287. module.exports = null;
  3288. } else {
  3289. module.exports = require_devtools_if_cjs();
  3290. }
  3291. }
  3292. });
  3293. // node_modules/@intlify/core-base/dist/core-base.cjs.js
  3294. var require_core_base_cjs = __commonJS({
  3295. "node_modules/@intlify/core-base/dist/core-base.cjs.js"(exports) {
  3296. "use strict";
  3297. init_define_APP_INFO();
  3298. Object.defineProperty(exports, "__esModule", { value: true });
  3299. var messageCompiler = require_message_compiler();
  3300. var shared = require_shared();
  3301. var devtoolsIf = require_devtools_if();
  3302. var pathStateMachine = [];
  3303. pathStateMachine[0] = {
  3304. ["w"]: [0],
  3305. ["i"]: [3, 0],
  3306. ["["]: [4],
  3307. ["o"]: [7]
  3308. };
  3309. pathStateMachine[1] = {
  3310. ["w"]: [1],
  3311. ["."]: [2],
  3312. ["["]: [4],
  3313. ["o"]: [7]
  3314. };
  3315. pathStateMachine[2] = {
  3316. ["w"]: [2],
  3317. ["i"]: [3, 0],
  3318. ["0"]: [3, 0]
  3319. };
  3320. pathStateMachine[3] = {
  3321. ["i"]: [3, 0],
  3322. ["0"]: [3, 0],
  3323. ["w"]: [1, 1],
  3324. ["."]: [2, 1],
  3325. ["["]: [4, 1],
  3326. ["o"]: [7, 1]
  3327. };
  3328. pathStateMachine[4] = {
  3329. ["'"]: [5, 0],
  3330. ['"']: [6, 0],
  3331. ["["]: [
  3332. 4,
  3333. 2
  3334. ],
  3335. ["]"]: [1, 3],
  3336. ["o"]: 8,
  3337. ["l"]: [4, 0]
  3338. };
  3339. pathStateMachine[5] = {
  3340. ["'"]: [4, 0],
  3341. ["o"]: 8,
  3342. ["l"]: [5, 0]
  3343. };
  3344. pathStateMachine[6] = {
  3345. ['"']: [4, 0],
  3346. ["o"]: 8,
  3347. ["l"]: [6, 0]
  3348. };
  3349. var literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
  3350. function isLiteral(exp) {
  3351. return literalValueRE.test(exp);
  3352. }
  3353. function stripQuotes(str) {
  3354. const a = str.charCodeAt(0);
  3355. const b = str.charCodeAt(str.length - 1);
  3356. return a === b && (a === 34 || a === 39) ? str.slice(1, -1) : str;
  3357. }
  3358. function getPathCharType(ch) {
  3359. if (ch === void 0 || ch === null) {
  3360. return "o";
  3361. }
  3362. const code2 = ch.charCodeAt(0);
  3363. switch (code2) {
  3364. case 91:
  3365. case 93:
  3366. case 46:
  3367. case 34:
  3368. case 39:
  3369. return ch;
  3370. case 95:
  3371. case 36:
  3372. case 45:
  3373. return "i";
  3374. case 9:
  3375. case 10:
  3376. case 13:
  3377. case 160:
  3378. case 65279:
  3379. case 8232:
  3380. case 8233:
  3381. return "w";
  3382. }
  3383. return "i";
  3384. }
  3385. function formatSubPath(path) {
  3386. const trimmed = path.trim();
  3387. if (path.charAt(0) === "0" && isNaN(parseInt(path))) {
  3388. return false;
  3389. }
  3390. return isLiteral(trimmed) ? stripQuotes(trimmed) : "*" + trimmed;
  3391. }
  3392. function parse2(path) {
  3393. const keys = [];
  3394. let index = -1;
  3395. let mode = 0;
  3396. let subPathDepth = 0;
  3397. let c;
  3398. let key;
  3399. let newChar;
  3400. let type;
  3401. let transition;
  3402. let action;
  3403. let typeMap;
  3404. const actions = [];
  3405. actions[0] = () => {
  3406. if (key === void 0) {
  3407. key = newChar;
  3408. } else {
  3409. key += newChar;
  3410. }
  3411. };
  3412. actions[1] = () => {
  3413. if (key !== void 0) {
  3414. keys.push(key);
  3415. key = void 0;
  3416. }
  3417. };
  3418. actions[2] = () => {
  3419. actions[0]();
  3420. subPathDepth++;
  3421. };
  3422. actions[3] = () => {
  3423. if (subPathDepth > 0) {
  3424. subPathDepth--;
  3425. mode = 4;
  3426. actions[0]();
  3427. } else {
  3428. subPathDepth = 0;
  3429. if (key === void 0) {
  3430. return false;
  3431. }
  3432. key = formatSubPath(key);
  3433. if (key === false) {
  3434. return false;
  3435. } else {
  3436. actions[1]();
  3437. }
  3438. }
  3439. };
  3440. function maybeUnescapeQuote() {
  3441. const nextChar = path[index + 1];
  3442. if (mode === 5 && nextChar === "'" || mode === 6 && nextChar === '"') {
  3443. index++;
  3444. newChar = "\\" + nextChar;
  3445. actions[0]();
  3446. return true;
  3447. }
  3448. }
  3449. while (mode !== null) {
  3450. index++;
  3451. c = path[index];
  3452. if (c === "\\" && maybeUnescapeQuote()) {
  3453. continue;
  3454. }
  3455. type = getPathCharType(c);
  3456. typeMap = pathStateMachine[mode];
  3457. transition = typeMap[type] || typeMap["l"] || 8;
  3458. if (transition === 8) {
  3459. return;
  3460. }
  3461. mode = transition[0];
  3462. if (transition[1] !== void 0) {
  3463. action = actions[transition[1]];
  3464. if (action) {
  3465. newChar = c;
  3466. if (action() === false) {
  3467. return;
  3468. }
  3469. }
  3470. }
  3471. if (mode === 7) {
  3472. return keys;
  3473. }
  3474. }
  3475. }
  3476. var cache = /* @__PURE__ */ new Map();
  3477. function resolveWithKeyValue(obj, path) {
  3478. return shared.isObject(obj) ? obj[path] : null;
  3479. }
  3480. function resolveValue(obj, path) {
  3481. if (!shared.isObject(obj)) {
  3482. return null;
  3483. }
  3484. let hit = cache.get(path);
  3485. if (!hit) {
  3486. hit = parse2(path);
  3487. if (hit) {
  3488. cache.set(path, hit);
  3489. }
  3490. }
  3491. if (!hit) {
  3492. return null;
  3493. }
  3494. const len = hit.length;
  3495. let last2 = obj;
  3496. let i = 0;
  3497. while (i < len) {
  3498. const val = last2[hit[i]];
  3499. if (val === void 0) {
  3500. return null;
  3501. }
  3502. last2 = val;
  3503. i++;
  3504. }
  3505. return last2;
  3506. }
  3507. var DEFAULT_MODIFIER = (str) => str;
  3508. var DEFAULT_MESSAGE = (ctx) => "";
  3509. var DEFAULT_MESSAGE_DATA_TYPE = "text";
  3510. var DEFAULT_NORMALIZE = (values) => values.length === 0 ? "" : values.join("");
  3511. var DEFAULT_INTERPOLATE = shared.toDisplayString;
  3512. function pluralDefault(choice, choicesLength) {
  3513. choice = Math.abs(choice);
  3514. if (choicesLength === 2) {
  3515. return choice ? choice > 1 ? 1 : 0 : 1;
  3516. }
  3517. return choice ? Math.min(choice, 2) : 0;
  3518. }
  3519. function getPluralIndex(options) {
  3520. const index = shared.isNumber(options.pluralIndex) ? options.pluralIndex : -1;
  3521. return options.named && (shared.isNumber(options.named.count) || shared.isNumber(options.named.n)) ? shared.isNumber(options.named.count) ? options.named.count : shared.isNumber(options.named.n) ? options.named.n : index : index;
  3522. }
  3523. function normalizeNamed(pluralIndex, props) {
  3524. if (!props.count) {
  3525. props.count = pluralIndex;
  3526. }
  3527. if (!props.n) {
  3528. props.n = pluralIndex;
  3529. }
  3530. }
  3531. function createMessageContext(options = {}) {
  3532. const locale = options.locale;
  3533. const pluralIndex = getPluralIndex(options);
  3534. const pluralRule = shared.isObject(options.pluralRules) && shared.isString(locale) && shared.isFunction(options.pluralRules[locale]) ? options.pluralRules[locale] : pluralDefault;
  3535. const orgPluralRule = shared.isObject(options.pluralRules) && shared.isString(locale) && shared.isFunction(options.pluralRules[locale]) ? pluralDefault : void 0;
  3536. const plural = (messages) => {
  3537. return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)];
  3538. };
  3539. const _list = options.list || [];
  3540. const list = (index) => _list[index];
  3541. const _named = options.named || {};
  3542. shared.isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named);
  3543. const named = (key) => _named[key];
  3544. function message(key) {
  3545. const msg = shared.isFunction(options.messages) ? options.messages(key) : shared.isObject(options.messages) ? options.messages[key] : false;
  3546. return !msg ? options.parent ? options.parent.message(key) : DEFAULT_MESSAGE : msg;
  3547. }
  3548. const _modifier = (name) => options.modifiers ? options.modifiers[name] : DEFAULT_MODIFIER;
  3549. const normalize = shared.isPlainObject(options.processor) && shared.isFunction(options.processor.normalize) ? options.processor.normalize : DEFAULT_NORMALIZE;
  3550. const interpolate = shared.isPlainObject(options.processor) && shared.isFunction(options.processor.interpolate) ? options.processor.interpolate : DEFAULT_INTERPOLATE;
  3551. const type = shared.isPlainObject(options.processor) && shared.isString(options.processor.type) ? options.processor.type : DEFAULT_MESSAGE_DATA_TYPE;
  3552. const linked = (key, ...args) => {
  3553. const [arg1, arg2] = args;
  3554. let type2 = "text";
  3555. let modifier = "";
  3556. if (args.length === 1) {
  3557. if (shared.isObject(arg1)) {
  3558. modifier = arg1.modifier || modifier;
  3559. type2 = arg1.type || type2;
  3560. } else if (shared.isString(arg1)) {
  3561. modifier = arg1 || modifier;
  3562. }
  3563. } else if (args.length === 2) {
  3564. if (shared.isString(arg1)) {
  3565. modifier = arg1 || modifier;
  3566. }
  3567. if (shared.isString(arg2)) {
  3568. type2 = arg2 || type2;
  3569. }
  3570. }
  3571. let msg = message(key)(ctx);
  3572. if (type2 === "vnode" && shared.isArray(msg) && modifier) {
  3573. msg = msg[0];
  3574. }
  3575. return modifier ? _modifier(modifier)(msg, type2) : msg;
  3576. };
  3577. const ctx = {
  3578. ["list"]: list,
  3579. ["named"]: named,
  3580. ["plural"]: plural,
  3581. ["linked"]: linked,
  3582. ["message"]: message,
  3583. ["type"]: type,
  3584. ["interpolate"]: interpolate,
  3585. ["normalize"]: normalize
  3586. };
  3587. return ctx;
  3588. }
  3589. var devtools = null;
  3590. function setDevToolsHook(hook) {
  3591. devtools = hook;
  3592. }
  3593. function getDevToolsHook() {
  3594. return devtools;
  3595. }
  3596. function initI18nDevTools(i18n, version, meta) {
  3597. devtools && devtools.emit(devtoolsIf.IntlifyDevToolsHooks.I18nInit, {
  3598. timestamp: Date.now(),
  3599. i18n,
  3600. version,
  3601. meta
  3602. });
  3603. }
  3604. var translateDevTools = createDevToolsHook(devtoolsIf.IntlifyDevToolsHooks.FunctionTranslate);
  3605. function createDevToolsHook(hook) {
  3606. return (payloads) => devtools && devtools.emit(hook, payloads);
  3607. }
  3608. var CoreWarnCodes = {
  3609. NOT_FOUND_KEY: 1,
  3610. FALLBACK_TO_TRANSLATE: 2,
  3611. CANNOT_FORMAT_NUMBER: 3,
  3612. FALLBACK_TO_NUMBER_FORMAT: 4,
  3613. CANNOT_FORMAT_DATE: 5,
  3614. FALLBACK_TO_DATE_FORMAT: 6,
  3615. __EXTEND_POINT__: 7
  3616. };
  3617. var warnMessages = {
  3618. [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`,
  3619. [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
  3620. [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
  3621. [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
  3622. [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
  3623. [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`
  3624. };
  3625. function getWarnMessage(code2, ...args) {
  3626. return shared.format(warnMessages[code2], ...args);
  3627. }
  3628. function fallbackWithSimple(ctx, fallback, start) {
  3629. return [.../* @__PURE__ */ new Set([
  3630. start,
  3631. ...shared.isArray(fallback) ? fallback : shared.isObject(fallback) ? Object.keys(fallback) : shared.isString(fallback) ? [fallback] : [start]
  3632. ])];
  3633. }
  3634. function fallbackWithLocaleChain(ctx, fallback, start) {
  3635. const startLocale = shared.isString(start) ? start : DEFAULT_LOCALE;
  3636. const context = ctx;
  3637. if (!context.__localeChainCache) {
  3638. context.__localeChainCache = /* @__PURE__ */ new Map();
  3639. }
  3640. let chain = context.__localeChainCache.get(startLocale);
  3641. if (!chain) {
  3642. chain = [];
  3643. let block = [start];
  3644. while (shared.isArray(block)) {
  3645. block = appendBlockToChain(chain, block, fallback);
  3646. }
  3647. const defaults = shared.isArray(fallback) || !shared.isPlainObject(fallback) ? fallback : fallback["default"] ? fallback["default"] : null;
  3648. block = shared.isString(defaults) ? [defaults] : defaults;
  3649. if (shared.isArray(block)) {
  3650. appendBlockToChain(chain, block, false);
  3651. }
  3652. context.__localeChainCache.set(startLocale, chain);
  3653. }
  3654. return chain;
  3655. }
  3656. function appendBlockToChain(chain, block, blocks) {
  3657. let follow = true;
  3658. for (let i = 0; i < block.length && shared.isBoolean(follow); i++) {
  3659. const locale = block[i];
  3660. if (shared.isString(locale)) {
  3661. follow = appendLocaleToChain(chain, block[i], blocks);
  3662. }
  3663. }
  3664. return follow;
  3665. }
  3666. function appendLocaleToChain(chain, locale, blocks) {
  3667. let follow;
  3668. const tokens = locale.split("-");
  3669. do {
  3670. const target = tokens.join("-");
  3671. follow = appendItemToChain(chain, target, blocks);
  3672. tokens.splice(-1, 1);
  3673. } while (tokens.length && follow === true);
  3674. return follow;
  3675. }
  3676. function appendItemToChain(chain, target, blocks) {
  3677. let follow = false;
  3678. if (!chain.includes(target)) {
  3679. follow = true;
  3680. if (target) {
  3681. follow = target[target.length - 1] !== "!";
  3682. const locale = target.replace(/!/g, "");
  3683. chain.push(locale);
  3684. if ((shared.isArray(blocks) || shared.isPlainObject(blocks)) && blocks[locale]) {
  3685. follow = blocks[locale];
  3686. }
  3687. }
  3688. }
  3689. return follow;
  3690. }
  3691. var VERSION = "9.2.0";
  3692. var NOT_REOSLVED = -1;
  3693. var DEFAULT_LOCALE = "en-US";
  3694. var MISSING_RESOLVE_VALUE = "";
  3695. var capitalize2 = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`;
  3696. function getDefaultLinkedModifiers() {
  3697. return {
  3698. upper: (val, type) => {
  3699. return type === "text" && shared.isString(val) ? val.toUpperCase() : type === "vnode" && shared.isObject(val) && "__v_isVNode" in val ? val.children.toUpperCase() : val;
  3700. },
  3701. lower: (val, type) => {
  3702. return type === "text" && shared.isString(val) ? val.toLowerCase() : type === "vnode" && shared.isObject(val) && "__v_isVNode" in val ? val.children.toLowerCase() : val;
  3703. },
  3704. capitalize: (val, type) => {
  3705. return type === "text" && shared.isString(val) ? capitalize2(val) : type === "vnode" && shared.isObject(val) && "__v_isVNode" in val ? capitalize2(val.children) : val;
  3706. }
  3707. };
  3708. }
  3709. var _compiler;
  3710. function registerMessageCompiler(compiler) {
  3711. _compiler = compiler;
  3712. }
  3713. var _resolver;
  3714. function registerMessageResolver(resolver) {
  3715. _resolver = resolver;
  3716. }
  3717. var _fallbacker;
  3718. function registerLocaleFallbacker(fallbacker) {
  3719. _fallbacker = fallbacker;
  3720. }
  3721. var _additionalMeta = null;
  3722. var setAdditionalMeta = (meta) => {
  3723. _additionalMeta = meta;
  3724. };
  3725. var getAdditionalMeta = () => _additionalMeta;
  3726. var _fallbackContext = null;
  3727. var setFallbackContext = (context) => {
  3728. _fallbackContext = context;
  3729. };
  3730. var getFallbackContext = () => _fallbackContext;
  3731. var _cid = 0;
  3732. function createCoreContext(options = {}) {
  3733. const version = shared.isString(options.version) ? options.version : VERSION;
  3734. const locale = shared.isString(options.locale) ? options.locale : DEFAULT_LOCALE;
  3735. const fallbackLocale = shared.isArray(options.fallbackLocale) || shared.isPlainObject(options.fallbackLocale) || shared.isString(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : locale;
  3736. const messages = shared.isPlainObject(options.messages) ? options.messages : { [locale]: {} };
  3737. const datetimeFormats = shared.isPlainObject(options.datetimeFormats) ? options.datetimeFormats : { [locale]: {} };
  3738. const numberFormats = shared.isPlainObject(options.numberFormats) ? options.numberFormats : { [locale]: {} };
  3739. const modifiers = shared.assign({}, options.modifiers || {}, getDefaultLinkedModifiers());
  3740. const pluralRules = options.pluralRules || {};
  3741. const missing = shared.isFunction(options.missing) ? options.missing : null;
  3742. const missingWarn = shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) ? options.missingWarn : true;
  3743. const fallbackWarn = shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) ? options.fallbackWarn : true;
  3744. const fallbackFormat = !!options.fallbackFormat;
  3745. const unresolving = !!options.unresolving;
  3746. const postTranslation = shared.isFunction(options.postTranslation) ? options.postTranslation : null;
  3747. const processor = shared.isPlainObject(options.processor) ? options.processor : null;
  3748. const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true;
  3749. const escapeParameter = !!options.escapeParameter;
  3750. const messageCompiler2 = shared.isFunction(options.messageCompiler) ? options.messageCompiler : _compiler;
  3751. const messageResolver = shared.isFunction(options.messageResolver) ? options.messageResolver : _resolver || resolveWithKeyValue;
  3752. const localeFallbacker = shared.isFunction(options.localeFallbacker) ? options.localeFallbacker : _fallbacker || fallbackWithSimple;
  3753. const fallbackContext = shared.isObject(options.fallbackContext) ? options.fallbackContext : void 0;
  3754. const onWarn = shared.isFunction(options.onWarn) ? options.onWarn : shared.warn;
  3755. const internalOptions = options;
  3756. const __datetimeFormatters = shared.isObject(internalOptions.__datetimeFormatters) ? internalOptions.__datetimeFormatters : /* @__PURE__ */ new Map();
  3757. const __numberFormatters = shared.isObject(internalOptions.__numberFormatters) ? internalOptions.__numberFormatters : /* @__PURE__ */ new Map();
  3758. const __meta = shared.isObject(internalOptions.__meta) ? internalOptions.__meta : {};
  3759. _cid++;
  3760. const context = {
  3761. version,
  3762. cid: _cid,
  3763. locale,
  3764. fallbackLocale,
  3765. messages,
  3766. modifiers,
  3767. pluralRules,
  3768. missing,
  3769. missingWarn,
  3770. fallbackWarn,
  3771. fallbackFormat,
  3772. unresolving,
  3773. postTranslation,
  3774. processor,
  3775. warnHtmlMessage,
  3776. escapeParameter,
  3777. messageCompiler: messageCompiler2,
  3778. messageResolver,
  3779. localeFallbacker,
  3780. fallbackContext,
  3781. onWarn,
  3782. __meta
  3783. };
  3784. {
  3785. context.datetimeFormats = datetimeFormats;
  3786. context.numberFormats = numberFormats;
  3787. context.__datetimeFormatters = __datetimeFormatters;
  3788. context.__numberFormatters = __numberFormatters;
  3789. }
  3790. {
  3791. context.__v_emitter = internalOptions.__v_emitter != null ? internalOptions.__v_emitter : void 0;
  3792. }
  3793. {
  3794. initI18nDevTools(context, version, __meta);
  3795. }
  3796. return context;
  3797. }
  3798. function isTranslateFallbackWarn(fallback, key) {
  3799. return fallback instanceof RegExp ? fallback.test(key) : fallback;
  3800. }
  3801. function isTranslateMissingWarn(missing, key) {
  3802. return missing instanceof RegExp ? missing.test(key) : missing;
  3803. }
  3804. function handleMissing(context, key, locale, missingWarn, type) {
  3805. const { missing, onWarn } = context;
  3806. {
  3807. const emitter = context.__v_emitter;
  3808. if (emitter) {
  3809. emitter.emit("missing", {
  3810. locale,
  3811. key,
  3812. type,
  3813. groupId: `${type}:${key}`
  3814. });
  3815. }
  3816. }
  3817. if (missing !== null) {
  3818. const ret = missing(context, locale, key, type);
  3819. return shared.isString(ret) ? ret : key;
  3820. } else {
  3821. if (isTranslateMissingWarn(missingWarn, key)) {
  3822. onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale }));
  3823. }
  3824. return key;
  3825. }
  3826. }
  3827. function updateFallbackLocale(ctx, locale, fallback) {
  3828. const context = ctx;
  3829. context.__localeChainCache = /* @__PURE__ */ new Map();
  3830. ctx.localeFallbacker(ctx, fallback, locale);
  3831. }
  3832. var RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/;
  3833. var WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`;
  3834. function checkHtmlMessage(source, options) {
  3835. const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true;
  3836. if (warnHtmlMessage && RE_HTML_TAG.test(source)) {
  3837. shared.warn(shared.format(WARN_MESSAGE, { source }));
  3838. }
  3839. }
  3840. var defaultOnCacheKey = (source) => source;
  3841. var compileCache = /* @__PURE__ */ Object.create(null);
  3842. function clearCompileCache() {
  3843. compileCache = /* @__PURE__ */ Object.create(null);
  3844. }
  3845. function compileToFunction(source, options = {}) {
  3846. {
  3847. checkHtmlMessage(source, options);
  3848. const onCacheKey = options.onCacheKey || defaultOnCacheKey;
  3849. const key = onCacheKey(source);
  3850. const cached = compileCache[key];
  3851. if (cached) {
  3852. return cached;
  3853. }
  3854. let occurred = false;
  3855. const onError = options.onError || messageCompiler.defaultOnError;
  3856. options.onError = (err) => {
  3857. occurred = true;
  3858. onError(err);
  3859. };
  3860. const { code: code2 } = messageCompiler.baseCompile(source, options);
  3861. const msg = new Function(`return ${code2}`)();
  3862. return !occurred ? compileCache[key] = msg : msg;
  3863. }
  3864. }
  3865. var code = messageCompiler.CompileErrorCodes.__EXTEND_POINT__;
  3866. var inc = () => ++code;
  3867. var CoreErrorCodes = {
  3868. INVALID_ARGUMENT: code,
  3869. INVALID_DATE_ARGUMENT: inc(),
  3870. INVALID_ISO_DATE_ARGUMENT: inc(),
  3871. __EXTEND_POINT__: inc()
  3872. };
  3873. function createCoreError(code2) {
  3874. return messageCompiler.createCompileError(code2, null, { messages: errorMessages2 });
  3875. }
  3876. var errorMessages2 = {
  3877. [CoreErrorCodes.INVALID_ARGUMENT]: "Invalid arguments",
  3878. [CoreErrorCodes.INVALID_DATE_ARGUMENT]: "The date provided is an invalid Date object.Make sure your Date represents a valid date.",
  3879. [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: "The argument provided is not a valid ISO date string"
  3880. };
  3881. var NOOP_MESSAGE_FUNCTION = () => "";
  3882. var isMessageFunction = (val) => shared.isFunction(val);
  3883. function translate(context, ...args) {
  3884. const { fallbackFormat, postTranslation, unresolving, messageCompiler: messageCompiler2, fallbackLocale, messages } = context;
  3885. const [key, options] = parseTranslateArgs(...args);
  3886. const missingWarn = shared.isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
  3887. const fallbackWarn = shared.isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
  3888. const escapeParameter = shared.isBoolean(options.escapeParameter) ? options.escapeParameter : context.escapeParameter;
  3889. const resolvedMessage = !!options.resolvedMessage;
  3890. const defaultMsgOrKey = shared.isString(options.default) || shared.isBoolean(options.default) ? !shared.isBoolean(options.default) ? options.default : !messageCompiler2 ? () => key : key : fallbackFormat ? !messageCompiler2 ? () => key : key : "";
  3891. const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== "";
  3892. const locale = shared.isString(options.locale) ? options.locale : context.locale;
  3893. escapeParameter && escapeParams(options);
  3894. let [formatScope, targetLocale, message] = !resolvedMessage ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) : [
  3895. key,
  3896. locale,
  3897. messages[locale] || {}
  3898. ];
  3899. let format = formatScope;
  3900. let cacheBaseKey = key;
  3901. if (!resolvedMessage && !(shared.isString(format) || isMessageFunction(format))) {
  3902. if (enableDefaultMsg) {
  3903. format = defaultMsgOrKey;
  3904. cacheBaseKey = format;
  3905. }
  3906. }
  3907. if (!resolvedMessage && (!(shared.isString(format) || isMessageFunction(format)) || !shared.isString(targetLocale))) {
  3908. return unresolving ? NOT_REOSLVED : key;
  3909. }
  3910. if (shared.isString(format) && context.messageCompiler == null) {
  3911. shared.warn(`The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return '${key}'.`);
  3912. return key;
  3913. }
  3914. let occurred = false;
  3915. const errorDetector = () => {
  3916. occurred = true;
  3917. };
  3918. const msg = !isMessageFunction(format) ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) : format;
  3919. if (occurred) {
  3920. return format;
  3921. }
  3922. const ctxOptions = getMessageContextOptions(context, targetLocale, message, options);
  3923. const msgContext = createMessageContext(ctxOptions);
  3924. const messaged = evaluateMessage(context, msg, msgContext);
  3925. const ret = postTranslation ? postTranslation(messaged, key) : messaged;
  3926. {
  3927. const payloads = {
  3928. timestamp: Date.now(),
  3929. key: shared.isString(key) ? key : isMessageFunction(format) ? format.key : "",
  3930. locale: targetLocale || (isMessageFunction(format) ? format.locale : ""),
  3931. format: shared.isString(format) ? format : isMessageFunction(format) ? format.source : "",
  3932. message: ret
  3933. };
  3934. payloads.meta = shared.assign({}, context.__meta, getAdditionalMeta() || {});
  3935. translateDevTools(payloads);
  3936. }
  3937. return ret;
  3938. }
  3939. function escapeParams(options) {
  3940. if (shared.isArray(options.list)) {
  3941. options.list = options.list.map((item) => shared.isString(item) ? shared.escapeHtml(item) : item);
  3942. } else if (shared.isObject(options.named)) {
  3943. Object.keys(options.named).forEach((key) => {
  3944. if (shared.isString(options.named[key])) {
  3945. options.named[key] = shared.escapeHtml(options.named[key]);
  3946. }
  3947. });
  3948. }
  3949. }
  3950. function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
  3951. const { messages, onWarn, messageResolver: resolveValue2, localeFallbacker } = context;
  3952. const locales = localeFallbacker(context, fallbackLocale, locale);
  3953. let message = {};
  3954. let targetLocale;
  3955. let format = null;
  3956. let from = locale;
  3957. let to = null;
  3958. const type = "translate";
  3959. for (let i = 0; i < locales.length; i++) {
  3960. targetLocale = to = locales[i];
  3961. if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) {
  3962. onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, {
  3963. key,
  3964. target: targetLocale
  3965. }));
  3966. }
  3967. if (locale !== targetLocale) {
  3968. const emitter = context.__v_emitter;
  3969. if (emitter) {
  3970. emitter.emit("fallback", {
  3971. type,
  3972. key,
  3973. from,
  3974. to,
  3975. groupId: `${type}:${key}`
  3976. });
  3977. }
  3978. }
  3979. message = messages[targetLocale] || {};
  3980. let start = null;
  3981. let startTag;
  3982. let endTag;
  3983. if (shared.inBrowser) {
  3984. start = window.performance.now();
  3985. startTag = "intlify-message-resolve-start";
  3986. endTag = "intlify-message-resolve-end";
  3987. shared.mark && shared.mark(startTag);
  3988. }
  3989. if ((format = resolveValue2(message, key)) === null) {
  3990. format = message[key];
  3991. }
  3992. if (shared.inBrowser) {
  3993. const end = window.performance.now();
  3994. const emitter = context.__v_emitter;
  3995. if (emitter && start && format) {
  3996. emitter.emit("message-resolve", {
  3997. type: "message-resolve",
  3998. key,
  3999. message: format,
  4000. time: end - start,
  4001. groupId: `${type}:${key}`
  4002. });
  4003. }
  4004. if (startTag && endTag && shared.mark && shared.measure) {
  4005. shared.mark(endTag);
  4006. shared.measure("intlify message resolve", startTag, endTag);
  4007. }
  4008. }
  4009. if (shared.isString(format) || shared.isFunction(format))
  4010. break;
  4011. const missingRet = handleMissing(
  4012. context,
  4013. key,
  4014. targetLocale,
  4015. missingWarn,
  4016. type
  4017. );
  4018. if (missingRet !== key) {
  4019. format = missingRet;
  4020. }
  4021. from = to;
  4022. }
  4023. return [format, targetLocale, message];
  4024. }
  4025. function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) {
  4026. const { messageCompiler: messageCompiler2, warnHtmlMessage } = context;
  4027. if (isMessageFunction(format)) {
  4028. const msg2 = format;
  4029. msg2.locale = msg2.locale || targetLocale;
  4030. msg2.key = msg2.key || key;
  4031. return msg2;
  4032. }
  4033. if (messageCompiler2 == null) {
  4034. const msg2 = () => format;
  4035. msg2.locale = targetLocale;
  4036. msg2.key = key;
  4037. return msg2;
  4038. }
  4039. let start = null;
  4040. let startTag;
  4041. let endTag;
  4042. if (shared.inBrowser) {
  4043. start = window.performance.now();
  4044. startTag = "intlify-message-compilation-start";
  4045. endTag = "intlify-message-compilation-end";
  4046. shared.mark && shared.mark(startTag);
  4047. }
  4048. const msg = messageCompiler2(format, getCompileOptions(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, errorDetector));
  4049. if (shared.inBrowser) {
  4050. const end = window.performance.now();
  4051. const emitter = context.__v_emitter;
  4052. if (emitter && start) {
  4053. emitter.emit("message-compilation", {
  4054. type: "message-compilation",
  4055. message: format,
  4056. time: end - start,
  4057. groupId: `${"translate"}:${key}`
  4058. });
  4059. }
  4060. if (startTag && endTag && shared.mark && shared.measure) {
  4061. shared.mark(endTag);
  4062. shared.measure("intlify message compilation", startTag, endTag);
  4063. }
  4064. }
  4065. msg.locale = targetLocale;
  4066. msg.key = key;
  4067. msg.source = format;
  4068. return msg;
  4069. }
  4070. function evaluateMessage(context, msg, msgCtx) {
  4071. let start = null;
  4072. let startTag;
  4073. let endTag;
  4074. if (shared.inBrowser) {
  4075. start = window.performance.now();
  4076. startTag = "intlify-message-evaluation-start";
  4077. endTag = "intlify-message-evaluation-end";
  4078. shared.mark && shared.mark(startTag);
  4079. }
  4080. const messaged = msg(msgCtx);
  4081. if (shared.inBrowser) {
  4082. const end = window.performance.now();
  4083. const emitter = context.__v_emitter;
  4084. if (emitter && start) {
  4085. emitter.emit("message-evaluation", {
  4086. type: "message-evaluation",
  4087. value: messaged,
  4088. time: end - start,
  4089. groupId: `${"translate"}:${msg.key}`
  4090. });
  4091. }
  4092. if (startTag && endTag && shared.mark && shared.measure) {
  4093. shared.mark(endTag);
  4094. shared.measure("intlify message evaluation", startTag, endTag);
  4095. }
  4096. }
  4097. return messaged;
  4098. }
  4099. function parseTranslateArgs(...args) {
  4100. const [arg1, arg2, arg3] = args;
  4101. const options = {};
  4102. if (!shared.isString(arg1) && !shared.isNumber(arg1) && !isMessageFunction(arg1)) {
  4103. throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
  4104. }
  4105. const key = shared.isNumber(arg1) ? String(arg1) : isMessageFunction(arg1) ? arg1 : arg1;
  4106. if (shared.isNumber(arg2)) {
  4107. options.plural = arg2;
  4108. } else if (shared.isString(arg2)) {
  4109. options.default = arg2;
  4110. } else if (shared.isPlainObject(arg2) && !shared.isEmptyObject(arg2)) {
  4111. options.named = arg2;
  4112. } else if (shared.isArray(arg2)) {
  4113. options.list = arg2;
  4114. }
  4115. if (shared.isNumber(arg3)) {
  4116. options.plural = arg3;
  4117. } else if (shared.isString(arg3)) {
  4118. options.default = arg3;
  4119. } else if (shared.isPlainObject(arg3)) {
  4120. shared.assign(options, arg3);
  4121. }
  4122. return [key, options];
  4123. }
  4124. function getCompileOptions(context, locale, key, source, warnHtmlMessage, errorDetector) {
  4125. return {
  4126. warnHtmlMessage,
  4127. onError: (err) => {
  4128. errorDetector && errorDetector(err);
  4129. {
  4130. const message = `Message compilation error: ${err.message}`;
  4131. const codeFrame = err.location && shared.generateCodeFrame(source, err.location.start.offset, err.location.end.offset);
  4132. const emitter = context.__v_emitter;
  4133. if (emitter) {
  4134. emitter.emit("compile-error", {
  4135. message: source,
  4136. error: err.message,
  4137. start: err.location && err.location.start.offset,
  4138. end: err.location && err.location.end.offset,
  4139. groupId: `${"translate"}:${key}`
  4140. });
  4141. }
  4142. console.error(codeFrame ? `${message}
  4143. ${codeFrame}` : message);
  4144. }
  4145. },
  4146. onCacheKey: (source2) => shared.generateFormatCacheKey(locale, key, source2)
  4147. };
  4148. }
  4149. function getMessageContextOptions(context, locale, message, options) {
  4150. const { modifiers, pluralRules, messageResolver: resolveValue2, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
  4151. const resolveMessage = (key) => {
  4152. let val = resolveValue2(message, key);
  4153. if (val == null && fallbackContext) {
  4154. const [, , message2] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn);
  4155. val = resolveValue2(message2, key);
  4156. }
  4157. if (shared.isString(val)) {
  4158. let occurred = false;
  4159. const errorDetector = () => {
  4160. occurred = true;
  4161. };
  4162. const msg = compileMessageFormat(context, key, locale, val, key, errorDetector);
  4163. return !occurred ? msg : NOOP_MESSAGE_FUNCTION;
  4164. } else if (isMessageFunction(val)) {
  4165. return val;
  4166. } else {
  4167. return NOOP_MESSAGE_FUNCTION;
  4168. }
  4169. };
  4170. const ctxOptions = {
  4171. locale,
  4172. modifiers,
  4173. pluralRules,
  4174. messages: resolveMessage
  4175. };
  4176. if (context.processor) {
  4177. ctxOptions.processor = context.processor;
  4178. }
  4179. if (options.list) {
  4180. ctxOptions.list = options.list;
  4181. }
  4182. if (options.named) {
  4183. ctxOptions.named = options.named;
  4184. }
  4185. if (shared.isNumber(options.plural)) {
  4186. ctxOptions.pluralIndex = options.plural;
  4187. }
  4188. return ctxOptions;
  4189. }
  4190. var intlDefined = typeof Intl !== "undefined";
  4191. var Availabilities = {
  4192. dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== "undefined",
  4193. numberFormat: intlDefined && typeof Intl.NumberFormat !== "undefined"
  4194. };
  4195. function datetime(context, ...args) {
  4196. const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
  4197. const { __datetimeFormatters } = context;
  4198. if (!Availabilities.dateTimeFormat) {
  4199. onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE));
  4200. return MISSING_RESOLVE_VALUE;
  4201. }
  4202. const [key, value, options, overrides] = parseDateTimeArgs(...args);
  4203. const missingWarn = shared.isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
  4204. const fallbackWarn = shared.isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
  4205. const part = !!options.part;
  4206. const locale = shared.isString(options.locale) ? options.locale : context.locale;
  4207. const locales = localeFallbacker(
  4208. context,
  4209. fallbackLocale,
  4210. locale
  4211. );
  4212. if (!shared.isString(key) || key === "") {
  4213. return new Intl.DateTimeFormat(locale, overrides).format(value);
  4214. }
  4215. let datetimeFormat = {};
  4216. let targetLocale;
  4217. let format = null;
  4218. let from = locale;
  4219. let to = null;
  4220. const type = "datetime format";
  4221. for (let i = 0; i < locales.length; i++) {
  4222. targetLocale = to = locales[i];
  4223. if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) {
  4224. onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, {
  4225. key,
  4226. target: targetLocale
  4227. }));
  4228. }
  4229. if (locale !== targetLocale) {
  4230. const emitter = context.__v_emitter;
  4231. if (emitter) {
  4232. emitter.emit("fallback", {
  4233. type,
  4234. key,
  4235. from,
  4236. to,
  4237. groupId: `${type}:${key}`
  4238. });
  4239. }
  4240. }
  4241. datetimeFormat = datetimeFormats[targetLocale] || {};
  4242. format = datetimeFormat[key];
  4243. if (shared.isPlainObject(format))
  4244. break;
  4245. handleMissing(context, key, targetLocale, missingWarn, type);
  4246. from = to;
  4247. }
  4248. if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) {
  4249. return unresolving ? NOT_REOSLVED : key;
  4250. }
  4251. let id = `${targetLocale}__${key}`;
  4252. if (!shared.isEmptyObject(overrides)) {
  4253. id = `${id}__${JSON.stringify(overrides)}`;
  4254. }
  4255. let formatter = __datetimeFormatters.get(id);
  4256. if (!formatter) {
  4257. formatter = new Intl.DateTimeFormat(targetLocale, shared.assign({}, format, overrides));
  4258. __datetimeFormatters.set(id, formatter);
  4259. }
  4260. return !part ? formatter.format(value) : formatter.formatToParts(value);
  4261. }
  4262. var DATETIME_FORMAT_OPTIONS_KEYS = [
  4263. "localeMatcher",
  4264. "weekday",
  4265. "era",
  4266. "year",
  4267. "month",
  4268. "day",
  4269. "hour",
  4270. "minute",
  4271. "second",
  4272. "timeZoneName",
  4273. "formatMatcher",
  4274. "hour12",
  4275. "timeZone",
  4276. "dateStyle",
  4277. "timeStyle",
  4278. "calendar",
  4279. "dayPeriod",
  4280. "numberingSystem",
  4281. "hourCycle",
  4282. "fractionalSecondDigits"
  4283. ];
  4284. function parseDateTimeArgs(...args) {
  4285. const [arg1, arg2, arg3, arg4] = args;
  4286. const options = {};
  4287. let overrides = {};
  4288. let value;
  4289. if (shared.isString(arg1)) {
  4290. const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);
  4291. if (!matches) {
  4292. throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
  4293. }
  4294. const dateTime = matches[3] ? matches[3].trim().startsWith("T") ? `${matches[1].trim()}${matches[3].trim()}` : `${matches[1].trim()}T${matches[3].trim()}` : matches[1].trim();
  4295. value = new Date(dateTime);
  4296. try {
  4297. value.toISOString();
  4298. } catch (e) {
  4299. throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
  4300. }
  4301. } else if (shared.isDate(arg1)) {
  4302. if (isNaN(arg1.getTime())) {
  4303. throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT);
  4304. }
  4305. value = arg1;
  4306. } else if (shared.isNumber(arg1)) {
  4307. value = arg1;
  4308. } else {
  4309. throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
  4310. }
  4311. if (shared.isString(arg2)) {
  4312. options.key = arg2;
  4313. } else if (shared.isPlainObject(arg2)) {
  4314. Object.keys(arg2).forEach((key) => {
  4315. if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) {
  4316. overrides[key] = arg2[key];
  4317. } else {
  4318. options[key] = arg2[key];
  4319. }
  4320. });
  4321. }
  4322. if (shared.isString(arg3)) {
  4323. options.locale = arg3;
  4324. } else if (shared.isPlainObject(arg3)) {
  4325. overrides = arg3;
  4326. }
  4327. if (shared.isPlainObject(arg4)) {
  4328. overrides = arg4;
  4329. }
  4330. return [options.key || "", value, options, overrides];
  4331. }
  4332. function clearDateTimeFormat(ctx, locale, format) {
  4333. const context = ctx;
  4334. for (const key in format) {
  4335. const id = `${locale}__${key}`;
  4336. if (!context.__datetimeFormatters.has(id)) {
  4337. continue;
  4338. }
  4339. context.__datetimeFormatters.delete(id);
  4340. }
  4341. }
  4342. function number(context, ...args) {
  4343. const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
  4344. const { __numberFormatters } = context;
  4345. if (!Availabilities.numberFormat) {
  4346. onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER));
  4347. return MISSING_RESOLVE_VALUE;
  4348. }
  4349. const [key, value, options, overrides] = parseNumberArgs(...args);
  4350. const missingWarn = shared.isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
  4351. const fallbackWarn = shared.isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
  4352. const part = !!options.part;
  4353. const locale = shared.isString(options.locale) ? options.locale : context.locale;
  4354. const locales = localeFallbacker(
  4355. context,
  4356. fallbackLocale,
  4357. locale
  4358. );
  4359. if (!shared.isString(key) || key === "") {
  4360. return new Intl.NumberFormat(locale, overrides).format(value);
  4361. }
  4362. let numberFormat = {};
  4363. let targetLocale;
  4364. let format = null;
  4365. let from = locale;
  4366. let to = null;
  4367. const type = "number format";
  4368. for (let i = 0; i < locales.length; i++) {
  4369. targetLocale = to = locales[i];
  4370. if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) {
  4371. onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
  4372. key,
  4373. target: targetLocale
  4374. }));
  4375. }
  4376. if (locale !== targetLocale) {
  4377. const emitter = context.__v_emitter;
  4378. if (emitter) {
  4379. emitter.emit("fallback", {
  4380. type,
  4381. key,
  4382. from,
  4383. to,
  4384. groupId: `${type}:${key}`
  4385. });
  4386. }
  4387. }
  4388. numberFormat = numberFormats[targetLocale] || {};
  4389. format = numberFormat[key];
  4390. if (shared.isPlainObject(format))
  4391. break;
  4392. handleMissing(context, key, targetLocale, missingWarn, type);
  4393. from = to;
  4394. }
  4395. if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) {
  4396. return unresolving ? NOT_REOSLVED : key;
  4397. }
  4398. let id = `${targetLocale}__${key}`;
  4399. if (!shared.isEmptyObject(overrides)) {
  4400. id = `${id}__${JSON.stringify(overrides)}`;
  4401. }
  4402. let formatter = __numberFormatters.get(id);
  4403. if (!formatter) {
  4404. formatter = new Intl.NumberFormat(targetLocale, shared.assign({}, format, overrides));
  4405. __numberFormatters.set(id, formatter);
  4406. }
  4407. return !part ? formatter.format(value) : formatter.formatToParts(value);
  4408. }
  4409. var NUMBER_FORMAT_OPTIONS_KEYS = [
  4410. "localeMatcher",
  4411. "style",
  4412. "currency",
  4413. "currencyDisplay",
  4414. "currencySign",
  4415. "useGrouping",
  4416. "minimumIntegerDigits",
  4417. "minimumFractionDigits",
  4418. "maximumFractionDigits",
  4419. "minimumSignificantDigits",
  4420. "maximumSignificantDigits",
  4421. "compactDisplay",
  4422. "notation",
  4423. "signDisplay",
  4424. "unit",
  4425. "unitDisplay",
  4426. "roundingMode",
  4427. "roundingPriority",
  4428. "roundingIncrement",
  4429. "trailingZeroDisplay"
  4430. ];
  4431. function parseNumberArgs(...args) {
  4432. const [arg1, arg2, arg3, arg4] = args;
  4433. const options = {};
  4434. let overrides = {};
  4435. if (!shared.isNumber(arg1)) {
  4436. throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
  4437. }
  4438. const value = arg1;
  4439. if (shared.isString(arg2)) {
  4440. options.key = arg2;
  4441. } else if (shared.isPlainObject(arg2)) {
  4442. Object.keys(arg2).forEach((key) => {
  4443. if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) {
  4444. overrides[key] = arg2[key];
  4445. } else {
  4446. options[key] = arg2[key];
  4447. }
  4448. });
  4449. }
  4450. if (shared.isString(arg3)) {
  4451. options.locale = arg3;
  4452. } else if (shared.isPlainObject(arg3)) {
  4453. overrides = arg3;
  4454. }
  4455. if (shared.isPlainObject(arg4)) {
  4456. overrides = arg4;
  4457. }
  4458. return [options.key || "", value, options, overrides];
  4459. }
  4460. function clearNumberFormat(ctx, locale, format) {
  4461. const context = ctx;
  4462. for (const key in format) {
  4463. const id = `${locale}__${key}`;
  4464. if (!context.__numberFormatters.has(id)) {
  4465. continue;
  4466. }
  4467. context.__numberFormatters.delete(id);
  4468. }
  4469. }
  4470. exports.CompileErrorCodes = messageCompiler.CompileErrorCodes;
  4471. exports.createCompileError = messageCompiler.createCompileError;
  4472. exports.CoreErrorCodes = CoreErrorCodes;
  4473. exports.CoreWarnCodes = CoreWarnCodes;
  4474. exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS;
  4475. exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
  4476. exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE;
  4477. exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE;
  4478. exports.NOT_REOSLVED = NOT_REOSLVED;
  4479. exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS;
  4480. exports.VERSION = VERSION;
  4481. exports.clearCompileCache = clearCompileCache;
  4482. exports.clearDateTimeFormat = clearDateTimeFormat;
  4483. exports.clearNumberFormat = clearNumberFormat;
  4484. exports.compileToFunction = compileToFunction;
  4485. exports.createCoreContext = createCoreContext;
  4486. exports.createCoreError = createCoreError;
  4487. exports.createMessageContext = createMessageContext;
  4488. exports.datetime = datetime;
  4489. exports.fallbackWithLocaleChain = fallbackWithLocaleChain;
  4490. exports.fallbackWithSimple = fallbackWithSimple;
  4491. exports.getAdditionalMeta = getAdditionalMeta;
  4492. exports.getDevToolsHook = getDevToolsHook;
  4493. exports.getFallbackContext = getFallbackContext;
  4494. exports.getWarnMessage = getWarnMessage;
  4495. exports.handleMissing = handleMissing;
  4496. exports.initI18nDevTools = initI18nDevTools;
  4497. exports.isMessageFunction = isMessageFunction;
  4498. exports.isTranslateFallbackWarn = isTranslateFallbackWarn;
  4499. exports.isTranslateMissingWarn = isTranslateMissingWarn;
  4500. exports.number = number;
  4501. exports.parse = parse2;
  4502. exports.parseDateTimeArgs = parseDateTimeArgs;
  4503. exports.parseNumberArgs = parseNumberArgs;
  4504. exports.parseTranslateArgs = parseTranslateArgs;
  4505. exports.registerLocaleFallbacker = registerLocaleFallbacker;
  4506. exports.registerMessageCompiler = registerMessageCompiler;
  4507. exports.registerMessageResolver = registerMessageResolver;
  4508. exports.resolveValue = resolveValue;
  4509. exports.resolveWithKeyValue = resolveWithKeyValue;
  4510. exports.setAdditionalMeta = setAdditionalMeta;
  4511. exports.setDevToolsHook = setDevToolsHook;
  4512. exports.setFallbackContext = setFallbackContext;
  4513. exports.translate = translate;
  4514. exports.translateDevTools = translateDevTools;
  4515. exports.updateFallbackLocale = updateFallbackLocale;
  4516. }
  4517. });
  4518. // node_modules/@intlify/core-base/index.js
  4519. var require_core_base = __commonJS({
  4520. "node_modules/@intlify/core-base/index.js"(exports, module) {
  4521. "use strict";
  4522. init_define_APP_INFO();
  4523. if (false) {
  4524. module.exports = null;
  4525. } else {
  4526. module.exports = require_core_base_cjs();
  4527. }
  4528. }
  4529. });
  4530. // node_modules/vue/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
  4531. function defaultOnError(error) {
  4532. throw error;
  4533. }
  4534. function defaultOnWarn(msg) {
  4535. console.warn(`[Vue warn] ${msg.message}`);
  4536. }
  4537. function createCompilerError(code, loc, messages, additionalMessage) {
  4538. const msg = true ? (messages || errorMessages)[code] + (additionalMessage || ``) : code;
  4539. const error = new SyntaxError(String(msg));
  4540. error.code = code;
  4541. error.loc = loc;
  4542. return error;
  4543. }
  4544. function registerRuntimeHelpers(helpers) {
  4545. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  4546. helperNameMap[s] = helpers[s];
  4547. });
  4548. }
  4549. function createRoot(children, loc = locStub) {
  4550. return {
  4551. type: 0,
  4552. children,
  4553. helpers: [],
  4554. components: [],
  4555. directives: [],
  4556. hoists: [],
  4557. imports: [],
  4558. cached: 0,
  4559. temps: 0,
  4560. codegenNode: void 0,
  4561. loc
  4562. };
  4563. }
  4564. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent2 = false, loc = locStub) {
  4565. if (context) {
  4566. if (isBlock) {
  4567. context.helper(OPEN_BLOCK);
  4568. context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
  4569. } else {
  4570. context.helper(getVNodeHelper(context.inSSR, isComponent2));
  4571. }
  4572. if (directives) {
  4573. context.helper(WITH_DIRECTIVES);
  4574. }
  4575. }
  4576. return {
  4577. type: 13,
  4578. tag,
  4579. props,
  4580. children,
  4581. patchFlag,
  4582. dynamicProps,
  4583. directives,
  4584. isBlock,
  4585. disableTracking,
  4586. isComponent: isComponent2,
  4587. loc
  4588. };
  4589. }
  4590. function createArrayExpression(elements, loc = locStub) {
  4591. return {
  4592. type: 17,
  4593. loc,
  4594. elements
  4595. };
  4596. }
  4597. function createObjectExpression(properties, loc = locStub) {
  4598. return {
  4599. type: 15,
  4600. loc,
  4601. properties
  4602. };
  4603. }
  4604. function createObjectProperty(key, value) {
  4605. return {
  4606. type: 16,
  4607. loc: locStub,
  4608. key: isString(key) ? createSimpleExpression(key, true) : key,
  4609. value
  4610. };
  4611. }
  4612. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  4613. return {
  4614. type: 4,
  4615. loc,
  4616. content,
  4617. isStatic,
  4618. constType: isStatic ? 3 : constType
  4619. };
  4620. }
  4621. function createInterpolation(content, loc) {
  4622. return {
  4623. type: 5,
  4624. loc,
  4625. content: isString(content) ? createSimpleExpression(content, false, loc) : content
  4626. };
  4627. }
  4628. function createCompoundExpression(children, loc = locStub) {
  4629. return {
  4630. type: 8,
  4631. loc,
  4632. children
  4633. };
  4634. }
  4635. function createCallExpression(callee, args = [], loc = locStub) {
  4636. return {
  4637. type: 14,
  4638. loc,
  4639. callee,
  4640. arguments: args
  4641. };
  4642. }
  4643. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  4644. return {
  4645. type: 18,
  4646. params,
  4647. returns,
  4648. newline,
  4649. isSlot,
  4650. loc
  4651. };
  4652. }
  4653. function createConditionalExpression(test, consequent, alternate, newline = true) {
  4654. return {
  4655. type: 19,
  4656. test,
  4657. consequent,
  4658. alternate,
  4659. newline,
  4660. loc: locStub
  4661. };
  4662. }
  4663. function createCacheExpression(index, value, isVNode = false) {
  4664. return {
  4665. type: 20,
  4666. index,
  4667. value,
  4668. isVNode,
  4669. loc: locStub
  4670. };
  4671. }
  4672. function createBlockStatement(body) {
  4673. return {
  4674. type: 21,
  4675. body,
  4676. loc: locStub
  4677. };
  4678. }
  4679. function createTemplateLiteral(elements) {
  4680. return {
  4681. type: 22,
  4682. elements,
  4683. loc: locStub
  4684. };
  4685. }
  4686. function createIfStatement(test, consequent, alternate) {
  4687. return {
  4688. type: 23,
  4689. test,
  4690. consequent,
  4691. alternate,
  4692. loc: locStub
  4693. };
  4694. }
  4695. function createAssignmentExpression(left, right) {
  4696. return {
  4697. type: 24,
  4698. left,
  4699. right,
  4700. loc: locStub
  4701. };
  4702. }
  4703. function createSequenceExpression(expressions) {
  4704. return {
  4705. type: 25,
  4706. expressions,
  4707. loc: locStub
  4708. };
  4709. }
  4710. function createReturnStatement(returns) {
  4711. return {
  4712. type: 26,
  4713. returns,
  4714. loc: locStub
  4715. };
  4716. }
  4717. function isCoreComponent(tag) {
  4718. if (isBuiltInType(tag, "Teleport")) {
  4719. return TELEPORT;
  4720. } else if (isBuiltInType(tag, "Suspense")) {
  4721. return SUSPENSE;
  4722. } else if (isBuiltInType(tag, "KeepAlive")) {
  4723. return KEEP_ALIVE;
  4724. } else if (isBuiltInType(tag, "BaseTransition")) {
  4725. return BASE_TRANSITION;
  4726. }
  4727. }
  4728. function getInnerRange(loc, offset, length) {
  4729. const source = loc.source.slice(offset, offset + length);
  4730. const newLoc = {
  4731. source,
  4732. start: advancePositionWithClone(loc.start, loc.source, offset),
  4733. end: loc.end
  4734. };
  4735. if (length != null) {
  4736. newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
  4737. }
  4738. return newLoc;
  4739. }
  4740. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  4741. return advancePositionWithMutation(extend({}, pos), source, numberOfCharacters);
  4742. }
  4743. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  4744. let linesCount = 0;
  4745. let lastNewLinePos = -1;
  4746. for (let i = 0; i < numberOfCharacters; i++) {
  4747. if (source.charCodeAt(i) === 10) {
  4748. linesCount++;
  4749. lastNewLinePos = i;
  4750. }
  4751. }
  4752. pos.offset += numberOfCharacters;
  4753. pos.line += linesCount;
  4754. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  4755. return pos;
  4756. }
  4757. function assert(condition, msg) {
  4758. if (!condition) {
  4759. throw new Error(msg || `unexpected compiler condition`);
  4760. }
  4761. }
  4762. function findDir(node, name, allowEmpty = false) {
  4763. for (let i = 0; i < node.props.length; i++) {
  4764. const p = node.props[i];
  4765. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  4766. return p;
  4767. }
  4768. }
  4769. }
  4770. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  4771. for (let i = 0; i < node.props.length; i++) {
  4772. const p = node.props[i];
  4773. if (p.type === 6) {
  4774. if (dynamicOnly)
  4775. continue;
  4776. if (p.name === name && (p.value || allowEmpty)) {
  4777. return p;
  4778. }
  4779. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  4780. return p;
  4781. }
  4782. }
  4783. }
  4784. function isStaticArgOf(arg, name) {
  4785. return !!(arg && isStaticExp(arg) && arg.content === name);
  4786. }
  4787. function hasDynamicKeyVBind(node) {
  4788. return node.props.some(
  4789. (p) => p.type === 7 && p.name === "bind" && (!p.arg || p.arg.type !== 4 || !p.arg.isStatic)
  4790. );
  4791. }
  4792. function isText(node) {
  4793. return node.type === 5 || node.type === 2;
  4794. }
  4795. function isVSlot(p) {
  4796. return p.type === 7 && p.name === "slot";
  4797. }
  4798. function isTemplateNode(node) {
  4799. return node.type === 1 && node.tagType === 3;
  4800. }
  4801. function isSlotOutlet(node) {
  4802. return node.type === 1 && node.tagType === 2;
  4803. }
  4804. function getVNodeHelper(ssr, isComponent2) {
  4805. return ssr || isComponent2 ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  4806. }
  4807. function getVNodeBlockHelper(ssr, isComponent2) {
  4808. return ssr || isComponent2 ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  4809. }
  4810. function getUnnormalizedProps(props, callPath = []) {
  4811. if (props && !isString(props) && props.type === 14) {
  4812. const callee = props.callee;
  4813. if (!isString(callee) && propsHelperSet.has(callee)) {
  4814. return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
  4815. }
  4816. }
  4817. return [props, callPath];
  4818. }
  4819. function injectProp(node, prop, context) {
  4820. let propsWithInjection;
  4821. let props = node.type === 13 ? node.props : node.arguments[2];
  4822. let callPath = [];
  4823. let parentCall;
  4824. if (props && !isString(props) && props.type === 14) {
  4825. const ret = getUnnormalizedProps(props);
  4826. props = ret[0];
  4827. callPath = ret[1];
  4828. parentCall = callPath[callPath.length - 1];
  4829. }
  4830. if (props == null || isString(props)) {
  4831. propsWithInjection = createObjectExpression([prop]);
  4832. } else if (props.type === 14) {
  4833. const first = props.arguments[0];
  4834. if (!isString(first) && first.type === 15) {
  4835. first.properties.unshift(prop);
  4836. } else {
  4837. if (props.callee === TO_HANDLERS) {
  4838. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  4839. createObjectExpression([prop]),
  4840. props
  4841. ]);
  4842. } else {
  4843. props.arguments.unshift(createObjectExpression([prop]));
  4844. }
  4845. }
  4846. !propsWithInjection && (propsWithInjection = props);
  4847. } else if (props.type === 15) {
  4848. let alreadyExists = false;
  4849. if (prop.key.type === 4) {
  4850. const propKeyName = prop.key.content;
  4851. alreadyExists = props.properties.some((p) => p.key.type === 4 && p.key.content === propKeyName);
  4852. }
  4853. if (!alreadyExists) {
  4854. props.properties.unshift(prop);
  4855. }
  4856. propsWithInjection = props;
  4857. } else {
  4858. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  4859. createObjectExpression([prop]),
  4860. props
  4861. ]);
  4862. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  4863. parentCall = callPath[callPath.length - 2];
  4864. }
  4865. }
  4866. if (node.type === 13) {
  4867. if (parentCall) {
  4868. parentCall.arguments[0] = propsWithInjection;
  4869. } else {
  4870. node.props = propsWithInjection;
  4871. }
  4872. } else {
  4873. if (parentCall) {
  4874. parentCall.arguments[0] = propsWithInjection;
  4875. } else {
  4876. node.arguments[2] = propsWithInjection;
  4877. }
  4878. }
  4879. }
  4880. function toValidAssetId(name, type) {
  4881. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  4882. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  4883. })}`;
  4884. }
  4885. function hasScopeRef(node, ids) {
  4886. if (!node || Object.keys(ids).length === 0) {
  4887. return false;
  4888. }
  4889. switch (node.type) {
  4890. case 1:
  4891. for (let i = 0; i < node.props.length; i++) {
  4892. const p = node.props[i];
  4893. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  4894. return true;
  4895. }
  4896. }
  4897. return node.children.some((c) => hasScopeRef(c, ids));
  4898. case 11:
  4899. if (hasScopeRef(node.source, ids)) {
  4900. return true;
  4901. }
  4902. return node.children.some((c) => hasScopeRef(c, ids));
  4903. case 9:
  4904. return node.branches.some((b) => hasScopeRef(b, ids));
  4905. case 10:
  4906. if (hasScopeRef(node.condition, ids)) {
  4907. return true;
  4908. }
  4909. return node.children.some((c) => hasScopeRef(c, ids));
  4910. case 4:
  4911. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  4912. case 8:
  4913. return node.children.some((c) => isObject(c) && hasScopeRef(c, ids));
  4914. case 5:
  4915. case 12:
  4916. return hasScopeRef(node.content, ids);
  4917. case 2:
  4918. case 3:
  4919. return false;
  4920. default:
  4921. if (true)
  4922. ;
  4923. return false;
  4924. }
  4925. }
  4926. function getMemoedVNodeCall(node) {
  4927. if (node.type === 14 && node.callee === WITH_MEMO) {
  4928. return node.arguments[1].returns;
  4929. } else {
  4930. return node;
  4931. }
  4932. }
  4933. function makeBlock(node, { helper, removeHelper, inSSR }) {
  4934. if (!node.isBlock) {
  4935. node.isBlock = true;
  4936. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  4937. helper(OPEN_BLOCK);
  4938. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  4939. }
  4940. }
  4941. function getCompatValue(key, context) {
  4942. const config = context.options ? context.options.compatConfig : context.compatConfig;
  4943. const value = config && config[key];
  4944. if (key === "MODE") {
  4945. return value || 3;
  4946. } else {
  4947. return value;
  4948. }
  4949. }
  4950. function isCompatEnabled(key, context) {
  4951. const mode = getCompatValue("MODE", context);
  4952. const value = getCompatValue(key, context);
  4953. return mode === 3 ? value === true : value !== false;
  4954. }
  4955. function checkCompatEnabled(key, context, loc, ...args) {
  4956. const enabled = isCompatEnabled(key, context);
  4957. if (enabled) {
  4958. warnDeprecation(key, context, loc, ...args);
  4959. }
  4960. return enabled;
  4961. }
  4962. function warnDeprecation(key, context, loc, ...args) {
  4963. const val = getCompatValue(key, context);
  4964. if (val === "suppress-warning") {
  4965. return;
  4966. }
  4967. const { message, link } = deprecationData[key];
  4968. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  4969. Details: ${link}` : ``}`;
  4970. const err = new SyntaxError(msg);
  4971. err.code = key;
  4972. if (loc)
  4973. err.loc = loc;
  4974. context.onWarn(err);
  4975. }
  4976. function baseParse(content, options = {}) {
  4977. const context = createParserContext(content, options);
  4978. const start = getCursor(context);
  4979. return createRoot(parseChildren(context, 0, []), getSelection(context, start));
  4980. }
  4981. function createParserContext(content, rawOptions) {
  4982. const options = extend({}, defaultParserOptions);
  4983. let key;
  4984. for (key in rawOptions) {
  4985. options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
  4986. }
  4987. return {
  4988. options,
  4989. column: 1,
  4990. line: 1,
  4991. offset: 0,
  4992. originalSource: content,
  4993. source: content,
  4994. inPre: false,
  4995. inVPre: false,
  4996. onWarn: options.onWarn
  4997. };
  4998. }
  4999. function parseChildren(context, mode, ancestors) {
  5000. const parent = last(ancestors);
  5001. const ns = parent ? parent.ns : 0;
  5002. const nodes = [];
  5003. while (!isEnd(context, mode, ancestors)) {
  5004. const s = context.source;
  5005. let node = void 0;
  5006. if (mode === 0 || mode === 1) {
  5007. if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
  5008. node = parseInterpolation(context, mode);
  5009. } else if (mode === 0 && s[0] === "<") {
  5010. if (s.length === 1) {
  5011. emitError(context, 5, 1);
  5012. } else if (s[1] === "!") {
  5013. if (startsWith(s, "<!--")) {
  5014. node = parseComment(context);
  5015. } else if (startsWith(s, "<!DOCTYPE")) {
  5016. node = parseBogusComment(context);
  5017. } else if (startsWith(s, "<![CDATA[")) {
  5018. if (ns !== 0) {
  5019. node = parseCDATA(context, ancestors);
  5020. } else {
  5021. emitError(context, 1);
  5022. node = parseBogusComment(context);
  5023. }
  5024. } else {
  5025. emitError(context, 11);
  5026. node = parseBogusComment(context);
  5027. }
  5028. } else if (s[1] === "/") {
  5029. if (s.length === 2) {
  5030. emitError(context, 5, 2);
  5031. } else if (s[2] === ">") {
  5032. emitError(context, 14, 2);
  5033. advanceBy(context, 3);
  5034. continue;
  5035. } else if (/[a-z]/i.test(s[2])) {
  5036. emitError(context, 23);
  5037. parseTag(context, 1, parent);
  5038. continue;
  5039. } else {
  5040. emitError(context, 12, 2);
  5041. node = parseBogusComment(context);
  5042. }
  5043. } else if (/[a-z]/i.test(s[1])) {
  5044. node = parseElement(context, ancestors);
  5045. if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE", context) && node && node.tag === "template" && !node.props.some((p) => p.type === 7 && isSpecialTemplateDirective(p.name))) {
  5046. warnDeprecation("COMPILER_NATIVE_TEMPLATE", context, node.loc);
  5047. node = node.children;
  5048. }
  5049. } else if (s[1] === "?") {
  5050. emitError(context, 21, 1);
  5051. node = parseBogusComment(context);
  5052. } else {
  5053. emitError(context, 12, 1);
  5054. }
  5055. }
  5056. }
  5057. if (!node) {
  5058. node = parseText(context, mode);
  5059. }
  5060. if (isArray(node)) {
  5061. for (let i = 0; i < node.length; i++) {
  5062. pushNode(nodes, node[i]);
  5063. }
  5064. } else {
  5065. pushNode(nodes, node);
  5066. }
  5067. }
  5068. let removedWhitespace = false;
  5069. if (mode !== 2 && mode !== 1) {
  5070. const shouldCondense = context.options.whitespace !== "preserve";
  5071. for (let i = 0; i < nodes.length; i++) {
  5072. const node = nodes[i];
  5073. if (!context.inPre && node.type === 2) {
  5074. if (!/[^\t\r\n\f ]/.test(node.content)) {
  5075. const prev = nodes[i - 1];
  5076. const next = nodes[i + 1];
  5077. if (!prev || !next || shouldCondense && (prev.type === 3 || next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
  5078. removedWhitespace = true;
  5079. nodes[i] = null;
  5080. } else {
  5081. node.content = " ";
  5082. }
  5083. } else if (shouldCondense) {
  5084. node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
  5085. }
  5086. } else if (node.type === 3 && !context.options.comments) {
  5087. removedWhitespace = true;
  5088. nodes[i] = null;
  5089. }
  5090. }
  5091. if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
  5092. const first = nodes[0];
  5093. if (first && first.type === 2) {
  5094. first.content = first.content.replace(/^\r?\n/, "");
  5095. }
  5096. }
  5097. }
  5098. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  5099. }
  5100. function pushNode(nodes, node) {
  5101. if (node.type === 2) {
  5102. const prev = last(nodes);
  5103. if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
  5104. prev.content += node.content;
  5105. prev.loc.end = node.loc.end;
  5106. prev.loc.source += node.loc.source;
  5107. return;
  5108. }
  5109. }
  5110. nodes.push(node);
  5111. }
  5112. function parseCDATA(context, ancestors) {
  5113. advanceBy(context, 9);
  5114. const nodes = parseChildren(context, 3, ancestors);
  5115. if (context.source.length === 0) {
  5116. emitError(context, 6);
  5117. } else {
  5118. advanceBy(context, 3);
  5119. }
  5120. return nodes;
  5121. }
  5122. function parseComment(context) {
  5123. const start = getCursor(context);
  5124. let content;
  5125. const match = /--(\!)?>/.exec(context.source);
  5126. if (!match) {
  5127. content = context.source.slice(4);
  5128. advanceBy(context, context.source.length);
  5129. emitError(context, 7);
  5130. } else {
  5131. if (match.index <= 3) {
  5132. emitError(context, 0);
  5133. }
  5134. if (match[1]) {
  5135. emitError(context, 10);
  5136. }
  5137. content = context.source.slice(4, match.index);
  5138. const s = context.source.slice(0, match.index);
  5139. let prevIndex = 1, nestedIndex = 0;
  5140. while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
  5141. advanceBy(context, nestedIndex - prevIndex + 1);
  5142. if (nestedIndex + 4 < s.length) {
  5143. emitError(context, 16);
  5144. }
  5145. prevIndex = nestedIndex + 1;
  5146. }
  5147. advanceBy(context, match.index + match[0].length - prevIndex + 1);
  5148. }
  5149. return {
  5150. type: 3,
  5151. content,
  5152. loc: getSelection(context, start)
  5153. };
  5154. }
  5155. function parseBogusComment(context) {
  5156. const start = getCursor(context);
  5157. const contentStart = context.source[1] === "?" ? 1 : 2;
  5158. let content;
  5159. const closeIndex = context.source.indexOf(">");
  5160. if (closeIndex === -1) {
  5161. content = context.source.slice(contentStart);
  5162. advanceBy(context, context.source.length);
  5163. } else {
  5164. content = context.source.slice(contentStart, closeIndex);
  5165. advanceBy(context, closeIndex + 1);
  5166. }
  5167. return {
  5168. type: 3,
  5169. content,
  5170. loc: getSelection(context, start)
  5171. };
  5172. }
  5173. function parseElement(context, ancestors) {
  5174. const wasInPre = context.inPre;
  5175. const wasInVPre = context.inVPre;
  5176. const parent = last(ancestors);
  5177. const element = parseTag(context, 0, parent);
  5178. const isPreBoundary = context.inPre && !wasInPre;
  5179. const isVPreBoundary = context.inVPre && !wasInVPre;
  5180. if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
  5181. if (isPreBoundary) {
  5182. context.inPre = false;
  5183. }
  5184. if (isVPreBoundary) {
  5185. context.inVPre = false;
  5186. }
  5187. return element;
  5188. }
  5189. ancestors.push(element);
  5190. const mode = context.options.getTextMode(element, parent);
  5191. const children = parseChildren(context, mode, ancestors);
  5192. ancestors.pop();
  5193. {
  5194. const inlineTemplateProp = element.props.find((p) => p.type === 6 && p.name === "inline-template");
  5195. if (inlineTemplateProp && checkCompatEnabled("COMPILER_INLINE_TEMPLATE", context, inlineTemplateProp.loc)) {
  5196. const loc = getSelection(context, element.loc.end);
  5197. inlineTemplateProp.value = {
  5198. type: 2,
  5199. content: loc.source,
  5200. loc
  5201. };
  5202. }
  5203. }
  5204. element.children = children;
  5205. if (startsWithEndTagOpen(context.source, element.tag)) {
  5206. parseTag(context, 1, parent);
  5207. } else {
  5208. emitError(context, 24, 0, element.loc.start);
  5209. if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
  5210. const first = children[0];
  5211. if (first && startsWith(first.loc.source, "<!--")) {
  5212. emitError(context, 8);
  5213. }
  5214. }
  5215. }
  5216. element.loc = getSelection(context, element.loc.start);
  5217. if (isPreBoundary) {
  5218. context.inPre = false;
  5219. }
  5220. if (isVPreBoundary) {
  5221. context.inVPre = false;
  5222. }
  5223. return element;
  5224. }
  5225. function parseTag(context, type, parent) {
  5226. const start = getCursor(context);
  5227. const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
  5228. const tag = match[1];
  5229. const ns = context.options.getNamespace(tag, parent);
  5230. advanceBy(context, match[0].length);
  5231. advanceSpaces(context);
  5232. const cursor = getCursor(context);
  5233. const currentSource = context.source;
  5234. if (context.options.isPreTag(tag)) {
  5235. context.inPre = true;
  5236. }
  5237. let props = parseAttributes(context, type);
  5238. if (type === 0 && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
  5239. context.inVPre = true;
  5240. extend(context, cursor);
  5241. context.source = currentSource;
  5242. props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
  5243. }
  5244. let isSelfClosing = false;
  5245. if (context.source.length === 0) {
  5246. emitError(context, 9);
  5247. } else {
  5248. isSelfClosing = startsWith(context.source, "/>");
  5249. if (type === 1 && isSelfClosing) {
  5250. emitError(context, 4);
  5251. }
  5252. advanceBy(context, isSelfClosing ? 2 : 1);
  5253. }
  5254. if (type === 1) {
  5255. return;
  5256. }
  5257. if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE", context)) {
  5258. let hasIf = false;
  5259. let hasFor = false;
  5260. for (let i = 0; i < props.length; i++) {
  5261. const p = props[i];
  5262. if (p.type === 7) {
  5263. if (p.name === "if") {
  5264. hasIf = true;
  5265. } else if (p.name === "for") {
  5266. hasFor = true;
  5267. }
  5268. }
  5269. if (hasIf && hasFor) {
  5270. warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE", context, getSelection(context, start));
  5271. break;
  5272. }
  5273. }
  5274. }
  5275. let tagType = 0;
  5276. if (!context.inVPre) {
  5277. if (tag === "slot") {
  5278. tagType = 2;
  5279. } else if (tag === "template") {
  5280. if (props.some((p) => p.type === 7 && isSpecialTemplateDirective(p.name))) {
  5281. tagType = 3;
  5282. }
  5283. } else if (isComponent(tag, props, context)) {
  5284. tagType = 1;
  5285. }
  5286. }
  5287. return {
  5288. type: 1,
  5289. ns,
  5290. tag,
  5291. tagType,
  5292. props,
  5293. isSelfClosing,
  5294. children: [],
  5295. loc: getSelection(context, start),
  5296. codegenNode: void 0
  5297. };
  5298. }
  5299. function isComponent(tag, props, context) {
  5300. const options = context.options;
  5301. if (options.isCustomElement(tag)) {
  5302. return false;
  5303. }
  5304. if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
  5305. return true;
  5306. }
  5307. for (let i = 0; i < props.length; i++) {
  5308. const p = props[i];
  5309. if (p.type === 6) {
  5310. if (p.name === "is" && p.value) {
  5311. if (p.value.content.startsWith("vue:")) {
  5312. return true;
  5313. } else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT", context, p.loc)) {
  5314. return true;
  5315. }
  5316. }
  5317. } else {
  5318. if (p.name === "is") {
  5319. return true;
  5320. } else if (p.name === "bind" && isStaticArgOf(p.arg, "is") && true && checkCompatEnabled("COMPILER_IS_ON_ELEMENT", context, p.loc)) {
  5321. return true;
  5322. }
  5323. }
  5324. }
  5325. }
  5326. function parseAttributes(context, type) {
  5327. const props = [];
  5328. const attributeNames = /* @__PURE__ */ new Set();
  5329. while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
  5330. if (startsWith(context.source, "/")) {
  5331. emitError(context, 22);
  5332. advanceBy(context, 1);
  5333. advanceSpaces(context);
  5334. continue;
  5335. }
  5336. if (type === 1) {
  5337. emitError(context, 3);
  5338. }
  5339. const attr = parseAttribute(context, attributeNames);
  5340. if (attr.type === 6 && attr.value && attr.name === "class") {
  5341. attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
  5342. }
  5343. if (type === 0) {
  5344. props.push(attr);
  5345. }
  5346. if (/^[^\t\r\n\f />]/.test(context.source)) {
  5347. emitError(context, 15);
  5348. }
  5349. advanceSpaces(context);
  5350. }
  5351. return props;
  5352. }
  5353. function parseAttribute(context, nameSet) {
  5354. const start = getCursor(context);
  5355. const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
  5356. const name = match[0];
  5357. if (nameSet.has(name)) {
  5358. emitError(context, 2);
  5359. }
  5360. nameSet.add(name);
  5361. if (name[0] === "=") {
  5362. emitError(context, 19);
  5363. }
  5364. {
  5365. const pattern = /["'<]/g;
  5366. let m;
  5367. while (m = pattern.exec(name)) {
  5368. emitError(context, 17, m.index);
  5369. }
  5370. }
  5371. advanceBy(context, name.length);
  5372. let value = void 0;
  5373. if (/^[\t\r\n\f ]*=/.test(context.source)) {
  5374. advanceSpaces(context);
  5375. advanceBy(context, 1);
  5376. advanceSpaces(context);
  5377. value = parseAttributeValue(context);
  5378. if (!value) {
  5379. emitError(context, 13);
  5380. }
  5381. }
  5382. const loc = getSelection(context, start);
  5383. if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
  5384. const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
  5385. let isPropShorthand = startsWith(name, ".");
  5386. let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
  5387. let arg;
  5388. if (match2[2]) {
  5389. const isSlot = dirName === "slot";
  5390. const startOffset = name.lastIndexOf(match2[2]);
  5391. const loc2 = getSelection(context, getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset + match2[2].length + (isSlot && match2[3] || "").length));
  5392. let content = match2[2];
  5393. let isStatic = true;
  5394. if (content.startsWith("[")) {
  5395. isStatic = false;
  5396. if (!content.endsWith("]")) {
  5397. emitError(context, 27);
  5398. content = content.slice(1);
  5399. } else {
  5400. content = content.slice(1, content.length - 1);
  5401. }
  5402. } else if (isSlot) {
  5403. content += match2[3] || "";
  5404. }
  5405. arg = {
  5406. type: 4,
  5407. content,
  5408. isStatic,
  5409. constType: isStatic ? 3 : 0,
  5410. loc: loc2
  5411. };
  5412. }
  5413. if (value && value.isQuoted) {
  5414. const valueLoc = value.loc;
  5415. valueLoc.start.offset++;
  5416. valueLoc.start.column++;
  5417. valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
  5418. valueLoc.source = valueLoc.source.slice(1, -1);
  5419. }
  5420. const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
  5421. if (isPropShorthand)
  5422. modifiers.push("prop");
  5423. if (dirName === "bind" && arg) {
  5424. if (modifiers.includes("sync") && checkCompatEnabled("COMPILER_V_BIND_SYNC", context, loc, arg.loc.source)) {
  5425. dirName = "model";
  5426. modifiers.splice(modifiers.indexOf("sync"), 1);
  5427. }
  5428. if (modifiers.includes("prop")) {
  5429. checkCompatEnabled("COMPILER_V_BIND_PROP", context, loc);
  5430. }
  5431. }
  5432. return {
  5433. type: 7,
  5434. name: dirName,
  5435. exp: value && {
  5436. type: 4,
  5437. content: value.content,
  5438. isStatic: false,
  5439. constType: 0,
  5440. loc: value.loc
  5441. },
  5442. arg,
  5443. modifiers,
  5444. loc
  5445. };
  5446. }
  5447. if (!context.inVPre && startsWith(name, "v-")) {
  5448. emitError(context, 26);
  5449. }
  5450. return {
  5451. type: 6,
  5452. name,
  5453. value: value && {
  5454. type: 2,
  5455. content: value.content,
  5456. loc: value.loc
  5457. },
  5458. loc
  5459. };
  5460. }
  5461. function parseAttributeValue(context) {
  5462. const start = getCursor(context);
  5463. let content;
  5464. const quote = context.source[0];
  5465. const isQuoted = quote === `"` || quote === `'`;
  5466. if (isQuoted) {
  5467. advanceBy(context, 1);
  5468. const endIndex = context.source.indexOf(quote);
  5469. if (endIndex === -1) {
  5470. content = parseTextData(context, context.source.length, 4);
  5471. } else {
  5472. content = parseTextData(context, endIndex, 4);
  5473. advanceBy(context, 1);
  5474. }
  5475. } else {
  5476. const match = /^[^\t\r\n\f >]+/.exec(context.source);
  5477. if (!match) {
  5478. return void 0;
  5479. }
  5480. const unexpectedChars = /["'<=`]/g;
  5481. let m;
  5482. while (m = unexpectedChars.exec(match[0])) {
  5483. emitError(context, 18, m.index);
  5484. }
  5485. content = parseTextData(context, match[0].length, 4);
  5486. }
  5487. return { content, isQuoted, loc: getSelection(context, start) };
  5488. }
  5489. function parseInterpolation(context, mode) {
  5490. const [open, close] = context.options.delimiters;
  5491. const closeIndex = context.source.indexOf(close, open.length);
  5492. if (closeIndex === -1) {
  5493. emitError(context, 25);
  5494. return void 0;
  5495. }
  5496. const start = getCursor(context);
  5497. advanceBy(context, open.length);
  5498. const innerStart = getCursor(context);
  5499. const innerEnd = getCursor(context);
  5500. const rawContentLength = closeIndex - open.length;
  5501. const rawContent = context.source.slice(0, rawContentLength);
  5502. const preTrimContent = parseTextData(context, rawContentLength, mode);
  5503. const content = preTrimContent.trim();
  5504. const startOffset = preTrimContent.indexOf(content);
  5505. if (startOffset > 0) {
  5506. advancePositionWithMutation(innerStart, rawContent, startOffset);
  5507. }
  5508. const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
  5509. advancePositionWithMutation(innerEnd, rawContent, endOffset);
  5510. advanceBy(context, close.length);
  5511. return {
  5512. type: 5,
  5513. content: {
  5514. type: 4,
  5515. isStatic: false,
  5516. constType: 0,
  5517. content,
  5518. loc: getSelection(context, innerStart, innerEnd)
  5519. },
  5520. loc: getSelection(context, start)
  5521. };
  5522. }
  5523. function parseText(context, mode) {
  5524. const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
  5525. let endIndex = context.source.length;
  5526. for (let i = 0; i < endTokens.length; i++) {
  5527. const index = context.source.indexOf(endTokens[i], 1);
  5528. if (index !== -1 && endIndex > index) {
  5529. endIndex = index;
  5530. }
  5531. }
  5532. const start = getCursor(context);
  5533. const content = parseTextData(context, endIndex, mode);
  5534. return {
  5535. type: 2,
  5536. content,
  5537. loc: getSelection(context, start)
  5538. };
  5539. }
  5540. function parseTextData(context, length, mode) {
  5541. const rawText = context.source.slice(0, length);
  5542. advanceBy(context, length);
  5543. if (mode === 2 || mode === 3 || !rawText.includes("&")) {
  5544. return rawText;
  5545. } else {
  5546. return context.options.decodeEntities(rawText, mode === 4);
  5547. }
  5548. }
  5549. function getCursor(context) {
  5550. const { column, line, offset } = context;
  5551. return { column, line, offset };
  5552. }
  5553. function getSelection(context, start, end) {
  5554. end = end || getCursor(context);
  5555. return {
  5556. start,
  5557. end,
  5558. source: context.originalSource.slice(start.offset, end.offset)
  5559. };
  5560. }
  5561. function last(xs) {
  5562. return xs[xs.length - 1];
  5563. }
  5564. function startsWith(source, searchString) {
  5565. return source.startsWith(searchString);
  5566. }
  5567. function advanceBy(context, numberOfCharacters) {
  5568. const { source } = context;
  5569. advancePositionWithMutation(context, source, numberOfCharacters);
  5570. context.source = source.slice(numberOfCharacters);
  5571. }
  5572. function advanceSpaces(context) {
  5573. const match = /^[\t\r\n\f ]+/.exec(context.source);
  5574. if (match) {
  5575. advanceBy(context, match[0].length);
  5576. }
  5577. }
  5578. function getNewPosition(context, start, numberOfCharacters) {
  5579. return advancePositionWithClone(start, context.originalSource.slice(start.offset, numberOfCharacters), numberOfCharacters);
  5580. }
  5581. function emitError(context, code, offset, loc = getCursor(context)) {
  5582. if (offset) {
  5583. loc.offset += offset;
  5584. loc.column += offset;
  5585. }
  5586. context.options.onError(createCompilerError(code, {
  5587. start: loc,
  5588. end: loc,
  5589. source: ""
  5590. }));
  5591. }
  5592. function isEnd(context, mode, ancestors) {
  5593. const s = context.source;
  5594. switch (mode) {
  5595. case 0:
  5596. if (startsWith(s, "</")) {
  5597. for (let i = ancestors.length - 1; i >= 0; --i) {
  5598. if (startsWithEndTagOpen(s, ancestors[i].tag)) {
  5599. return true;
  5600. }
  5601. }
  5602. }
  5603. break;
  5604. case 1:
  5605. case 2: {
  5606. const parent = last(ancestors);
  5607. if (parent && startsWithEndTagOpen(s, parent.tag)) {
  5608. return true;
  5609. }
  5610. break;
  5611. }
  5612. case 3:
  5613. if (startsWith(s, "]]>")) {
  5614. return true;
  5615. }
  5616. break;
  5617. }
  5618. return !s;
  5619. }
  5620. function startsWithEndTagOpen(source, tag) {
  5621. return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
  5622. }
  5623. function hoistStatic(root, context) {
  5624. walk(
  5625. root,
  5626. context,
  5627. isSingleElementRoot(root, root.children[0])
  5628. );
  5629. }
  5630. function isSingleElementRoot(root, child) {
  5631. const { children } = root;
  5632. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  5633. }
  5634. function walk(node, context, doNotHoistNode = false) {
  5635. const { children } = node;
  5636. const originalCount = children.length;
  5637. let hoistedCount = 0;
  5638. for (let i = 0; i < children.length; i++) {
  5639. const child = children[i];
  5640. if (child.type === 1 && child.tagType === 0) {
  5641. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  5642. if (constantType > 0) {
  5643. if (constantType >= 2) {
  5644. child.codegenNode.patchFlag = -1 + (true ? ` /* HOISTED */` : ``);
  5645. child.codegenNode = context.hoist(child.codegenNode);
  5646. hoistedCount++;
  5647. continue;
  5648. }
  5649. } else {
  5650. const codegenNode = child.codegenNode;
  5651. if (codegenNode.type === 13) {
  5652. const flag = getPatchFlag(codegenNode);
  5653. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  5654. const props = getNodeProps(child);
  5655. if (props) {
  5656. codegenNode.props = context.hoist(props);
  5657. }
  5658. }
  5659. if (codegenNode.dynamicProps) {
  5660. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  5661. }
  5662. }
  5663. }
  5664. } else if (child.type === 12 && getConstantType(child.content, context) >= 2) {
  5665. child.codegenNode = context.hoist(child.codegenNode);
  5666. hoistedCount++;
  5667. }
  5668. if (child.type === 1) {
  5669. const isComponent2 = child.tagType === 1;
  5670. if (isComponent2) {
  5671. context.scopes.vSlot++;
  5672. }
  5673. walk(child, context);
  5674. if (isComponent2) {
  5675. context.scopes.vSlot--;
  5676. }
  5677. } else if (child.type === 11) {
  5678. walk(child, context, child.children.length === 1);
  5679. } else if (child.type === 9) {
  5680. for (let i2 = 0; i2 < child.branches.length; i2++) {
  5681. walk(child.branches[i2], context, child.branches[i2].children.length === 1);
  5682. }
  5683. }
  5684. }
  5685. if (hoistedCount && context.transformHoist) {
  5686. context.transformHoist(children, context, node);
  5687. }
  5688. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  5689. node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
  5690. }
  5691. }
  5692. function getConstantType(node, context) {
  5693. const { constantCache } = context;
  5694. switch (node.type) {
  5695. case 1:
  5696. if (node.tagType !== 0) {
  5697. return 0;
  5698. }
  5699. const cached = constantCache.get(node);
  5700. if (cached !== void 0) {
  5701. return cached;
  5702. }
  5703. const codegenNode = node.codegenNode;
  5704. if (codegenNode.type !== 13) {
  5705. return 0;
  5706. }
  5707. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  5708. return 0;
  5709. }
  5710. const flag = getPatchFlag(codegenNode);
  5711. if (!flag) {
  5712. let returnType2 = 3;
  5713. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  5714. if (generatedPropsType === 0) {
  5715. constantCache.set(node, 0);
  5716. return 0;
  5717. }
  5718. if (generatedPropsType < returnType2) {
  5719. returnType2 = generatedPropsType;
  5720. }
  5721. for (let i = 0; i < node.children.length; i++) {
  5722. const childType = getConstantType(node.children[i], context);
  5723. if (childType === 0) {
  5724. constantCache.set(node, 0);
  5725. return 0;
  5726. }
  5727. if (childType < returnType2) {
  5728. returnType2 = childType;
  5729. }
  5730. }
  5731. if (returnType2 > 1) {
  5732. for (let i = 0; i < node.props.length; i++) {
  5733. const p = node.props[i];
  5734. if (p.type === 7 && p.name === "bind" && p.exp) {
  5735. const expType = getConstantType(p.exp, context);
  5736. if (expType === 0) {
  5737. constantCache.set(node, 0);
  5738. return 0;
  5739. }
  5740. if (expType < returnType2) {
  5741. returnType2 = expType;
  5742. }
  5743. }
  5744. }
  5745. }
  5746. if (codegenNode.isBlock) {
  5747. for (let i = 0; i < node.props.length; i++) {
  5748. const p = node.props[i];
  5749. if (p.type === 7) {
  5750. constantCache.set(node, 0);
  5751. return 0;
  5752. }
  5753. }
  5754. context.removeHelper(OPEN_BLOCK);
  5755. context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
  5756. codegenNode.isBlock = false;
  5757. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  5758. }
  5759. constantCache.set(node, returnType2);
  5760. return returnType2;
  5761. } else {
  5762. constantCache.set(node, 0);
  5763. return 0;
  5764. }
  5765. case 2:
  5766. case 3:
  5767. return 3;
  5768. case 9:
  5769. case 11:
  5770. case 10:
  5771. return 0;
  5772. case 5:
  5773. case 12:
  5774. return getConstantType(node.content, context);
  5775. case 4:
  5776. return node.constType;
  5777. case 8:
  5778. let returnType = 3;
  5779. for (let i = 0; i < node.children.length; i++) {
  5780. const child = node.children[i];
  5781. if (isString(child) || isSymbol(child)) {
  5782. continue;
  5783. }
  5784. const childType = getConstantType(child, context);
  5785. if (childType === 0) {
  5786. return 0;
  5787. } else if (childType < returnType) {
  5788. returnType = childType;
  5789. }
  5790. }
  5791. return returnType;
  5792. default:
  5793. if (true)
  5794. ;
  5795. return 0;
  5796. }
  5797. }
  5798. function getConstantTypeOfHelperCall(value, context) {
  5799. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  5800. const arg = value.arguments[0];
  5801. if (arg.type === 4) {
  5802. return getConstantType(arg, context);
  5803. } else if (arg.type === 14) {
  5804. return getConstantTypeOfHelperCall(arg, context);
  5805. }
  5806. }
  5807. return 0;
  5808. }
  5809. function getGeneratedPropsConstantType(node, context) {
  5810. let returnType = 3;
  5811. const props = getNodeProps(node);
  5812. if (props && props.type === 15) {
  5813. const { properties } = props;
  5814. for (let i = 0; i < properties.length; i++) {
  5815. const { key, value } = properties[i];
  5816. const keyType = getConstantType(key, context);
  5817. if (keyType === 0) {
  5818. return keyType;
  5819. }
  5820. if (keyType < returnType) {
  5821. returnType = keyType;
  5822. }
  5823. let valueType;
  5824. if (value.type === 4) {
  5825. valueType = getConstantType(value, context);
  5826. } else if (value.type === 14) {
  5827. valueType = getConstantTypeOfHelperCall(value, context);
  5828. } else {
  5829. valueType = 0;
  5830. }
  5831. if (valueType === 0) {
  5832. return valueType;
  5833. }
  5834. if (valueType < returnType) {
  5835. returnType = valueType;
  5836. }
  5837. }
  5838. }
  5839. return returnType;
  5840. }
  5841. function getNodeProps(node) {
  5842. const codegenNode = node.codegenNode;
  5843. if (codegenNode.type === 13) {
  5844. return codegenNode.props;
  5845. }
  5846. }
  5847. function getPatchFlag(node) {
  5848. const flag = node.patchFlag;
  5849. return flag ? parseInt(flag, 10) : void 0;
  5850. }
  5851. function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic: hoistStatic2 = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
  5852. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  5853. const context = {
  5854. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  5855. prefixIdentifiers,
  5856. hoistStatic: hoistStatic2,
  5857. cacheHandlers,
  5858. nodeTransforms,
  5859. directiveTransforms,
  5860. transformHoist,
  5861. isBuiltInComponent,
  5862. isCustomElement,
  5863. expressionPlugins,
  5864. scopeId,
  5865. slotted,
  5866. ssr,
  5867. inSSR,
  5868. ssrCssVars,
  5869. bindingMetadata,
  5870. inline,
  5871. isTS,
  5872. onError,
  5873. onWarn,
  5874. compatConfig,
  5875. root,
  5876. helpers: /* @__PURE__ */ new Map(),
  5877. components: /* @__PURE__ */ new Set(),
  5878. directives: /* @__PURE__ */ new Set(),
  5879. hoists: [],
  5880. imports: [],
  5881. constantCache: /* @__PURE__ */ new Map(),
  5882. temps: 0,
  5883. cached: 0,
  5884. identifiers: /* @__PURE__ */ Object.create(null),
  5885. scopes: {
  5886. vFor: 0,
  5887. vSlot: 0,
  5888. vPre: 0,
  5889. vOnce: 0
  5890. },
  5891. parent: null,
  5892. currentNode: root,
  5893. childIndex: 0,
  5894. inVOnce: false,
  5895. helper(name) {
  5896. const count = context.helpers.get(name) || 0;
  5897. context.helpers.set(name, count + 1);
  5898. return name;
  5899. },
  5900. removeHelper(name) {
  5901. const count = context.helpers.get(name);
  5902. if (count) {
  5903. const currentCount = count - 1;
  5904. if (!currentCount) {
  5905. context.helpers.delete(name);
  5906. } else {
  5907. context.helpers.set(name, currentCount);
  5908. }
  5909. }
  5910. },
  5911. helperString(name) {
  5912. return `_${helperNameMap[context.helper(name)]}`;
  5913. },
  5914. replaceNode(node) {
  5915. if (true) {
  5916. if (!context.currentNode) {
  5917. throw new Error(`Node being replaced is already removed.`);
  5918. }
  5919. if (!context.parent) {
  5920. throw new Error(`Cannot replace root node.`);
  5921. }
  5922. }
  5923. context.parent.children[context.childIndex] = context.currentNode = node;
  5924. },
  5925. removeNode(node) {
  5926. if (!context.parent) {
  5927. throw new Error(`Cannot remove root node.`);
  5928. }
  5929. const list = context.parent.children;
  5930. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  5931. if (removalIndex < 0) {
  5932. throw new Error(`node being removed is not a child of current parent`);
  5933. }
  5934. if (!node || node === context.currentNode) {
  5935. context.currentNode = null;
  5936. context.onNodeRemoved();
  5937. } else {
  5938. if (context.childIndex > removalIndex) {
  5939. context.childIndex--;
  5940. context.onNodeRemoved();
  5941. }
  5942. }
  5943. context.parent.children.splice(removalIndex, 1);
  5944. },
  5945. onNodeRemoved: () => {
  5946. },
  5947. addIdentifiers(exp) {
  5948. },
  5949. removeIdentifiers(exp) {
  5950. },
  5951. hoist(exp) {
  5952. if (isString(exp))
  5953. exp = createSimpleExpression(exp);
  5954. context.hoists.push(exp);
  5955. const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2);
  5956. identifier.hoisted = exp;
  5957. return identifier;
  5958. },
  5959. cache(exp, isVNode = false) {
  5960. return createCacheExpression(context.cached++, exp, isVNode);
  5961. }
  5962. };
  5963. {
  5964. context.filters = /* @__PURE__ */ new Set();
  5965. }
  5966. return context;
  5967. }
  5968. function transform(root, options) {
  5969. const context = createTransformContext(root, options);
  5970. traverseNode(root, context);
  5971. if (options.hoistStatic) {
  5972. hoistStatic(root, context);
  5973. }
  5974. if (!options.ssr) {
  5975. createRootCodegen(root, context);
  5976. }
  5977. root.helpers = [...context.helpers.keys()];
  5978. root.components = [...context.components];
  5979. root.directives = [...context.directives];
  5980. root.imports = context.imports;
  5981. root.hoists = context.hoists;
  5982. root.temps = context.temps;
  5983. root.cached = context.cached;
  5984. {
  5985. root.filters = [...context.filters];
  5986. }
  5987. }
  5988. function createRootCodegen(root, context) {
  5989. const { helper } = context;
  5990. const { children } = root;
  5991. if (children.length === 1) {
  5992. const child = children[0];
  5993. if (isSingleElementRoot(root, child) && child.codegenNode) {
  5994. const codegenNode = child.codegenNode;
  5995. if (codegenNode.type === 13) {
  5996. makeBlock(codegenNode, context);
  5997. }
  5998. root.codegenNode = codegenNode;
  5999. } else {
  6000. root.codegenNode = child;
  6001. }
  6002. } else if (children.length > 1) {
  6003. let patchFlag = 64;
  6004. let patchFlagText = PatchFlagNames[64];
  6005. if (children.filter((c) => c.type !== 3).length === 1) {
  6006. patchFlag |= 2048;
  6007. patchFlagText += `, ${PatchFlagNames[2048]}`;
  6008. }
  6009. root.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, root.children, patchFlag + (true ? ` /* ${patchFlagText} */` : ``), void 0, void 0, true, void 0, false);
  6010. } else
  6011. ;
  6012. }
  6013. function traverseChildren(parent, context) {
  6014. let i = 0;
  6015. const nodeRemoved = () => {
  6016. i--;
  6017. };
  6018. for (; i < parent.children.length; i++) {
  6019. const child = parent.children[i];
  6020. if (isString(child))
  6021. continue;
  6022. context.parent = parent;
  6023. context.childIndex = i;
  6024. context.onNodeRemoved = nodeRemoved;
  6025. traverseNode(child, context);
  6026. }
  6027. }
  6028. function traverseNode(node, context) {
  6029. context.currentNode = node;
  6030. const { nodeTransforms } = context;
  6031. const exitFns = [];
  6032. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  6033. const onExit = nodeTransforms[i2](node, context);
  6034. if (onExit) {
  6035. if (isArray(onExit)) {
  6036. exitFns.push(...onExit);
  6037. } else {
  6038. exitFns.push(onExit);
  6039. }
  6040. }
  6041. if (!context.currentNode) {
  6042. return;
  6043. } else {
  6044. node = context.currentNode;
  6045. }
  6046. }
  6047. switch (node.type) {
  6048. case 3:
  6049. if (!context.ssr) {
  6050. context.helper(CREATE_COMMENT);
  6051. }
  6052. break;
  6053. case 5:
  6054. if (!context.ssr) {
  6055. context.helper(TO_DISPLAY_STRING);
  6056. }
  6057. break;
  6058. case 9:
  6059. for (let i2 = 0; i2 < node.branches.length; i2++) {
  6060. traverseNode(node.branches[i2], context);
  6061. }
  6062. break;
  6063. case 10:
  6064. case 11:
  6065. case 1:
  6066. case 0:
  6067. traverseChildren(node, context);
  6068. break;
  6069. }
  6070. context.currentNode = node;
  6071. let i = exitFns.length;
  6072. while (i--) {
  6073. exitFns[i]();
  6074. }
  6075. }
  6076. function createStructuralDirectiveTransform(name, fn) {
  6077. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  6078. return (node, context) => {
  6079. if (node.type === 1) {
  6080. const { props } = node;
  6081. if (node.tagType === 3 && props.some(isVSlot)) {
  6082. return;
  6083. }
  6084. const exitFns = [];
  6085. for (let i = 0; i < props.length; i++) {
  6086. const prop = props[i];
  6087. if (prop.type === 7 && matches(prop.name)) {
  6088. props.splice(i, 1);
  6089. i--;
  6090. const onExit = fn(node, prop, context);
  6091. if (onExit)
  6092. exitFns.push(onExit);
  6093. }
  6094. }
  6095. return exitFns;
  6096. }
  6097. };
  6098. }
  6099. function createCodegenContext(ast, { mode = "function", prefixIdentifiers = mode === "module", sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = "vue/server-renderer", ssr = false, isTS = false, inSSR = false }) {
  6100. const context = {
  6101. mode,
  6102. prefixIdentifiers,
  6103. sourceMap,
  6104. filename,
  6105. scopeId,
  6106. optimizeImports,
  6107. runtimeGlobalName,
  6108. runtimeModuleName,
  6109. ssrRuntimeModuleName,
  6110. ssr,
  6111. isTS,
  6112. inSSR,
  6113. source: ast.loc.source,
  6114. code: ``,
  6115. column: 1,
  6116. line: 1,
  6117. offset: 0,
  6118. indentLevel: 0,
  6119. pure: false,
  6120. map: void 0,
  6121. helper(key) {
  6122. return `_${helperNameMap[key]}`;
  6123. },
  6124. push(code, node) {
  6125. context.code += code;
  6126. },
  6127. indent() {
  6128. newline(++context.indentLevel);
  6129. },
  6130. deindent(withoutNewLine = false) {
  6131. if (withoutNewLine) {
  6132. --context.indentLevel;
  6133. } else {
  6134. newline(--context.indentLevel);
  6135. }
  6136. },
  6137. newline() {
  6138. newline(context.indentLevel);
  6139. }
  6140. };
  6141. function newline(n) {
  6142. context.push("\n" + ` `.repeat(n));
  6143. }
  6144. return context;
  6145. }
  6146. function generate(ast, options = {}) {
  6147. const context = createCodegenContext(ast, options);
  6148. if (options.onContextCreated)
  6149. options.onContextCreated(context);
  6150. const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
  6151. const hasHelpers = ast.helpers.length > 0;
  6152. const useWithBlock = !prefixIdentifiers && mode !== "module";
  6153. const preambleContext = context;
  6154. {
  6155. genFunctionPreamble(ast, preambleContext);
  6156. }
  6157. const functionName = ssr ? `ssrRender` : `render`;
  6158. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  6159. const signature = args.join(", ");
  6160. {
  6161. push(`function ${functionName}(${signature}) {`);
  6162. }
  6163. indent();
  6164. if (useWithBlock) {
  6165. push(`with (_ctx) {`);
  6166. indent();
  6167. if (hasHelpers) {
  6168. push(`const { ${ast.helpers.map(aliasHelper).join(", ")} } = _Vue`);
  6169. push(`
  6170. `);
  6171. newline();
  6172. }
  6173. }
  6174. if (ast.components.length) {
  6175. genAssets(ast.components, "component", context);
  6176. if (ast.directives.length || ast.temps > 0) {
  6177. newline();
  6178. }
  6179. }
  6180. if (ast.directives.length) {
  6181. genAssets(ast.directives, "directive", context);
  6182. if (ast.temps > 0) {
  6183. newline();
  6184. }
  6185. }
  6186. if (ast.filters && ast.filters.length) {
  6187. newline();
  6188. genAssets(ast.filters, "filter", context);
  6189. newline();
  6190. }
  6191. if (ast.temps > 0) {
  6192. push(`let `);
  6193. for (let i = 0; i < ast.temps; i++) {
  6194. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  6195. }
  6196. }
  6197. if (ast.components.length || ast.directives.length || ast.temps) {
  6198. push(`
  6199. `);
  6200. newline();
  6201. }
  6202. if (!ssr) {
  6203. push(`return `);
  6204. }
  6205. if (ast.codegenNode) {
  6206. genNode(ast.codegenNode, context);
  6207. } else {
  6208. push(`null`);
  6209. }
  6210. if (useWithBlock) {
  6211. deindent();
  6212. push(`}`);
  6213. }
  6214. deindent();
  6215. push(`}`);
  6216. return {
  6217. ast,
  6218. code: context.code,
  6219. preamble: ``,
  6220. map: context.map ? context.map.toJSON() : void 0
  6221. };
  6222. }
  6223. function genFunctionPreamble(ast, context) {
  6224. const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
  6225. const VueBinding = runtimeGlobalName;
  6226. if (ast.helpers.length > 0) {
  6227. {
  6228. push(`const _Vue = ${VueBinding}
  6229. `);
  6230. if (ast.hoists.length) {
  6231. const staticHelpers = [
  6232. CREATE_VNODE,
  6233. CREATE_ELEMENT_VNODE,
  6234. CREATE_COMMENT,
  6235. CREATE_TEXT,
  6236. CREATE_STATIC
  6237. ].filter((helper) => ast.helpers.includes(helper)).map(aliasHelper).join(", ");
  6238. push(`const { ${staticHelpers} } = _Vue
  6239. `);
  6240. }
  6241. }
  6242. }
  6243. genHoists(ast.hoists, context);
  6244. newline();
  6245. push(`return `);
  6246. }
  6247. function genAssets(assets, type, { helper, push, newline, isTS }) {
  6248. const resolver = helper(type === "filter" ? RESOLVE_FILTER : type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE);
  6249. for (let i = 0; i < assets.length; i++) {
  6250. let id = assets[i];
  6251. const maybeSelfReference = id.endsWith("__self");
  6252. if (maybeSelfReference) {
  6253. id = id.slice(0, -6);
  6254. }
  6255. push(`const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`);
  6256. if (i < assets.length - 1) {
  6257. newline();
  6258. }
  6259. }
  6260. }
  6261. function genHoists(hoists, context) {
  6262. if (!hoists.length) {
  6263. return;
  6264. }
  6265. context.pure = true;
  6266. const { push, newline, helper, scopeId, mode } = context;
  6267. newline();
  6268. for (let i = 0; i < hoists.length; i++) {
  6269. const exp = hoists[i];
  6270. if (exp) {
  6271. push(`const _hoisted_${i + 1} = ${``}`);
  6272. genNode(exp, context);
  6273. newline();
  6274. }
  6275. }
  6276. context.pure = false;
  6277. }
  6278. function isText$1(n) {
  6279. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  6280. }
  6281. function genNodeListAsArray(nodes, context) {
  6282. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText$1(n));
  6283. context.push(`[`);
  6284. multilines && context.indent();
  6285. genNodeList(nodes, context, multilines);
  6286. multilines && context.deindent();
  6287. context.push(`]`);
  6288. }
  6289. function genNodeList(nodes, context, multilines = false, comma = true) {
  6290. const { push, newline } = context;
  6291. for (let i = 0; i < nodes.length; i++) {
  6292. const node = nodes[i];
  6293. if (isString(node)) {
  6294. push(node);
  6295. } else if (isArray(node)) {
  6296. genNodeListAsArray(node, context);
  6297. } else {
  6298. genNode(node, context);
  6299. }
  6300. if (i < nodes.length - 1) {
  6301. if (multilines) {
  6302. comma && push(",");
  6303. newline();
  6304. } else {
  6305. comma && push(", ");
  6306. }
  6307. }
  6308. }
  6309. }
  6310. function genNode(node, context) {
  6311. if (isString(node)) {
  6312. context.push(node);
  6313. return;
  6314. }
  6315. if (isSymbol(node)) {
  6316. context.push(context.helper(node));
  6317. return;
  6318. }
  6319. switch (node.type) {
  6320. case 1:
  6321. case 9:
  6322. case 11:
  6323. assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`);
  6324. genNode(node.codegenNode, context);
  6325. break;
  6326. case 2:
  6327. genText(node, context);
  6328. break;
  6329. case 4:
  6330. genExpression(node, context);
  6331. break;
  6332. case 5:
  6333. genInterpolation(node, context);
  6334. break;
  6335. case 12:
  6336. genNode(node.codegenNode, context);
  6337. break;
  6338. case 8:
  6339. genCompoundExpression(node, context);
  6340. break;
  6341. case 3:
  6342. genComment(node, context);
  6343. break;
  6344. case 13:
  6345. genVNodeCall(node, context);
  6346. break;
  6347. case 14:
  6348. genCallExpression(node, context);
  6349. break;
  6350. case 15:
  6351. genObjectExpression(node, context);
  6352. break;
  6353. case 17:
  6354. genArrayExpression(node, context);
  6355. break;
  6356. case 18:
  6357. genFunctionExpression(node, context);
  6358. break;
  6359. case 19:
  6360. genConditionalExpression(node, context);
  6361. break;
  6362. case 20:
  6363. genCacheExpression(node, context);
  6364. break;
  6365. case 21:
  6366. genNodeList(node.body, context, true, false);
  6367. break;
  6368. case 22:
  6369. break;
  6370. case 23:
  6371. break;
  6372. case 24:
  6373. break;
  6374. case 25:
  6375. break;
  6376. case 26:
  6377. break;
  6378. case 10:
  6379. break;
  6380. default:
  6381. if (true) {
  6382. assert(false, `unhandled codegen node type: ${node.type}`);
  6383. const exhaustiveCheck = node;
  6384. return exhaustiveCheck;
  6385. }
  6386. }
  6387. }
  6388. function genText(node, context) {
  6389. context.push(JSON.stringify(node.content), node);
  6390. }
  6391. function genExpression(node, context) {
  6392. const { content, isStatic } = node;
  6393. context.push(isStatic ? JSON.stringify(content) : content, node);
  6394. }
  6395. function genInterpolation(node, context) {
  6396. const { push, helper, pure } = context;
  6397. if (pure)
  6398. push(PURE_ANNOTATION);
  6399. push(`${helper(TO_DISPLAY_STRING)}(`);
  6400. genNode(node.content, context);
  6401. push(`)`);
  6402. }
  6403. function genCompoundExpression(node, context) {
  6404. for (let i = 0; i < node.children.length; i++) {
  6405. const child = node.children[i];
  6406. if (isString(child)) {
  6407. context.push(child);
  6408. } else {
  6409. genNode(child, context);
  6410. }
  6411. }
  6412. }
  6413. function genExpressionAsPropertyKey(node, context) {
  6414. const { push } = context;
  6415. if (node.type === 8) {
  6416. push(`[`);
  6417. genCompoundExpression(node, context);
  6418. push(`]`);
  6419. } else if (node.isStatic) {
  6420. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  6421. push(text, node);
  6422. } else {
  6423. push(`[${node.content}]`, node);
  6424. }
  6425. }
  6426. function genComment(node, context) {
  6427. const { push, helper, pure } = context;
  6428. if (pure) {
  6429. push(PURE_ANNOTATION);
  6430. }
  6431. push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
  6432. }
  6433. function genVNodeCall(node, context) {
  6434. const { push, helper, pure } = context;
  6435. const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent: isComponent2 } = node;
  6436. if (directives) {
  6437. push(helper(WITH_DIRECTIVES) + `(`);
  6438. }
  6439. if (isBlock) {
  6440. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  6441. }
  6442. if (pure) {
  6443. push(PURE_ANNOTATION);
  6444. }
  6445. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
  6446. push(helper(callHelper) + `(`, node);
  6447. genNodeList(genNullableArgs([tag, props, children, patchFlag, dynamicProps]), context);
  6448. push(`)`);
  6449. if (isBlock) {
  6450. push(`)`);
  6451. }
  6452. if (directives) {
  6453. push(`, `);
  6454. genNode(directives, context);
  6455. push(`)`);
  6456. }
  6457. }
  6458. function genNullableArgs(args) {
  6459. let i = args.length;
  6460. while (i--) {
  6461. if (args[i] != null)
  6462. break;
  6463. }
  6464. return args.slice(0, i + 1).map((arg) => arg || `null`);
  6465. }
  6466. function genCallExpression(node, context) {
  6467. const { push, helper, pure } = context;
  6468. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  6469. if (pure) {
  6470. push(PURE_ANNOTATION);
  6471. }
  6472. push(callee + `(`, node);
  6473. genNodeList(node.arguments, context);
  6474. push(`)`);
  6475. }
  6476. function genObjectExpression(node, context) {
  6477. const { push, indent, deindent, newline } = context;
  6478. const { properties } = node;
  6479. if (!properties.length) {
  6480. push(`{}`, node);
  6481. return;
  6482. }
  6483. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  6484. push(multilines ? `{` : `{ `);
  6485. multilines && indent();
  6486. for (let i = 0; i < properties.length; i++) {
  6487. const { key, value } = properties[i];
  6488. genExpressionAsPropertyKey(key, context);
  6489. push(`: `);
  6490. genNode(value, context);
  6491. if (i < properties.length - 1) {
  6492. push(`,`);
  6493. newline();
  6494. }
  6495. }
  6496. multilines && deindent();
  6497. push(multilines ? `}` : ` }`);
  6498. }
  6499. function genArrayExpression(node, context) {
  6500. genNodeListAsArray(node.elements, context);
  6501. }
  6502. function genFunctionExpression(node, context) {
  6503. const { push, indent, deindent } = context;
  6504. const { params, returns, body, newline, isSlot } = node;
  6505. if (isSlot) {
  6506. push(`_${helperNameMap[WITH_CTX]}(`);
  6507. }
  6508. push(`(`, node);
  6509. if (isArray(params)) {
  6510. genNodeList(params, context);
  6511. } else if (params) {
  6512. genNode(params, context);
  6513. }
  6514. push(`) => `);
  6515. if (newline || body) {
  6516. push(`{`);
  6517. indent();
  6518. }
  6519. if (returns) {
  6520. if (newline) {
  6521. push(`return `);
  6522. }
  6523. if (isArray(returns)) {
  6524. genNodeListAsArray(returns, context);
  6525. } else {
  6526. genNode(returns, context);
  6527. }
  6528. } else if (body) {
  6529. genNode(body, context);
  6530. }
  6531. if (newline || body) {
  6532. deindent();
  6533. push(`}`);
  6534. }
  6535. if (isSlot) {
  6536. if (node.isNonScopedSlot) {
  6537. push(`, undefined, true`);
  6538. }
  6539. push(`)`);
  6540. }
  6541. }
  6542. function genConditionalExpression(node, context) {
  6543. const { test, consequent, alternate, newline: needNewline } = node;
  6544. const { push, indent, deindent, newline } = context;
  6545. if (test.type === 4) {
  6546. const needsParens = !isSimpleIdentifier(test.content);
  6547. needsParens && push(`(`);
  6548. genExpression(test, context);
  6549. needsParens && push(`)`);
  6550. } else {
  6551. push(`(`);
  6552. genNode(test, context);
  6553. push(`)`);
  6554. }
  6555. needNewline && indent();
  6556. context.indentLevel++;
  6557. needNewline || push(` `);
  6558. push(`? `);
  6559. genNode(consequent, context);
  6560. context.indentLevel--;
  6561. needNewline && newline();
  6562. needNewline || push(` `);
  6563. push(`: `);
  6564. const isNested = alternate.type === 19;
  6565. if (!isNested) {
  6566. context.indentLevel++;
  6567. }
  6568. genNode(alternate, context);
  6569. if (!isNested) {
  6570. context.indentLevel--;
  6571. }
  6572. needNewline && deindent(true);
  6573. }
  6574. function genCacheExpression(node, context) {
  6575. const { push, helper, indent, deindent, newline } = context;
  6576. push(`_cache[${node.index}] || (`);
  6577. if (node.isVNode) {
  6578. indent();
  6579. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  6580. newline();
  6581. }
  6582. push(`_cache[${node.index}] = `);
  6583. genNode(node.value, context);
  6584. if (node.isVNode) {
  6585. push(`,`);
  6586. newline();
  6587. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  6588. newline();
  6589. push(`_cache[${node.index}]`);
  6590. deindent();
  6591. }
  6592. push(`)`);
  6593. }
  6594. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  6595. {
  6596. return;
  6597. }
  6598. }
  6599. function isReferencedIdentifier(id, parent, parentStack) {
  6600. {
  6601. return false;
  6602. }
  6603. }
  6604. function isInDestructureAssignment(parent, parentStack) {
  6605. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  6606. let i = parentStack.length;
  6607. while (i--) {
  6608. const p = parentStack[i];
  6609. if (p.type === "AssignmentExpression") {
  6610. return true;
  6611. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  6612. break;
  6613. }
  6614. }
  6615. }
  6616. return false;
  6617. }
  6618. function walkFunctionParams(node, onIdent) {
  6619. for (const p of node.params) {
  6620. for (const id of extractIdentifiers(p)) {
  6621. onIdent(id);
  6622. }
  6623. }
  6624. }
  6625. function walkBlockDeclarations(block, onIdent) {
  6626. for (const stmt of block.body) {
  6627. if (stmt.type === "VariableDeclaration") {
  6628. if (stmt.declare)
  6629. continue;
  6630. for (const decl of stmt.declarations) {
  6631. for (const id of extractIdentifiers(decl.id)) {
  6632. onIdent(id);
  6633. }
  6634. }
  6635. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  6636. if (stmt.declare || !stmt.id)
  6637. continue;
  6638. onIdent(stmt.id);
  6639. }
  6640. }
  6641. }
  6642. function extractIdentifiers(param, nodes = []) {
  6643. switch (param.type) {
  6644. case "Identifier":
  6645. nodes.push(param);
  6646. break;
  6647. case "MemberExpression":
  6648. let object = param;
  6649. while (object.type === "MemberExpression") {
  6650. object = object.object;
  6651. }
  6652. nodes.push(object);
  6653. break;
  6654. case "ObjectPattern":
  6655. for (const prop of param.properties) {
  6656. if (prop.type === "RestElement") {
  6657. extractIdentifiers(prop.argument, nodes);
  6658. } else {
  6659. extractIdentifiers(prop.value, nodes);
  6660. }
  6661. }
  6662. break;
  6663. case "ArrayPattern":
  6664. param.elements.forEach((element) => {
  6665. if (element)
  6666. extractIdentifiers(element, nodes);
  6667. });
  6668. break;
  6669. case "RestElement":
  6670. extractIdentifiers(param.argument, nodes);
  6671. break;
  6672. case "AssignmentPattern":
  6673. extractIdentifiers(param.left, nodes);
  6674. break;
  6675. }
  6676. return nodes;
  6677. }
  6678. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  6679. const exp = node.content;
  6680. if (!exp.trim()) {
  6681. return;
  6682. }
  6683. try {
  6684. new Function(asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`);
  6685. } catch (e) {
  6686. let message = e.message;
  6687. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  6688. if (keywordMatch) {
  6689. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  6690. }
  6691. context.onError(createCompilerError(44, node.loc, void 0, message));
  6692. }
  6693. }
  6694. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  6695. {
  6696. if (true) {
  6697. validateBrowserExpression(node, context, asParams, asRawStatements);
  6698. }
  6699. return node;
  6700. }
  6701. }
  6702. function processIf(node, dir, context, processCodegen) {
  6703. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  6704. const loc = dir.exp ? dir.exp.loc : node.loc;
  6705. context.onError(createCompilerError(28, dir.loc));
  6706. dir.exp = createSimpleExpression(`true`, false, loc);
  6707. }
  6708. if (dir.exp) {
  6709. validateBrowserExpression(dir.exp, context);
  6710. }
  6711. if (dir.name === "if") {
  6712. const branch = createIfBranch(node, dir);
  6713. const ifNode = {
  6714. type: 9,
  6715. loc: node.loc,
  6716. branches: [branch]
  6717. };
  6718. context.replaceNode(ifNode);
  6719. if (processCodegen) {
  6720. return processCodegen(ifNode, branch, true);
  6721. }
  6722. } else {
  6723. const siblings = context.parent.children;
  6724. const comments = [];
  6725. let i = siblings.indexOf(node);
  6726. while (i-- >= -1) {
  6727. const sibling = siblings[i];
  6728. if (sibling && sibling.type === 3) {
  6729. context.removeNode(sibling);
  6730. comments.unshift(sibling);
  6731. continue;
  6732. }
  6733. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  6734. context.removeNode(sibling);
  6735. continue;
  6736. }
  6737. if (sibling && sibling.type === 9) {
  6738. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  6739. context.onError(createCompilerError(30, node.loc));
  6740. }
  6741. context.removeNode();
  6742. const branch = createIfBranch(node, dir);
  6743. if (comments.length && !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
  6744. branch.children = [...comments, ...branch.children];
  6745. }
  6746. if (true) {
  6747. const key = branch.userKey;
  6748. if (key) {
  6749. sibling.branches.forEach(({ userKey }) => {
  6750. if (isSameKey(userKey, key)) {
  6751. context.onError(createCompilerError(29, branch.userKey.loc));
  6752. }
  6753. });
  6754. }
  6755. }
  6756. sibling.branches.push(branch);
  6757. const onExit = processCodegen && processCodegen(sibling, branch, false);
  6758. traverseNode(branch, context);
  6759. if (onExit)
  6760. onExit();
  6761. context.currentNode = null;
  6762. } else {
  6763. context.onError(createCompilerError(30, node.loc));
  6764. }
  6765. break;
  6766. }
  6767. }
  6768. }
  6769. function createIfBranch(node, dir) {
  6770. const isTemplateIf = node.tagType === 3;
  6771. return {
  6772. type: 10,
  6773. loc: node.loc,
  6774. condition: dir.name === "else" ? void 0 : dir.exp,
  6775. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  6776. userKey: findProp(node, `key`),
  6777. isTemplateIf
  6778. };
  6779. }
  6780. function createCodegenNodeForBranch(branch, keyIndex, context) {
  6781. if (branch.condition) {
  6782. return createConditionalExpression(
  6783. branch.condition,
  6784. createChildrenCodegenNode(branch, keyIndex, context),
  6785. createCallExpression(context.helper(CREATE_COMMENT), [
  6786. true ? '"v-if"' : '""',
  6787. "true"
  6788. ])
  6789. );
  6790. } else {
  6791. return createChildrenCodegenNode(branch, keyIndex, context);
  6792. }
  6793. }
  6794. function createChildrenCodegenNode(branch, keyIndex, context) {
  6795. const { helper } = context;
  6796. const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2));
  6797. const { children } = branch;
  6798. const firstChild = children[0];
  6799. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  6800. if (needFragmentWrapper) {
  6801. if (children.length === 1 && firstChild.type === 11) {
  6802. const vnodeCall = firstChild.codegenNode;
  6803. injectProp(vnodeCall, keyProperty, context);
  6804. return vnodeCall;
  6805. } else {
  6806. let patchFlag = 64;
  6807. let patchFlagText = PatchFlagNames[64];
  6808. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  6809. patchFlag |= 2048;
  6810. patchFlagText += `, ${PatchFlagNames[2048]}`;
  6811. }
  6812. return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (true ? ` /* ${patchFlagText} */` : ``), void 0, void 0, true, false, false, branch.loc);
  6813. }
  6814. } else {
  6815. const ret = firstChild.codegenNode;
  6816. const vnodeCall = getMemoedVNodeCall(ret);
  6817. if (vnodeCall.type === 13) {
  6818. makeBlock(vnodeCall, context);
  6819. }
  6820. injectProp(vnodeCall, keyProperty, context);
  6821. return ret;
  6822. }
  6823. }
  6824. function isSameKey(a, b) {
  6825. if (!a || a.type !== b.type) {
  6826. return false;
  6827. }
  6828. if (a.type === 6) {
  6829. if (a.value.content !== b.value.content) {
  6830. return false;
  6831. }
  6832. } else {
  6833. const exp = a.exp;
  6834. const branchExp = b.exp;
  6835. if (exp.type !== branchExp.type) {
  6836. return false;
  6837. }
  6838. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  6839. return false;
  6840. }
  6841. }
  6842. return true;
  6843. }
  6844. function getParentCondition(node) {
  6845. while (true) {
  6846. if (node.type === 19) {
  6847. if (node.alternate.type === 19) {
  6848. node = node.alternate;
  6849. } else {
  6850. return node;
  6851. }
  6852. } else if (node.type === 20) {
  6853. node = node.value;
  6854. }
  6855. }
  6856. }
  6857. function processFor(node, dir, context, processCodegen) {
  6858. if (!dir.exp) {
  6859. context.onError(createCompilerError(31, dir.loc));
  6860. return;
  6861. }
  6862. const parseResult = parseForExpression(
  6863. dir.exp,
  6864. context
  6865. );
  6866. if (!parseResult) {
  6867. context.onError(createCompilerError(32, dir.loc));
  6868. return;
  6869. }
  6870. const { addIdentifiers, removeIdentifiers, scopes } = context;
  6871. const { source, value, key, index } = parseResult;
  6872. const forNode = {
  6873. type: 11,
  6874. loc: dir.loc,
  6875. source,
  6876. valueAlias: value,
  6877. keyAlias: key,
  6878. objectIndexAlias: index,
  6879. parseResult,
  6880. children: isTemplateNode(node) ? node.children : [node]
  6881. };
  6882. context.replaceNode(forNode);
  6883. scopes.vFor++;
  6884. const onExit = processCodegen && processCodegen(forNode);
  6885. return () => {
  6886. scopes.vFor--;
  6887. if (onExit)
  6888. onExit();
  6889. };
  6890. }
  6891. function parseForExpression(input, context) {
  6892. const loc = input.loc;
  6893. const exp = input.content;
  6894. const inMatch = exp.match(forAliasRE);
  6895. if (!inMatch)
  6896. return;
  6897. const [, LHS, RHS] = inMatch;
  6898. const result = {
  6899. source: createAliasExpression(loc, RHS.trim(), exp.indexOf(RHS, LHS.length)),
  6900. value: void 0,
  6901. key: void 0,
  6902. index: void 0
  6903. };
  6904. if (true) {
  6905. validateBrowserExpression(result.source, context);
  6906. }
  6907. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  6908. const trimmedOffset = LHS.indexOf(valueContent);
  6909. const iteratorMatch = valueContent.match(forIteratorRE);
  6910. if (iteratorMatch) {
  6911. valueContent = valueContent.replace(forIteratorRE, "").trim();
  6912. const keyContent = iteratorMatch[1].trim();
  6913. let keyOffset;
  6914. if (keyContent) {
  6915. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  6916. result.key = createAliasExpression(loc, keyContent, keyOffset);
  6917. if (true) {
  6918. validateBrowserExpression(result.key, context, true);
  6919. }
  6920. }
  6921. if (iteratorMatch[2]) {
  6922. const indexContent = iteratorMatch[2].trim();
  6923. if (indexContent) {
  6924. result.index = createAliasExpression(loc, indexContent, exp.indexOf(indexContent, result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length));
  6925. if (true) {
  6926. validateBrowserExpression(result.index, context, true);
  6927. }
  6928. }
  6929. }
  6930. }
  6931. if (valueContent) {
  6932. result.value = createAliasExpression(loc, valueContent, trimmedOffset);
  6933. if (true) {
  6934. validateBrowserExpression(result.value, context, true);
  6935. }
  6936. }
  6937. return result;
  6938. }
  6939. function createAliasExpression(range, content, offset) {
  6940. return createSimpleExpression(content, false, getInnerRange(range, offset, content.length));
  6941. }
  6942. function createForLoopParams({ value, key, index }, memoArgs = []) {
  6943. return createParamsList([value, key, index, ...memoArgs]);
  6944. }
  6945. function createParamsList(args) {
  6946. let i = args.length;
  6947. while (i--) {
  6948. if (args[i])
  6949. break;
  6950. }
  6951. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  6952. }
  6953. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  6954. context.helper(WITH_CTX);
  6955. const { children, loc } = node;
  6956. const slotsProperties = [];
  6957. const dynamicSlots = [];
  6958. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  6959. const onComponentSlot = findDir(node, "slot", true);
  6960. if (onComponentSlot) {
  6961. const { arg, exp } = onComponentSlot;
  6962. if (arg && !isStaticExp(arg)) {
  6963. hasDynamicSlots = true;
  6964. }
  6965. slotsProperties.push(createObjectProperty(arg || createSimpleExpression("default", true), buildSlotFn(exp, children, loc)));
  6966. }
  6967. let hasTemplateSlots = false;
  6968. let hasNamedDefaultSlot = false;
  6969. const implicitDefaultChildren = [];
  6970. const seenSlotNames = /* @__PURE__ */ new Set();
  6971. for (let i = 0; i < children.length; i++) {
  6972. const slotElement = children[i];
  6973. let slotDir;
  6974. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  6975. if (slotElement.type !== 3) {
  6976. implicitDefaultChildren.push(slotElement);
  6977. }
  6978. continue;
  6979. }
  6980. if (onComponentSlot) {
  6981. context.onError(createCompilerError(37, slotDir.loc));
  6982. break;
  6983. }
  6984. hasTemplateSlots = true;
  6985. const { children: slotChildren, loc: slotLoc } = slotElement;
  6986. const { arg: slotName = createSimpleExpression(`default`, true), exp: slotProps, loc: dirLoc } = slotDir;
  6987. let staticSlotName;
  6988. if (isStaticExp(slotName)) {
  6989. staticSlotName = slotName ? slotName.content : `default`;
  6990. } else {
  6991. hasDynamicSlots = true;
  6992. }
  6993. const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
  6994. let vIf;
  6995. let vElse;
  6996. let vFor;
  6997. if (vIf = findDir(slotElement, "if")) {
  6998. hasDynamicSlots = true;
  6999. dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
  7000. } else if (vElse = findDir(slotElement, /^else(-if)?$/, true)) {
  7001. let j = i;
  7002. let prev;
  7003. while (j--) {
  7004. prev = children[j];
  7005. if (prev.type !== 3) {
  7006. break;
  7007. }
  7008. }
  7009. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  7010. children.splice(i, 1);
  7011. i--;
  7012. let conditional = dynamicSlots[dynamicSlots.length - 1];
  7013. while (conditional.alternate.type === 19) {
  7014. conditional = conditional.alternate;
  7015. }
  7016. conditional.alternate = vElse.exp ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback) : buildDynamicSlot(slotName, slotFunction);
  7017. } else {
  7018. context.onError(createCompilerError(30, vElse.loc));
  7019. }
  7020. } else if (vFor = findDir(slotElement, "for")) {
  7021. hasDynamicSlots = true;
  7022. const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
  7023. if (parseResult) {
  7024. dynamicSlots.push(createCallExpression(context.helper(RENDER_LIST), [
  7025. parseResult.source,
  7026. createFunctionExpression(createForLoopParams(parseResult), buildDynamicSlot(slotName, slotFunction), true)
  7027. ]));
  7028. } else {
  7029. context.onError(createCompilerError(32, vFor.loc));
  7030. }
  7031. } else {
  7032. if (staticSlotName) {
  7033. if (seenSlotNames.has(staticSlotName)) {
  7034. context.onError(createCompilerError(38, dirLoc));
  7035. continue;
  7036. }
  7037. seenSlotNames.add(staticSlotName);
  7038. if (staticSlotName === "default") {
  7039. hasNamedDefaultSlot = true;
  7040. }
  7041. }
  7042. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  7043. }
  7044. }
  7045. if (!onComponentSlot) {
  7046. const buildDefaultSlotProperty = (props, children2) => {
  7047. const fn = buildSlotFn(props, children2, loc);
  7048. if (context.compatConfig) {
  7049. fn.isNonScopedSlot = true;
  7050. }
  7051. return createObjectProperty(`default`, fn);
  7052. };
  7053. if (!hasTemplateSlots) {
  7054. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  7055. } else if (implicitDefaultChildren.length && implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  7056. if (hasNamedDefaultSlot) {
  7057. context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
  7058. } else {
  7059. slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
  7060. }
  7061. }
  7062. }
  7063. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  7064. let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(
  7065. `_`,
  7066. createSimpleExpression(slotFlag + (true ? ` /* ${slotFlagsText[slotFlag]} */` : ``), false)
  7067. )), loc);
  7068. if (dynamicSlots.length) {
  7069. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  7070. slots,
  7071. createArrayExpression(dynamicSlots)
  7072. ]);
  7073. }
  7074. return {
  7075. slots,
  7076. hasDynamicSlots
  7077. };
  7078. }
  7079. function buildDynamicSlot(name, fn) {
  7080. return createObjectExpression([
  7081. createObjectProperty(`name`, name),
  7082. createObjectProperty(`fn`, fn)
  7083. ]);
  7084. }
  7085. function hasForwardedSlots(children) {
  7086. for (let i = 0; i < children.length; i++) {
  7087. const child = children[i];
  7088. switch (child.type) {
  7089. case 1:
  7090. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  7091. return true;
  7092. }
  7093. break;
  7094. case 9:
  7095. if (hasForwardedSlots(child.branches))
  7096. return true;
  7097. break;
  7098. case 10:
  7099. case 11:
  7100. if (hasForwardedSlots(child.children))
  7101. return true;
  7102. break;
  7103. }
  7104. }
  7105. return false;
  7106. }
  7107. function isNonWhitespaceContent(node) {
  7108. if (node.type !== 2 && node.type !== 12)
  7109. return true;
  7110. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  7111. }
  7112. function resolveComponentType(node, context, ssr = false) {
  7113. let { tag } = node;
  7114. const isExplicitDynamic = isComponentTag(tag);
  7115. const isProp = findProp(node, "is");
  7116. if (isProp) {
  7117. if (isExplicitDynamic || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context)) {
  7118. const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
  7119. if (exp) {
  7120. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  7121. exp
  7122. ]);
  7123. }
  7124. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  7125. tag = isProp.value.content.slice(4);
  7126. }
  7127. }
  7128. const isDir = !isExplicitDynamic && findDir(node, "is");
  7129. if (isDir && isDir.exp) {
  7130. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  7131. isDir.exp
  7132. ]);
  7133. }
  7134. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  7135. if (builtIn) {
  7136. if (!ssr)
  7137. context.helper(builtIn);
  7138. return builtIn;
  7139. }
  7140. context.helper(RESOLVE_COMPONENT);
  7141. context.components.add(tag);
  7142. return toValidAssetId(tag, `component`);
  7143. }
  7144. function buildProps(node, context, props = node.props, isComponent2, isDynamicComponent, ssr = false) {
  7145. const { tag, loc: elementLoc, children } = node;
  7146. let properties = [];
  7147. const mergeArgs = [];
  7148. const runtimeDirectives = [];
  7149. const hasChildren = children.length > 0;
  7150. let shouldUseBlock = false;
  7151. let patchFlag = 0;
  7152. let hasRef = false;
  7153. let hasClassBinding = false;
  7154. let hasStyleBinding = false;
  7155. let hasHydrationEventBinding = false;
  7156. let hasDynamicKeys = false;
  7157. let hasVnodeHook = false;
  7158. const dynamicPropNames = [];
  7159. const analyzePatchFlag = ({ key, value }) => {
  7160. if (isStaticExp(key)) {
  7161. const name = key.content;
  7162. const isEventHandler = isOn(name);
  7163. if (isEventHandler && (!isComponent2 || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) {
  7164. hasHydrationEventBinding = true;
  7165. }
  7166. if (isEventHandler && isReservedProp(name)) {
  7167. hasVnodeHook = true;
  7168. }
  7169. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  7170. return;
  7171. }
  7172. if (name === "ref") {
  7173. hasRef = true;
  7174. } else if (name === "class") {
  7175. hasClassBinding = true;
  7176. } else if (name === "style") {
  7177. hasStyleBinding = true;
  7178. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  7179. dynamicPropNames.push(name);
  7180. }
  7181. if (isComponent2 && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  7182. dynamicPropNames.push(name);
  7183. }
  7184. } else {
  7185. hasDynamicKeys = true;
  7186. }
  7187. };
  7188. for (let i = 0; i < props.length; i++) {
  7189. const prop = props[i];
  7190. if (prop.type === 6) {
  7191. const { loc, name, value } = prop;
  7192. let isStatic = true;
  7193. if (name === "ref") {
  7194. hasRef = true;
  7195. if (context.scopes.vFor > 0) {
  7196. properties.push(createObjectProperty(createSimpleExpression("ref_for", true), createSimpleExpression("true")));
  7197. }
  7198. }
  7199. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) {
  7200. continue;
  7201. }
  7202. properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : "", isStatic, value ? value.loc : loc)));
  7203. } else {
  7204. const { name, arg, exp, loc } = prop;
  7205. const isVBind = name === "bind";
  7206. const isVOn = name === "on";
  7207. if (name === "slot") {
  7208. if (!isComponent2) {
  7209. context.onError(createCompilerError(40, loc));
  7210. }
  7211. continue;
  7212. }
  7213. if (name === "once" || name === "memo") {
  7214. continue;
  7215. }
  7216. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) {
  7217. continue;
  7218. }
  7219. if (isVOn && ssr) {
  7220. continue;
  7221. }
  7222. if (isVBind && isStaticArgOf(arg, "key") || isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")) {
  7223. shouldUseBlock = true;
  7224. }
  7225. if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
  7226. properties.push(createObjectProperty(createSimpleExpression("ref_for", true), createSimpleExpression("true")));
  7227. }
  7228. if (!arg && (isVBind || isVOn)) {
  7229. hasDynamicKeys = true;
  7230. if (exp) {
  7231. if (properties.length) {
  7232. mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
  7233. properties = [];
  7234. }
  7235. if (isVBind) {
  7236. {
  7237. if (true) {
  7238. const hasOverridableKeys = mergeArgs.some((arg2) => {
  7239. if (arg2.type === 15) {
  7240. return arg2.properties.some(({ key }) => {
  7241. if (key.type !== 4 || !key.isStatic) {
  7242. return true;
  7243. }
  7244. return key.content !== "class" && key.content !== "style" && !isOn(key.content);
  7245. });
  7246. } else {
  7247. return true;
  7248. }
  7249. });
  7250. if (hasOverridableKeys) {
  7251. checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
  7252. }
  7253. }
  7254. if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
  7255. mergeArgs.unshift(exp);
  7256. continue;
  7257. }
  7258. }
  7259. mergeArgs.push(exp);
  7260. } else {
  7261. mergeArgs.push({
  7262. type: 14,
  7263. loc,
  7264. callee: context.helper(TO_HANDLERS),
  7265. arguments: [exp]
  7266. });
  7267. }
  7268. } else {
  7269. context.onError(createCompilerError(isVBind ? 34 : 35, loc));
  7270. }
  7271. continue;
  7272. }
  7273. const directiveTransform = context.directiveTransforms[name];
  7274. if (directiveTransform) {
  7275. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  7276. !ssr && props2.forEach(analyzePatchFlag);
  7277. properties.push(...props2);
  7278. if (needRuntime) {
  7279. runtimeDirectives.push(prop);
  7280. if (isSymbol(needRuntime)) {
  7281. directiveImportMap.set(prop, needRuntime);
  7282. }
  7283. }
  7284. } else if (!isBuiltInDirective(name)) {
  7285. runtimeDirectives.push(prop);
  7286. if (hasChildren) {
  7287. shouldUseBlock = true;
  7288. }
  7289. }
  7290. }
  7291. }
  7292. let propsExpression = void 0;
  7293. if (mergeArgs.length) {
  7294. if (properties.length) {
  7295. mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
  7296. }
  7297. if (mergeArgs.length > 1) {
  7298. propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
  7299. } else {
  7300. propsExpression = mergeArgs[0];
  7301. }
  7302. } else if (properties.length) {
  7303. propsExpression = createObjectExpression(dedupeProperties(properties), elementLoc);
  7304. }
  7305. if (hasDynamicKeys) {
  7306. patchFlag |= 16;
  7307. } else {
  7308. if (hasClassBinding && !isComponent2) {
  7309. patchFlag |= 2;
  7310. }
  7311. if (hasStyleBinding && !isComponent2) {
  7312. patchFlag |= 4;
  7313. }
  7314. if (dynamicPropNames.length) {
  7315. patchFlag |= 8;
  7316. }
  7317. if (hasHydrationEventBinding) {
  7318. patchFlag |= 32;
  7319. }
  7320. }
  7321. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  7322. patchFlag |= 512;
  7323. }
  7324. if (!context.inSSR && propsExpression) {
  7325. switch (propsExpression.type) {
  7326. case 15:
  7327. let classKeyIndex = -1;
  7328. let styleKeyIndex = -1;
  7329. let hasDynamicKey = false;
  7330. for (let i = 0; i < propsExpression.properties.length; i++) {
  7331. const key = propsExpression.properties[i].key;
  7332. if (isStaticExp(key)) {
  7333. if (key.content === "class") {
  7334. classKeyIndex = i;
  7335. } else if (key.content === "style") {
  7336. styleKeyIndex = i;
  7337. }
  7338. } else if (!key.isHandlerKey) {
  7339. hasDynamicKey = true;
  7340. }
  7341. }
  7342. const classProp = propsExpression.properties[classKeyIndex];
  7343. const styleProp = propsExpression.properties[styleKeyIndex];
  7344. if (!hasDynamicKey) {
  7345. if (classProp && !isStaticExp(classProp.value)) {
  7346. classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
  7347. }
  7348. if (styleProp && (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || styleProp.value.type === 17)) {
  7349. styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
  7350. }
  7351. } else {
  7352. propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
  7353. }
  7354. break;
  7355. case 14:
  7356. break;
  7357. default:
  7358. propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [
  7359. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  7360. propsExpression
  7361. ])
  7362. ]);
  7363. break;
  7364. }
  7365. }
  7366. return {
  7367. props: propsExpression,
  7368. directives: runtimeDirectives,
  7369. patchFlag,
  7370. dynamicPropNames,
  7371. shouldUseBlock
  7372. };
  7373. }
  7374. function dedupeProperties(properties) {
  7375. const knownProps = /* @__PURE__ */ new Map();
  7376. const deduped = [];
  7377. for (let i = 0; i < properties.length; i++) {
  7378. const prop = properties[i];
  7379. if (prop.key.type === 8 || !prop.key.isStatic) {
  7380. deduped.push(prop);
  7381. continue;
  7382. }
  7383. const name = prop.key.content;
  7384. const existing = knownProps.get(name);
  7385. if (existing) {
  7386. if (name === "style" || name === "class" || isOn(name)) {
  7387. mergeAsArray(existing, prop);
  7388. }
  7389. } else {
  7390. knownProps.set(name, prop);
  7391. deduped.push(prop);
  7392. }
  7393. }
  7394. return deduped;
  7395. }
  7396. function mergeAsArray(existing, incoming) {
  7397. if (existing.value.type === 17) {
  7398. existing.value.elements.push(incoming.value);
  7399. } else {
  7400. existing.value = createArrayExpression([existing.value, incoming.value], existing.loc);
  7401. }
  7402. }
  7403. function buildDirectiveArgs(dir, context) {
  7404. const dirArgs = [];
  7405. const runtime = directiveImportMap.get(dir);
  7406. if (runtime) {
  7407. dirArgs.push(context.helperString(runtime));
  7408. } else {
  7409. {
  7410. context.helper(RESOLVE_DIRECTIVE);
  7411. context.directives.add(dir.name);
  7412. dirArgs.push(toValidAssetId(dir.name, `directive`));
  7413. }
  7414. }
  7415. const { loc } = dir;
  7416. if (dir.exp)
  7417. dirArgs.push(dir.exp);
  7418. if (dir.arg) {
  7419. if (!dir.exp) {
  7420. dirArgs.push(`void 0`);
  7421. }
  7422. dirArgs.push(dir.arg);
  7423. }
  7424. if (Object.keys(dir.modifiers).length) {
  7425. if (!dir.arg) {
  7426. if (!dir.exp) {
  7427. dirArgs.push(`void 0`);
  7428. }
  7429. dirArgs.push(`void 0`);
  7430. }
  7431. const trueExpression = createSimpleExpression(`true`, false, loc);
  7432. dirArgs.push(createObjectExpression(dir.modifiers.map((modifier) => createObjectProperty(modifier, trueExpression)), loc));
  7433. }
  7434. return createArrayExpression(dirArgs, dir.loc);
  7435. }
  7436. function stringifyDynamicPropNames(props) {
  7437. let propsNamesString = `[`;
  7438. for (let i = 0, l = props.length; i < l; i++) {
  7439. propsNamesString += JSON.stringify(props[i]);
  7440. if (i < l - 1)
  7441. propsNamesString += ", ";
  7442. }
  7443. return propsNamesString + `]`;
  7444. }
  7445. function isComponentTag(tag) {
  7446. return tag === "component" || tag === "Component";
  7447. }
  7448. function processSlotOutlet(node, context) {
  7449. let slotName = `"default"`;
  7450. let slotProps = void 0;
  7451. const nonNameProps = [];
  7452. for (let i = 0; i < node.props.length; i++) {
  7453. const p = node.props[i];
  7454. if (p.type === 6) {
  7455. if (p.value) {
  7456. if (p.name === "name") {
  7457. slotName = JSON.stringify(p.value.content);
  7458. } else {
  7459. p.name = camelize2(p.name);
  7460. nonNameProps.push(p);
  7461. }
  7462. }
  7463. } else {
  7464. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  7465. if (p.exp)
  7466. slotName = p.exp;
  7467. } else {
  7468. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  7469. p.arg.content = camelize2(p.arg.content);
  7470. }
  7471. nonNameProps.push(p);
  7472. }
  7473. }
  7474. }
  7475. if (nonNameProps.length > 0) {
  7476. const { props, directives } = buildProps(node, context, nonNameProps, false, false);
  7477. slotProps = props;
  7478. if (directives.length) {
  7479. context.onError(createCompilerError(36, directives[0].loc));
  7480. }
  7481. }
  7482. return {
  7483. slotName,
  7484. slotProps
  7485. };
  7486. }
  7487. function createTransformProps(props = []) {
  7488. return { props };
  7489. }
  7490. function rewriteFilter(node, context) {
  7491. if (node.type === 4) {
  7492. parseFilter(node, context);
  7493. } else {
  7494. for (let i = 0; i < node.children.length; i++) {
  7495. const child = node.children[i];
  7496. if (typeof child !== "object")
  7497. continue;
  7498. if (child.type === 4) {
  7499. parseFilter(child, context);
  7500. } else if (child.type === 8) {
  7501. rewriteFilter(node, context);
  7502. } else if (child.type === 5) {
  7503. rewriteFilter(child.content, context);
  7504. }
  7505. }
  7506. }
  7507. }
  7508. function parseFilter(node, context) {
  7509. const exp = node.content;
  7510. let inSingle = false;
  7511. let inDouble = false;
  7512. let inTemplateString = false;
  7513. let inRegex = false;
  7514. let curly = 0;
  7515. let square = 0;
  7516. let paren = 0;
  7517. let lastFilterIndex = 0;
  7518. let c, prev, i, expression, filters = [];
  7519. for (i = 0; i < exp.length; i++) {
  7520. prev = c;
  7521. c = exp.charCodeAt(i);
  7522. if (inSingle) {
  7523. if (c === 39 && prev !== 92)
  7524. inSingle = false;
  7525. } else if (inDouble) {
  7526. if (c === 34 && prev !== 92)
  7527. inDouble = false;
  7528. } else if (inTemplateString) {
  7529. if (c === 96 && prev !== 92)
  7530. inTemplateString = false;
  7531. } else if (inRegex) {
  7532. if (c === 47 && prev !== 92)
  7533. inRegex = false;
  7534. } else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
  7535. if (expression === void 0) {
  7536. lastFilterIndex = i + 1;
  7537. expression = exp.slice(0, i).trim();
  7538. } else {
  7539. pushFilter();
  7540. }
  7541. } else {
  7542. switch (c) {
  7543. case 34:
  7544. inDouble = true;
  7545. break;
  7546. case 39:
  7547. inSingle = true;
  7548. break;
  7549. case 96:
  7550. inTemplateString = true;
  7551. break;
  7552. case 40:
  7553. paren++;
  7554. break;
  7555. case 41:
  7556. paren--;
  7557. break;
  7558. case 91:
  7559. square++;
  7560. break;
  7561. case 93:
  7562. square--;
  7563. break;
  7564. case 123:
  7565. curly++;
  7566. break;
  7567. case 125:
  7568. curly--;
  7569. break;
  7570. }
  7571. if (c === 47) {
  7572. let j = i - 1;
  7573. let p;
  7574. for (; j >= 0; j--) {
  7575. p = exp.charAt(j);
  7576. if (p !== " ")
  7577. break;
  7578. }
  7579. if (!p || !validDivisionCharRE.test(p)) {
  7580. inRegex = true;
  7581. }
  7582. }
  7583. }
  7584. }
  7585. if (expression === void 0) {
  7586. expression = exp.slice(0, i).trim();
  7587. } else if (lastFilterIndex !== 0) {
  7588. pushFilter();
  7589. }
  7590. function pushFilter() {
  7591. filters.push(exp.slice(lastFilterIndex, i).trim());
  7592. lastFilterIndex = i + 1;
  7593. }
  7594. if (filters.length) {
  7595. warnDeprecation("COMPILER_FILTER", context, node.loc);
  7596. for (i = 0; i < filters.length; i++) {
  7597. expression = wrapFilter(expression, filters[i], context);
  7598. }
  7599. node.content = expression;
  7600. }
  7601. }
  7602. function wrapFilter(exp, filter, context) {
  7603. context.helper(RESOLVE_FILTER);
  7604. const i = filter.indexOf("(");
  7605. if (i < 0) {
  7606. context.filters.add(filter);
  7607. return `${toValidAssetId(filter, "filter")}(${exp})`;
  7608. } else {
  7609. const name = filter.slice(0, i);
  7610. const args = filter.slice(i + 1);
  7611. context.filters.add(name);
  7612. return `${toValidAssetId(name, "filter")}(${exp}${args !== ")" ? "," + args : args}`;
  7613. }
  7614. }
  7615. function getBaseTransformPreset(prefixIdentifiers) {
  7616. return [
  7617. [
  7618. transformOnce,
  7619. transformIf,
  7620. transformMemo,
  7621. transformFor,
  7622. ...[transformFilter],
  7623. ...true ? [transformExpression] : [],
  7624. transformSlotOutlet,
  7625. transformElement,
  7626. trackSlotScopes,
  7627. transformText
  7628. ],
  7629. {
  7630. on: transformOn,
  7631. bind: transformBind,
  7632. model: transformModel
  7633. }
  7634. ];
  7635. }
  7636. function baseCompile(template, options = {}) {
  7637. const onError = options.onError || defaultOnError;
  7638. const isModuleMode = options.mode === "module";
  7639. {
  7640. if (options.prefixIdentifiers === true) {
  7641. onError(createCompilerError(46));
  7642. } else if (isModuleMode) {
  7643. onError(createCompilerError(47));
  7644. }
  7645. }
  7646. const prefixIdentifiers = false;
  7647. if (options.cacheHandlers) {
  7648. onError(createCompilerError(48));
  7649. }
  7650. if (options.scopeId && !isModuleMode) {
  7651. onError(createCompilerError(49));
  7652. }
  7653. const ast = isString(template) ? baseParse(template, options) : template;
  7654. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  7655. transform(ast, extend({}, options, {
  7656. prefixIdentifiers,
  7657. nodeTransforms: [
  7658. ...nodeTransforms,
  7659. ...options.nodeTransforms || []
  7660. ],
  7661. directiveTransforms: extend(
  7662. {},
  7663. directiveTransforms,
  7664. options.directiveTransforms || {}
  7665. )
  7666. }));
  7667. return generate(ast, extend({}, options, {
  7668. prefixIdentifiers
  7669. }));
  7670. }
  7671. var errorMessages, FRAGMENT, TELEPORT, SUSPENSE, KEEP_ALIVE, BASE_TRANSITION, OPEN_BLOCK, CREATE_BLOCK, CREATE_ELEMENT_BLOCK, CREATE_VNODE, CREATE_ELEMENT_VNODE, CREATE_COMMENT, CREATE_TEXT, CREATE_STATIC, RESOLVE_COMPONENT, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_FILTER, WITH_DIRECTIVES, RENDER_LIST, RENDER_SLOT, CREATE_SLOTS, TO_DISPLAY_STRING, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_STYLE, NORMALIZE_PROPS, GUARD_REACTIVE_PROPS, TO_HANDLERS, CAMELIZE, CAPITALIZE, TO_HANDLER_KEY, SET_BLOCK_TRACKING, PUSH_SCOPE_ID, POP_SCOPE_ID, WITH_CTX, UNREF, IS_REF, WITH_MEMO, IS_MEMO_SAME, helperNameMap, locStub, isStaticExp, isBuiltInType, nonIdentifierRE, isSimpleIdentifier, validFirstIdentCharRE, validIdentCharRE, whitespaceRE, isMemberExpressionBrowser, isMemberExpressionNode, isMemberExpression, propsHelperSet, deprecationData, decodeRE, decodeMap, defaultParserOptions, isSpecialTemplateDirective, allowHoistedHelperSet, PURE_ANNOTATION, aliasHelper, isFunctionType, isStaticProperty, isStaticPropertyKey, prohibitedKeywordRE, stripStringRE, transformExpression, transformIf, transformFor, forAliasRE, forIteratorRE, stripParensRE, defaultFallback, trackSlotScopes, trackVForSlotScopes, buildClientSlotFn, directiveImportMap, transformElement, cacheStringFunction, camelizeRE, camelize2, transformSlotOutlet, fnExpRE, transformOn, transformBind, injectPrefix, transformText, seen, transformOnce, transformModel, validDivisionCharRE, transformFilter, seen$1, transformMemo, noopDirectiveTransform;
  7672. var init_compiler_core_esm_bundler = __esm({
  7673. "node_modules/vue/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js"() {
  7674. init_define_APP_INFO();
  7675. init_shared_esm_bundler();
  7676. init_shared_esm_bundler();
  7677. errorMessages = {
  7678. [0]: "Illegal comment.",
  7679. [1]: "CDATA section is allowed only in XML context.",
  7680. [2]: "Duplicate attribute.",
  7681. [3]: "End tag cannot have attributes.",
  7682. [4]: "Illegal '/' in tags.",
  7683. [5]: "Unexpected EOF in tag.",
  7684. [6]: "Unexpected EOF in CDATA section.",
  7685. [7]: "Unexpected EOF in comment.",
  7686. [8]: "Unexpected EOF in script.",
  7687. [9]: "Unexpected EOF in tag.",
  7688. [10]: "Incorrectly closed comment.",
  7689. [11]: "Incorrectly opened comment.",
  7690. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  7691. [13]: "Attribute value was expected.",
  7692. [14]: "End tag name was expected.",
  7693. [15]: "Whitespace was expected.",
  7694. [16]: "Unexpected '<!--' in comment.",
  7695. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  7696. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  7697. [19]: "Attribute name cannot start with '='.",
  7698. [21]: "'<?' is allowed only in XML context.",
  7699. [20]: `Unexpected null character.`,
  7700. [22]: "Illegal '/' in tags.",
  7701. [23]: "Invalid end tag.",
  7702. [24]: "Element is missing end tag.",
  7703. [25]: "Interpolation end sign was not found.",
  7704. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  7705. [26]: "Legal directive name was expected.",
  7706. [28]: `v-if/v-else-if is missing expression.`,
  7707. [29]: `v-if/else branches must use unique keys.`,
  7708. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  7709. [31]: `v-for is missing expression.`,
  7710. [32]: `v-for has invalid expression.`,
  7711. [33]: `<template v-for> key should be placed on the <template> tag.`,
  7712. [34]: `v-bind is missing expression.`,
  7713. [35]: `v-on is missing expression.`,
  7714. [36]: `Unexpected custom directive on <slot> outlet.`,
  7715. [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.`,
  7716. [38]: `Duplicate slot names found. `,
  7717. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  7718. [40]: `v-slot can only be used on components or <template> tags.`,
  7719. [41]: `v-model is missing expression.`,
  7720. [42]: `v-model value must be a valid JavaScript member expression.`,
  7721. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  7722. [44]: `Error parsing JavaScript expression: `,
  7723. [45]: `<KeepAlive> expects exactly one child component.`,
  7724. [46]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  7725. [47]: `ES module mode is not supported in this build of compiler.`,
  7726. [48]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  7727. [49]: `"scopeId" option is only supported in module mode.`,
  7728. [50]: ``
  7729. };
  7730. FRAGMENT = Symbol(true ? `Fragment` : ``);
  7731. TELEPORT = Symbol(true ? `Teleport` : ``);
  7732. SUSPENSE = Symbol(true ? `Suspense` : ``);
  7733. KEEP_ALIVE = Symbol(true ? `KeepAlive` : ``);
  7734. BASE_TRANSITION = Symbol(true ? `BaseTransition` : ``);
  7735. OPEN_BLOCK = Symbol(true ? `openBlock` : ``);
  7736. CREATE_BLOCK = Symbol(true ? `createBlock` : ``);
  7737. CREATE_ELEMENT_BLOCK = Symbol(true ? `createElementBlock` : ``);
  7738. CREATE_VNODE = Symbol(true ? `createVNode` : ``);
  7739. CREATE_ELEMENT_VNODE = Symbol(true ? `createElementVNode` : ``);
  7740. CREATE_COMMENT = Symbol(true ? `createCommentVNode` : ``);
  7741. CREATE_TEXT = Symbol(true ? `createTextVNode` : ``);
  7742. CREATE_STATIC = Symbol(true ? `createStaticVNode` : ``);
  7743. RESOLVE_COMPONENT = Symbol(true ? `resolveComponent` : ``);
  7744. RESOLVE_DYNAMIC_COMPONENT = Symbol(true ? `resolveDynamicComponent` : ``);
  7745. RESOLVE_DIRECTIVE = Symbol(true ? `resolveDirective` : ``);
  7746. RESOLVE_FILTER = Symbol(true ? `resolveFilter` : ``);
  7747. WITH_DIRECTIVES = Symbol(true ? `withDirectives` : ``);
  7748. RENDER_LIST = Symbol(true ? `renderList` : ``);
  7749. RENDER_SLOT = Symbol(true ? `renderSlot` : ``);
  7750. CREATE_SLOTS = Symbol(true ? `createSlots` : ``);
  7751. TO_DISPLAY_STRING = Symbol(true ? `toDisplayString` : ``);
  7752. MERGE_PROPS = Symbol(true ? `mergeProps` : ``);
  7753. NORMALIZE_CLASS = Symbol(true ? `normalizeClass` : ``);
  7754. NORMALIZE_STYLE = Symbol(true ? `normalizeStyle` : ``);
  7755. NORMALIZE_PROPS = Symbol(true ? `normalizeProps` : ``);
  7756. GUARD_REACTIVE_PROPS = Symbol(true ? `guardReactiveProps` : ``);
  7757. TO_HANDLERS = Symbol(true ? `toHandlers` : ``);
  7758. CAMELIZE = Symbol(true ? `camelize` : ``);
  7759. CAPITALIZE = Symbol(true ? `capitalize` : ``);
  7760. TO_HANDLER_KEY = Symbol(true ? `toHandlerKey` : ``);
  7761. SET_BLOCK_TRACKING = Symbol(true ? `setBlockTracking` : ``);
  7762. PUSH_SCOPE_ID = Symbol(true ? `pushScopeId` : ``);
  7763. POP_SCOPE_ID = Symbol(true ? `popScopeId` : ``);
  7764. WITH_CTX = Symbol(true ? `withCtx` : ``);
  7765. UNREF = Symbol(true ? `unref` : ``);
  7766. IS_REF = Symbol(true ? `isRef` : ``);
  7767. WITH_MEMO = Symbol(true ? `withMemo` : ``);
  7768. IS_MEMO_SAME = Symbol(true ? `isMemoSame` : ``);
  7769. helperNameMap = {
  7770. [FRAGMENT]: `Fragment`,
  7771. [TELEPORT]: `Teleport`,
  7772. [SUSPENSE]: `Suspense`,
  7773. [KEEP_ALIVE]: `KeepAlive`,
  7774. [BASE_TRANSITION]: `BaseTransition`,
  7775. [OPEN_BLOCK]: `openBlock`,
  7776. [CREATE_BLOCK]: `createBlock`,
  7777. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  7778. [CREATE_VNODE]: `createVNode`,
  7779. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  7780. [CREATE_COMMENT]: `createCommentVNode`,
  7781. [CREATE_TEXT]: `createTextVNode`,
  7782. [CREATE_STATIC]: `createStaticVNode`,
  7783. [RESOLVE_COMPONENT]: `resolveComponent`,
  7784. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  7785. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  7786. [RESOLVE_FILTER]: `resolveFilter`,
  7787. [WITH_DIRECTIVES]: `withDirectives`,
  7788. [RENDER_LIST]: `renderList`,
  7789. [RENDER_SLOT]: `renderSlot`,
  7790. [CREATE_SLOTS]: `createSlots`,
  7791. [TO_DISPLAY_STRING]: `toDisplayString`,
  7792. [MERGE_PROPS]: `mergeProps`,
  7793. [NORMALIZE_CLASS]: `normalizeClass`,
  7794. [NORMALIZE_STYLE]: `normalizeStyle`,
  7795. [NORMALIZE_PROPS]: `normalizeProps`,
  7796. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  7797. [TO_HANDLERS]: `toHandlers`,
  7798. [CAMELIZE]: `camelize`,
  7799. [CAPITALIZE]: `capitalize`,
  7800. [TO_HANDLER_KEY]: `toHandlerKey`,
  7801. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  7802. [PUSH_SCOPE_ID]: `pushScopeId`,
  7803. [POP_SCOPE_ID]: `popScopeId`,
  7804. [WITH_CTX]: `withCtx`,
  7805. [UNREF]: `unref`,
  7806. [IS_REF]: `isRef`,
  7807. [WITH_MEMO]: `withMemo`,
  7808. [IS_MEMO_SAME]: `isMemoSame`
  7809. };
  7810. locStub = {
  7811. source: "",
  7812. start: { line: 1, column: 1, offset: 0 },
  7813. end: { line: 1, column: 1, offset: 0 }
  7814. };
  7815. isStaticExp = (p) => p.type === 4 && p.isStatic;
  7816. isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
  7817. nonIdentifierRE = /^\d|[^\$\w]/;
  7818. isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  7819. validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  7820. validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  7821. whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  7822. isMemberExpressionBrowser = (path) => {
  7823. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  7824. let state = 0;
  7825. let stateStack = [];
  7826. let currentOpenBracketCount = 0;
  7827. let currentOpenParensCount = 0;
  7828. let currentStringType = null;
  7829. for (let i = 0; i < path.length; i++) {
  7830. const char = path.charAt(i);
  7831. switch (state) {
  7832. case 0:
  7833. if (char === "[") {
  7834. stateStack.push(state);
  7835. state = 1;
  7836. currentOpenBracketCount++;
  7837. } else if (char === "(") {
  7838. stateStack.push(state);
  7839. state = 2;
  7840. currentOpenParensCount++;
  7841. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  7842. return false;
  7843. }
  7844. break;
  7845. case 1:
  7846. if (char === `'` || char === `"` || char === "`") {
  7847. stateStack.push(state);
  7848. state = 3;
  7849. currentStringType = char;
  7850. } else if (char === `[`) {
  7851. currentOpenBracketCount++;
  7852. } else if (char === `]`) {
  7853. if (!--currentOpenBracketCount) {
  7854. state = stateStack.pop();
  7855. }
  7856. }
  7857. break;
  7858. case 2:
  7859. if (char === `'` || char === `"` || char === "`") {
  7860. stateStack.push(state);
  7861. state = 3;
  7862. currentStringType = char;
  7863. } else if (char === `(`) {
  7864. currentOpenParensCount++;
  7865. } else if (char === `)`) {
  7866. if (i === path.length - 1) {
  7867. return false;
  7868. }
  7869. if (!--currentOpenParensCount) {
  7870. state = stateStack.pop();
  7871. }
  7872. }
  7873. break;
  7874. case 3:
  7875. if (char === currentStringType) {
  7876. state = stateStack.pop();
  7877. currentStringType = null;
  7878. }
  7879. break;
  7880. }
  7881. }
  7882. return !currentOpenBracketCount && !currentOpenParensCount;
  7883. };
  7884. isMemberExpressionNode = NOOP;
  7885. isMemberExpression = isMemberExpressionBrowser;
  7886. propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  7887. deprecationData = {
  7888. ["COMPILER_IS_ON_ELEMENT"]: {
  7889. message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
  7890. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  7891. },
  7892. ["COMPILER_V_BIND_SYNC"]: {
  7893. message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
  7894. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  7895. },
  7896. ["COMPILER_V_BIND_PROP"]: {
  7897. message: `.prop modifier for v-bind has been removed and no longer necessary. Vue 3 will automatically set a binding as DOM property when appropriate.`
  7898. },
  7899. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  7900. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
  7901. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  7902. },
  7903. ["COMPILER_V_ON_NATIVE"]: {
  7904. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  7905. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  7906. },
  7907. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  7908. message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
  7909. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  7910. },
  7911. ["COMPILER_NATIVE_TEMPLATE"]: {
  7912. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  7913. },
  7914. ["COMPILER_INLINE_TEMPLATE"]: {
  7915. message: `"inline-template" has been removed in Vue 3.`,
  7916. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  7917. },
  7918. ["COMPILER_FILTER"]: {
  7919. message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
  7920. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  7921. }
  7922. };
  7923. decodeRE = /&(gt|lt|amp|apos|quot);/g;
  7924. decodeMap = {
  7925. gt: ">",
  7926. lt: "<",
  7927. amp: "&",
  7928. apos: "'",
  7929. quot: '"'
  7930. };
  7931. defaultParserOptions = {
  7932. delimiters: [`{{`, `}}`],
  7933. getNamespace: () => 0,
  7934. getTextMode: () => 0,
  7935. isVoidTag: NO,
  7936. isPreTag: NO,
  7937. isCustomElement: NO,
  7938. decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
  7939. onError: defaultOnError,
  7940. onWarn: defaultOnWarn,
  7941. comments: true
  7942. };
  7943. isSpecialTemplateDirective = makeMap(`if,else,else-if,for,slot`);
  7944. allowHoistedHelperSet = /* @__PURE__ */ new Set([
  7945. NORMALIZE_CLASS,
  7946. NORMALIZE_STYLE,
  7947. NORMALIZE_PROPS,
  7948. GUARD_REACTIVE_PROPS
  7949. ]);
  7950. PURE_ANNOTATION = `/*#__PURE__*/`;
  7951. aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  7952. isFunctionType = (node) => {
  7953. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  7954. };
  7955. isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  7956. isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  7957. prohibitedKeywordRE = new RegExp("\\b" + "do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,super,throw,while,yield,delete,export,import,return,switch,default,extends,finally,continue,debugger,function,arguments,typeof,void".split(",").join("\\b|\\b") + "\\b");
  7958. stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  7959. transformExpression = (node, context) => {
  7960. if (node.type === 5) {
  7961. node.content = processExpression(node.content, context);
  7962. } else if (node.type === 1) {
  7963. for (let i = 0; i < node.props.length; i++) {
  7964. const dir = node.props[i];
  7965. if (dir.type === 7 && dir.name !== "for") {
  7966. const exp = dir.exp;
  7967. const arg = dir.arg;
  7968. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  7969. dir.exp = processExpression(
  7970. exp,
  7971. context,
  7972. dir.name === "slot"
  7973. );
  7974. }
  7975. if (arg && arg.type === 4 && !arg.isStatic) {
  7976. dir.arg = processExpression(arg, context);
  7977. }
  7978. }
  7979. }
  7980. }
  7981. };
  7982. transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (node, dir, context) => {
  7983. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  7984. const siblings = context.parent.children;
  7985. let i = siblings.indexOf(ifNode);
  7986. let key = 0;
  7987. while (i-- >= 0) {
  7988. const sibling = siblings[i];
  7989. if (sibling && sibling.type === 9) {
  7990. key += sibling.branches.length;
  7991. }
  7992. }
  7993. return () => {
  7994. if (isRoot) {
  7995. ifNode.codegenNode = createCodegenNodeForBranch(branch, key, context);
  7996. } else {
  7997. const parentCondition = getParentCondition(ifNode.codegenNode);
  7998. parentCondition.alternate = createCodegenNodeForBranch(branch, key + ifNode.branches.length - 1, context);
  7999. }
  8000. };
  8001. });
  8002. });
  8003. transformFor = createStructuralDirectiveTransform("for", (node, dir, context) => {
  8004. const { helper, removeHelper } = context;
  8005. return processFor(node, dir, context, (forNode) => {
  8006. const renderExp = createCallExpression(helper(RENDER_LIST), [
  8007. forNode.source
  8008. ]);
  8009. const isTemplate = isTemplateNode(node);
  8010. const memo = findDir(node, "memo");
  8011. const keyProp = findProp(node, `key`);
  8012. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  8013. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  8014. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  8015. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  8016. forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag + (true ? ` /* ${PatchFlagNames[fragmentFlag]} */` : ``), void 0, void 0, true, !isStableFragment, false, node.loc);
  8017. return () => {
  8018. let childBlock;
  8019. const { children } = forNode;
  8020. if (isTemplate) {
  8021. node.children.some((c) => {
  8022. if (c.type === 1) {
  8023. const key = findProp(c, "key");
  8024. if (key) {
  8025. context.onError(createCompilerError(33, key.loc));
  8026. return true;
  8027. }
  8028. }
  8029. });
  8030. }
  8031. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  8032. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  8033. if (slotOutlet) {
  8034. childBlock = slotOutlet.codegenNode;
  8035. if (isTemplate && keyProperty) {
  8036. injectProp(childBlock, keyProperty, context);
  8037. }
  8038. } else if (needFragmentWrapper) {
  8039. childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : void 0, node.children, 64 + (true ? ` /* ${PatchFlagNames[64]} */` : ``), void 0, void 0, true, void 0, false);
  8040. } else {
  8041. childBlock = children[0].codegenNode;
  8042. if (isTemplate && keyProperty) {
  8043. injectProp(childBlock, keyProperty, context);
  8044. }
  8045. if (childBlock.isBlock !== !isStableFragment) {
  8046. if (childBlock.isBlock) {
  8047. removeHelper(OPEN_BLOCK);
  8048. removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  8049. } else {
  8050. removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  8051. }
  8052. }
  8053. childBlock.isBlock = !isStableFragment;
  8054. if (childBlock.isBlock) {
  8055. helper(OPEN_BLOCK);
  8056. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  8057. } else {
  8058. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  8059. }
  8060. }
  8061. if (memo) {
  8062. const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [
  8063. createSimpleExpression(`_cached`)
  8064. ]));
  8065. loop.body = createBlockStatement([
  8066. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  8067. createCompoundExpression([
  8068. `if (_cached`,
  8069. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  8070. ` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
  8071. ]),
  8072. createCompoundExpression([`const _item = `, childBlock]),
  8073. createSimpleExpression(`_item.memo = _memo`),
  8074. createSimpleExpression(`return _item`)
  8075. ]);
  8076. renderExp.arguments.push(loop, createSimpleExpression(`_cache`), createSimpleExpression(String(context.cached++)));
  8077. } else {
  8078. renderExp.arguments.push(createFunctionExpression(createForLoopParams(forNode.parseResult), childBlock, true));
  8079. }
  8080. };
  8081. });
  8082. });
  8083. forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  8084. forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  8085. stripParensRE = /^\(|\)$/g;
  8086. defaultFallback = createSimpleExpression(`undefined`, false);
  8087. trackSlotScopes = (node, context) => {
  8088. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  8089. const vSlot = findDir(node, "slot");
  8090. if (vSlot) {
  8091. vSlot.exp;
  8092. context.scopes.vSlot++;
  8093. return () => {
  8094. context.scopes.vSlot--;
  8095. };
  8096. }
  8097. }
  8098. };
  8099. trackVForSlotScopes = (node, context) => {
  8100. let vFor;
  8101. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  8102. const result = vFor.parseResult = parseForExpression(vFor.exp, context);
  8103. if (result) {
  8104. const { value, key, index } = result;
  8105. const { addIdentifiers, removeIdentifiers } = context;
  8106. value && addIdentifiers(value);
  8107. key && addIdentifiers(key);
  8108. index && addIdentifiers(index);
  8109. return () => {
  8110. value && removeIdentifiers(value);
  8111. key && removeIdentifiers(key);
  8112. index && removeIdentifiers(index);
  8113. };
  8114. }
  8115. }
  8116. };
  8117. buildClientSlotFn = (props, children, loc) => createFunctionExpression(props, children, false, true, children.length ? children[0].loc : loc);
  8118. directiveImportMap = /* @__PURE__ */ new WeakMap();
  8119. transformElement = (node, context) => {
  8120. return function postTransformElement() {
  8121. node = context.currentNode;
  8122. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  8123. return;
  8124. }
  8125. const { tag, props } = node;
  8126. const isComponent2 = node.tagType === 1;
  8127. let vnodeTag = isComponent2 ? resolveComponentType(node, context) : `"${tag}"`;
  8128. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  8129. let vnodeProps;
  8130. let vnodeChildren;
  8131. let vnodePatchFlag;
  8132. let patchFlag = 0;
  8133. let vnodeDynamicProps;
  8134. let dynamicPropNames;
  8135. let vnodeDirectives;
  8136. let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent2 && (tag === "svg" || tag === "foreignObject");
  8137. if (props.length > 0) {
  8138. const propsBuildResult = buildProps(node, context, void 0, isComponent2, isDynamicComponent);
  8139. vnodeProps = propsBuildResult.props;
  8140. patchFlag = propsBuildResult.patchFlag;
  8141. dynamicPropNames = propsBuildResult.dynamicPropNames;
  8142. const directives = propsBuildResult.directives;
  8143. vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
  8144. if (propsBuildResult.shouldUseBlock) {
  8145. shouldUseBlock = true;
  8146. }
  8147. }
  8148. if (node.children.length > 0) {
  8149. if (vnodeTag === KEEP_ALIVE) {
  8150. shouldUseBlock = true;
  8151. patchFlag |= 1024;
  8152. if (node.children.length > 1) {
  8153. context.onError(createCompilerError(45, {
  8154. start: node.children[0].loc.start,
  8155. end: node.children[node.children.length - 1].loc.end,
  8156. source: ""
  8157. }));
  8158. }
  8159. }
  8160. const shouldBuildAsSlots = isComponent2 && vnodeTag !== TELEPORT && vnodeTag !== KEEP_ALIVE;
  8161. if (shouldBuildAsSlots) {
  8162. const { slots, hasDynamicSlots } = buildSlots(node, context);
  8163. vnodeChildren = slots;
  8164. if (hasDynamicSlots) {
  8165. patchFlag |= 1024;
  8166. }
  8167. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  8168. const child = node.children[0];
  8169. const type = child.type;
  8170. const hasDynamicTextChild = type === 5 || type === 8;
  8171. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  8172. patchFlag |= 1;
  8173. }
  8174. if (hasDynamicTextChild || type === 2) {
  8175. vnodeChildren = child;
  8176. } else {
  8177. vnodeChildren = node.children;
  8178. }
  8179. } else {
  8180. vnodeChildren = node.children;
  8181. }
  8182. }
  8183. if (patchFlag !== 0) {
  8184. if (true) {
  8185. if (patchFlag < 0) {
  8186. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  8187. } else {
  8188. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  8189. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  8190. }
  8191. } else {
  8192. vnodePatchFlag = String(patchFlag);
  8193. }
  8194. if (dynamicPropNames && dynamicPropNames.length) {
  8195. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  8196. }
  8197. }
  8198. node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, vnodePatchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent2, node.loc);
  8199. };
  8200. };
  8201. true ? Object.freeze({}) : {};
  8202. true ? Object.freeze([]) : [];
  8203. cacheStringFunction = (fn) => {
  8204. const cache = /* @__PURE__ */ Object.create(null);
  8205. return (str) => {
  8206. const hit = cache[str];
  8207. return hit || (cache[str] = fn(str));
  8208. };
  8209. };
  8210. camelizeRE = /-(\w)/g;
  8211. camelize2 = cacheStringFunction((str) => {
  8212. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  8213. });
  8214. transformSlotOutlet = (node, context) => {
  8215. if (isSlotOutlet(node)) {
  8216. const { children, loc } = node;
  8217. const { slotName, slotProps } = processSlotOutlet(node, context);
  8218. const slotArgs = [
  8219. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  8220. slotName,
  8221. "{}",
  8222. "undefined",
  8223. "true"
  8224. ];
  8225. let expectedLen = 2;
  8226. if (slotProps) {
  8227. slotArgs[2] = slotProps;
  8228. expectedLen = 3;
  8229. }
  8230. if (children.length) {
  8231. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  8232. expectedLen = 4;
  8233. }
  8234. if (context.scopeId && !context.slotted) {
  8235. expectedLen = 5;
  8236. }
  8237. slotArgs.splice(expectedLen);
  8238. node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
  8239. }
  8240. };
  8241. fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  8242. transformOn = (dir, node, context, augmentor) => {
  8243. const { loc, modifiers, arg } = dir;
  8244. if (!dir.exp && !modifiers.length) {
  8245. context.onError(createCompilerError(35, loc));
  8246. }
  8247. let eventName;
  8248. if (arg.type === 4) {
  8249. if (arg.isStatic) {
  8250. let rawName = arg.content;
  8251. if (rawName.startsWith("vue:")) {
  8252. rawName = `vnode-${rawName.slice(4)}`;
  8253. }
  8254. eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
  8255. } else {
  8256. eventName = createCompoundExpression([
  8257. `${context.helperString(TO_HANDLER_KEY)}(`,
  8258. arg,
  8259. `)`
  8260. ]);
  8261. }
  8262. } else {
  8263. eventName = arg;
  8264. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  8265. eventName.children.push(`)`);
  8266. }
  8267. let exp = dir.exp;
  8268. if (exp && !exp.content.trim()) {
  8269. exp = void 0;
  8270. }
  8271. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  8272. if (exp) {
  8273. const isMemberExp = isMemberExpression(exp.content);
  8274. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  8275. const hasMultipleStatements = exp.content.includes(`;`);
  8276. if (true) {
  8277. validateBrowserExpression(exp, context, false, hasMultipleStatements);
  8278. }
  8279. if (isInlineStatement || shouldCache && isMemberExp) {
  8280. exp = createCompoundExpression([
  8281. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  8282. exp,
  8283. hasMultipleStatements ? `}` : `)`
  8284. ]);
  8285. }
  8286. }
  8287. let ret = {
  8288. props: [
  8289. createObjectProperty(eventName, exp || createSimpleExpression(`() => {}`, false, loc))
  8290. ]
  8291. };
  8292. if (augmentor) {
  8293. ret = augmentor(ret);
  8294. }
  8295. if (shouldCache) {
  8296. ret.props[0].value = context.cache(ret.props[0].value);
  8297. }
  8298. ret.props.forEach((p) => p.key.isHandlerKey = true);
  8299. return ret;
  8300. };
  8301. transformBind = (dir, _node, context) => {
  8302. const { exp, modifiers, loc } = dir;
  8303. const arg = dir.arg;
  8304. if (arg.type !== 4) {
  8305. arg.children.unshift(`(`);
  8306. arg.children.push(`) || ""`);
  8307. } else if (!arg.isStatic) {
  8308. arg.content = `${arg.content} || ""`;
  8309. }
  8310. if (modifiers.includes("camel")) {
  8311. if (arg.type === 4) {
  8312. if (arg.isStatic) {
  8313. arg.content = camelize(arg.content);
  8314. } else {
  8315. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  8316. }
  8317. } else {
  8318. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  8319. arg.children.push(`)`);
  8320. }
  8321. }
  8322. if (!context.inSSR) {
  8323. if (modifiers.includes("prop")) {
  8324. injectPrefix(arg, ".");
  8325. }
  8326. if (modifiers.includes("attr")) {
  8327. injectPrefix(arg, "^");
  8328. }
  8329. }
  8330. if (!exp || exp.type === 4 && !exp.content.trim()) {
  8331. context.onError(createCompilerError(34, loc));
  8332. return {
  8333. props: [createObjectProperty(arg, createSimpleExpression("", true, loc))]
  8334. };
  8335. }
  8336. return {
  8337. props: [createObjectProperty(arg, exp)]
  8338. };
  8339. };
  8340. injectPrefix = (arg, prefix) => {
  8341. if (arg.type === 4) {
  8342. if (arg.isStatic) {
  8343. arg.content = prefix + arg.content;
  8344. } else {
  8345. arg.content = `\`${prefix}\${${arg.content}}\``;
  8346. }
  8347. } else {
  8348. arg.children.unshift(`'${prefix}' + (`);
  8349. arg.children.push(`)`);
  8350. }
  8351. };
  8352. transformText = (node, context) => {
  8353. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  8354. return () => {
  8355. const children = node.children;
  8356. let currentContainer = void 0;
  8357. let hasText = false;
  8358. for (let i = 0; i < children.length; i++) {
  8359. const child = children[i];
  8360. if (isText(child)) {
  8361. hasText = true;
  8362. for (let j = i + 1; j < children.length; j++) {
  8363. const next = children[j];
  8364. if (isText(next)) {
  8365. if (!currentContainer) {
  8366. currentContainer = children[i] = createCompoundExpression([child], child.loc);
  8367. }
  8368. currentContainer.children.push(` + `, next);
  8369. children.splice(j, 1);
  8370. j--;
  8371. } else {
  8372. currentContainer = void 0;
  8373. break;
  8374. }
  8375. }
  8376. }
  8377. }
  8378. if (!hasText || children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && !node.props.find((p) => p.type === 7 && !context.directiveTransforms[p.name]) && !(node.tag === "template"))) {
  8379. return;
  8380. }
  8381. for (let i = 0; i < children.length; i++) {
  8382. const child = children[i];
  8383. if (isText(child) || child.type === 8) {
  8384. const callArgs = [];
  8385. if (child.type !== 2 || child.content !== " ") {
  8386. callArgs.push(child);
  8387. }
  8388. if (!context.ssr && getConstantType(child, context) === 0) {
  8389. callArgs.push(1 + (true ? ` /* ${PatchFlagNames[1]} */` : ``));
  8390. }
  8391. children[i] = {
  8392. type: 12,
  8393. content: child,
  8394. loc: child.loc,
  8395. codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
  8396. };
  8397. }
  8398. }
  8399. };
  8400. }
  8401. };
  8402. seen = /* @__PURE__ */ new WeakSet();
  8403. transformOnce = (node, context) => {
  8404. if (node.type === 1 && findDir(node, "once", true)) {
  8405. if (seen.has(node) || context.inVOnce) {
  8406. return;
  8407. }
  8408. seen.add(node);
  8409. context.inVOnce = true;
  8410. context.helper(SET_BLOCK_TRACKING);
  8411. return () => {
  8412. context.inVOnce = false;
  8413. const cur = context.currentNode;
  8414. if (cur.codegenNode) {
  8415. cur.codegenNode = context.cache(cur.codegenNode, true);
  8416. }
  8417. };
  8418. }
  8419. };
  8420. transformModel = (dir, node, context) => {
  8421. const { exp, arg } = dir;
  8422. if (!exp) {
  8423. context.onError(createCompilerError(41, dir.loc));
  8424. return createTransformProps();
  8425. }
  8426. const rawExp = exp.loc.source;
  8427. const expString = exp.type === 4 ? exp.content : rawExp;
  8428. context.bindingMetadata[rawExp];
  8429. const maybeRef = false;
  8430. if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
  8431. context.onError(createCompilerError(42, exp.loc));
  8432. return createTransformProps();
  8433. }
  8434. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  8435. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${arg.content}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  8436. let assignmentExp;
  8437. const eventArg = context.isTS ? `($event: any)` : `$event`;
  8438. {
  8439. assignmentExp = createCompoundExpression([
  8440. `${eventArg} => ((`,
  8441. exp,
  8442. `) = $event)`
  8443. ]);
  8444. }
  8445. const props = [
  8446. createObjectProperty(propName, dir.exp),
  8447. createObjectProperty(eventName, assignmentExp)
  8448. ];
  8449. if (dir.modifiers.length && node.tagType === 1) {
  8450. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  8451. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  8452. props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2)));
  8453. }
  8454. return createTransformProps(props);
  8455. };
  8456. validDivisionCharRE = /[\w).+\-_$\]]/;
  8457. transformFilter = (node, context) => {
  8458. if (!isCompatEnabled("COMPILER_FILTER", context)) {
  8459. return;
  8460. }
  8461. if (node.type === 5) {
  8462. rewriteFilter(node.content, context);
  8463. }
  8464. if (node.type === 1) {
  8465. node.props.forEach((prop) => {
  8466. if (prop.type === 7 && prop.name !== "for" && prop.exp) {
  8467. rewriteFilter(prop.exp, context);
  8468. }
  8469. });
  8470. }
  8471. };
  8472. seen$1 = /* @__PURE__ */ new WeakSet();
  8473. transformMemo = (node, context) => {
  8474. if (node.type === 1) {
  8475. const dir = findDir(node, "memo");
  8476. if (!dir || seen$1.has(node)) {
  8477. return;
  8478. }
  8479. seen$1.add(node);
  8480. return () => {
  8481. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  8482. if (codegenNode && codegenNode.type === 13) {
  8483. if (node.tagType !== 1) {
  8484. makeBlock(codegenNode, context);
  8485. }
  8486. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  8487. dir.exp,
  8488. createFunctionExpression(void 0, codegenNode),
  8489. `_cache`,
  8490. String(context.cached++)
  8491. ]);
  8492. }
  8493. };
  8494. }
  8495. };
  8496. noopDirectiveTransform = () => ({ props: [] });
  8497. }
  8498. });
  8499. // node_modules/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js
  8500. var compiler_dom_esm_bundler_exports = {};
  8501. __export(compiler_dom_esm_bundler_exports, {
  8502. BASE_TRANSITION: () => BASE_TRANSITION,
  8503. CAMELIZE: () => CAMELIZE,
  8504. CAPITALIZE: () => CAPITALIZE,
  8505. CREATE_BLOCK: () => CREATE_BLOCK,
  8506. CREATE_COMMENT: () => CREATE_COMMENT,
  8507. CREATE_ELEMENT_BLOCK: () => CREATE_ELEMENT_BLOCK,
  8508. CREATE_ELEMENT_VNODE: () => CREATE_ELEMENT_VNODE,
  8509. CREATE_SLOTS: () => CREATE_SLOTS,
  8510. CREATE_STATIC: () => CREATE_STATIC,
  8511. CREATE_TEXT: () => CREATE_TEXT,
  8512. CREATE_VNODE: () => CREATE_VNODE,
  8513. DOMDirectiveTransforms: () => DOMDirectiveTransforms,
  8514. DOMNodeTransforms: () => DOMNodeTransforms,
  8515. FRAGMENT: () => FRAGMENT,
  8516. GUARD_REACTIVE_PROPS: () => GUARD_REACTIVE_PROPS,
  8517. IS_MEMO_SAME: () => IS_MEMO_SAME,
  8518. IS_REF: () => IS_REF,
  8519. KEEP_ALIVE: () => KEEP_ALIVE,
  8520. MERGE_PROPS: () => MERGE_PROPS,
  8521. NORMALIZE_CLASS: () => NORMALIZE_CLASS,
  8522. NORMALIZE_PROPS: () => NORMALIZE_PROPS,
  8523. NORMALIZE_STYLE: () => NORMALIZE_STYLE,
  8524. OPEN_BLOCK: () => OPEN_BLOCK,
  8525. POP_SCOPE_ID: () => POP_SCOPE_ID,
  8526. PUSH_SCOPE_ID: () => PUSH_SCOPE_ID,
  8527. RENDER_LIST: () => RENDER_LIST,
  8528. RENDER_SLOT: () => RENDER_SLOT,
  8529. RESOLVE_COMPONENT: () => RESOLVE_COMPONENT,
  8530. RESOLVE_DIRECTIVE: () => RESOLVE_DIRECTIVE,
  8531. RESOLVE_DYNAMIC_COMPONENT: () => RESOLVE_DYNAMIC_COMPONENT,
  8532. RESOLVE_FILTER: () => RESOLVE_FILTER,
  8533. SET_BLOCK_TRACKING: () => SET_BLOCK_TRACKING,
  8534. SUSPENSE: () => SUSPENSE,
  8535. TELEPORT: () => TELEPORT,
  8536. TO_DISPLAY_STRING: () => TO_DISPLAY_STRING,
  8537. TO_HANDLERS: () => TO_HANDLERS,
  8538. TO_HANDLER_KEY: () => TO_HANDLER_KEY,
  8539. TRANSITION: () => TRANSITION,
  8540. TRANSITION_GROUP: () => TRANSITION_GROUP,
  8541. UNREF: () => UNREF,
  8542. V_MODEL_CHECKBOX: () => V_MODEL_CHECKBOX,
  8543. V_MODEL_DYNAMIC: () => V_MODEL_DYNAMIC,
  8544. V_MODEL_RADIO: () => V_MODEL_RADIO,
  8545. V_MODEL_SELECT: () => V_MODEL_SELECT,
  8546. V_MODEL_TEXT: () => V_MODEL_TEXT,
  8547. V_ON_WITH_KEYS: () => V_ON_WITH_KEYS,
  8548. V_ON_WITH_MODIFIERS: () => V_ON_WITH_MODIFIERS,
  8549. V_SHOW: () => V_SHOW,
  8550. WITH_CTX: () => WITH_CTX,
  8551. WITH_DIRECTIVES: () => WITH_DIRECTIVES,
  8552. WITH_MEMO: () => WITH_MEMO,
  8553. advancePositionWithClone: () => advancePositionWithClone,
  8554. advancePositionWithMutation: () => advancePositionWithMutation,
  8555. assert: () => assert,
  8556. baseCompile: () => baseCompile,
  8557. baseParse: () => baseParse,
  8558. buildDirectiveArgs: () => buildDirectiveArgs,
  8559. buildProps: () => buildProps,
  8560. buildSlots: () => buildSlots,
  8561. checkCompatEnabled: () => checkCompatEnabled,
  8562. compile: () => compile,
  8563. createArrayExpression: () => createArrayExpression,
  8564. createAssignmentExpression: () => createAssignmentExpression,
  8565. createBlockStatement: () => createBlockStatement,
  8566. createCacheExpression: () => createCacheExpression,
  8567. createCallExpression: () => createCallExpression,
  8568. createCompilerError: () => createCompilerError,
  8569. createCompoundExpression: () => createCompoundExpression,
  8570. createConditionalExpression: () => createConditionalExpression,
  8571. createDOMCompilerError: () => createDOMCompilerError,
  8572. createForLoopParams: () => createForLoopParams,
  8573. createFunctionExpression: () => createFunctionExpression,
  8574. createIfStatement: () => createIfStatement,
  8575. createInterpolation: () => createInterpolation,
  8576. createObjectExpression: () => createObjectExpression,
  8577. createObjectProperty: () => createObjectProperty,
  8578. createReturnStatement: () => createReturnStatement,
  8579. createRoot: () => createRoot,
  8580. createSequenceExpression: () => createSequenceExpression,
  8581. createSimpleExpression: () => createSimpleExpression,
  8582. createStructuralDirectiveTransform: () => createStructuralDirectiveTransform,
  8583. createTemplateLiteral: () => createTemplateLiteral,
  8584. createTransformContext: () => createTransformContext,
  8585. createVNodeCall: () => createVNodeCall,
  8586. extractIdentifiers: () => extractIdentifiers,
  8587. findDir: () => findDir,
  8588. findProp: () => findProp,
  8589. generate: () => generate,
  8590. generateCodeFrame: () => generateCodeFrame,
  8591. getBaseTransformPreset: () => getBaseTransformPreset,
  8592. getConstantType: () => getConstantType,
  8593. getInnerRange: () => getInnerRange,
  8594. getMemoedVNodeCall: () => getMemoedVNodeCall,
  8595. getVNodeBlockHelper: () => getVNodeBlockHelper,
  8596. getVNodeHelper: () => getVNodeHelper,
  8597. hasDynamicKeyVBind: () => hasDynamicKeyVBind,
  8598. hasScopeRef: () => hasScopeRef,
  8599. helperNameMap: () => helperNameMap,
  8600. injectProp: () => injectProp,
  8601. isBuiltInType: () => isBuiltInType,
  8602. isCoreComponent: () => isCoreComponent,
  8603. isFunctionType: () => isFunctionType,
  8604. isInDestructureAssignment: () => isInDestructureAssignment,
  8605. isMemberExpression: () => isMemberExpression,
  8606. isMemberExpressionBrowser: () => isMemberExpressionBrowser,
  8607. isMemberExpressionNode: () => isMemberExpressionNode,
  8608. isReferencedIdentifier: () => isReferencedIdentifier,
  8609. isSimpleIdentifier: () => isSimpleIdentifier,
  8610. isSlotOutlet: () => isSlotOutlet,
  8611. isStaticArgOf: () => isStaticArgOf,
  8612. isStaticExp: () => isStaticExp,
  8613. isStaticProperty: () => isStaticProperty,
  8614. isStaticPropertyKey: () => isStaticPropertyKey,
  8615. isTemplateNode: () => isTemplateNode,
  8616. isText: () => isText,
  8617. isVSlot: () => isVSlot,
  8618. locStub: () => locStub,
  8619. makeBlock: () => makeBlock,
  8620. noopDirectiveTransform: () => noopDirectiveTransform,
  8621. parse: () => parse,
  8622. parserOptions: () => parserOptions,
  8623. processExpression: () => processExpression,
  8624. processFor: () => processFor,
  8625. processIf: () => processIf,
  8626. processSlotOutlet: () => processSlotOutlet,
  8627. registerRuntimeHelpers: () => registerRuntimeHelpers,
  8628. resolveComponentType: () => resolveComponentType,
  8629. toValidAssetId: () => toValidAssetId,
  8630. trackSlotScopes: () => trackSlotScopes,
  8631. trackVForSlotScopes: () => trackVForSlotScopes,
  8632. transform: () => transform,
  8633. transformBind: () => transformBind,
  8634. transformElement: () => transformElement,
  8635. transformExpression: () => transformExpression,
  8636. transformModel: () => transformModel,
  8637. transformOn: () => transformOn,
  8638. transformStyle: () => transformStyle,
  8639. traverseNode: () => traverseNode,
  8640. walkBlockDeclarations: () => walkBlockDeclarations,
  8641. walkFunctionParams: () => walkFunctionParams,
  8642. walkIdentifiers: () => walkIdentifiers,
  8643. warnDeprecation: () => warnDeprecation
  8644. });
  8645. function decodeHtmlBrowser(raw, asAttr = false) {
  8646. if (!decoder) {
  8647. decoder = document.createElement("div");
  8648. }
  8649. if (asAttr) {
  8650. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  8651. return decoder.children[0].getAttribute("foo");
  8652. } else {
  8653. decoder.innerHTML = raw;
  8654. return decoder.textContent;
  8655. }
  8656. }
  8657. function createDOMCompilerError(code, loc) {
  8658. return createCompilerError(code, loc, true ? DOMErrorMessages : void 0);
  8659. }
  8660. function hasMultipleChildren(node) {
  8661. const children = node.children = node.children.filter((c) => c.type !== 3 && !(c.type === 2 && !c.content.trim()));
  8662. const child = children[0];
  8663. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  8664. }
  8665. function compile(template, options = {}) {
  8666. return baseCompile(template, extend({}, parserOptions, options, {
  8667. nodeTransforms: [
  8668. ignoreSideEffectTags,
  8669. ...DOMNodeTransforms,
  8670. ...options.nodeTransforms || []
  8671. ],
  8672. directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
  8673. transformHoist: null
  8674. }));
  8675. }
  8676. function parse(template, options = {}) {
  8677. return baseParse(template, extend({}, parserOptions, options));
  8678. }
  8679. var V_MODEL_RADIO, V_MODEL_CHECKBOX, V_MODEL_TEXT, V_MODEL_SELECT, V_MODEL_DYNAMIC, V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS, V_SHOW, TRANSITION, TRANSITION_GROUP, decoder, isRawTextContainer, parserOptions, transformStyle, parseInlineCSS, DOMErrorMessages, transformVHtml, transformVText, transformModel2, isEventOptionModifier, isNonKeyModifier, maybeKeyModifier, isKeyboardEvent, resolveModifiers, transformClick, transformOn2, transformShow, transformTransition, ignoreSideEffectTags, DOMNodeTransforms, DOMDirectiveTransforms;
  8680. var init_compiler_dom_esm_bundler = __esm({
  8681. "node_modules/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js"() {
  8682. init_define_APP_INFO();
  8683. init_compiler_core_esm_bundler();
  8684. init_compiler_core_esm_bundler();
  8685. init_shared_esm_bundler();
  8686. V_MODEL_RADIO = Symbol(true ? `vModelRadio` : ``);
  8687. V_MODEL_CHECKBOX = Symbol(true ? `vModelCheckbox` : ``);
  8688. V_MODEL_TEXT = Symbol(true ? `vModelText` : ``);
  8689. V_MODEL_SELECT = Symbol(true ? `vModelSelect` : ``);
  8690. V_MODEL_DYNAMIC = Symbol(true ? `vModelDynamic` : ``);
  8691. V_ON_WITH_MODIFIERS = Symbol(true ? `vOnModifiersGuard` : ``);
  8692. V_ON_WITH_KEYS = Symbol(true ? `vOnKeysGuard` : ``);
  8693. V_SHOW = Symbol(true ? `vShow` : ``);
  8694. TRANSITION = Symbol(true ? `Transition` : ``);
  8695. TRANSITION_GROUP = Symbol(true ? `TransitionGroup` : ``);
  8696. registerRuntimeHelpers({
  8697. [V_MODEL_RADIO]: `vModelRadio`,
  8698. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  8699. [V_MODEL_TEXT]: `vModelText`,
  8700. [V_MODEL_SELECT]: `vModelSelect`,
  8701. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  8702. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  8703. [V_ON_WITH_KEYS]: `withKeys`,
  8704. [V_SHOW]: `vShow`,
  8705. [TRANSITION]: `Transition`,
  8706. [TRANSITION_GROUP]: `TransitionGroup`
  8707. });
  8708. isRawTextContainer = makeMap("style,iframe,script,noscript", true);
  8709. parserOptions = {
  8710. isVoidTag,
  8711. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  8712. isPreTag: (tag) => tag === "pre",
  8713. decodeEntities: decodeHtmlBrowser,
  8714. isBuiltInComponent: (tag) => {
  8715. if (isBuiltInType(tag, `Transition`)) {
  8716. return TRANSITION;
  8717. } else if (isBuiltInType(tag, `TransitionGroup`)) {
  8718. return TRANSITION_GROUP;
  8719. }
  8720. },
  8721. getNamespace(tag, parent) {
  8722. let ns = parent ? parent.ns : 0;
  8723. if (parent && ns === 2) {
  8724. if (parent.tag === "annotation-xml") {
  8725. if (tag === "svg") {
  8726. return 1;
  8727. }
  8728. if (parent.props.some((a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml"))) {
  8729. ns = 0;
  8730. }
  8731. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  8732. ns = 0;
  8733. }
  8734. } else if (parent && ns === 1) {
  8735. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  8736. ns = 0;
  8737. }
  8738. }
  8739. if (ns === 0) {
  8740. if (tag === "svg") {
  8741. return 1;
  8742. }
  8743. if (tag === "math") {
  8744. return 2;
  8745. }
  8746. }
  8747. return ns;
  8748. },
  8749. getTextMode({ tag, ns }) {
  8750. if (ns === 0) {
  8751. if (tag === "textarea" || tag === "title") {
  8752. return 1;
  8753. }
  8754. if (isRawTextContainer(tag)) {
  8755. return 2;
  8756. }
  8757. }
  8758. return 0;
  8759. }
  8760. };
  8761. transformStyle = (node) => {
  8762. if (node.type === 1) {
  8763. node.props.forEach((p, i) => {
  8764. if (p.type === 6 && p.name === "style" && p.value) {
  8765. node.props[i] = {
  8766. type: 7,
  8767. name: `bind`,
  8768. arg: createSimpleExpression(`style`, true, p.loc),
  8769. exp: parseInlineCSS(p.value.content, p.loc),
  8770. modifiers: [],
  8771. loc: p.loc
  8772. };
  8773. }
  8774. });
  8775. }
  8776. };
  8777. parseInlineCSS = (cssText, loc) => {
  8778. const normalized = parseStringStyle(cssText);
  8779. return createSimpleExpression(JSON.stringify(normalized), false, loc, 3);
  8780. };
  8781. DOMErrorMessages = {
  8782. [50]: `v-html is missing expression.`,
  8783. [51]: `v-html will override element children.`,
  8784. [52]: `v-text is missing expression.`,
  8785. [53]: `v-text will override element children.`,
  8786. [54]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  8787. [55]: `v-model argument is not supported on plain elements.`,
  8788. [56]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  8789. [57]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  8790. [58]: `v-show is missing expression.`,
  8791. [59]: `<Transition> expects exactly one child element or component.`,
  8792. [60]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  8793. };
  8794. transformVHtml = (dir, node, context) => {
  8795. const { exp, loc } = dir;
  8796. if (!exp) {
  8797. context.onError(createDOMCompilerError(50, loc));
  8798. }
  8799. if (node.children.length) {
  8800. context.onError(createDOMCompilerError(51, loc));
  8801. node.children.length = 0;
  8802. }
  8803. return {
  8804. props: [
  8805. createObjectProperty(createSimpleExpression(`innerHTML`, true, loc), exp || createSimpleExpression("", true))
  8806. ]
  8807. };
  8808. };
  8809. transformVText = (dir, node, context) => {
  8810. const { exp, loc } = dir;
  8811. if (!exp) {
  8812. context.onError(createDOMCompilerError(52, loc));
  8813. }
  8814. if (node.children.length) {
  8815. context.onError(createDOMCompilerError(53, loc));
  8816. node.children.length = 0;
  8817. }
  8818. return {
  8819. props: [
  8820. createObjectProperty(createSimpleExpression(`textContent`, true), exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc) : createSimpleExpression("", true))
  8821. ]
  8822. };
  8823. };
  8824. transformModel2 = (dir, node, context) => {
  8825. const baseResult = transformModel(dir, node, context);
  8826. if (!baseResult.props.length || node.tagType === 1) {
  8827. return baseResult;
  8828. }
  8829. if (dir.arg) {
  8830. context.onError(createDOMCompilerError(55, dir.arg.loc));
  8831. }
  8832. function checkDuplicatedValue() {
  8833. const value = findProp(node, "value");
  8834. if (value) {
  8835. context.onError(createDOMCompilerError(57, value.loc));
  8836. }
  8837. }
  8838. const { tag } = node;
  8839. const isCustomElement = context.isCustomElement(tag);
  8840. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  8841. let directiveToUse = V_MODEL_TEXT;
  8842. let isInvalidType = false;
  8843. if (tag === "input" || isCustomElement) {
  8844. const type = findProp(node, `type`);
  8845. if (type) {
  8846. if (type.type === 7) {
  8847. directiveToUse = V_MODEL_DYNAMIC;
  8848. } else if (type.value) {
  8849. switch (type.value.content) {
  8850. case "radio":
  8851. directiveToUse = V_MODEL_RADIO;
  8852. break;
  8853. case "checkbox":
  8854. directiveToUse = V_MODEL_CHECKBOX;
  8855. break;
  8856. case "file":
  8857. isInvalidType = true;
  8858. context.onError(createDOMCompilerError(56, dir.loc));
  8859. break;
  8860. default:
  8861. checkDuplicatedValue();
  8862. break;
  8863. }
  8864. }
  8865. } else if (hasDynamicKeyVBind(node)) {
  8866. directiveToUse = V_MODEL_DYNAMIC;
  8867. } else {
  8868. checkDuplicatedValue();
  8869. }
  8870. } else if (tag === "select") {
  8871. directiveToUse = V_MODEL_SELECT;
  8872. } else {
  8873. checkDuplicatedValue();
  8874. }
  8875. if (!isInvalidType) {
  8876. baseResult.needRuntime = context.helper(directiveToUse);
  8877. }
  8878. } else {
  8879. context.onError(createDOMCompilerError(54, dir.loc));
  8880. }
  8881. baseResult.props = baseResult.props.filter((p) => !(p.key.type === 4 && p.key.content === "modelValue"));
  8882. return baseResult;
  8883. };
  8884. isEventOptionModifier = makeMap(`passive,once,capture`);
  8885. isNonKeyModifier = makeMap(
  8886. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  8887. );
  8888. maybeKeyModifier = makeMap("left,right");
  8889. isKeyboardEvent = makeMap(`onkeyup,onkeydown,onkeypress`, true);
  8890. resolveModifiers = (key, modifiers, context, loc) => {
  8891. const keyModifiers = [];
  8892. const nonKeyModifiers = [];
  8893. const eventOptionModifiers = [];
  8894. for (let i = 0; i < modifiers.length; i++) {
  8895. const modifier = modifiers[i];
  8896. if (modifier === "native" && checkCompatEnabled("COMPILER_V_ON_NATIVE", context, loc)) {
  8897. eventOptionModifiers.push(modifier);
  8898. } else if (isEventOptionModifier(modifier)) {
  8899. eventOptionModifiers.push(modifier);
  8900. } else {
  8901. if (maybeKeyModifier(modifier)) {
  8902. if (isStaticExp(key)) {
  8903. if (isKeyboardEvent(key.content)) {
  8904. keyModifiers.push(modifier);
  8905. } else {
  8906. nonKeyModifiers.push(modifier);
  8907. }
  8908. } else {
  8909. keyModifiers.push(modifier);
  8910. nonKeyModifiers.push(modifier);
  8911. }
  8912. } else {
  8913. if (isNonKeyModifier(modifier)) {
  8914. nonKeyModifiers.push(modifier);
  8915. } else {
  8916. keyModifiers.push(modifier);
  8917. }
  8918. }
  8919. }
  8920. }
  8921. return {
  8922. keyModifiers,
  8923. nonKeyModifiers,
  8924. eventOptionModifiers
  8925. };
  8926. };
  8927. transformClick = (key, event) => {
  8928. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  8929. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  8930. `(`,
  8931. key,
  8932. `) === "onClick" ? "${event}" : (`,
  8933. key,
  8934. `)`
  8935. ]) : key;
  8936. };
  8937. transformOn2 = (dir, node, context) => {
  8938. return transformOn(dir, node, context, (baseResult) => {
  8939. const { modifiers } = dir;
  8940. if (!modifiers.length)
  8941. return baseResult;
  8942. let { key, value: handlerExp } = baseResult.props[0];
  8943. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  8944. if (nonKeyModifiers.includes("right")) {
  8945. key = transformClick(key, `onContextmenu`);
  8946. }
  8947. if (nonKeyModifiers.includes("middle")) {
  8948. key = transformClick(key, `onMouseup`);
  8949. }
  8950. if (nonKeyModifiers.length) {
  8951. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  8952. handlerExp,
  8953. JSON.stringify(nonKeyModifiers)
  8954. ]);
  8955. }
  8956. if (keyModifiers.length && (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  8957. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  8958. handlerExp,
  8959. JSON.stringify(keyModifiers)
  8960. ]);
  8961. }
  8962. if (eventOptionModifiers.length) {
  8963. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  8964. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  8965. }
  8966. return {
  8967. props: [createObjectProperty(key, handlerExp)]
  8968. };
  8969. });
  8970. };
  8971. transformShow = (dir, node, context) => {
  8972. const { exp, loc } = dir;
  8973. if (!exp) {
  8974. context.onError(createDOMCompilerError(58, loc));
  8975. }
  8976. return {
  8977. props: [],
  8978. needRuntime: context.helper(V_SHOW)
  8979. };
  8980. };
  8981. transformTransition = (node, context) => {
  8982. if (node.type === 1 && node.tagType === 1) {
  8983. const component = context.isBuiltInComponent(node.tag);
  8984. if (component === TRANSITION) {
  8985. return () => {
  8986. if (!node.children.length) {
  8987. return;
  8988. }
  8989. if (hasMultipleChildren(node)) {
  8990. context.onError(createDOMCompilerError(59, {
  8991. start: node.children[0].loc.start,
  8992. end: node.children[node.children.length - 1].loc.end,
  8993. source: ""
  8994. }));
  8995. }
  8996. const child = node.children[0];
  8997. if (child.type === 1) {
  8998. for (const p of child.props) {
  8999. if (p.type === 7 && p.name === "show") {
  9000. node.props.push({
  9001. type: 6,
  9002. name: "persisted",
  9003. value: void 0,
  9004. loc: node.loc
  9005. });
  9006. }
  9007. }
  9008. }
  9009. };
  9010. }
  9011. }
  9012. };
  9013. ignoreSideEffectTags = (node, context) => {
  9014. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  9015. context.onError(createDOMCompilerError(60, node.loc));
  9016. context.removeNode();
  9017. }
  9018. };
  9019. DOMNodeTransforms = [
  9020. transformStyle,
  9021. ...true ? [transformTransition] : []
  9022. ];
  9023. DOMDirectiveTransforms = {
  9024. cloak: noopDirectiveTransform,
  9025. html: transformVHtml,
  9026. text: transformVText,
  9027. model: transformModel2,
  9028. on: transformOn2,
  9029. show: transformShow
  9030. };
  9031. }
  9032. });
  9033. // node_modules/vue/dist/vue.cjs.js
  9034. var require_vue_cjs = __commonJS({
  9035. "node_modules/vue/dist/vue.cjs.js"(exports) {
  9036. "use strict";
  9037. init_define_APP_INFO();
  9038. Object.defineProperty(exports, "__esModule", { value: true });
  9039. var compilerDom = (init_compiler_dom_esm_bundler(), __toCommonJS(compiler_dom_esm_bundler_exports));
  9040. var runtimeDom = (init_runtime_dom_esm_bundler(), __toCommonJS(runtime_dom_esm_bundler_exports));
  9041. var shared = (init_shared_esm_bundler(), __toCommonJS(shared_esm_bundler_exports));
  9042. function _interopNamespace(e) {
  9043. if (e && e.__esModule)
  9044. return e;
  9045. var n = /* @__PURE__ */ Object.create(null);
  9046. if (e) {
  9047. Object.keys(e).forEach(function(k) {
  9048. n[k] = e[k];
  9049. });
  9050. }
  9051. n["default"] = e;
  9052. return Object.freeze(n);
  9053. }
  9054. var runtimeDom__namespace = _interopNamespace(runtimeDom);
  9055. var compileCache = /* @__PURE__ */ Object.create(null);
  9056. function compileToFunction(template, options) {
  9057. if (!shared.isString(template)) {
  9058. if (template.nodeType) {
  9059. template = template.innerHTML;
  9060. } else {
  9061. runtimeDom.warn(`invalid template option: `, template);
  9062. return shared.NOOP;
  9063. }
  9064. }
  9065. const key = template;
  9066. const cached = compileCache[key];
  9067. if (cached) {
  9068. return cached;
  9069. }
  9070. if (template[0] === "#") {
  9071. const el = document.querySelector(template);
  9072. if (!el) {
  9073. runtimeDom.warn(`Template element not found or is empty: ${template}`);
  9074. }
  9075. template = el ? el.innerHTML : ``;
  9076. }
  9077. const { code } = compilerDom.compile(template, shared.extend({
  9078. hoistStatic: true,
  9079. onError,
  9080. onWarn: (e) => onError(e, true)
  9081. }, options));
  9082. function onError(err, asWarning = false) {
  9083. const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
  9084. const codeFrame = err.loc && shared.generateCodeFrame(template, err.loc.start.offset, err.loc.end.offset);
  9085. runtimeDom.warn(codeFrame ? `${message}
  9086. ${codeFrame}` : message);
  9087. }
  9088. const render = new Function("Vue", code)(runtimeDom__namespace);
  9089. render._rc = true;
  9090. return compileCache[key] = render;
  9091. }
  9092. runtimeDom.registerRuntimeCompiler(compileToFunction);
  9093. Object.keys(runtimeDom).forEach(function(k) {
  9094. if (k !== "default")
  9095. exports[k] = runtimeDom[k];
  9096. });
  9097. exports.compile = compileToFunction;
  9098. }
  9099. });
  9100. // node_modules/vue/index.js
  9101. var require_vue = __commonJS({
  9102. "node_modules/vue/index.js"(exports, module) {
  9103. "use strict";
  9104. init_define_APP_INFO();
  9105. if (false) {
  9106. module.exports = null;
  9107. } else {
  9108. module.exports = require_vue_cjs();
  9109. }
  9110. }
  9111. });
  9112. // node_modules/vue-i18n/dist/vue-i18n.cjs.js
  9113. var require_vue_i18n_cjs = __commonJS({
  9114. "node_modules/vue-i18n/dist/vue-i18n.cjs.js"(exports) {
  9115. "use strict";
  9116. init_define_APP_INFO();
  9117. Object.defineProperty(exports, "__esModule", { value: true });
  9118. var shared = require_shared();
  9119. var coreBase = require_core_base();
  9120. var vue = require_vue();
  9121. var VERSION = "9.2.0";
  9122. var code$1 = coreBase.CoreWarnCodes.__EXTEND_POINT__;
  9123. var inc$1 = () => ++code$1;
  9124. var I18nWarnCodes = {
  9125. FALLBACK_TO_ROOT: code$1,
  9126. NOT_SUPPORTED_PRESERVE: inc$1(),
  9127. NOT_SUPPORTED_FORMATTER: inc$1(),
  9128. NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(),
  9129. NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(),
  9130. COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(),
  9131. NOT_FOUND_PARENT_SCOPE: inc$1()
  9132. };
  9133. var warnMessages = {
  9134. [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`,
  9135. [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`,
  9136. [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`,
  9137. [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`,
  9138. [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`,
  9139. [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`,
  9140. [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`
  9141. };
  9142. function getWarnMessage(code2, ...args) {
  9143. return shared.format(warnMessages[code2], ...args);
  9144. }
  9145. var code = coreBase.CompileErrorCodes.__EXTEND_POINT__;
  9146. var inc = () => ++code;
  9147. var I18nErrorCodes = {
  9148. UNEXPECTED_RETURN_TYPE: code,
  9149. INVALID_ARGUMENT: inc(),
  9150. MUST_BE_CALL_SETUP_TOP: inc(),
  9151. NOT_INSLALLED: inc(),
  9152. NOT_AVAILABLE_IN_LEGACY_MODE: inc(),
  9153. REQUIRED_VALUE: inc(),
  9154. INVALID_VALUE: inc(),
  9155. CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(),
  9156. NOT_INSLALLED_WITH_PROVIDE: inc(),
  9157. UNEXPECTED_ERROR: inc(),
  9158. NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(),
  9159. BRIDGE_SUPPORT_VUE_2_ONLY: inc(),
  9160. MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(),
  9161. NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(),
  9162. __EXTEND_POINT__: inc()
  9163. };
  9164. function createI18nError(code2, ...args) {
  9165. return coreBase.createCompileError(code2, null, { messages: errorMessages2, args });
  9166. }
  9167. var errorMessages2 = {
  9168. [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: "Unexpected return type in composer",
  9169. [I18nErrorCodes.INVALID_ARGUMENT]: "Invalid argument",
  9170. [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: "Must be called at the top of a `setup` function",
  9171. [I18nErrorCodes.NOT_INSLALLED]: "Need to install with `app.use` function",
  9172. [I18nErrorCodes.UNEXPECTED_ERROR]: "Unexpected error",
  9173. [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: "Not available in legacy mode",
  9174. [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`,
  9175. [I18nErrorCodes.INVALID_VALUE]: `Invalid value`,
  9176. [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`,
  9177. [I18nErrorCodes.NOT_INSLALLED_WITH_PROVIDE]: "Need to install with `provide` function",
  9178. [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: "Not compatible legacy VueI18n.",
  9179. [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: "vue-i18n-bridge support Vue 2.x only",
  9180. [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: "Must define \u2018i18n\u2019 option or custom block in Composition API with using local scope in Legacy API mode",
  9181. [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: "Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly"
  9182. };
  9183. var TransrateVNodeSymbol = shared.makeSymbol("__transrateVNode");
  9184. var DatetimePartsSymbol = shared.makeSymbol("__datetimeParts");
  9185. var NumberPartsSymbol = shared.makeSymbol("__numberParts");
  9186. var EnableEmitter = shared.makeSymbol("__enableEmitter");
  9187. var DisableEmitter = shared.makeSymbol("__disableEmitter");
  9188. var SetPluralRulesSymbol = shared.makeSymbol("__setPluralRules");
  9189. shared.makeSymbol("__intlifyMeta");
  9190. var InejctWithOption = shared.makeSymbol("__injectWithOption");
  9191. var __VUE_I18N_BRIDGE__ = "__VUE_I18N_BRIDGE__";
  9192. function handleFlatJson(obj) {
  9193. if (!shared.isObject(obj)) {
  9194. return obj;
  9195. }
  9196. for (const key in obj) {
  9197. if (!shared.hasOwn(obj, key)) {
  9198. continue;
  9199. }
  9200. if (!key.includes(".")) {
  9201. if (shared.isObject(obj[key])) {
  9202. handleFlatJson(obj[key]);
  9203. }
  9204. } else {
  9205. const subKeys = key.split(".");
  9206. const lastIndex = subKeys.length - 1;
  9207. let currentObj = obj;
  9208. for (let i = 0; i < lastIndex; i++) {
  9209. if (!(subKeys[i] in currentObj)) {
  9210. currentObj[subKeys[i]] = {};
  9211. }
  9212. currentObj = currentObj[subKeys[i]];
  9213. }
  9214. currentObj[subKeys[lastIndex]] = obj[key];
  9215. delete obj[key];
  9216. if (shared.isObject(currentObj[subKeys[lastIndex]])) {
  9217. handleFlatJson(currentObj[subKeys[lastIndex]]);
  9218. }
  9219. }
  9220. }
  9221. return obj;
  9222. }
  9223. function getLocaleMessages(locale, options) {
  9224. const { messages, __i18n, messageResolver, flatJson } = options;
  9225. const ret = shared.isPlainObject(messages) ? messages : shared.isArray(__i18n) ? {} : { [locale]: {} };
  9226. if (shared.isArray(__i18n)) {
  9227. __i18n.forEach((custom) => {
  9228. if ("locale" in custom && "resource" in custom) {
  9229. const { locale: locale2, resource } = custom;
  9230. if (locale2) {
  9231. ret[locale2] = ret[locale2] || {};
  9232. deepCopy(resource, ret[locale2]);
  9233. } else {
  9234. deepCopy(resource, ret);
  9235. }
  9236. } else {
  9237. shared.isString(custom) && deepCopy(JSON.parse(custom), ret);
  9238. }
  9239. });
  9240. }
  9241. if (messageResolver == null && flatJson) {
  9242. for (const key in ret) {
  9243. if (shared.hasOwn(ret, key)) {
  9244. handleFlatJson(ret[key]);
  9245. }
  9246. }
  9247. }
  9248. return ret;
  9249. }
  9250. var isNotObjectOrIsArray = (val) => !shared.isObject(val) || shared.isArray(val);
  9251. function deepCopy(src, des) {
  9252. if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) {
  9253. throw createI18nError(I18nErrorCodes.INVALID_VALUE);
  9254. }
  9255. for (const key in src) {
  9256. if (shared.hasOwn(src, key)) {
  9257. if (isNotObjectOrIsArray(src[key]) || isNotObjectOrIsArray(des[key])) {
  9258. des[key] = src[key];
  9259. } else {
  9260. deepCopy(src[key], des[key]);
  9261. }
  9262. }
  9263. }
  9264. }
  9265. function getComponentOptions(instance) {
  9266. return instance.type;
  9267. }
  9268. function adjustI18nResources(global2, options, componentOptions) {
  9269. let messages = shared.isObject(options.messages) ? options.messages : {};
  9270. if ("__i18nGlobal" in componentOptions) {
  9271. messages = getLocaleMessages(global2.locale.value, {
  9272. messages,
  9273. __i18n: componentOptions.__i18nGlobal
  9274. });
  9275. }
  9276. const locales = Object.keys(messages);
  9277. if (locales.length) {
  9278. locales.forEach((locale) => {
  9279. global2.mergeLocaleMessage(locale, messages[locale]);
  9280. });
  9281. }
  9282. {
  9283. if (shared.isObject(options.datetimeFormats)) {
  9284. const locales2 = Object.keys(options.datetimeFormats);
  9285. if (locales2.length) {
  9286. locales2.forEach((locale) => {
  9287. global2.mergeDateTimeFormat(locale, options.datetimeFormats[locale]);
  9288. });
  9289. }
  9290. }
  9291. if (shared.isObject(options.numberFormats)) {
  9292. const locales2 = Object.keys(options.numberFormats);
  9293. if (locales2.length) {
  9294. locales2.forEach((locale) => {
  9295. global2.mergeNumberFormat(locale, options.numberFormats[locale]);
  9296. });
  9297. }
  9298. }
  9299. }
  9300. }
  9301. function createTextNode(key) {
  9302. return vue.createVNode(vue.Text, null, key, 0);
  9303. }
  9304. var DEVTOOLS_META = "__INTLIFY_META__";
  9305. var composerID = 0;
  9306. function defineCoreMissingHandler(missing) {
  9307. return (ctx, locale, key, type) => {
  9308. return missing(locale, key, vue.getCurrentInstance() || void 0, type);
  9309. };
  9310. }
  9311. var getMetaInfo = () => {
  9312. const instance = vue.getCurrentInstance();
  9313. let meta = null;
  9314. return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) ? { [DEVTOOLS_META]: meta } : null;
  9315. };
  9316. function createComposer(options = {}, VueI18nLegacy) {
  9317. const { __root } = options;
  9318. const _isGlobal = __root === void 0;
  9319. let _inheritLocale = shared.isBoolean(options.inheritLocale) ? options.inheritLocale : true;
  9320. const _locale = vue.ref(
  9321. __root && _inheritLocale ? __root.locale.value : shared.isString(options.locale) ? options.locale : coreBase.DEFAULT_LOCALE
  9322. );
  9323. const _fallbackLocale = vue.ref(
  9324. __root && _inheritLocale ? __root.fallbackLocale.value : shared.isString(options.fallbackLocale) || shared.isArray(options.fallbackLocale) || shared.isPlainObject(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : _locale.value
  9325. );
  9326. const _messages = vue.ref(getLocaleMessages(_locale.value, options));
  9327. const _datetimeFormats = vue.ref(shared.isPlainObject(options.datetimeFormats) ? options.datetimeFormats : { [_locale.value]: {} });
  9328. const _numberFormats = vue.ref(shared.isPlainObject(options.numberFormats) ? options.numberFormats : { [_locale.value]: {} });
  9329. let _missingWarn = __root ? __root.missingWarn : shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) ? options.missingWarn : true;
  9330. let _fallbackWarn = __root ? __root.fallbackWarn : shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) ? options.fallbackWarn : true;
  9331. let _fallbackRoot = __root ? __root.fallbackRoot : shared.isBoolean(options.fallbackRoot) ? options.fallbackRoot : true;
  9332. let _fallbackFormat = !!options.fallbackFormat;
  9333. let _missing = shared.isFunction(options.missing) ? options.missing : null;
  9334. let _runtimeMissing = shared.isFunction(options.missing) ? defineCoreMissingHandler(options.missing) : null;
  9335. let _postTranslation = shared.isFunction(options.postTranslation) ? options.postTranslation : null;
  9336. let _warnHtmlMessage = __root ? __root.warnHtmlMessage : shared.isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true;
  9337. let _escapeParameter = !!options.escapeParameter;
  9338. const _modifiers = __root ? __root.modifiers : shared.isPlainObject(options.modifiers) ? options.modifiers : {};
  9339. let _pluralRules = options.pluralRules || __root && __root.pluralRules;
  9340. let _context;
  9341. function getCoreContext() {
  9342. _isGlobal && coreBase.setFallbackContext(null);
  9343. const ctxOptions = {
  9344. version: VERSION,
  9345. locale: _locale.value,
  9346. fallbackLocale: _fallbackLocale.value,
  9347. messages: _messages.value,
  9348. modifiers: _modifiers,
  9349. pluralRules: _pluralRules,
  9350. missing: _runtimeMissing === null ? void 0 : _runtimeMissing,
  9351. missingWarn: _missingWarn,
  9352. fallbackWarn: _fallbackWarn,
  9353. fallbackFormat: _fallbackFormat,
  9354. unresolving: true,
  9355. postTranslation: _postTranslation === null ? void 0 : _postTranslation,
  9356. warnHtmlMessage: _warnHtmlMessage,
  9357. escapeParameter: _escapeParameter,
  9358. messageResolver: options.messageResolver,
  9359. __meta: { framework: "vue" }
  9360. };
  9361. {
  9362. ctxOptions.datetimeFormats = _datetimeFormats.value;
  9363. ctxOptions.numberFormats = _numberFormats.value;
  9364. ctxOptions.__datetimeFormatters = shared.isPlainObject(_context) ? _context.__datetimeFormatters : void 0;
  9365. ctxOptions.__numberFormatters = shared.isPlainObject(_context) ? _context.__numberFormatters : void 0;
  9366. }
  9367. {
  9368. ctxOptions.__v_emitter = shared.isPlainObject(_context) ? _context.__v_emitter : void 0;
  9369. }
  9370. const ctx = coreBase.createCoreContext(ctxOptions);
  9371. _isGlobal && coreBase.setFallbackContext(ctx);
  9372. return ctx;
  9373. }
  9374. _context = getCoreContext();
  9375. coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
  9376. function trackReactivityValues() {
  9377. return [
  9378. _locale.value,
  9379. _fallbackLocale.value,
  9380. _messages.value,
  9381. _datetimeFormats.value,
  9382. _numberFormats.value
  9383. ];
  9384. }
  9385. const locale = vue.computed({
  9386. get: () => _locale.value,
  9387. set: (val) => {
  9388. _locale.value = val;
  9389. _context.locale = _locale.value;
  9390. }
  9391. });
  9392. const fallbackLocale = vue.computed({
  9393. get: () => _fallbackLocale.value,
  9394. set: (val) => {
  9395. _fallbackLocale.value = val;
  9396. _context.fallbackLocale = _fallbackLocale.value;
  9397. coreBase.updateFallbackLocale(_context, _locale.value, val);
  9398. }
  9399. });
  9400. const messages = vue.computed(() => _messages.value);
  9401. const datetimeFormats = vue.computed(() => _datetimeFormats.value);
  9402. const numberFormats = vue.computed(() => _numberFormats.value);
  9403. function getPostTranslationHandler() {
  9404. return shared.isFunction(_postTranslation) ? _postTranslation : null;
  9405. }
  9406. function setPostTranslationHandler(handler) {
  9407. _postTranslation = handler;
  9408. _context.postTranslation = handler;
  9409. }
  9410. function getMissingHandler() {
  9411. return _missing;
  9412. }
  9413. function setMissingHandler(handler) {
  9414. if (handler !== null) {
  9415. _runtimeMissing = defineCoreMissingHandler(handler);
  9416. }
  9417. _missing = handler;
  9418. _context.missing = _runtimeMissing;
  9419. }
  9420. function isResolvedTranslateMessage(type, arg) {
  9421. return type !== "translate" || !arg.resolvedMessage;
  9422. }
  9423. function wrapWithDeps(fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) {
  9424. trackReactivityValues();
  9425. let ret;
  9426. {
  9427. try {
  9428. coreBase.setAdditionalMeta(getMetaInfo());
  9429. if (!_isGlobal) {
  9430. _context.fallbackContext = __root ? coreBase.getFallbackContext() : void 0;
  9431. }
  9432. ret = fn(_context);
  9433. } finally {
  9434. coreBase.setAdditionalMeta(null);
  9435. if (!_isGlobal) {
  9436. _context.fallbackContext = void 0;
  9437. }
  9438. }
  9439. }
  9440. if (shared.isNumber(ret) && ret === coreBase.NOT_REOSLVED) {
  9441. const [key, arg2] = argumentParser();
  9442. if (__root && shared.isString(key) && isResolvedTranslateMessage(warnType, arg2)) {
  9443. if (_fallbackRoot && (coreBase.isTranslateFallbackWarn(_fallbackWarn, key) || coreBase.isTranslateMissingWarn(_missingWarn, key))) {
  9444. shared.warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, {
  9445. key,
  9446. type: warnType
  9447. }));
  9448. }
  9449. {
  9450. const { __v_emitter: emitter } = _context;
  9451. if (emitter && _fallbackRoot) {
  9452. emitter.emit("fallback", {
  9453. type: warnType,
  9454. key,
  9455. to: "global",
  9456. groupId: `${warnType}:${key}`
  9457. });
  9458. }
  9459. }
  9460. }
  9461. return __root && _fallbackRoot ? fallbackSuccess(__root) : fallbackFail(key);
  9462. } else if (successCondition(ret)) {
  9463. return ret;
  9464. } else {
  9465. throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE);
  9466. }
  9467. }
  9468. function t(...args) {
  9469. return wrapWithDeps((context) => Reflect.apply(coreBase.translate, null, [context, ...args]), () => coreBase.parseTranslateArgs(...args), "translate", (root) => Reflect.apply(root.t, root, [...args]), (key) => key, (val) => shared.isString(val));
  9470. }
  9471. function rt(...args) {
  9472. const [arg1, arg2, arg3] = args;
  9473. if (arg3 && !shared.isObject(arg3)) {
  9474. throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT);
  9475. }
  9476. return t(...[arg1, arg2, shared.assign({ resolvedMessage: true }, arg3 || {})]);
  9477. }
  9478. function d(...args) {
  9479. return wrapWithDeps((context) => Reflect.apply(coreBase.datetime, null, [context, ...args]), () => coreBase.parseDateTimeArgs(...args), "datetime format", (root) => Reflect.apply(root.d, root, [...args]), () => coreBase.MISSING_RESOLVE_VALUE, (val) => shared.isString(val));
  9480. }
  9481. function n(...args) {
  9482. return wrapWithDeps((context) => Reflect.apply(coreBase.number, null, [context, ...args]), () => coreBase.parseNumberArgs(...args), "number format", (root) => Reflect.apply(root.n, root, [...args]), () => coreBase.MISSING_RESOLVE_VALUE, (val) => shared.isString(val));
  9483. }
  9484. function normalize(values) {
  9485. return values.map((val) => shared.isString(val) || shared.isNumber(val) || shared.isBoolean(val) ? createTextNode(String(val)) : val);
  9486. }
  9487. const interpolate = (val) => val;
  9488. const processor = {
  9489. normalize,
  9490. interpolate,
  9491. type: "vnode"
  9492. };
  9493. function transrateVNode(...args) {
  9494. return wrapWithDeps(
  9495. (context) => {
  9496. let ret;
  9497. const _context2 = context;
  9498. try {
  9499. _context2.processor = processor;
  9500. ret = Reflect.apply(coreBase.translate, null, [_context2, ...args]);
  9501. } finally {
  9502. _context2.processor = null;
  9503. }
  9504. return ret;
  9505. },
  9506. () => coreBase.parseTranslateArgs(...args),
  9507. "translate",
  9508. (root) => root[TransrateVNodeSymbol](...args),
  9509. (key) => [createTextNode(key)],
  9510. (val) => shared.isArray(val)
  9511. );
  9512. }
  9513. function numberParts(...args) {
  9514. return wrapWithDeps(
  9515. (context) => Reflect.apply(coreBase.number, null, [context, ...args]),
  9516. () => coreBase.parseNumberArgs(...args),
  9517. "number format",
  9518. (root) => root[NumberPartsSymbol](...args),
  9519. () => [],
  9520. (val) => shared.isString(val) || shared.isArray(val)
  9521. );
  9522. }
  9523. function datetimeParts(...args) {
  9524. return wrapWithDeps(
  9525. (context) => Reflect.apply(coreBase.datetime, null, [context, ...args]),
  9526. () => coreBase.parseDateTimeArgs(...args),
  9527. "datetime format",
  9528. (root) => root[DatetimePartsSymbol](...args),
  9529. () => [],
  9530. (val) => shared.isString(val) || shared.isArray(val)
  9531. );
  9532. }
  9533. function setPluralRules(rules) {
  9534. _pluralRules = rules;
  9535. _context.pluralRules = _pluralRules;
  9536. }
  9537. function te(key, locale2) {
  9538. const targetLocale = shared.isString(locale2) ? locale2 : _locale.value;
  9539. const message = getLocaleMessage(targetLocale);
  9540. return _context.messageResolver(message, key) !== null;
  9541. }
  9542. function resolveMessages(key) {
  9543. let messages2 = null;
  9544. const locales = coreBase.fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value);
  9545. for (let i = 0; i < locales.length; i++) {
  9546. const targetLocaleMessages = _messages.value[locales[i]] || {};
  9547. const messageValue = _context.messageResolver(targetLocaleMessages, key);
  9548. if (messageValue != null) {
  9549. messages2 = messageValue;
  9550. break;
  9551. }
  9552. }
  9553. return messages2;
  9554. }
  9555. function tm(key) {
  9556. const messages2 = resolveMessages(key);
  9557. return messages2 != null ? messages2 : __root ? __root.tm(key) || {} : {};
  9558. }
  9559. function getLocaleMessage(locale2) {
  9560. return _messages.value[locale2] || {};
  9561. }
  9562. function setLocaleMessage(locale2, message) {
  9563. _messages.value[locale2] = message;
  9564. _context.messages = _messages.value;
  9565. }
  9566. function mergeLocaleMessage(locale2, message) {
  9567. _messages.value[locale2] = _messages.value[locale2] || {};
  9568. deepCopy(message, _messages.value[locale2]);
  9569. _context.messages = _messages.value;
  9570. }
  9571. function getDateTimeFormat(locale2) {
  9572. return _datetimeFormats.value[locale2] || {};
  9573. }
  9574. function setDateTimeFormat(locale2, format) {
  9575. _datetimeFormats.value[locale2] = format;
  9576. _context.datetimeFormats = _datetimeFormats.value;
  9577. coreBase.clearDateTimeFormat(_context, locale2, format);
  9578. }
  9579. function mergeDateTimeFormat(locale2, format) {
  9580. _datetimeFormats.value[locale2] = shared.assign(_datetimeFormats.value[locale2] || {}, format);
  9581. _context.datetimeFormats = _datetimeFormats.value;
  9582. coreBase.clearDateTimeFormat(_context, locale2, format);
  9583. }
  9584. function getNumberFormat(locale2) {
  9585. return _numberFormats.value[locale2] || {};
  9586. }
  9587. function setNumberFormat(locale2, format) {
  9588. _numberFormats.value[locale2] = format;
  9589. _context.numberFormats = _numberFormats.value;
  9590. coreBase.clearNumberFormat(_context, locale2, format);
  9591. }
  9592. function mergeNumberFormat(locale2, format) {
  9593. _numberFormats.value[locale2] = shared.assign(_numberFormats.value[locale2] || {}, format);
  9594. _context.numberFormats = _numberFormats.value;
  9595. coreBase.clearNumberFormat(_context, locale2, format);
  9596. }
  9597. composerID++;
  9598. if (__root && shared.inBrowser) {
  9599. vue.watch(__root.locale, (val) => {
  9600. if (_inheritLocale) {
  9601. _locale.value = val;
  9602. _context.locale = val;
  9603. coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
  9604. }
  9605. });
  9606. vue.watch(__root.fallbackLocale, (val) => {
  9607. if (_inheritLocale) {
  9608. _fallbackLocale.value = val;
  9609. _context.fallbackLocale = val;
  9610. coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
  9611. }
  9612. });
  9613. }
  9614. const composer = {
  9615. id: composerID,
  9616. locale,
  9617. fallbackLocale,
  9618. get inheritLocale() {
  9619. return _inheritLocale;
  9620. },
  9621. set inheritLocale(val) {
  9622. _inheritLocale = val;
  9623. if (val && __root) {
  9624. _locale.value = __root.locale.value;
  9625. _fallbackLocale.value = __root.fallbackLocale.value;
  9626. coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
  9627. }
  9628. },
  9629. get availableLocales() {
  9630. return Object.keys(_messages.value).sort();
  9631. },
  9632. messages,
  9633. get modifiers() {
  9634. return _modifiers;
  9635. },
  9636. get pluralRules() {
  9637. return _pluralRules || {};
  9638. },
  9639. get isGlobal() {
  9640. return _isGlobal;
  9641. },
  9642. get missingWarn() {
  9643. return _missingWarn;
  9644. },
  9645. set missingWarn(val) {
  9646. _missingWarn = val;
  9647. _context.missingWarn = _missingWarn;
  9648. },
  9649. get fallbackWarn() {
  9650. return _fallbackWarn;
  9651. },
  9652. set fallbackWarn(val) {
  9653. _fallbackWarn = val;
  9654. _context.fallbackWarn = _fallbackWarn;
  9655. },
  9656. get fallbackRoot() {
  9657. return _fallbackRoot;
  9658. },
  9659. set fallbackRoot(val) {
  9660. _fallbackRoot = val;
  9661. },
  9662. get fallbackFormat() {
  9663. return _fallbackFormat;
  9664. },
  9665. set fallbackFormat(val) {
  9666. _fallbackFormat = val;
  9667. _context.fallbackFormat = _fallbackFormat;
  9668. },
  9669. get warnHtmlMessage() {
  9670. return _warnHtmlMessage;
  9671. },
  9672. set warnHtmlMessage(val) {
  9673. _warnHtmlMessage = val;
  9674. _context.warnHtmlMessage = val;
  9675. },
  9676. get escapeParameter() {
  9677. return _escapeParameter;
  9678. },
  9679. set escapeParameter(val) {
  9680. _escapeParameter = val;
  9681. _context.escapeParameter = val;
  9682. },
  9683. t,
  9684. getLocaleMessage,
  9685. setLocaleMessage,
  9686. mergeLocaleMessage,
  9687. getPostTranslationHandler,
  9688. setPostTranslationHandler,
  9689. getMissingHandler,
  9690. setMissingHandler,
  9691. [SetPluralRulesSymbol]: setPluralRules
  9692. };
  9693. {
  9694. composer.datetimeFormats = datetimeFormats;
  9695. composer.numberFormats = numberFormats;
  9696. composer.rt = rt;
  9697. composer.te = te;
  9698. composer.tm = tm;
  9699. composer.d = d;
  9700. composer.n = n;
  9701. composer.getDateTimeFormat = getDateTimeFormat;
  9702. composer.setDateTimeFormat = setDateTimeFormat;
  9703. composer.mergeDateTimeFormat = mergeDateTimeFormat;
  9704. composer.getNumberFormat = getNumberFormat;
  9705. composer.setNumberFormat = setNumberFormat;
  9706. composer.mergeNumberFormat = mergeNumberFormat;
  9707. composer[InejctWithOption] = options.__injectWithOption;
  9708. composer[TransrateVNodeSymbol] = transrateVNode;
  9709. composer[DatetimePartsSymbol] = datetimeParts;
  9710. composer[NumberPartsSymbol] = numberParts;
  9711. }
  9712. {
  9713. composer[EnableEmitter] = (emitter) => {
  9714. _context.__v_emitter = emitter;
  9715. };
  9716. composer[DisableEmitter] = () => {
  9717. _context.__v_emitter = void 0;
  9718. };
  9719. }
  9720. return composer;
  9721. }
  9722. function convertComposerOptions(options) {
  9723. const locale = shared.isString(options.locale) ? options.locale : coreBase.DEFAULT_LOCALE;
  9724. const fallbackLocale = shared.isString(options.fallbackLocale) || shared.isArray(options.fallbackLocale) || shared.isPlainObject(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : locale;
  9725. const missing = shared.isFunction(options.missing) ? options.missing : void 0;
  9726. const missingWarn = shared.isBoolean(options.silentTranslationWarn) || shared.isRegExp(options.silentTranslationWarn) ? !options.silentTranslationWarn : true;
  9727. const fallbackWarn = shared.isBoolean(options.silentFallbackWarn) || shared.isRegExp(options.silentFallbackWarn) ? !options.silentFallbackWarn : true;
  9728. const fallbackRoot = shared.isBoolean(options.fallbackRoot) ? options.fallbackRoot : true;
  9729. const fallbackFormat = !!options.formatFallbackMessages;
  9730. const modifiers = shared.isPlainObject(options.modifiers) ? options.modifiers : {};
  9731. const pluralizationRules = options.pluralizationRules;
  9732. const postTranslation = shared.isFunction(options.postTranslation) ? options.postTranslation : void 0;
  9733. const warnHtmlMessage = shared.isString(options.warnHtmlInMessage) ? options.warnHtmlInMessage !== "off" : true;
  9734. const escapeParameter = !!options.escapeParameterHtml;
  9735. const inheritLocale = shared.isBoolean(options.sync) ? options.sync : true;
  9736. if (options.formatter) {
  9737. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER));
  9738. }
  9739. if (options.preserveDirectiveContent) {
  9740. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE));
  9741. }
  9742. let messages = options.messages;
  9743. if (shared.isPlainObject(options.sharedMessages)) {
  9744. const sharedMessages = options.sharedMessages;
  9745. const locales = Object.keys(sharedMessages);
  9746. messages = locales.reduce((messages2, locale2) => {
  9747. const message = messages2[locale2] || (messages2[locale2] = {});
  9748. shared.assign(message, sharedMessages[locale2]);
  9749. return messages2;
  9750. }, messages || {});
  9751. }
  9752. const { __i18n, __root, __injectWithOption } = options;
  9753. const datetimeFormats = options.datetimeFormats;
  9754. const numberFormats = options.numberFormats;
  9755. const flatJson = options.flatJson;
  9756. return {
  9757. locale,
  9758. fallbackLocale,
  9759. messages,
  9760. flatJson,
  9761. datetimeFormats,
  9762. numberFormats,
  9763. missing,
  9764. missingWarn,
  9765. fallbackWarn,
  9766. fallbackRoot,
  9767. fallbackFormat,
  9768. modifiers,
  9769. pluralRules: pluralizationRules,
  9770. postTranslation,
  9771. warnHtmlMessage,
  9772. escapeParameter,
  9773. messageResolver: options.messageResolver,
  9774. inheritLocale,
  9775. __i18n,
  9776. __root,
  9777. __injectWithOption
  9778. };
  9779. }
  9780. function createVueI18n(options = {}, VueI18nLegacy) {
  9781. {
  9782. const composer = createComposer(convertComposerOptions(options));
  9783. const vueI18n = {
  9784. id: composer.id,
  9785. get locale() {
  9786. return composer.locale.value;
  9787. },
  9788. set locale(val) {
  9789. composer.locale.value = val;
  9790. },
  9791. get fallbackLocale() {
  9792. return composer.fallbackLocale.value;
  9793. },
  9794. set fallbackLocale(val) {
  9795. composer.fallbackLocale.value = val;
  9796. },
  9797. get messages() {
  9798. return composer.messages.value;
  9799. },
  9800. get datetimeFormats() {
  9801. return composer.datetimeFormats.value;
  9802. },
  9803. get numberFormats() {
  9804. return composer.numberFormats.value;
  9805. },
  9806. get availableLocales() {
  9807. return composer.availableLocales;
  9808. },
  9809. get formatter() {
  9810. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER));
  9811. return {
  9812. interpolate() {
  9813. return [];
  9814. }
  9815. };
  9816. },
  9817. set formatter(val) {
  9818. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER));
  9819. },
  9820. get missing() {
  9821. return composer.getMissingHandler();
  9822. },
  9823. set missing(handler) {
  9824. composer.setMissingHandler(handler);
  9825. },
  9826. get silentTranslationWarn() {
  9827. return shared.isBoolean(composer.missingWarn) ? !composer.missingWarn : composer.missingWarn;
  9828. },
  9829. set silentTranslationWarn(val) {
  9830. composer.missingWarn = shared.isBoolean(val) ? !val : val;
  9831. },
  9832. get silentFallbackWarn() {
  9833. return shared.isBoolean(composer.fallbackWarn) ? !composer.fallbackWarn : composer.fallbackWarn;
  9834. },
  9835. set silentFallbackWarn(val) {
  9836. composer.fallbackWarn = shared.isBoolean(val) ? !val : val;
  9837. },
  9838. get modifiers() {
  9839. return composer.modifiers;
  9840. },
  9841. get formatFallbackMessages() {
  9842. return composer.fallbackFormat;
  9843. },
  9844. set formatFallbackMessages(val) {
  9845. composer.fallbackFormat = val;
  9846. },
  9847. get postTranslation() {
  9848. return composer.getPostTranslationHandler();
  9849. },
  9850. set postTranslation(handler) {
  9851. composer.setPostTranslationHandler(handler);
  9852. },
  9853. get sync() {
  9854. return composer.inheritLocale;
  9855. },
  9856. set sync(val) {
  9857. composer.inheritLocale = val;
  9858. },
  9859. get warnHtmlInMessage() {
  9860. return composer.warnHtmlMessage ? "warn" : "off";
  9861. },
  9862. set warnHtmlInMessage(val) {
  9863. composer.warnHtmlMessage = val !== "off";
  9864. },
  9865. get escapeParameterHtml() {
  9866. return composer.escapeParameter;
  9867. },
  9868. set escapeParameterHtml(val) {
  9869. composer.escapeParameter = val;
  9870. },
  9871. get preserveDirectiveContent() {
  9872. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE));
  9873. return true;
  9874. },
  9875. set preserveDirectiveContent(val) {
  9876. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE));
  9877. },
  9878. get pluralizationRules() {
  9879. return composer.pluralRules || {};
  9880. },
  9881. __composer: composer,
  9882. t(...args) {
  9883. const [arg1, arg2, arg3] = args;
  9884. const options2 = {};
  9885. let list = null;
  9886. let named = null;
  9887. if (!shared.isString(arg1)) {
  9888. throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT);
  9889. }
  9890. const key = arg1;
  9891. if (shared.isString(arg2)) {
  9892. options2.locale = arg2;
  9893. } else if (shared.isArray(arg2)) {
  9894. list = arg2;
  9895. } else if (shared.isPlainObject(arg2)) {
  9896. named = arg2;
  9897. }
  9898. if (shared.isArray(arg3)) {
  9899. list = arg3;
  9900. } else if (shared.isPlainObject(arg3)) {
  9901. named = arg3;
  9902. }
  9903. return Reflect.apply(composer.t, composer, [
  9904. key,
  9905. list || named || {},
  9906. options2
  9907. ]);
  9908. },
  9909. rt(...args) {
  9910. return Reflect.apply(composer.rt, composer, [...args]);
  9911. },
  9912. tc(...args) {
  9913. const [arg1, arg2, arg3] = args;
  9914. const options2 = { plural: 1 };
  9915. let list = null;
  9916. let named = null;
  9917. if (!shared.isString(arg1)) {
  9918. throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT);
  9919. }
  9920. const key = arg1;
  9921. if (shared.isString(arg2)) {
  9922. options2.locale = arg2;
  9923. } else if (shared.isNumber(arg2)) {
  9924. options2.plural = arg2;
  9925. } else if (shared.isArray(arg2)) {
  9926. list = arg2;
  9927. } else if (shared.isPlainObject(arg2)) {
  9928. named = arg2;
  9929. }
  9930. if (shared.isString(arg3)) {
  9931. options2.locale = arg3;
  9932. } else if (shared.isArray(arg3)) {
  9933. list = arg3;
  9934. } else if (shared.isPlainObject(arg3)) {
  9935. named = arg3;
  9936. }
  9937. return Reflect.apply(composer.t, composer, [
  9938. key,
  9939. list || named || {},
  9940. options2
  9941. ]);
  9942. },
  9943. te(key, locale) {
  9944. return composer.te(key, locale);
  9945. },
  9946. tm(key) {
  9947. return composer.tm(key);
  9948. },
  9949. getLocaleMessage(locale) {
  9950. return composer.getLocaleMessage(locale);
  9951. },
  9952. setLocaleMessage(locale, message) {
  9953. composer.setLocaleMessage(locale, message);
  9954. },
  9955. mergeLocaleMessage(locale, message) {
  9956. composer.mergeLocaleMessage(locale, message);
  9957. },
  9958. d(...args) {
  9959. return Reflect.apply(composer.d, composer, [...args]);
  9960. },
  9961. getDateTimeFormat(locale) {
  9962. return composer.getDateTimeFormat(locale);
  9963. },
  9964. setDateTimeFormat(locale, format) {
  9965. composer.setDateTimeFormat(locale, format);
  9966. },
  9967. mergeDateTimeFormat(locale, format) {
  9968. composer.mergeDateTimeFormat(locale, format);
  9969. },
  9970. n(...args) {
  9971. return Reflect.apply(composer.n, composer, [...args]);
  9972. },
  9973. getNumberFormat(locale) {
  9974. return composer.getNumberFormat(locale);
  9975. },
  9976. setNumberFormat(locale, format) {
  9977. composer.setNumberFormat(locale, format);
  9978. },
  9979. mergeNumberFormat(locale, format) {
  9980. composer.mergeNumberFormat(locale, format);
  9981. },
  9982. getChoiceIndex(choice, choicesLength) {
  9983. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX));
  9984. return -1;
  9985. },
  9986. __onComponentInstanceCreated(target) {
  9987. const { componentInstanceCreatedListener } = options;
  9988. if (componentInstanceCreatedListener) {
  9989. componentInstanceCreatedListener(target, vueI18n);
  9990. }
  9991. }
  9992. };
  9993. {
  9994. vueI18n.__enableEmitter = (emitter) => {
  9995. const __composer = composer;
  9996. __composer[EnableEmitter] && __composer[EnableEmitter](emitter);
  9997. };
  9998. vueI18n.__disableEmitter = () => {
  9999. const __composer = composer;
  10000. __composer[DisableEmitter] && __composer[DisableEmitter]();
  10001. };
  10002. }
  10003. return vueI18n;
  10004. }
  10005. }
  10006. var baseFormatProps = {
  10007. tag: {
  10008. type: [String, Object]
  10009. },
  10010. locale: {
  10011. type: String
  10012. },
  10013. scope: {
  10014. type: String,
  10015. validator: (val) => val === "parent" || val === "global",
  10016. default: "parent"
  10017. },
  10018. i18n: {
  10019. type: Object
  10020. }
  10021. };
  10022. function getInterpolateArg({ slots }, keys) {
  10023. if (keys.length === 1 && keys[0] === "default") {
  10024. const ret = slots.default ? slots.default() : [];
  10025. return ret.reduce((slot, current) => {
  10026. return slot = [
  10027. ...slot,
  10028. ...shared.isArray(current.children) ? current.children : [current]
  10029. ];
  10030. }, []);
  10031. } else {
  10032. return keys.reduce((arg, key) => {
  10033. const slot = slots[key];
  10034. if (slot) {
  10035. arg[key] = slot();
  10036. }
  10037. return arg;
  10038. }, {});
  10039. }
  10040. }
  10041. function getFragmentableTag(tag) {
  10042. return vue.Fragment;
  10043. }
  10044. var Translation = {
  10045. name: "i18n-t",
  10046. props: shared.assign({
  10047. keypath: {
  10048. type: String,
  10049. required: true
  10050. },
  10051. plural: {
  10052. type: [Number, String],
  10053. validator: (val) => shared.isNumber(val) || !isNaN(val)
  10054. }
  10055. }, baseFormatProps),
  10056. setup(props, context) {
  10057. const { slots, attrs } = context;
  10058. const i18n = props.i18n || useI18n({
  10059. useScope: props.scope,
  10060. __useComponent: true
  10061. });
  10062. return () => {
  10063. const keys = Object.keys(slots).filter((key) => key !== "_");
  10064. const options = {};
  10065. if (props.locale) {
  10066. options.locale = props.locale;
  10067. }
  10068. if (props.plural !== void 0) {
  10069. options.plural = shared.isString(props.plural) ? +props.plural : props.plural;
  10070. }
  10071. const arg = getInterpolateArg(context, keys);
  10072. const children = i18n[TransrateVNodeSymbol](props.keypath, arg, options);
  10073. const assignedAttrs = shared.assign({}, attrs);
  10074. const tag = shared.isString(props.tag) || shared.isObject(props.tag) ? props.tag : getFragmentableTag();
  10075. return vue.h(tag, assignedAttrs, children);
  10076. };
  10077. }
  10078. };
  10079. function isVNode(target) {
  10080. return shared.isArray(target) && !shared.isString(target[0]);
  10081. }
  10082. function renderFormatter(props, context, slotKeys, partFormatter) {
  10083. const { slots, attrs } = context;
  10084. return () => {
  10085. const options = { part: true };
  10086. let overrides = {};
  10087. if (props.locale) {
  10088. options.locale = props.locale;
  10089. }
  10090. if (shared.isString(props.format)) {
  10091. options.key = props.format;
  10092. } else if (shared.isObject(props.format)) {
  10093. if (shared.isString(props.format.key)) {
  10094. options.key = props.format.key;
  10095. }
  10096. overrides = Object.keys(props.format).reduce((options2, prop) => {
  10097. return slotKeys.includes(prop) ? shared.assign({}, options2, { [prop]: props.format[prop] }) : options2;
  10098. }, {});
  10099. }
  10100. const parts = partFormatter(...[props.value, options, overrides]);
  10101. let children = [options.key];
  10102. if (shared.isArray(parts)) {
  10103. children = parts.map((part, index) => {
  10104. const slot = slots[part.type];
  10105. const node = slot ? slot({ [part.type]: part.value, index, parts }) : [part.value];
  10106. if (isVNode(node)) {
  10107. node[0].key = `${part.type}-${index}`;
  10108. }
  10109. return node;
  10110. });
  10111. } else if (shared.isString(parts)) {
  10112. children = [parts];
  10113. }
  10114. const assignedAttrs = shared.assign({}, attrs);
  10115. const tag = shared.isString(props.tag) || shared.isObject(props.tag) ? props.tag : getFragmentableTag();
  10116. return vue.h(tag, assignedAttrs, children);
  10117. };
  10118. }
  10119. var NumberFormat = {
  10120. name: "i18n-n",
  10121. props: shared.assign({
  10122. value: {
  10123. type: Number,
  10124. required: true
  10125. },
  10126. format: {
  10127. type: [String, Object]
  10128. }
  10129. }, baseFormatProps),
  10130. setup(props, context) {
  10131. const i18n = props.i18n || useI18n({ useScope: "parent", __useComponent: true });
  10132. return renderFormatter(props, context, coreBase.NUMBER_FORMAT_OPTIONS_KEYS, (...args) => i18n[NumberPartsSymbol](...args));
  10133. }
  10134. };
  10135. var DatetimeFormat = {
  10136. name: "i18n-d",
  10137. props: shared.assign({
  10138. value: {
  10139. type: [Number, Date],
  10140. required: true
  10141. },
  10142. format: {
  10143. type: [String, Object]
  10144. }
  10145. }, baseFormatProps),
  10146. setup(props, context) {
  10147. const i18n = props.i18n || useI18n({ useScope: "parent", __useComponent: true });
  10148. return renderFormatter(props, context, coreBase.DATETIME_FORMAT_OPTIONS_KEYS, (...args) => i18n[DatetimePartsSymbol](...args));
  10149. }
  10150. };
  10151. function getComposer$1(i18n, instance) {
  10152. const i18nInternal = i18n;
  10153. if (i18n.mode === "composition") {
  10154. return i18nInternal.__getInstance(instance) || i18n.global;
  10155. } else {
  10156. const vueI18n = i18nInternal.__getInstance(instance);
  10157. return vueI18n != null ? vueI18n.__composer : i18n.global.__composer;
  10158. }
  10159. }
  10160. function vTDirective(i18n) {
  10161. function process2(binding) {
  10162. const { instance, modifiers, value } = binding;
  10163. if (!instance || !instance.$) {
  10164. throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
  10165. }
  10166. const composer = getComposer$1(i18n, instance.$);
  10167. if (modifiers.preserve) {
  10168. shared.warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE));
  10169. }
  10170. const parsedValue = parseValue(value);
  10171. return [
  10172. Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]),
  10173. composer
  10174. ];
  10175. }
  10176. const register = (el, binding) => {
  10177. const [textContent, composer] = process2(binding);
  10178. if (shared.inBrowser && i18n.global === composer) {
  10179. el.__i18nWatcher = vue.watch(composer.locale, () => {
  10180. binding.instance && binding.instance.$forceUpdate();
  10181. });
  10182. }
  10183. el.__composer = composer;
  10184. el.textContent = textContent;
  10185. };
  10186. const unregister = (el) => {
  10187. if (shared.inBrowser && el.__i18nWatcher) {
  10188. el.__i18nWatcher();
  10189. el.__i18nWatcher = void 0;
  10190. delete el.__i18nWatcher;
  10191. }
  10192. if (el.__composer) {
  10193. el.__composer = void 0;
  10194. delete el.__composer;
  10195. }
  10196. };
  10197. const update = (el, { value }) => {
  10198. if (el.__composer) {
  10199. const composer = el.__composer;
  10200. const parsedValue = parseValue(value);
  10201. el.textContent = Reflect.apply(composer.t, composer, [
  10202. ...makeParams(parsedValue)
  10203. ]);
  10204. }
  10205. };
  10206. return {
  10207. created: register,
  10208. unmounted: unregister,
  10209. beforeUpdate: update,
  10210. getSSRProps: (binding) => {
  10211. const [textContent] = process2(binding);
  10212. return { textContent };
  10213. }
  10214. };
  10215. }
  10216. function parseValue(value) {
  10217. if (shared.isString(value)) {
  10218. return { path: value };
  10219. } else if (shared.isPlainObject(value)) {
  10220. if (!("path" in value)) {
  10221. throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, "path");
  10222. }
  10223. return value;
  10224. } else {
  10225. throw createI18nError(I18nErrorCodes.INVALID_VALUE);
  10226. }
  10227. }
  10228. function makeParams(value) {
  10229. const { path, locale, args, choice, plural } = value;
  10230. const options = {};
  10231. const named = args || {};
  10232. if (shared.isString(locale)) {
  10233. options.locale = locale;
  10234. }
  10235. if (shared.isNumber(choice)) {
  10236. options.plural = choice;
  10237. }
  10238. if (shared.isNumber(plural)) {
  10239. options.plural = plural;
  10240. }
  10241. return [path, named, options];
  10242. }
  10243. function apply(app, i18n, ...options) {
  10244. const pluginOptions = shared.isPlainObject(options[0]) ? options[0] : {};
  10245. const useI18nComponentName = !!pluginOptions.useI18nComponentName;
  10246. const globalInstall = shared.isBoolean(pluginOptions.globalInstall) ? pluginOptions.globalInstall : true;
  10247. if (globalInstall && useI18nComponentName) {
  10248. shared.warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, {
  10249. name: Translation.name
  10250. }));
  10251. }
  10252. if (globalInstall) {
  10253. app.component(!useI18nComponentName ? Translation.name : "i18n", Translation);
  10254. app.component(NumberFormat.name, NumberFormat);
  10255. app.component(DatetimeFormat.name, DatetimeFormat);
  10256. }
  10257. {
  10258. app.directive("t", vTDirective(i18n));
  10259. }
  10260. }
  10261. function defineMixin(vuei18n, composer, i18n) {
  10262. return {
  10263. beforeCreate() {
  10264. const instance = vue.getCurrentInstance();
  10265. if (!instance) {
  10266. throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
  10267. }
  10268. const options = this.$options;
  10269. if (options.i18n) {
  10270. const optionsI18n = options.i18n;
  10271. if (options.__i18n) {
  10272. optionsI18n.__i18n = options.__i18n;
  10273. }
  10274. optionsI18n.__root = composer;
  10275. if (this === this.$root) {
  10276. this.$i18n = mergeToRoot(vuei18n, optionsI18n);
  10277. } else {
  10278. optionsI18n.__injectWithOption = true;
  10279. this.$i18n = createVueI18n(optionsI18n);
  10280. }
  10281. } else if (options.__i18n) {
  10282. if (this === this.$root) {
  10283. this.$i18n = mergeToRoot(vuei18n, options);
  10284. } else {
  10285. this.$i18n = createVueI18n({
  10286. __i18n: options.__i18n,
  10287. __injectWithOption: true,
  10288. __root: composer
  10289. });
  10290. }
  10291. } else {
  10292. this.$i18n = vuei18n;
  10293. }
  10294. if (options.__i18nGlobal) {
  10295. adjustI18nResources(composer, options, options);
  10296. }
  10297. vuei18n.__onComponentInstanceCreated(this.$i18n);
  10298. i18n.__setInstance(instance, this.$i18n);
  10299. this.$t = (...args) => this.$i18n.t(...args);
  10300. this.$rt = (...args) => this.$i18n.rt(...args);
  10301. this.$tc = (...args) => this.$i18n.tc(...args);
  10302. this.$te = (key, locale) => this.$i18n.te(key, locale);
  10303. this.$d = (...args) => this.$i18n.d(...args);
  10304. this.$n = (...args) => this.$i18n.n(...args);
  10305. this.$tm = (key) => this.$i18n.tm(key);
  10306. },
  10307. mounted() {
  10308. },
  10309. unmounted() {
  10310. const instance = vue.getCurrentInstance();
  10311. if (!instance) {
  10312. throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
  10313. }
  10314. delete this.$t;
  10315. delete this.$rt;
  10316. delete this.$tc;
  10317. delete this.$te;
  10318. delete this.$d;
  10319. delete this.$n;
  10320. delete this.$tm;
  10321. i18n.__deleteInstance(instance);
  10322. delete this.$i18n;
  10323. }
  10324. };
  10325. }
  10326. function mergeToRoot(root, options) {
  10327. root.locale = options.locale || root.locale;
  10328. root.fallbackLocale = options.fallbackLocale || root.fallbackLocale;
  10329. root.missing = options.missing || root.missing;
  10330. root.silentTranslationWarn = options.silentTranslationWarn || root.silentFallbackWarn;
  10331. root.silentFallbackWarn = options.silentFallbackWarn || root.silentFallbackWarn;
  10332. root.formatFallbackMessages = options.formatFallbackMessages || root.formatFallbackMessages;
  10333. root.postTranslation = options.postTranslation || root.postTranslation;
  10334. root.warnHtmlInMessage = options.warnHtmlInMessage || root.warnHtmlInMessage;
  10335. root.escapeParameterHtml = options.escapeParameterHtml || root.escapeParameterHtml;
  10336. root.sync = options.sync || root.sync;
  10337. root.__composer[SetPluralRulesSymbol](options.pluralizationRules || root.pluralizationRules);
  10338. const messages = getLocaleMessages(root.locale, {
  10339. messages: options.messages,
  10340. __i18n: options.__i18n
  10341. });
  10342. Object.keys(messages).forEach((locale) => root.mergeLocaleMessage(locale, messages[locale]));
  10343. if (options.datetimeFormats) {
  10344. Object.keys(options.datetimeFormats).forEach((locale) => root.mergeDateTimeFormat(locale, options.datetimeFormats[locale]));
  10345. }
  10346. if (options.numberFormats) {
  10347. Object.keys(options.numberFormats).forEach((locale) => root.mergeNumberFormat(locale, options.numberFormats[locale]));
  10348. }
  10349. return root;
  10350. }
  10351. var I18nInjectionKey = shared.makeSymbol("global-vue-i18n");
  10352. function createI18n(options = {}, VueI18nLegacy) {
  10353. const __legacyMode = shared.isBoolean(options.legacy) ? options.legacy : true;
  10354. const __globalInjection = shared.isBoolean(options.globalInjection) ? options.globalInjection : true;
  10355. const __allowComposition = __legacyMode ? !!options.allowComposition : true;
  10356. const __instances = /* @__PURE__ */ new Map();
  10357. const [globalScope, __global] = createGlobal(options, __legacyMode);
  10358. const symbol = shared.makeSymbol("vue-i18n");
  10359. function __getInstance(component) {
  10360. return __instances.get(component) || null;
  10361. }
  10362. function __setInstance(component, instance) {
  10363. __instances.set(component, instance);
  10364. }
  10365. function __deleteInstance(component) {
  10366. __instances.delete(component);
  10367. }
  10368. {
  10369. let _a;
  10370. const i18n = {
  10371. get mode() {
  10372. return __legacyMode ? "legacy" : "composition";
  10373. },
  10374. get allowComposition() {
  10375. return __allowComposition;
  10376. },
  10377. install(app, ...options2) {
  10378. return __async(this, null, function* () {
  10379. app.__VUE_I18N_SYMBOL__ = symbol;
  10380. app.provide(app.__VUE_I18N_SYMBOL__, i18n);
  10381. if (!__legacyMode && __globalInjection) {
  10382. injectGlobalFields(app, i18n.global);
  10383. }
  10384. {
  10385. apply(app, i18n, ...options2);
  10386. }
  10387. if (__legacyMode) {
  10388. app.mixin(defineMixin(__global, __global.__composer, i18n));
  10389. }
  10390. const unmountApp = app.unmount;
  10391. app.unmount = () => {
  10392. i18n.dispose();
  10393. unmountApp();
  10394. };
  10395. });
  10396. },
  10397. get global() {
  10398. return __global;
  10399. },
  10400. dispose() {
  10401. globalScope.stop();
  10402. },
  10403. __instances,
  10404. __getInstance,
  10405. __setInstance,
  10406. __deleteInstance
  10407. };
  10408. return i18n;
  10409. }
  10410. }
  10411. function useI18n(options = {}) {
  10412. const instance = vue.getCurrentInstance();
  10413. if (instance == null) {
  10414. throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP);
  10415. }
  10416. if (!instance.isCE && instance.appContext.app != null && !instance.appContext.app.__VUE_I18N_SYMBOL__) {
  10417. throw createI18nError(I18nErrorCodes.NOT_INSLALLED);
  10418. }
  10419. const i18n = getI18nInstance(instance);
  10420. const global2 = getGlobalComposer(i18n);
  10421. const componentOptions = getComponentOptions(instance);
  10422. const scope = getScope(options, componentOptions);
  10423. {
  10424. if (i18n.mode === "legacy" && !options.__useComponent) {
  10425. if (!i18n.allowComposition) {
  10426. throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE);
  10427. }
  10428. return useI18nForLegacy(instance, scope, global2, options);
  10429. }
  10430. }
  10431. if (scope === "global") {
  10432. adjustI18nResources(global2, options, componentOptions);
  10433. return global2;
  10434. }
  10435. if (scope === "parent") {
  10436. let composer2 = getComposer(i18n, instance, options.__useComponent);
  10437. if (composer2 == null) {
  10438. {
  10439. shared.warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE));
  10440. }
  10441. composer2 = global2;
  10442. }
  10443. return composer2;
  10444. }
  10445. const i18nInternal = i18n;
  10446. let composer = i18nInternal.__getInstance(instance);
  10447. if (composer == null) {
  10448. const composerOptions = shared.assign({}, options);
  10449. if ("__i18n" in componentOptions) {
  10450. composerOptions.__i18n = componentOptions.__i18n;
  10451. }
  10452. if (global2) {
  10453. composerOptions.__root = global2;
  10454. }
  10455. composer = createComposer(composerOptions);
  10456. setupLifeCycle(i18nInternal, instance);
  10457. i18nInternal.__setInstance(instance, composer);
  10458. }
  10459. return composer;
  10460. }
  10461. var castToVueI18n = (i18n) => {
  10462. if (!(__VUE_I18N_BRIDGE__ in i18n)) {
  10463. throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N);
  10464. }
  10465. return i18n;
  10466. };
  10467. function createGlobal(options, legacyMode, VueI18nLegacy) {
  10468. const scope = vue.effectScope();
  10469. {
  10470. const obj = legacyMode ? scope.run(() => createVueI18n(options)) : scope.run(() => createComposer(options));
  10471. if (obj == null) {
  10472. throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
  10473. }
  10474. return [scope, obj];
  10475. }
  10476. }
  10477. function getI18nInstance(instance) {
  10478. {
  10479. const i18n = vue.inject(!instance.isCE ? instance.appContext.app.__VUE_I18N_SYMBOL__ : I18nInjectionKey);
  10480. if (!i18n) {
  10481. throw createI18nError(!instance.isCE ? I18nErrorCodes.UNEXPECTED_ERROR : I18nErrorCodes.NOT_INSLALLED_WITH_PROVIDE);
  10482. }
  10483. return i18n;
  10484. }
  10485. }
  10486. function getScope(options, componentOptions) {
  10487. return shared.isEmptyObject(options) ? "__i18n" in componentOptions ? "local" : "global" : !options.useScope ? "local" : options.useScope;
  10488. }
  10489. function getGlobalComposer(i18n) {
  10490. return i18n.mode === "composition" ? i18n.global : i18n.global.__composer;
  10491. }
  10492. function getComposer(i18n, target, useComponent = false) {
  10493. let composer = null;
  10494. const root = target.root;
  10495. let current = target.parent;
  10496. while (current != null) {
  10497. const i18nInternal = i18n;
  10498. if (i18n.mode === "composition") {
  10499. composer = i18nInternal.__getInstance(current);
  10500. } else {
  10501. {
  10502. const vueI18n = i18nInternal.__getInstance(current);
  10503. if (vueI18n != null) {
  10504. composer = vueI18n.__composer;
  10505. if (useComponent && composer && !composer[InejctWithOption]) {
  10506. composer = null;
  10507. }
  10508. }
  10509. }
  10510. }
  10511. if (composer != null) {
  10512. break;
  10513. }
  10514. if (root === current) {
  10515. break;
  10516. }
  10517. current = current.parent;
  10518. }
  10519. return composer;
  10520. }
  10521. function setupLifeCycle(i18n, target, composer) {
  10522. {
  10523. vue.onMounted(() => {
  10524. }, target);
  10525. vue.onUnmounted(() => {
  10526. i18n.__deleteInstance(target);
  10527. }, target);
  10528. }
  10529. }
  10530. function useI18nForLegacy(instance, scope, root, options = {}) {
  10531. const isLocale = scope === "local";
  10532. const _composer = vue.shallowRef(null);
  10533. if (isLocale && instance.proxy && !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) {
  10534. throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION);
  10535. }
  10536. const _inheritLocale = shared.isBoolean(options.inheritLocale) ? options.inheritLocale : true;
  10537. const _locale = vue.ref(
  10538. isLocale && _inheritLocale ? root.locale.value : shared.isString(options.locale) ? options.locale : coreBase.DEFAULT_LOCALE
  10539. );
  10540. const _fallbackLocale = vue.ref(
  10541. isLocale && _inheritLocale ? root.fallbackLocale.value : shared.isString(options.fallbackLocale) || shared.isArray(options.fallbackLocale) || shared.isPlainObject(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : _locale.value
  10542. );
  10543. const _messages = vue.ref(getLocaleMessages(_locale.value, options));
  10544. const _datetimeFormats = vue.ref(shared.isPlainObject(options.datetimeFormats) ? options.datetimeFormats : { [_locale.value]: {} });
  10545. const _numberFormats = vue.ref(shared.isPlainObject(options.numberFormats) ? options.numberFormats : { [_locale.value]: {} });
  10546. const _missingWarn = isLocale ? root.missingWarn : shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) ? options.missingWarn : true;
  10547. const _fallbackWarn = isLocale ? root.fallbackWarn : shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) ? options.fallbackWarn : true;
  10548. const _fallbackRoot = isLocale ? root.fallbackRoot : shared.isBoolean(options.fallbackRoot) ? options.fallbackRoot : true;
  10549. const _fallbackFormat = !!options.fallbackFormat;
  10550. const _missing = shared.isFunction(options.missing) ? options.missing : null;
  10551. const _postTranslation = shared.isFunction(options.postTranslation) ? options.postTranslation : null;
  10552. const _warnHtmlMessage = isLocale ? root.warnHtmlMessage : shared.isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true;
  10553. const _escapeParameter = !!options.escapeParameter;
  10554. const _modifiers = isLocale ? root.modifiers : shared.isPlainObject(options.modifiers) ? options.modifiers : {};
  10555. const _pluralRules = options.pluralRules || isLocale && root.pluralRules;
  10556. function trackReactivityValues() {
  10557. return [
  10558. _locale.value,
  10559. _fallbackLocale.value,
  10560. _messages.value,
  10561. _datetimeFormats.value,
  10562. _numberFormats.value
  10563. ];
  10564. }
  10565. const locale = vue.computed({
  10566. get: () => {
  10567. return _composer.value ? _composer.value.locale.value : _locale.value;
  10568. },
  10569. set: (val) => {
  10570. if (_composer.value) {
  10571. _composer.value.locale.value = val;
  10572. }
  10573. _locale.value = val;
  10574. }
  10575. });
  10576. const fallbackLocale = vue.computed({
  10577. get: () => {
  10578. return _composer.value ? _composer.value.fallbackLocale.value : _fallbackLocale.value;
  10579. },
  10580. set: (val) => {
  10581. if (_composer.value) {
  10582. _composer.value.fallbackLocale.value = val;
  10583. }
  10584. _fallbackLocale.value = val;
  10585. }
  10586. });
  10587. const messages = vue.computed(() => {
  10588. if (_composer.value) {
  10589. return _composer.value.messages.value;
  10590. } else {
  10591. return _messages.value;
  10592. }
  10593. });
  10594. const datetimeFormats = vue.computed(() => _datetimeFormats.value);
  10595. const numberFormats = vue.computed(() => _numberFormats.value);
  10596. function getPostTranslationHandler() {
  10597. return _composer.value ? _composer.value.getPostTranslationHandler() : _postTranslation;
  10598. }
  10599. function setPostTranslationHandler(handler) {
  10600. if (_composer.value) {
  10601. _composer.value.setPostTranslationHandler(handler);
  10602. }
  10603. }
  10604. function getMissingHandler() {
  10605. return _composer.value ? _composer.value.getMissingHandler() : _missing;
  10606. }
  10607. function setMissingHandler(handler) {
  10608. if (_composer.value) {
  10609. _composer.value.setMissingHandler(handler);
  10610. }
  10611. }
  10612. function warpWithDeps(fn) {
  10613. trackReactivityValues();
  10614. return fn();
  10615. }
  10616. function t(...args) {
  10617. return _composer.value ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) : warpWithDeps(() => "");
  10618. }
  10619. function rt(...args) {
  10620. return _composer.value ? Reflect.apply(_composer.value.rt, null, [...args]) : "";
  10621. }
  10622. function d(...args) {
  10623. return _composer.value ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) : warpWithDeps(() => "");
  10624. }
  10625. function n(...args) {
  10626. return _composer.value ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) : warpWithDeps(() => "");
  10627. }
  10628. function tm(key) {
  10629. return _composer.value ? _composer.value.tm(key) : {};
  10630. }
  10631. function te(key, locale2) {
  10632. return _composer.value ? _composer.value.te(key, locale2) : false;
  10633. }
  10634. function getLocaleMessage(locale2) {
  10635. return _composer.value ? _composer.value.getLocaleMessage(locale2) : {};
  10636. }
  10637. function setLocaleMessage(locale2, message) {
  10638. if (_composer.value) {
  10639. _composer.value.setLocaleMessage(locale2, message);
  10640. _messages.value[locale2] = message;
  10641. }
  10642. }
  10643. function mergeLocaleMessage(locale2, message) {
  10644. if (_composer.value) {
  10645. _composer.value.mergeLocaleMessage(locale2, message);
  10646. }
  10647. }
  10648. function getDateTimeFormat(locale2) {
  10649. return _composer.value ? _composer.value.getDateTimeFormat(locale2) : {};
  10650. }
  10651. function setDateTimeFormat(locale2, format) {
  10652. if (_composer.value) {
  10653. _composer.value.setDateTimeFormat(locale2, format);
  10654. _datetimeFormats.value[locale2] = format;
  10655. }
  10656. }
  10657. function mergeDateTimeFormat(locale2, format) {
  10658. if (_composer.value) {
  10659. _composer.value.mergeDateTimeFormat(locale2, format);
  10660. }
  10661. }
  10662. function getNumberFormat(locale2) {
  10663. return _composer.value ? _composer.value.getNumberFormat(locale2) : {};
  10664. }
  10665. function setNumberFormat(locale2, format) {
  10666. if (_composer.value) {
  10667. _composer.value.setNumberFormat(locale2, format);
  10668. _numberFormats.value[locale2] = format;
  10669. }
  10670. }
  10671. function mergeNumberFormat(locale2, format) {
  10672. if (_composer.value) {
  10673. _composer.value.mergeNumberFormat(locale2, format);
  10674. }
  10675. }
  10676. const wrapper = {
  10677. get id() {
  10678. return _composer.value ? _composer.value.id : -1;
  10679. },
  10680. locale,
  10681. fallbackLocale,
  10682. messages,
  10683. datetimeFormats,
  10684. numberFormats,
  10685. get inheritLocale() {
  10686. return _composer.value ? _composer.value.inheritLocale : _inheritLocale;
  10687. },
  10688. set inheritLocale(val) {
  10689. if (_composer.value) {
  10690. _composer.value.inheritLocale = val;
  10691. }
  10692. },
  10693. get availableLocales() {
  10694. return _composer.value ? _composer.value.availableLocales : Object.keys(_messages.value);
  10695. },
  10696. get modifiers() {
  10697. return _composer.value ? _composer.value.modifiers : _modifiers;
  10698. },
  10699. get pluralRules() {
  10700. return _composer.value ? _composer.value.pluralRules : _pluralRules;
  10701. },
  10702. get isGlobal() {
  10703. return _composer.value ? _composer.value.isGlobal : false;
  10704. },
  10705. get missingWarn() {
  10706. return _composer.value ? _composer.value.missingWarn : _missingWarn;
  10707. },
  10708. set missingWarn(val) {
  10709. if (_composer.value) {
  10710. _composer.value.missingWarn = val;
  10711. }
  10712. },
  10713. get fallbackWarn() {
  10714. return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn;
  10715. },
  10716. set fallbackWarn(val) {
  10717. if (_composer.value) {
  10718. _composer.value.missingWarn = val;
  10719. }
  10720. },
  10721. get fallbackRoot() {
  10722. return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot;
  10723. },
  10724. set fallbackRoot(val) {
  10725. if (_composer.value) {
  10726. _composer.value.fallbackRoot = val;
  10727. }
  10728. },
  10729. get fallbackFormat() {
  10730. return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat;
  10731. },
  10732. set fallbackFormat(val) {
  10733. if (_composer.value) {
  10734. _composer.value.fallbackFormat = val;
  10735. }
  10736. },
  10737. get warnHtmlMessage() {
  10738. return _composer.value ? _composer.value.warnHtmlMessage : _warnHtmlMessage;
  10739. },
  10740. set warnHtmlMessage(val) {
  10741. if (_composer.value) {
  10742. _composer.value.warnHtmlMessage = val;
  10743. }
  10744. },
  10745. get escapeParameter() {
  10746. return _composer.value ? _composer.value.escapeParameter : _escapeParameter;
  10747. },
  10748. set escapeParameter(val) {
  10749. if (_composer.value) {
  10750. _composer.value.escapeParameter = val;
  10751. }
  10752. },
  10753. t,
  10754. getPostTranslationHandler,
  10755. setPostTranslationHandler,
  10756. getMissingHandler,
  10757. setMissingHandler,
  10758. rt,
  10759. d,
  10760. n,
  10761. tm,
  10762. te,
  10763. getLocaleMessage,
  10764. setLocaleMessage,
  10765. mergeLocaleMessage,
  10766. getDateTimeFormat,
  10767. setDateTimeFormat,
  10768. mergeDateTimeFormat,
  10769. getNumberFormat,
  10770. setNumberFormat,
  10771. mergeNumberFormat
  10772. };
  10773. function sync(composer) {
  10774. composer.locale.value = _locale.value;
  10775. composer.fallbackLocale.value = _fallbackLocale.value;
  10776. Object.keys(_messages.value).forEach((locale2) => {
  10777. composer.mergeLocaleMessage(locale2, _messages.value[locale2]);
  10778. });
  10779. Object.keys(_datetimeFormats.value).forEach((locale2) => {
  10780. composer.mergeDateTimeFormat(locale2, _datetimeFormats.value[locale2]);
  10781. });
  10782. Object.keys(_numberFormats.value).forEach((locale2) => {
  10783. composer.mergeNumberFormat(locale2, _numberFormats.value[locale2]);
  10784. });
  10785. composer.escapeParameter = _escapeParameter;
  10786. composer.fallbackFormat = _fallbackFormat;
  10787. composer.fallbackRoot = _fallbackRoot;
  10788. composer.fallbackWarn = _fallbackWarn;
  10789. composer.missingWarn = _missingWarn;
  10790. composer.warnHtmlMessage = _warnHtmlMessage;
  10791. }
  10792. vue.onBeforeMount(() => {
  10793. if (instance.proxy == null || instance.proxy.$i18n == null) {
  10794. throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY);
  10795. }
  10796. const composer = _composer.value = instance.proxy.$i18n.__composer;
  10797. if (scope === "global") {
  10798. _locale.value = composer.locale.value;
  10799. _fallbackLocale.value = composer.fallbackLocale.value;
  10800. _messages.value = composer.messages.value;
  10801. _datetimeFormats.value = composer.datetimeFormats.value;
  10802. _numberFormats.value = composer.numberFormats.value;
  10803. } else if (isLocale) {
  10804. sync(composer);
  10805. }
  10806. });
  10807. return wrapper;
  10808. }
  10809. var globalExportProps = [
  10810. "locale",
  10811. "fallbackLocale",
  10812. "availableLocales"
  10813. ];
  10814. var globalExportMethods = ["t", "rt", "d", "n", "tm"];
  10815. function injectGlobalFields(app, composer) {
  10816. const i18n = /* @__PURE__ */ Object.create(null);
  10817. globalExportProps.forEach((prop) => {
  10818. const desc = Object.getOwnPropertyDescriptor(composer, prop);
  10819. if (!desc) {
  10820. throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
  10821. }
  10822. const wrap = vue.isRef(desc.value) ? {
  10823. get() {
  10824. return desc.value.value;
  10825. },
  10826. set(val) {
  10827. desc.value.value = val;
  10828. }
  10829. } : {
  10830. get() {
  10831. return desc.get && desc.get();
  10832. }
  10833. };
  10834. Object.defineProperty(i18n, prop, wrap);
  10835. });
  10836. app.config.globalProperties.$i18n = i18n;
  10837. globalExportMethods.forEach((method) => {
  10838. const desc = Object.getOwnPropertyDescriptor(composer, method);
  10839. if (!desc || !desc.value) {
  10840. throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR);
  10841. }
  10842. Object.defineProperty(app.config.globalProperties, `$${method}`, desc);
  10843. });
  10844. }
  10845. coreBase.registerMessageCompiler(coreBase.compileToFunction);
  10846. coreBase.registerMessageResolver(coreBase.resolveValue);
  10847. coreBase.registerLocaleFallbacker(coreBase.fallbackWithLocaleChain);
  10848. {
  10849. const target = shared.getGlobalThis();
  10850. target.__INTLIFY__ = true;
  10851. coreBase.setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__);
  10852. }
  10853. exports.DatetimeFormat = DatetimeFormat;
  10854. exports.I18nInjectionKey = I18nInjectionKey;
  10855. exports.NumberFormat = NumberFormat;
  10856. exports.Translation = Translation;
  10857. exports.VERSION = VERSION;
  10858. exports.castToVueI18n = castToVueI18n;
  10859. exports.createI18n = createI18n;
  10860. exports.useI18n = useI18n;
  10861. exports.vTDirective = vTDirective;
  10862. }
  10863. });
  10864. // dep:vue-i18n
  10865. init_define_APP_INFO();
  10866. var vue_i18n_default = require_vue_i18n_cjs();
  10867. export {
  10868. vue_i18n_default as default
  10869. };
  10870. /*!
  10871. * core-base v9.2.0
  10872. * (c) 2022 kazuya kawaguchi
  10873. * Released under the MIT License.
  10874. */
  10875. /*!
  10876. * devtools-if v9.2.0
  10877. * (c) 2022 kazuya kawaguchi
  10878. * Released under the MIT License.
  10879. */
  10880. /*!
  10881. * message-compiler v9.2.0
  10882. * (c) 2022 kazuya kawaguchi
  10883. * Released under the MIT License.
  10884. */
  10885. /*!
  10886. * shared v9.2.0
  10887. * (c) 2022 kazuya kawaguchi
  10888. * Released under the MIT License.
  10889. */
  10890. /*!
  10891. * vue-i18n v9.2.0
  10892. * (c) 2022 kazuya kawaguchi
  10893. * Released under the MIT License.
  10894. */
  10895. //# sourceMappingURL=vue-i18n.js.map