compiler-sfc.js 646 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var require$$0 = require('source-map');
  4. var parser$1 = require('@babel/parser');
  5. var url = require('url');
  6. var path = require('path');
  7. var require$$0$1 = require('fs');
  8. var require$$2 = require('util');
  9. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  10. var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0);
  11. var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
  12. var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
  13. var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
  14. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  15. function getDefaultExportFromCjs (x) {
  16. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  17. }
  18. var splitRE$2 = /\r?\n/g;
  19. var emptyRE$1 = /^\s*$/;
  20. var needFixRE = /^(\r?\n)*[\t\s]/;
  21. var deIndent = function deindent (str) {
  22. if (!needFixRE.test(str)) {
  23. return str
  24. }
  25. var lines = str.split(splitRE$2);
  26. var min = Infinity;
  27. var type, cur, c;
  28. for (var i = 0; i < lines.length; i++) {
  29. var line = lines[i];
  30. if (!emptyRE$1.test(line)) {
  31. if (!type) {
  32. c = line.charAt(0);
  33. if (c === ' ' || c === '\t') {
  34. type = c;
  35. cur = count(line, type);
  36. if (cur < min) {
  37. min = cur;
  38. }
  39. } else {
  40. return str
  41. }
  42. } else {
  43. cur = count(line, type);
  44. if (cur < min) {
  45. min = cur;
  46. }
  47. }
  48. }
  49. }
  50. return lines.map(function (line) {
  51. return line.slice(min)
  52. }).join('\n')
  53. };
  54. function count (line, type) {
  55. var i = 0;
  56. while (line.charAt(i) === type) {
  57. i++;
  58. }
  59. return i
  60. }
  61. const emptyObject = Object.freeze({});
  62. const isArray = Array.isArray;
  63. // These helpers produce better VM code in JS engines due to their
  64. // explicitness and function inlining.
  65. function isUndef(v) {
  66. return v === undefined || v === null;
  67. }
  68. function isDef(v) {
  69. return v !== undefined && v !== null;
  70. }
  71. function isTrue(v) {
  72. return v === true;
  73. }
  74. function isFalse(v) {
  75. return v === false;
  76. }
  77. /**
  78. * Check if value is primitive.
  79. */
  80. function isPrimitive(value) {
  81. return (typeof value === 'string' ||
  82. typeof value === 'number' ||
  83. // $flow-disable-line
  84. typeof value === 'symbol' ||
  85. typeof value === 'boolean');
  86. }
  87. function isFunction(value) {
  88. return typeof value === 'function';
  89. }
  90. /**
  91. * Quick object check - this is primarily used to tell
  92. * objects from primitive values when we know the value
  93. * is a JSON-compliant type.
  94. */
  95. function isObject$1(obj) {
  96. return obj !== null && typeof obj === 'object';
  97. }
  98. /**
  99. * Get the raw type string of a value, e.g., [object Object].
  100. */
  101. const _toString = Object.prototype.toString;
  102. function toRawType(value) {
  103. return _toString.call(value).slice(8, -1);
  104. }
  105. /**
  106. * Strict object type check. Only returns true
  107. * for plain JavaScript objects.
  108. */
  109. function isPlainObject(obj) {
  110. return _toString.call(obj) === '[object Object]';
  111. }
  112. /**
  113. * Check if val is a valid array index.
  114. */
  115. function isValidArrayIndex(val) {
  116. const n = parseFloat(String(val));
  117. return n >= 0 && Math.floor(n) === n && isFinite(val);
  118. }
  119. function isPromise(val) {
  120. return (isDef(val) &&
  121. typeof val.then === 'function' &&
  122. typeof val.catch === 'function');
  123. }
  124. /**
  125. * Convert a value to a string that is actually rendered.
  126. */
  127. function toString$2(val) {
  128. return val == null
  129. ? ''
  130. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  131. ? JSON.stringify(val, replacer, 2)
  132. : String(val);
  133. }
  134. function replacer(_key, val) {
  135. // avoid circular deps from v3
  136. if (val && val.__v_isRef) {
  137. return val.value;
  138. }
  139. return val;
  140. }
  141. /**
  142. * Convert an input value to a number for persistence.
  143. * If the conversion fails, return original string.
  144. */
  145. function toNumber(val) {
  146. const n = parseFloat(val);
  147. return isNaN(n) ? val : n;
  148. }
  149. /**
  150. * Make a map and return a function for checking if a key
  151. * is in that map.
  152. */
  153. function makeMap(str, expectsLowerCase) {
  154. const map = Object.create(null);
  155. const list = str.split(',');
  156. for (let i = 0; i < list.length; i++) {
  157. map[list[i]] = true;
  158. }
  159. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  160. }
  161. /**
  162. * Check if a tag is a built-in tag.
  163. */
  164. const isBuiltInTag = makeMap('slot,component', true);
  165. /**
  166. * Check if an attribute is a reserved attribute.
  167. */
  168. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  169. /**
  170. * Check whether an object has the property.
  171. */
  172. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  173. function hasOwn(obj, key) {
  174. return hasOwnProperty$1.call(obj, key);
  175. }
  176. /**
  177. * Create a cached version of a pure function.
  178. */
  179. function cached(fn) {
  180. const cache = Object.create(null);
  181. return function cachedFn(str) {
  182. const hit = cache[str];
  183. return hit || (cache[str] = fn(str));
  184. };
  185. }
  186. /**
  187. * Camelize a hyphen-delimited string.
  188. */
  189. const camelizeRE = /-(\w)/g;
  190. const camelize = cached((str) => {
  191. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  192. });
  193. /**
  194. * Capitalize a string.
  195. */
  196. const capitalize = cached((str) => {
  197. return str.charAt(0).toUpperCase() + str.slice(1);
  198. });
  199. /**
  200. * Hyphenate a camelCase string.
  201. */
  202. const hyphenateRE = /\B([A-Z])/g;
  203. const hyphenate = cached((str) => {
  204. return str.replace(hyphenateRE, '-$1').toLowerCase();
  205. });
  206. /**
  207. * Mix properties into target object.
  208. */
  209. function extend(to, _from) {
  210. for (const key in _from) {
  211. to[key] = _from[key];
  212. }
  213. return to;
  214. }
  215. /**
  216. * Merge an Array of Objects into a single Object.
  217. */
  218. function toObject(arr) {
  219. const res = {};
  220. for (let i = 0; i < arr.length; i++) {
  221. if (arr[i]) {
  222. extend(res, arr[i]);
  223. }
  224. }
  225. return res;
  226. }
  227. /* eslint-disable no-unused-vars */
  228. /**
  229. * Perform no operation.
  230. * Stubbing args to make Flow happy without leaving useless transpiled code
  231. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  232. */
  233. function noop(a, b, c) { }
  234. /**
  235. * Always return false.
  236. */
  237. const no = (a, b, c) => false;
  238. /* eslint-enable no-unused-vars */
  239. /**
  240. * Return the same value.
  241. */
  242. const identity = (_) => _;
  243. /**
  244. * Generate a string containing static keys from compiler modules.
  245. */
  246. function genStaticKeys$1(modules) {
  247. return modules
  248. .reduce((keys, m) => keys.concat(m.staticKeys || []), [])
  249. .join(',');
  250. }
  251. /**
  252. * Check if two values are loosely equal - that is,
  253. * if they are plain objects, do they have the same shape?
  254. */
  255. function looseEqual(a, b) {
  256. if (a === b)
  257. return true;
  258. const isObjectA = isObject$1(a);
  259. const isObjectB = isObject$1(b);
  260. if (isObjectA && isObjectB) {
  261. try {
  262. const isArrayA = Array.isArray(a);
  263. const isArrayB = Array.isArray(b);
  264. if (isArrayA && isArrayB) {
  265. return (a.length === b.length &&
  266. a.every((e, i) => {
  267. return looseEqual(e, b[i]);
  268. }));
  269. }
  270. else if (a instanceof Date && b instanceof Date) {
  271. return a.getTime() === b.getTime();
  272. }
  273. else if (!isArrayA && !isArrayB) {
  274. const keysA = Object.keys(a);
  275. const keysB = Object.keys(b);
  276. return (keysA.length === keysB.length &&
  277. keysA.every(key => {
  278. return looseEqual(a[key], b[key]);
  279. }));
  280. }
  281. else {
  282. /* istanbul ignore next */
  283. return false;
  284. }
  285. }
  286. catch (e) {
  287. /* istanbul ignore next */
  288. return false;
  289. }
  290. }
  291. else if (!isObjectA && !isObjectB) {
  292. return String(a) === String(b);
  293. }
  294. else {
  295. return false;
  296. }
  297. }
  298. /**
  299. * Return the first index at which a loosely equal value can be
  300. * found in the array (if value is a plain object, the array must
  301. * contain an object of the same shape), or -1 if it is not present.
  302. */
  303. function looseIndexOf(arr, val) {
  304. for (let i = 0; i < arr.length; i++) {
  305. if (looseEqual(arr[i], val))
  306. return i;
  307. }
  308. return -1;
  309. }
  310. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  311. function hasChanged(x, y) {
  312. if (x === y) {
  313. return x === 0 && 1 / x !== 1 / y;
  314. }
  315. else {
  316. return x === x || y === y;
  317. }
  318. }
  319. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  320. 'link,meta,param,source,track,wbr');
  321. // Elements that you can, intentionally, leave open
  322. // (and which close themselves)
  323. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  324. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  325. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  326. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  327. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  328. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  329. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  330. 'title,tr,track');
  331. /**
  332. * unicode letters used for parsing html tags, component names and property paths.
  333. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  334. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  335. */
  336. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  337. /**
  338. * Define a property.
  339. */
  340. function def(obj, key, val, enumerable) {
  341. Object.defineProperty(obj, key, {
  342. value: val,
  343. enumerable: !!enumerable,
  344. writable: true,
  345. configurable: true
  346. });
  347. }
  348. /**
  349. * Not type-checking this file because it's mostly vendor code.
  350. */
  351. // Regular Expressions for parsing tags and attributes
  352. const attribute$2 = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  353. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  354. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  355. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  356. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  357. const startTagClose = /^\s*(\/?)>/;
  358. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  359. const doctype = /^<!DOCTYPE [^>]+>/i;
  360. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  361. const comment$3 = /^<!\--/;
  362. const conditionalComment = /^<!\[/;
  363. // Special Elements (can contain anything)
  364. const isPlainTextElement = makeMap('script,style,textarea', true);
  365. const reCache = {};
  366. const decodingMap = {
  367. '&lt;': '<',
  368. '&gt;': '>',
  369. '&quot;': '"',
  370. '&amp;': '&',
  371. '&#10;': '\n',
  372. '&#9;': '\t',
  373. '&#39;': "'"
  374. };
  375. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  376. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  377. // #5992
  378. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  379. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  380. function decodeAttr(value, shouldDecodeNewlines) {
  381. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  382. return value.replace(re, match => decodingMap[match]);
  383. }
  384. function parseHTML(html, options) {
  385. const stack = [];
  386. const expectHTML = options.expectHTML;
  387. const isUnaryTag = options.isUnaryTag || no;
  388. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  389. let index = 0;
  390. let last, lastTag;
  391. while (html) {
  392. last = html;
  393. // Make sure we're not in a plaintext content element like script/style
  394. if (!lastTag || !isPlainTextElement(lastTag)) {
  395. let textEnd = html.indexOf('<');
  396. if (textEnd === 0) {
  397. // Comment:
  398. if (comment$3.test(html)) {
  399. const commentEnd = html.indexOf('-->');
  400. if (commentEnd >= 0) {
  401. if (options.shouldKeepComment && options.comment) {
  402. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  403. }
  404. advance(commentEnd + 3);
  405. continue;
  406. }
  407. }
  408. // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  409. if (conditionalComment.test(html)) {
  410. const conditionalEnd = html.indexOf(']>');
  411. if (conditionalEnd >= 0) {
  412. advance(conditionalEnd + 2);
  413. continue;
  414. }
  415. }
  416. // Doctype:
  417. const doctypeMatch = html.match(doctype);
  418. if (doctypeMatch) {
  419. advance(doctypeMatch[0].length);
  420. continue;
  421. }
  422. // End tag:
  423. const endTagMatch = html.match(endTag);
  424. if (endTagMatch) {
  425. const curIndex = index;
  426. advance(endTagMatch[0].length);
  427. parseEndTag(endTagMatch[1], curIndex, index);
  428. continue;
  429. }
  430. // Start tag:
  431. const startTagMatch = parseStartTag();
  432. if (startTagMatch) {
  433. handleStartTag(startTagMatch);
  434. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  435. advance(1);
  436. }
  437. continue;
  438. }
  439. }
  440. let text, rest, next;
  441. if (textEnd >= 0) {
  442. rest = html.slice(textEnd);
  443. while (!endTag.test(rest) &&
  444. !startTagOpen.test(rest) &&
  445. !comment$3.test(rest) &&
  446. !conditionalComment.test(rest)) {
  447. // < in plain text, be forgiving and treat it as text
  448. next = rest.indexOf('<', 1);
  449. if (next < 0)
  450. break;
  451. textEnd += next;
  452. rest = html.slice(textEnd);
  453. }
  454. text = html.substring(0, textEnd);
  455. }
  456. if (textEnd < 0) {
  457. text = html;
  458. }
  459. if (text) {
  460. advance(text.length);
  461. }
  462. if (options.chars && text) {
  463. options.chars(text, index - text.length, index);
  464. }
  465. }
  466. else {
  467. let endTagLength = 0;
  468. const stackedTag = lastTag.toLowerCase();
  469. const reStackedTag = reCache[stackedTag] ||
  470. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  471. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  472. endTagLength = endTag.length;
  473. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  474. text = text
  475. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  476. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  477. }
  478. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  479. text = text.slice(1);
  480. }
  481. if (options.chars) {
  482. options.chars(text);
  483. }
  484. return '';
  485. });
  486. index += html.length - rest.length;
  487. html = rest;
  488. parseEndTag(stackedTag, index - endTagLength, index);
  489. }
  490. if (html === last) {
  491. options.chars && options.chars(html);
  492. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  493. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  494. start: index + html.length
  495. });
  496. }
  497. break;
  498. }
  499. }
  500. // Clean up any remaining tags
  501. parseEndTag();
  502. function advance(n) {
  503. index += n;
  504. html = html.substring(n);
  505. }
  506. function parseStartTag() {
  507. const start = html.match(startTagOpen);
  508. if (start) {
  509. const match = {
  510. tagName: start[1],
  511. attrs: [],
  512. start: index
  513. };
  514. advance(start[0].length);
  515. let end, attr;
  516. while (!(end = html.match(startTagClose)) &&
  517. (attr = html.match(dynamicArgAttribute) || html.match(attribute$2))) {
  518. attr.start = index;
  519. advance(attr[0].length);
  520. attr.end = index;
  521. match.attrs.push(attr);
  522. }
  523. if (end) {
  524. match.unarySlash = end[1];
  525. advance(end[0].length);
  526. match.end = index;
  527. return match;
  528. }
  529. }
  530. }
  531. function handleStartTag(match) {
  532. const tagName = match.tagName;
  533. const unarySlash = match.unarySlash;
  534. if (expectHTML) {
  535. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  536. parseEndTag(lastTag);
  537. }
  538. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  539. parseEndTag(tagName);
  540. }
  541. }
  542. const unary = isUnaryTag(tagName) || !!unarySlash;
  543. const l = match.attrs.length;
  544. const attrs = new Array(l);
  545. for (let i = 0; i < l; i++) {
  546. const args = match.attrs[i];
  547. const value = args[3] || args[4] || args[5] || '';
  548. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  549. ? options.shouldDecodeNewlinesForHref
  550. : options.shouldDecodeNewlines;
  551. attrs[i] = {
  552. name: args[1],
  553. value: decodeAttr(value, shouldDecodeNewlines)
  554. };
  555. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  556. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  557. attrs[i].end = args.end;
  558. }
  559. }
  560. if (!unary) {
  561. stack.push({
  562. tag: tagName,
  563. lowerCasedTag: tagName.toLowerCase(),
  564. attrs: attrs,
  565. start: match.start,
  566. end: match.end
  567. });
  568. lastTag = tagName;
  569. }
  570. if (options.start) {
  571. options.start(tagName, attrs, unary, match.start, match.end);
  572. }
  573. }
  574. function parseEndTag(tagName, start, end) {
  575. let pos, lowerCasedTagName;
  576. if (start == null)
  577. start = index;
  578. if (end == null)
  579. end = index;
  580. // Find the closest opened tag of the same type
  581. if (tagName) {
  582. lowerCasedTagName = tagName.toLowerCase();
  583. for (pos = stack.length - 1; pos >= 0; pos--) {
  584. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  585. break;
  586. }
  587. }
  588. }
  589. else {
  590. // If no tag name is provided, clean shop
  591. pos = 0;
  592. }
  593. if (pos >= 0) {
  594. // Close all the open elements, up the stack
  595. for (let i = stack.length - 1; i >= pos; i--) {
  596. if (process.env.NODE_ENV !== 'production' && (i > pos || !tagName) && options.warn) {
  597. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  598. start: stack[i].start,
  599. end: stack[i].end
  600. });
  601. }
  602. if (options.end) {
  603. options.end(stack[i].tag, start, end);
  604. }
  605. }
  606. // Remove the open elements from the stack
  607. stack.length = pos;
  608. lastTag = pos && stack[pos - 1].tag;
  609. }
  610. else if (lowerCasedTagName === 'br') {
  611. if (options.start) {
  612. options.start(tagName, [], true, start, end);
  613. }
  614. }
  615. else if (lowerCasedTagName === 'p') {
  616. if (options.start) {
  617. options.start(tagName, [], false, start, end);
  618. }
  619. if (options.end) {
  620. options.end(tagName, start, end);
  621. }
  622. }
  623. }
  624. }
  625. const DEFAULT_FILENAME = 'anonymous.vue';
  626. const splitRE$1 = /\r?\n/g;
  627. const replaceRE = /./g;
  628. const isSpecialTag = makeMap('script,style,template', true);
  629. /**
  630. * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
  631. */
  632. function parseComponent(source, options = {}) {
  633. const sfc = {
  634. source,
  635. filename: DEFAULT_FILENAME,
  636. template: null,
  637. script: null,
  638. scriptSetup: null,
  639. styles: [],
  640. customBlocks: [],
  641. cssVars: [],
  642. errors: [],
  643. shouldForceReload: null // attached in parse() by compiler-sfc
  644. };
  645. let depth = 0;
  646. let currentBlock = null;
  647. let warn = msg => {
  648. sfc.errors.push(msg);
  649. };
  650. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  651. warn = (msg, range) => {
  652. const data = { msg };
  653. if (range.start != null) {
  654. data.start = range.start;
  655. }
  656. if (range.end != null) {
  657. data.end = range.end;
  658. }
  659. sfc.errors.push(data);
  660. };
  661. }
  662. function start(tag, attrs, unary, start, end) {
  663. if (depth === 0) {
  664. currentBlock = {
  665. type: tag,
  666. content: '',
  667. start: end,
  668. end: 0,
  669. attrs: attrs.reduce((cumulated, { name, value }) => {
  670. cumulated[name] = value || true;
  671. return cumulated;
  672. }, {})
  673. };
  674. if (typeof currentBlock.attrs.src === 'string') {
  675. currentBlock.src = currentBlock.attrs.src;
  676. }
  677. if (isSpecialTag(tag)) {
  678. checkAttrs(currentBlock, attrs);
  679. if (tag === 'script') {
  680. const block = currentBlock;
  681. if (block.attrs.setup) {
  682. block.setup = currentBlock.attrs.setup;
  683. sfc.scriptSetup = block;
  684. }
  685. else {
  686. sfc.script = block;
  687. }
  688. }
  689. else if (tag === 'style') {
  690. sfc.styles.push(currentBlock);
  691. }
  692. else {
  693. sfc[tag] = currentBlock;
  694. }
  695. }
  696. else {
  697. // custom blocks
  698. sfc.customBlocks.push(currentBlock);
  699. }
  700. }
  701. if (!unary) {
  702. depth++;
  703. }
  704. }
  705. function checkAttrs(block, attrs) {
  706. for (let i = 0; i < attrs.length; i++) {
  707. const attr = attrs[i];
  708. if (attr.name === 'lang') {
  709. block.lang = attr.value;
  710. }
  711. if (attr.name === 'scoped') {
  712. block.scoped = true;
  713. }
  714. if (attr.name === 'module') {
  715. block.module = attr.value || true;
  716. }
  717. }
  718. }
  719. function end(tag, start) {
  720. if (depth === 1 && currentBlock) {
  721. currentBlock.end = start;
  722. let text = source.slice(currentBlock.start, currentBlock.end);
  723. if (options.deindent === true ||
  724. // by default, deindent unless it's script with default lang or (j/t)sx?
  725. (options.deindent !== false &&
  726. !(currentBlock.type === 'script' &&
  727. (!currentBlock.lang || /^(j|t)sx?$/.test(currentBlock.lang))))) {
  728. text = deIndent(text);
  729. }
  730. // pad content so that linters and pre-processors can output correct
  731. // line numbers in errors and warnings
  732. if (currentBlock.type !== 'template' && options.pad) {
  733. text = padContent(currentBlock, options.pad) + text;
  734. }
  735. currentBlock.content = text;
  736. currentBlock = null;
  737. }
  738. depth--;
  739. }
  740. function padContent(block, pad) {
  741. if (pad === 'space') {
  742. return source.slice(0, block.start).replace(replaceRE, ' ');
  743. }
  744. else {
  745. const offset = source.slice(0, block.start).split(splitRE$1).length;
  746. const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n';
  747. return Array(offset).join(padChar);
  748. }
  749. }
  750. parseHTML(source, {
  751. warn,
  752. start,
  753. end,
  754. outputSourceRange: options.outputSourceRange
  755. });
  756. return sfc;
  757. }
  758. function pad (hash, len) {
  759. while (hash.length < len) {
  760. hash = '0' + hash;
  761. }
  762. return hash;
  763. }
  764. function fold (hash, text) {
  765. var i;
  766. var chr;
  767. var len;
  768. if (text.length === 0) {
  769. return hash;
  770. }
  771. for (i = 0, len = text.length; i < len; i++) {
  772. chr = text.charCodeAt(i);
  773. hash = ((hash << 5) - hash) + chr;
  774. hash |= 0;
  775. }
  776. return hash < 0 ? hash * -2 : hash;
  777. }
  778. function foldObject (hash, o, seen) {
  779. return Object.keys(o).sort().reduce(foldKey, hash);
  780. function foldKey (hash, key) {
  781. return foldValue(hash, o[key], key, seen);
  782. }
  783. }
  784. function foldValue (input, value, key, seen) {
  785. var hash = fold(fold(fold(input, key), toString$1(value)), typeof value);
  786. if (value === null) {
  787. return fold(hash, 'null');
  788. }
  789. if (value === undefined) {
  790. return fold(hash, 'undefined');
  791. }
  792. if (typeof value === 'object' || typeof value === 'function') {
  793. if (seen.indexOf(value) !== -1) {
  794. return fold(hash, '[Circular]' + key);
  795. }
  796. seen.push(value);
  797. var objHash = foldObject(hash, value, seen);
  798. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  799. return objHash;
  800. }
  801. try {
  802. return fold(objHash, String(value.valueOf()))
  803. } catch (err) {
  804. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  805. }
  806. }
  807. return fold(hash, value.toString());
  808. }
  809. function toString$1 (o) {
  810. return Object.prototype.toString.call(o);
  811. }
  812. function sum (o) {
  813. return pad(foldValue(0, o, '', []).toString(16), 8);
  814. }
  815. var hashSum = sum;
  816. var iterator;
  817. var hasRequiredIterator;
  818. function requireIterator () {
  819. if (hasRequiredIterator) return iterator;
  820. hasRequiredIterator = 1;
  821. iterator = function (Yallist) {
  822. Yallist.prototype[Symbol.iterator] = function* () {
  823. for (let walker = this.head; walker; walker = walker.next) {
  824. yield walker.value;
  825. }
  826. };
  827. };
  828. return iterator;
  829. }
  830. var yallist = Yallist$1;
  831. Yallist$1.Node = Node;
  832. Yallist$1.create = Yallist$1;
  833. function Yallist$1 (list) {
  834. var self = this;
  835. if (!(self instanceof Yallist$1)) {
  836. self = new Yallist$1();
  837. }
  838. self.tail = null;
  839. self.head = null;
  840. self.length = 0;
  841. if (list && typeof list.forEach === 'function') {
  842. list.forEach(function (item) {
  843. self.push(item);
  844. });
  845. } else if (arguments.length > 0) {
  846. for (var i = 0, l = arguments.length; i < l; i++) {
  847. self.push(arguments[i]);
  848. }
  849. }
  850. return self
  851. }
  852. Yallist$1.prototype.removeNode = function (node) {
  853. if (node.list !== this) {
  854. throw new Error('removing node which does not belong to this list')
  855. }
  856. var next = node.next;
  857. var prev = node.prev;
  858. if (next) {
  859. next.prev = prev;
  860. }
  861. if (prev) {
  862. prev.next = next;
  863. }
  864. if (node === this.head) {
  865. this.head = next;
  866. }
  867. if (node === this.tail) {
  868. this.tail = prev;
  869. }
  870. node.list.length--;
  871. node.next = null;
  872. node.prev = null;
  873. node.list = null;
  874. return next
  875. };
  876. Yallist$1.prototype.unshiftNode = function (node) {
  877. if (node === this.head) {
  878. return
  879. }
  880. if (node.list) {
  881. node.list.removeNode(node);
  882. }
  883. var head = this.head;
  884. node.list = this;
  885. node.next = head;
  886. if (head) {
  887. head.prev = node;
  888. }
  889. this.head = node;
  890. if (!this.tail) {
  891. this.tail = node;
  892. }
  893. this.length++;
  894. };
  895. Yallist$1.prototype.pushNode = function (node) {
  896. if (node === this.tail) {
  897. return
  898. }
  899. if (node.list) {
  900. node.list.removeNode(node);
  901. }
  902. var tail = this.tail;
  903. node.list = this;
  904. node.prev = tail;
  905. if (tail) {
  906. tail.next = node;
  907. }
  908. this.tail = node;
  909. if (!this.head) {
  910. this.head = node;
  911. }
  912. this.length++;
  913. };
  914. Yallist$1.prototype.push = function () {
  915. for (var i = 0, l = arguments.length; i < l; i++) {
  916. push(this, arguments[i]);
  917. }
  918. return this.length
  919. };
  920. Yallist$1.prototype.unshift = function () {
  921. for (var i = 0, l = arguments.length; i < l; i++) {
  922. unshift(this, arguments[i]);
  923. }
  924. return this.length
  925. };
  926. Yallist$1.prototype.pop = function () {
  927. if (!this.tail) {
  928. return undefined
  929. }
  930. var res = this.tail.value;
  931. this.tail = this.tail.prev;
  932. if (this.tail) {
  933. this.tail.next = null;
  934. } else {
  935. this.head = null;
  936. }
  937. this.length--;
  938. return res
  939. };
  940. Yallist$1.prototype.shift = function () {
  941. if (!this.head) {
  942. return undefined
  943. }
  944. var res = this.head.value;
  945. this.head = this.head.next;
  946. if (this.head) {
  947. this.head.prev = null;
  948. } else {
  949. this.tail = null;
  950. }
  951. this.length--;
  952. return res
  953. };
  954. Yallist$1.prototype.forEach = function (fn, thisp) {
  955. thisp = thisp || this;
  956. for (var walker = this.head, i = 0; walker !== null; i++) {
  957. fn.call(thisp, walker.value, i, this);
  958. walker = walker.next;
  959. }
  960. };
  961. Yallist$1.prototype.forEachReverse = function (fn, thisp) {
  962. thisp = thisp || this;
  963. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  964. fn.call(thisp, walker.value, i, this);
  965. walker = walker.prev;
  966. }
  967. };
  968. Yallist$1.prototype.get = function (n) {
  969. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  970. // abort out of the list early if we hit a cycle
  971. walker = walker.next;
  972. }
  973. if (i === n && walker !== null) {
  974. return walker.value
  975. }
  976. };
  977. Yallist$1.prototype.getReverse = function (n) {
  978. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  979. // abort out of the list early if we hit a cycle
  980. walker = walker.prev;
  981. }
  982. if (i === n && walker !== null) {
  983. return walker.value
  984. }
  985. };
  986. Yallist$1.prototype.map = function (fn, thisp) {
  987. thisp = thisp || this;
  988. var res = new Yallist$1();
  989. for (var walker = this.head; walker !== null;) {
  990. res.push(fn.call(thisp, walker.value, this));
  991. walker = walker.next;
  992. }
  993. return res
  994. };
  995. Yallist$1.prototype.mapReverse = function (fn, thisp) {
  996. thisp = thisp || this;
  997. var res = new Yallist$1();
  998. for (var walker = this.tail; walker !== null;) {
  999. res.push(fn.call(thisp, walker.value, this));
  1000. walker = walker.prev;
  1001. }
  1002. return res
  1003. };
  1004. Yallist$1.prototype.reduce = function (fn, initial) {
  1005. var acc;
  1006. var walker = this.head;
  1007. if (arguments.length > 1) {
  1008. acc = initial;
  1009. } else if (this.head) {
  1010. walker = this.head.next;
  1011. acc = this.head.value;
  1012. } else {
  1013. throw new TypeError('Reduce of empty list with no initial value')
  1014. }
  1015. for (var i = 0; walker !== null; i++) {
  1016. acc = fn(acc, walker.value, i);
  1017. walker = walker.next;
  1018. }
  1019. return acc
  1020. };
  1021. Yallist$1.prototype.reduceReverse = function (fn, initial) {
  1022. var acc;
  1023. var walker = this.tail;
  1024. if (arguments.length > 1) {
  1025. acc = initial;
  1026. } else if (this.tail) {
  1027. walker = this.tail.prev;
  1028. acc = this.tail.value;
  1029. } else {
  1030. throw new TypeError('Reduce of empty list with no initial value')
  1031. }
  1032. for (var i = this.length - 1; walker !== null; i--) {
  1033. acc = fn(acc, walker.value, i);
  1034. walker = walker.prev;
  1035. }
  1036. return acc
  1037. };
  1038. Yallist$1.prototype.toArray = function () {
  1039. var arr = new Array(this.length);
  1040. for (var i = 0, walker = this.head; walker !== null; i++) {
  1041. arr[i] = walker.value;
  1042. walker = walker.next;
  1043. }
  1044. return arr
  1045. };
  1046. Yallist$1.prototype.toArrayReverse = function () {
  1047. var arr = new Array(this.length);
  1048. for (var i = 0, walker = this.tail; walker !== null; i++) {
  1049. arr[i] = walker.value;
  1050. walker = walker.prev;
  1051. }
  1052. return arr
  1053. };
  1054. Yallist$1.prototype.slice = function (from, to) {
  1055. to = to || this.length;
  1056. if (to < 0) {
  1057. to += this.length;
  1058. }
  1059. from = from || 0;
  1060. if (from < 0) {
  1061. from += this.length;
  1062. }
  1063. var ret = new Yallist$1();
  1064. if (to < from || to < 0) {
  1065. return ret
  1066. }
  1067. if (from < 0) {
  1068. from = 0;
  1069. }
  1070. if (to > this.length) {
  1071. to = this.length;
  1072. }
  1073. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  1074. walker = walker.next;
  1075. }
  1076. for (; walker !== null && i < to; i++, walker = walker.next) {
  1077. ret.push(walker.value);
  1078. }
  1079. return ret
  1080. };
  1081. Yallist$1.prototype.sliceReverse = function (from, to) {
  1082. to = to || this.length;
  1083. if (to < 0) {
  1084. to += this.length;
  1085. }
  1086. from = from || 0;
  1087. if (from < 0) {
  1088. from += this.length;
  1089. }
  1090. var ret = new Yallist$1();
  1091. if (to < from || to < 0) {
  1092. return ret
  1093. }
  1094. if (from < 0) {
  1095. from = 0;
  1096. }
  1097. if (to > this.length) {
  1098. to = this.length;
  1099. }
  1100. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  1101. walker = walker.prev;
  1102. }
  1103. for (; walker !== null && i > from; i--, walker = walker.prev) {
  1104. ret.push(walker.value);
  1105. }
  1106. return ret
  1107. };
  1108. Yallist$1.prototype.splice = function (start, deleteCount /*, ...nodes */) {
  1109. if (start > this.length) {
  1110. start = this.length - 1;
  1111. }
  1112. if (start < 0) {
  1113. start = this.length + start;
  1114. }
  1115. for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
  1116. walker = walker.next;
  1117. }
  1118. var ret = [];
  1119. for (var i = 0; walker && i < deleteCount; i++) {
  1120. ret.push(walker.value);
  1121. walker = this.removeNode(walker);
  1122. }
  1123. if (walker === null) {
  1124. walker = this.tail;
  1125. }
  1126. if (walker !== this.head && walker !== this.tail) {
  1127. walker = walker.prev;
  1128. }
  1129. for (var i = 2; i < arguments.length; i++) {
  1130. walker = insert(this, walker, arguments[i]);
  1131. }
  1132. return ret;
  1133. };
  1134. Yallist$1.prototype.reverse = function () {
  1135. var head = this.head;
  1136. var tail = this.tail;
  1137. for (var walker = head; walker !== null; walker = walker.prev) {
  1138. var p = walker.prev;
  1139. walker.prev = walker.next;
  1140. walker.next = p;
  1141. }
  1142. this.head = tail;
  1143. this.tail = head;
  1144. return this
  1145. };
  1146. function insert (self, node, value) {
  1147. var inserted = node === self.head ?
  1148. new Node(value, null, node, self) :
  1149. new Node(value, node, node.next, self);
  1150. if (inserted.next === null) {
  1151. self.tail = inserted;
  1152. }
  1153. if (inserted.prev === null) {
  1154. self.head = inserted;
  1155. }
  1156. self.length++;
  1157. return inserted
  1158. }
  1159. function push (self, item) {
  1160. self.tail = new Node(item, self.tail, null, self);
  1161. if (!self.head) {
  1162. self.head = self.tail;
  1163. }
  1164. self.length++;
  1165. }
  1166. function unshift (self, item) {
  1167. self.head = new Node(item, null, self.head, self);
  1168. if (!self.tail) {
  1169. self.tail = self.head;
  1170. }
  1171. self.length++;
  1172. }
  1173. function Node (value, prev, next, list) {
  1174. if (!(this instanceof Node)) {
  1175. return new Node(value, prev, next, list)
  1176. }
  1177. this.list = list;
  1178. this.value = value;
  1179. if (prev) {
  1180. prev.next = this;
  1181. this.prev = prev;
  1182. } else {
  1183. this.prev = null;
  1184. }
  1185. if (next) {
  1186. next.prev = this;
  1187. this.next = next;
  1188. } else {
  1189. this.next = null;
  1190. }
  1191. }
  1192. try {
  1193. // add if support for Symbol.iterator is present
  1194. requireIterator()(Yallist$1);
  1195. } catch (er) {}
  1196. // A linked list to keep track of recently-used-ness
  1197. const Yallist = yallist;
  1198. const MAX = Symbol('max');
  1199. const LENGTH = Symbol('length');
  1200. const LENGTH_CALCULATOR = Symbol('lengthCalculator');
  1201. const ALLOW_STALE = Symbol('allowStale');
  1202. const MAX_AGE = Symbol('maxAge');
  1203. const DISPOSE = Symbol('dispose');
  1204. const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
  1205. const LRU_LIST = Symbol('lruList');
  1206. const CACHE = Symbol('cache');
  1207. const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
  1208. const naiveLength = () => 1;
  1209. // lruList is a yallist where the head is the youngest
  1210. // item, and the tail is the oldest. the list contains the Hit
  1211. // objects as the entries.
  1212. // Each Hit object has a reference to its Yallist.Node. This
  1213. // never changes.
  1214. //
  1215. // cache is a Map (or PseudoMap) that matches the keys to
  1216. // the Yallist.Node object.
  1217. class LRUCache {
  1218. constructor (options) {
  1219. if (typeof options === 'number')
  1220. options = { max: options };
  1221. if (!options)
  1222. options = {};
  1223. if (options.max && (typeof options.max !== 'number' || options.max < 0))
  1224. throw new TypeError('max must be a non-negative number')
  1225. // Kind of weird to have a default max of Infinity, but oh well.
  1226. this[MAX] = options.max || Infinity;
  1227. const lc = options.length || naiveLength;
  1228. this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
  1229. this[ALLOW_STALE] = options.stale || false;
  1230. if (options.maxAge && typeof options.maxAge !== 'number')
  1231. throw new TypeError('maxAge must be a number')
  1232. this[MAX_AGE] = options.maxAge || 0;
  1233. this[DISPOSE] = options.dispose;
  1234. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  1235. this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
  1236. this.reset();
  1237. }
  1238. // resize the cache when the max changes.
  1239. set max (mL) {
  1240. if (typeof mL !== 'number' || mL < 0)
  1241. throw new TypeError('max must be a non-negative number')
  1242. this[MAX] = mL || Infinity;
  1243. trim(this);
  1244. }
  1245. get max () {
  1246. return this[MAX]
  1247. }
  1248. set allowStale (allowStale) {
  1249. this[ALLOW_STALE] = !!allowStale;
  1250. }
  1251. get allowStale () {
  1252. return this[ALLOW_STALE]
  1253. }
  1254. set maxAge (mA) {
  1255. if (typeof mA !== 'number')
  1256. throw new TypeError('maxAge must be a non-negative number')
  1257. this[MAX_AGE] = mA;
  1258. trim(this);
  1259. }
  1260. get maxAge () {
  1261. return this[MAX_AGE]
  1262. }
  1263. // resize the cache when the lengthCalculator changes.
  1264. set lengthCalculator (lC) {
  1265. if (typeof lC !== 'function')
  1266. lC = naiveLength;
  1267. if (lC !== this[LENGTH_CALCULATOR]) {
  1268. this[LENGTH_CALCULATOR] = lC;
  1269. this[LENGTH] = 0;
  1270. this[LRU_LIST].forEach(hit => {
  1271. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  1272. this[LENGTH] += hit.length;
  1273. });
  1274. }
  1275. trim(this);
  1276. }
  1277. get lengthCalculator () { return this[LENGTH_CALCULATOR] }
  1278. get length () { return this[LENGTH] }
  1279. get itemCount () { return this[LRU_LIST].length }
  1280. rforEach (fn, thisp) {
  1281. thisp = thisp || this;
  1282. for (let walker = this[LRU_LIST].tail; walker !== null;) {
  1283. const prev = walker.prev;
  1284. forEachStep(this, fn, walker, thisp);
  1285. walker = prev;
  1286. }
  1287. }
  1288. forEach (fn, thisp) {
  1289. thisp = thisp || this;
  1290. for (let walker = this[LRU_LIST].head; walker !== null;) {
  1291. const next = walker.next;
  1292. forEachStep(this, fn, walker, thisp);
  1293. walker = next;
  1294. }
  1295. }
  1296. keys () {
  1297. return this[LRU_LIST].toArray().map(k => k.key)
  1298. }
  1299. values () {
  1300. return this[LRU_LIST].toArray().map(k => k.value)
  1301. }
  1302. reset () {
  1303. if (this[DISPOSE] &&
  1304. this[LRU_LIST] &&
  1305. this[LRU_LIST].length) {
  1306. this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
  1307. }
  1308. this[CACHE] = new Map(); // hash of items by key
  1309. this[LRU_LIST] = new Yallist(); // list of items in order of use recency
  1310. this[LENGTH] = 0; // length of items in the list
  1311. }
  1312. dump () {
  1313. return this[LRU_LIST].map(hit =>
  1314. isStale(this, hit) ? false : {
  1315. k: hit.key,
  1316. v: hit.value,
  1317. e: hit.now + (hit.maxAge || 0)
  1318. }).toArray().filter(h => h)
  1319. }
  1320. dumpLru () {
  1321. return this[LRU_LIST]
  1322. }
  1323. set (key, value, maxAge) {
  1324. maxAge = maxAge || this[MAX_AGE];
  1325. if (maxAge && typeof maxAge !== 'number')
  1326. throw new TypeError('maxAge must be a number')
  1327. const now = maxAge ? Date.now() : 0;
  1328. const len = this[LENGTH_CALCULATOR](value, key);
  1329. if (this[CACHE].has(key)) {
  1330. if (len > this[MAX]) {
  1331. del(this, this[CACHE].get(key));
  1332. return false
  1333. }
  1334. const node = this[CACHE].get(key);
  1335. const item = node.value;
  1336. // dispose of the old one before overwriting
  1337. // split out into 2 ifs for better coverage tracking
  1338. if (this[DISPOSE]) {
  1339. if (!this[NO_DISPOSE_ON_SET])
  1340. this[DISPOSE](key, item.value);
  1341. }
  1342. item.now = now;
  1343. item.maxAge = maxAge;
  1344. item.value = value;
  1345. this[LENGTH] += len - item.length;
  1346. item.length = len;
  1347. this.get(key);
  1348. trim(this);
  1349. return true
  1350. }
  1351. const hit = new Entry(key, value, len, now, maxAge);
  1352. // oversized objects fall out of cache automatically.
  1353. if (hit.length > this[MAX]) {
  1354. if (this[DISPOSE])
  1355. this[DISPOSE](key, value);
  1356. return false
  1357. }
  1358. this[LENGTH] += hit.length;
  1359. this[LRU_LIST].unshift(hit);
  1360. this[CACHE].set(key, this[LRU_LIST].head);
  1361. trim(this);
  1362. return true
  1363. }
  1364. has (key) {
  1365. if (!this[CACHE].has(key)) return false
  1366. const hit = this[CACHE].get(key).value;
  1367. return !isStale(this, hit)
  1368. }
  1369. get (key) {
  1370. return get(this, key, true)
  1371. }
  1372. peek (key) {
  1373. return get(this, key, false)
  1374. }
  1375. pop () {
  1376. const node = this[LRU_LIST].tail;
  1377. if (!node)
  1378. return null
  1379. del(this, node);
  1380. return node.value
  1381. }
  1382. del (key) {
  1383. del(this, this[CACHE].get(key));
  1384. }
  1385. load (arr) {
  1386. // reset the cache
  1387. this.reset();
  1388. const now = Date.now();
  1389. // A previous serialized cache has the most recent items first
  1390. for (let l = arr.length - 1; l >= 0; l--) {
  1391. const hit = arr[l];
  1392. const expiresAt = hit.e || 0;
  1393. if (expiresAt === 0)
  1394. // the item was created without expiration in a non aged cache
  1395. this.set(hit.k, hit.v);
  1396. else {
  1397. const maxAge = expiresAt - now;
  1398. // dont add already expired items
  1399. if (maxAge > 0) {
  1400. this.set(hit.k, hit.v, maxAge);
  1401. }
  1402. }
  1403. }
  1404. }
  1405. prune () {
  1406. this[CACHE].forEach((value, key) => get(this, key, false));
  1407. }
  1408. }
  1409. const get = (self, key, doUse) => {
  1410. const node = self[CACHE].get(key);
  1411. if (node) {
  1412. const hit = node.value;
  1413. if (isStale(self, hit)) {
  1414. del(self, node);
  1415. if (!self[ALLOW_STALE])
  1416. return undefined
  1417. } else {
  1418. if (doUse) {
  1419. if (self[UPDATE_AGE_ON_GET])
  1420. node.value.now = Date.now();
  1421. self[LRU_LIST].unshiftNode(node);
  1422. }
  1423. }
  1424. return hit.value
  1425. }
  1426. };
  1427. const isStale = (self, hit) => {
  1428. if (!hit || (!hit.maxAge && !self[MAX_AGE]))
  1429. return false
  1430. const diff = Date.now() - hit.now;
  1431. return hit.maxAge ? diff > hit.maxAge
  1432. : self[MAX_AGE] && (diff > self[MAX_AGE])
  1433. };
  1434. const trim = self => {
  1435. if (self[LENGTH] > self[MAX]) {
  1436. for (let walker = self[LRU_LIST].tail;
  1437. self[LENGTH] > self[MAX] && walker !== null;) {
  1438. // We know that we're about to delete this one, and also
  1439. // what the next least recently used key will be, so just
  1440. // go ahead and set it now.
  1441. const prev = walker.prev;
  1442. del(self, walker);
  1443. walker = prev;
  1444. }
  1445. }
  1446. };
  1447. const del = (self, node) => {
  1448. if (node) {
  1449. const hit = node.value;
  1450. if (self[DISPOSE])
  1451. self[DISPOSE](hit.key, hit.value);
  1452. self[LENGTH] -= hit.length;
  1453. self[CACHE].delete(hit.key);
  1454. self[LRU_LIST].removeNode(node);
  1455. }
  1456. };
  1457. class Entry {
  1458. constructor (key, value, length, now, maxAge) {
  1459. this.key = key;
  1460. this.value = value;
  1461. this.length = length;
  1462. this.now = now;
  1463. this.maxAge = maxAge || 0;
  1464. }
  1465. }
  1466. const forEachStep = (self, fn, node, thisp) => {
  1467. let hit = node.value;
  1468. if (isStale(self, hit)) {
  1469. del(self, node);
  1470. if (!self[ALLOW_STALE])
  1471. hit = undefined;
  1472. }
  1473. if (hit)
  1474. fn.call(thisp, hit.value, hit.key, self);
  1475. };
  1476. var lruCache = LRUCache;
  1477. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1478. function encode(decoded) {
  1479. var sourceFileIndex = 0; // second field
  1480. var sourceCodeLine = 0; // third field
  1481. var sourceCodeColumn = 0; // fourth field
  1482. var nameIndex = 0; // fifth field
  1483. var mappings = '';
  1484. for (var i = 0; i < decoded.length; i++) {
  1485. var line = decoded[i];
  1486. if (i > 0)
  1487. mappings += ';';
  1488. if (line.length === 0)
  1489. continue;
  1490. var generatedCodeColumn = 0; // first field
  1491. var lineMappings = [];
  1492. for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
  1493. var segment = line_1[_i];
  1494. var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
  1495. generatedCodeColumn = segment[0];
  1496. if (segment.length > 1) {
  1497. segmentMappings +=
  1498. encodeInteger(segment[1] - sourceFileIndex) +
  1499. encodeInteger(segment[2] - sourceCodeLine) +
  1500. encodeInteger(segment[3] - sourceCodeColumn);
  1501. sourceFileIndex = segment[1];
  1502. sourceCodeLine = segment[2];
  1503. sourceCodeColumn = segment[3];
  1504. }
  1505. if (segment.length === 5) {
  1506. segmentMappings += encodeInteger(segment[4] - nameIndex);
  1507. nameIndex = segment[4];
  1508. }
  1509. lineMappings.push(segmentMappings);
  1510. }
  1511. mappings += lineMappings.join(',');
  1512. }
  1513. return mappings;
  1514. }
  1515. function encodeInteger(num) {
  1516. var result = '';
  1517. num = num < 0 ? (-num << 1) | 1 : num << 1;
  1518. do {
  1519. var clamped = num & 31;
  1520. num >>>= 5;
  1521. if (num > 0) {
  1522. clamped |= 32;
  1523. }
  1524. result += chars[clamped];
  1525. } while (num > 0);
  1526. return result;
  1527. }
  1528. var BitSet = function BitSet(arg) {
  1529. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  1530. };
  1531. BitSet.prototype.add = function add (n) {
  1532. this.bits[n >> 5] |= 1 << (n & 31);
  1533. };
  1534. BitSet.prototype.has = function has (n) {
  1535. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  1536. };
  1537. var Chunk = function Chunk(start, end, content) {
  1538. this.start = start;
  1539. this.end = end;
  1540. this.original = content;
  1541. this.intro = '';
  1542. this.outro = '';
  1543. this.content = content;
  1544. this.storeName = false;
  1545. this.edited = false;
  1546. // we make these non-enumerable, for sanity while debugging
  1547. Object.defineProperties(this, {
  1548. previous: { writable: true, value: null },
  1549. next: { writable: true, value: null },
  1550. });
  1551. };
  1552. Chunk.prototype.appendLeft = function appendLeft (content) {
  1553. this.outro += content;
  1554. };
  1555. Chunk.prototype.appendRight = function appendRight (content) {
  1556. this.intro = this.intro + content;
  1557. };
  1558. Chunk.prototype.clone = function clone () {
  1559. var chunk = new Chunk(this.start, this.end, this.original);
  1560. chunk.intro = this.intro;
  1561. chunk.outro = this.outro;
  1562. chunk.content = this.content;
  1563. chunk.storeName = this.storeName;
  1564. chunk.edited = this.edited;
  1565. return chunk;
  1566. };
  1567. Chunk.prototype.contains = function contains (index) {
  1568. return this.start < index && index < this.end;
  1569. };
  1570. Chunk.prototype.eachNext = function eachNext (fn) {
  1571. var chunk = this;
  1572. while (chunk) {
  1573. fn(chunk);
  1574. chunk = chunk.next;
  1575. }
  1576. };
  1577. Chunk.prototype.eachPrevious = function eachPrevious (fn) {
  1578. var chunk = this;
  1579. while (chunk) {
  1580. fn(chunk);
  1581. chunk = chunk.previous;
  1582. }
  1583. };
  1584. Chunk.prototype.edit = function edit (content, storeName, contentOnly) {
  1585. this.content = content;
  1586. if (!contentOnly) {
  1587. this.intro = '';
  1588. this.outro = '';
  1589. }
  1590. this.storeName = storeName;
  1591. this.edited = true;
  1592. return this;
  1593. };
  1594. Chunk.prototype.prependLeft = function prependLeft (content) {
  1595. this.outro = content + this.outro;
  1596. };
  1597. Chunk.prototype.prependRight = function prependRight (content) {
  1598. this.intro = content + this.intro;
  1599. };
  1600. Chunk.prototype.split = function split (index) {
  1601. var sliceIndex = index - this.start;
  1602. var originalBefore = this.original.slice(0, sliceIndex);
  1603. var originalAfter = this.original.slice(sliceIndex);
  1604. this.original = originalBefore;
  1605. var newChunk = new Chunk(index, this.end, originalAfter);
  1606. newChunk.outro = this.outro;
  1607. this.outro = '';
  1608. this.end = index;
  1609. if (this.edited) {
  1610. // TODO is this block necessary?...
  1611. newChunk.edit('', false);
  1612. this.content = '';
  1613. } else {
  1614. this.content = originalBefore;
  1615. }
  1616. newChunk.next = this.next;
  1617. if (newChunk.next) { newChunk.next.previous = newChunk; }
  1618. newChunk.previous = this;
  1619. this.next = newChunk;
  1620. return newChunk;
  1621. };
  1622. Chunk.prototype.toString = function toString () {
  1623. return this.intro + this.content + this.outro;
  1624. };
  1625. Chunk.prototype.trimEnd = function trimEnd (rx) {
  1626. this.outro = this.outro.replace(rx, '');
  1627. if (this.outro.length) { return true; }
  1628. var trimmed = this.content.replace(rx, '');
  1629. if (trimmed.length) {
  1630. if (trimmed !== this.content) {
  1631. this.split(this.start + trimmed.length).edit('', undefined, true);
  1632. }
  1633. return true;
  1634. } else {
  1635. this.edit('', undefined, true);
  1636. this.intro = this.intro.replace(rx, '');
  1637. if (this.intro.length) { return true; }
  1638. }
  1639. };
  1640. Chunk.prototype.trimStart = function trimStart (rx) {
  1641. this.intro = this.intro.replace(rx, '');
  1642. if (this.intro.length) { return true; }
  1643. var trimmed = this.content.replace(rx, '');
  1644. if (trimmed.length) {
  1645. if (trimmed !== this.content) {
  1646. this.split(this.end - trimmed.length);
  1647. this.edit('', undefined, true);
  1648. }
  1649. return true;
  1650. } else {
  1651. this.edit('', undefined, true);
  1652. this.outro = this.outro.replace(rx, '');
  1653. if (this.outro.length) { return true; }
  1654. }
  1655. };
  1656. var btoa = function () {
  1657. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  1658. };
  1659. if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
  1660. btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
  1661. } else if (typeof Buffer === 'function') {
  1662. btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
  1663. }
  1664. var SourceMap = function SourceMap(properties) {
  1665. this.version = 3;
  1666. this.file = properties.file;
  1667. this.sources = properties.sources;
  1668. this.sourcesContent = properties.sourcesContent;
  1669. this.names = properties.names;
  1670. this.mappings = encode(properties.mappings);
  1671. };
  1672. SourceMap.prototype.toString = function toString () {
  1673. return JSON.stringify(this);
  1674. };
  1675. SourceMap.prototype.toUrl = function toUrl () {
  1676. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  1677. };
  1678. function guessIndent(code) {
  1679. var lines = code.split('\n');
  1680. var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
  1681. var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
  1682. if (tabbed.length === 0 && spaced.length === 0) {
  1683. return null;
  1684. }
  1685. // More lines tabbed than spaced? Assume tabs, and
  1686. // default to tabs in the case of a tie (or nothing
  1687. // to go on)
  1688. if (tabbed.length >= spaced.length) {
  1689. return '\t';
  1690. }
  1691. // Otherwise, we need to guess the multiple
  1692. var min = spaced.reduce(function (previous, current) {
  1693. var numSpaces = /^ +/.exec(current)[0].length;
  1694. return Math.min(numSpaces, previous);
  1695. }, Infinity);
  1696. return new Array(min + 1).join(' ');
  1697. }
  1698. function getRelativePath(from, to) {
  1699. var fromParts = from.split(/[/\\]/);
  1700. var toParts = to.split(/[/\\]/);
  1701. fromParts.pop(); // get dirname
  1702. while (fromParts[0] === toParts[0]) {
  1703. fromParts.shift();
  1704. toParts.shift();
  1705. }
  1706. if (fromParts.length) {
  1707. var i = fromParts.length;
  1708. while (i--) { fromParts[i] = '..'; }
  1709. }
  1710. return fromParts.concat(toParts).join('/');
  1711. }
  1712. var toString = Object.prototype.toString;
  1713. function isObject(thing) {
  1714. return toString.call(thing) === '[object Object]';
  1715. }
  1716. function getLocator(source) {
  1717. var originalLines = source.split('\n');
  1718. var lineOffsets = [];
  1719. for (var i = 0, pos = 0; i < originalLines.length; i++) {
  1720. lineOffsets.push(pos);
  1721. pos += originalLines[i].length + 1;
  1722. }
  1723. return function locate(index) {
  1724. var i = 0;
  1725. var j = lineOffsets.length;
  1726. while (i < j) {
  1727. var m = (i + j) >> 1;
  1728. if (index < lineOffsets[m]) {
  1729. j = m;
  1730. } else {
  1731. i = m + 1;
  1732. }
  1733. }
  1734. var line = i - 1;
  1735. var column = index - lineOffsets[line];
  1736. return { line: line, column: column };
  1737. };
  1738. }
  1739. var Mappings = function Mappings(hires) {
  1740. this.hires = hires;
  1741. this.generatedCodeLine = 0;
  1742. this.generatedCodeColumn = 0;
  1743. this.raw = [];
  1744. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  1745. this.pending = null;
  1746. };
  1747. Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) {
  1748. if (content.length) {
  1749. var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  1750. if (nameIndex >= 0) {
  1751. segment.push(nameIndex);
  1752. }
  1753. this.rawSegments.push(segment);
  1754. } else if (this.pending) {
  1755. this.rawSegments.push(this.pending);
  1756. }
  1757. this.advance(content);
  1758. this.pending = null;
  1759. };
  1760. Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
  1761. var originalCharIndex = chunk.start;
  1762. var first = true;
  1763. while (originalCharIndex < chunk.end) {
  1764. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  1765. this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
  1766. }
  1767. if (original[originalCharIndex] === '\n') {
  1768. loc.line += 1;
  1769. loc.column = 0;
  1770. this.generatedCodeLine += 1;
  1771. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  1772. this.generatedCodeColumn = 0;
  1773. first = true;
  1774. } else {
  1775. loc.column += 1;
  1776. this.generatedCodeColumn += 1;
  1777. first = false;
  1778. }
  1779. originalCharIndex += 1;
  1780. }
  1781. this.pending = null;
  1782. };
  1783. Mappings.prototype.advance = function advance (str) {
  1784. if (!str) { return; }
  1785. var lines = str.split('\n');
  1786. if (lines.length > 1) {
  1787. for (var i = 0; i < lines.length - 1; i++) {
  1788. this.generatedCodeLine++;
  1789. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  1790. }
  1791. this.generatedCodeColumn = 0;
  1792. }
  1793. this.generatedCodeColumn += lines[lines.length - 1].length;
  1794. };
  1795. var n = '\n';
  1796. var warned = {
  1797. insertLeft: false,
  1798. insertRight: false,
  1799. storeName: false,
  1800. };
  1801. var MagicString = function MagicString(string, options) {
  1802. if ( options === void 0 ) options = {};
  1803. var chunk = new Chunk(0, string.length, string);
  1804. Object.defineProperties(this, {
  1805. original: { writable: true, value: string },
  1806. outro: { writable: true, value: '' },
  1807. intro: { writable: true, value: '' },
  1808. firstChunk: { writable: true, value: chunk },
  1809. lastChunk: { writable: true, value: chunk },
  1810. lastSearchedChunk: { writable: true, value: chunk },
  1811. byStart: { writable: true, value: {} },
  1812. byEnd: { writable: true, value: {} },
  1813. filename: { writable: true, value: options.filename },
  1814. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  1815. sourcemapLocations: { writable: true, value: new BitSet() },
  1816. storedNames: { writable: true, value: {} },
  1817. indentStr: { writable: true, value: guessIndent(string) },
  1818. });
  1819. this.byStart[0] = chunk;
  1820. this.byEnd[string.length] = chunk;
  1821. };
  1822. MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) {
  1823. this.sourcemapLocations.add(char);
  1824. };
  1825. MagicString.prototype.append = function append (content) {
  1826. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  1827. this.outro += content;
  1828. return this;
  1829. };
  1830. MagicString.prototype.appendLeft = function appendLeft (index, content) {
  1831. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  1832. this._split(index);
  1833. var chunk = this.byEnd[index];
  1834. if (chunk) {
  1835. chunk.appendLeft(content);
  1836. } else {
  1837. this.intro += content;
  1838. }
  1839. return this;
  1840. };
  1841. MagicString.prototype.appendRight = function appendRight (index, content) {
  1842. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  1843. this._split(index);
  1844. var chunk = this.byStart[index];
  1845. if (chunk) {
  1846. chunk.appendRight(content);
  1847. } else {
  1848. this.outro += content;
  1849. }
  1850. return this;
  1851. };
  1852. MagicString.prototype.clone = function clone () {
  1853. var cloned = new MagicString(this.original, { filename: this.filename });
  1854. var originalChunk = this.firstChunk;
  1855. var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  1856. while (originalChunk) {
  1857. cloned.byStart[clonedChunk.start] = clonedChunk;
  1858. cloned.byEnd[clonedChunk.end] = clonedChunk;
  1859. var nextOriginalChunk = originalChunk.next;
  1860. var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  1861. if (nextClonedChunk) {
  1862. clonedChunk.next = nextClonedChunk;
  1863. nextClonedChunk.previous = clonedChunk;
  1864. clonedChunk = nextClonedChunk;
  1865. }
  1866. originalChunk = nextOriginalChunk;
  1867. }
  1868. cloned.lastChunk = clonedChunk;
  1869. if (this.indentExclusionRanges) {
  1870. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  1871. }
  1872. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  1873. cloned.intro = this.intro;
  1874. cloned.outro = this.outro;
  1875. return cloned;
  1876. };
  1877. MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) {
  1878. var this$1$1 = this;
  1879. options = options || {};
  1880. var sourceIndex = 0;
  1881. var names = Object.keys(this.storedNames);
  1882. var mappings = new Mappings(options.hires);
  1883. var locate = getLocator(this.original);
  1884. if (this.intro) {
  1885. mappings.advance(this.intro);
  1886. }
  1887. this.firstChunk.eachNext(function (chunk) {
  1888. var loc = locate(chunk.start);
  1889. if (chunk.intro.length) { mappings.advance(chunk.intro); }
  1890. if (chunk.edited) {
  1891. mappings.addEdit(
  1892. sourceIndex,
  1893. chunk.content,
  1894. loc,
  1895. chunk.storeName ? names.indexOf(chunk.original) : -1
  1896. );
  1897. } else {
  1898. mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations);
  1899. }
  1900. if (chunk.outro.length) { mappings.advance(chunk.outro); }
  1901. });
  1902. return {
  1903. file: options.file ? options.file.split(/[/\\]/).pop() : null,
  1904. sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
  1905. sourcesContent: options.includeContent ? [this.original] : [null],
  1906. names: names,
  1907. mappings: mappings.raw,
  1908. };
  1909. };
  1910. MagicString.prototype.generateMap = function generateMap (options) {
  1911. return new SourceMap(this.generateDecodedMap(options));
  1912. };
  1913. MagicString.prototype.getIndentString = function getIndentString () {
  1914. return this.indentStr === null ? '\t' : this.indentStr;
  1915. };
  1916. MagicString.prototype.indent = function indent (indentStr, options) {
  1917. var pattern = /^[^\r\n]/gm;
  1918. if (isObject(indentStr)) {
  1919. options = indentStr;
  1920. indentStr = undefined;
  1921. }
  1922. indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
  1923. if (indentStr === '') { return this; } // noop
  1924. options = options || {};
  1925. // Process exclusion ranges
  1926. var isExcluded = {};
  1927. if (options.exclude) {
  1928. var exclusions =
  1929. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  1930. exclusions.forEach(function (exclusion) {
  1931. for (var i = exclusion[0]; i < exclusion[1]; i += 1) {
  1932. isExcluded[i] = true;
  1933. }
  1934. });
  1935. }
  1936. var shouldIndentNextCharacter = options.indentStart !== false;
  1937. var replacer = function (match) {
  1938. if (shouldIndentNextCharacter) { return ("" + indentStr + match); }
  1939. shouldIndentNextCharacter = true;
  1940. return match;
  1941. };
  1942. this.intro = this.intro.replace(pattern, replacer);
  1943. var charIndex = 0;
  1944. var chunk = this.firstChunk;
  1945. while (chunk) {
  1946. var end = chunk.end;
  1947. if (chunk.edited) {
  1948. if (!isExcluded[charIndex]) {
  1949. chunk.content = chunk.content.replace(pattern, replacer);
  1950. if (chunk.content.length) {
  1951. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  1952. }
  1953. }
  1954. } else {
  1955. charIndex = chunk.start;
  1956. while (charIndex < end) {
  1957. if (!isExcluded[charIndex]) {
  1958. var char = this.original[charIndex];
  1959. if (char === '\n') {
  1960. shouldIndentNextCharacter = true;
  1961. } else if (char !== '\r' && shouldIndentNextCharacter) {
  1962. shouldIndentNextCharacter = false;
  1963. if (charIndex === chunk.start) {
  1964. chunk.prependRight(indentStr);
  1965. } else {
  1966. this._splitChunk(chunk, charIndex);
  1967. chunk = chunk.next;
  1968. chunk.prependRight(indentStr);
  1969. }
  1970. }
  1971. }
  1972. charIndex += 1;
  1973. }
  1974. }
  1975. charIndex = chunk.end;
  1976. chunk = chunk.next;
  1977. }
  1978. this.outro = this.outro.replace(pattern, replacer);
  1979. return this;
  1980. };
  1981. MagicString.prototype.insert = function insert () {
  1982. throw new Error(
  1983. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
  1984. );
  1985. };
  1986. MagicString.prototype.insertLeft = function insertLeft (index, content) {
  1987. if (!warned.insertLeft) {
  1988. console.warn(
  1989. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
  1990. ); // eslint-disable-line no-console
  1991. warned.insertLeft = true;
  1992. }
  1993. return this.appendLeft(index, content);
  1994. };
  1995. MagicString.prototype.insertRight = function insertRight (index, content) {
  1996. if (!warned.insertRight) {
  1997. console.warn(
  1998. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
  1999. ); // eslint-disable-line no-console
  2000. warned.insertRight = true;
  2001. }
  2002. return this.prependRight(index, content);
  2003. };
  2004. MagicString.prototype.move = function move (start, end, index) {
  2005. if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); }
  2006. this._split(start);
  2007. this._split(end);
  2008. this._split(index);
  2009. var first = this.byStart[start];
  2010. var last = this.byEnd[end];
  2011. var oldLeft = first.previous;
  2012. var oldRight = last.next;
  2013. var newRight = this.byStart[index];
  2014. if (!newRight && last === this.lastChunk) { return this; }
  2015. var newLeft = newRight ? newRight.previous : this.lastChunk;
  2016. if (oldLeft) { oldLeft.next = oldRight; }
  2017. if (oldRight) { oldRight.previous = oldLeft; }
  2018. if (newLeft) { newLeft.next = first; }
  2019. if (newRight) { newRight.previous = last; }
  2020. if (!first.previous) { this.firstChunk = last.next; }
  2021. if (!last.next) {
  2022. this.lastChunk = first.previous;
  2023. this.lastChunk.next = null;
  2024. }
  2025. first.previous = newLeft;
  2026. last.next = newRight || null;
  2027. if (!newLeft) { this.firstChunk = first; }
  2028. if (!newRight) { this.lastChunk = last; }
  2029. return this;
  2030. };
  2031. MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
  2032. if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
  2033. while (start < 0) { start += this.original.length; }
  2034. while (end < 0) { end += this.original.length; }
  2035. if (end > this.original.length) { throw new Error('end is out of bounds'); }
  2036. if (start === end)
  2037. { throw new Error(
  2038. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
  2039. ); }
  2040. this._split(start);
  2041. this._split(end);
  2042. if (options === true) {
  2043. if (!warned.storeName) {
  2044. console.warn(
  2045. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
  2046. ); // eslint-disable-line no-console
  2047. warned.storeName = true;
  2048. }
  2049. options = { storeName: true };
  2050. }
  2051. var storeName = options !== undefined ? options.storeName : false;
  2052. var contentOnly = options !== undefined ? options.contentOnly : false;
  2053. if (storeName) {
  2054. var original = this.original.slice(start, end);
  2055. Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });
  2056. }
  2057. var first = this.byStart[start];
  2058. var last = this.byEnd[end];
  2059. if (first) {
  2060. var chunk = first;
  2061. while (chunk !== last) {
  2062. if (chunk.next !== this.byStart[chunk.end]) {
  2063. throw new Error('Cannot overwrite across a split point');
  2064. }
  2065. chunk = chunk.next;
  2066. chunk.edit('', false);
  2067. }
  2068. first.edit(content, storeName, contentOnly);
  2069. } else {
  2070. // must be inserting at the end
  2071. var newChunk = new Chunk(start, end, '').edit(content, storeName);
  2072. // TODO last chunk in the array may not be the last chunk, if it's moved...
  2073. last.next = newChunk;
  2074. newChunk.previous = last;
  2075. }
  2076. return this;
  2077. };
  2078. MagicString.prototype.prepend = function prepend (content) {
  2079. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  2080. this.intro = content + this.intro;
  2081. return this;
  2082. };
  2083. MagicString.prototype.prependLeft = function prependLeft (index, content) {
  2084. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  2085. this._split(index);
  2086. var chunk = this.byEnd[index];
  2087. if (chunk) {
  2088. chunk.prependLeft(content);
  2089. } else {
  2090. this.intro = content + this.intro;
  2091. }
  2092. return this;
  2093. };
  2094. MagicString.prototype.prependRight = function prependRight (index, content) {
  2095. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  2096. this._split(index);
  2097. var chunk = this.byStart[index];
  2098. if (chunk) {
  2099. chunk.prependRight(content);
  2100. } else {
  2101. this.outro = content + this.outro;
  2102. }
  2103. return this;
  2104. };
  2105. MagicString.prototype.remove = function remove (start, end) {
  2106. while (start < 0) { start += this.original.length; }
  2107. while (end < 0) { end += this.original.length; }
  2108. if (start === end) { return this; }
  2109. if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); }
  2110. if (start > end) { throw new Error('end must be greater than start'); }
  2111. this._split(start);
  2112. this._split(end);
  2113. var chunk = this.byStart[start];
  2114. while (chunk) {
  2115. chunk.intro = '';
  2116. chunk.outro = '';
  2117. chunk.edit('');
  2118. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  2119. }
  2120. return this;
  2121. };
  2122. MagicString.prototype.lastChar = function lastChar () {
  2123. if (this.outro.length) { return this.outro[this.outro.length - 1]; }
  2124. var chunk = this.lastChunk;
  2125. do {
  2126. if (chunk.outro.length) { return chunk.outro[chunk.outro.length - 1]; }
  2127. if (chunk.content.length) { return chunk.content[chunk.content.length - 1]; }
  2128. if (chunk.intro.length) { return chunk.intro[chunk.intro.length - 1]; }
  2129. } while ((chunk = chunk.previous));
  2130. if (this.intro.length) { return this.intro[this.intro.length - 1]; }
  2131. return '';
  2132. };
  2133. MagicString.prototype.lastLine = function lastLine () {
  2134. var lineIndex = this.outro.lastIndexOf(n);
  2135. if (lineIndex !== -1) { return this.outro.substr(lineIndex + 1); }
  2136. var lineStr = this.outro;
  2137. var chunk = this.lastChunk;
  2138. do {
  2139. if (chunk.outro.length > 0) {
  2140. lineIndex = chunk.outro.lastIndexOf(n);
  2141. if (lineIndex !== -1) { return chunk.outro.substr(lineIndex + 1) + lineStr; }
  2142. lineStr = chunk.outro + lineStr;
  2143. }
  2144. if (chunk.content.length > 0) {
  2145. lineIndex = chunk.content.lastIndexOf(n);
  2146. if (lineIndex !== -1) { return chunk.content.substr(lineIndex + 1) + lineStr; }
  2147. lineStr = chunk.content + lineStr;
  2148. }
  2149. if (chunk.intro.length > 0) {
  2150. lineIndex = chunk.intro.lastIndexOf(n);
  2151. if (lineIndex !== -1) { return chunk.intro.substr(lineIndex + 1) + lineStr; }
  2152. lineStr = chunk.intro + lineStr;
  2153. }
  2154. } while ((chunk = chunk.previous));
  2155. lineIndex = this.intro.lastIndexOf(n);
  2156. if (lineIndex !== -1) { return this.intro.substr(lineIndex + 1) + lineStr; }
  2157. return this.intro + lineStr;
  2158. };
  2159. MagicString.prototype.slice = function slice (start, end) {
  2160. if ( start === void 0 ) start = 0;
  2161. if ( end === void 0 ) end = this.original.length;
  2162. while (start < 0) { start += this.original.length; }
  2163. while (end < 0) { end += this.original.length; }
  2164. var result = '';
  2165. // find start chunk
  2166. var chunk = this.firstChunk;
  2167. while (chunk && (chunk.start > start || chunk.end <= start)) {
  2168. // found end chunk before start
  2169. if (chunk.start < end && chunk.end >= end) {
  2170. return result;
  2171. }
  2172. chunk = chunk.next;
  2173. }
  2174. if (chunk && chunk.edited && chunk.start !== start)
  2175. { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
  2176. var startChunk = chunk;
  2177. while (chunk) {
  2178. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  2179. result += chunk.intro;
  2180. }
  2181. var containsEnd = chunk.start < end && chunk.end >= end;
  2182. if (containsEnd && chunk.edited && chunk.end !== end)
  2183. { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
  2184. var sliceStart = startChunk === chunk ? start - chunk.start : 0;
  2185. var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  2186. result += chunk.content.slice(sliceStart, sliceEnd);
  2187. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  2188. result += chunk.outro;
  2189. }
  2190. if (containsEnd) {
  2191. break;
  2192. }
  2193. chunk = chunk.next;
  2194. }
  2195. return result;
  2196. };
  2197. // TODO deprecate this? not really very useful
  2198. MagicString.prototype.snip = function snip (start, end) {
  2199. var clone = this.clone();
  2200. clone.remove(0, start);
  2201. clone.remove(end, clone.original.length);
  2202. return clone;
  2203. };
  2204. MagicString.prototype._split = function _split (index) {
  2205. if (this.byStart[index] || this.byEnd[index]) { return; }
  2206. var chunk = this.lastSearchedChunk;
  2207. var searchForward = index > chunk.end;
  2208. while (chunk) {
  2209. if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
  2210. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  2211. }
  2212. };
  2213. MagicString.prototype._splitChunk = function _splitChunk (chunk, index) {
  2214. if (chunk.edited && chunk.content.length) {
  2215. // zero-length edited chunks are a special case (overlapping replacements)
  2216. var loc = getLocator(this.original)(index);
  2217. throw new Error(
  2218. ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")")
  2219. );
  2220. }
  2221. var newChunk = chunk.split(index);
  2222. this.byEnd[index] = chunk;
  2223. this.byStart[index] = newChunk;
  2224. this.byEnd[newChunk.end] = newChunk;
  2225. if (chunk === this.lastChunk) { this.lastChunk = newChunk; }
  2226. this.lastSearchedChunk = chunk;
  2227. return true;
  2228. };
  2229. MagicString.prototype.toString = function toString () {
  2230. var str = this.intro;
  2231. var chunk = this.firstChunk;
  2232. while (chunk) {
  2233. str += chunk.toString();
  2234. chunk = chunk.next;
  2235. }
  2236. return str + this.outro;
  2237. };
  2238. MagicString.prototype.isEmpty = function isEmpty () {
  2239. var chunk = this.firstChunk;
  2240. do {
  2241. if (
  2242. (chunk.intro.length && chunk.intro.trim()) ||
  2243. (chunk.content.length && chunk.content.trim()) ||
  2244. (chunk.outro.length && chunk.outro.trim())
  2245. )
  2246. { return false; }
  2247. } while ((chunk = chunk.next));
  2248. return true;
  2249. };
  2250. MagicString.prototype.length = function length () {
  2251. var chunk = this.firstChunk;
  2252. var length = 0;
  2253. do {
  2254. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  2255. } while ((chunk = chunk.next));
  2256. return length;
  2257. };
  2258. MagicString.prototype.trimLines = function trimLines () {
  2259. return this.trim('[\\r\\n]');
  2260. };
  2261. MagicString.prototype.trim = function trim (charType) {
  2262. return this.trimStart(charType).trimEnd(charType);
  2263. };
  2264. MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
  2265. var rx = new RegExp((charType || '\\s') + '+$');
  2266. this.outro = this.outro.replace(rx, '');
  2267. if (this.outro.length) { return true; }
  2268. var chunk = this.lastChunk;
  2269. do {
  2270. var end = chunk.end;
  2271. var aborted = chunk.trimEnd(rx);
  2272. // if chunk was trimmed, we have a new lastChunk
  2273. if (chunk.end !== end) {
  2274. if (this.lastChunk === chunk) {
  2275. this.lastChunk = chunk.next;
  2276. }
  2277. this.byEnd[chunk.end] = chunk;
  2278. this.byStart[chunk.next.start] = chunk.next;
  2279. this.byEnd[chunk.next.end] = chunk.next;
  2280. }
  2281. if (aborted) { return true; }
  2282. chunk = chunk.previous;
  2283. } while (chunk);
  2284. return false;
  2285. };
  2286. MagicString.prototype.trimEnd = function trimEnd (charType) {
  2287. this.trimEndAborted(charType);
  2288. return this;
  2289. };
  2290. MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
  2291. var rx = new RegExp('^' + (charType || '\\s') + '+');
  2292. this.intro = this.intro.replace(rx, '');
  2293. if (this.intro.length) { return true; }
  2294. var chunk = this.firstChunk;
  2295. do {
  2296. var end = chunk.end;
  2297. var aborted = chunk.trimStart(rx);
  2298. if (chunk.end !== end) {
  2299. // special case...
  2300. if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
  2301. this.byEnd[chunk.end] = chunk;
  2302. this.byStart[chunk.next.start] = chunk.next;
  2303. this.byEnd[chunk.next.end] = chunk.next;
  2304. }
  2305. if (aborted) { return true; }
  2306. chunk = chunk.next;
  2307. } while (chunk);
  2308. return false;
  2309. };
  2310. MagicString.prototype.trimStart = function trimStart (charType) {
  2311. this.trimStartAborted(charType);
  2312. return this;
  2313. };
  2314. // @ts-check
  2315. /** @typedef { import('estree').BaseNode} BaseNode */
  2316. /** @typedef {{
  2317. skip: () => void;
  2318. remove: () => void;
  2319. replace: (node: BaseNode) => void;
  2320. }} WalkerContext */
  2321. class WalkerBase {
  2322. constructor() {
  2323. /** @type {boolean} */
  2324. this.should_skip = false;
  2325. /** @type {boolean} */
  2326. this.should_remove = false;
  2327. /** @type {BaseNode | null} */
  2328. this.replacement = null;
  2329. /** @type {WalkerContext} */
  2330. this.context = {
  2331. skip: () => (this.should_skip = true),
  2332. remove: () => (this.should_remove = true),
  2333. replace: (node) => (this.replacement = node)
  2334. };
  2335. }
  2336. /**
  2337. *
  2338. * @param {any} parent
  2339. * @param {string} prop
  2340. * @param {number} index
  2341. * @param {BaseNode} node
  2342. */
  2343. replace(parent, prop, index, node) {
  2344. if (parent) {
  2345. if (index !== null) {
  2346. parent[prop][index] = node;
  2347. } else {
  2348. parent[prop] = node;
  2349. }
  2350. }
  2351. }
  2352. /**
  2353. *
  2354. * @param {any} parent
  2355. * @param {string} prop
  2356. * @param {number} index
  2357. */
  2358. remove(parent, prop, index) {
  2359. if (parent) {
  2360. if (index !== null) {
  2361. parent[prop].splice(index, 1);
  2362. } else {
  2363. delete parent[prop];
  2364. }
  2365. }
  2366. }
  2367. }
  2368. // @ts-check
  2369. /** @typedef { import('estree').BaseNode} BaseNode */
  2370. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  2371. /** @typedef {(
  2372. * this: WalkerContext,
  2373. * node: BaseNode,
  2374. * parent: BaseNode,
  2375. * key: string,
  2376. * index: number
  2377. * ) => void} SyncHandler */
  2378. class SyncWalker extends WalkerBase {
  2379. /**
  2380. *
  2381. * @param {SyncHandler} enter
  2382. * @param {SyncHandler} leave
  2383. */
  2384. constructor(enter, leave) {
  2385. super();
  2386. /** @type {SyncHandler} */
  2387. this.enter = enter;
  2388. /** @type {SyncHandler} */
  2389. this.leave = leave;
  2390. }
  2391. /**
  2392. *
  2393. * @param {BaseNode} node
  2394. * @param {BaseNode} parent
  2395. * @param {string} [prop]
  2396. * @param {number} [index]
  2397. * @returns {BaseNode}
  2398. */
  2399. visit(node, parent, prop, index) {
  2400. if (node) {
  2401. if (this.enter) {
  2402. const _should_skip = this.should_skip;
  2403. const _should_remove = this.should_remove;
  2404. const _replacement = this.replacement;
  2405. this.should_skip = false;
  2406. this.should_remove = false;
  2407. this.replacement = null;
  2408. this.enter.call(this.context, node, parent, prop, index);
  2409. if (this.replacement) {
  2410. node = this.replacement;
  2411. this.replace(parent, prop, index, node);
  2412. }
  2413. if (this.should_remove) {
  2414. this.remove(parent, prop, index);
  2415. }
  2416. const skipped = this.should_skip;
  2417. const removed = this.should_remove;
  2418. this.should_skip = _should_skip;
  2419. this.should_remove = _should_remove;
  2420. this.replacement = _replacement;
  2421. if (skipped) return node;
  2422. if (removed) return null;
  2423. }
  2424. for (const key in node) {
  2425. const value = node[key];
  2426. if (typeof value !== "object") {
  2427. continue;
  2428. } else if (Array.isArray(value)) {
  2429. for (let i = 0; i < value.length; i += 1) {
  2430. if (value[i] !== null && typeof value[i].type === 'string') {
  2431. if (!this.visit(value[i], node, key, i)) {
  2432. // removed
  2433. i--;
  2434. }
  2435. }
  2436. }
  2437. } else if (value !== null && typeof value.type === "string") {
  2438. this.visit(value, node, key, null);
  2439. }
  2440. }
  2441. if (this.leave) {
  2442. const _replacement = this.replacement;
  2443. const _should_remove = this.should_remove;
  2444. this.replacement = null;
  2445. this.should_remove = false;
  2446. this.leave.call(this.context, node, parent, prop, index);
  2447. if (this.replacement) {
  2448. node = this.replacement;
  2449. this.replace(parent, prop, index, node);
  2450. }
  2451. if (this.should_remove) {
  2452. this.remove(parent, prop, index);
  2453. }
  2454. const removed = this.should_remove;
  2455. this.replacement = _replacement;
  2456. this.should_remove = _should_remove;
  2457. if (removed) return null;
  2458. }
  2459. }
  2460. return node;
  2461. }
  2462. }
  2463. // @ts-check
  2464. /** @typedef { import('estree').BaseNode} BaseNode */
  2465. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  2466. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  2467. /**
  2468. *
  2469. * @param {BaseNode} ast
  2470. * @param {{
  2471. * enter?: SyncHandler
  2472. * leave?: SyncHandler
  2473. * }} walker
  2474. * @returns {BaseNode}
  2475. */
  2476. function walk$1(ast, { enter, leave }) {
  2477. const instance = new SyncWalker(enter, leave);
  2478. return instance.visit(ast, null);
  2479. }
  2480. // https://github.com/vuejs/core/blob/main/packages/compiler-core/src/babelUtils.ts
  2481. function walkIdentifiers(root, onIdentifier, onNode) {
  2482. const parentStack = [];
  2483. const knownIds = Object.create(null);
  2484. const rootExp = root.type === 'Program' &&
  2485. root.body[0].type === 'ExpressionStatement' &&
  2486. root.body[0].expression;
  2487. walk$1(root, {
  2488. enter(node, parent) {
  2489. parent && parentStack.push(parent);
  2490. if (parent &&
  2491. parent.type.startsWith('TS') &&
  2492. parent.type !== 'TSAsExpression' &&
  2493. parent.type !== 'TSNonNullExpression' &&
  2494. parent.type !== 'TSTypeAssertion') {
  2495. return this.skip();
  2496. }
  2497. if (onNode)
  2498. onNode(node);
  2499. if (node.type === 'Identifier') {
  2500. const isLocal = !!knownIds[node.name];
  2501. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  2502. if ((isRefed && !isLocal)) {
  2503. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  2504. }
  2505. }
  2506. else if (node.type === 'ObjectProperty' &&
  2507. parent.type === 'ObjectPattern') {
  2508. node.inPattern = true;
  2509. }
  2510. else if (isFunctionType(node)) {
  2511. // walk function expressions and add its arguments to known identifiers
  2512. // so that we don't prefix them
  2513. walkFunctionParams(node, id => markScopeIdentifier(node, id, knownIds));
  2514. }
  2515. else if (node.type === 'BlockStatement') {
  2516. // #3445 record block-level local variables
  2517. walkBlockDeclarations(node, id => markScopeIdentifier(node, id, knownIds));
  2518. }
  2519. },
  2520. leave(node, parent) {
  2521. parent && parentStack.pop();
  2522. if (node !== rootExp && node.scopeIds) {
  2523. for (const id of node.scopeIds) {
  2524. knownIds[id]--;
  2525. if (knownIds[id] === 0) {
  2526. delete knownIds[id];
  2527. }
  2528. }
  2529. }
  2530. }
  2531. });
  2532. }
  2533. function isReferencedIdentifier(id, parent, parentStack) {
  2534. if (!parent) {
  2535. return true;
  2536. }
  2537. // is a special keyword but parsed as identifier
  2538. if (id.name === 'arguments') {
  2539. return false;
  2540. }
  2541. if (isReferenced(id, parent)) {
  2542. return true;
  2543. }
  2544. // babel's isReferenced check returns false for ids being assigned to, so we
  2545. // need to cover those cases here
  2546. switch (parent.type) {
  2547. case 'AssignmentExpression':
  2548. case 'AssignmentPattern':
  2549. return true;
  2550. case 'ObjectPattern':
  2551. case 'ArrayPattern':
  2552. return isInDestructureAssignment(parent, parentStack);
  2553. }
  2554. return false;
  2555. }
  2556. function isInDestructureAssignment(parent, parentStack) {
  2557. if (parent &&
  2558. (parent.type === 'ObjectProperty' || parent.type === 'ArrayPattern')) {
  2559. let i = parentStack.length;
  2560. while (i--) {
  2561. const p = parentStack[i];
  2562. if (p.type === 'AssignmentExpression') {
  2563. return true;
  2564. }
  2565. else if (p.type !== 'ObjectProperty' && !p.type.endsWith('Pattern')) {
  2566. break;
  2567. }
  2568. }
  2569. }
  2570. return false;
  2571. }
  2572. function walkFunctionParams(node, onIdent) {
  2573. for (const p of node.params) {
  2574. for (const id of extractIdentifiers(p)) {
  2575. onIdent(id);
  2576. }
  2577. }
  2578. }
  2579. function walkBlockDeclarations(block, onIdent) {
  2580. for (const stmt of block.body) {
  2581. if (stmt.type === 'VariableDeclaration') {
  2582. if (stmt.declare)
  2583. continue;
  2584. for (const decl of stmt.declarations) {
  2585. for (const id of extractIdentifiers(decl.id)) {
  2586. onIdent(id);
  2587. }
  2588. }
  2589. }
  2590. else if (stmt.type === 'FunctionDeclaration' ||
  2591. stmt.type === 'ClassDeclaration') {
  2592. if (stmt.declare || !stmt.id)
  2593. continue;
  2594. onIdent(stmt.id);
  2595. }
  2596. }
  2597. }
  2598. function extractIdentifiers(param, nodes = []) {
  2599. switch (param.type) {
  2600. case 'Identifier':
  2601. nodes.push(param);
  2602. break;
  2603. case 'MemberExpression':
  2604. let object = param;
  2605. while (object.type === 'MemberExpression') {
  2606. object = object.object;
  2607. }
  2608. nodes.push(object);
  2609. break;
  2610. case 'ObjectPattern':
  2611. for (const prop of param.properties) {
  2612. if (prop.type === 'RestElement') {
  2613. extractIdentifiers(prop.argument, nodes);
  2614. }
  2615. else {
  2616. extractIdentifiers(prop.value, nodes);
  2617. }
  2618. }
  2619. break;
  2620. case 'ArrayPattern':
  2621. param.elements.forEach(element => {
  2622. if (element)
  2623. extractIdentifiers(element, nodes);
  2624. });
  2625. break;
  2626. case 'RestElement':
  2627. extractIdentifiers(param.argument, nodes);
  2628. break;
  2629. case 'AssignmentPattern':
  2630. extractIdentifiers(param.left, nodes);
  2631. break;
  2632. }
  2633. return nodes;
  2634. }
  2635. function markScopeIdentifier(node, child, knownIds) {
  2636. const { name } = child;
  2637. if (node.scopeIds && node.scopeIds.has(name)) {
  2638. return;
  2639. }
  2640. if (name in knownIds) {
  2641. knownIds[name]++;
  2642. }
  2643. else {
  2644. knownIds[name] = 1;
  2645. }
  2646. (node.scopeIds || (node.scopeIds = new Set())).add(name);
  2647. }
  2648. const isFunctionType = (node) => {
  2649. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  2650. };
  2651. const isStaticProperty = (node) => node &&
  2652. (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
  2653. !node.computed;
  2654. /**
  2655. * Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
  2656. * To avoid runtime dependency on @babel/types (which includes process references)
  2657. * This file should not change very often in babel but we may need to keep it
  2658. * up-to-date from time to time.
  2659. *
  2660. * https://github.com/babel/babel/blob/main/LICENSE
  2661. *
  2662. */
  2663. function isReferenced(node, parent, grandparent) {
  2664. switch (parent.type) {
  2665. // yes: PARENT[NODE]
  2666. // yes: NODE.child
  2667. // no: parent.NODE
  2668. case 'MemberExpression':
  2669. case 'OptionalMemberExpression':
  2670. if (parent.property === node) {
  2671. return !!parent.computed;
  2672. }
  2673. return parent.object === node;
  2674. case 'JSXMemberExpression':
  2675. return parent.object === node;
  2676. // no: let NODE = init;
  2677. // yes: let id = NODE;
  2678. case 'VariableDeclarator':
  2679. return parent.init === node;
  2680. // yes: () => NODE
  2681. // no: (NODE) => {}
  2682. case 'ArrowFunctionExpression':
  2683. return parent.body === node;
  2684. // no: class { #NODE; }
  2685. // no: class { get #NODE() {} }
  2686. // no: class { #NODE() {} }
  2687. // no: class { fn() { return this.#NODE; } }
  2688. case 'PrivateName':
  2689. return false;
  2690. // no: class { NODE() {} }
  2691. // yes: class { [NODE]() {} }
  2692. // no: class { foo(NODE) {} }
  2693. case 'ClassMethod':
  2694. case 'ClassPrivateMethod':
  2695. case 'ObjectMethod':
  2696. if (parent.key === node) {
  2697. return !!parent.computed;
  2698. }
  2699. return false;
  2700. // yes: { [NODE]: "" }
  2701. // no: { NODE: "" }
  2702. // depends: { NODE }
  2703. // depends: { key: NODE }
  2704. case 'ObjectProperty':
  2705. if (parent.key === node) {
  2706. return !!parent.computed;
  2707. }
  2708. // parent.value === node
  2709. return !grandparent || grandparent.type !== 'ObjectPattern';
  2710. // no: class { NODE = value; }
  2711. // yes: class { [NODE] = value; }
  2712. // yes: class { key = NODE; }
  2713. case 'ClassProperty':
  2714. if (parent.key === node) {
  2715. return !!parent.computed;
  2716. }
  2717. return true;
  2718. case 'ClassPrivateProperty':
  2719. return parent.key !== node;
  2720. // no: class NODE {}
  2721. // yes: class Foo extends NODE {}
  2722. case 'ClassDeclaration':
  2723. case 'ClassExpression':
  2724. return parent.superClass === node;
  2725. // yes: left = NODE;
  2726. // no: NODE = right;
  2727. case 'AssignmentExpression':
  2728. return parent.right === node;
  2729. // no: [NODE = foo] = [];
  2730. // yes: [foo = NODE] = [];
  2731. case 'AssignmentPattern':
  2732. return parent.right === node;
  2733. // no: NODE: for (;;) {}
  2734. case 'LabeledStatement':
  2735. return false;
  2736. // no: try {} catch (NODE) {}
  2737. case 'CatchClause':
  2738. return false;
  2739. // no: function foo(...NODE) {}
  2740. case 'RestElement':
  2741. return false;
  2742. case 'BreakStatement':
  2743. case 'ContinueStatement':
  2744. return false;
  2745. // no: function NODE() {}
  2746. // no: function foo(NODE) {}
  2747. case 'FunctionDeclaration':
  2748. case 'FunctionExpression':
  2749. return false;
  2750. // no: export NODE from "foo";
  2751. // no: export * as NODE from "foo";
  2752. case 'ExportNamespaceSpecifier':
  2753. case 'ExportDefaultSpecifier':
  2754. return false;
  2755. // no: export { foo as NODE };
  2756. // yes: export { NODE as foo };
  2757. // no: export { NODE as foo } from "foo";
  2758. case 'ExportSpecifier':
  2759. // @ts-expect-error
  2760. if (grandparent === null || grandparent === void 0 ? void 0 : grandparent.source) {
  2761. return false;
  2762. }
  2763. return parent.local === node;
  2764. // no: import NODE from "foo";
  2765. // no: import * as NODE from "foo";
  2766. // no: import { NODE as foo } from "foo";
  2767. // no: import { foo as NODE } from "foo";
  2768. // no: import NODE from "bar";
  2769. case 'ImportDefaultSpecifier':
  2770. case 'ImportNamespaceSpecifier':
  2771. case 'ImportSpecifier':
  2772. return false;
  2773. // no: import "foo" assert { NODE: "json" }
  2774. case 'ImportAttribute':
  2775. return false;
  2776. // no: <div NODE="foo" />
  2777. case 'JSXAttribute':
  2778. return false;
  2779. // no: [NODE] = [];
  2780. // no: ({ NODE }) = [];
  2781. case 'ObjectPattern':
  2782. case 'ArrayPattern':
  2783. return false;
  2784. // no: new.NODE
  2785. // no: NODE.target
  2786. case 'MetaProperty':
  2787. return false;
  2788. // yes: type X = { someProperty: NODE }
  2789. // no: type X = { NODE: OtherType }
  2790. case 'ObjectTypeProperty':
  2791. return parent.key !== node;
  2792. // yes: enum X { Foo = NODE }
  2793. // no: enum X { NODE }
  2794. case 'TSEnumMember':
  2795. return parent.id !== node;
  2796. // yes: { [NODE]: value }
  2797. // no: { NODE: value }
  2798. case 'TSPropertySignature':
  2799. if (parent.key === node) {
  2800. return !!parent.computed;
  2801. }
  2802. return true;
  2803. }
  2804. return true;
  2805. }
  2806. const range = 2;
  2807. function generateCodeFrame(source, start = 0, end = source.length) {
  2808. const lines = source.split(/\r?\n/);
  2809. let count = 0;
  2810. const res = [];
  2811. for (let i = 0; i < lines.length; i++) {
  2812. count += lines[i].length + 1;
  2813. if (count >= start) {
  2814. for (let j = i - range; j <= i + range || end > count; j++) {
  2815. if (j < 0 || j >= lines.length)
  2816. continue;
  2817. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  2818. const lineLength = lines[j].length;
  2819. if (j === i) {
  2820. // push underline
  2821. const pad = start - (count - lineLength) + 1;
  2822. const length = end > count ? lineLength - pad : end - start;
  2823. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  2824. }
  2825. else if (j > i) {
  2826. if (end > count) {
  2827. const length = Math.min(end - count, lineLength);
  2828. res.push(` | ` + repeat(`^`, length));
  2829. }
  2830. count += lineLength + 1;
  2831. }
  2832. }
  2833. break;
  2834. }
  2835. }
  2836. return res.join('\n');
  2837. }
  2838. function repeat(str, n) {
  2839. let result = '';
  2840. if (n > 0) {
  2841. // eslint-disable-next-line no-constant-condition
  2842. while (true) {
  2843. // eslint-disable-line
  2844. if (n & 1)
  2845. result += str;
  2846. n >>>= 1;
  2847. if (n <= 0)
  2848. break;
  2849. str += str;
  2850. }
  2851. }
  2852. return result;
  2853. }
  2854. // can we use __proto__?
  2855. const hasProto = '__proto__' in {};
  2856. // Browser environment sniffing
  2857. const inBrowser = typeof window !== 'undefined';
  2858. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  2859. const isIE = UA && /msie|trident/.test(UA);
  2860. UA && UA.indexOf('msie 9.0') > 0;
  2861. const isEdge = UA && UA.indexOf('edge/') > 0;
  2862. UA && UA.indexOf('android') > 0;
  2863. UA && /iphone|ipad|ipod|ios/.test(UA);
  2864. UA && /chrome\/\d+/.test(UA) && !isEdge;
  2865. UA && /phantomjs/.test(UA);
  2866. UA && UA.match(/firefox\/(\d+)/);
  2867. // Firefox has a "watch" function on Object.prototype...
  2868. // @ts-expect-error firebox support
  2869. const nativeWatch = {}.watch;
  2870. let supportsPassive = false;
  2871. if (inBrowser) {
  2872. try {
  2873. const opts = {};
  2874. Object.defineProperty(opts, 'passive', {
  2875. get() {
  2876. /* istanbul ignore next */
  2877. supportsPassive = true;
  2878. }
  2879. }); // https://github.com/facebook/flow/issues/285
  2880. window.addEventListener('test-passive', null, opts);
  2881. }
  2882. catch (e) { }
  2883. }
  2884. // this needs to be lazy-evaled because vue may be required before
  2885. // vue-server-renderer can set VUE_ENV
  2886. let _isServer;
  2887. const isServerRendering = () => {
  2888. if (_isServer === undefined) {
  2889. /* istanbul ignore if */
  2890. if (!inBrowser && typeof global !== 'undefined') {
  2891. // detect presence of vue-server-renderer and avoid
  2892. // Webpack shimming the process
  2893. _isServer =
  2894. global['process'] && global['process'].env.VUE_ENV === 'server';
  2895. }
  2896. else {
  2897. _isServer = false;
  2898. }
  2899. }
  2900. return _isServer;
  2901. };
  2902. /* istanbul ignore next */
  2903. function isNative(Ctor) {
  2904. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  2905. }
  2906. const hasSymbol = typeof Symbol !== 'undefined' &&
  2907. isNative(Symbol) &&
  2908. typeof Reflect !== 'undefined' &&
  2909. isNative(Reflect.ownKeys);
  2910. let _Set; // $flow-disable-line
  2911. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  2912. // use native Set when available.
  2913. _Set = Set;
  2914. }
  2915. else {
  2916. // a non-standard Set polyfill that only works with primitive keys.
  2917. _Set = class Set {
  2918. constructor() {
  2919. this.set = Object.create(null);
  2920. }
  2921. has(key) {
  2922. return this.set[key] === true;
  2923. }
  2924. add(key) {
  2925. this.set[key] = true;
  2926. }
  2927. clear() {
  2928. this.set = Object.create(null);
  2929. }
  2930. };
  2931. }
  2932. const ASSET_TYPES = ['component', 'directive', 'filter'];
  2933. const LIFECYCLE_HOOKS = [
  2934. 'beforeCreate',
  2935. 'created',
  2936. 'beforeMount',
  2937. 'mounted',
  2938. 'beforeUpdate',
  2939. 'updated',
  2940. 'beforeDestroy',
  2941. 'destroyed',
  2942. 'activated',
  2943. 'deactivated',
  2944. 'errorCaptured',
  2945. 'serverPrefetch',
  2946. 'renderTracked',
  2947. 'renderTriggered'
  2948. ];
  2949. var config = {
  2950. /**
  2951. * Option merge strategies (used in core/util/options)
  2952. */
  2953. // $flow-disable-line
  2954. optionMergeStrategies: Object.create(null),
  2955. /**
  2956. * Whether to suppress warnings.
  2957. */
  2958. silent: false,
  2959. /**
  2960. * Show production mode tip message on boot?
  2961. */
  2962. productionTip: process.env.NODE_ENV !== 'production',
  2963. /**
  2964. * Whether to enable devtools
  2965. */
  2966. devtools: process.env.NODE_ENV !== 'production',
  2967. /**
  2968. * Whether to record perf
  2969. */
  2970. performance: false,
  2971. /**
  2972. * Error handler for watcher errors
  2973. */
  2974. errorHandler: null,
  2975. /**
  2976. * Warn handler for watcher warns
  2977. */
  2978. warnHandler: null,
  2979. /**
  2980. * Ignore certain custom elements
  2981. */
  2982. ignoredElements: [],
  2983. /**
  2984. * Custom user key aliases for v-on
  2985. */
  2986. // $flow-disable-line
  2987. keyCodes: Object.create(null),
  2988. /**
  2989. * Check if a tag is reserved so that it cannot be registered as a
  2990. * component. This is platform-dependent and may be overwritten.
  2991. */
  2992. isReservedTag: no,
  2993. /**
  2994. * Check if an attribute is reserved so that it cannot be used as a component
  2995. * prop. This is platform-dependent and may be overwritten.
  2996. */
  2997. isReservedAttr: no,
  2998. /**
  2999. * Check if a tag is an unknown element.
  3000. * Platform-dependent.
  3001. */
  3002. isUnknownElement: no,
  3003. /**
  3004. * Get the namespace of an element
  3005. */
  3006. getTagNamespace: noop,
  3007. /**
  3008. * Parse the real tag name for the specific platform.
  3009. */
  3010. parsePlatformTagName: identity,
  3011. /**
  3012. * Check if an attribute must be bound using property, e.g. value
  3013. * Platform-dependent.
  3014. */
  3015. mustUseProp: no,
  3016. /**
  3017. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  3018. * This will significantly reduce performance if set to false.
  3019. */
  3020. async: true,
  3021. /**
  3022. * Exposed for legacy reasons
  3023. */
  3024. _lifecycleHooks: LIFECYCLE_HOOKS
  3025. };
  3026. let currentInstance = null;
  3027. /**
  3028. * @internal
  3029. */
  3030. function setCurrentInstance(vm = null) {
  3031. if (!vm)
  3032. currentInstance && currentInstance._scope.off();
  3033. currentInstance = vm;
  3034. vm && vm._scope.on();
  3035. }
  3036. /**
  3037. * @internal
  3038. */
  3039. class VNode {
  3040. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  3041. this.tag = tag;
  3042. this.data = data;
  3043. this.children = children;
  3044. this.text = text;
  3045. this.elm = elm;
  3046. this.ns = undefined;
  3047. this.context = context;
  3048. this.fnContext = undefined;
  3049. this.fnOptions = undefined;
  3050. this.fnScopeId = undefined;
  3051. this.key = data && data.key;
  3052. this.componentOptions = componentOptions;
  3053. this.componentInstance = undefined;
  3054. this.parent = undefined;
  3055. this.raw = false;
  3056. this.isStatic = false;
  3057. this.isRootInsert = true;
  3058. this.isComment = false;
  3059. this.isCloned = false;
  3060. this.isOnce = false;
  3061. this.asyncFactory = asyncFactory;
  3062. this.asyncMeta = undefined;
  3063. this.isAsyncPlaceholder = false;
  3064. }
  3065. // DEPRECATED: alias for componentInstance for backwards compat.
  3066. /* istanbul ignore next */
  3067. get child() {
  3068. return this.componentInstance;
  3069. }
  3070. }
  3071. const createEmptyVNode = (text = '') => {
  3072. const node = new VNode();
  3073. node.text = text;
  3074. node.isComment = true;
  3075. return node;
  3076. };
  3077. function createTextVNode(val) {
  3078. return new VNode(undefined, undefined, undefined, String(val));
  3079. }
  3080. // optimized shallow clone
  3081. // used for static nodes and slot nodes because they may be reused across
  3082. // multiple renders, cloning them avoids errors when DOM manipulations rely
  3083. // on their elm reference.
  3084. function cloneVNode(vnode) {
  3085. const cloned = new VNode(vnode.tag, vnode.data,
  3086. // #7975
  3087. // clone children array to avoid mutating original in case of cloning
  3088. // a child.
  3089. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  3090. cloned.ns = vnode.ns;
  3091. cloned.isStatic = vnode.isStatic;
  3092. cloned.key = vnode.key;
  3093. cloned.isComment = vnode.isComment;
  3094. cloned.fnContext = vnode.fnContext;
  3095. cloned.fnOptions = vnode.fnOptions;
  3096. cloned.fnScopeId = vnode.fnScopeId;
  3097. cloned.asyncMeta = vnode.asyncMeta;
  3098. cloned.isCloned = true;
  3099. return cloned;
  3100. }
  3101. /* not type checking this file because flow doesn't play well with Proxy */
  3102. if (process.env.NODE_ENV !== 'production') {
  3103. makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  3104. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  3105. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  3106. 'require' // for Webpack/Browserify
  3107. );
  3108. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  3109. if (hasProxy) {
  3110. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  3111. config.keyCodes = new Proxy(config.keyCodes, {
  3112. set(target, key, value) {
  3113. if (isBuiltInModifier(key)) {
  3114. warn$3(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  3115. return false;
  3116. }
  3117. else {
  3118. target[key] = value;
  3119. return true;
  3120. }
  3121. }
  3122. });
  3123. }
  3124. }
  3125. let uid = 0;
  3126. /**
  3127. * A dep is an observable that can have multiple
  3128. * directives subscribing to it.
  3129. * @internal
  3130. */
  3131. class Dep {
  3132. constructor() {
  3133. // pending subs cleanup
  3134. this._pending = false;
  3135. this.id = uid++;
  3136. this.subs = [];
  3137. }
  3138. addSub(sub) {
  3139. this.subs.push(sub);
  3140. }
  3141. removeSub(sub) {
  3142. // #12696 deps with massive amount of subscribers are extremely slow to
  3143. // clean up in Chromium
  3144. // to workaround this, we unset the sub for now, and clear them on
  3145. // next scheduler flush.
  3146. this.subs[this.subs.indexOf(sub)] = null;
  3147. if (!this._pending) {
  3148. this._pending = true;
  3149. }
  3150. }
  3151. depend(info) {
  3152. if (Dep.target) {
  3153. Dep.target.addDep(this);
  3154. if (process.env.NODE_ENV !== 'production' && info && Dep.target.onTrack) {
  3155. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  3156. }
  3157. }
  3158. }
  3159. notify(info) {
  3160. // stabilize the subscriber list first
  3161. const subs = this.subs.filter(s => s);
  3162. if (process.env.NODE_ENV !== 'production' && !config.async) {
  3163. // subs aren't sorted in scheduler if not running async
  3164. // we need to sort them now to make sure they fire in correct
  3165. // order
  3166. subs.sort((a, b) => a.id - b.id);
  3167. }
  3168. for (let i = 0, l = subs.length; i < l; i++) {
  3169. const sub = subs[i];
  3170. if (process.env.NODE_ENV !== 'production' && info) {
  3171. sub.onTrigger &&
  3172. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  3173. }
  3174. sub.update();
  3175. }
  3176. }
  3177. }
  3178. // The current target watcher being evaluated.
  3179. // This is globally unique because only one watcher
  3180. // can be evaluated at a time.
  3181. Dep.target = null;
  3182. const targetStack = [];
  3183. function pushTarget(target) {
  3184. targetStack.push(target);
  3185. Dep.target = target;
  3186. }
  3187. function popTarget() {
  3188. targetStack.pop();
  3189. Dep.target = targetStack[targetStack.length - 1];
  3190. }
  3191. /*
  3192. * not type checking this file because flow doesn't play well with
  3193. * dynamically accessing methods on Array prototype
  3194. */
  3195. const arrayProto = Array.prototype;
  3196. const arrayMethods = Object.create(arrayProto);
  3197. const methodsToPatch = [
  3198. 'push',
  3199. 'pop',
  3200. 'shift',
  3201. 'unshift',
  3202. 'splice',
  3203. 'sort',
  3204. 'reverse'
  3205. ];
  3206. /**
  3207. * Intercept mutating methods and emit events
  3208. */
  3209. methodsToPatch.forEach(function (method) {
  3210. // cache original method
  3211. const original = arrayProto[method];
  3212. def(arrayMethods, method, function mutator(...args) {
  3213. const result = original.apply(this, args);
  3214. const ob = this.__ob__;
  3215. let inserted;
  3216. switch (method) {
  3217. case 'push':
  3218. case 'unshift':
  3219. inserted = args;
  3220. break;
  3221. case 'splice':
  3222. inserted = args.slice(2);
  3223. break;
  3224. }
  3225. if (inserted)
  3226. ob.observeArray(inserted);
  3227. // notify change
  3228. if (process.env.NODE_ENV !== 'production') {
  3229. ob.dep.notify({
  3230. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  3231. target: this,
  3232. key: method
  3233. });
  3234. }
  3235. else {
  3236. ob.dep.notify();
  3237. }
  3238. return result;
  3239. });
  3240. });
  3241. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  3242. const NO_INITIAL_VALUE = {};
  3243. /**
  3244. * In some cases we may want to disable observation inside a component's
  3245. * update computation.
  3246. */
  3247. let shouldObserve = true;
  3248. function toggleObserving(value) {
  3249. shouldObserve = value;
  3250. }
  3251. // ssr mock dep
  3252. const mockDep = {
  3253. notify: noop,
  3254. depend: noop,
  3255. addSub: noop,
  3256. removeSub: noop
  3257. };
  3258. /**
  3259. * Observer class that is attached to each observed
  3260. * object. Once attached, the observer converts the target
  3261. * object's property keys into getter/setters that
  3262. * collect dependencies and dispatch updates.
  3263. */
  3264. class Observer {
  3265. constructor(value, shallow = false, mock = false) {
  3266. this.value = value;
  3267. this.shallow = shallow;
  3268. this.mock = mock;
  3269. // this.value = value
  3270. this.dep = mock ? mockDep : new Dep();
  3271. this.vmCount = 0;
  3272. def(value, '__ob__', this);
  3273. if (isArray(value)) {
  3274. if (!mock) {
  3275. if (hasProto) {
  3276. value.__proto__ = arrayMethods;
  3277. /* eslint-enable no-proto */
  3278. }
  3279. else {
  3280. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  3281. const key = arrayKeys[i];
  3282. def(value, key, arrayMethods[key]);
  3283. }
  3284. }
  3285. }
  3286. if (!shallow) {
  3287. this.observeArray(value);
  3288. }
  3289. }
  3290. else {
  3291. /**
  3292. * Walk through all properties and convert them into
  3293. * getter/setters. This method should only be called when
  3294. * value type is Object.
  3295. */
  3296. const keys = Object.keys(value);
  3297. for (let i = 0; i < keys.length; i++) {
  3298. const key = keys[i];
  3299. defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
  3300. }
  3301. }
  3302. }
  3303. /**
  3304. * Observe a list of Array items.
  3305. */
  3306. observeArray(value) {
  3307. for (let i = 0, l = value.length; i < l; i++) {
  3308. observe(value[i], false, this.mock);
  3309. }
  3310. }
  3311. }
  3312. // helpers
  3313. /**
  3314. * Attempt to create an observer instance for a value,
  3315. * returns the new observer if successfully observed,
  3316. * or the existing observer if the value already has one.
  3317. */
  3318. function observe(value, shallow, ssrMockReactivity) {
  3319. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  3320. return value.__ob__;
  3321. }
  3322. if (shouldObserve &&
  3323. (ssrMockReactivity || !isServerRendering()) &&
  3324. (isArray(value) || isPlainObject(value)) &&
  3325. Object.isExtensible(value) &&
  3326. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  3327. !isRef(value) &&
  3328. !(value instanceof VNode)) {
  3329. return new Observer(value, shallow, ssrMockReactivity);
  3330. }
  3331. }
  3332. /**
  3333. * Define a reactive property on an Object.
  3334. */
  3335. function defineReactive(obj, key, val, customSetter, shallow, mock, observeEvenIfShallow = false) {
  3336. const dep = new Dep();
  3337. const property = Object.getOwnPropertyDescriptor(obj, key);
  3338. if (property && property.configurable === false) {
  3339. return;
  3340. }
  3341. // cater for pre-defined getter/setters
  3342. const getter = property && property.get;
  3343. const setter = property && property.set;
  3344. if ((!getter || setter) &&
  3345. (val === NO_INITIAL_VALUE || arguments.length === 2)) {
  3346. val = obj[key];
  3347. }
  3348. let childOb = shallow ? val && val.__ob__ : observe(val, false, mock);
  3349. Object.defineProperty(obj, key, {
  3350. enumerable: true,
  3351. configurable: true,
  3352. get: function reactiveGetter() {
  3353. const value = getter ? getter.call(obj) : val;
  3354. if (Dep.target) {
  3355. if (process.env.NODE_ENV !== 'production') {
  3356. dep.depend({
  3357. target: obj,
  3358. type: "get" /* TrackOpTypes.GET */,
  3359. key
  3360. });
  3361. }
  3362. else {
  3363. dep.depend();
  3364. }
  3365. if (childOb) {
  3366. childOb.dep.depend();
  3367. if (isArray(value)) {
  3368. dependArray(value);
  3369. }
  3370. }
  3371. }
  3372. return isRef(value) && !shallow ? value.value : value;
  3373. },
  3374. set: function reactiveSetter(newVal) {
  3375. const value = getter ? getter.call(obj) : val;
  3376. if (!hasChanged(value, newVal)) {
  3377. return;
  3378. }
  3379. if (process.env.NODE_ENV !== 'production' && customSetter) {
  3380. customSetter();
  3381. }
  3382. if (setter) {
  3383. setter.call(obj, newVal);
  3384. }
  3385. else if (getter) {
  3386. // #7981: for accessor properties without setter
  3387. return;
  3388. }
  3389. else if (!shallow && isRef(value) && !isRef(newVal)) {
  3390. value.value = newVal;
  3391. return;
  3392. }
  3393. else {
  3394. val = newVal;
  3395. }
  3396. childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock);
  3397. if (process.env.NODE_ENV !== 'production') {
  3398. dep.notify({
  3399. type: "set" /* TriggerOpTypes.SET */,
  3400. target: obj,
  3401. key,
  3402. newValue: newVal,
  3403. oldValue: value
  3404. });
  3405. }
  3406. else {
  3407. dep.notify();
  3408. }
  3409. }
  3410. });
  3411. return dep;
  3412. }
  3413. function set(target, key, val) {
  3414. if (process.env.NODE_ENV !== 'production' && (isUndef(target) || isPrimitive(target))) {
  3415. warn$3(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  3416. }
  3417. if (isReadonly(target)) {
  3418. process.env.NODE_ENV !== 'production' && warn$3(`Set operation on key "${key}" failed: target is readonly.`);
  3419. return;
  3420. }
  3421. const ob = target.__ob__;
  3422. if (isArray(target) && isValidArrayIndex(key)) {
  3423. target.length = Math.max(target.length, key);
  3424. target.splice(key, 1, val);
  3425. // when mocking for SSR, array methods are not hijacked
  3426. if (ob && !ob.shallow && ob.mock) {
  3427. observe(val, false, true);
  3428. }
  3429. return val;
  3430. }
  3431. if (key in target && !(key in Object.prototype)) {
  3432. target[key] = val;
  3433. return val;
  3434. }
  3435. if (target._isVue || (ob && ob.vmCount)) {
  3436. process.env.NODE_ENV !== 'production' &&
  3437. warn$3('Avoid adding reactive properties to a Vue instance or its root $data ' +
  3438. 'at runtime - declare it upfront in the data option.');
  3439. return val;
  3440. }
  3441. if (!ob) {
  3442. target[key] = val;
  3443. return val;
  3444. }
  3445. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  3446. if (process.env.NODE_ENV !== 'production') {
  3447. ob.dep.notify({
  3448. type: "add" /* TriggerOpTypes.ADD */,
  3449. target: target,
  3450. key,
  3451. newValue: val,
  3452. oldValue: undefined
  3453. });
  3454. }
  3455. else {
  3456. ob.dep.notify();
  3457. }
  3458. return val;
  3459. }
  3460. /**
  3461. * Collect dependencies on array elements when the array is touched, since
  3462. * we cannot intercept array element access like property getters.
  3463. */
  3464. function dependArray(value) {
  3465. for (let e, i = 0, l = value.length; i < l; i++) {
  3466. e = value[i];
  3467. if (e && e.__ob__) {
  3468. e.__ob__.dep.depend();
  3469. }
  3470. if (isArray(e)) {
  3471. dependArray(e);
  3472. }
  3473. }
  3474. }
  3475. function isReadonly(value) {
  3476. return !!(value && value.__v_isReadonly);
  3477. }
  3478. function isRef(r) {
  3479. return !!(r && r.__v_isRef === true);
  3480. }
  3481. if (process.env.NODE_ENV !== 'production') ;
  3482. const normalizeEvent = cached((name) => {
  3483. const passive = name.charAt(0) === '&';
  3484. name = passive ? name.slice(1) : name;
  3485. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  3486. name = once ? name.slice(1) : name;
  3487. const capture = name.charAt(0) === '!';
  3488. name = capture ? name.slice(1) : name;
  3489. return {
  3490. name,
  3491. once,
  3492. capture,
  3493. passive
  3494. };
  3495. });
  3496. function createFnInvoker(fns, vm) {
  3497. function invoker() {
  3498. const fns = invoker.fns;
  3499. if (isArray(fns)) {
  3500. const cloned = fns.slice();
  3501. for (let i = 0; i < cloned.length; i++) {
  3502. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  3503. }
  3504. }
  3505. else {
  3506. // return handler return value for single handlers
  3507. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  3508. }
  3509. }
  3510. invoker.fns = fns;
  3511. return invoker;
  3512. }
  3513. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  3514. let name, cur, old, event;
  3515. for (name in on) {
  3516. cur = on[name];
  3517. old = oldOn[name];
  3518. event = normalizeEvent(name);
  3519. if (isUndef(cur)) {
  3520. process.env.NODE_ENV !== 'production' &&
  3521. warn$3(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  3522. }
  3523. else if (isUndef(old)) {
  3524. if (isUndef(cur.fns)) {
  3525. cur = on[name] = createFnInvoker(cur, vm);
  3526. }
  3527. if (isTrue(event.once)) {
  3528. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  3529. }
  3530. add(event.name, cur, event.capture, event.passive, event.params);
  3531. }
  3532. else if (cur !== old) {
  3533. old.fns = cur;
  3534. on[name] = old;
  3535. }
  3536. }
  3537. for (name in oldOn) {
  3538. if (isUndef(on[name])) {
  3539. event = normalizeEvent(name);
  3540. remove(event.name, oldOn[name], event.capture);
  3541. }
  3542. }
  3543. }
  3544. function extractPropsFromVNodeData(data, Ctor, tag) {
  3545. // we are only extracting raw values here.
  3546. // validation and default values are handled in the child
  3547. // component itself.
  3548. const propOptions = Ctor.options.props;
  3549. if (isUndef(propOptions)) {
  3550. return;
  3551. }
  3552. const res = {};
  3553. const { attrs, props } = data;
  3554. if (isDef(attrs) || isDef(props)) {
  3555. for (const key in propOptions) {
  3556. const altKey = hyphenate(key);
  3557. if (process.env.NODE_ENV !== 'production') {
  3558. const keyInLowerCase = key.toLowerCase();
  3559. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  3560. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  3561. `${formatComponentName(
  3562. // @ts-expect-error tag is string
  3563. tag || Ctor)}, but the declared prop name is` +
  3564. ` "${key}". ` +
  3565. `Note that HTML attributes are case-insensitive and camelCased ` +
  3566. `props need to use their kebab-case equivalents when using in-DOM ` +
  3567. `templates. You should probably use "${altKey}" instead of "${key}".`);
  3568. }
  3569. }
  3570. checkProp(res, props, key, altKey, true) ||
  3571. checkProp(res, attrs, key, altKey, false);
  3572. }
  3573. }
  3574. return res;
  3575. }
  3576. function checkProp(res, hash, key, altKey, preserve) {
  3577. if (isDef(hash)) {
  3578. if (hasOwn(hash, key)) {
  3579. res[key] = hash[key];
  3580. if (!preserve) {
  3581. delete hash[key];
  3582. }
  3583. return true;
  3584. }
  3585. else if (hasOwn(hash, altKey)) {
  3586. res[key] = hash[altKey];
  3587. if (!preserve) {
  3588. delete hash[altKey];
  3589. }
  3590. return true;
  3591. }
  3592. }
  3593. return false;
  3594. }
  3595. // The template compiler attempts to minimize the need for normalization by
  3596. // statically analyzing the template at compile time.
  3597. //
  3598. // For plain HTML markup, normalization can be completely skipped because the
  3599. // generated render function is guaranteed to return Array<VNode>. There are
  3600. // two cases where extra normalization is needed:
  3601. // 1. When the children contains components - because a functional component
  3602. // may return an Array instead of a single root. In this case, just a simple
  3603. // normalization is needed - if any child is an Array, we flatten the whole
  3604. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  3605. // because functional components already normalize their own children.
  3606. function simpleNormalizeChildren(children) {
  3607. for (let i = 0; i < children.length; i++) {
  3608. if (isArray(children[i])) {
  3609. return Array.prototype.concat.apply([], children);
  3610. }
  3611. }
  3612. return children;
  3613. }
  3614. // 2. When the children contains constructs that always generated nested Arrays,
  3615. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  3616. // with hand-written render functions / JSX. In such cases a full normalization
  3617. // is needed to cater to all possible types of children values.
  3618. function normalizeChildren(children) {
  3619. return isPrimitive(children)
  3620. ? [createTextVNode(children)]
  3621. : isArray(children)
  3622. ? normalizeArrayChildren(children)
  3623. : undefined;
  3624. }
  3625. function isTextNode(node) {
  3626. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  3627. }
  3628. function normalizeArrayChildren(children, nestedIndex) {
  3629. const res = [];
  3630. let i, c, lastIndex, last;
  3631. for (i = 0; i < children.length; i++) {
  3632. c = children[i];
  3633. if (isUndef(c) || typeof c === 'boolean')
  3634. continue;
  3635. lastIndex = res.length - 1;
  3636. last = res[lastIndex];
  3637. // nested
  3638. if (isArray(c)) {
  3639. if (c.length > 0) {
  3640. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  3641. // merge adjacent text nodes
  3642. if (isTextNode(c[0]) && isTextNode(last)) {
  3643. res[lastIndex] = createTextVNode(last.text + c[0].text);
  3644. c.shift();
  3645. }
  3646. res.push.apply(res, c);
  3647. }
  3648. }
  3649. else if (isPrimitive(c)) {
  3650. if (isTextNode(last)) {
  3651. // merge adjacent text nodes
  3652. // this is necessary for SSR hydration because text nodes are
  3653. // essentially merged when rendered to HTML strings
  3654. res[lastIndex] = createTextVNode(last.text + c);
  3655. }
  3656. else if (c !== '') {
  3657. // convert primitive to vnode
  3658. res.push(createTextVNode(c));
  3659. }
  3660. }
  3661. else {
  3662. if (isTextNode(c) && isTextNode(last)) {
  3663. // merge adjacent text nodes
  3664. res[lastIndex] = createTextVNode(last.text + c.text);
  3665. }
  3666. else {
  3667. // default key for nested array children (likely generated by v-for)
  3668. if (isTrue(children._isVList) &&
  3669. isDef(c.tag) &&
  3670. isUndef(c.key) &&
  3671. isDef(nestedIndex)) {
  3672. c.key = `__vlist${nestedIndex}_${i}__`;
  3673. }
  3674. res.push(c);
  3675. }
  3676. }
  3677. }
  3678. return res;
  3679. }
  3680. const SIMPLE_NORMALIZE = 1;
  3681. const ALWAYS_NORMALIZE = 2;
  3682. // wrapper function for providing a more flexible interface
  3683. // without getting yelled at by flow
  3684. function createElement(context, tag, data, children, normalizationType, alwaysNormalize) {
  3685. if (isArray(data) || isPrimitive(data)) {
  3686. normalizationType = children;
  3687. children = data;
  3688. data = undefined;
  3689. }
  3690. if (isTrue(alwaysNormalize)) {
  3691. normalizationType = ALWAYS_NORMALIZE;
  3692. }
  3693. return _createElement(context, tag, data, children, normalizationType);
  3694. }
  3695. function _createElement(context, tag, data, children, normalizationType) {
  3696. if (isDef(data) && isDef(data.__ob__)) {
  3697. process.env.NODE_ENV !== 'production' &&
  3698. warn$3(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  3699. return createEmptyVNode();
  3700. }
  3701. // object syntax in v-bind
  3702. if (isDef(data) && isDef(data.is)) {
  3703. tag = data.is;
  3704. }
  3705. if (!tag) {
  3706. // in case of component :is set to falsy value
  3707. return createEmptyVNode();
  3708. }
  3709. // warn against non-primitive key
  3710. if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  3711. warn$3('Avoid using non-primitive value as key, ' +
  3712. 'use string/number value instead.', context);
  3713. }
  3714. // support single function children as default scoped slot
  3715. if (isArray(children) && isFunction(children[0])) {
  3716. data = data || {};
  3717. data.scopedSlots = { default: children[0] };
  3718. children.length = 0;
  3719. }
  3720. if (normalizationType === ALWAYS_NORMALIZE) {
  3721. children = normalizeChildren(children);
  3722. }
  3723. else if (normalizationType === SIMPLE_NORMALIZE) {
  3724. children = simpleNormalizeChildren(children);
  3725. }
  3726. let vnode, ns;
  3727. if (typeof tag === 'string') {
  3728. let Ctor;
  3729. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  3730. if ((!data || !data.pre) &&
  3731. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  3732. // component
  3733. vnode = createComponent(Ctor, data, context, children, tag);
  3734. }
  3735. else {
  3736. // unknown or unlisted namespaced elements
  3737. // check at runtime because it may get assigned a namespace when its
  3738. // parent normalizes children
  3739. vnode = new VNode(tag, data, children, undefined, undefined, context);
  3740. }
  3741. }
  3742. else {
  3743. // direct component options / constructor
  3744. vnode = createComponent(tag, data, context, children);
  3745. }
  3746. if (isArray(vnode)) {
  3747. return vnode;
  3748. }
  3749. else if (isDef(vnode)) {
  3750. if (isDef(ns))
  3751. applyNS(vnode, ns);
  3752. if (isDef(data))
  3753. registerDeepBindings(data);
  3754. return vnode;
  3755. }
  3756. else {
  3757. return createEmptyVNode();
  3758. }
  3759. }
  3760. function applyNS(vnode, ns, force) {
  3761. vnode.ns = ns;
  3762. if (vnode.tag === 'foreignObject') {
  3763. // use default namespace inside foreignObject
  3764. ns = undefined;
  3765. force = true;
  3766. }
  3767. if (isDef(vnode.children)) {
  3768. for (let i = 0, l = vnode.children.length; i < l; i++) {
  3769. const child = vnode.children[i];
  3770. if (isDef(child.tag) &&
  3771. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3772. applyNS(child, ns, force);
  3773. }
  3774. }
  3775. }
  3776. }
  3777. // ref #5318
  3778. // necessary to ensure parent re-render when deep bindings like :style and
  3779. // :class are used on slot nodes
  3780. function registerDeepBindings(data) {
  3781. if (isObject$1(data.style)) {
  3782. traverse(data.style);
  3783. }
  3784. if (isObject$1(data.class)) {
  3785. traverse(data.class);
  3786. }
  3787. }
  3788. /**
  3789. * Runtime helper for rendering v-for lists.
  3790. */
  3791. function renderList(val, render) {
  3792. let ret = null, i, l, keys, key;
  3793. if (isArray(val) || typeof val === 'string') {
  3794. ret = new Array(val.length);
  3795. for (i = 0, l = val.length; i < l; i++) {
  3796. ret[i] = render(val[i], i);
  3797. }
  3798. }
  3799. else if (typeof val === 'number') {
  3800. ret = new Array(val);
  3801. for (i = 0; i < val; i++) {
  3802. ret[i] = render(i + 1, i);
  3803. }
  3804. }
  3805. else if (isObject$1(val)) {
  3806. if (hasSymbol && val[Symbol.iterator]) {
  3807. ret = [];
  3808. const iterator = val[Symbol.iterator]();
  3809. let result = iterator.next();
  3810. while (!result.done) {
  3811. ret.push(render(result.value, ret.length));
  3812. result = iterator.next();
  3813. }
  3814. }
  3815. else {
  3816. keys = Object.keys(val);
  3817. ret = new Array(keys.length);
  3818. for (i = 0, l = keys.length; i < l; i++) {
  3819. key = keys[i];
  3820. ret[i] = render(val[key], key, i);
  3821. }
  3822. }
  3823. }
  3824. if (!isDef(ret)) {
  3825. ret = [];
  3826. }
  3827. ret._isVList = true;
  3828. return ret;
  3829. }
  3830. /**
  3831. * Runtime helper for rendering <slot>
  3832. */
  3833. function renderSlot(name, fallbackRender, props, bindObject) {
  3834. const scopedSlotFn = this.$scopedSlots[name];
  3835. let nodes;
  3836. if (scopedSlotFn) {
  3837. // scoped slot
  3838. props = props || {};
  3839. if (bindObject) {
  3840. if (process.env.NODE_ENV !== 'production' && !isObject$1(bindObject)) {
  3841. warn$3('slot v-bind without argument expects an Object', this);
  3842. }
  3843. props = extend(extend({}, bindObject), props);
  3844. }
  3845. nodes =
  3846. scopedSlotFn(props) ||
  3847. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  3848. }
  3849. else {
  3850. nodes =
  3851. this.$slots[name] ||
  3852. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  3853. }
  3854. const target = props && props.slot;
  3855. if (target) {
  3856. return this.$createElement('template', { slot: target }, nodes);
  3857. }
  3858. else {
  3859. return nodes;
  3860. }
  3861. }
  3862. /**
  3863. * Runtime helper for resolving filters
  3864. */
  3865. function resolveFilter(id) {
  3866. return resolveAsset(this.$options, 'filters', id, true) || identity;
  3867. }
  3868. function isKeyNotMatch(expect, actual) {
  3869. if (isArray(expect)) {
  3870. return expect.indexOf(actual) === -1;
  3871. }
  3872. else {
  3873. return expect !== actual;
  3874. }
  3875. }
  3876. /**
  3877. * Runtime helper for checking keyCodes from config.
  3878. * exposed as Vue.prototype._k
  3879. * passing in eventKeyName as last argument separately for backwards compat
  3880. */
  3881. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  3882. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  3883. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  3884. return isKeyNotMatch(builtInKeyName, eventKeyName);
  3885. }
  3886. else if (mappedKeyCode) {
  3887. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  3888. }
  3889. else if (eventKeyName) {
  3890. return hyphenate(eventKeyName) !== key;
  3891. }
  3892. return eventKeyCode === undefined;
  3893. }
  3894. /**
  3895. * Runtime helper for merging v-bind="object" into a VNode's data.
  3896. */
  3897. function bindObjectProps(data, tag, value, asProp, isSync) {
  3898. if (value) {
  3899. if (!isObject$1(value)) {
  3900. process.env.NODE_ENV !== 'production' &&
  3901. warn$3('v-bind without argument expects an Object or Array value', this);
  3902. }
  3903. else {
  3904. if (isArray(value)) {
  3905. value = toObject(value);
  3906. }
  3907. let hash;
  3908. for (const key in value) {
  3909. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  3910. hash = data;
  3911. }
  3912. else {
  3913. const type = data.attrs && data.attrs.type;
  3914. hash =
  3915. asProp || config.mustUseProp(tag, type, key)
  3916. ? data.domProps || (data.domProps = {})
  3917. : data.attrs || (data.attrs = {});
  3918. }
  3919. const camelizedKey = camelize(key);
  3920. const hyphenatedKey = hyphenate(key);
  3921. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  3922. hash[key] = value[key];
  3923. if (isSync) {
  3924. const on = data.on || (data.on = {});
  3925. on[`update:${key}`] = function ($event) {
  3926. value[key] = $event;
  3927. };
  3928. }
  3929. }
  3930. }
  3931. }
  3932. }
  3933. return data;
  3934. }
  3935. /**
  3936. * Runtime helper for rendering static trees.
  3937. */
  3938. function renderStatic(index, isInFor) {
  3939. const cached = this._staticTrees || (this._staticTrees = []);
  3940. let tree = cached[index];
  3941. // if has already-rendered static tree and not inside v-for,
  3942. // we can reuse the same tree.
  3943. if (tree && !isInFor) {
  3944. return tree;
  3945. }
  3946. // otherwise, render a fresh tree.
  3947. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  3948. );
  3949. markStatic$1(tree, `__static__${index}`, false);
  3950. return tree;
  3951. }
  3952. /**
  3953. * Runtime helper for v-once.
  3954. * Effectively it means marking the node as static with a unique key.
  3955. */
  3956. function markOnce(tree, index, key) {
  3957. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  3958. return tree;
  3959. }
  3960. function markStatic$1(tree, key, isOnce) {
  3961. if (isArray(tree)) {
  3962. for (let i = 0; i < tree.length; i++) {
  3963. if (tree[i] && typeof tree[i] !== 'string') {
  3964. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  3965. }
  3966. }
  3967. }
  3968. else {
  3969. markStaticNode(tree, key, isOnce);
  3970. }
  3971. }
  3972. function markStaticNode(node, key, isOnce) {
  3973. node.isStatic = true;
  3974. node.key = key;
  3975. node.isOnce = isOnce;
  3976. }
  3977. function bindObjectListeners(data, value) {
  3978. if (value) {
  3979. if (!isPlainObject(value)) {
  3980. process.env.NODE_ENV !== 'production' && warn$3('v-on without argument expects an Object value', this);
  3981. }
  3982. else {
  3983. const on = (data.on = data.on ? extend({}, data.on) : {});
  3984. for (const key in value) {
  3985. const existing = on[key];
  3986. const ours = value[key];
  3987. on[key] = existing ? [].concat(existing, ours) : ours;
  3988. }
  3989. }
  3990. }
  3991. return data;
  3992. }
  3993. function resolveScopedSlots(fns, res,
  3994. // the following are added in 2.6
  3995. hasDynamicKeys, contentHashKey) {
  3996. res = res || { $stable: !hasDynamicKeys };
  3997. for (let i = 0; i < fns.length; i++) {
  3998. const slot = fns[i];
  3999. if (isArray(slot)) {
  4000. resolveScopedSlots(slot, res, hasDynamicKeys);
  4001. }
  4002. else if (slot) {
  4003. // marker for reverse proxying v-slot without scope on this.$slots
  4004. // @ts-expect-error
  4005. if (slot.proxy) {
  4006. // @ts-expect-error
  4007. slot.fn.proxy = true;
  4008. }
  4009. res[slot.key] = slot.fn;
  4010. }
  4011. }
  4012. if (contentHashKey) {
  4013. res.$key = contentHashKey;
  4014. }
  4015. return res;
  4016. }
  4017. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  4018. function bindDynamicKeys(baseObj, values) {
  4019. for (let i = 0; i < values.length; i += 2) {
  4020. const key = values[i];
  4021. if (typeof key === 'string' && key) {
  4022. baseObj[values[i]] = values[i + 1];
  4023. }
  4024. else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
  4025. // null is a special value for explicitly removing a binding
  4026. warn$3(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  4027. }
  4028. }
  4029. return baseObj;
  4030. }
  4031. // helper to dynamically append modifier runtime markers to event names.
  4032. // ensure only append when value is already string, otherwise it will be cast
  4033. // to string and cause the type check to miss.
  4034. function prependModifier(value, symbol) {
  4035. return typeof value === 'string' ? symbol + value : value;
  4036. }
  4037. function installRenderHelpers(target) {
  4038. target._o = markOnce;
  4039. target._n = toNumber;
  4040. target._s = toString$2;
  4041. target._l = renderList;
  4042. target._t = renderSlot;
  4043. target._q = looseEqual;
  4044. target._i = looseIndexOf;
  4045. target._m = renderStatic;
  4046. target._f = resolveFilter;
  4047. target._k = checkKeyCodes;
  4048. target._b = bindObjectProps;
  4049. target._v = createTextVNode;
  4050. target._e = createEmptyVNode;
  4051. target._u = resolveScopedSlots;
  4052. target._g = bindObjectListeners;
  4053. target._d = bindDynamicKeys;
  4054. target._p = prependModifier;
  4055. }
  4056. /**
  4057. * Runtime helper for resolving raw children VNodes into a slot object.
  4058. */
  4059. function resolveSlots(children, context) {
  4060. if (!children || !children.length) {
  4061. return {};
  4062. }
  4063. const slots = {};
  4064. for (let i = 0, l = children.length; i < l; i++) {
  4065. const child = children[i];
  4066. const data = child.data;
  4067. // remove slot attribute if the node is resolved as a Vue slot node
  4068. if (data && data.attrs && data.attrs.slot) {
  4069. delete data.attrs.slot;
  4070. }
  4071. // named slots should only be respected if the vnode was rendered in the
  4072. // same context.
  4073. if ((child.context === context || child.fnContext === context) &&
  4074. data &&
  4075. data.slot != null) {
  4076. const name = data.slot;
  4077. const slot = slots[name] || (slots[name] = []);
  4078. if (child.tag === 'template') {
  4079. slot.push.apply(slot, child.children || []);
  4080. }
  4081. else {
  4082. slot.push(child);
  4083. }
  4084. }
  4085. else {
  4086. (slots.default || (slots.default = [])).push(child);
  4087. }
  4088. }
  4089. // ignore slots that contains only whitespace
  4090. for (const name in slots) {
  4091. if (slots[name].every(isWhitespace)) {
  4092. delete slots[name];
  4093. }
  4094. }
  4095. return slots;
  4096. }
  4097. function isWhitespace(node) {
  4098. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  4099. }
  4100. function isAsyncPlaceholder(node) {
  4101. // @ts-expect-error not really boolean type
  4102. return node.isComment && node.asyncFactory;
  4103. }
  4104. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  4105. let res;
  4106. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  4107. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  4108. const key = scopedSlots && scopedSlots.$key;
  4109. if (!scopedSlots) {
  4110. res = {};
  4111. }
  4112. else if (scopedSlots._normalized) {
  4113. // fast path 1: child component re-render only, parent did not change
  4114. return scopedSlots._normalized;
  4115. }
  4116. else if (isStable &&
  4117. prevScopedSlots &&
  4118. prevScopedSlots !== emptyObject &&
  4119. key === prevScopedSlots.$key &&
  4120. !hasNormalSlots &&
  4121. !prevScopedSlots.$hasNormal) {
  4122. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  4123. // only need to normalize once
  4124. return prevScopedSlots;
  4125. }
  4126. else {
  4127. res = {};
  4128. for (const key in scopedSlots) {
  4129. if (scopedSlots[key] && key[0] !== '$') {
  4130. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  4131. }
  4132. }
  4133. }
  4134. // expose normal slots on scopedSlots
  4135. for (const key in normalSlots) {
  4136. if (!(key in res)) {
  4137. res[key] = proxyNormalSlot(normalSlots, key);
  4138. }
  4139. }
  4140. // avoriaz seems to mock a non-extensible $scopedSlots object
  4141. // and when that is passed down this would cause an error
  4142. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  4143. scopedSlots._normalized = res;
  4144. }
  4145. def(res, '$stable', isStable);
  4146. def(res, '$key', key);
  4147. def(res, '$hasNormal', hasNormalSlots);
  4148. return res;
  4149. }
  4150. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  4151. const normalized = function () {
  4152. const cur = currentInstance;
  4153. setCurrentInstance(vm);
  4154. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  4155. res =
  4156. res && typeof res === 'object' && !isArray(res)
  4157. ? [res] // single vnode
  4158. : normalizeChildren(res);
  4159. const vnode = res && res[0];
  4160. setCurrentInstance(cur);
  4161. return res &&
  4162. (!vnode ||
  4163. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  4164. ? undefined
  4165. : res;
  4166. };
  4167. // this is a slot using the new v-slot syntax without scope. although it is
  4168. // compiled as a scoped slot, render fn users would expect it to be present
  4169. // on this.$slots because the usage is semantically a normal slot.
  4170. if (fn.proxy) {
  4171. Object.defineProperty(normalSlots, key, {
  4172. get: normalized,
  4173. enumerable: true,
  4174. configurable: true
  4175. });
  4176. }
  4177. return normalized;
  4178. }
  4179. function proxyNormalSlot(slots, key) {
  4180. return () => slots[key];
  4181. }
  4182. function syncSetupProxy(to, from, prev, instance, type) {
  4183. let changed = false;
  4184. for (const key in from) {
  4185. if (!(key in to)) {
  4186. changed = true;
  4187. defineProxyAttr(to, key, instance, type);
  4188. }
  4189. else if (from[key] !== prev[key]) {
  4190. changed = true;
  4191. }
  4192. }
  4193. for (const key in to) {
  4194. if (!(key in from)) {
  4195. changed = true;
  4196. delete to[key];
  4197. }
  4198. }
  4199. return changed;
  4200. }
  4201. function defineProxyAttr(proxy, key, instance, type) {
  4202. Object.defineProperty(proxy, key, {
  4203. enumerable: true,
  4204. configurable: true,
  4205. get() {
  4206. return instance[type][key];
  4207. }
  4208. });
  4209. }
  4210. function createAsyncPlaceholder(factory, data, context, children, tag) {
  4211. const node = createEmptyVNode();
  4212. node.asyncFactory = factory;
  4213. node.asyncMeta = { data, context, children, tag };
  4214. return node;
  4215. }
  4216. function resolveAsyncComponent(factory, baseCtor) {
  4217. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  4218. return factory.errorComp;
  4219. }
  4220. if (isDef(factory.resolved)) {
  4221. return factory.resolved;
  4222. }
  4223. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  4224. return factory.loadingComp;
  4225. }
  4226. }
  4227. let target;
  4228. function add(event, fn) {
  4229. target.$on(event, fn);
  4230. }
  4231. function remove(event, fn) {
  4232. target.$off(event, fn);
  4233. }
  4234. function createOnceHandler(event, fn) {
  4235. const _target = target;
  4236. return function onceHandler() {
  4237. const res = fn.apply(null, arguments);
  4238. if (res !== null) {
  4239. _target.$off(event, onceHandler);
  4240. }
  4241. };
  4242. }
  4243. function updateComponentListeners(vm, listeners, oldListeners) {
  4244. target = vm;
  4245. updateListeners(listeners, oldListeners || {}, add, remove, createOnceHandler, vm);
  4246. target = undefined;
  4247. }
  4248. let activeInstance = null;
  4249. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  4250. if (process.env.NODE_ENV !== 'production') ;
  4251. // determine whether component has slot children
  4252. // we need to do this before overwriting $options._renderChildren.
  4253. // check if there are dynamic scopedSlots (hand-written or compiled but with
  4254. // dynamic slot names). Static scoped slots compiled from template has the
  4255. // "$stable" marker.
  4256. const newScopedSlots = parentVnode.data.scopedSlots;
  4257. const oldScopedSlots = vm.$scopedSlots;
  4258. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  4259. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  4260. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  4261. (!newScopedSlots && vm.$scopedSlots.$key));
  4262. // Any static slot children from the parent may have changed during parent's
  4263. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  4264. // update is necessary to ensure correctness.
  4265. let needsForceUpdate = !!(renderChildren || // has new static slots
  4266. vm.$options._renderChildren || // has old static slots
  4267. hasDynamicScopedSlot);
  4268. const prevVNode = vm.$vnode;
  4269. vm.$options._parentVnode = parentVnode;
  4270. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  4271. if (vm._vnode) {
  4272. // update child tree's parent
  4273. vm._vnode.parent = parentVnode;
  4274. }
  4275. vm.$options._renderChildren = renderChildren;
  4276. // update $attrs and $listeners hash
  4277. // these are also reactive so they may trigger child update if the child
  4278. // used them during render
  4279. const attrs = parentVnode.data.attrs || emptyObject;
  4280. if (vm._attrsProxy) {
  4281. // force update if attrs are accessed and has changed since it may be
  4282. // passed to a child component.
  4283. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  4284. needsForceUpdate = true;
  4285. }
  4286. }
  4287. vm.$attrs = attrs;
  4288. // update listeners
  4289. listeners = listeners || emptyObject;
  4290. const prevListeners = vm.$options._parentListeners;
  4291. if (vm._listenersProxy) {
  4292. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  4293. }
  4294. vm.$listeners = vm.$options._parentListeners = listeners;
  4295. updateComponentListeners(vm, listeners, prevListeners);
  4296. // update props
  4297. if (propsData && vm.$options.props) {
  4298. toggleObserving(false);
  4299. const props = vm._props;
  4300. const propKeys = vm.$options._propKeys || [];
  4301. for (let i = 0; i < propKeys.length; i++) {
  4302. const key = propKeys[i];
  4303. const propOptions = vm.$options.props; // wtf flow?
  4304. props[key] = validateProp(key, propOptions, propsData, vm);
  4305. }
  4306. toggleObserving(true);
  4307. // keep a copy of raw propsData
  4308. vm.$options.propsData = propsData;
  4309. }
  4310. // resolve slots + force update if has children
  4311. if (needsForceUpdate) {
  4312. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  4313. vm.$forceUpdate();
  4314. }
  4315. if (process.env.NODE_ENV !== 'production') ;
  4316. }
  4317. function isInInactiveTree(vm) {
  4318. while (vm && (vm = vm.$parent)) {
  4319. if (vm._inactive)
  4320. return true;
  4321. }
  4322. return false;
  4323. }
  4324. function activateChildComponent(vm, direct) {
  4325. if (direct) {
  4326. vm._directInactive = false;
  4327. if (isInInactiveTree(vm)) {
  4328. return;
  4329. }
  4330. }
  4331. else if (vm._directInactive) {
  4332. return;
  4333. }
  4334. if (vm._inactive || vm._inactive === null) {
  4335. vm._inactive = false;
  4336. for (let i = 0; i < vm.$children.length; i++) {
  4337. activateChildComponent(vm.$children[i]);
  4338. }
  4339. callHook(vm, 'activated');
  4340. }
  4341. }
  4342. function deactivateChildComponent(vm, direct) {
  4343. if (direct) {
  4344. vm._directInactive = true;
  4345. if (isInInactiveTree(vm)) {
  4346. return;
  4347. }
  4348. }
  4349. if (!vm._inactive) {
  4350. vm._inactive = true;
  4351. for (let i = 0; i < vm.$children.length; i++) {
  4352. deactivateChildComponent(vm.$children[i]);
  4353. }
  4354. callHook(vm, 'deactivated');
  4355. }
  4356. }
  4357. function callHook(vm, hook, args, setContext = true) {
  4358. // #7573 disable dep collection when invoking lifecycle hooks
  4359. pushTarget();
  4360. const prevInst = currentInstance;
  4361. setContext && setCurrentInstance(vm);
  4362. const handlers = vm.$options[hook];
  4363. const info = `${hook} hook`;
  4364. if (handlers) {
  4365. for (let i = 0, j = handlers.length; i < j; i++) {
  4366. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  4367. }
  4368. }
  4369. if (vm._hasHookEvent) {
  4370. vm.$emit('hook:' + hook);
  4371. }
  4372. if (setContext) {
  4373. setCurrentInstance(prevInst);
  4374. }
  4375. popTarget();
  4376. }
  4377. // Async edge case fix requires storing an event listener's attach timestamp.
  4378. let getNow = Date.now;
  4379. // Determine what event timestamp the browser is using. Annoyingly, the
  4380. // timestamp can either be hi-res (relative to page load) or low-res
  4381. // (relative to UNIX epoch), so in order to compare time we have to use the
  4382. // same timestamp type when saving the flush timestamp.
  4383. // All IE versions use low-res event timestamps, and have problematic clock
  4384. // implementations (#9632)
  4385. if (inBrowser && !isIE) {
  4386. const performance = window.performance;
  4387. if (performance &&
  4388. typeof performance.now === 'function' &&
  4389. getNow() > document.createEvent('Event').timeStamp) {
  4390. // if the event timestamp, although evaluated AFTER the Date.now(), is
  4391. // smaller than it, it means the event is using a hi-res timestamp,
  4392. // and we need to use the hi-res version for event listener timestamps as
  4393. // well.
  4394. getNow = () => performance.now();
  4395. }
  4396. }
  4397. /**
  4398. * Queue a kept-alive component that was activated during patch.
  4399. * The queue will be processed after the entire tree has been patched.
  4400. */
  4401. function queueActivatedComponent(vm) {
  4402. // setting _inactive to false here so that a render function can
  4403. // rely on checking whether it's in an inactive tree (e.g. router-view)
  4404. vm._inactive = false;
  4405. }
  4406. function handleError(err, vm, info) {
  4407. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  4408. // See: https://github.com/vuejs/vuex/issues/1505
  4409. pushTarget();
  4410. try {
  4411. if (vm) {
  4412. let cur = vm;
  4413. while ((cur = cur.$parent)) {
  4414. const hooks = cur.$options.errorCaptured;
  4415. if (hooks) {
  4416. for (let i = 0; i < hooks.length; i++) {
  4417. try {
  4418. const capture = hooks[i].call(cur, err, vm, info) === false;
  4419. if (capture)
  4420. return;
  4421. }
  4422. catch (e) {
  4423. globalHandleError(e, cur, 'errorCaptured hook');
  4424. }
  4425. }
  4426. }
  4427. }
  4428. }
  4429. globalHandleError(err, vm, info);
  4430. }
  4431. finally {
  4432. popTarget();
  4433. }
  4434. }
  4435. function invokeWithErrorHandling(handler, context, args, vm, info) {
  4436. let res;
  4437. try {
  4438. res = args ? handler.apply(context, args) : handler.call(context);
  4439. if (res && !res._isVue && isPromise(res) && !res._handled) {
  4440. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  4441. res._handled = true;
  4442. }
  4443. }
  4444. catch (e) {
  4445. handleError(e, vm, info);
  4446. }
  4447. return res;
  4448. }
  4449. function globalHandleError(err, vm, info) {
  4450. logError(err, vm, info);
  4451. }
  4452. function logError(err, vm, info) {
  4453. if (process.env.NODE_ENV !== 'production') {
  4454. warn$3(`Error in ${info}: "${err.toString()}"`, vm);
  4455. }
  4456. /* istanbul ignore else */
  4457. if (inBrowser && typeof console !== 'undefined') {
  4458. console.error(err);
  4459. }
  4460. else {
  4461. throw err;
  4462. }
  4463. }
  4464. /* globals MutationObserver */
  4465. const callbacks = [];
  4466. function flushCallbacks() {
  4467. const copies = callbacks.slice(0);
  4468. callbacks.length = 0;
  4469. for (let i = 0; i < copies.length; i++) {
  4470. copies[i]();
  4471. }
  4472. }
  4473. // The nextTick behavior leverages the microtask queue, which can be accessed
  4474. // via either native Promise.then or MutationObserver.
  4475. // MutationObserver has wider support, however it is seriously bugged in
  4476. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  4477. // completely stops working after triggering a few times... so, if native
  4478. // Promise is available, we will use it:
  4479. /* istanbul ignore next, $flow-disable-line */
  4480. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  4481. Promise.resolve();
  4482. }
  4483. else if (!isIE &&
  4484. typeof MutationObserver !== 'undefined' &&
  4485. (isNative(MutationObserver) ||
  4486. // PhantomJS and iOS 7.x
  4487. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  4488. // Use MutationObserver where native Promise is not available,
  4489. // e.g. PhantomJS, iOS7, Android 4.4
  4490. // (#6466 MutationObserver is unreliable in IE11)
  4491. let counter = 1;
  4492. const observer = new MutationObserver(flushCallbacks);
  4493. const textNode = document.createTextNode(String(counter));
  4494. observer.observe(textNode, {
  4495. characterData: true
  4496. });
  4497. }
  4498. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ;
  4499. else ;
  4500. const seenObjects = new _Set();
  4501. /**
  4502. * Recursively traverse an object to evoke all converted
  4503. * getters, so that every nested property inside the object
  4504. * is collected as a "deep" dependency.
  4505. */
  4506. function traverse(val) {
  4507. _traverse(val, seenObjects);
  4508. seenObjects.clear();
  4509. return val;
  4510. }
  4511. function _traverse(val, seen) {
  4512. let i, keys;
  4513. const isA = isArray(val);
  4514. if ((!isA && !isObject$1(val)) ||
  4515. val.__v_skip /* ReactiveFlags.SKIP */ ||
  4516. Object.isFrozen(val) ||
  4517. val instanceof VNode) {
  4518. return;
  4519. }
  4520. if (val.__ob__) {
  4521. const depId = val.__ob__.dep.id;
  4522. if (seen.has(depId)) {
  4523. return;
  4524. }
  4525. seen.add(depId);
  4526. }
  4527. if (isA) {
  4528. i = val.length;
  4529. while (i--)
  4530. _traverse(val[i], seen);
  4531. }
  4532. else if (isRef(val)) {
  4533. _traverse(val.value, seen);
  4534. }
  4535. else {
  4536. keys = Object.keys(val);
  4537. i = keys.length;
  4538. while (i--)
  4539. _traverse(val[keys[i]], seen);
  4540. }
  4541. }
  4542. function resolveInject(inject, vm) {
  4543. if (inject) {
  4544. // inject is :any because flow is not smart enough to figure out cached
  4545. const result = Object.create(null);
  4546. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4547. for (let i = 0; i < keys.length; i++) {
  4548. const key = keys[i];
  4549. // #6574 in case the inject object is observed...
  4550. if (key === '__ob__')
  4551. continue;
  4552. const provideKey = inject[key].from;
  4553. if (provideKey in vm._provided) {
  4554. result[key] = vm._provided[provideKey];
  4555. }
  4556. else if ('default' in inject[key]) {
  4557. const provideDefault = inject[key].default;
  4558. result[key] = isFunction(provideDefault)
  4559. ? provideDefault.call(vm)
  4560. : provideDefault;
  4561. }
  4562. else if (process.env.NODE_ENV !== 'production') {
  4563. warn$3(`Injection "${key}" not found`, vm);
  4564. }
  4565. }
  4566. return result;
  4567. }
  4568. }
  4569. function resolveConstructorOptions(Ctor) {
  4570. let options = Ctor.options;
  4571. if (Ctor.super) {
  4572. const superOptions = resolveConstructorOptions(Ctor.super);
  4573. const cachedSuperOptions = Ctor.superOptions;
  4574. if (superOptions !== cachedSuperOptions) {
  4575. // super option changed,
  4576. // need to resolve new options.
  4577. Ctor.superOptions = superOptions;
  4578. // check if there are any late-modified/attached options (#4976)
  4579. const modifiedOptions = resolveModifiedOptions(Ctor);
  4580. // update base extend options
  4581. if (modifiedOptions) {
  4582. extend(Ctor.extendOptions, modifiedOptions);
  4583. }
  4584. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4585. if (options.name) {
  4586. options.components[options.name] = Ctor;
  4587. }
  4588. }
  4589. }
  4590. return options;
  4591. }
  4592. function resolveModifiedOptions(Ctor) {
  4593. let modified;
  4594. const latest = Ctor.options;
  4595. const sealed = Ctor.sealedOptions;
  4596. for (const key in latest) {
  4597. if (latest[key] !== sealed[key]) {
  4598. if (!modified)
  4599. modified = {};
  4600. modified[key] = latest[key];
  4601. }
  4602. }
  4603. return modified;
  4604. }
  4605. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4606. const options = Ctor.options;
  4607. // ensure the createElement function in functional components
  4608. // gets a unique context - this is necessary for correct named slot check
  4609. let contextVm;
  4610. if (hasOwn(parent, '_uid')) {
  4611. contextVm = Object.create(parent);
  4612. contextVm._original = parent;
  4613. }
  4614. else {
  4615. // the context vm passed in is a functional context as well.
  4616. // in this case we want to make sure we are able to get a hold to the
  4617. // real context instance.
  4618. contextVm = parent;
  4619. // @ts-ignore
  4620. parent = parent._original;
  4621. }
  4622. const isCompiled = isTrue(options._compiled);
  4623. const needNormalization = !isCompiled;
  4624. this.data = data;
  4625. this.props = props;
  4626. this.children = children;
  4627. this.parent = parent;
  4628. this.listeners = data.on || emptyObject;
  4629. this.injections = resolveInject(options.inject, parent);
  4630. this.slots = () => {
  4631. if (!this.$slots) {
  4632. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4633. }
  4634. return this.$slots;
  4635. };
  4636. Object.defineProperty(this, 'scopedSlots', {
  4637. enumerable: true,
  4638. get() {
  4639. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4640. }
  4641. });
  4642. // support for compiled functional template
  4643. if (isCompiled) {
  4644. // exposing $options for renderStatic()
  4645. this.$options = options;
  4646. // pre-resolve slots for renderSlot()
  4647. this.$slots = this.slots();
  4648. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4649. }
  4650. if (options._scopeId) {
  4651. this._c = (a, b, c, d) => {
  4652. const vnode = createElement(contextVm, a, b, c, d, needNormalization);
  4653. if (vnode && !isArray(vnode)) {
  4654. vnode.fnScopeId = options._scopeId;
  4655. vnode.fnContext = parent;
  4656. }
  4657. return vnode;
  4658. };
  4659. }
  4660. else {
  4661. this._c = (a, b, c, d) => createElement(contextVm, a, b, c, d, needNormalization);
  4662. }
  4663. }
  4664. installRenderHelpers(FunctionalRenderContext.prototype);
  4665. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4666. const options = Ctor.options;
  4667. const props = {};
  4668. const propOptions = options.props;
  4669. if (isDef(propOptions)) {
  4670. for (const key in propOptions) {
  4671. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4672. }
  4673. }
  4674. else {
  4675. if (isDef(data.attrs))
  4676. mergeProps(props, data.attrs);
  4677. if (isDef(data.props))
  4678. mergeProps(props, data.props);
  4679. }
  4680. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4681. const vnode = options.render.call(null, renderContext._c, renderContext);
  4682. if (vnode instanceof VNode) {
  4683. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4684. }
  4685. else if (isArray(vnode)) {
  4686. const vnodes = normalizeChildren(vnode) || [];
  4687. const res = new Array(vnodes.length);
  4688. for (let i = 0; i < vnodes.length; i++) {
  4689. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4690. }
  4691. return res;
  4692. }
  4693. }
  4694. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4695. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4696. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4697. // that should not be matched to match.
  4698. const clone = cloneVNode(vnode);
  4699. clone.fnContext = contextVm;
  4700. clone.fnOptions = options;
  4701. if (process.env.NODE_ENV !== 'production') {
  4702. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4703. renderContext;
  4704. }
  4705. if (data.slot) {
  4706. (clone.data || (clone.data = {})).slot = data.slot;
  4707. }
  4708. return clone;
  4709. }
  4710. function mergeProps(to, from) {
  4711. for (const key in from) {
  4712. to[camelize(key)] = from[key];
  4713. }
  4714. }
  4715. function getComponentName(options) {
  4716. return options.name || options.__name || options._componentTag;
  4717. }
  4718. // inline hooks to be invoked on component VNodes during patch
  4719. const componentVNodeHooks = {
  4720. init(vnode, hydrating) {
  4721. if (vnode.componentInstance &&
  4722. !vnode.componentInstance._isDestroyed &&
  4723. vnode.data.keepAlive) {
  4724. // kept-alive components, treat as a patch
  4725. const mountedNode = vnode; // work around flow
  4726. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4727. }
  4728. else {
  4729. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4730. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4731. }
  4732. },
  4733. prepatch(oldVnode, vnode) {
  4734. const options = vnode.componentOptions;
  4735. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4736. updateChildComponent(child, options.propsData, // updated props
  4737. options.listeners, // updated listeners
  4738. vnode, // new parent vnode
  4739. options.children // new children
  4740. );
  4741. },
  4742. insert(vnode) {
  4743. const { context, componentInstance } = vnode;
  4744. if (!componentInstance._isMounted) {
  4745. componentInstance._isMounted = true;
  4746. callHook(componentInstance, 'mounted');
  4747. }
  4748. if (vnode.data.keepAlive) {
  4749. if (context._isMounted) {
  4750. // vue-router#1212
  4751. // During updates, a kept-alive component's child components may
  4752. // change, so directly walking the tree here may call activated hooks
  4753. // on incorrect children. Instead we push them into a queue which will
  4754. // be processed after the whole patch process ended.
  4755. queueActivatedComponent(componentInstance);
  4756. }
  4757. else {
  4758. activateChildComponent(componentInstance, true /* direct */);
  4759. }
  4760. }
  4761. },
  4762. destroy(vnode) {
  4763. const { componentInstance } = vnode;
  4764. if (!componentInstance._isDestroyed) {
  4765. if (!vnode.data.keepAlive) {
  4766. componentInstance.$destroy();
  4767. }
  4768. else {
  4769. deactivateChildComponent(componentInstance, true /* direct */);
  4770. }
  4771. }
  4772. }
  4773. };
  4774. const hooksToMerge = Object.keys(componentVNodeHooks);
  4775. function createComponent(Ctor, data, context, children, tag) {
  4776. if (isUndef(Ctor)) {
  4777. return;
  4778. }
  4779. const baseCtor = context.$options._base;
  4780. // plain options object: turn it into a constructor
  4781. if (isObject$1(Ctor)) {
  4782. Ctor = baseCtor.extend(Ctor);
  4783. }
  4784. // if at this stage it's not a constructor or an async component factory,
  4785. // reject.
  4786. if (typeof Ctor !== 'function') {
  4787. if (process.env.NODE_ENV !== 'production') {
  4788. warn$3(`Invalid Component definition: ${String(Ctor)}`, context);
  4789. }
  4790. return;
  4791. }
  4792. // async component
  4793. let asyncFactory;
  4794. // @ts-expect-error
  4795. if (isUndef(Ctor.cid)) {
  4796. asyncFactory = Ctor;
  4797. Ctor = resolveAsyncComponent(asyncFactory);
  4798. if (Ctor === undefined) {
  4799. // return a placeholder node for async component, which is rendered
  4800. // as a comment node but preserves all the raw information for the node.
  4801. // the information will be used for async server-rendering and hydration.
  4802. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4803. }
  4804. }
  4805. data = data || {};
  4806. // resolve constructor options in case global mixins are applied after
  4807. // component constructor creation
  4808. resolveConstructorOptions(Ctor);
  4809. // transform component v-model data into props & events
  4810. if (isDef(data.model)) {
  4811. // @ts-expect-error
  4812. transformModel(Ctor.options, data);
  4813. }
  4814. // extract props
  4815. // @ts-expect-error
  4816. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4817. // functional component
  4818. // @ts-expect-error
  4819. if (isTrue(Ctor.options.functional)) {
  4820. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4821. }
  4822. // extract listeners, since these needs to be treated as
  4823. // child component listeners instead of DOM listeners
  4824. const listeners = data.on;
  4825. // replace with listeners with .native modifier
  4826. // so it gets processed during parent component patch.
  4827. data.on = data.nativeOn;
  4828. // @ts-expect-error
  4829. if (isTrue(Ctor.options.abstract)) {
  4830. // abstract components do not keep anything
  4831. // other than props & listeners & slot
  4832. // work around flow
  4833. const slot = data.slot;
  4834. data = {};
  4835. if (slot) {
  4836. data.slot = slot;
  4837. }
  4838. }
  4839. // install component management hooks onto the placeholder node
  4840. installComponentHooks(data);
  4841. // return a placeholder vnode
  4842. // @ts-expect-error
  4843. const name = getComponentName(Ctor.options) || tag;
  4844. const vnode = new VNode(
  4845. // @ts-expect-error
  4846. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4847. // @ts-expect-error
  4848. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4849. return vnode;
  4850. }
  4851. function createComponentInstanceForVnode(
  4852. // we know it's MountedComponentVNode but flow doesn't
  4853. vnode,
  4854. // activeInstance in lifecycle state
  4855. parent) {
  4856. const options = {
  4857. _isComponent: true,
  4858. _parentVnode: vnode,
  4859. parent
  4860. };
  4861. // check inline-template render functions
  4862. const inlineTemplate = vnode.data.inlineTemplate;
  4863. if (isDef(inlineTemplate)) {
  4864. options.render = inlineTemplate.render;
  4865. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4866. }
  4867. return new vnode.componentOptions.Ctor(options);
  4868. }
  4869. function installComponentHooks(data) {
  4870. const hooks = data.hook || (data.hook = {});
  4871. for (let i = 0; i < hooksToMerge.length; i++) {
  4872. const key = hooksToMerge[i];
  4873. const existing = hooks[key];
  4874. const toMerge = componentVNodeHooks[key];
  4875. // @ts-expect-error
  4876. if (existing !== toMerge && !(existing && existing._merged)) {
  4877. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4878. }
  4879. }
  4880. }
  4881. function mergeHook(f1, f2) {
  4882. const merged = (a, b) => {
  4883. // flow complains about extra args which is why we use any
  4884. f1(a, b);
  4885. f2(a, b);
  4886. };
  4887. merged._merged = true;
  4888. return merged;
  4889. }
  4890. // transform component v-model info (value and callback) into
  4891. // prop and event handler respectively.
  4892. function transformModel(options, data) {
  4893. const prop = (options.model && options.model.prop) || 'value';
  4894. const event = (options.model && options.model.event) || 'input';
  4895. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4896. const on = data.on || (data.on = {});
  4897. const existing = on[event];
  4898. const callback = data.model.callback;
  4899. if (isDef(existing)) {
  4900. if (isArray(existing)
  4901. ? existing.indexOf(callback) === -1
  4902. : existing !== callback) {
  4903. on[event] = [callback].concat(existing);
  4904. }
  4905. }
  4906. else {
  4907. on[event] = callback;
  4908. }
  4909. }
  4910. let warn$3 = noop;
  4911. let tip = noop;
  4912. let generateComponentTrace; // work around flow check
  4913. let formatComponentName;
  4914. if (process.env.NODE_ENV !== 'production') {
  4915. const hasConsole = typeof console !== 'undefined';
  4916. const classifyRE = /(?:^|[-_])(\w)/g;
  4917. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4918. warn$3 = (msg, vm = currentInstance) => {
  4919. const trace = vm ? generateComponentTrace(vm) : '';
  4920. if (hasConsole && !config.silent) {
  4921. console.error(`[Vue warn]: ${msg}${trace}`);
  4922. }
  4923. };
  4924. tip = (msg, vm) => {
  4925. if (hasConsole && !config.silent) {
  4926. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4927. }
  4928. };
  4929. formatComponentName = (vm, includeFile) => {
  4930. if (vm.$root === vm) {
  4931. return '<Root>';
  4932. }
  4933. const options = isFunction(vm) && vm.cid != null
  4934. ? vm.options
  4935. : vm._isVue
  4936. ? vm.$options || vm.constructor.options
  4937. : vm;
  4938. let name = getComponentName(options);
  4939. const file = options.__file;
  4940. if (!name && file) {
  4941. const match = file.match(/([^/\\]+)\.vue$/);
  4942. name = match && match[1];
  4943. }
  4944. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4945. (file && includeFile !== false ? ` at ${file}` : ''));
  4946. };
  4947. const repeat = (str, n) => {
  4948. let res = '';
  4949. while (n) {
  4950. if (n % 2 === 1)
  4951. res += str;
  4952. if (n > 1)
  4953. str += str;
  4954. n >>= 1;
  4955. }
  4956. return res;
  4957. };
  4958. generateComponentTrace = (vm) => {
  4959. if (vm._isVue && vm.$parent) {
  4960. const tree = [];
  4961. let currentRecursiveSequence = 0;
  4962. while (vm) {
  4963. if (tree.length > 0) {
  4964. const last = tree[tree.length - 1];
  4965. if (last.constructor === vm.constructor) {
  4966. currentRecursiveSequence++;
  4967. vm = vm.$parent;
  4968. continue;
  4969. }
  4970. else if (currentRecursiveSequence > 0) {
  4971. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4972. currentRecursiveSequence = 0;
  4973. }
  4974. }
  4975. tree.push(vm);
  4976. vm = vm.$parent;
  4977. }
  4978. return ('\n\nfound in\n\n' +
  4979. tree
  4980. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4981. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4982. : formatComponentName(vm)}`)
  4983. .join('\n'));
  4984. }
  4985. else {
  4986. return `\n\n(found in ${formatComponentName(vm)})`;
  4987. }
  4988. };
  4989. }
  4990. /**
  4991. * Option overwriting strategies are functions that handle
  4992. * how to merge a parent option value and a child option
  4993. * value into the final value.
  4994. */
  4995. const strats = config.optionMergeStrategies;
  4996. /**
  4997. * Options with restrictions
  4998. */
  4999. if (process.env.NODE_ENV !== 'production') {
  5000. strats.el = strats.propsData = function (parent, child, vm, key) {
  5001. if (!vm) {
  5002. warn$3(`option "${key}" can only be used during instance ` +
  5003. 'creation with the `new` keyword.');
  5004. }
  5005. return defaultStrat(parent, child);
  5006. };
  5007. }
  5008. /**
  5009. * Helper that recursively merges two data objects together.
  5010. */
  5011. function mergeData(to, from, recursive = true) {
  5012. if (!from)
  5013. return to;
  5014. let key, toVal, fromVal;
  5015. const keys = hasSymbol
  5016. ? Reflect.ownKeys(from)
  5017. : Object.keys(from);
  5018. for (let i = 0; i < keys.length; i++) {
  5019. key = keys[i];
  5020. // in case the object is already observed...
  5021. if (key === '__ob__')
  5022. continue;
  5023. toVal = to[key];
  5024. fromVal = from[key];
  5025. if (!recursive || !hasOwn(to, key)) {
  5026. set(to, key, fromVal);
  5027. }
  5028. else if (toVal !== fromVal &&
  5029. isPlainObject(toVal) &&
  5030. isPlainObject(fromVal)) {
  5031. mergeData(toVal, fromVal);
  5032. }
  5033. }
  5034. return to;
  5035. }
  5036. /**
  5037. * Data
  5038. */
  5039. function mergeDataOrFn(parentVal, childVal, vm) {
  5040. if (!vm) {
  5041. // in a Vue.extend merge, both should be functions
  5042. if (!childVal) {
  5043. return parentVal;
  5044. }
  5045. if (!parentVal) {
  5046. return childVal;
  5047. }
  5048. // when parentVal & childVal are both present,
  5049. // we need to return a function that returns the
  5050. // merged result of both functions... no need to
  5051. // check if parentVal is a function here because
  5052. // it has to be a function to pass previous merges.
  5053. return function mergedDataFn() {
  5054. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5055. };
  5056. }
  5057. else {
  5058. return function mergedInstanceDataFn() {
  5059. // instance merge
  5060. const instanceData = isFunction(childVal)
  5061. ? childVal.call(vm, vm)
  5062. : childVal;
  5063. const defaultData = isFunction(parentVal)
  5064. ? parentVal.call(vm, vm)
  5065. : parentVal;
  5066. if (instanceData) {
  5067. return mergeData(instanceData, defaultData);
  5068. }
  5069. else {
  5070. return defaultData;
  5071. }
  5072. };
  5073. }
  5074. }
  5075. strats.data = function (parentVal, childVal, vm) {
  5076. if (!vm) {
  5077. if (childVal && typeof childVal !== 'function') {
  5078. process.env.NODE_ENV !== 'production' &&
  5079. warn$3('The "data" option should be a function ' +
  5080. 'that returns a per-instance value in component ' +
  5081. 'definitions.', vm);
  5082. return parentVal;
  5083. }
  5084. return mergeDataOrFn(parentVal, childVal);
  5085. }
  5086. return mergeDataOrFn(parentVal, childVal, vm);
  5087. };
  5088. /**
  5089. * Hooks and props are merged as arrays.
  5090. */
  5091. function mergeLifecycleHook(parentVal, childVal) {
  5092. const res = childVal
  5093. ? parentVal
  5094. ? parentVal.concat(childVal)
  5095. : isArray(childVal)
  5096. ? childVal
  5097. : [childVal]
  5098. : parentVal;
  5099. return res ? dedupeHooks(res) : res;
  5100. }
  5101. function dedupeHooks(hooks) {
  5102. const res = [];
  5103. for (let i = 0; i < hooks.length; i++) {
  5104. if (res.indexOf(hooks[i]) === -1) {
  5105. res.push(hooks[i]);
  5106. }
  5107. }
  5108. return res;
  5109. }
  5110. LIFECYCLE_HOOKS.forEach(hook => {
  5111. strats[hook] = mergeLifecycleHook;
  5112. });
  5113. /**
  5114. * Assets
  5115. *
  5116. * When a vm is present (instance creation), we need to do
  5117. * a three-way merge between constructor options, instance
  5118. * options and parent options.
  5119. */
  5120. function mergeAssets(parentVal, childVal, vm, key) {
  5121. const res = Object.create(parentVal || null);
  5122. if (childVal) {
  5123. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  5124. return extend(res, childVal);
  5125. }
  5126. else {
  5127. return res;
  5128. }
  5129. }
  5130. ASSET_TYPES.forEach(function (type) {
  5131. strats[type + 's'] = mergeAssets;
  5132. });
  5133. /**
  5134. * Watchers.
  5135. *
  5136. * Watchers hashes should not overwrite one
  5137. * another, so we merge them as arrays.
  5138. */
  5139. strats.watch = function (parentVal, childVal, vm, key) {
  5140. // work around Firefox's Object.prototype.watch...
  5141. //@ts-expect-error work around
  5142. if (parentVal === nativeWatch)
  5143. parentVal = undefined;
  5144. //@ts-expect-error work around
  5145. if (childVal === nativeWatch)
  5146. childVal = undefined;
  5147. /* istanbul ignore if */
  5148. if (!childVal)
  5149. return Object.create(parentVal || null);
  5150. if (process.env.NODE_ENV !== 'production') {
  5151. assertObjectType(key, childVal, vm);
  5152. }
  5153. if (!parentVal)
  5154. return childVal;
  5155. const ret = {};
  5156. extend(ret, parentVal);
  5157. for (const key in childVal) {
  5158. let parent = ret[key];
  5159. const child = childVal[key];
  5160. if (parent && !isArray(parent)) {
  5161. parent = [parent];
  5162. }
  5163. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5164. }
  5165. return ret;
  5166. };
  5167. /**
  5168. * Other object hashes.
  5169. */
  5170. strats.props =
  5171. strats.methods =
  5172. strats.inject =
  5173. strats.computed =
  5174. function (parentVal, childVal, vm, key) {
  5175. if (childVal && process.env.NODE_ENV !== 'production') {
  5176. assertObjectType(key, childVal, vm);
  5177. }
  5178. if (!parentVal)
  5179. return childVal;
  5180. const ret = Object.create(null);
  5181. extend(ret, parentVal);
  5182. if (childVal)
  5183. extend(ret, childVal);
  5184. return ret;
  5185. };
  5186. strats.provide = function (parentVal, childVal) {
  5187. if (!parentVal)
  5188. return childVal;
  5189. return function () {
  5190. const ret = Object.create(null);
  5191. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  5192. if (childVal) {
  5193. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  5194. );
  5195. }
  5196. return ret;
  5197. };
  5198. };
  5199. /**
  5200. * Default strategy.
  5201. */
  5202. const defaultStrat = function (parentVal, childVal) {
  5203. return childVal === undefined ? parentVal : childVal;
  5204. };
  5205. /**
  5206. * Validate component names
  5207. */
  5208. function checkComponents(options) {
  5209. for (const key in options.components) {
  5210. validateComponentName(key);
  5211. }
  5212. }
  5213. function validateComponentName(name) {
  5214. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5215. warn$3('Invalid component name: "' +
  5216. name +
  5217. '". Component names ' +
  5218. 'should conform to valid custom element name in html5 specification.');
  5219. }
  5220. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5221. warn$3('Do not use built-in or reserved HTML elements as component ' +
  5222. 'id: ' +
  5223. name);
  5224. }
  5225. }
  5226. /**
  5227. * Ensure all props option syntax are normalized into the
  5228. * Object-based format.
  5229. */
  5230. function normalizeProps(options, vm) {
  5231. const props = options.props;
  5232. if (!props)
  5233. return;
  5234. const res = {};
  5235. let i, val, name;
  5236. if (isArray(props)) {
  5237. i = props.length;
  5238. while (i--) {
  5239. val = props[i];
  5240. if (typeof val === 'string') {
  5241. name = camelize(val);
  5242. res[name] = { type: null };
  5243. }
  5244. else if (process.env.NODE_ENV !== 'production') {
  5245. warn$3('props must be strings when using array syntax.');
  5246. }
  5247. }
  5248. }
  5249. else if (isPlainObject(props)) {
  5250. for (const key in props) {
  5251. val = props[key];
  5252. name = camelize(key);
  5253. res[name] = isPlainObject(val) ? val : { type: val };
  5254. }
  5255. }
  5256. else if (process.env.NODE_ENV !== 'production') {
  5257. warn$3(`Invalid value for option "props": expected an Array or an Object, ` +
  5258. `but got ${toRawType(props)}.`, vm);
  5259. }
  5260. options.props = res;
  5261. }
  5262. /**
  5263. * Normalize all injections into Object-based format
  5264. */
  5265. function normalizeInject(options, vm) {
  5266. const inject = options.inject;
  5267. if (!inject)
  5268. return;
  5269. const normalized = (options.inject = {});
  5270. if (isArray(inject)) {
  5271. for (let i = 0; i < inject.length; i++) {
  5272. normalized[inject[i]] = { from: inject[i] };
  5273. }
  5274. }
  5275. else if (isPlainObject(inject)) {
  5276. for (const key in inject) {
  5277. const val = inject[key];
  5278. normalized[key] = isPlainObject(val)
  5279. ? extend({ from: key }, val)
  5280. : { from: val };
  5281. }
  5282. }
  5283. else if (process.env.NODE_ENV !== 'production') {
  5284. warn$3(`Invalid value for option "inject": expected an Array or an Object, ` +
  5285. `but got ${toRawType(inject)}.`, vm);
  5286. }
  5287. }
  5288. /**
  5289. * Normalize raw function directives into object format.
  5290. */
  5291. function normalizeDirectives(options) {
  5292. const dirs = options.directives;
  5293. if (dirs) {
  5294. for (const key in dirs) {
  5295. const def = dirs[key];
  5296. if (isFunction(def)) {
  5297. dirs[key] = { bind: def, update: def };
  5298. }
  5299. }
  5300. }
  5301. }
  5302. function assertObjectType(name, value, vm) {
  5303. if (!isPlainObject(value)) {
  5304. warn$3(`Invalid value for option "${name}": expected an Object, ` +
  5305. `but got ${toRawType(value)}.`, vm);
  5306. }
  5307. }
  5308. /**
  5309. * Merge two option objects into a new one.
  5310. * Core utility used in both instantiation and inheritance.
  5311. */
  5312. function mergeOptions(parent, child, vm) {
  5313. if (process.env.NODE_ENV !== 'production') {
  5314. checkComponents(child);
  5315. }
  5316. if (isFunction(child)) {
  5317. // @ts-expect-error
  5318. child = child.options;
  5319. }
  5320. normalizeProps(child, vm);
  5321. normalizeInject(child, vm);
  5322. normalizeDirectives(child);
  5323. // Apply extends and mixins on the child options,
  5324. // but only if it is a raw options object that isn't
  5325. // the result of another mergeOptions call.
  5326. // Only merged options has the _base property.
  5327. if (!child._base) {
  5328. if (child.extends) {
  5329. parent = mergeOptions(parent, child.extends, vm);
  5330. }
  5331. if (child.mixins) {
  5332. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5333. parent = mergeOptions(parent, child.mixins[i], vm);
  5334. }
  5335. }
  5336. }
  5337. const options = {};
  5338. let key;
  5339. for (key in parent) {
  5340. mergeField(key);
  5341. }
  5342. for (key in child) {
  5343. if (!hasOwn(parent, key)) {
  5344. mergeField(key);
  5345. }
  5346. }
  5347. function mergeField(key) {
  5348. const strat = strats[key] || defaultStrat;
  5349. options[key] = strat(parent[key], child[key], vm, key);
  5350. }
  5351. return options;
  5352. }
  5353. /**
  5354. * Resolve an asset.
  5355. * This function is used because child instances need access
  5356. * to assets defined in its ancestor chain.
  5357. */
  5358. function resolveAsset(options, type, id, warnMissing) {
  5359. /* istanbul ignore if */
  5360. if (typeof id !== 'string') {
  5361. return;
  5362. }
  5363. const assets = options[type];
  5364. // check local registration variations first
  5365. if (hasOwn(assets, id))
  5366. return assets[id];
  5367. const camelizedId = camelize(id);
  5368. if (hasOwn(assets, camelizedId))
  5369. return assets[camelizedId];
  5370. const PascalCaseId = capitalize(camelizedId);
  5371. if (hasOwn(assets, PascalCaseId))
  5372. return assets[PascalCaseId];
  5373. // fallback to prototype chain
  5374. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5375. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  5376. warn$3('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5377. }
  5378. return res;
  5379. }
  5380. function validateProp(key, propOptions, propsData, vm) {
  5381. const prop = propOptions[key];
  5382. const absent = !hasOwn(propsData, key);
  5383. let value = propsData[key];
  5384. // boolean casting
  5385. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5386. if (booleanIndex > -1) {
  5387. if (absent && !hasOwn(prop, 'default')) {
  5388. value = false;
  5389. }
  5390. else if (value === '' || value === hyphenate(key)) {
  5391. // only cast empty string / same name to boolean if
  5392. // boolean has higher priority
  5393. const stringIndex = getTypeIndex(String, prop.type);
  5394. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5395. value = true;
  5396. }
  5397. }
  5398. }
  5399. // check default value
  5400. if (value === undefined) {
  5401. value = getPropDefaultValue(vm, prop, key);
  5402. // since the default value is a fresh copy,
  5403. // make sure to observe it.
  5404. const prevShouldObserve = shouldObserve;
  5405. toggleObserving(true);
  5406. observe(value);
  5407. toggleObserving(prevShouldObserve);
  5408. }
  5409. if (process.env.NODE_ENV !== 'production') {
  5410. assertProp(prop, key, value, vm, absent);
  5411. }
  5412. return value;
  5413. }
  5414. /**
  5415. * Get the default value of a prop.
  5416. */
  5417. function getPropDefaultValue(vm, prop, key) {
  5418. // no default, return undefined
  5419. if (!hasOwn(prop, 'default')) {
  5420. return undefined;
  5421. }
  5422. const def = prop.default;
  5423. // warn against non-factory defaults for Object & Array
  5424. if (process.env.NODE_ENV !== 'production' && isObject$1(def)) {
  5425. warn$3('Invalid default value for prop "' +
  5426. key +
  5427. '": ' +
  5428. 'Props with type Object/Array must use a factory function ' +
  5429. 'to return the default value.', vm);
  5430. }
  5431. // the raw prop value was also undefined from previous render,
  5432. // return previous default value to avoid unnecessary watcher trigger
  5433. if (vm &&
  5434. vm.$options.propsData &&
  5435. vm.$options.propsData[key] === undefined &&
  5436. vm._props[key] !== undefined) {
  5437. return vm._props[key];
  5438. }
  5439. // call factory function for non-Function types
  5440. // a value is Function if its prototype is function even across different execution context
  5441. return isFunction(def) && getType(prop.type) !== 'Function'
  5442. ? def.call(vm)
  5443. : def;
  5444. }
  5445. /**
  5446. * Assert whether a prop is valid.
  5447. */
  5448. function assertProp(prop, name, value, vm, absent) {
  5449. if (prop.required && absent) {
  5450. warn$3('Missing required prop: "' + name + '"', vm);
  5451. return;
  5452. }
  5453. if (value == null && !prop.required) {
  5454. return;
  5455. }
  5456. let type = prop.type;
  5457. let valid = !type || type === true;
  5458. const expectedTypes = [];
  5459. if (type) {
  5460. if (!isArray(type)) {
  5461. type = [type];
  5462. }
  5463. for (let i = 0; i < type.length && !valid; i++) {
  5464. const assertedType = assertType(value, type[i], vm);
  5465. expectedTypes.push(assertedType.expectedType || '');
  5466. valid = assertedType.valid;
  5467. }
  5468. }
  5469. const haveExpectedTypes = expectedTypes.some(t => t);
  5470. if (!valid && haveExpectedTypes) {
  5471. warn$3(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5472. return;
  5473. }
  5474. const validator = prop.validator;
  5475. if (validator) {
  5476. if (!validator(value)) {
  5477. warn$3('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5478. }
  5479. }
  5480. }
  5481. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5482. function assertType(value, type, vm) {
  5483. let valid;
  5484. const expectedType = getType(type);
  5485. if (simpleCheckRE.test(expectedType)) {
  5486. const t = typeof value;
  5487. valid = t === expectedType.toLowerCase();
  5488. // for primitive wrapper objects
  5489. if (!valid && t === 'object') {
  5490. valid = value instanceof type;
  5491. }
  5492. }
  5493. else if (expectedType === 'Object') {
  5494. valid = isPlainObject(value);
  5495. }
  5496. else if (expectedType === 'Array') {
  5497. valid = isArray(value);
  5498. }
  5499. else {
  5500. try {
  5501. valid = value instanceof type;
  5502. }
  5503. catch (e) {
  5504. warn$3('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5505. valid = false;
  5506. }
  5507. }
  5508. return {
  5509. valid,
  5510. expectedType
  5511. };
  5512. }
  5513. const functionTypeCheckRE = /^\s*function (\w+)/;
  5514. /**
  5515. * Use function string name to check built-in types,
  5516. * because a simple equality check will fail when running
  5517. * across different vms / iframes.
  5518. */
  5519. function getType(fn) {
  5520. const match = fn && fn.toString().match(functionTypeCheckRE);
  5521. return match ? match[1] : '';
  5522. }
  5523. function isSameType(a, b) {
  5524. return getType(a) === getType(b);
  5525. }
  5526. function getTypeIndex(type, expectedTypes) {
  5527. if (!isArray(expectedTypes)) {
  5528. return isSameType(expectedTypes, type) ? 0 : -1;
  5529. }
  5530. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5531. if (isSameType(expectedTypes[i], type)) {
  5532. return i;
  5533. }
  5534. }
  5535. return -1;
  5536. }
  5537. function getInvalidTypeMessage(name, value, expectedTypes) {
  5538. let message = `Invalid prop: type check failed for prop "${name}".` +
  5539. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5540. const expectedType = expectedTypes[0];
  5541. const receivedType = toRawType(value);
  5542. // check if we need to specify expected value
  5543. if (expectedTypes.length === 1 &&
  5544. isExplicable(expectedType) &&
  5545. isExplicable(typeof value) &&
  5546. !isBoolean(expectedType, receivedType)) {
  5547. message += ` with value ${styleValue(value, expectedType)}`;
  5548. }
  5549. message += `, got ${receivedType} `;
  5550. // check if we need to specify received value
  5551. if (isExplicable(receivedType)) {
  5552. message += `with value ${styleValue(value, receivedType)}.`;
  5553. }
  5554. return message;
  5555. }
  5556. function styleValue(value, type) {
  5557. if (type === 'String') {
  5558. return `"${value}"`;
  5559. }
  5560. else if (type === 'Number') {
  5561. return `${Number(value)}`;
  5562. }
  5563. else {
  5564. return `${value}`;
  5565. }
  5566. }
  5567. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5568. function isExplicable(value) {
  5569. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5570. }
  5571. function isBoolean(...args) {
  5572. return args.some(elem => elem.toLowerCase() === 'boolean');
  5573. }
  5574. // these are reserved for web because they are directly compiled away
  5575. // during template compilation
  5576. makeMap('style,class');
  5577. // attributes that should be using props for binding
  5578. const acceptValue = makeMap('input,textarea,option,select,progress');
  5579. const mustUseProp = (tag, type, attr) => {
  5580. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5581. (attr === 'selected' && tag === 'option') ||
  5582. (attr === 'checked' && tag === 'input') ||
  5583. (attr === 'muted' && tag === 'video'));
  5584. };
  5585. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5586. makeMap('events,caret,typing,plaintext-only');
  5587. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5588. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5589. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5590. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5591. 'required,reversed,scoped,seamless,selected,sortable,' +
  5592. 'truespeed,typemustmatch,visible');
  5593. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  5594. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5595. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5596. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5597. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5598. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5599. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5600. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5601. 'output,progress,select,textarea,' +
  5602. 'details,dialog,menu,menuitem,summary,' +
  5603. 'content,element,shadow,template,blockquote,iframe,tfoot');
  5604. // this map is intentionally selective, only covering SVG elements that may
  5605. // contain child elements.
  5606. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5607. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5608. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  5609. const isPreTag = (tag) => tag === 'pre';
  5610. const isReservedTag = (tag) => {
  5611. return isHTMLTag(tag) || isSVG(tag);
  5612. };
  5613. function getTagNamespace(tag) {
  5614. if (isSVG(tag)) {
  5615. return 'svg';
  5616. }
  5617. // basic support for MathML
  5618. // note it doesn't support other MathML elements being component roots
  5619. if (tag === 'math') {
  5620. return 'math';
  5621. }
  5622. }
  5623. makeMap('text,number,password,search,email,tel,url');
  5624. const validDivisionCharRE = /[\w).+\-_$\]]/;
  5625. function parseFilters(exp) {
  5626. let inSingle = false;
  5627. let inDouble = false;
  5628. let inTemplateString = false;
  5629. let inRegex = false;
  5630. let curly = 0;
  5631. let square = 0;
  5632. let paren = 0;
  5633. let lastFilterIndex = 0;
  5634. let c, prev, i, expression, filters;
  5635. for (i = 0; i < exp.length; i++) {
  5636. prev = c;
  5637. c = exp.charCodeAt(i);
  5638. if (inSingle) {
  5639. if (c === 0x27 && prev !== 0x5c)
  5640. inSingle = false;
  5641. }
  5642. else if (inDouble) {
  5643. if (c === 0x22 && prev !== 0x5c)
  5644. inDouble = false;
  5645. }
  5646. else if (inTemplateString) {
  5647. if (c === 0x60 && prev !== 0x5c)
  5648. inTemplateString = false;
  5649. }
  5650. else if (inRegex) {
  5651. if (c === 0x2f && prev !== 0x5c)
  5652. inRegex = false;
  5653. }
  5654. else if (c === 0x7c && // pipe
  5655. exp.charCodeAt(i + 1) !== 0x7c &&
  5656. exp.charCodeAt(i - 1) !== 0x7c &&
  5657. !curly &&
  5658. !square &&
  5659. !paren) {
  5660. if (expression === undefined) {
  5661. // first filter, end of expression
  5662. lastFilterIndex = i + 1;
  5663. expression = exp.slice(0, i).trim();
  5664. }
  5665. else {
  5666. pushFilter();
  5667. }
  5668. }
  5669. else {
  5670. switch (c) {
  5671. case 0x22:
  5672. inDouble = true;
  5673. break; // "
  5674. case 0x27:
  5675. inSingle = true;
  5676. break; // '
  5677. case 0x60:
  5678. inTemplateString = true;
  5679. break; // `
  5680. case 0x28:
  5681. paren++;
  5682. break; // (
  5683. case 0x29:
  5684. paren--;
  5685. break; // )
  5686. case 0x5b:
  5687. square++;
  5688. break; // [
  5689. case 0x5d:
  5690. square--;
  5691. break; // ]
  5692. case 0x7b:
  5693. curly++;
  5694. break; // {
  5695. case 0x7d:
  5696. curly--;
  5697. break; // }
  5698. }
  5699. if (c === 0x2f) {
  5700. // /
  5701. let j = i - 1;
  5702. let p;
  5703. // find first non-whitespace prev char
  5704. for (; j >= 0; j--) {
  5705. p = exp.charAt(j);
  5706. if (p !== ' ')
  5707. break;
  5708. }
  5709. if (!p || !validDivisionCharRE.test(p)) {
  5710. inRegex = true;
  5711. }
  5712. }
  5713. }
  5714. }
  5715. if (expression === undefined) {
  5716. expression = exp.slice(0, i).trim();
  5717. }
  5718. else if (lastFilterIndex !== 0) {
  5719. pushFilter();
  5720. }
  5721. function pushFilter() {
  5722. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  5723. lastFilterIndex = i + 1;
  5724. }
  5725. if (filters) {
  5726. for (i = 0; i < filters.length; i++) {
  5727. expression = wrapFilter(expression, filters[i]);
  5728. }
  5729. }
  5730. return expression;
  5731. }
  5732. function wrapFilter(exp, filter) {
  5733. const i = filter.indexOf('(');
  5734. if (i < 0) {
  5735. // _f: resolveFilter
  5736. return `_f("${filter}")(${exp})`;
  5737. }
  5738. else {
  5739. const name = filter.slice(0, i);
  5740. const args = filter.slice(i + 1);
  5741. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  5742. }
  5743. }
  5744. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  5745. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  5746. const buildRegex = cached(delimiters => {
  5747. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  5748. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  5749. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  5750. });
  5751. function parseText(text, delimiters) {
  5752. //@ts-expect-error
  5753. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  5754. if (!tagRE.test(text)) {
  5755. return;
  5756. }
  5757. const tokens = [];
  5758. const rawTokens = [];
  5759. let lastIndex = (tagRE.lastIndex = 0);
  5760. let match, index, tokenValue;
  5761. while ((match = tagRE.exec(text))) {
  5762. index = match.index;
  5763. // push text token
  5764. if (index > lastIndex) {
  5765. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  5766. tokens.push(JSON.stringify(tokenValue));
  5767. }
  5768. // tag token
  5769. const exp = parseFilters(match[1].trim());
  5770. tokens.push(`_s(${exp})`);
  5771. rawTokens.push({ '@binding': exp });
  5772. lastIndex = index + match[0].length;
  5773. }
  5774. if (lastIndex < text.length) {
  5775. rawTokens.push((tokenValue = text.slice(lastIndex)));
  5776. tokens.push(JSON.stringify(tokenValue));
  5777. }
  5778. return {
  5779. expression: tokens.join('+'),
  5780. tokens: rawTokens
  5781. };
  5782. }
  5783. /* eslint-disable no-unused-vars */
  5784. function baseWarn(msg, range) {
  5785. console.error(`[Vue compiler]: ${msg}`);
  5786. }
  5787. /* eslint-enable no-unused-vars */
  5788. function pluckModuleFunction(modules, key) {
  5789. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  5790. }
  5791. function addProp(el, name, value, range, dynamic) {
  5792. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  5793. el.plain = false;
  5794. }
  5795. function addAttr(el, name, value, range, dynamic) {
  5796. const attrs = dynamic
  5797. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  5798. : el.attrs || (el.attrs = []);
  5799. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  5800. el.plain = false;
  5801. }
  5802. // add a raw attr (use this in preTransforms)
  5803. function addRawAttr(el, name, value, range) {
  5804. el.attrsMap[name] = value;
  5805. el.attrsList.push(rangeSetItem({ name, value }, range));
  5806. }
  5807. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  5808. (el.directives || (el.directives = [])).push(rangeSetItem({
  5809. name,
  5810. rawName,
  5811. value,
  5812. arg,
  5813. isDynamicArg,
  5814. modifiers
  5815. }, range));
  5816. el.plain = false;
  5817. }
  5818. function prependModifierMarker(symbol, name, dynamic) {
  5819. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  5820. }
  5821. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  5822. modifiers = modifiers || emptyObject;
  5823. // warn prevent and passive modifier
  5824. /* istanbul ignore if */
  5825. if (process.env.NODE_ENV !== 'production' && warn && modifiers.prevent && modifiers.passive) {
  5826. warn("passive and prevent can't be used together. " +
  5827. "Passive handler can't prevent default event.", range);
  5828. }
  5829. // normalize click.right and click.middle since they don't actually fire
  5830. // this is technically browser-specific, but at least for now browsers are
  5831. // the only target envs that have right/middle clicks.
  5832. if (modifiers.right) {
  5833. if (dynamic) {
  5834. name = `(${name})==='click'?'contextmenu':(${name})`;
  5835. }
  5836. else if (name === 'click') {
  5837. name = 'contextmenu';
  5838. delete modifiers.right;
  5839. }
  5840. }
  5841. else if (modifiers.middle) {
  5842. if (dynamic) {
  5843. name = `(${name})==='click'?'mouseup':(${name})`;
  5844. }
  5845. else if (name === 'click') {
  5846. name = 'mouseup';
  5847. }
  5848. }
  5849. // check capture modifier
  5850. if (modifiers.capture) {
  5851. delete modifiers.capture;
  5852. name = prependModifierMarker('!', name, dynamic);
  5853. }
  5854. if (modifiers.once) {
  5855. delete modifiers.once;
  5856. name = prependModifierMarker('~', name, dynamic);
  5857. }
  5858. /* istanbul ignore if */
  5859. if (modifiers.passive) {
  5860. delete modifiers.passive;
  5861. name = prependModifierMarker('&', name, dynamic);
  5862. }
  5863. let events;
  5864. if (modifiers.native) {
  5865. delete modifiers.native;
  5866. events = el.nativeEvents || (el.nativeEvents = {});
  5867. }
  5868. else {
  5869. events = el.events || (el.events = {});
  5870. }
  5871. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  5872. if (modifiers !== emptyObject) {
  5873. newHandler.modifiers = modifiers;
  5874. }
  5875. const handlers = events[name];
  5876. /* istanbul ignore if */
  5877. if (Array.isArray(handlers)) {
  5878. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  5879. }
  5880. else if (handlers) {
  5881. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  5882. }
  5883. else {
  5884. events[name] = newHandler;
  5885. }
  5886. el.plain = false;
  5887. }
  5888. function getRawBindingAttr(el, name) {
  5889. return (el.rawAttrsMap[':' + name] ||
  5890. el.rawAttrsMap['v-bind:' + name] ||
  5891. el.rawAttrsMap[name]);
  5892. }
  5893. function getBindingAttr(el, name, getStatic) {
  5894. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  5895. if (dynamicValue != null) {
  5896. return parseFilters(dynamicValue);
  5897. }
  5898. else if (getStatic !== false) {
  5899. const staticValue = getAndRemoveAttr(el, name);
  5900. if (staticValue != null) {
  5901. return JSON.stringify(staticValue);
  5902. }
  5903. }
  5904. }
  5905. // note: this only removes the attr from the Array (attrsList) so that it
  5906. // doesn't get processed by processAttrs.
  5907. // By default it does NOT remove it from the map (attrsMap) because the map is
  5908. // needed during codegen.
  5909. function getAndRemoveAttr(el, name, removeFromMap) {
  5910. let val;
  5911. if ((val = el.attrsMap[name]) != null) {
  5912. const list = el.attrsList;
  5913. for (let i = 0, l = list.length; i < l; i++) {
  5914. if (list[i].name === name) {
  5915. list.splice(i, 1);
  5916. break;
  5917. }
  5918. }
  5919. }
  5920. if (removeFromMap) {
  5921. delete el.attrsMap[name];
  5922. }
  5923. return val;
  5924. }
  5925. function getAndRemoveAttrByRegex(el, name) {
  5926. const list = el.attrsList;
  5927. for (let i = 0, l = list.length; i < l; i++) {
  5928. const attr = list[i];
  5929. if (name.test(attr.name)) {
  5930. list.splice(i, 1);
  5931. return attr;
  5932. }
  5933. }
  5934. }
  5935. function rangeSetItem(item, range) {
  5936. if (range) {
  5937. if (range.start != null) {
  5938. item.start = range.start;
  5939. }
  5940. if (range.end != null) {
  5941. item.end = range.end;
  5942. }
  5943. }
  5944. return item;
  5945. }
  5946. function transformNode$1(el, options) {
  5947. const warn = options.warn || baseWarn;
  5948. const staticClass = getAndRemoveAttr(el, 'class');
  5949. if (process.env.NODE_ENV !== 'production' && staticClass) {
  5950. const res = parseText(staticClass, options.delimiters);
  5951. if (res) {
  5952. warn(`class="${staticClass}": ` +
  5953. 'Interpolation inside attributes has been removed. ' +
  5954. 'Use v-bind or the colon shorthand instead. For example, ' +
  5955. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  5956. }
  5957. }
  5958. if (staticClass) {
  5959. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  5960. }
  5961. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  5962. if (classBinding) {
  5963. el.classBinding = classBinding;
  5964. }
  5965. }
  5966. function genData$2(el) {
  5967. let data = '';
  5968. if (el.staticClass) {
  5969. data += `staticClass:${el.staticClass},`;
  5970. }
  5971. if (el.classBinding) {
  5972. data += `class:${el.classBinding},`;
  5973. }
  5974. return data;
  5975. }
  5976. var klass = {
  5977. staticKeys: ['staticClass'],
  5978. transformNode: transformNode$1,
  5979. genData: genData$2
  5980. };
  5981. const parseStyleText = cached(function (cssText) {
  5982. const res = {};
  5983. const listDelimiter = /;(?![^(]*\))/g;
  5984. const propertyDelimiter = /:(.+)/;
  5985. cssText.split(listDelimiter).forEach(function (item) {
  5986. if (item) {
  5987. const tmp = item.split(propertyDelimiter);
  5988. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  5989. }
  5990. });
  5991. return res;
  5992. });
  5993. function transformNode(el, options) {
  5994. const warn = options.warn || baseWarn;
  5995. const staticStyle = getAndRemoveAttr(el, 'style');
  5996. if (staticStyle) {
  5997. /* istanbul ignore if */
  5998. if (process.env.NODE_ENV !== 'production') {
  5999. const res = parseText(staticStyle, options.delimiters);
  6000. if (res) {
  6001. warn(`style="${staticStyle}": ` +
  6002. 'Interpolation inside attributes has been removed. ' +
  6003. 'Use v-bind or the colon shorthand instead. For example, ' +
  6004. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  6005. }
  6006. }
  6007. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  6008. }
  6009. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  6010. if (styleBinding) {
  6011. el.styleBinding = styleBinding;
  6012. }
  6013. }
  6014. function genData$1(el) {
  6015. let data = '';
  6016. if (el.staticStyle) {
  6017. data += `staticStyle:${el.staticStyle},`;
  6018. }
  6019. if (el.styleBinding) {
  6020. data += `style:(${el.styleBinding}),`;
  6021. }
  6022. return data;
  6023. }
  6024. var style = {
  6025. staticKeys: ['staticStyle'],
  6026. transformNode,
  6027. genData: genData$1
  6028. };
  6029. var he$1 = {exports: {}};
  6030. /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
  6031. (function (module, exports) {
  6032. (function(root) {
  6033. // Detect free variables `exports`.
  6034. var freeExports = exports;
  6035. // Detect free variable `module`.
  6036. var freeModule = module &&
  6037. module.exports == freeExports && module;
  6038. // Detect free variable `global`, from Node.js or Browserified code,
  6039. // and use it as `root`.
  6040. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
  6041. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  6042. root = freeGlobal;
  6043. }
  6044. /*--------------------------------------------------------------------------*/
  6045. // All astral symbols.
  6046. var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  6047. // All ASCII symbols (not just printable ASCII) except those listed in the
  6048. // first column of the overrides table.
  6049. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
  6050. var regexAsciiWhitelist = /[\x01-\x7F]/g;
  6051. // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
  6052. // code points listed in the first column of the overrides table on
  6053. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
  6054. var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
  6055. var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
  6056. var encodeMap = {'\xAD':'shy','\u200C':'zwnj','\u200D':'zwj','\u200E':'lrm','\u2063':'ic','\u2062':'it','\u2061':'af','\u200F':'rlm','\u200B':'ZeroWidthSpace','\u2060':'NoBreak','\u0311':'DownBreve','\u20DB':'tdot','\u20DC':'DotDot','\t':'Tab','\n':'NewLine','\u2008':'puncsp','\u205F':'MediumSpace','\u2009':'thinsp','\u200A':'hairsp','\u2004':'emsp13','\u2002':'ensp','\u2005':'emsp14','\u2003':'emsp','\u2007':'numsp','\xA0':'nbsp','\u205F\u200A':'ThickSpace','\u203E':'oline','_':'lowbar','\u2010':'dash','\u2013':'ndash','\u2014':'mdash','\u2015':'horbar',',':'comma',';':'semi','\u204F':'bsemi',':':'colon','\u2A74':'Colone','!':'excl','\xA1':'iexcl','?':'quest','\xBF':'iquest','.':'period','\u2025':'nldr','\u2026':'mldr','\xB7':'middot','\'':'apos','\u2018':'lsquo','\u2019':'rsquo','\u201A':'sbquo','\u2039':'lsaquo','\u203A':'rsaquo','"':'quot','\u201C':'ldquo','\u201D':'rdquo','\u201E':'bdquo','\xAB':'laquo','\xBB':'raquo','(':'lpar',')':'rpar','[':'lsqb',']':'rsqb','{':'lcub','}':'rcub','\u2308':'lceil','\u2309':'rceil','\u230A':'lfloor','\u230B':'rfloor','\u2985':'lopar','\u2986':'ropar','\u298B':'lbrke','\u298C':'rbrke','\u298D':'lbrkslu','\u298E':'rbrksld','\u298F':'lbrksld','\u2990':'rbrkslu','\u2991':'langd','\u2992':'rangd','\u2993':'lparlt','\u2994':'rpargt','\u2995':'gtlPar','\u2996':'ltrPar','\u27E6':'lobrk','\u27E7':'robrk','\u27E8':'lang','\u27E9':'rang','\u27EA':'Lang','\u27EB':'Rang','\u27EC':'loang','\u27ED':'roang','\u2772':'lbbrk','\u2773':'rbbrk','\u2016':'Vert','\xA7':'sect','\xB6':'para','@':'commat','*':'ast','/':'sol','undefined':null,'&':'amp','#':'num','%':'percnt','\u2030':'permil','\u2031':'pertenk','\u2020':'dagger','\u2021':'Dagger','\u2022':'bull','\u2043':'hybull','\u2032':'prime','\u2033':'Prime','\u2034':'tprime','\u2057':'qprime','\u2035':'bprime','\u2041':'caret','`':'grave','\xB4':'acute','\u02DC':'tilde','^':'Hat','\xAF':'macr','\u02D8':'breve','\u02D9':'dot','\xA8':'die','\u02DA':'ring','\u02DD':'dblac','\xB8':'cedil','\u02DB':'ogon','\u02C6':'circ','\u02C7':'caron','\xB0':'deg','\xA9':'copy','\xAE':'reg','\u2117':'copysr','\u2118':'wp','\u211E':'rx','\u2127':'mho','\u2129':'iiota','\u2190':'larr','\u219A':'nlarr','\u2192':'rarr','\u219B':'nrarr','\u2191':'uarr','\u2193':'darr','\u2194':'harr','\u21AE':'nharr','\u2195':'varr','\u2196':'nwarr','\u2197':'nearr','\u2198':'searr','\u2199':'swarr','\u219D':'rarrw','\u219D\u0338':'nrarrw','\u219E':'Larr','\u219F':'Uarr','\u21A0':'Rarr','\u21A1':'Darr','\u21A2':'larrtl','\u21A3':'rarrtl','\u21A4':'mapstoleft','\u21A5':'mapstoup','\u21A6':'map','\u21A7':'mapstodown','\u21A9':'larrhk','\u21AA':'rarrhk','\u21AB':'larrlp','\u21AC':'rarrlp','\u21AD':'harrw','\u21B0':'lsh','\u21B1':'rsh','\u21B2':'ldsh','\u21B3':'rdsh','\u21B5':'crarr','\u21B6':'cularr','\u21B7':'curarr','\u21BA':'olarr','\u21BB':'orarr','\u21BC':'lharu','\u21BD':'lhard','\u21BE':'uharr','\u21BF':'uharl','\u21C0':'rharu','\u21C1':'rhard','\u21C2':'dharr','\u21C3':'dharl','\u21C4':'rlarr','\u21C5':'udarr','\u21C6':'lrarr','\u21C7':'llarr','\u21C8':'uuarr','\u21C9':'rrarr','\u21CA':'ddarr','\u21CB':'lrhar','\u21CC':'rlhar','\u21D0':'lArr','\u21CD':'nlArr','\u21D1':'uArr','\u21D2':'rArr','\u21CF':'nrArr','\u21D3':'dArr','\u21D4':'iff','\u21CE':'nhArr','\u21D5':'vArr','\u21D6':'nwArr','\u21D7':'neArr','\u21D8':'seArr','\u21D9':'swArr','\u21DA':'lAarr','\u21DB':'rAarr','\u21DD':'zigrarr','\u21E4':'larrb','\u21E5':'rarrb','\u21F5':'duarr','\u21FD':'loarr','\u21FE':'roarr','\u21FF':'hoarr','\u2200':'forall','\u2201':'comp','\u2202':'part','\u2202\u0338':'npart','\u2203':'exist','\u2204':'nexist','\u2205':'empty','\u2207':'Del','\u2208':'in','\u2209':'notin','\u220B':'ni','\u220C':'notni','\u03F6':'bepsi','\u220F':'prod','\u2210':'coprod','\u2211':'sum','+':'plus','\xB1':'pm','\xF7':'div','\xD7':'times','<':'lt','\u226E':'nlt','<\u20D2':'nvlt','=':'equals','\u2260':'ne','=\u20E5':'bne','\u2A75':'Equal','>':'gt','\u226F':'ngt','>\u20D2':'nvgt','\xAC':'not','|':'vert','\xA6':'brvbar','\u2212':'minus','\u2213':'mp','\u2214':'plusdo','\u2044':'frasl','\u2216':'setmn','\u2217':'lowast','\u2218':'compfn','\u221A':'Sqrt','\u221D':'prop','\u221E':'infin','\u221F':'angrt','\u2220':'ang','\u2220\u20D2':'nang','\u2221':'angmsd','\u2222':'angsph','\u2223':'mid','\u2224':'nmid','\u2225':'par','\u2226':'npar','\u2227':'and','\u2228':'or','\u2229':'cap','\u2229\uFE00':'caps','\u222A':'cup','\u222A\uFE00':'cups','\u222B':'int','\u222C':'Int','\u222D':'tint','\u2A0C':'qint','\u222E':'oint','\u222F':'Conint','\u2230':'Cconint','\u2231':'cwint','\u2232':'cwconint','\u2233':'awconint','\u2234':'there4','\u2235':'becaus','\u2236':'ratio','\u2237':'Colon','\u2238':'minusd','\u223A':'mDDot','\u223B':'homtht','\u223C':'sim','\u2241':'nsim','\u223C\u20D2':'nvsim','\u223D':'bsim','\u223D\u0331':'race','\u223E':'ac','\u223E\u0333':'acE','\u223F':'acd','\u2240':'wr','\u2242':'esim','\u2242\u0338':'nesim','\u2243':'sime','\u2244':'nsime','\u2245':'cong','\u2247':'ncong','\u2246':'simne','\u2248':'ap','\u2249':'nap','\u224A':'ape','\u224B':'apid','\u224B\u0338':'napid','\u224C':'bcong','\u224D':'CupCap','\u226D':'NotCupCap','\u224D\u20D2':'nvap','\u224E':'bump','\u224E\u0338':'nbump','\u224F':'bumpe','\u224F\u0338':'nbumpe','\u2250':'doteq','\u2250\u0338':'nedot','\u2251':'eDot','\u2252':'efDot','\u2253':'erDot','\u2254':'colone','\u2255':'ecolon','\u2256':'ecir','\u2257':'cire','\u2259':'wedgeq','\u225A':'veeeq','\u225C':'trie','\u225F':'equest','\u2261':'equiv','\u2262':'nequiv','\u2261\u20E5':'bnequiv','\u2264':'le','\u2270':'nle','\u2264\u20D2':'nvle','\u2265':'ge','\u2271':'nge','\u2265\u20D2':'nvge','\u2266':'lE','\u2266\u0338':'nlE','\u2267':'gE','\u2267\u0338':'ngE','\u2268\uFE00':'lvnE','\u2268':'lnE','\u2269':'gnE','\u2269\uFE00':'gvnE','\u226A':'ll','\u226A\u0338':'nLtv','\u226A\u20D2':'nLt','\u226B':'gg','\u226B\u0338':'nGtv','\u226B\u20D2':'nGt','\u226C':'twixt','\u2272':'lsim','\u2274':'nlsim','\u2273':'gsim','\u2275':'ngsim','\u2276':'lg','\u2278':'ntlg','\u2277':'gl','\u2279':'ntgl','\u227A':'pr','\u2280':'npr','\u227B':'sc','\u2281':'nsc','\u227C':'prcue','\u22E0':'nprcue','\u227D':'sccue','\u22E1':'nsccue','\u227E':'prsim','\u227F':'scsim','\u227F\u0338':'NotSucceedsTilde','\u2282':'sub','\u2284':'nsub','\u2282\u20D2':'vnsub','\u2283':'sup','\u2285':'nsup','\u2283\u20D2':'vnsup','\u2286':'sube','\u2288':'nsube','\u2287':'supe','\u2289':'nsupe','\u228A\uFE00':'vsubne','\u228A':'subne','\u228B\uFE00':'vsupne','\u228B':'supne','\u228D':'cupdot','\u228E':'uplus','\u228F':'sqsub','\u228F\u0338':'NotSquareSubset','\u2290':'sqsup','\u2290\u0338':'NotSquareSuperset','\u2291':'sqsube','\u22E2':'nsqsube','\u2292':'sqsupe','\u22E3':'nsqsupe','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u2295':'oplus','\u2296':'ominus','\u2297':'otimes','\u2298':'osol','\u2299':'odot','\u229A':'ocir','\u229B':'oast','\u229D':'odash','\u229E':'plusb','\u229F':'minusb','\u22A0':'timesb','\u22A1':'sdotb','\u22A2':'vdash','\u22AC':'nvdash','\u22A3':'dashv','\u22A4':'top','\u22A5':'bot','\u22A7':'models','\u22A8':'vDash','\u22AD':'nvDash','\u22A9':'Vdash','\u22AE':'nVdash','\u22AA':'Vvdash','\u22AB':'VDash','\u22AF':'nVDash','\u22B0':'prurel','\u22B2':'vltri','\u22EA':'nltri','\u22B3':'vrtri','\u22EB':'nrtri','\u22B4':'ltrie','\u22EC':'nltrie','\u22B4\u20D2':'nvltrie','\u22B5':'rtrie','\u22ED':'nrtrie','\u22B5\u20D2':'nvrtrie','\u22B6':'origof','\u22B7':'imof','\u22B8':'mumap','\u22B9':'hercon','\u22BA':'intcal','\u22BB':'veebar','\u22BD':'barvee','\u22BE':'angrtvb','\u22BF':'lrtri','\u22C0':'Wedge','\u22C1':'Vee','\u22C2':'xcap','\u22C3':'xcup','\u22C4':'diam','\u22C5':'sdot','\u22C6':'Star','\u22C7':'divonx','\u22C8':'bowtie','\u22C9':'ltimes','\u22CA':'rtimes','\u22CB':'lthree','\u22CC':'rthree','\u22CD':'bsime','\u22CE':'cuvee','\u22CF':'cuwed','\u22D0':'Sub','\u22D1':'Sup','\u22D2':'Cap','\u22D3':'Cup','\u22D4':'fork','\u22D5':'epar','\u22D6':'ltdot','\u22D7':'gtdot','\u22D8':'Ll','\u22D8\u0338':'nLl','\u22D9':'Gg','\u22D9\u0338':'nGg','\u22DA\uFE00':'lesg','\u22DA':'leg','\u22DB':'gel','\u22DB\uFE00':'gesl','\u22DE':'cuepr','\u22DF':'cuesc','\u22E6':'lnsim','\u22E7':'gnsim','\u22E8':'prnsim','\u22E9':'scnsim','\u22EE':'vellip','\u22EF':'ctdot','\u22F0':'utdot','\u22F1':'dtdot','\u22F2':'disin','\u22F3':'isinsv','\u22F4':'isins','\u22F5':'isindot','\u22F5\u0338':'notindot','\u22F6':'notinvc','\u22F7':'notinvb','\u22F9':'isinE','\u22F9\u0338':'notinE','\u22FA':'nisd','\u22FB':'xnis','\u22FC':'nis','\u22FD':'notnivc','\u22FE':'notnivb','\u2305':'barwed','\u2306':'Barwed','\u230C':'drcrop','\u230D':'dlcrop','\u230E':'urcrop','\u230F':'ulcrop','\u2310':'bnot','\u2312':'profline','\u2313':'profsurf','\u2315':'telrec','\u2316':'target','\u231C':'ulcorn','\u231D':'urcorn','\u231E':'dlcorn','\u231F':'drcorn','\u2322':'frown','\u2323':'smile','\u232D':'cylcty','\u232E':'profalar','\u2336':'topbot','\u233D':'ovbar','\u233F':'solbar','\u237C':'angzarr','\u23B0':'lmoust','\u23B1':'rmoust','\u23B4':'tbrk','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u23DC':'OverParenthesis','\u23DD':'UnderParenthesis','\u23DE':'OverBrace','\u23DF':'UnderBrace','\u23E2':'trpezium','\u23E7':'elinters','\u2423':'blank','\u2500':'boxh','\u2502':'boxv','\u250C':'boxdr','\u2510':'boxdl','\u2514':'boxur','\u2518':'boxul','\u251C':'boxvr','\u2524':'boxvl','\u252C':'boxhd','\u2534':'boxhu','\u253C':'boxvh','\u2550':'boxH','\u2551':'boxV','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2580':'uhblk','\u2584':'lhblk','\u2588':'block','\u2591':'blk14','\u2592':'blk12','\u2593':'blk34','\u25A1':'squ','\u25AA':'squf','\u25AB':'EmptyVerySmallSquare','\u25AD':'rect','\u25AE':'marker','\u25B1':'fltns','\u25B3':'xutri','\u25B4':'utrif','\u25B5':'utri','\u25B8':'rtrif','\u25B9':'rtri','\u25BD':'xdtri','\u25BE':'dtrif','\u25BF':'dtri','\u25C2':'ltrif','\u25C3':'ltri','\u25CA':'loz','\u25CB':'cir','\u25EC':'tridot','\u25EF':'xcirc','\u25F8':'ultri','\u25F9':'urtri','\u25FA':'lltri','\u25FB':'EmptySmallSquare','\u25FC':'FilledSmallSquare','\u2605':'starf','\u2606':'star','\u260E':'phone','\u2640':'female','\u2642':'male','\u2660':'spades','\u2663':'clubs','\u2665':'hearts','\u2666':'diams','\u266A':'sung','\u2713':'check','\u2717':'cross','\u2720':'malt','\u2736':'sext','\u2758':'VerticalSeparator','\u27C8':'bsolhsub','\u27C9':'suphsol','\u27F5':'xlarr','\u27F6':'xrarr','\u27F7':'xharr','\u27F8':'xlArr','\u27F9':'xrArr','\u27FA':'xhArr','\u27FC':'xmap','\u27FF':'dzigrarr','\u2902':'nvlArr','\u2903':'nvrArr','\u2904':'nvHarr','\u2905':'Map','\u290C':'lbarr','\u290D':'rbarr','\u290E':'lBarr','\u290F':'rBarr','\u2910':'RBarr','\u2911':'DDotrahd','\u2912':'UpArrowBar','\u2913':'DownArrowBar','\u2916':'Rarrtl','\u2919':'latail','\u291A':'ratail','\u291B':'lAtail','\u291C':'rAtail','\u291D':'larrfs','\u291E':'rarrfs','\u291F':'larrbfs','\u2920':'rarrbfs','\u2923':'nwarhk','\u2924':'nearhk','\u2925':'searhk','\u2926':'swarhk','\u2927':'nwnear','\u2928':'toea','\u2929':'tosa','\u292A':'swnwar','\u2933':'rarrc','\u2933\u0338':'nrarrc','\u2935':'cudarrr','\u2936':'ldca','\u2937':'rdca','\u2938':'cudarrl','\u2939':'larrpl','\u293C':'curarrm','\u293D':'cularrp','\u2945':'rarrpl','\u2948':'harrcir','\u2949':'Uarrocir','\u294A':'lurdshar','\u294B':'ldrushar','\u294E':'LeftRightVector','\u294F':'RightUpDownVector','\u2950':'DownLeftRightVector','\u2951':'LeftUpDownVector','\u2952':'LeftVectorBar','\u2953':'RightVectorBar','\u2954':'RightUpVectorBar','\u2955':'RightDownVectorBar','\u2956':'DownLeftVectorBar','\u2957':'DownRightVectorBar','\u2958':'LeftUpVectorBar','\u2959':'LeftDownVectorBar','\u295A':'LeftTeeVector','\u295B':'RightTeeVector','\u295C':'RightUpTeeVector','\u295D':'RightDownTeeVector','\u295E':'DownLeftTeeVector','\u295F':'DownRightTeeVector','\u2960':'LeftUpTeeVector','\u2961':'LeftDownTeeVector','\u2962':'lHar','\u2963':'uHar','\u2964':'rHar','\u2965':'dHar','\u2966':'luruhar','\u2967':'ldrdhar','\u2968':'ruluhar','\u2969':'rdldhar','\u296A':'lharul','\u296B':'llhard','\u296C':'rharul','\u296D':'lrhard','\u296E':'udhar','\u296F':'duhar','\u2970':'RoundImplies','\u2971':'erarr','\u2972':'simrarr','\u2973':'larrsim','\u2974':'rarrsim','\u2975':'rarrap','\u2976':'ltlarr','\u2978':'gtrarr','\u2979':'subrarr','\u297B':'suplarr','\u297C':'lfisht','\u297D':'rfisht','\u297E':'ufisht','\u297F':'dfisht','\u299A':'vzigzag','\u299C':'vangrt','\u299D':'angrtvbd','\u29A4':'ange','\u29A5':'range','\u29A6':'dwangle','\u29A7':'uwangle','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u29B0':'bemptyv','\u29B1':'demptyv','\u29B2':'cemptyv','\u29B3':'raemptyv','\u29B4':'laemptyv','\u29B5':'ohbar','\u29B6':'omid','\u29B7':'opar','\u29B9':'operp','\u29BB':'olcross','\u29BC':'odsold','\u29BE':'olcir','\u29BF':'ofcir','\u29C0':'olt','\u29C1':'ogt','\u29C2':'cirscir','\u29C3':'cirE','\u29C4':'solb','\u29C5':'bsolb','\u29C9':'boxbox','\u29CD':'trisb','\u29CE':'rtriltri','\u29CF':'LeftTriangleBar','\u29CF\u0338':'NotLeftTriangleBar','\u29D0':'RightTriangleBar','\u29D0\u0338':'NotRightTriangleBar','\u29DC':'iinfin','\u29DD':'infintie','\u29DE':'nvinfin','\u29E3':'eparsl','\u29E4':'smeparsl','\u29E5':'eqvparsl','\u29EB':'lozf','\u29F4':'RuleDelayed','\u29F6':'dsol','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A04':'xuplus','\u2A06':'xsqcup','\u2A0D':'fpartint','\u2A10':'cirfnint','\u2A11':'awint','\u2A12':'rppolint','\u2A13':'scpolint','\u2A14':'npolint','\u2A15':'pointint','\u2A16':'quatint','\u2A17':'intlarhk','\u2A22':'pluscir','\u2A23':'plusacir','\u2A24':'simplus','\u2A25':'plusdu','\u2A26':'plussim','\u2A27':'plustwo','\u2A29':'mcomma','\u2A2A':'minusdu','\u2A2D':'loplus','\u2A2E':'roplus','\u2A2F':'Cross','\u2A30':'timesd','\u2A31':'timesbar','\u2A33':'smashp','\u2A34':'lotimes','\u2A35':'rotimes','\u2A36':'otimesas','\u2A37':'Otimes','\u2A38':'odiv','\u2A39':'triplus','\u2A3A':'triminus','\u2A3B':'tritime','\u2A3C':'iprod','\u2A3F':'amalg','\u2A40':'capdot','\u2A42':'ncup','\u2A43':'ncap','\u2A44':'capand','\u2A45':'cupor','\u2A46':'cupcap','\u2A47':'capcup','\u2A48':'cupbrcap','\u2A49':'capbrcup','\u2A4A':'cupcup','\u2A4B':'capcap','\u2A4C':'ccups','\u2A4D':'ccaps','\u2A50':'ccupssm','\u2A53':'And','\u2A54':'Or','\u2A55':'andand','\u2A56':'oror','\u2A57':'orslope','\u2A58':'andslope','\u2A5A':'andv','\u2A5B':'orv','\u2A5C':'andd','\u2A5D':'ord','\u2A5F':'wedbar','\u2A66':'sdote','\u2A6A':'simdot','\u2A6D':'congdot','\u2A6D\u0338':'ncongdot','\u2A6E':'easter','\u2A6F':'apacir','\u2A70':'apE','\u2A70\u0338':'napE','\u2A71':'eplus','\u2A72':'pluse','\u2A73':'Esim','\u2A77':'eDDot','\u2A78':'equivDD','\u2A79':'ltcir','\u2A7A':'gtcir','\u2A7B':'ltquest','\u2A7C':'gtquest','\u2A7D':'les','\u2A7D\u0338':'nles','\u2A7E':'ges','\u2A7E\u0338':'nges','\u2A7F':'lesdot','\u2A80':'gesdot','\u2A81':'lesdoto','\u2A82':'gesdoto','\u2A83':'lesdotor','\u2A84':'gesdotol','\u2A85':'lap','\u2A86':'gap','\u2A87':'lne','\u2A88':'gne','\u2A89':'lnap','\u2A8A':'gnap','\u2A8B':'lEg','\u2A8C':'gEl','\u2A8D':'lsime','\u2A8E':'gsime','\u2A8F':'lsimg','\u2A90':'gsiml','\u2A91':'lgE','\u2A92':'glE','\u2A93':'lesges','\u2A94':'gesles','\u2A95':'els','\u2A96':'egs','\u2A97':'elsdot','\u2A98':'egsdot','\u2A99':'el','\u2A9A':'eg','\u2A9D':'siml','\u2A9E':'simg','\u2A9F':'simlE','\u2AA0':'simgE','\u2AA1':'LessLess','\u2AA1\u0338':'NotNestedLessLess','\u2AA2':'GreaterGreater','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA4':'glj','\u2AA5':'gla','\u2AA6':'ltcc','\u2AA7':'gtcc','\u2AA8':'lescc','\u2AA9':'gescc','\u2AAA':'smt','\u2AAB':'lat','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u2AAD':'late','\u2AAD\uFE00':'lates','\u2AAE':'bumpE','\u2AAF':'pre','\u2AAF\u0338':'npre','\u2AB0':'sce','\u2AB0\u0338':'nsce','\u2AB3':'prE','\u2AB4':'scE','\u2AB5':'prnE','\u2AB6':'scnE','\u2AB7':'prap','\u2AB8':'scap','\u2AB9':'prnap','\u2ABA':'scnap','\u2ABB':'Pr','\u2ABC':'Sc','\u2ABD':'subdot','\u2ABE':'supdot','\u2ABF':'subplus','\u2AC0':'supplus','\u2AC1':'submult','\u2AC2':'supmult','\u2AC3':'subedot','\u2AC4':'supedot','\u2AC5':'subE','\u2AC5\u0338':'nsubE','\u2AC6':'supE','\u2AC6\u0338':'nsupE','\u2AC7':'subsim','\u2AC8':'supsim','\u2ACB\uFE00':'vsubnE','\u2ACB':'subnE','\u2ACC\uFE00':'vsupnE','\u2ACC':'supnE','\u2ACF':'csub','\u2AD0':'csup','\u2AD1':'csube','\u2AD2':'csupe','\u2AD3':'subsup','\u2AD4':'supsub','\u2AD5':'subsub','\u2AD6':'supsup','\u2AD7':'suphsub','\u2AD8':'supdsub','\u2AD9':'forkv','\u2ADA':'topfork','\u2ADB':'mlcp','\u2AE4':'Dashv','\u2AE6':'Vdashl','\u2AE7':'Barv','\u2AE8':'vBar','\u2AE9':'vBarv','\u2AEB':'Vbar','\u2AEC':'Not','\u2AED':'bNot','\u2AEE':'rnmid','\u2AEF':'cirmid','\u2AF0':'midcir','\u2AF1':'topcir','\u2AF2':'nhpar','\u2AF3':'parsim','\u2AFD':'parsl','\u2AFD\u20E5':'nparsl','\u266D':'flat','\u266E':'natur','\u266F':'sharp','\xA4':'curren','\xA2':'cent','$':'dollar','\xA3':'pound','\xA5':'yen','\u20AC':'euro','\xB9':'sup1','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\xB2':'sup2','\u2154':'frac23','\u2156':'frac25','\xB3':'sup3','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\uD835\uDCB6':'ascr','\uD835\uDD52':'aopf','\uD835\uDD1E':'afr','\uD835\uDD38':'Aopf','\uD835\uDD04':'Afr','\uD835\uDC9C':'Ascr','\xAA':'ordf','\xE1':'aacute','\xC1':'Aacute','\xE0':'agrave','\xC0':'Agrave','\u0103':'abreve','\u0102':'Abreve','\xE2':'acirc','\xC2':'Acirc','\xE5':'aring','\xC5':'angst','\xE4':'auml','\xC4':'Auml','\xE3':'atilde','\xC3':'Atilde','\u0105':'aogon','\u0104':'Aogon','\u0101':'amacr','\u0100':'Amacr','\xE6':'aelig','\xC6':'AElig','\uD835\uDCB7':'bscr','\uD835\uDD53':'bopf','\uD835\uDD1F':'bfr','\uD835\uDD39':'Bopf','\u212C':'Bscr','\uD835\uDD05':'Bfr','\uD835\uDD20':'cfr','\uD835\uDCB8':'cscr','\uD835\uDD54':'copf','\u212D':'Cfr','\uD835\uDC9E':'Cscr','\u2102':'Copf','\u0107':'cacute','\u0106':'Cacute','\u0109':'ccirc','\u0108':'Ccirc','\u010D':'ccaron','\u010C':'Ccaron','\u010B':'cdot','\u010A':'Cdot','\xE7':'ccedil','\xC7':'Ccedil','\u2105':'incare','\uD835\uDD21':'dfr','\u2146':'dd','\uD835\uDD55':'dopf','\uD835\uDCB9':'dscr','\uD835\uDC9F':'Dscr','\uD835\uDD07':'Dfr','\u2145':'DD','\uD835\uDD3B':'Dopf','\u010F':'dcaron','\u010E':'Dcaron','\u0111':'dstrok','\u0110':'Dstrok','\xF0':'eth','\xD0':'ETH','\u2147':'ee','\u212F':'escr','\uD835\uDD22':'efr','\uD835\uDD56':'eopf','\u2130':'Escr','\uD835\uDD08':'Efr','\uD835\uDD3C':'Eopf','\xE9':'eacute','\xC9':'Eacute','\xE8':'egrave','\xC8':'Egrave','\xEA':'ecirc','\xCA':'Ecirc','\u011B':'ecaron','\u011A':'Ecaron','\xEB':'euml','\xCB':'Euml','\u0117':'edot','\u0116':'Edot','\u0119':'eogon','\u0118':'Eogon','\u0113':'emacr','\u0112':'Emacr','\uD835\uDD23':'ffr','\uD835\uDD57':'fopf','\uD835\uDCBB':'fscr','\uD835\uDD09':'Ffr','\uD835\uDD3D':'Fopf','\u2131':'Fscr','\uFB00':'fflig','\uFB03':'ffilig','\uFB04':'ffllig','\uFB01':'filig','fj':'fjlig','\uFB02':'fllig','\u0192':'fnof','\u210A':'gscr','\uD835\uDD58':'gopf','\uD835\uDD24':'gfr','\uD835\uDCA2':'Gscr','\uD835\uDD3E':'Gopf','\uD835\uDD0A':'Gfr','\u01F5':'gacute','\u011F':'gbreve','\u011E':'Gbreve','\u011D':'gcirc','\u011C':'Gcirc','\u0121':'gdot','\u0120':'Gdot','\u0122':'Gcedil','\uD835\uDD25':'hfr','\u210E':'planckh','\uD835\uDCBD':'hscr','\uD835\uDD59':'hopf','\u210B':'Hscr','\u210C':'Hfr','\u210D':'Hopf','\u0125':'hcirc','\u0124':'Hcirc','\u210F':'hbar','\u0127':'hstrok','\u0126':'Hstrok','\uD835\uDD5A':'iopf','\uD835\uDD26':'ifr','\uD835\uDCBE':'iscr','\u2148':'ii','\uD835\uDD40':'Iopf','\u2110':'Iscr','\u2111':'Im','\xED':'iacute','\xCD':'Iacute','\xEC':'igrave','\xCC':'Igrave','\xEE':'icirc','\xCE':'Icirc','\xEF':'iuml','\xCF':'Iuml','\u0129':'itilde','\u0128':'Itilde','\u0130':'Idot','\u012F':'iogon','\u012E':'Iogon','\u012B':'imacr','\u012A':'Imacr','\u0133':'ijlig','\u0132':'IJlig','\u0131':'imath','\uD835\uDCBF':'jscr','\uD835\uDD5B':'jopf','\uD835\uDD27':'jfr','\uD835\uDCA5':'Jscr','\uD835\uDD0D':'Jfr','\uD835\uDD41':'Jopf','\u0135':'jcirc','\u0134':'Jcirc','\u0237':'jmath','\uD835\uDD5C':'kopf','\uD835\uDCC0':'kscr','\uD835\uDD28':'kfr','\uD835\uDCA6':'Kscr','\uD835\uDD42':'Kopf','\uD835\uDD0E':'Kfr','\u0137':'kcedil','\u0136':'Kcedil','\uD835\uDD29':'lfr','\uD835\uDCC1':'lscr','\u2113':'ell','\uD835\uDD5D':'lopf','\u2112':'Lscr','\uD835\uDD0F':'Lfr','\uD835\uDD43':'Lopf','\u013A':'lacute','\u0139':'Lacute','\u013E':'lcaron','\u013D':'Lcaron','\u013C':'lcedil','\u013B':'Lcedil','\u0142':'lstrok','\u0141':'Lstrok','\u0140':'lmidot','\u013F':'Lmidot','\uD835\uDD2A':'mfr','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\uD835\uDD10':'Mfr','\uD835\uDD44':'Mopf','\u2133':'Mscr','\uD835\uDD2B':'nfr','\uD835\uDD5F':'nopf','\uD835\uDCC3':'nscr','\u2115':'Nopf','\uD835\uDCA9':'Nscr','\uD835\uDD11':'Nfr','\u0144':'nacute','\u0143':'Nacute','\u0148':'ncaron','\u0147':'Ncaron','\xF1':'ntilde','\xD1':'Ntilde','\u0146':'ncedil','\u0145':'Ncedil','\u2116':'numero','\u014B':'eng','\u014A':'ENG','\uD835\uDD60':'oopf','\uD835\uDD2C':'ofr','\u2134':'oscr','\uD835\uDCAA':'Oscr','\uD835\uDD12':'Ofr','\uD835\uDD46':'Oopf','\xBA':'ordm','\xF3':'oacute','\xD3':'Oacute','\xF2':'ograve','\xD2':'Ograve','\xF4':'ocirc','\xD4':'Ocirc','\xF6':'ouml','\xD6':'Ouml','\u0151':'odblac','\u0150':'Odblac','\xF5':'otilde','\xD5':'Otilde','\xF8':'oslash','\xD8':'Oslash','\u014D':'omacr','\u014C':'Omacr','\u0153':'oelig','\u0152':'OElig','\uD835\uDD2D':'pfr','\uD835\uDCC5':'pscr','\uD835\uDD61':'popf','\u2119':'Popf','\uD835\uDD13':'Pfr','\uD835\uDCAB':'Pscr','\uD835\uDD62':'qopf','\uD835\uDD2E':'qfr','\uD835\uDCC6':'qscr','\uD835\uDCAC':'Qscr','\uD835\uDD14':'Qfr','\u211A':'Qopf','\u0138':'kgreen','\uD835\uDD2F':'rfr','\uD835\uDD63':'ropf','\uD835\uDCC7':'rscr','\u211B':'Rscr','\u211C':'Re','\u211D':'Ropf','\u0155':'racute','\u0154':'Racute','\u0159':'rcaron','\u0158':'Rcaron','\u0157':'rcedil','\u0156':'Rcedil','\uD835\uDD64':'sopf','\uD835\uDCC8':'sscr','\uD835\uDD30':'sfr','\uD835\uDD4A':'Sopf','\uD835\uDD16':'Sfr','\uD835\uDCAE':'Sscr','\u24C8':'oS','\u015B':'sacute','\u015A':'Sacute','\u015D':'scirc','\u015C':'Scirc','\u0161':'scaron','\u0160':'Scaron','\u015F':'scedil','\u015E':'Scedil','\xDF':'szlig','\uD835\uDD31':'tfr','\uD835\uDCC9':'tscr','\uD835\uDD65':'topf','\uD835\uDCAF':'Tscr','\uD835\uDD17':'Tfr','\uD835\uDD4B':'Topf','\u0165':'tcaron','\u0164':'Tcaron','\u0163':'tcedil','\u0162':'Tcedil','\u2122':'trade','\u0167':'tstrok','\u0166':'Tstrok','\uD835\uDCCA':'uscr','\uD835\uDD66':'uopf','\uD835\uDD32':'ufr','\uD835\uDD4C':'Uopf','\uD835\uDD18':'Ufr','\uD835\uDCB0':'Uscr','\xFA':'uacute','\xDA':'Uacute','\xF9':'ugrave','\xD9':'Ugrave','\u016D':'ubreve','\u016C':'Ubreve','\xFB':'ucirc','\xDB':'Ucirc','\u016F':'uring','\u016E':'Uring','\xFC':'uuml','\xDC':'Uuml','\u0171':'udblac','\u0170':'Udblac','\u0169':'utilde','\u0168':'Utilde','\u0173':'uogon','\u0172':'Uogon','\u016B':'umacr','\u016A':'Umacr','\uD835\uDD33':'vfr','\uD835\uDD67':'vopf','\uD835\uDCCB':'vscr','\uD835\uDD19':'Vfr','\uD835\uDD4D':'Vopf','\uD835\uDCB1':'Vscr','\uD835\uDD68':'wopf','\uD835\uDCCC':'wscr','\uD835\uDD34':'wfr','\uD835\uDCB2':'Wscr','\uD835\uDD4E':'Wopf','\uD835\uDD1A':'Wfr','\u0175':'wcirc','\u0174':'Wcirc','\uD835\uDD35':'xfr','\uD835\uDCCD':'xscr','\uD835\uDD69':'xopf','\uD835\uDD4F':'Xopf','\uD835\uDD1B':'Xfr','\uD835\uDCB3':'Xscr','\uD835\uDD36':'yfr','\uD835\uDCCE':'yscr','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDD1C':'Yfr','\uD835\uDD50':'Yopf','\xFD':'yacute','\xDD':'Yacute','\u0177':'ycirc','\u0176':'Ycirc','\xFF':'yuml','\u0178':'Yuml','\uD835\uDCCF':'zscr','\uD835\uDD37':'zfr','\uD835\uDD6B':'zopf','\u2128':'Zfr','\u2124':'Zopf','\uD835\uDCB5':'Zscr','\u017A':'zacute','\u0179':'Zacute','\u017E':'zcaron','\u017D':'Zcaron','\u017C':'zdot','\u017B':'Zdot','\u01B5':'imped','\xFE':'thorn','\xDE':'THORN','\u0149':'napos','\u03B1':'alpha','\u0391':'Alpha','\u03B2':'beta','\u0392':'Beta','\u03B3':'gamma','\u0393':'Gamma','\u03B4':'delta','\u0394':'Delta','\u03B5':'epsi','\u03F5':'epsiv','\u0395':'Epsilon','\u03DD':'gammad','\u03DC':'Gammad','\u03B6':'zeta','\u0396':'Zeta','\u03B7':'eta','\u0397':'Eta','\u03B8':'theta','\u03D1':'thetav','\u0398':'Theta','\u03B9':'iota','\u0399':'Iota','\u03BA':'kappa','\u03F0':'kappav','\u039A':'Kappa','\u03BB':'lambda','\u039B':'Lambda','\u03BC':'mu','\xB5':'micro','\u039C':'Mu','\u03BD':'nu','\u039D':'Nu','\u03BE':'xi','\u039E':'Xi','\u03BF':'omicron','\u039F':'Omicron','\u03C0':'pi','\u03D6':'piv','\u03A0':'Pi','\u03C1':'rho','\u03F1':'rhov','\u03A1':'Rho','\u03C3':'sigma','\u03A3':'Sigma','\u03C2':'sigmaf','\u03C4':'tau','\u03A4':'Tau','\u03C5':'upsi','\u03A5':'Upsilon','\u03D2':'Upsi','\u03C6':'phi','\u03D5':'phiv','\u03A6':'Phi','\u03C7':'chi','\u03A7':'Chi','\u03C8':'psi','\u03A8':'Psi','\u03C9':'omega','\u03A9':'ohm','\u0430':'acy','\u0410':'Acy','\u0431':'bcy','\u0411':'Bcy','\u0432':'vcy','\u0412':'Vcy','\u0433':'gcy','\u0413':'Gcy','\u0453':'gjcy','\u0403':'GJcy','\u0434':'dcy','\u0414':'Dcy','\u0452':'djcy','\u0402':'DJcy','\u0435':'iecy','\u0415':'IEcy','\u0451':'iocy','\u0401':'IOcy','\u0454':'jukcy','\u0404':'Jukcy','\u0436':'zhcy','\u0416':'ZHcy','\u0437':'zcy','\u0417':'Zcy','\u0455':'dscy','\u0405':'DScy','\u0438':'icy','\u0418':'Icy','\u0456':'iukcy','\u0406':'Iukcy','\u0457':'yicy','\u0407':'YIcy','\u0439':'jcy','\u0419':'Jcy','\u0458':'jsercy','\u0408':'Jsercy','\u043A':'kcy','\u041A':'Kcy','\u045C':'kjcy','\u040C':'KJcy','\u043B':'lcy','\u041B':'Lcy','\u0459':'ljcy','\u0409':'LJcy','\u043C':'mcy','\u041C':'Mcy','\u043D':'ncy','\u041D':'Ncy','\u045A':'njcy','\u040A':'NJcy','\u043E':'ocy','\u041E':'Ocy','\u043F':'pcy','\u041F':'Pcy','\u0440':'rcy','\u0420':'Rcy','\u0441':'scy','\u0421':'Scy','\u0442':'tcy','\u0422':'Tcy','\u045B':'tshcy','\u040B':'TSHcy','\u0443':'ucy','\u0423':'Ucy','\u045E':'ubrcy','\u040E':'Ubrcy','\u0444':'fcy','\u0424':'Fcy','\u0445':'khcy','\u0425':'KHcy','\u0446':'tscy','\u0426':'TScy','\u0447':'chcy','\u0427':'CHcy','\u045F':'dzcy','\u040F':'DZcy','\u0448':'shcy','\u0428':'SHcy','\u0449':'shchcy','\u0429':'SHCHcy','\u044A':'hardcy','\u042A':'HARDcy','\u044B':'ycy','\u042B':'Ycy','\u044C':'softcy','\u042C':'SOFTcy','\u044D':'ecy','\u042D':'Ecy','\u044E':'yucy','\u042E':'YUcy','\u044F':'yacy','\u042F':'YAcy','\u2135':'aleph','\u2136':'beth','\u2137':'gimel','\u2138':'daleth'};
  6057. var regexEscape = /["&'<>`]/g;
  6058. var escapeMap = {
  6059. '"': '&quot;',
  6060. '&': '&amp;',
  6061. '\'': '&#x27;',
  6062. '<': '&lt;',
  6063. // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
  6064. // following is not strictly necessary unless it’s part of a tag or an
  6065. // unquoted attribute value. We’re only escaping it to support those
  6066. // situations, and for XML support.
  6067. '>': '&gt;',
  6068. // In Internet Explorer ≤ 8, the backtick character can be used
  6069. // to break out of (un)quoted attribute values or HTML comments.
  6070. // See http://html5sec.org/#102, http://html5sec.org/#108, and
  6071. // http://html5sec.org/#133.
  6072. '`': '&#x60;'
  6073. };
  6074. var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
  6075. var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  6076. var regexDecode = /&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g;
  6077. var decodeMap = {'aacute':'\xE1','Aacute':'\xC1','abreve':'\u0103','Abreve':'\u0102','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','acy':'\u0430','Acy':'\u0410','aelig':'\xE6','AElig':'\xC6','af':'\u2061','afr':'\uD835\uDD1E','Afr':'\uD835\uDD04','agrave':'\xE0','Agrave':'\xC0','alefsym':'\u2135','aleph':'\u2135','alpha':'\u03B1','Alpha':'\u0391','amacr':'\u0101','Amacr':'\u0100','amalg':'\u2A3F','amp':'&','AMP':'&','and':'\u2227','And':'\u2A53','andand':'\u2A55','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsd':'\u2221','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','aogon':'\u0105','Aogon':'\u0104','aopf':'\uD835\uDD52','Aopf':'\uD835\uDD38','ap':'\u2248','apacir':'\u2A6F','ape':'\u224A','apE':'\u2A70','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','aring':'\xE5','Aring':'\xC5','ascr':'\uD835\uDCB6','Ascr':'\uD835\uDC9C','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','bcy':'\u0431','Bcy':'\u0411','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','beta':'\u03B2','Beta':'\u0392','beth':'\u2136','between':'\u226C','bfr':'\uD835\uDD1F','Bfr':'\uD835\uDD05','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bnot':'\u2310','bNot':'\u2AED','bopf':'\uD835\uDD53','Bopf':'\uD835\uDD39','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxhD':'\u2565','boxHd':'\u2564','boxHD':'\u2566','boxhu':'\u2534','boxhU':'\u2568','boxHu':'\u2567','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsol':'\\','bsolb':'\u29C5','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpe':'\u224F','bumpE':'\u2AAE','bumpeq':'\u224F','Bumpeq':'\u224E','cacute':'\u0107','Cacute':'\u0106','cap':'\u2229','Cap':'\u22D2','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','ccaron':'\u010D','Ccaron':'\u010C','ccedil':'\xE7','Ccedil':'\xC7','ccirc':'\u0109','Ccirc':'\u0108','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','cdot':'\u010B','Cdot':'\u010A','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','chcy':'\u0447','CHcy':'\u0427','check':'\u2713','checkmark':'\u2713','chi':'\u03C7','Chi':'\u03A7','cir':'\u25CB','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cire':'\u2257','cirE':'\u29C3','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','colone':'\u2254','Colone':'\u2A74','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','cscr':'\uD835\uDCB8','Cscr':'\uD835\uDC9E','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cup':'\u222A','Cup':'\u22D3','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','dArr':'\u21D3','Darr':'\u21A1','dash':'\u2010','dashv':'\u22A3','Dashv':'\u2AE4','dbkarow':'\u290F','dblac':'\u02DD','dcaron':'\u010F','Dcaron':'\u010E','dcy':'\u0434','Dcy':'\u0414','dd':'\u2146','DD':'\u2145','ddagger':'\u2021','ddarr':'\u21CA','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','delta':'\u03B4','Delta':'\u0394','demptyv':'\u29B1','dfisht':'\u297F','dfr':'\uD835\uDD21','Dfr':'\uD835\uDD07','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','djcy':'\u0452','DJcy':'\u0402','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','dopf':'\uD835\uDD55','Dopf':'\uD835\uDD3B','dot':'\u02D9','Dot':'\xA8','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','downarrow':'\u2193','Downarrow':'\u21D3','DownArrow':'\u2193','DownArrowBar':'\u2913','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVector':'\u21BD','DownLeftVectorBar':'\u2956','DownRightTeeVector':'\u295F','DownRightVector':'\u21C1','DownRightVectorBar':'\u2957','DownTee':'\u22A4','DownTeeArrow':'\u21A7','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','dscr':'\uD835\uDCB9','Dscr':'\uD835\uDC9F','dscy':'\u0455','DScy':'\u0405','dsol':'\u29F6','dstrok':'\u0111','Dstrok':'\u0110','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','dzcy':'\u045F','DZcy':'\u040F','dzigrarr':'\u27FF','eacute':'\xE9','Eacute':'\xC9','easter':'\u2A6E','ecaron':'\u011B','Ecaron':'\u011A','ecir':'\u2256','ecirc':'\xEA','Ecirc':'\xCA','ecolon':'\u2255','ecy':'\u044D','Ecy':'\u042D','eDDot':'\u2A77','edot':'\u0117','eDot':'\u2251','Edot':'\u0116','ee':'\u2147','efDot':'\u2252','efr':'\uD835\uDD22','Efr':'\uD835\uDD08','eg':'\u2A9A','egrave':'\xE8','Egrave':'\xC8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','emacr':'\u0113','Emacr':'\u0112','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp':'\u2003','emsp13':'\u2004','emsp14':'\u2005','eng':'\u014B','ENG':'\u014A','ensp':'\u2002','eogon':'\u0119','Eogon':'\u0118','eopf':'\uD835\uDD56','Eopf':'\uD835\uDD3C','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','epsilon':'\u03B5','Epsilon':'\u0395','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','esim':'\u2242','Esim':'\u2A73','eta':'\u03B7','Eta':'\u0397','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','fcy':'\u0444','Fcy':'\u0424','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','ffr':'\uD835\uDD23','Ffr':'\uD835\uDD09','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','fopf':'\uD835\uDD57','Fopf':'\uD835\uDD3D','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','gamma':'\u03B3','Gamma':'\u0393','gammad':'\u03DD','Gammad':'\u03DC','gap':'\u2A86','gbreve':'\u011F','Gbreve':'\u011E','Gcedil':'\u0122','gcirc':'\u011D','Gcirc':'\u011C','gcy':'\u0433','Gcy':'\u0413','gdot':'\u0121','Gdot':'\u0120','ge':'\u2265','gE':'\u2267','gel':'\u22DB','gEl':'\u2A8C','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','ges':'\u2A7E','gescc':'\u2AA9','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','gfr':'\uD835\uDD24','Gfr':'\uD835\uDD0A','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','gjcy':'\u0453','GJcy':'\u0403','gl':'\u2277','gla':'\u2AA5','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','gopf':'\uD835\uDD58','Gopf':'\uD835\uDD3E','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','gscr':'\u210A','Gscr':'\uD835\uDCA2','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gt':'>','Gt':'\u226B','GT':'>','gtcc':'\u2AA7','gtcir':'\u2A7A','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','hardcy':'\u044A','HARDcy':'\u042A','harr':'\u2194','hArr':'\u21D4','harrcir':'\u2948','harrw':'\u21AD','Hat':'^','hbar':'\u210F','hcirc':'\u0125','Hcirc':'\u0124','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','hstrok':'\u0127','Hstrok':'\u0126','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','iacute':'\xED','Iacute':'\xCD','ic':'\u2063','icirc':'\xEE','Icirc':'\xCE','icy':'\u0438','Icy':'\u0418','Idot':'\u0130','iecy':'\u0435','IEcy':'\u0415','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','igrave':'\xEC','Igrave':'\xCC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','ijlig':'\u0133','IJlig':'\u0132','Im':'\u2111','imacr':'\u012B','Imacr':'\u012A','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','in':'\u2208','incare':'\u2105','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','int':'\u222B','Int':'\u222C','intcal':'\u22BA','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','iocy':'\u0451','IOcy':'\u0401','iogon':'\u012F','Iogon':'\u012E','iopf':'\uD835\uDD5A','Iopf':'\uD835\uDD40','iota':'\u03B9','Iota':'\u0399','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','itilde':'\u0129','Itilde':'\u0128','iukcy':'\u0456','Iukcy':'\u0406','iuml':'\xEF','Iuml':'\xCF','jcirc':'\u0135','Jcirc':'\u0134','jcy':'\u0439','Jcy':'\u0419','jfr':'\uD835\uDD27','Jfr':'\uD835\uDD0D','jmath':'\u0237','jopf':'\uD835\uDD5B','Jopf':'\uD835\uDD41','jscr':'\uD835\uDCBF','Jscr':'\uD835\uDCA5','jsercy':'\u0458','Jsercy':'\u0408','jukcy':'\u0454','Jukcy':'\u0404','kappa':'\u03BA','Kappa':'\u039A','kappav':'\u03F0','kcedil':'\u0137','Kcedil':'\u0136','kcy':'\u043A','Kcy':'\u041A','kfr':'\uD835\uDD28','Kfr':'\uD835\uDD0E','kgreen':'\u0138','khcy':'\u0445','KHcy':'\u0425','kjcy':'\u045C','KJcy':'\u040C','kopf':'\uD835\uDD5C','Kopf':'\uD835\uDD42','kscr':'\uD835\uDCC0','Kscr':'\uD835\uDCA6','lAarr':'\u21DA','lacute':'\u013A','Lacute':'\u0139','laemptyv':'\u29B4','lagran':'\u2112','lambda':'\u03BB','Lambda':'\u039B','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larr':'\u2190','lArr':'\u21D0','Larr':'\u219E','larrb':'\u21E4','larrbfs':'\u291F','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','lat':'\u2AAB','latail':'\u2919','lAtail':'\u291B','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','lcaron':'\u013E','Lcaron':'\u013D','lcedil':'\u013C','Lcedil':'\u013B','lceil':'\u2308','lcub':'{','lcy':'\u043B','Lcy':'\u041B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','leftarrow':'\u2190','Leftarrow':'\u21D0','LeftArrow':'\u2190','LeftArrowBar':'\u21E4','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVector':'\u21C3','LeftDownVectorBar':'\u2959','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','Leftrightarrow':'\u21D4','LeftRightArrow':'\u2194','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTee':'\u22A3','LeftTeeArrow':'\u21A4','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangle':'\u22B2','LeftTriangleBar':'\u29CF','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVector':'\u21BF','LeftUpVectorBar':'\u2958','LeftVector':'\u21BC','LeftVectorBar':'\u2952','leg':'\u22DA','lEg':'\u2A8B','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','les':'\u2A7D','lescc':'\u2AA8','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','lfr':'\uD835\uDD29','Lfr':'\uD835\uDD0F','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','ljcy':'\u0459','LJcy':'\u0409','ll':'\u226A','Ll':'\u22D8','llarr':'\u21C7','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','lmidot':'\u0140','Lmidot':'\u013F','lmoust':'\u23B0','lmoustache':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','Longleftarrow':'\u27F8','LongLeftArrow':'\u27F5','longleftrightarrow':'\u27F7','Longleftrightarrow':'\u27FA','LongLeftRightArrow':'\u27F7','longmapsto':'\u27FC','longrightarrow':'\u27F6','Longrightarrow':'\u27F9','LongRightArrow':'\u27F6','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','lopf':'\uD835\uDD5D','Lopf':'\uD835\uDD43','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','lstrok':'\u0142','Lstrok':'\u0141','lt':'<','Lt':'\u226A','LT':'<','ltcc':'\u2AA6','ltcir':'\u2A79','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','map':'\u21A6','Map':'\u2905','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','mcy':'\u043C','Mcy':'\u041C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','mfr':'\uD835\uDD2A','Mfr':'\uD835\uDD10','mho':'\u2127','micro':'\xB5','mid':'\u2223','midast':'*','midcir':'\u2AF0','middot':'\xB7','minus':'\u2212','minusb':'\u229F','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','mopf':'\uD835\uDD5E','Mopf':'\uD835\uDD44','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','mu':'\u03BC','Mu':'\u039C','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','nacute':'\u0144','Nacute':'\u0143','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natur':'\u266E','natural':'\u266E','naturals':'\u2115','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','ncaron':'\u0148','Ncaron':'\u0147','ncedil':'\u0146','Ncedil':'\u0145','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','ncy':'\u043D','Ncy':'\u041D','ndash':'\u2013','ne':'\u2260','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','nfr':'\uD835\uDD2B','Nfr':'\uD835\uDD11','nge':'\u2271','ngE':'\u2267\u0338','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','ngt':'\u226F','nGt':'\u226B\u20D2','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','njcy':'\u045A','NJcy':'\u040A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nle':'\u2270','nlE':'\u2266\u0338','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nlt':'\u226E','nLt':'\u226A\u20D2','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','not':'\xAC','Not':'\u2AEC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangle':'\u22EA','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangle':'\u22EB','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','npar':'\u2226','nparallel':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','npre':'\u2AAF\u0338','nprec':'\u2280','npreceq':'\u2AAF\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrc':'\u2933\u0338','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','nscr':'\uD835\uDCC3','Nscr':'\uD835\uDCA9','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsube':'\u2288','nsubE':'\u2AC5\u0338','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupe':'\u2289','nsupE':'\u2AC6\u0338','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','ntilde':'\xF1','Ntilde':'\xD1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','nu':'\u03BD','Nu':'\u039D','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','oacute':'\xF3','Oacute':'\xD3','oast':'\u229B','ocir':'\u229A','ocirc':'\xF4','Ocirc':'\xD4','ocy':'\u043E','Ocy':'\u041E','odash':'\u229D','odblac':'\u0151','Odblac':'\u0150','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','oelig':'\u0153','OElig':'\u0152','ofcir':'\u29BF','ofr':'\uD835\uDD2C','Ofr':'\uD835\uDD12','ogon':'\u02DB','ograve':'\xF2','Ograve':'\xD2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','omacr':'\u014D','Omacr':'\u014C','omega':'\u03C9','Omega':'\u03A9','omicron':'\u03BF','Omicron':'\u039F','omid':'\u29B6','ominus':'\u2296','oopf':'\uD835\uDD60','Oopf':'\uD835\uDD46','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','or':'\u2228','Or':'\u2A54','orarr':'\u21BB','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','oscr':'\u2134','Oscr':'\uD835\uDCAA','oslash':'\xF8','Oslash':'\xD8','osol':'\u2298','otilde':'\xF5','Otilde':'\xD5','otimes':'\u2297','Otimes':'\u2A37','otimesas':'\u2A36','ouml':'\xF6','Ouml':'\xD6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','par':'\u2225','para':'\xB6','parallel':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','pcy':'\u043F','Pcy':'\u041F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','pfr':'\uD835\uDD2D','Pfr':'\uD835\uDD13','phi':'\u03C6','Phi':'\u03A6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','pi':'\u03C0','Pi':'\u03A0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plus':'+','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','pr':'\u227A','Pr':'\u2ABB','prap':'\u2AB7','prcue':'\u227C','pre':'\u2AAF','prE':'\u2AB3','prec':'\u227A','precapprox':'\u2AB7','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportion':'\u2237','Proportional':'\u221D','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','pscr':'\uD835\uDCC5','Pscr':'\uD835\uDCAB','psi':'\u03C8','Psi':'\u03A8','puncsp':'\u2008','qfr':'\uD835\uDD2E','Qfr':'\uD835\uDD14','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','qscr':'\uD835\uDCC6','Qscr':'\uD835\uDCAC','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','racute':'\u0155','Racute':'\u0154','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarr':'\u2192','rArr':'\u21D2','Rarr':'\u21A0','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','rarrtl':'\u21A3','Rarrtl':'\u2916','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','rcaron':'\u0159','Rcaron':'\u0158','rcedil':'\u0157','Rcedil':'\u0156','rceil':'\u2309','rcub':'}','rcy':'\u0440','Rcy':'\u0420','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','Re':'\u211C','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','rho':'\u03C1','Rho':'\u03A1','rhov':'\u03F1','RightAngleBracket':'\u27E9','rightarrow':'\u2192','Rightarrow':'\u21D2','RightArrow':'\u2192','RightArrowBar':'\u21E5','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVector':'\u21C2','RightDownVectorBar':'\u2955','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTee':'\u22A2','RightTeeArrow':'\u21A6','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangle':'\u22B3','RightTriangleBar':'\u29D0','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVector':'\u21BE','RightUpVectorBar':'\u2954','RightVector':'\u21C0','RightVectorBar':'\u2953','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoust':'\u23B1','rmoustache':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','sacute':'\u015B','Sacute':'\u015A','sbquo':'\u201A','sc':'\u227B','Sc':'\u2ABC','scap':'\u2AB8','scaron':'\u0161','Scaron':'\u0160','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','scedil':'\u015F','Scedil':'\u015E','scirc':'\u015D','Scirc':'\u015C','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','scy':'\u0441','Scy':'\u0421','sdot':'\u22C5','sdotb':'\u22A1','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','sfr':'\uD835\uDD30','Sfr':'\uD835\uDD16','sfrown':'\u2322','sharp':'\u266F','shchcy':'\u0449','SHCHcy':'\u0429','shcy':'\u0448','SHcy':'\u0428','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','sigma':'\u03C3','Sigma':'\u03A3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','softcy':'\u044C','SOFTcy':'\u042C','sol':'/','solb':'\u29C4','solbar':'\u233F','sopf':'\uD835\uDD64','Sopf':'\uD835\uDD4A','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','squ':'\u25A1','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squf':'\u25AA','srarr':'\u2192','sscr':'\uD835\uDCC8','Sscr':'\uD835\uDCAE','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','star':'\u2606','Star':'\u22C6','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','sube':'\u2286','subE':'\u2AC5','subedot':'\u2AC3','submult':'\u2AC1','subne':'\u228A','subnE':'\u2ACB','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succ':'\u227B','succapprox':'\u2AB8','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup':'\u2283','Sup':'\u22D1','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','supdot':'\u2ABE','supdsub':'\u2AD8','supe':'\u2287','supE':'\u2AC6','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supne':'\u228B','supnE':'\u2ACC','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','tau':'\u03C4','Tau':'\u03A4','tbrk':'\u23B4','tcaron':'\u0165','Tcaron':'\u0164','tcedil':'\u0163','Tcedil':'\u0162','tcy':'\u0442','Tcy':'\u0422','tdot':'\u20DB','telrec':'\u2315','tfr':'\uD835\uDD31','Tfr':'\uD835\uDD17','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','theta':'\u03B8','Theta':'\u0398','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','thinsp':'\u2009','ThinSpace':'\u2009','thkap':'\u2248','thksim':'\u223C','thorn':'\xFE','THORN':'\xDE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','times':'\xD7','timesb':'\u22A0','timesbar':'\u2A31','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','top':'\u22A4','topbot':'\u2336','topcir':'\u2AF1','topf':'\uD835\uDD65','Topf':'\uD835\uDD4B','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','tscr':'\uD835\uDCC9','Tscr':'\uD835\uDCAF','tscy':'\u0446','TScy':'\u0426','tshcy':'\u045B','TSHcy':'\u040B','tstrok':'\u0167','Tstrok':'\u0166','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','uacute':'\xFA','Uacute':'\xDA','uarr':'\u2191','uArr':'\u21D1','Uarr':'\u219F','Uarrocir':'\u2949','ubrcy':'\u045E','Ubrcy':'\u040E','ubreve':'\u016D','Ubreve':'\u016C','ucirc':'\xFB','Ucirc':'\xDB','ucy':'\u0443','Ucy':'\u0423','udarr':'\u21C5','udblac':'\u0171','Udblac':'\u0170','udhar':'\u296E','ufisht':'\u297E','ufr':'\uD835\uDD32','Ufr':'\uD835\uDD18','ugrave':'\xF9','Ugrave':'\xD9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','umacr':'\u016B','Umacr':'\u016A','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','uogon':'\u0173','Uogon':'\u0172','uopf':'\uD835\uDD66','Uopf':'\uD835\uDD4C','uparrow':'\u2191','Uparrow':'\u21D1','UpArrow':'\u2191','UpArrowBar':'\u2912','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','Updownarrow':'\u21D5','UpDownArrow':'\u2195','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','upsilon':'\u03C5','Upsilon':'\u03A5','UpTee':'\u22A5','UpTeeArrow':'\u21A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','uring':'\u016F','Uring':'\u016E','urtri':'\u25F9','uscr':'\uD835\uDCCA','Uscr':'\uD835\uDCB0','utdot':'\u22F0','utilde':'\u0169','Utilde':'\u0168','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','uuml':'\xFC','Uuml':'\xDC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','vcy':'\u0432','Vcy':'\u0412','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','vee':'\u2228','Vee':'\u22C1','veebar':'\u22BB','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','vfr':'\uD835\uDD33','Vfr':'\uD835\uDD19','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','vopf':'\uD835\uDD67','Vopf':'\uD835\uDD4D','vprop':'\u221D','vrtri':'\u22B3','vscr':'\uD835\uDCCB','Vscr':'\uD835\uDCB1','vsubne':'\u228A\uFE00','vsubnE':'\u2ACB\uFE00','vsupne':'\u228B\uFE00','vsupnE':'\u2ACC\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','wcirc':'\u0175','Wcirc':'\u0174','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','wfr':'\uD835\uDD34','Wfr':'\uD835\uDD1A','wopf':'\uD835\uDD68','Wopf':'\uD835\uDD4E','wp':'\u2118','wr':'\u2240','wreath':'\u2240','wscr':'\uD835\uDCCC','Wscr':'\uD835\uDCB2','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','xfr':'\uD835\uDD35','Xfr':'\uD835\uDD1B','xharr':'\u27F7','xhArr':'\u27FA','xi':'\u03BE','Xi':'\u039E','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','xopf':'\uD835\uDD69','Xopf':'\uD835\uDD4F','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','xscr':'\uD835\uDCCD','Xscr':'\uD835\uDCB3','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','yacute':'\xFD','Yacute':'\xDD','yacy':'\u044F','YAcy':'\u042F','ycirc':'\u0177','Ycirc':'\u0176','ycy':'\u044B','Ycy':'\u042B','yen':'\xA5','yfr':'\uD835\uDD36','Yfr':'\uD835\uDD1C','yicy':'\u0457','YIcy':'\u0407','yopf':'\uD835\uDD6A','Yopf':'\uD835\uDD50','yscr':'\uD835\uDCCE','Yscr':'\uD835\uDCB4','yucy':'\u044E','YUcy':'\u042E','yuml':'\xFF','Yuml':'\u0178','zacute':'\u017A','Zacute':'\u0179','zcaron':'\u017E','Zcaron':'\u017D','zcy':'\u0437','Zcy':'\u0417','zdot':'\u017C','Zdot':'\u017B','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','zeta':'\u03B6','Zeta':'\u0396','zfr':'\uD835\uDD37','Zfr':'\u2128','zhcy':'\u0436','ZHcy':'\u0416','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','zscr':'\uD835\uDCCF','Zscr':'\uD835\uDCB5','zwj':'\u200D','zwnj':'\u200C'};
  6078. var decodeMapLegacy = {'aacute':'\xE1','Aacute':'\xC1','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','aelig':'\xE6','AElig':'\xC6','agrave':'\xE0','Agrave':'\xC0','amp':'&','AMP':'&','aring':'\xE5','Aring':'\xC5','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','brvbar':'\xA6','ccedil':'\xE7','Ccedil':'\xC7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','eacute':'\xE9','Eacute':'\xC9','ecirc':'\xEA','Ecirc':'\xCA','egrave':'\xE8','Egrave':'\xC8','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','iacute':'\xED','Iacute':'\xCD','icirc':'\xEE','Icirc':'\xCE','iexcl':'\xA1','igrave':'\xEC','Igrave':'\xCC','iquest':'\xBF','iuml':'\xEF','Iuml':'\xCF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','ntilde':'\xF1','Ntilde':'\xD1','oacute':'\xF3','Oacute':'\xD3','ocirc':'\xF4','Ocirc':'\xD4','ograve':'\xF2','Ograve':'\xD2','ordf':'\xAA','ordm':'\xBA','oslash':'\xF8','Oslash':'\xD8','otilde':'\xF5','Otilde':'\xD5','ouml':'\xF6','Ouml':'\xD6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','thorn':'\xFE','THORN':'\xDE','times':'\xD7','uacute':'\xFA','Uacute':'\xDA','ucirc':'\xFB','Ucirc':'\xDB','ugrave':'\xF9','Ugrave':'\xD9','uml':'\xA8','uuml':'\xFC','Uuml':'\xDC','yacute':'\xFD','Yacute':'\xDD','yen':'\xA5','yuml':'\xFF'};
  6079. var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'};
  6080. var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];
  6081. /*--------------------------------------------------------------------------*/
  6082. var stringFromCharCode = String.fromCharCode;
  6083. var object = {};
  6084. var hasOwnProperty = object.hasOwnProperty;
  6085. var has = function(object, propertyName) {
  6086. return hasOwnProperty.call(object, propertyName);
  6087. };
  6088. var contains = function(array, value) {
  6089. var index = -1;
  6090. var length = array.length;
  6091. while (++index < length) {
  6092. if (array[index] == value) {
  6093. return true;
  6094. }
  6095. }
  6096. return false;
  6097. };
  6098. var merge = function(options, defaults) {
  6099. if (!options) {
  6100. return defaults;
  6101. }
  6102. var result = {};
  6103. var key;
  6104. for (key in defaults) {
  6105. // A `hasOwnProperty` check is not needed here, since only recognized
  6106. // option names are used anyway. Any others are ignored.
  6107. result[key] = has(options, key) ? options[key] : defaults[key];
  6108. }
  6109. return result;
  6110. };
  6111. // Modified version of `ucs2encode`; see https://mths.be/punycode.
  6112. var codePointToSymbol = function(codePoint, strict) {
  6113. var output = '';
  6114. if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
  6115. // See issue #4:
  6116. // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
  6117. // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
  6118. // REPLACEMENT CHARACTER.”
  6119. if (strict) {
  6120. parseError('character reference outside the permissible Unicode range');
  6121. }
  6122. return '\uFFFD';
  6123. }
  6124. if (has(decodeMapNumeric, codePoint)) {
  6125. if (strict) {
  6126. parseError('disallowed character reference');
  6127. }
  6128. return decodeMapNumeric[codePoint];
  6129. }
  6130. if (strict && contains(invalidReferenceCodePoints, codePoint)) {
  6131. parseError('disallowed character reference');
  6132. }
  6133. if (codePoint > 0xFFFF) {
  6134. codePoint -= 0x10000;
  6135. output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
  6136. codePoint = 0xDC00 | codePoint & 0x3FF;
  6137. }
  6138. output += stringFromCharCode(codePoint);
  6139. return output;
  6140. };
  6141. var hexEscape = function(codePoint) {
  6142. return '&#x' + codePoint.toString(16).toUpperCase() + ';';
  6143. };
  6144. var decEscape = function(codePoint) {
  6145. return '&#' + codePoint + ';';
  6146. };
  6147. var parseError = function(message) {
  6148. throw Error('Parse error: ' + message);
  6149. };
  6150. /*--------------------------------------------------------------------------*/
  6151. var encode = function(string, options) {
  6152. options = merge(options, encode.options);
  6153. var strict = options.strict;
  6154. if (strict && regexInvalidRawCodePoint.test(string)) {
  6155. parseError('forbidden code point');
  6156. }
  6157. var encodeEverything = options.encodeEverything;
  6158. var useNamedReferences = options.useNamedReferences;
  6159. var allowUnsafeSymbols = options.allowUnsafeSymbols;
  6160. var escapeCodePoint = options.decimal ? decEscape : hexEscape;
  6161. var escapeBmpSymbol = function(symbol) {
  6162. return escapeCodePoint(symbol.charCodeAt(0));
  6163. };
  6164. if (encodeEverything) {
  6165. // Encode ASCII symbols.
  6166. string = string.replace(regexAsciiWhitelist, function(symbol) {
  6167. // Use named references if requested & possible.
  6168. if (useNamedReferences && has(encodeMap, symbol)) {
  6169. return '&' + encodeMap[symbol] + ';';
  6170. }
  6171. return escapeBmpSymbol(symbol);
  6172. });
  6173. // Shorten a few escapes that represent two symbols, of which at least one
  6174. // is within the ASCII range.
  6175. if (useNamedReferences) {
  6176. string = string
  6177. .replace(/&gt;\u20D2/g, '&nvgt;')
  6178. .replace(/&lt;\u20D2/g, '&nvlt;')
  6179. .replace(/&#x66;&#x6A;/g, '&fjlig;');
  6180. }
  6181. // Encode non-ASCII symbols.
  6182. if (useNamedReferences) {
  6183. // Encode non-ASCII symbols that can be replaced with a named reference.
  6184. string = string.replace(regexEncodeNonAscii, function(string) {
  6185. // Note: there is no need to check `has(encodeMap, string)` here.
  6186. return '&' + encodeMap[string] + ';';
  6187. });
  6188. }
  6189. // Note: any remaining non-ASCII symbols are handled outside of the `if`.
  6190. } else if (useNamedReferences) {
  6191. // Apply named character references.
  6192. // Encode `<>"'&` using named character references.
  6193. if (!allowUnsafeSymbols) {
  6194. string = string.replace(regexEscape, function(string) {
  6195. return '&' + encodeMap[string] + ';'; // no need to check `has()` here
  6196. });
  6197. }
  6198. // Shorten escapes that represent two symbols, of which at least one is
  6199. // `<>"'&`.
  6200. string = string
  6201. .replace(/&gt;\u20D2/g, '&nvgt;')
  6202. .replace(/&lt;\u20D2/g, '&nvlt;');
  6203. // Encode non-ASCII symbols that can be replaced with a named reference.
  6204. string = string.replace(regexEncodeNonAscii, function(string) {
  6205. // Note: there is no need to check `has(encodeMap, string)` here.
  6206. return '&' + encodeMap[string] + ';';
  6207. });
  6208. } else if (!allowUnsafeSymbols) {
  6209. // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
  6210. // using named character references.
  6211. string = string.replace(regexEscape, escapeBmpSymbol);
  6212. }
  6213. return string
  6214. // Encode astral symbols.
  6215. .replace(regexAstralSymbols, function($0) {
  6216. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  6217. var high = $0.charCodeAt(0);
  6218. var low = $0.charCodeAt(1);
  6219. var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
  6220. return escapeCodePoint(codePoint);
  6221. })
  6222. // Encode any remaining BMP symbols that are not printable ASCII symbols
  6223. // using a hexadecimal escape.
  6224. .replace(regexBmpWhitelist, escapeBmpSymbol);
  6225. };
  6226. // Expose default options (so they can be overridden globally).
  6227. encode.options = {
  6228. 'allowUnsafeSymbols': false,
  6229. 'encodeEverything': false,
  6230. 'strict': false,
  6231. 'useNamedReferences': false,
  6232. 'decimal' : false
  6233. };
  6234. var decode = function(html, options) {
  6235. options = merge(options, decode.options);
  6236. var strict = options.strict;
  6237. if (strict && regexInvalidEntity.test(html)) {
  6238. parseError('malformed character reference');
  6239. }
  6240. return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
  6241. var codePoint;
  6242. var semicolon;
  6243. var decDigits;
  6244. var hexDigits;
  6245. var reference;
  6246. var next;
  6247. if ($1) {
  6248. reference = $1;
  6249. // Note: there is no need to check `has(decodeMap, reference)`.
  6250. return decodeMap[reference];
  6251. }
  6252. if ($2) {
  6253. // Decode named character references without trailing `;`, e.g. `&amp`.
  6254. // This is only a parse error if it gets converted to `&`, or if it is
  6255. // followed by `=` in an attribute context.
  6256. reference = $2;
  6257. next = $3;
  6258. if (next && options.isAttributeValue) {
  6259. if (strict && next == '=') {
  6260. parseError('`&` did not start a character reference');
  6261. }
  6262. return $0;
  6263. } else {
  6264. if (strict) {
  6265. parseError(
  6266. 'named character reference was not terminated by a semicolon'
  6267. );
  6268. }
  6269. // Note: there is no need to check `has(decodeMapLegacy, reference)`.
  6270. return decodeMapLegacy[reference] + (next || '');
  6271. }
  6272. }
  6273. if ($4) {
  6274. // Decode decimal escapes, e.g. `&#119558;`.
  6275. decDigits = $4;
  6276. semicolon = $5;
  6277. if (strict && !semicolon) {
  6278. parseError('character reference was not terminated by a semicolon');
  6279. }
  6280. codePoint = parseInt(decDigits, 10);
  6281. return codePointToSymbol(codePoint, strict);
  6282. }
  6283. if ($6) {
  6284. // Decode hexadecimal escapes, e.g. `&#x1D306;`.
  6285. hexDigits = $6;
  6286. semicolon = $7;
  6287. if (strict && !semicolon) {
  6288. parseError('character reference was not terminated by a semicolon');
  6289. }
  6290. codePoint = parseInt(hexDigits, 16);
  6291. return codePointToSymbol(codePoint, strict);
  6292. }
  6293. // If we’re still here, `if ($7)` is implied; it’s an ambiguous
  6294. // ampersand for sure. https://mths.be/notes/ambiguous-ampersands
  6295. if (strict) {
  6296. parseError(
  6297. 'named character reference was not terminated by a semicolon'
  6298. );
  6299. }
  6300. return $0;
  6301. });
  6302. };
  6303. // Expose default options (so they can be overridden globally).
  6304. decode.options = {
  6305. 'isAttributeValue': false,
  6306. 'strict': false
  6307. };
  6308. var escape = function(string) {
  6309. return string.replace(regexEscape, function($0) {
  6310. // Note: there is no need to check `has(escapeMap, $0)` here.
  6311. return escapeMap[$0];
  6312. });
  6313. };
  6314. /*--------------------------------------------------------------------------*/
  6315. var he = {
  6316. 'version': '1.2.0',
  6317. 'encode': encode,
  6318. 'decode': decode,
  6319. 'escape': escape,
  6320. 'unescape': decode
  6321. };
  6322. // Some AMD build optimizers, like r.js, check for specific condition patterns
  6323. // like the following:
  6324. if (freeExports && !freeExports.nodeType) {
  6325. if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
  6326. freeModule.exports = he;
  6327. } else { // in Narwhal or RingoJS v0.7.0-
  6328. for (var key in he) {
  6329. has(he, key) && (freeExports[key] = he[key]);
  6330. }
  6331. }
  6332. } else { // in Rhino or a web browser
  6333. root.he = he;
  6334. }
  6335. }(commonjsGlobal));
  6336. } (he$1, he$1.exports));
  6337. var he = he$1.exports;
  6338. /**
  6339. * Cross-platform code generation for component v-model
  6340. */
  6341. function genComponentModel(el, value, modifiers) {
  6342. const { number, trim } = modifiers || {};
  6343. const baseValueExpression = '$$v';
  6344. let valueExpression = baseValueExpression;
  6345. if (trim) {
  6346. valueExpression =
  6347. `(typeof ${baseValueExpression} === 'string'` +
  6348. `? ${baseValueExpression}.trim()` +
  6349. `: ${baseValueExpression})`;
  6350. }
  6351. if (number) {
  6352. valueExpression = `_n(${valueExpression})`;
  6353. }
  6354. const assignment = genAssignmentCode(value, valueExpression);
  6355. el.model = {
  6356. value: `(${value})`,
  6357. expression: JSON.stringify(value),
  6358. callback: `function (${baseValueExpression}) {${assignment}}`
  6359. };
  6360. }
  6361. /**
  6362. * Cross-platform codegen helper for generating v-model value assignment code.
  6363. */
  6364. function genAssignmentCode(value, assignment) {
  6365. const res = parseModel(value);
  6366. if (res.key === null) {
  6367. return `${value}=${assignment}`;
  6368. }
  6369. else {
  6370. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  6371. }
  6372. }
  6373. /**
  6374. * Parse a v-model expression into a base path and a final key segment.
  6375. * Handles both dot-path and possible square brackets.
  6376. *
  6377. * Possible cases:
  6378. *
  6379. * - test
  6380. * - test[key]
  6381. * - test[test1[key]]
  6382. * - test["a"][key]
  6383. * - xxx.test[a[a].test1[key]]
  6384. * - test.xxx.a["asa"][test1[key]]
  6385. *
  6386. */
  6387. let len, str$1, chr, index, expressionPos, expressionEndPos;
  6388. function parseModel(val) {
  6389. // Fix https://github.com/vuejs/vue/pull/7730
  6390. // allow v-model="obj.val " (trailing whitespace)
  6391. val = val.trim();
  6392. len = val.length;
  6393. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6394. index = val.lastIndexOf('.');
  6395. if (index > -1) {
  6396. return {
  6397. exp: val.slice(0, index),
  6398. key: '"' + val.slice(index + 1) + '"'
  6399. };
  6400. }
  6401. else {
  6402. return {
  6403. exp: val,
  6404. key: null
  6405. };
  6406. }
  6407. }
  6408. str$1 = val;
  6409. index = expressionPos = expressionEndPos = 0;
  6410. while (!eof()) {
  6411. chr = next();
  6412. /* istanbul ignore if */
  6413. if (isStringStart(chr)) {
  6414. parseString(chr);
  6415. }
  6416. else if (chr === 0x5b) {
  6417. parseBracket(chr);
  6418. }
  6419. }
  6420. return {
  6421. exp: val.slice(0, expressionPos),
  6422. key: val.slice(expressionPos + 1, expressionEndPos)
  6423. };
  6424. }
  6425. function next() {
  6426. return str$1.charCodeAt(++index);
  6427. }
  6428. function eof() {
  6429. return index >= len;
  6430. }
  6431. function isStringStart(chr) {
  6432. return chr === 0x22 || chr === 0x27;
  6433. }
  6434. function parseBracket(chr) {
  6435. let inBracket = 1;
  6436. expressionPos = index;
  6437. while (!eof()) {
  6438. chr = next();
  6439. if (isStringStart(chr)) {
  6440. parseString(chr);
  6441. continue;
  6442. }
  6443. if (chr === 0x5b)
  6444. inBracket++;
  6445. if (chr === 0x5d)
  6446. inBracket--;
  6447. if (inBracket === 0) {
  6448. expressionEndPos = index;
  6449. break;
  6450. }
  6451. }
  6452. }
  6453. function parseString(chr) {
  6454. const stringQuote = chr;
  6455. while (!eof()) {
  6456. chr = next();
  6457. if (chr === stringQuote) {
  6458. break;
  6459. }
  6460. }
  6461. }
  6462. const onRE = /^@|^v-on:/;
  6463. const dirRE = /^v-|^@|^:|^#/;
  6464. const forAliasRE$1 = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  6465. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  6466. const stripParensRE = /^\(|\)$/g;
  6467. const dynamicArgRE = /^\[.*\]$/;
  6468. const argRE = /:(.*)$/;
  6469. const bindRE = /^:|^\.|^v-bind:/;
  6470. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  6471. const slotRE = /^v-slot(:|$)|^#/;
  6472. const lineBreakRE = /[\r\n]/;
  6473. const whitespaceRE = /[ \f\t\r\n]+/g;
  6474. const invalidAttributeRE = /[\s"'<>\/=]/;
  6475. const decodeHTMLCached = cached(he.decode);
  6476. const emptySlotScopeToken = `_empty_`;
  6477. // configurable state
  6478. let warn$2;
  6479. let delimiters;
  6480. let transforms;
  6481. let preTransforms;
  6482. let postTransforms;
  6483. let platformIsPreTag;
  6484. let platformMustUseProp;
  6485. let platformGetTagNamespace;
  6486. let maybeComponent;
  6487. function createASTElement(tag, attrs, parent) {
  6488. return {
  6489. type: 1,
  6490. tag,
  6491. attrsList: attrs,
  6492. attrsMap: makeAttrsMap(attrs),
  6493. rawAttrsMap: {},
  6494. parent,
  6495. children: []
  6496. };
  6497. }
  6498. /**
  6499. * Convert HTML string to AST.
  6500. */
  6501. function parse$1(template, options) {
  6502. warn$2 = options.warn || baseWarn;
  6503. platformIsPreTag = options.isPreTag || no;
  6504. platformMustUseProp = options.mustUseProp || no;
  6505. platformGetTagNamespace = options.getTagNamespace || no;
  6506. const isReservedTag = options.isReservedTag || no;
  6507. maybeComponent = (el) => !!(el.component ||
  6508. el.attrsMap[':is'] ||
  6509. el.attrsMap['v-bind:is'] ||
  6510. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  6511. transforms = pluckModuleFunction(options.modules, 'transformNode');
  6512. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  6513. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  6514. delimiters = options.delimiters;
  6515. const stack = [];
  6516. const preserveWhitespace = options.preserveWhitespace !== false;
  6517. const whitespaceOption = options.whitespace;
  6518. let root;
  6519. let currentParent;
  6520. let inVPre = false;
  6521. let inPre = false;
  6522. let warned = false;
  6523. function warnOnce(msg, range) {
  6524. if (!warned) {
  6525. warned = true;
  6526. warn$2(msg, range);
  6527. }
  6528. }
  6529. function closeElement(element) {
  6530. trimEndingWhitespace(element);
  6531. if (!inVPre && !element.processed) {
  6532. element = processElement(element, options);
  6533. }
  6534. // tree management
  6535. if (!stack.length && element !== root) {
  6536. // allow root elements with v-if, v-else-if and v-else
  6537. if (root.if && (element.elseif || element.else)) {
  6538. if (process.env.NODE_ENV !== 'production') {
  6539. checkRootConstraints(element);
  6540. }
  6541. addIfCondition(root, {
  6542. exp: element.elseif,
  6543. block: element
  6544. });
  6545. }
  6546. else if (process.env.NODE_ENV !== 'production') {
  6547. warnOnce(`Component template should contain exactly one root element. ` +
  6548. `If you are using v-if on multiple elements, ` +
  6549. `use v-else-if to chain them instead.`, { start: element.start });
  6550. }
  6551. }
  6552. if (currentParent && !element.forbidden) {
  6553. if (element.elseif || element.else) {
  6554. processIfConditions(element, currentParent);
  6555. }
  6556. else {
  6557. if (element.slotScope) {
  6558. // scoped slot
  6559. // keep it in the children list so that v-else(-if) conditions can
  6560. // find it as the prev node.
  6561. const name = element.slotTarget || '"default"';
  6562. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  6563. }
  6564. currentParent.children.push(element);
  6565. element.parent = currentParent;
  6566. }
  6567. }
  6568. // final children cleanup
  6569. // filter out scoped slots
  6570. element.children = element.children.filter(c => !c.slotScope);
  6571. // remove trailing whitespace node again
  6572. trimEndingWhitespace(element);
  6573. // check pre state
  6574. if (element.pre) {
  6575. inVPre = false;
  6576. }
  6577. if (platformIsPreTag(element.tag)) {
  6578. inPre = false;
  6579. }
  6580. // apply post-transforms
  6581. for (let i = 0; i < postTransforms.length; i++) {
  6582. postTransforms[i](element, options);
  6583. }
  6584. }
  6585. function trimEndingWhitespace(el) {
  6586. // remove trailing whitespace node
  6587. if (!inPre) {
  6588. let lastNode;
  6589. while ((lastNode = el.children[el.children.length - 1]) &&
  6590. lastNode.type === 3 &&
  6591. lastNode.text === ' ') {
  6592. el.children.pop();
  6593. }
  6594. }
  6595. }
  6596. function checkRootConstraints(el) {
  6597. if (el.tag === 'slot' || el.tag === 'template') {
  6598. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  6599. 'contain multiple nodes.', { start: el.start });
  6600. }
  6601. if (el.attrsMap.hasOwnProperty('v-for')) {
  6602. warnOnce('Cannot use v-for on stateful component root element because ' +
  6603. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  6604. }
  6605. }
  6606. parseHTML(template, {
  6607. warn: warn$2,
  6608. expectHTML: options.expectHTML,
  6609. isUnaryTag: options.isUnaryTag,
  6610. canBeLeftOpenTag: options.canBeLeftOpenTag,
  6611. shouldDecodeNewlines: options.shouldDecodeNewlines,
  6612. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  6613. shouldKeepComment: options.comments,
  6614. outputSourceRange: options.outputSourceRange,
  6615. start(tag, attrs, unary, start, end) {
  6616. // check namespace.
  6617. // inherit parent ns if there is one
  6618. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  6619. // handle IE svg bug
  6620. /* istanbul ignore if */
  6621. if (isIE && ns === 'svg') {
  6622. attrs = guardIESVGBug(attrs);
  6623. }
  6624. let element = createASTElement(tag, attrs, currentParent);
  6625. if (ns) {
  6626. element.ns = ns;
  6627. }
  6628. if (process.env.NODE_ENV !== 'production') {
  6629. if (options.outputSourceRange) {
  6630. element.start = start;
  6631. element.end = end;
  6632. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  6633. cumulated[attr.name] = attr;
  6634. return cumulated;
  6635. }, {});
  6636. }
  6637. attrs.forEach(attr => {
  6638. if (invalidAttributeRE.test(attr.name)) {
  6639. warn$2(`Invalid dynamic argument expression: attribute names cannot contain ` +
  6640. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  6641. ? {
  6642. start: attr.start + attr.name.indexOf(`[`),
  6643. end: attr.start + attr.name.length
  6644. }
  6645. : undefined);
  6646. }
  6647. });
  6648. }
  6649. if (isForbiddenTag(element) && !isServerRendering()) {
  6650. element.forbidden = true;
  6651. process.env.NODE_ENV !== 'production' &&
  6652. warn$2('Templates should only be responsible for mapping the state to the ' +
  6653. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  6654. `<${tag}>` +
  6655. ', as they will not be parsed.', { start: element.start });
  6656. }
  6657. // apply pre-transforms
  6658. for (let i = 0; i < preTransforms.length; i++) {
  6659. element = preTransforms[i](element, options) || element;
  6660. }
  6661. if (!inVPre) {
  6662. processPre(element);
  6663. if (element.pre) {
  6664. inVPre = true;
  6665. }
  6666. }
  6667. if (platformIsPreTag(element.tag)) {
  6668. inPre = true;
  6669. }
  6670. if (inVPre) {
  6671. processRawAttrs(element);
  6672. }
  6673. else if (!element.processed) {
  6674. // structural directives
  6675. processFor(element);
  6676. processIf(element);
  6677. processOnce(element);
  6678. }
  6679. if (!root) {
  6680. root = element;
  6681. if (process.env.NODE_ENV !== 'production') {
  6682. checkRootConstraints(root);
  6683. }
  6684. }
  6685. if (!unary) {
  6686. currentParent = element;
  6687. stack.push(element);
  6688. }
  6689. else {
  6690. closeElement(element);
  6691. }
  6692. },
  6693. end(tag, start, end) {
  6694. const element = stack[stack.length - 1];
  6695. // pop stack
  6696. stack.length -= 1;
  6697. currentParent = stack[stack.length - 1];
  6698. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6699. element.end = end;
  6700. }
  6701. closeElement(element);
  6702. },
  6703. chars(text, start, end) {
  6704. if (!currentParent) {
  6705. if (process.env.NODE_ENV !== 'production') {
  6706. if (text === template) {
  6707. warnOnce('Component template requires a root element, rather than just text.', { start });
  6708. }
  6709. else if ((text = text.trim())) {
  6710. warnOnce(`text "${text}" outside root element will be ignored.`, {
  6711. start
  6712. });
  6713. }
  6714. }
  6715. return;
  6716. }
  6717. // IE textarea placeholder bug
  6718. /* istanbul ignore if */
  6719. if (isIE &&
  6720. currentParent.tag === 'textarea' &&
  6721. currentParent.attrsMap.placeholder === text) {
  6722. return;
  6723. }
  6724. const children = currentParent.children;
  6725. if (inPre || text.trim()) {
  6726. text = isTextTag(currentParent)
  6727. ? text
  6728. : decodeHTMLCached(text);
  6729. }
  6730. else if (!children.length) {
  6731. // remove the whitespace-only node right after an opening tag
  6732. text = '';
  6733. }
  6734. else if (whitespaceOption) {
  6735. if (whitespaceOption === 'condense') {
  6736. // in condense mode, remove the whitespace node if it contains
  6737. // line break, otherwise condense to a single space
  6738. text = lineBreakRE.test(text) ? '' : ' ';
  6739. }
  6740. else {
  6741. text = ' ';
  6742. }
  6743. }
  6744. else {
  6745. text = preserveWhitespace ? ' ' : '';
  6746. }
  6747. if (text) {
  6748. if (!inPre && whitespaceOption === 'condense') {
  6749. // condense consecutive whitespaces into single space
  6750. text = text.replace(whitespaceRE, ' ');
  6751. }
  6752. let res;
  6753. let child;
  6754. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  6755. child = {
  6756. type: 2,
  6757. expression: res.expression,
  6758. tokens: res.tokens,
  6759. text
  6760. };
  6761. }
  6762. else if (text !== ' ' ||
  6763. !children.length ||
  6764. children[children.length - 1].text !== ' ') {
  6765. child = {
  6766. type: 3,
  6767. text
  6768. };
  6769. }
  6770. if (child) {
  6771. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6772. child.start = start;
  6773. child.end = end;
  6774. }
  6775. children.push(child);
  6776. }
  6777. }
  6778. },
  6779. comment(text, start, end) {
  6780. // adding anything as a sibling to the root node is forbidden
  6781. // comments should still be allowed, but ignored
  6782. if (currentParent) {
  6783. const child = {
  6784. type: 3,
  6785. text,
  6786. isComment: true
  6787. };
  6788. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6789. child.start = start;
  6790. child.end = end;
  6791. }
  6792. currentParent.children.push(child);
  6793. }
  6794. }
  6795. });
  6796. return root;
  6797. }
  6798. function processPre(el) {
  6799. if (getAndRemoveAttr(el, 'v-pre') != null) {
  6800. el.pre = true;
  6801. }
  6802. }
  6803. function processRawAttrs(el) {
  6804. const list = el.attrsList;
  6805. const len = list.length;
  6806. if (len) {
  6807. const attrs = (el.attrs = new Array(len));
  6808. for (let i = 0; i < len; i++) {
  6809. attrs[i] = {
  6810. name: list[i].name,
  6811. value: JSON.stringify(list[i].value)
  6812. };
  6813. if (list[i].start != null) {
  6814. attrs[i].start = list[i].start;
  6815. attrs[i].end = list[i].end;
  6816. }
  6817. }
  6818. }
  6819. else if (!el.pre) {
  6820. // non root node in pre blocks with no attributes
  6821. el.plain = true;
  6822. }
  6823. }
  6824. function processElement(element, options) {
  6825. processKey(element);
  6826. // determine whether this is a plain element after
  6827. // removing structural attributes
  6828. element.plain =
  6829. !element.key && !element.scopedSlots && !element.attrsList.length;
  6830. processRef(element);
  6831. processSlotContent(element);
  6832. processSlotOutlet(element);
  6833. processComponent(element);
  6834. for (let i = 0; i < transforms.length; i++) {
  6835. element = transforms[i](element, options) || element;
  6836. }
  6837. processAttrs(element);
  6838. return element;
  6839. }
  6840. function processKey(el) {
  6841. const exp = getBindingAttr(el, 'key');
  6842. if (exp) {
  6843. if (process.env.NODE_ENV !== 'production') {
  6844. if (el.tag === 'template') {
  6845. warn$2(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  6846. }
  6847. if (el.for) {
  6848. const iterator = el.iterator2 || el.iterator1;
  6849. const parent = el.parent;
  6850. if (iterator &&
  6851. iterator === exp &&
  6852. parent &&
  6853. parent.tag === 'transition-group') {
  6854. warn$2(`Do not use v-for index as key on <transition-group> children, ` +
  6855. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  6856. }
  6857. }
  6858. }
  6859. el.key = exp;
  6860. }
  6861. }
  6862. function processRef(el) {
  6863. const ref = getBindingAttr(el, 'ref');
  6864. if (ref) {
  6865. el.ref = ref;
  6866. el.refInFor = checkInFor(el);
  6867. }
  6868. }
  6869. function processFor(el) {
  6870. let exp;
  6871. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  6872. const res = parseFor(exp);
  6873. if (res) {
  6874. extend(el, res);
  6875. }
  6876. else if (process.env.NODE_ENV !== 'production') {
  6877. warn$2(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  6878. }
  6879. }
  6880. }
  6881. function parseFor(exp) {
  6882. const inMatch = exp.match(forAliasRE$1);
  6883. if (!inMatch)
  6884. return;
  6885. const res = {};
  6886. res.for = inMatch[2].trim();
  6887. const alias = inMatch[1].trim().replace(stripParensRE, '');
  6888. const iteratorMatch = alias.match(forIteratorRE);
  6889. if (iteratorMatch) {
  6890. res.alias = alias.replace(forIteratorRE, '').trim();
  6891. res.iterator1 = iteratorMatch[1].trim();
  6892. if (iteratorMatch[2]) {
  6893. res.iterator2 = iteratorMatch[2].trim();
  6894. }
  6895. }
  6896. else {
  6897. res.alias = alias;
  6898. }
  6899. return res;
  6900. }
  6901. function processIf(el) {
  6902. const exp = getAndRemoveAttr(el, 'v-if');
  6903. if (exp) {
  6904. el.if = exp;
  6905. addIfCondition(el, {
  6906. exp: exp,
  6907. block: el
  6908. });
  6909. }
  6910. else {
  6911. if (getAndRemoveAttr(el, 'v-else') != null) {
  6912. el.else = true;
  6913. }
  6914. const elseif = getAndRemoveAttr(el, 'v-else-if');
  6915. if (elseif) {
  6916. el.elseif = elseif;
  6917. }
  6918. }
  6919. }
  6920. function processIfConditions(el, parent) {
  6921. const prev = findPrevElement(parent.children);
  6922. if (prev && prev.if) {
  6923. addIfCondition(prev, {
  6924. exp: el.elseif,
  6925. block: el
  6926. });
  6927. }
  6928. else if (process.env.NODE_ENV !== 'production') {
  6929. warn$2(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  6930. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  6931. }
  6932. }
  6933. function findPrevElement(children) {
  6934. let i = children.length;
  6935. while (i--) {
  6936. if (children[i].type === 1) {
  6937. return children[i];
  6938. }
  6939. else {
  6940. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  6941. warn$2(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  6942. `will be ignored.`, children[i]);
  6943. }
  6944. children.pop();
  6945. }
  6946. }
  6947. }
  6948. function addIfCondition(el, condition) {
  6949. if (!el.ifConditions) {
  6950. el.ifConditions = [];
  6951. }
  6952. el.ifConditions.push(condition);
  6953. }
  6954. function processOnce(el) {
  6955. const once = getAndRemoveAttr(el, 'v-once');
  6956. if (once != null) {
  6957. el.once = true;
  6958. }
  6959. }
  6960. // handle content being passed to a component as slot,
  6961. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  6962. function processSlotContent(el) {
  6963. let slotScope;
  6964. if (el.tag === 'template') {
  6965. slotScope = getAndRemoveAttr(el, 'scope');
  6966. /* istanbul ignore if */
  6967. if (process.env.NODE_ENV !== 'production' && slotScope) {
  6968. warn$2(`the "scope" attribute for scoped slots have been deprecated and ` +
  6969. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  6970. `can also be used on plain elements in addition to <template> to ` +
  6971. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  6972. }
  6973. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  6974. }
  6975. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  6976. /* istanbul ignore if */
  6977. if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
  6978. warn$2(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  6979. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  6980. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  6981. }
  6982. el.slotScope = slotScope;
  6983. }
  6984. // slot="xxx"
  6985. const slotTarget = getBindingAttr(el, 'slot');
  6986. if (slotTarget) {
  6987. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  6988. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  6989. // preserve slot as an attribute for native shadow DOM compat
  6990. // only for non-scoped slots.
  6991. if (el.tag !== 'template' && !el.slotScope) {
  6992. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  6993. }
  6994. }
  6995. // 2.6 v-slot syntax
  6996. {
  6997. if (el.tag === 'template') {
  6998. // v-slot on <template>
  6999. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  7000. if (slotBinding) {
  7001. if (process.env.NODE_ENV !== 'production') {
  7002. if (el.slotTarget || el.slotScope) {
  7003. warn$2(`Unexpected mixed usage of different slot syntaxes.`, el);
  7004. }
  7005. if (el.parent && !maybeComponent(el.parent)) {
  7006. warn$2(`<template v-slot> can only appear at the root level inside ` +
  7007. `the receiving component`, el);
  7008. }
  7009. }
  7010. const { name, dynamic } = getSlotName(slotBinding);
  7011. el.slotTarget = name;
  7012. el.slotTargetDynamic = dynamic;
  7013. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  7014. }
  7015. }
  7016. else {
  7017. // v-slot on component, denotes default slot
  7018. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  7019. if (slotBinding) {
  7020. if (process.env.NODE_ENV !== 'production') {
  7021. if (!maybeComponent(el)) {
  7022. warn$2(`v-slot can only be used on components or <template>.`, slotBinding);
  7023. }
  7024. if (el.slotScope || el.slotTarget) {
  7025. warn$2(`Unexpected mixed usage of different slot syntaxes.`, el);
  7026. }
  7027. if (el.scopedSlots) {
  7028. warn$2(`To avoid scope ambiguity, the default slot should also use ` +
  7029. `<template> syntax when there are other named slots.`, slotBinding);
  7030. }
  7031. }
  7032. // add the component's children to its default slot
  7033. const slots = el.scopedSlots || (el.scopedSlots = {});
  7034. const { name, dynamic } = getSlotName(slotBinding);
  7035. const slotContainer = (slots[name] = createASTElement('template', [], el));
  7036. slotContainer.slotTarget = name;
  7037. slotContainer.slotTargetDynamic = dynamic;
  7038. slotContainer.children = el.children.filter((c) => {
  7039. if (!c.slotScope) {
  7040. c.parent = slotContainer;
  7041. return true;
  7042. }
  7043. });
  7044. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  7045. // remove children as they are returned from scopedSlots now
  7046. el.children = [];
  7047. // mark el non-plain so data gets generated
  7048. el.plain = false;
  7049. }
  7050. }
  7051. }
  7052. }
  7053. function getSlotName(binding) {
  7054. let name = binding.name.replace(slotRE, '');
  7055. if (!name) {
  7056. if (binding.name[0] !== '#') {
  7057. name = 'default';
  7058. }
  7059. else if (process.env.NODE_ENV !== 'production') {
  7060. warn$2(`v-slot shorthand syntax requires a slot name.`, binding);
  7061. }
  7062. }
  7063. return dynamicArgRE.test(name)
  7064. ? // dynamic [name]
  7065. { name: name.slice(1, -1), dynamic: true }
  7066. : // static name
  7067. { name: `"${name}"`, dynamic: false };
  7068. }
  7069. // handle <slot/> outlets
  7070. function processSlotOutlet(el) {
  7071. if (el.tag === 'slot') {
  7072. el.slotName = getBindingAttr(el, 'name');
  7073. if (process.env.NODE_ENV !== 'production' && el.key) {
  7074. warn$2(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  7075. `and can possibly expand into multiple elements. ` +
  7076. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  7077. }
  7078. }
  7079. }
  7080. function processComponent(el) {
  7081. let binding;
  7082. if ((binding = getBindingAttr(el, 'is'))) {
  7083. el.component = binding;
  7084. }
  7085. if (getAndRemoveAttr(el, 'inline-template') != null) {
  7086. el.inlineTemplate = true;
  7087. }
  7088. }
  7089. function processAttrs(el) {
  7090. const list = el.attrsList;
  7091. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  7092. for (i = 0, l = list.length; i < l; i++) {
  7093. name = rawName = list[i].name;
  7094. value = list[i].value;
  7095. if (dirRE.test(name)) {
  7096. // mark element as dynamic
  7097. el.hasBindings = true;
  7098. // modifiers
  7099. modifiers = parseModifiers(name.replace(dirRE, ''));
  7100. // support .foo shorthand syntax for the .prop modifier
  7101. if (modifiers) {
  7102. name = name.replace(modifierRE, '');
  7103. }
  7104. if (bindRE.test(name)) {
  7105. // v-bind
  7106. name = name.replace(bindRE, '');
  7107. value = parseFilters(value);
  7108. isDynamic = dynamicArgRE.test(name);
  7109. if (isDynamic) {
  7110. name = name.slice(1, -1);
  7111. }
  7112. if (process.env.NODE_ENV !== 'production' && value.trim().length === 0) {
  7113. warn$2(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  7114. }
  7115. if (modifiers) {
  7116. if (modifiers.prop && !isDynamic) {
  7117. name = camelize(name);
  7118. if (name === 'innerHtml')
  7119. name = 'innerHTML';
  7120. }
  7121. if (modifiers.camel && !isDynamic) {
  7122. name = camelize(name);
  7123. }
  7124. if (modifiers.sync) {
  7125. syncGen = genAssignmentCode(value, `$event`);
  7126. if (!isDynamic) {
  7127. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn$2, list[i]);
  7128. if (hyphenate(name) !== camelize(name)) {
  7129. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn$2, list[i]);
  7130. }
  7131. }
  7132. else {
  7133. // handler w/ dynamic event name
  7134. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn$2, list[i], true // dynamic
  7135. );
  7136. }
  7137. }
  7138. }
  7139. if ((modifiers && modifiers.prop) ||
  7140. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  7141. addProp(el, name, value, list[i], isDynamic);
  7142. }
  7143. else {
  7144. addAttr(el, name, value, list[i], isDynamic);
  7145. }
  7146. }
  7147. else if (onRE.test(name)) {
  7148. // v-on
  7149. name = name.replace(onRE, '');
  7150. isDynamic = dynamicArgRE.test(name);
  7151. if (isDynamic) {
  7152. name = name.slice(1, -1);
  7153. }
  7154. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  7155. }
  7156. else {
  7157. // normal directives
  7158. name = name.replace(dirRE, '');
  7159. // parse arg
  7160. const argMatch = name.match(argRE);
  7161. let arg = argMatch && argMatch[1];
  7162. isDynamic = false;
  7163. if (arg) {
  7164. name = name.slice(0, -(arg.length + 1));
  7165. if (dynamicArgRE.test(arg)) {
  7166. arg = arg.slice(1, -1);
  7167. isDynamic = true;
  7168. }
  7169. }
  7170. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  7171. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  7172. checkForAliasModel(el, value);
  7173. }
  7174. }
  7175. }
  7176. else {
  7177. // literal attribute
  7178. if (process.env.NODE_ENV !== 'production') {
  7179. const res = parseText(value, delimiters);
  7180. if (res) {
  7181. warn$2(`${name}="${value}": ` +
  7182. 'Interpolation inside attributes has been removed. ' +
  7183. 'Use v-bind or the colon shorthand instead. For example, ' +
  7184. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  7185. }
  7186. }
  7187. addAttr(el, name, JSON.stringify(value), list[i]);
  7188. // #6887 firefox doesn't update muted state if set via attribute
  7189. // even immediately after element creation
  7190. if (!el.component &&
  7191. name === 'muted' &&
  7192. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  7193. addProp(el, name, 'true', list[i]);
  7194. }
  7195. }
  7196. }
  7197. }
  7198. function checkInFor(el) {
  7199. let parent = el;
  7200. while (parent) {
  7201. if (parent.for !== undefined) {
  7202. return true;
  7203. }
  7204. parent = parent.parent;
  7205. }
  7206. return false;
  7207. }
  7208. function parseModifiers(name) {
  7209. const match = name.match(modifierRE);
  7210. if (match) {
  7211. const ret = {};
  7212. match.forEach(m => {
  7213. ret[m.slice(1)] = true;
  7214. });
  7215. return ret;
  7216. }
  7217. }
  7218. function makeAttrsMap(attrs) {
  7219. const map = {};
  7220. for (let i = 0, l = attrs.length; i < l; i++) {
  7221. if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE && !isEdge) {
  7222. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  7223. }
  7224. map[attrs[i].name] = attrs[i].value;
  7225. }
  7226. return map;
  7227. }
  7228. // for script (e.g. type="x/template") or style, do not decode content
  7229. function isTextTag(el) {
  7230. return el.tag === 'script' || el.tag === 'style';
  7231. }
  7232. function isForbiddenTag(el) {
  7233. return (el.tag === 'style' ||
  7234. (el.tag === 'script' &&
  7235. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  7236. }
  7237. const ieNSBug = /^xmlns:NS\d+/;
  7238. const ieNSPrefix = /^NS\d+:/;
  7239. /* istanbul ignore next */
  7240. function guardIESVGBug(attrs) {
  7241. const res = [];
  7242. for (let i = 0; i < attrs.length; i++) {
  7243. const attr = attrs[i];
  7244. if (!ieNSBug.test(attr.name)) {
  7245. attr.name = attr.name.replace(ieNSPrefix, '');
  7246. res.push(attr);
  7247. }
  7248. }
  7249. return res;
  7250. }
  7251. function checkForAliasModel(el, value) {
  7252. let _el = el;
  7253. while (_el) {
  7254. if (_el.for && _el.alias === value) {
  7255. warn$2(`<${el.tag} v-model="${value}">: ` +
  7256. `You are binding v-model directly to a v-for iteration alias. ` +
  7257. `This will not be able to modify the v-for source array because ` +
  7258. `writing to the alias is like modifying a function local variable. ` +
  7259. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  7260. }
  7261. _el = _el.parent;
  7262. }
  7263. }
  7264. /**
  7265. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  7266. * Turn this:
  7267. * <input v-model="data[type]" :type="type">
  7268. * into this:
  7269. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  7270. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  7271. * <input v-else :type="type" v-model="data[type]">
  7272. */
  7273. function preTransformNode(el, options) {
  7274. if (el.tag === 'input') {
  7275. const map = el.attrsMap;
  7276. if (!map['v-model']) {
  7277. return;
  7278. }
  7279. let typeBinding;
  7280. if (map[':type'] || map['v-bind:type']) {
  7281. typeBinding = getBindingAttr(el, 'type');
  7282. }
  7283. if (!map.type && !typeBinding && map['v-bind']) {
  7284. typeBinding = `(${map['v-bind']}).type`;
  7285. }
  7286. if (typeBinding) {
  7287. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  7288. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  7289. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  7290. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  7291. // 1. checkbox
  7292. const branch0 = cloneASTElement(el);
  7293. // process for on the main node
  7294. processFor(branch0);
  7295. addRawAttr(branch0, 'type', 'checkbox');
  7296. processElement(branch0, options);
  7297. branch0.processed = true; // prevent it from double-processed
  7298. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  7299. addIfCondition(branch0, {
  7300. exp: branch0.if,
  7301. block: branch0
  7302. });
  7303. // 2. add radio else-if condition
  7304. const branch1 = cloneASTElement(el);
  7305. getAndRemoveAttr(branch1, 'v-for', true);
  7306. addRawAttr(branch1, 'type', 'radio');
  7307. processElement(branch1, options);
  7308. addIfCondition(branch0, {
  7309. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  7310. block: branch1
  7311. });
  7312. // 3. other
  7313. const branch2 = cloneASTElement(el);
  7314. getAndRemoveAttr(branch2, 'v-for', true);
  7315. addRawAttr(branch2, ':type', typeBinding);
  7316. processElement(branch2, options);
  7317. addIfCondition(branch0, {
  7318. exp: ifCondition,
  7319. block: branch2
  7320. });
  7321. if (hasElse) {
  7322. branch0.else = true;
  7323. }
  7324. else if (elseIfCondition) {
  7325. branch0.elseif = elseIfCondition;
  7326. }
  7327. return branch0;
  7328. }
  7329. }
  7330. }
  7331. function cloneASTElement(el) {
  7332. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  7333. }
  7334. var model$1 = {
  7335. preTransformNode
  7336. };
  7337. var modules = [klass, style, model$1];
  7338. let warn$1;
  7339. // in some cases, the event used has to be determined at runtime
  7340. // so we used some reserved tokens during compile.
  7341. const RANGE_TOKEN = '__r';
  7342. function model(el, dir, _warn) {
  7343. warn$1 = _warn;
  7344. const value = dir.value;
  7345. const modifiers = dir.modifiers;
  7346. const tag = el.tag;
  7347. const type = el.attrsMap.type;
  7348. if (process.env.NODE_ENV !== 'production') {
  7349. // inputs with type="file" are read only and setting the input's
  7350. // value will throw an error.
  7351. if (tag === 'input' && type === 'file') {
  7352. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7353. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7354. }
  7355. }
  7356. if (el.component) {
  7357. genComponentModel(el, value, modifiers);
  7358. // component v-model doesn't need extra runtime
  7359. return false;
  7360. }
  7361. else if (tag === 'select') {
  7362. genSelect(el, value, modifiers);
  7363. }
  7364. else if (tag === 'input' && type === 'checkbox') {
  7365. genCheckboxModel(el, value, modifiers);
  7366. }
  7367. else if (tag === 'input' && type === 'radio') {
  7368. genRadioModel(el, value, modifiers);
  7369. }
  7370. else if (tag === 'input' || tag === 'textarea') {
  7371. genDefaultModel(el, value, modifiers);
  7372. }
  7373. else {
  7374. genComponentModel(el, value, modifiers);
  7375. // component v-model doesn't need extra runtime
  7376. return false;
  7377. }
  7378. // ensure runtime directive metadata
  7379. return true;
  7380. }
  7381. function genCheckboxModel(el, value, modifiers) {
  7382. const number = modifiers && modifiers.number;
  7383. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7384. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7385. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7386. addProp(el, 'checked', `Array.isArray(${value})` +
  7387. `?_i(${value},${valueBinding})>-1` +
  7388. (trueValueBinding === 'true'
  7389. ? `:(${value})`
  7390. : `:_q(${value},${trueValueBinding})`));
  7391. addHandler(el, 'change', `var $$a=${value},` +
  7392. '$$el=$event.target,' +
  7393. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7394. 'if(Array.isArray($$a)){' +
  7395. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7396. '$$i=_i($$a,$$v);' +
  7397. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7398. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7399. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7400. }
  7401. function genRadioModel(el, value, modifiers) {
  7402. const number = modifiers && modifiers.number;
  7403. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7404. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7405. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7406. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7407. }
  7408. function genSelect(el, value, modifiers) {
  7409. const number = modifiers && modifiers.number;
  7410. const selectedVal = `Array.prototype.filter` +
  7411. `.call($event.target.options,function(o){return o.selected})` +
  7412. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7413. `return ${number ? '_n(val)' : 'val'}})`;
  7414. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7415. let code = `var $$selectedVal = ${selectedVal};`;
  7416. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7417. addHandler(el, 'change', code, null, true);
  7418. }
  7419. function genDefaultModel(el, value, modifiers) {
  7420. const type = el.attrsMap.type;
  7421. // warn if v-bind:value conflicts with v-model
  7422. // except for inputs with v-bind:type
  7423. if (process.env.NODE_ENV !== 'production') {
  7424. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7425. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7426. if (value && !typeBinding) {
  7427. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7428. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7429. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7430. }
  7431. }
  7432. const { lazy, number, trim } = modifiers || {};
  7433. const needCompositionGuard = !lazy && type !== 'range';
  7434. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7435. let valueExpression = '$event.target.value';
  7436. if (trim) {
  7437. valueExpression = `$event.target.value.trim()`;
  7438. }
  7439. if (number) {
  7440. valueExpression = `_n(${valueExpression})`;
  7441. }
  7442. let code = genAssignmentCode(value, valueExpression);
  7443. if (needCompositionGuard) {
  7444. code = `if($event.target.composing)return;${code}`;
  7445. }
  7446. addProp(el, 'value', `(${value})`);
  7447. addHandler(el, event, code, null, true);
  7448. if (trim || number) {
  7449. addHandler(el, 'blur', '$forceUpdate()');
  7450. }
  7451. }
  7452. function text(el, dir) {
  7453. if (dir.value) {
  7454. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  7455. }
  7456. }
  7457. function html(el, dir) {
  7458. if (dir.value) {
  7459. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  7460. }
  7461. }
  7462. var directives = {
  7463. model,
  7464. text,
  7465. html
  7466. };
  7467. const baseOptions = {
  7468. expectHTML: true,
  7469. modules,
  7470. directives,
  7471. isPreTag,
  7472. isUnaryTag,
  7473. mustUseProp,
  7474. canBeLeftOpenTag,
  7475. isReservedTag,
  7476. getTagNamespace,
  7477. staticKeys: genStaticKeys$1(modules)
  7478. };
  7479. const hasWarned = {};
  7480. function warnOnce(msg) {
  7481. const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
  7482. if (!isNodeProd && !hasWarned[msg]) {
  7483. hasWarned[msg] = true;
  7484. warn(msg);
  7485. }
  7486. }
  7487. function warn(msg) {
  7488. console.warn(`\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`);
  7489. }
  7490. const doNotPrefix = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  7491. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  7492. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  7493. 'require,' + // for webpack
  7494. 'arguments,' + // parsed as identifier but is a special keyword...
  7495. '_c' // cached to save property access
  7496. );
  7497. /**
  7498. * The input is expected to be a valid expression.
  7499. */
  7500. function prefixIdentifiers(source, isFunctional = false, isTS = false, babelOptions = {}, bindings) {
  7501. const s = new MagicString(source);
  7502. const plugins = [
  7503. ...(isTS ? ['typescript'] : []),
  7504. ...((babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [])
  7505. ];
  7506. const ast = parser$1.parseExpression(source, Object.assign(Object.assign({}, babelOptions), { plugins }));
  7507. const isScriptSetup = bindings && bindings.__isScriptSetup !== false;
  7508. walkIdentifiers(ast, (ident, parent) => {
  7509. const { name } = ident;
  7510. if (doNotPrefix(name)) {
  7511. return;
  7512. }
  7513. let prefix = `_vm.`;
  7514. if (isScriptSetup) {
  7515. const type = bindings[name];
  7516. if (type && type.startsWith('setup')) {
  7517. prefix = `_setup.`;
  7518. }
  7519. }
  7520. if (isStaticProperty(parent) && parent.shorthand) {
  7521. // property shorthand like { foo }, we need to add the key since
  7522. // we rewrite the value
  7523. // { foo } -> { foo: _vm.foo }
  7524. s.appendLeft(ident.end, `: ${prefix}${name}`);
  7525. }
  7526. else {
  7527. s.prependRight(ident.start, prefix);
  7528. }
  7529. }, node => {
  7530. if (node.type === 'WithStatement') {
  7531. s.remove(node.start, node.body.start + 1);
  7532. s.remove(node.end - 1, node.end);
  7533. if (!isFunctional) {
  7534. s.prependRight(node.start, `var _vm=this,_c=_vm._self._c${isScriptSetup ? `,_setup=_vm._self._setupProxy;` : `;`}`);
  7535. }
  7536. }
  7537. });
  7538. return s.toString();
  7539. }
  7540. const CSS_VARS_HELPER = `useCssVars`;
  7541. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  7542. return `{\n ${vars
  7543. .map(key => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`)
  7544. .join(',\n ')}\n}`;
  7545. }
  7546. function genVarName(id, raw, isProd) {
  7547. if (isProd) {
  7548. return hashSum(id + raw);
  7549. }
  7550. else {
  7551. return `${id}-${raw.replace(/([^\w-])/g, '_')}`;
  7552. }
  7553. }
  7554. function normalizeExpression(exp) {
  7555. exp = exp.trim();
  7556. if ((exp[0] === `'` && exp[exp.length - 1] === `'`) ||
  7557. (exp[0] === `"` && exp[exp.length - 1] === `"`)) {
  7558. return exp.slice(1, -1);
  7559. }
  7560. return exp;
  7561. }
  7562. const vBindRE = /v-bind\s*\(/g;
  7563. function parseCssVars(sfc) {
  7564. const vars = [];
  7565. sfc.styles.forEach(style => {
  7566. let match;
  7567. // ignore v-bind() in comments /* ... */
  7568. const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
  7569. while ((match = vBindRE.exec(content))) {
  7570. const start = match.index + match[0].length;
  7571. const end = lexBinding(content, start);
  7572. if (end !== null) {
  7573. const variable = normalizeExpression(content.slice(start, end));
  7574. if (!vars.includes(variable)) {
  7575. vars.push(variable);
  7576. }
  7577. }
  7578. }
  7579. });
  7580. return vars;
  7581. }
  7582. function lexBinding(content, start) {
  7583. let state = 0 /* LexerState.inParens */;
  7584. let parenDepth = 0;
  7585. for (let i = start; i < content.length; i++) {
  7586. const char = content.charAt(i);
  7587. switch (state) {
  7588. case 0 /* LexerState.inParens */:
  7589. if (char === `'`) {
  7590. state = 1 /* LexerState.inSingleQuoteString */;
  7591. }
  7592. else if (char === `"`) {
  7593. state = 2 /* LexerState.inDoubleQuoteString */;
  7594. }
  7595. else if (char === `(`) {
  7596. parenDepth++;
  7597. }
  7598. else if (char === `)`) {
  7599. if (parenDepth > 0) {
  7600. parenDepth--;
  7601. }
  7602. else {
  7603. return i;
  7604. }
  7605. }
  7606. break;
  7607. case 1 /* LexerState.inSingleQuoteString */:
  7608. if (char === `'`) {
  7609. state = 0 /* LexerState.inParens */;
  7610. }
  7611. break;
  7612. case 2 /* LexerState.inDoubleQuoteString */:
  7613. if (char === `"`) {
  7614. state = 0 /* LexerState.inParens */;
  7615. }
  7616. break;
  7617. }
  7618. }
  7619. return null;
  7620. }
  7621. const cssVarsPlugin = opts => {
  7622. const { id, isProd } = opts;
  7623. return {
  7624. postcssPlugin: 'vue-sfc-vars',
  7625. Declaration(decl) {
  7626. // rewrite CSS variables
  7627. const value = decl.value;
  7628. if (vBindRE.test(value)) {
  7629. vBindRE.lastIndex = 0;
  7630. let transformed = '';
  7631. let lastIndex = 0;
  7632. let match;
  7633. while ((match = vBindRE.exec(value))) {
  7634. const start = match.index + match[0].length;
  7635. const end = lexBinding(value, start);
  7636. if (end !== null) {
  7637. const variable = normalizeExpression(value.slice(start, end));
  7638. transformed +=
  7639. value.slice(lastIndex, match.index) +
  7640. `var(--${genVarName(id, variable, isProd)})`;
  7641. lastIndex = end + 1;
  7642. }
  7643. }
  7644. decl.value = transformed + value.slice(lastIndex);
  7645. }
  7646. }
  7647. };
  7648. };
  7649. cssVarsPlugin.postcss = true;
  7650. function genCssVarsCode(vars, bindings, id, isProd) {
  7651. const varsExp = genCssVarsFromList(vars, id, isProd);
  7652. return `_${CSS_VARS_HELPER}((_vm, _setup) => ${prefixIdentifiers(`(${varsExp})`, false, false, undefined, bindings)})`;
  7653. }
  7654. // <script setup> already gets the calls injected as part of the transform
  7655. // this is only for single normal <script>
  7656. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd) {
  7657. return (`\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\n` +
  7658. `const __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\n` +
  7659. `const __setup__ = __default__.setup\n` +
  7660. `__default__.setup = __setup__\n` +
  7661. ` ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n` +
  7662. ` : __injectCSSVars__\n`);
  7663. }
  7664. const defaultExportRE = /((?:^|\n|;)\s*)export(\s*)default/;
  7665. const namedDefaultExportRE = /((?:^|\n|;)\s*)export(.+)(?:as)?(\s*)default/s;
  7666. const exportDefaultClassRE = /((?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/;
  7667. /**
  7668. * Utility for rewriting `export default` in a script block into a variable
  7669. * declaration so that we can inject things into it
  7670. */
  7671. function rewriteDefault(input, as, parserPlugins) {
  7672. if (!hasDefaultExport(input)) {
  7673. return input + `\nconst ${as} = {}`;
  7674. }
  7675. let replaced;
  7676. const classMatch = input.match(exportDefaultClassRE);
  7677. if (classMatch) {
  7678. replaced =
  7679. input.replace(exportDefaultClassRE, '$1class $2') +
  7680. `\nconst ${as} = ${classMatch[2]}`;
  7681. }
  7682. else {
  7683. replaced = input.replace(defaultExportRE, `$1const ${as} =`);
  7684. }
  7685. if (!hasDefaultExport(replaced)) {
  7686. return replaced;
  7687. }
  7688. // if the script somehow still contains `default export`, it probably has
  7689. // multi-line comments or template strings. fallback to a full parse.
  7690. const s = new MagicString(input);
  7691. const ast = parser$1.parse(input, {
  7692. sourceType: 'module',
  7693. plugins: parserPlugins
  7694. }).program.body;
  7695. ast.forEach(node => {
  7696. if (node.type === 'ExportDefaultDeclaration') {
  7697. if (node.declaration.type === 'ClassDeclaration' && node.declaration.id) {
  7698. let start = node.declaration.decorators && node.declaration.decorators.length > 0
  7699. ? node.declaration.decorators[node.declaration.decorators.length - 1].end
  7700. : node.start;
  7701. s.overwrite(start, node.declaration.id.start, ` class `);
  7702. s.append(`\nconst ${as} = ${node.declaration.id.name}`);
  7703. }
  7704. else {
  7705. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  7706. }
  7707. }
  7708. if (node.type === 'ExportNamedDeclaration') {
  7709. for (const specifier of node.specifiers) {
  7710. if (specifier.type === 'ExportSpecifier' &&
  7711. specifier.exported.type === 'Identifier' &&
  7712. specifier.exported.name === 'default') {
  7713. if (node.source) {
  7714. if (specifier.local.name === 'default') {
  7715. const end = specifierEnd(input, specifier.local.end, node.end);
  7716. s.prepend(`import { default as __VUE_DEFAULT__ } from '${node.source.value}'\n`);
  7717. s.overwrite(specifier.start, end, ``);
  7718. s.append(`\nconst ${as} = __VUE_DEFAULT__`);
  7719. continue;
  7720. }
  7721. else {
  7722. const end = specifierEnd(input, specifier.exported.end, node.end);
  7723. s.prepend(`import { ${input.slice(specifier.local.start, specifier.local.end)} } from '${node.source.value}'\n`);
  7724. s.overwrite(specifier.start, end, ``);
  7725. s.append(`\nconst ${as} = ${specifier.local.name}`);
  7726. continue;
  7727. }
  7728. }
  7729. const end = specifierEnd(input, specifier.end, node.end);
  7730. s.overwrite(specifier.start, end, ``);
  7731. s.append(`\nconst ${as} = ${specifier.local.name}`);
  7732. }
  7733. }
  7734. }
  7735. });
  7736. return s.toString();
  7737. }
  7738. function hasDefaultExport(input) {
  7739. return defaultExportRE.test(input) || namedDefaultExportRE.test(input);
  7740. }
  7741. function specifierEnd(input, end, nodeEnd) {
  7742. // export { default , foo } ...
  7743. let hasCommas = false;
  7744. let oldEnd = end;
  7745. while (end < nodeEnd) {
  7746. if (/\s/.test(input.charAt(end))) {
  7747. end++;
  7748. }
  7749. else if (input.charAt(end) === ',') {
  7750. end++;
  7751. hasCommas = true;
  7752. break;
  7753. }
  7754. else if (input.charAt(end) === '}') {
  7755. break;
  7756. }
  7757. }
  7758. return hasCommas ? end : oldEnd;
  7759. }
  7760. // Special compiler macros
  7761. const DEFINE_PROPS = 'defineProps';
  7762. const DEFINE_EMITS = 'defineEmits';
  7763. const DEFINE_EXPOSE = 'defineExpose';
  7764. const WITH_DEFAULTS = 'withDefaults';
  7765. // constants
  7766. const DEFAULT_VAR = `__default__`;
  7767. const isBuiltInDir$1 = makeMap(`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
  7768. /**
  7769. * Compile `<script setup>`
  7770. * It requires the whole SFC descriptor because we need to handle and merge
  7771. * normal `<script>` + `<script setup>` if both are present.
  7772. */
  7773. function compileScript(sfc, options = { id: '' }) {
  7774. let { filename, script, scriptSetup, source } = sfc;
  7775. const isProd = !!options.isProd;
  7776. const genSourceMap = options.sourceMap !== false;
  7777. const cssVars = sfc.cssVars;
  7778. const scopeId = options.id ? options.id.replace(/^data-v-/, '') : '';
  7779. const scriptLang = script && script.lang;
  7780. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  7781. const isTS = scriptLang === 'ts' ||
  7782. scriptLang === 'tsx' ||
  7783. scriptSetupLang === 'ts' ||
  7784. scriptSetupLang === 'tsx';
  7785. // resolve parser plugins
  7786. const plugins = [];
  7787. if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
  7788. plugins.push('jsx');
  7789. }
  7790. else {
  7791. // If don't match the case of adding jsx, should remove the jsx from the babelParserPlugins
  7792. if (options.babelParserPlugins)
  7793. options.babelParserPlugins = options.babelParserPlugins.filter(n => n !== 'jsx');
  7794. }
  7795. if (options.babelParserPlugins)
  7796. plugins.push(...options.babelParserPlugins);
  7797. if (isTS) {
  7798. plugins.push('typescript');
  7799. if (!plugins.includes('decorators')) {
  7800. plugins.push('decorators-legacy');
  7801. }
  7802. }
  7803. if (!scriptSetup) {
  7804. if (!script) {
  7805. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  7806. }
  7807. if (scriptLang && !isTS && scriptLang !== 'jsx') {
  7808. // do not process non js/ts script blocks
  7809. return script;
  7810. }
  7811. try {
  7812. let content = script.content;
  7813. let map = script.map;
  7814. const scriptAst = parser$1.parse(content, {
  7815. plugins,
  7816. sourceType: 'module'
  7817. }).program;
  7818. const bindings = analyzeScriptBindings(scriptAst.body);
  7819. if (cssVars.length) {
  7820. content = rewriteDefault(content, DEFAULT_VAR, plugins);
  7821. content += genNormalScriptCssVarsCode(cssVars, bindings, scopeId, isProd);
  7822. content += `\nexport default ${DEFAULT_VAR}`;
  7823. }
  7824. return Object.assign(Object.assign({}, script), { content,
  7825. map,
  7826. bindings, scriptAst: scriptAst.body });
  7827. }
  7828. catch (e) {
  7829. // silently fallback if parse fails since user may be using custom
  7830. // babel syntax
  7831. return script;
  7832. }
  7833. }
  7834. if (script && scriptLang !== scriptSetupLang) {
  7835. throw new Error(`[@vue/compiler-sfc] <script> and <script setup> must have the same ` +
  7836. `language type.`);
  7837. }
  7838. if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
  7839. // do not process non js/ts script blocks
  7840. return scriptSetup;
  7841. }
  7842. // metadata that needs to be returned
  7843. const bindingMetadata = {};
  7844. const helperImports = new Set();
  7845. const userImports = Object.create(null);
  7846. const userImportAlias = Object.create(null);
  7847. const scriptBindings = Object.create(null);
  7848. const setupBindings = Object.create(null);
  7849. let defaultExport;
  7850. let hasDefinePropsCall = false;
  7851. let hasDefineEmitCall = false;
  7852. let hasDefineExposeCall = false;
  7853. let hasDefaultExportName = false;
  7854. let propsRuntimeDecl;
  7855. let propsRuntimeDefaults;
  7856. let propsDestructureDecl;
  7857. let propsTypeDecl;
  7858. let propsTypeDeclRaw;
  7859. let propsIdentifier;
  7860. let emitsRuntimeDecl;
  7861. let emitsTypeDecl;
  7862. let emitsTypeDeclRaw;
  7863. let emitIdentifier;
  7864. // props/emits declared via types
  7865. const typeDeclaredProps = {};
  7866. const typeDeclaredEmits = new Set();
  7867. // record declared types for runtime props type generation
  7868. const declaredTypes = {};
  7869. // props destructure data
  7870. const propsDestructuredBindings = Object.create(null);
  7871. // magic-string state
  7872. const s = new MagicString(source);
  7873. const startOffset = scriptSetup.start;
  7874. const endOffset = scriptSetup.end;
  7875. const scriptStartOffset = script && script.start;
  7876. const scriptEndOffset = script && script.end;
  7877. function helper(key) {
  7878. helperImports.add(key);
  7879. return `_${key}`;
  7880. }
  7881. function parse(input, options, offset) {
  7882. try {
  7883. return parser$1.parse(input, options).program;
  7884. }
  7885. catch (e) {
  7886. e.message = `[@vue/compiler-sfc] ${e.message}\n\n${filename}\n${generateCodeFrame(source, e.pos + offset, e.pos + offset + 1)}`;
  7887. throw e;
  7888. }
  7889. }
  7890. function error(msg, node, end = node.end + startOffset) {
  7891. throw new Error(`[@vue/compiler-sfc] ${msg}\n\n${filename}\n${generateCodeFrame(source, node.start + startOffset, end)}`);
  7892. }
  7893. function registerUserImport(source, local, imported, isType, isFromSetup) {
  7894. if (source === 'vue' && imported) {
  7895. userImportAlias[imported] = local;
  7896. }
  7897. let isUsedInTemplate = true;
  7898. if (sfc.template && !sfc.template.src && !sfc.template.lang) {
  7899. isUsedInTemplate = isImportUsed(local, sfc, isTS);
  7900. }
  7901. userImports[local] = {
  7902. isType,
  7903. imported: imported || 'default',
  7904. source,
  7905. isFromSetup,
  7906. isUsedInTemplate
  7907. };
  7908. }
  7909. function processDefineProps(node, declId) {
  7910. if (!isCallOf(node, DEFINE_PROPS)) {
  7911. return false;
  7912. }
  7913. if (hasDefinePropsCall) {
  7914. error(`duplicate ${DEFINE_PROPS}() call`, node);
  7915. }
  7916. hasDefinePropsCall = true;
  7917. propsRuntimeDecl = node.arguments[0];
  7918. // call has type parameters - infer runtime types from it
  7919. if (node.typeParameters) {
  7920. if (propsRuntimeDecl) {
  7921. error(`${DEFINE_PROPS}() cannot accept both type and non-type arguments ` +
  7922. `at the same time. Use one or the other.`, node);
  7923. }
  7924. propsTypeDeclRaw = node.typeParameters.params[0];
  7925. propsTypeDecl = resolveQualifiedType(propsTypeDeclRaw, node => node.type === 'TSTypeLiteral');
  7926. if (!propsTypeDecl) {
  7927. error(`type argument passed to ${DEFINE_PROPS}() must be a literal type, ` +
  7928. `or a reference to an interface or literal type.`, propsTypeDeclRaw);
  7929. }
  7930. }
  7931. if (declId) {
  7932. propsIdentifier = scriptSetup.content.slice(declId.start, declId.end);
  7933. }
  7934. return true;
  7935. }
  7936. function processWithDefaults(node, declId) {
  7937. if (!isCallOf(node, WITH_DEFAULTS)) {
  7938. return false;
  7939. }
  7940. if (processDefineProps(node.arguments[0], declId)) {
  7941. if (propsRuntimeDecl) {
  7942. error(`${WITH_DEFAULTS} can only be used with type-based ` +
  7943. `${DEFINE_PROPS} declaration.`, node);
  7944. }
  7945. propsRuntimeDefaults = node.arguments[1];
  7946. if (!propsRuntimeDefaults ||
  7947. propsRuntimeDefaults.type !== 'ObjectExpression') {
  7948. error(`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`, propsRuntimeDefaults || node);
  7949. }
  7950. }
  7951. else {
  7952. error(`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`, node.arguments[0] || node);
  7953. }
  7954. return true;
  7955. }
  7956. function processDefineEmits(node, declId) {
  7957. if (!isCallOf(node, DEFINE_EMITS)) {
  7958. return false;
  7959. }
  7960. if (hasDefineEmitCall) {
  7961. error(`duplicate ${DEFINE_EMITS}() call`, node);
  7962. }
  7963. hasDefineEmitCall = true;
  7964. emitsRuntimeDecl = node.arguments[0];
  7965. if (node.typeParameters) {
  7966. if (emitsRuntimeDecl) {
  7967. error(`${DEFINE_EMITS}() cannot accept both type and non-type arguments ` +
  7968. `at the same time. Use one or the other.`, node);
  7969. }
  7970. emitsTypeDeclRaw = node.typeParameters.params[0];
  7971. emitsTypeDecl = resolveQualifiedType(emitsTypeDeclRaw, node => node.type === 'TSFunctionType' || node.type === 'TSTypeLiteral');
  7972. if (!emitsTypeDecl) {
  7973. error(`type argument passed to ${DEFINE_EMITS}() must be a function type, ` +
  7974. `a literal type with call signatures, or a reference to the above types.`, emitsTypeDeclRaw);
  7975. }
  7976. }
  7977. if (declId) {
  7978. emitIdentifier =
  7979. declId.type === 'Identifier'
  7980. ? declId.name
  7981. : scriptSetup.content.slice(declId.start, declId.end);
  7982. }
  7983. return true;
  7984. }
  7985. function resolveQualifiedType(node, qualifier) {
  7986. if (qualifier(node)) {
  7987. return node;
  7988. }
  7989. if (node.type === 'TSTypeReference' &&
  7990. node.typeName.type === 'Identifier') {
  7991. const refName = node.typeName.name;
  7992. const isQualifiedType = (node) => {
  7993. if (node.type === 'TSInterfaceDeclaration' &&
  7994. node.id.name === refName) {
  7995. return node.body;
  7996. }
  7997. else if (node.type === 'TSTypeAliasDeclaration' &&
  7998. node.id.name === refName &&
  7999. qualifier(node.typeAnnotation)) {
  8000. return node.typeAnnotation;
  8001. }
  8002. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  8003. return isQualifiedType(node.declaration);
  8004. }
  8005. };
  8006. const body = scriptAst
  8007. ? [...scriptSetupAst.body, ...scriptAst.body]
  8008. : scriptSetupAst.body;
  8009. for (const node of body) {
  8010. const qualified = isQualifiedType(node);
  8011. if (qualified) {
  8012. return qualified;
  8013. }
  8014. }
  8015. }
  8016. }
  8017. function processDefineExpose(node) {
  8018. if (isCallOf(node, DEFINE_EXPOSE)) {
  8019. if (hasDefineExposeCall) {
  8020. error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  8021. }
  8022. hasDefineExposeCall = true;
  8023. return true;
  8024. }
  8025. return false;
  8026. }
  8027. function checkInvalidScopeReference(node, method) {
  8028. if (!node)
  8029. return;
  8030. walkIdentifiers(node, id => {
  8031. if (setupBindings[id.name]) {
  8032. error(`\`${method}()\` in <script setup> cannot reference locally ` +
  8033. `declared variables because it will be hoisted outside of the ` +
  8034. `setup() function. If your component options require initialization ` +
  8035. `in the module scope, use a separate normal <script> to export ` +
  8036. `the options instead.`, id);
  8037. }
  8038. });
  8039. }
  8040. /**
  8041. * check defaults. If the default object is an object literal with only
  8042. * static properties, we can directly generate more optimized default
  8043. * declarations. Otherwise we will have to fallback to runtime merging.
  8044. */
  8045. function hasStaticWithDefaults() {
  8046. return (propsRuntimeDefaults &&
  8047. propsRuntimeDefaults.type === 'ObjectExpression' &&
  8048. propsRuntimeDefaults.properties.every(node => (node.type === 'ObjectProperty' && !node.computed) ||
  8049. node.type === 'ObjectMethod'));
  8050. }
  8051. function genRuntimeProps(props) {
  8052. const keys = Object.keys(props);
  8053. if (!keys.length) {
  8054. return ``;
  8055. }
  8056. const hasStaticDefaults = hasStaticWithDefaults();
  8057. const scriptSetupSource = scriptSetup.content;
  8058. let propsDecls = `{
  8059. ${keys
  8060. .map(key => {
  8061. let defaultString;
  8062. const destructured = genDestructuredDefaultValue(key);
  8063. if (destructured) {
  8064. defaultString = `default: ${destructured}`;
  8065. }
  8066. else if (hasStaticDefaults) {
  8067. const prop = propsRuntimeDefaults.properties.find((node) => node.key.name === key);
  8068. if (prop) {
  8069. if (prop.type === 'ObjectProperty') {
  8070. // prop has corresponding static default value
  8071. defaultString = `default: ${scriptSetupSource.slice(prop.value.start, prop.value.end)}`;
  8072. }
  8073. else {
  8074. defaultString = `default() ${scriptSetupSource.slice(prop.body.start, prop.body.end)}`;
  8075. }
  8076. }
  8077. }
  8078. const { type, required } = props[key];
  8079. if (!isProd) {
  8080. return `${key}: { type: ${toRuntimeTypeString(type)}, required: ${required}${defaultString ? `, ${defaultString}` : ``} }`;
  8081. }
  8082. else if (type.some(el => el === 'Boolean' || (defaultString && el === 'Function'))) {
  8083. // #4783 production: if boolean or defaultString and function exists, should keep the type.
  8084. return `${key}: { type: ${toRuntimeTypeString(type)}${defaultString ? `, ${defaultString}` : ``} }`;
  8085. }
  8086. else {
  8087. // production: checks are useless
  8088. return `${key}: ${defaultString ? `{ ${defaultString} }` : 'null'}`;
  8089. }
  8090. })
  8091. .join(',\n ')}\n }`;
  8092. if (propsRuntimeDefaults && !hasStaticDefaults) {
  8093. propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(propsRuntimeDefaults.start + startOffset, propsRuntimeDefaults.end + startOffset)})`;
  8094. }
  8095. return `\n props: ${propsDecls},`;
  8096. }
  8097. function genDestructuredDefaultValue(key) {
  8098. const destructured = propsDestructuredBindings[key];
  8099. if (destructured && destructured.default) {
  8100. const value = scriptSetup.content.slice(destructured.default.start, destructured.default.end);
  8101. const isLiteral = destructured.default.type.endsWith('Literal');
  8102. return isLiteral ? value : `() => (${value})`;
  8103. }
  8104. }
  8105. function genSetupPropsType(node) {
  8106. const scriptSetupSource = scriptSetup.content;
  8107. if (hasStaticWithDefaults()) {
  8108. // if withDefaults() is used, we need to remove the optional flags
  8109. // on props that have default values
  8110. let res = `{ `;
  8111. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8112. for (const m of members) {
  8113. if ((m.type === 'TSPropertySignature' ||
  8114. m.type === 'TSMethodSignature') &&
  8115. m.typeAnnotation &&
  8116. m.key.type === 'Identifier') {
  8117. if (propsRuntimeDefaults.properties.some((p) => p.key.name === m.key.name)) {
  8118. res +=
  8119. m.key.name +
  8120. (m.type === 'TSMethodSignature' ? '()' : '') +
  8121. scriptSetupSource.slice(m.typeAnnotation.start, m.typeAnnotation.end) +
  8122. ', ';
  8123. }
  8124. else {
  8125. res +=
  8126. scriptSetupSource.slice(m.start, m.typeAnnotation.end) + `, `;
  8127. }
  8128. }
  8129. }
  8130. return (res.length ? res.slice(0, -2) : res) + ` }`;
  8131. }
  8132. else {
  8133. return scriptSetupSource.slice(node.start, node.end);
  8134. }
  8135. }
  8136. // 1. process normal <script> first if it exists
  8137. let scriptAst;
  8138. if (script) {
  8139. scriptAst = parse(script.content, {
  8140. plugins,
  8141. sourceType: 'module'
  8142. }, scriptStartOffset);
  8143. for (const node of scriptAst.body) {
  8144. if (node.type === 'ImportDeclaration') {
  8145. // record imports for dedupe
  8146. for (const specifier of node.specifiers) {
  8147. const imported = specifier.type === 'ImportSpecifier' &&
  8148. specifier.imported.type === 'Identifier' &&
  8149. specifier.imported.name;
  8150. registerUserImport(node.source.value, specifier.local.name, imported, node.importKind === 'type' ||
  8151. (specifier.type === 'ImportSpecifier' &&
  8152. specifier.importKind === 'type'), false);
  8153. }
  8154. }
  8155. else if (node.type === 'ExportDefaultDeclaration') {
  8156. // export default
  8157. defaultExport = node;
  8158. // check if user has manually specified `name` or 'render` option in
  8159. // export default
  8160. // if has name, skip name inference
  8161. // if has render and no template, generate return object instead of
  8162. // empty render function (#4980)
  8163. let optionProperties;
  8164. if (defaultExport.declaration.type === 'ObjectExpression') {
  8165. optionProperties = defaultExport.declaration.properties;
  8166. }
  8167. else if (defaultExport.declaration.type === 'CallExpression' &&
  8168. defaultExport.declaration.arguments[0].type === 'ObjectExpression') {
  8169. optionProperties = defaultExport.declaration.arguments[0].properties;
  8170. }
  8171. if (optionProperties) {
  8172. for (const s of optionProperties) {
  8173. if (s.type === 'ObjectProperty' &&
  8174. s.key.type === 'Identifier' &&
  8175. s.key.name === 'name') {
  8176. hasDefaultExportName = true;
  8177. }
  8178. }
  8179. }
  8180. // export default { ... } --> const __default__ = { ... }
  8181. const start = node.start + scriptStartOffset;
  8182. const end = node.declaration.start + scriptStartOffset;
  8183. s.overwrite(start, end, `const ${DEFAULT_VAR} = `);
  8184. }
  8185. else if (node.type === 'ExportNamedDeclaration') {
  8186. const defaultSpecifier = node.specifiers.find(s => s.exported.type === 'Identifier' && s.exported.name === 'default');
  8187. if (defaultSpecifier) {
  8188. defaultExport = node;
  8189. // 1. remove specifier
  8190. if (node.specifiers.length > 1) {
  8191. s.remove(defaultSpecifier.start + scriptStartOffset, defaultSpecifier.end + scriptStartOffset);
  8192. }
  8193. else {
  8194. s.remove(node.start + scriptStartOffset, node.end + scriptStartOffset);
  8195. }
  8196. if (node.source) {
  8197. // export { x as default } from './x'
  8198. // rewrite to `import { x as __default__ } from './x'` and
  8199. // add to top
  8200. s.prepend(`import { ${defaultSpecifier.local.name} as ${DEFAULT_VAR} } from '${node.source.value}'\n`);
  8201. }
  8202. else {
  8203. // export { x as default }
  8204. // rewrite to `const __default__ = x` and move to end
  8205. s.appendLeft(scriptEndOffset, `\nconst ${DEFAULT_VAR} = ${defaultSpecifier.local.name}\n`);
  8206. }
  8207. }
  8208. if (node.declaration) {
  8209. walkDeclaration(node.declaration, scriptBindings, userImportAlias);
  8210. }
  8211. }
  8212. else if ((node.type === 'VariableDeclaration' ||
  8213. node.type === 'FunctionDeclaration' ||
  8214. node.type === 'ClassDeclaration' ||
  8215. node.type === 'TSEnumDeclaration') &&
  8216. !node.declare) {
  8217. walkDeclaration(node, scriptBindings, userImportAlias);
  8218. }
  8219. }
  8220. // apply reactivity transform
  8221. // if (enableReactivityTransform && shouldTransform(script.content)) {
  8222. // const { rootRefs, importedHelpers } = transformAST(
  8223. // scriptAst,
  8224. // s,
  8225. // scriptStartOffset!
  8226. // )
  8227. // refBindings = rootRefs
  8228. // for (const h of importedHelpers) {
  8229. // helperImports.add(h)
  8230. // }
  8231. // }
  8232. // <script> after <script setup>
  8233. // we need to move the block up so that `const __default__` is
  8234. // declared before being used in the actual component definition
  8235. if (scriptStartOffset > startOffset) {
  8236. // if content doesn't end with newline, add one
  8237. if (!/\n$/.test(script.content.trim())) {
  8238. s.appendLeft(scriptEndOffset, `\n`);
  8239. }
  8240. s.move(scriptStartOffset, scriptEndOffset, 0);
  8241. }
  8242. }
  8243. // 2. parse <script setup> and walk over top level statements
  8244. const scriptSetupAst = parse(scriptSetup.content, {
  8245. plugins: [
  8246. ...plugins,
  8247. // allow top level await but only inside <script setup>
  8248. 'topLevelAwait'
  8249. ],
  8250. sourceType: 'module'
  8251. }, startOffset);
  8252. for (const node of scriptSetupAst.body) {
  8253. const start = node.start + startOffset;
  8254. let end = node.end + startOffset;
  8255. // locate comment
  8256. if (node.trailingComments && node.trailingComments.length > 0) {
  8257. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  8258. end = lastCommentNode.end + startOffset;
  8259. }
  8260. // locate the end of whitespace between this statement and the next
  8261. while (end <= source.length) {
  8262. if (!/\s/.test(source.charAt(end))) {
  8263. break;
  8264. }
  8265. end++;
  8266. }
  8267. // (Dropped) `ref: x` bindings
  8268. if (node.type === 'LabeledStatement' &&
  8269. node.label.name === 'ref' &&
  8270. node.body.type === 'ExpressionStatement') {
  8271. error(`ref sugar using the label syntax was an experimental proposal and ` +
  8272. `has been dropped based on community feedback. Please check out ` +
  8273. `the new proposal at https://github.com/vuejs/rfcs/discussions/369`, node);
  8274. }
  8275. if (node.type === 'ImportDeclaration') {
  8276. // import declarations are moved to top
  8277. s.move(start, end, 0);
  8278. // dedupe imports
  8279. let removed = 0;
  8280. const removeSpecifier = (i) => {
  8281. const removeLeft = i > removed;
  8282. removed++;
  8283. const current = node.specifiers[i];
  8284. const next = node.specifiers[i + 1];
  8285. s.remove(removeLeft
  8286. ? node.specifiers[i - 1].end + startOffset
  8287. : current.start + startOffset, next && !removeLeft
  8288. ? next.start + startOffset
  8289. : current.end + startOffset);
  8290. };
  8291. for (let i = 0; i < node.specifiers.length; i++) {
  8292. const specifier = node.specifiers[i];
  8293. const local = specifier.local.name;
  8294. let imported = specifier.type === 'ImportSpecifier' &&
  8295. specifier.imported.type === 'Identifier' &&
  8296. specifier.imported.name;
  8297. if (specifier.type === 'ImportNamespaceSpecifier') {
  8298. imported = '*';
  8299. }
  8300. const source = node.source.value;
  8301. const existing = userImports[local];
  8302. if (source === 'vue' &&
  8303. (imported === DEFINE_PROPS ||
  8304. imported === DEFINE_EMITS ||
  8305. imported === DEFINE_EXPOSE)) {
  8306. warnOnce(`\`${imported}\` is a compiler macro and no longer needs to be imported.`);
  8307. removeSpecifier(i);
  8308. }
  8309. else if (existing) {
  8310. if (existing.source === source && existing.imported === imported) {
  8311. // already imported in <script setup>, dedupe
  8312. removeSpecifier(i);
  8313. }
  8314. else {
  8315. error(`different imports aliased to same local name.`, specifier);
  8316. }
  8317. }
  8318. else {
  8319. registerUserImport(source, local, imported, node.importKind === 'type' ||
  8320. (specifier.type === 'ImportSpecifier' &&
  8321. specifier.importKind === 'type'), true);
  8322. }
  8323. }
  8324. if (node.specifiers.length && removed === node.specifiers.length) {
  8325. s.remove(node.start + startOffset, node.end + startOffset);
  8326. }
  8327. }
  8328. if (node.type === 'ExpressionStatement') {
  8329. // process `defineProps` and `defineEmit(s)` calls
  8330. if (processDefineProps(node.expression) ||
  8331. processDefineEmits(node.expression) ||
  8332. processWithDefaults(node.expression)) {
  8333. s.remove(node.start + startOffset, node.end + startOffset);
  8334. }
  8335. else if (processDefineExpose(node.expression)) {
  8336. // defineExpose({}) -> expose({})
  8337. const callee = node.expression.callee;
  8338. s.overwrite(callee.start + startOffset, callee.end + startOffset, 'expose');
  8339. }
  8340. }
  8341. if (node.type === 'VariableDeclaration' && !node.declare) {
  8342. const total = node.declarations.length;
  8343. let left = total;
  8344. for (let i = 0; i < total; i++) {
  8345. const decl = node.declarations[i];
  8346. if (decl.init) {
  8347. // defineProps / defineEmits
  8348. const isDefineProps = processDefineProps(decl.init, decl.id) ||
  8349. processWithDefaults(decl.init, decl.id);
  8350. const isDefineEmits = processDefineEmits(decl.init, decl.id);
  8351. if (isDefineProps || isDefineEmits) {
  8352. if (left === 1) {
  8353. s.remove(node.start + startOffset, node.end + startOffset);
  8354. }
  8355. else {
  8356. let start = decl.start + startOffset;
  8357. let end = decl.end + startOffset;
  8358. if (i === 0) {
  8359. // first one, locate the start of the next
  8360. end = node.declarations[i + 1].start + startOffset;
  8361. }
  8362. else {
  8363. // not first one, locate the end of the prev
  8364. start = node.declarations[i - 1].end + startOffset;
  8365. }
  8366. s.remove(start, end);
  8367. left--;
  8368. }
  8369. }
  8370. }
  8371. }
  8372. }
  8373. // walk declarations to record declared bindings
  8374. if ((node.type === 'VariableDeclaration' ||
  8375. node.type === 'FunctionDeclaration' ||
  8376. node.type === 'ClassDeclaration') &&
  8377. !node.declare) {
  8378. walkDeclaration(node, setupBindings, userImportAlias);
  8379. }
  8380. // walk statements & named exports / variable declarations for top level
  8381. // await
  8382. if ((node.type === 'VariableDeclaration' && !node.declare) ||
  8383. node.type.endsWith('Statement')) {
  8384. const scope = [scriptSetupAst.body];
  8385. walk$1(node, {
  8386. enter(child, parent) {
  8387. if (isFunctionType(child)) {
  8388. this.skip();
  8389. }
  8390. if (child.type === 'BlockStatement') {
  8391. scope.push(child.body);
  8392. }
  8393. if (child.type === 'AwaitExpression') {
  8394. error(`Vue 2 does not support top level await in <script setup>.`, child);
  8395. }
  8396. },
  8397. exit(node) {
  8398. if (node.type === 'BlockStatement')
  8399. scope.pop();
  8400. }
  8401. });
  8402. }
  8403. if ((node.type === 'ExportNamedDeclaration' && node.exportKind !== 'type') ||
  8404. node.type === 'ExportAllDeclaration' ||
  8405. node.type === 'ExportDefaultDeclaration') {
  8406. error(`<script setup> cannot contain ES module exports. ` +
  8407. `If you are using a previous version of <script setup>, please ` +
  8408. `consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`, node);
  8409. }
  8410. if (isTS) {
  8411. // runtime enum
  8412. if (node.type === 'TSEnumDeclaration') {
  8413. registerBinding(setupBindings, node.id, "setup-const" /* BindingTypes.SETUP_CONST */);
  8414. }
  8415. // move all Type declarations to outer scope
  8416. if (node.type.startsWith('TS') ||
  8417. (node.type === 'ExportNamedDeclaration' &&
  8418. node.exportKind === 'type') ||
  8419. (node.type === 'VariableDeclaration' && node.declare)) {
  8420. recordType(node, declaredTypes);
  8421. s.move(start, end, 0);
  8422. }
  8423. }
  8424. }
  8425. // 3. Apply reactivity transform
  8426. // if (
  8427. // (enableReactivityTransform &&
  8428. // // normal <script> had ref bindings that maybe used in <script setup>
  8429. // (refBindings || shouldTransform(scriptSetup.content))) ||
  8430. // propsDestructureDecl
  8431. // ) {
  8432. // const { rootRefs, importedHelpers } = transformAST(
  8433. // scriptSetupAst,
  8434. // s,
  8435. // startOffset,
  8436. // refBindings,
  8437. // propsDestructuredBindings
  8438. // )
  8439. // refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs
  8440. // for (const h of importedHelpers) {
  8441. // helperImports.add(h)
  8442. // }
  8443. // }
  8444. // 4. extract runtime props/emits code from setup context type
  8445. if (propsTypeDecl) {
  8446. extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes);
  8447. }
  8448. if (emitsTypeDecl) {
  8449. extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits);
  8450. }
  8451. // 5. check useOptions args to make sure it doesn't reference setup scope
  8452. // variables
  8453. checkInvalidScopeReference(propsRuntimeDecl, DEFINE_PROPS);
  8454. checkInvalidScopeReference(propsRuntimeDefaults, DEFINE_PROPS);
  8455. checkInvalidScopeReference(propsDestructureDecl, DEFINE_PROPS);
  8456. checkInvalidScopeReference(emitsRuntimeDecl, DEFINE_EMITS);
  8457. // 6. remove non-script content
  8458. if (script) {
  8459. if (startOffset < scriptStartOffset) {
  8460. // <script setup> before <script>
  8461. s.remove(0, startOffset);
  8462. s.remove(endOffset, scriptStartOffset);
  8463. s.remove(scriptEndOffset, source.length);
  8464. }
  8465. else {
  8466. // <script> before <script setup>
  8467. s.remove(0, scriptStartOffset);
  8468. s.remove(scriptEndOffset, startOffset);
  8469. s.remove(endOffset, source.length);
  8470. }
  8471. }
  8472. else {
  8473. // only <script setup>
  8474. s.remove(0, startOffset);
  8475. s.remove(endOffset, source.length);
  8476. }
  8477. // 7. analyze binding metadata
  8478. if (scriptAst) {
  8479. Object.assign(bindingMetadata, analyzeScriptBindings(scriptAst.body));
  8480. }
  8481. if (propsRuntimeDecl) {
  8482. for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
  8483. bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
  8484. }
  8485. }
  8486. for (const key in typeDeclaredProps) {
  8487. bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
  8488. }
  8489. // props aliases
  8490. // if (propsDestructureDecl) {
  8491. // if (propsDestructureRestId) {
  8492. // bindingMetadata[propsDestructureRestId] =
  8493. // BindingTypes.SETUP_REACTIVE_CONST
  8494. // }
  8495. // for (const key in propsDestructuredBindings) {
  8496. // const { local } = propsDestructuredBindings[key]
  8497. // if (local !== key) {
  8498. // bindingMetadata[local] = BindingTypes.PROPS_ALIASED
  8499. // ;(bindingMetadata.__propsAliases ||
  8500. // (bindingMetadata.__propsAliases = {}))[local] = key
  8501. // }
  8502. // }
  8503. // }
  8504. for (const [key, { isType, imported, source }] of Object.entries(userImports)) {
  8505. if (isType)
  8506. continue;
  8507. bindingMetadata[key] =
  8508. imported === '*' ||
  8509. (imported === 'default' && source.endsWith('.vue')) ||
  8510. source === 'vue'
  8511. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8512. : "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
  8513. }
  8514. for (const key in scriptBindings) {
  8515. bindingMetadata[key] = scriptBindings[key];
  8516. }
  8517. for (const key in setupBindings) {
  8518. bindingMetadata[key] = setupBindings[key];
  8519. }
  8520. // 8. inject `useCssVars` calls
  8521. if (cssVars.length) {
  8522. helperImports.add(CSS_VARS_HELPER);
  8523. s.prependRight(startOffset, `\n${genCssVarsCode(cssVars, bindingMetadata, scopeId, isProd)}\n`);
  8524. }
  8525. // 9. finalize setup() argument signature
  8526. let args = `__props`;
  8527. if (propsTypeDecl) {
  8528. // mark as any and only cast on assignment
  8529. // since the user defined complex types may be incompatible with the
  8530. // inferred type from generated runtime declarations
  8531. args += `: any`;
  8532. }
  8533. // inject user assignment of props
  8534. // we use a default __props so that template expressions referencing props
  8535. // can use it directly
  8536. if (propsIdentifier) {
  8537. s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``};\n`);
  8538. }
  8539. const destructureElements = hasDefineExposeCall ? [`expose`] : [];
  8540. if (emitIdentifier) {
  8541. destructureElements.push(emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}`);
  8542. }
  8543. if (destructureElements.length) {
  8544. args += `, { ${destructureElements.join(', ')} }`;
  8545. if (emitsTypeDecl) {
  8546. args += `: { emit: (${scriptSetup.content.slice(emitsTypeDecl.start, emitsTypeDecl.end)}), expose: any, slots: any, attrs: any }`;
  8547. }
  8548. }
  8549. // 10. generate return statement
  8550. const allBindings = Object.assign(Object.assign({}, scriptBindings), setupBindings);
  8551. for (const key in userImports) {
  8552. if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
  8553. allBindings[key] = true;
  8554. }
  8555. }
  8556. // __sfc marker indicates these bindings are compiled from <script setup>
  8557. // and should not be proxied on `this`
  8558. const returned = `{ ${`__sfc: true,`}${Object.keys(allBindings).join(', ')} }`;
  8559. s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`);
  8560. // 11. finalize default export
  8561. let runtimeOptions = ``;
  8562. if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  8563. const match = filename.match(/([^/\\]+)\.\w+$/);
  8564. if (match) {
  8565. runtimeOptions += `\n __name: '${match[1]}',`;
  8566. }
  8567. }
  8568. if (propsRuntimeDecl) {
  8569. let declCode = scriptSetup.content
  8570. .slice(propsRuntimeDecl.start, propsRuntimeDecl.end)
  8571. .trim();
  8572. runtimeOptions += `\n props: ${declCode},`;
  8573. }
  8574. else if (propsTypeDecl) {
  8575. runtimeOptions += genRuntimeProps(typeDeclaredProps);
  8576. }
  8577. if (emitsRuntimeDecl) {
  8578. runtimeOptions += `\n emits: ${scriptSetup.content
  8579. .slice(emitsRuntimeDecl.start, emitsRuntimeDecl.end)
  8580. .trim()},`;
  8581. }
  8582. else if (emitsTypeDecl) {
  8583. runtimeOptions += genRuntimeEmits(typeDeclaredEmits);
  8584. }
  8585. // wrap setup code with function.
  8586. if (isTS) {
  8587. // for TS, make sure the exported type is still valid type with
  8588. // correct props information
  8589. // we have to use object spread for types to be merged properly
  8590. // user's TS setting should compile it down to proper targets
  8591. // export default defineComponent({ ...__default__, ... })
  8592. const def = defaultExport ? `\n ...${DEFAULT_VAR},` : ``;
  8593. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup(${args}) {\n`);
  8594. s.appendRight(endOffset, `})`);
  8595. }
  8596. else {
  8597. if (defaultExport) {
  8598. // without TS, can't rely on rest spread, so we use Object.assign
  8599. // export default Object.assign(__default__, { ... })
  8600. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/Object.assign(${DEFAULT_VAR}, {${runtimeOptions}\n ` +
  8601. `setup(${args}) {\n`);
  8602. s.appendRight(endOffset, `})`);
  8603. }
  8604. else {
  8605. s.prependLeft(startOffset, `\nexport default {${runtimeOptions}\n setup(${args}) {\n`);
  8606. s.appendRight(endOffset, `}`);
  8607. }
  8608. }
  8609. // 12. finalize Vue helper imports
  8610. if (helperImports.size > 0) {
  8611. s.prepend(`import { ${[...helperImports]
  8612. .map(h => `${h} as _${h}`)
  8613. .join(', ')} } from 'vue'\n`);
  8614. }
  8615. s.trim();
  8616. return Object.assign(Object.assign({}, scriptSetup), { bindings: bindingMetadata, imports: userImports, content: s.toString(), map: genSourceMap
  8617. ? s.generateMap({
  8618. source: filename,
  8619. hires: true,
  8620. includeContent: true
  8621. })
  8622. : undefined, scriptAst: scriptAst === null || scriptAst === void 0 ? void 0 : scriptAst.body, scriptSetupAst: scriptSetupAst === null || scriptSetupAst === void 0 ? void 0 : scriptSetupAst.body });
  8623. }
  8624. function registerBinding(bindings, node, type) {
  8625. bindings[node.name] = type;
  8626. }
  8627. function walkDeclaration(node, bindings, userImportAlias) {
  8628. if (node.type === 'VariableDeclaration') {
  8629. const isConst = node.kind === 'const';
  8630. // export const foo = ...
  8631. for (const { id, init } of node.declarations) {
  8632. const isDefineCall = !!(isConst &&
  8633. isCallOf(init, c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS));
  8634. if (id.type === 'Identifier') {
  8635. let bindingType;
  8636. const userReactiveBinding = userImportAlias['reactive'] || 'reactive';
  8637. if (isCallOf(init, userReactiveBinding)) {
  8638. // treat reactive() calls as let since it's meant to be mutable
  8639. bindingType = isConst
  8640. ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
  8641. : "setup-let" /* BindingTypes.SETUP_LET */;
  8642. }
  8643. else if (
  8644. // if a declaration is a const literal, we can mark it so that
  8645. // the generated render fn code doesn't need to unref() it
  8646. isDefineCall ||
  8647. (isConst && canNeverBeRef(init, userReactiveBinding))) {
  8648. bindingType = isCallOf(init, DEFINE_PROPS)
  8649. ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
  8650. : "setup-const" /* BindingTypes.SETUP_CONST */;
  8651. }
  8652. else if (isConst) {
  8653. if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
  8654. bindingType = "setup-ref" /* BindingTypes.SETUP_REF */;
  8655. }
  8656. else {
  8657. bindingType = "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
  8658. }
  8659. }
  8660. else {
  8661. bindingType = "setup-let" /* BindingTypes.SETUP_LET */;
  8662. }
  8663. registerBinding(bindings, id, bindingType);
  8664. }
  8665. else {
  8666. if (isCallOf(init, DEFINE_PROPS)) {
  8667. // skip walking props destructure
  8668. return;
  8669. }
  8670. if (id.type === 'ObjectPattern') {
  8671. walkObjectPattern(id, bindings, isConst, isDefineCall);
  8672. }
  8673. else if (id.type === 'ArrayPattern') {
  8674. walkArrayPattern(id, bindings, isConst, isDefineCall);
  8675. }
  8676. }
  8677. }
  8678. }
  8679. else if (node.type === 'TSEnumDeclaration' ||
  8680. node.type === 'FunctionDeclaration' ||
  8681. node.type === 'ClassDeclaration') {
  8682. // export function foo() {} / export class Foo {}
  8683. // export declarations must be named.
  8684. bindings[node.id.name] = "setup-const" /* BindingTypes.SETUP_CONST */;
  8685. }
  8686. }
  8687. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  8688. for (const p of node.properties) {
  8689. if (p.type === 'ObjectProperty') {
  8690. if (p.key.type === 'Identifier' && p.key === p.value) {
  8691. // shorthand: const { x } = ...
  8692. const type = isDefineCall
  8693. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8694. : isConst
  8695. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8696. : "setup-let" /* BindingTypes.SETUP_LET */;
  8697. registerBinding(bindings, p.key, type);
  8698. }
  8699. else {
  8700. walkPattern(p.value, bindings, isConst, isDefineCall);
  8701. }
  8702. }
  8703. else {
  8704. // ...rest
  8705. // argument can only be identifier when destructuring
  8706. const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
  8707. registerBinding(bindings, p.argument, type);
  8708. }
  8709. }
  8710. }
  8711. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  8712. for (const e of node.elements) {
  8713. e && walkPattern(e, bindings, isConst, isDefineCall);
  8714. }
  8715. }
  8716. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  8717. if (node.type === 'Identifier') {
  8718. const type = isDefineCall
  8719. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8720. : isConst
  8721. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8722. : "setup-let" /* BindingTypes.SETUP_LET */;
  8723. registerBinding(bindings, node, type);
  8724. }
  8725. else if (node.type === 'RestElement') {
  8726. // argument can only be identifier when destructuring
  8727. const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
  8728. registerBinding(bindings, node.argument, type);
  8729. }
  8730. else if (node.type === 'ObjectPattern') {
  8731. walkObjectPattern(node, bindings, isConst);
  8732. }
  8733. else if (node.type === 'ArrayPattern') {
  8734. walkArrayPattern(node, bindings, isConst);
  8735. }
  8736. else if (node.type === 'AssignmentPattern') {
  8737. if (node.left.type === 'Identifier') {
  8738. const type = isDefineCall
  8739. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8740. : isConst
  8741. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8742. : "setup-let" /* BindingTypes.SETUP_LET */;
  8743. registerBinding(bindings, node.left, type);
  8744. }
  8745. else {
  8746. walkPattern(node.left, bindings, isConst);
  8747. }
  8748. }
  8749. }
  8750. function recordType(node, declaredTypes) {
  8751. if (node.type === 'TSInterfaceDeclaration') {
  8752. declaredTypes[node.id.name] = [`Object`];
  8753. }
  8754. else if (node.type === 'TSTypeAliasDeclaration') {
  8755. declaredTypes[node.id.name] = inferRuntimeType(node.typeAnnotation, declaredTypes);
  8756. }
  8757. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  8758. recordType(node.declaration, declaredTypes);
  8759. }
  8760. }
  8761. function extractRuntimeProps(node, props, declaredTypes, isProd) {
  8762. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8763. for (const m of members) {
  8764. if ((m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
  8765. m.key.type === 'Identifier') {
  8766. let type;
  8767. if (m.type === 'TSMethodSignature') {
  8768. type = ['Function'];
  8769. }
  8770. else if (m.typeAnnotation) {
  8771. type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
  8772. }
  8773. props[m.key.name] = {
  8774. key: m.key.name,
  8775. required: !m.optional,
  8776. type: type || [`null`]
  8777. };
  8778. }
  8779. }
  8780. }
  8781. function inferRuntimeType(node, declaredTypes) {
  8782. switch (node.type) {
  8783. case 'TSStringKeyword':
  8784. return ['String'];
  8785. case 'TSNumberKeyword':
  8786. return ['Number'];
  8787. case 'TSBooleanKeyword':
  8788. return ['Boolean'];
  8789. case 'TSObjectKeyword':
  8790. return ['Object'];
  8791. case 'TSTypeLiteral':
  8792. // TODO (nice to have) generate runtime property validation
  8793. return ['Object'];
  8794. case 'TSFunctionType':
  8795. return ['Function'];
  8796. case 'TSArrayType':
  8797. case 'TSTupleType':
  8798. // TODO (nice to have) generate runtime element type/length checks
  8799. return ['Array'];
  8800. case 'TSLiteralType':
  8801. switch (node.literal.type) {
  8802. case 'StringLiteral':
  8803. return ['String'];
  8804. case 'BooleanLiteral':
  8805. return ['Boolean'];
  8806. case 'NumericLiteral':
  8807. case 'BigIntLiteral':
  8808. return ['Number'];
  8809. default:
  8810. return [`null`];
  8811. }
  8812. case 'TSTypeReference':
  8813. if (node.typeName.type === 'Identifier') {
  8814. if (declaredTypes[node.typeName.name]) {
  8815. return declaredTypes[node.typeName.name];
  8816. }
  8817. switch (node.typeName.name) {
  8818. case 'Array':
  8819. case 'Function':
  8820. case 'Object':
  8821. case 'Set':
  8822. case 'Map':
  8823. case 'WeakSet':
  8824. case 'WeakMap':
  8825. case 'Date':
  8826. case 'Promise':
  8827. return [node.typeName.name];
  8828. case 'Record':
  8829. case 'Partial':
  8830. case 'Readonly':
  8831. case 'Pick':
  8832. case 'Omit':
  8833. case 'Exclude':
  8834. case 'Extract':
  8835. case 'Required':
  8836. case 'InstanceType':
  8837. return ['Object'];
  8838. }
  8839. }
  8840. return [`null`];
  8841. case 'TSParenthesizedType':
  8842. return inferRuntimeType(node.typeAnnotation, declaredTypes);
  8843. case 'TSUnionType':
  8844. return [
  8845. ...new Set([].concat(...node.types.map(t => inferRuntimeType(t, declaredTypes))))
  8846. ];
  8847. case 'TSIntersectionType':
  8848. return ['Object'];
  8849. case 'TSSymbolKeyword':
  8850. return ['Symbol'];
  8851. default:
  8852. return [`null`]; // no runtime check
  8853. }
  8854. }
  8855. function toRuntimeTypeString(types) {
  8856. return types.length > 1 ? `[${types.join(', ')}]` : types[0];
  8857. }
  8858. function extractRuntimeEmits(node, emits) {
  8859. if (node.type === 'TSTypeLiteral' || node.type === 'TSInterfaceBody') {
  8860. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8861. for (let t of members) {
  8862. if (t.type === 'TSCallSignatureDeclaration') {
  8863. extractEventNames(t.parameters[0], emits);
  8864. }
  8865. }
  8866. return;
  8867. }
  8868. else {
  8869. extractEventNames(node.parameters[0], emits);
  8870. }
  8871. }
  8872. function extractEventNames(eventName, emits) {
  8873. if (eventName.type === 'Identifier' &&
  8874. eventName.typeAnnotation &&
  8875. eventName.typeAnnotation.type === 'TSTypeAnnotation') {
  8876. const typeNode = eventName.typeAnnotation.typeAnnotation;
  8877. if (typeNode.type === 'TSLiteralType') {
  8878. if (typeNode.literal.type !== 'UnaryExpression' &&
  8879. typeNode.literal.type !== 'TemplateLiteral') {
  8880. emits.add(String(typeNode.literal.value));
  8881. }
  8882. }
  8883. else if (typeNode.type === 'TSUnionType') {
  8884. for (const t of typeNode.types) {
  8885. if (t.type === 'TSLiteralType' &&
  8886. t.literal.type !== 'UnaryExpression' &&
  8887. t.literal.type !== 'TemplateLiteral') {
  8888. emits.add(String(t.literal.value));
  8889. }
  8890. }
  8891. }
  8892. }
  8893. }
  8894. function genRuntimeEmits(emits) {
  8895. return emits.size
  8896. ? `\n emits: [${Array.from(emits)
  8897. .map(p => JSON.stringify(p))
  8898. .join(', ')}],`
  8899. : ``;
  8900. }
  8901. function isCallOf(node, test) {
  8902. return !!(node &&
  8903. node.type === 'CallExpression' &&
  8904. node.callee.type === 'Identifier' &&
  8905. (typeof test === 'string'
  8906. ? node.callee.name === test
  8907. : test(node.callee.name)));
  8908. }
  8909. function canNeverBeRef(node, userReactiveImport) {
  8910. if (isCallOf(node, userReactiveImport)) {
  8911. return true;
  8912. }
  8913. switch (node.type) {
  8914. case 'UnaryExpression':
  8915. case 'BinaryExpression':
  8916. case 'ArrayExpression':
  8917. case 'ObjectExpression':
  8918. case 'FunctionExpression':
  8919. case 'ArrowFunctionExpression':
  8920. case 'UpdateExpression':
  8921. case 'ClassExpression':
  8922. case 'TaggedTemplateExpression':
  8923. return true;
  8924. case 'SequenceExpression':
  8925. return canNeverBeRef(node.expressions[node.expressions.length - 1], userReactiveImport);
  8926. default:
  8927. if (node.type.endsWith('Literal')) {
  8928. return true;
  8929. }
  8930. return false;
  8931. }
  8932. }
  8933. /**
  8934. * Analyze bindings in normal `<script>`
  8935. * Note that `compileScriptSetup` already analyzes bindings as part of its
  8936. * compilation process so this should only be used on single `<script>` SFCs.
  8937. */
  8938. function analyzeScriptBindings(ast) {
  8939. for (const node of ast) {
  8940. if (node.type === 'ExportDefaultDeclaration' &&
  8941. node.declaration.type === 'ObjectExpression') {
  8942. return analyzeBindingsFromOptions(node.declaration);
  8943. }
  8944. }
  8945. return {};
  8946. }
  8947. function analyzeBindingsFromOptions(node) {
  8948. const bindings = {};
  8949. // #3270, #3275
  8950. // mark non-script-setup so we don't resolve components/directives from these
  8951. Object.defineProperty(bindings, '__isScriptSetup', {
  8952. enumerable: false,
  8953. value: false
  8954. });
  8955. for (const property of node.properties) {
  8956. if (property.type === 'ObjectProperty' &&
  8957. !property.computed &&
  8958. property.key.type === 'Identifier') {
  8959. // props
  8960. if (property.key.name === 'props') {
  8961. // props: ['foo']
  8962. // props: { foo: ... }
  8963. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  8964. bindings[key] = "props" /* BindingTypes.PROPS */;
  8965. }
  8966. }
  8967. // inject
  8968. else if (property.key.name === 'inject') {
  8969. // inject: ['foo']
  8970. // inject: { foo: {} }
  8971. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  8972. bindings[key] = "options" /* BindingTypes.OPTIONS */;
  8973. }
  8974. }
  8975. // computed & methods
  8976. else if (property.value.type === 'ObjectExpression' &&
  8977. (property.key.name === 'computed' || property.key.name === 'methods')) {
  8978. // methods: { foo() {} }
  8979. // computed: { foo() {} }
  8980. for (const key of getObjectExpressionKeys(property.value)) {
  8981. bindings[key] = "options" /* BindingTypes.OPTIONS */;
  8982. }
  8983. }
  8984. }
  8985. // setup & data
  8986. else if (property.type === 'ObjectMethod' &&
  8987. property.key.type === 'Identifier' &&
  8988. (property.key.name === 'setup' || property.key.name === 'data')) {
  8989. for (const bodyItem of property.body.body) {
  8990. // setup() {
  8991. // return {
  8992. // foo: null
  8993. // }
  8994. // }
  8995. if (bodyItem.type === 'ReturnStatement' &&
  8996. bodyItem.argument &&
  8997. bodyItem.argument.type === 'ObjectExpression') {
  8998. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  8999. bindings[key] =
  9000. property.key.name === 'setup'
  9001. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  9002. : "data" /* BindingTypes.DATA */;
  9003. }
  9004. }
  9005. }
  9006. }
  9007. }
  9008. return bindings;
  9009. }
  9010. function getObjectExpressionKeys(node) {
  9011. const keys = [];
  9012. for (const prop of node.properties) {
  9013. if ((prop.type === 'ObjectProperty' || prop.type === 'ObjectMethod') &&
  9014. !prop.computed) {
  9015. if (prop.key.type === 'Identifier') {
  9016. keys.push(prop.key.name);
  9017. }
  9018. else if (prop.key.type === 'StringLiteral') {
  9019. keys.push(prop.key.value);
  9020. }
  9021. }
  9022. }
  9023. return keys;
  9024. }
  9025. function getArrayExpressionKeys(node) {
  9026. const keys = [];
  9027. for (const element of node.elements) {
  9028. if (element && element.type === 'StringLiteral') {
  9029. keys.push(element.value);
  9030. }
  9031. }
  9032. return keys;
  9033. }
  9034. function getObjectOrArrayExpressionKeys(value) {
  9035. if (value.type === 'ArrayExpression') {
  9036. return getArrayExpressionKeys(value);
  9037. }
  9038. if (value.type === 'ObjectExpression') {
  9039. return getObjectExpressionKeys(value);
  9040. }
  9041. return [];
  9042. }
  9043. const templateUsageCheckCache = new lruCache(512);
  9044. function resolveTemplateUsageCheckString(sfc, isTS) {
  9045. const { content } = sfc.template;
  9046. const cached = templateUsageCheckCache.get(content);
  9047. if (cached) {
  9048. return cached;
  9049. }
  9050. let code = '';
  9051. parseHTML(content, Object.assign(Object.assign({}, baseOptions), { start(tag, attrs) {
  9052. if (!isBuiltInTag(tag) && !isReservedTag(tag)) {
  9053. code += `,${camelize(tag)},${capitalize(camelize(tag))}`;
  9054. }
  9055. for (let i = 0; i < attrs.length; i++) {
  9056. const { name, value } = attrs[i];
  9057. if (dirRE.test(name)) {
  9058. const baseName = onRE.test(name)
  9059. ? 'on'
  9060. : slotRE.test(name)
  9061. ? 'slot'
  9062. : bindRE.test(name)
  9063. ? 'bind'
  9064. : name.replace(dirRE, '');
  9065. if (!isBuiltInDir$1(baseName)) {
  9066. code += `,v${capitalize(camelize(baseName))}`;
  9067. }
  9068. if (value) {
  9069. code += `,${processExp(value, isTS, baseName)}`;
  9070. }
  9071. }
  9072. else if (name === 'ref') {
  9073. code += `,${value}`;
  9074. }
  9075. }
  9076. },
  9077. chars(text) {
  9078. const res = parseText(text);
  9079. if (res) {
  9080. code += `,${processExp(res.expression, isTS)}`;
  9081. }
  9082. } }));
  9083. code += ';';
  9084. templateUsageCheckCache.set(content, code);
  9085. return code;
  9086. }
  9087. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9088. function processExp(exp, isTS, dir) {
  9089. if (isTS && / as\s+\w|<.*>|:/.test(exp)) {
  9090. if (dir === 'slot') {
  9091. exp = `(${exp})=>{}`;
  9092. }
  9093. else if (dir === 'on') {
  9094. exp = `()=>{return ${exp}}`;
  9095. }
  9096. else if (dir === 'for') {
  9097. const inMatch = exp.match(forAliasRE);
  9098. if (inMatch) {
  9099. const [, LHS, RHS] = inMatch;
  9100. return processExp(`(${LHS})=>{}`, true) + processExp(RHS, true);
  9101. }
  9102. }
  9103. let ret = '';
  9104. // has potential type cast or generic arguments that uses types
  9105. const ast = parser$1.parseExpression(exp, { plugins: ['typescript'] });
  9106. walkIdentifiers(ast, node => {
  9107. ret += `,` + node.name;
  9108. });
  9109. return ret;
  9110. }
  9111. return stripStrings(exp);
  9112. }
  9113. function stripStrings(exp) {
  9114. return exp
  9115. .replace(/'[^']*'|"[^"]*"/g, '')
  9116. .replace(/`[^`]+`/g, stripTemplateString);
  9117. }
  9118. function stripTemplateString(str) {
  9119. const interpMatch = str.match(/\${[^}]+}/g);
  9120. if (interpMatch) {
  9121. return interpMatch.map(m => m.slice(2, -1)).join(',');
  9122. }
  9123. return '';
  9124. }
  9125. function isImportUsed(local, sfc, isTS) {
  9126. return new RegExp(
  9127. // #4274 escape $ since it's a special char in regex
  9128. // (and is the only regex special char that is valid in identifiers)
  9129. `[^\\w$_]${local.replace(/\$/g, '\\$')}[^\\w$_]`).test(resolveTemplateUsageCheckString(sfc, isTS));
  9130. }
  9131. /**
  9132. * Note: this comparison assumes the prev/next script are already identical,
  9133. * and only checks the special case where <script setup> unused import
  9134. * pruning result changes due to template changes.
  9135. */
  9136. function hmrShouldReload(prevImports, next) {
  9137. if (!next.scriptSetup) {
  9138. return false;
  9139. }
  9140. const isTS = next.scriptSetup.lang === 'ts' || next.scriptSetup.lang === 'tsx';
  9141. // for each previous import, check if its used status remain the same based on
  9142. // the next descriptor's template
  9143. for (const key in prevImports) {
  9144. // if an import was previous unused, but now is used, we need to force
  9145. // reload so that the script now includes that import.
  9146. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next, isTS)) {
  9147. return true;
  9148. }
  9149. }
  9150. return false;
  9151. }
  9152. const cache = new lruCache(100);
  9153. const splitRE = /\r?\n/g;
  9154. const emptyRE = /^(?:\/\/)?\s*$/;
  9155. function parse(options) {
  9156. const { source, filename = DEFAULT_FILENAME, compiler, compilerParseOptions = { pad: false }, sourceRoot = '', needMap = true, sourceMap = needMap } = options;
  9157. const cacheKey = hashSum(filename + source + JSON.stringify(compilerParseOptions));
  9158. let output = cache.get(cacheKey);
  9159. if (output) {
  9160. return output;
  9161. }
  9162. if (compiler) {
  9163. // user-provided compiler
  9164. output = compiler.parseComponent(source, compilerParseOptions);
  9165. }
  9166. else {
  9167. // use built-in compiler
  9168. output = parseComponent(source, compilerParseOptions);
  9169. }
  9170. output.filename = filename;
  9171. // parse CSS vars
  9172. output.cssVars = parseCssVars(output);
  9173. output.shouldForceReload = prevImports => hmrShouldReload(prevImports, output);
  9174. if (sourceMap) {
  9175. if (output.script && !output.script.src) {
  9176. output.script.map = generateSourceMap(filename, source, output.script.content, sourceRoot, compilerParseOptions.pad);
  9177. }
  9178. if (output.styles) {
  9179. output.styles.forEach(style => {
  9180. if (!style.src) {
  9181. style.map = generateSourceMap(filename, source, style.content, sourceRoot, compilerParseOptions.pad);
  9182. }
  9183. });
  9184. }
  9185. }
  9186. cache.set(cacheKey, output);
  9187. return output;
  9188. }
  9189. function generateSourceMap(filename, source, generated, sourceRoot, pad) {
  9190. const map = new require$$0.SourceMapGenerator({
  9191. file: filename.replace(/\\/g, '/'),
  9192. sourceRoot: sourceRoot.replace(/\\/g, '/')
  9193. });
  9194. let offset = 0;
  9195. if (!pad) {
  9196. offset = source.split(generated).shift().split(splitRE).length - 1;
  9197. }
  9198. map.setSourceContent(filename, source);
  9199. generated.split(splitRE).forEach((line, index) => {
  9200. if (!emptyRE.test(line)) {
  9201. map.addMapping({
  9202. source: filename,
  9203. original: {
  9204. line: index + 1 + offset,
  9205. column: 0
  9206. },
  9207. generated: {
  9208. line: index + 1,
  9209. column: 0
  9210. }
  9211. });
  9212. }
  9213. });
  9214. return JSON.parse(map.toString());
  9215. }
  9216. function urlToRequire(url, transformAssetUrlsOption = {}) {
  9217. const returnValue = `"${url}"`;
  9218. // same logic as in transform-require.js
  9219. const firstChar = url.charAt(0);
  9220. if (firstChar === '~') {
  9221. const secondChar = url.charAt(1);
  9222. url = url.slice(secondChar === '/' ? 2 : 1);
  9223. }
  9224. if (isExternalUrl(url) || isDataUrl(url) || firstChar === '#') {
  9225. return returnValue;
  9226. }
  9227. const uriParts = parseUriParts(url);
  9228. if (transformAssetUrlsOption.base) {
  9229. // explicit base - directly rewrite the url into absolute url
  9230. // does not apply to absolute urls or urls that start with `@`
  9231. // since they are aliases
  9232. if (firstChar === '.' || firstChar === '~') {
  9233. // Allow for full hostnames provided in options.base
  9234. const base = parseUriParts(transformAssetUrlsOption.base);
  9235. const protocol = base.protocol || '';
  9236. const host = base.host ? protocol + '//' + base.host : '';
  9237. const basePath = base.path || '/';
  9238. // when packaged in the browser, path will be using the posix-
  9239. // only version provided by rollup-plugin-node-builtins.
  9240. return `"${host}${(path__default["default"].posix || path__default["default"]).join(basePath, uriParts.path + (uriParts.hash || ''))}"`;
  9241. }
  9242. }
  9243. if (transformAssetUrlsOption.includeAbsolute ||
  9244. firstChar === '.' ||
  9245. firstChar === '~' ||
  9246. firstChar === '@') {
  9247. if (!uriParts.hash) {
  9248. return `require("${url}")`;
  9249. }
  9250. else {
  9251. // support uri fragment case by excluding it from
  9252. // the require and instead appending it as string;
  9253. // assuming that the path part is sufficient according to
  9254. // the above caseing(t.i. no protocol-auth-host parts expected)
  9255. return `require("${uriParts.path}") + "${uriParts.hash}"`;
  9256. }
  9257. }
  9258. return returnValue;
  9259. }
  9260. /**
  9261. * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
  9262. * @param urlString an url as a string
  9263. */
  9264. function parseUriParts(urlString) {
  9265. // initialize return value
  9266. const returnValue = url.parse('');
  9267. if (urlString) {
  9268. // A TypeError is thrown if urlString is not a string
  9269. // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
  9270. if ('string' === typeof urlString) {
  9271. // check is an uri
  9272. return url.parse(urlString, false, true); // take apart the uri
  9273. }
  9274. }
  9275. return returnValue;
  9276. }
  9277. const externalRE = /^(https?:)?\/\//;
  9278. function isExternalUrl(url) {
  9279. return externalRE.test(url);
  9280. }
  9281. const dataUrlRE = /^\s*data:/i;
  9282. function isDataUrl(url) {
  9283. return dataUrlRE.test(url);
  9284. }
  9285. // vue compiler module for transforming `<tag>:<attribute>` to `require`
  9286. const defaultOptions = {
  9287. audio: 'src',
  9288. video: ['src', 'poster'],
  9289. source: 'src',
  9290. img: 'src',
  9291. image: ['xlink:href', 'href'],
  9292. use: ['xlink:href', 'href']
  9293. };
  9294. var assetUrlsModule = (userOptions, transformAssetUrlsOption) => {
  9295. const options = userOptions
  9296. ? Object.assign({}, defaultOptions, userOptions)
  9297. : defaultOptions;
  9298. return {
  9299. postTransformNode: (node) => {
  9300. transform$1(node, options, transformAssetUrlsOption);
  9301. }
  9302. };
  9303. };
  9304. function transform$1(node, options, transformAssetUrlsOption) {
  9305. if (node.type !== 1 || !node.attrs)
  9306. return;
  9307. for (const tag in options) {
  9308. if (tag === '*' || node.tag === tag) {
  9309. const attributes = options[tag];
  9310. if (typeof attributes === 'string') {
  9311. node.attrs.some(attr => rewrite(attr, attributes, transformAssetUrlsOption));
  9312. }
  9313. else if (Array.isArray(attributes)) {
  9314. attributes.forEach(item => node.attrs.some(attr => rewrite(attr, item, transformAssetUrlsOption)));
  9315. }
  9316. }
  9317. }
  9318. }
  9319. function rewrite(attr, name, transformAssetUrlsOption) {
  9320. if (attr.name === name) {
  9321. const value = attr.value;
  9322. // only transform static URLs
  9323. if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
  9324. attr.value = urlToRequire(value.slice(1, -1), transformAssetUrlsOption);
  9325. return true;
  9326. }
  9327. }
  9328. return false;
  9329. }
  9330. // vue compiler module for transforming `img:srcset` to a number of `require`s
  9331. var srcsetModule = (transformAssetUrlsOptions) => ({
  9332. postTransformNode: (node) => {
  9333. transform(node, transformAssetUrlsOptions);
  9334. }
  9335. });
  9336. // http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
  9337. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  9338. function transform(node, transformAssetUrlsOptions) {
  9339. if (node.type !== 1 || !node.attrs) {
  9340. return;
  9341. }
  9342. if (node.tag === 'img' || node.tag === 'source') {
  9343. node.attrs.forEach(attr => {
  9344. if (attr.name === 'srcset') {
  9345. // same logic as in transform-require.js
  9346. const value = attr.value;
  9347. const isStatic = value.charAt(0) === '"' && value.charAt(value.length - 1) === '"';
  9348. if (!isStatic) {
  9349. return;
  9350. }
  9351. const imageCandidates = value
  9352. .slice(1, -1)
  9353. .split(',')
  9354. .map(s => {
  9355. // The attribute value arrives here with all whitespace, except
  9356. // normal spaces, represented by escape sequences
  9357. const [url, descriptor] = s
  9358. .replace(escapedSpaceCharacters, ' ')
  9359. .trim()
  9360. .split(' ', 2);
  9361. return {
  9362. require: urlToRequire(url, transformAssetUrlsOptions),
  9363. descriptor
  9364. };
  9365. });
  9366. // "require(url1)"
  9367. // "require(url1) 1x"
  9368. // "require(url1), require(url2)"
  9369. // "require(url1), require(url2) 2x"
  9370. // "require(url1) 1x, require(url2)"
  9371. // "require(url1) 1x, require(url2) 2x"
  9372. const code = imageCandidates
  9373. .map(({ require, descriptor }) => `${require} + "${descriptor ? ' ' + descriptor : ''}, " + `)
  9374. .join('')
  9375. .slice(0, -6)
  9376. .concat('"')
  9377. .replace(/ \+ ""$/, '');
  9378. attr.value = code;
  9379. }
  9380. });
  9381. }
  9382. }
  9383. var consolidate$2 = {exports: {}};
  9384. function commonjsRequire(path) {
  9385. throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
  9386. }
  9387. var consolidate$1 = {exports: {}};
  9388. (function (module, exports) {
  9389. /*
  9390. * Engines which do not support caching of their file contents
  9391. * should use the `read()` function defined in consolidate.js
  9392. * On top of this, when an engine compiles to a `Function`,
  9393. * these functions should either be cached within consolidate.js
  9394. * or the engine itself via `options.cache`. This will allow
  9395. * users and frameworks to pass `options.cache = true` for
  9396. * `NODE_ENV=production`, however edit the file(s) without
  9397. * re-loading the application in development.
  9398. */
  9399. /**
  9400. * Module dependencies.
  9401. */
  9402. var fs = require$$0__default["default"];
  9403. var path = path__default["default"];
  9404. var util = require$$2__default["default"];
  9405. var join = path.join;
  9406. var resolve = path.resolve;
  9407. var extname = path.extname;
  9408. var dirname = path.dirname;
  9409. var isAbsolute = path.isAbsolute;
  9410. var readCache = {};
  9411. /**
  9412. * Require cache.
  9413. */
  9414. var cacheStore = {};
  9415. /**
  9416. * Require cache.
  9417. */
  9418. var requires = {};
  9419. /**
  9420. * Clear the cache.
  9421. *
  9422. * @api public
  9423. */
  9424. exports.clearCache = function() {
  9425. readCache = {};
  9426. cacheStore = {};
  9427. };
  9428. /**
  9429. * Conditionally cache `compiled` template based
  9430. * on the `options` filename and `.cache` boolean.
  9431. *
  9432. * @param {Object} options
  9433. * @param {Function} compiled
  9434. * @return {Function}
  9435. * @api private
  9436. */
  9437. function cache(options, compiled) {
  9438. // cachable
  9439. if (compiled && options.filename && options.cache) {
  9440. delete readCache[options.filename];
  9441. cacheStore[options.filename] = compiled;
  9442. return compiled;
  9443. }
  9444. // check cache
  9445. if (options.filename && options.cache) {
  9446. return cacheStore[options.filename];
  9447. }
  9448. return compiled;
  9449. }
  9450. /**
  9451. * Read `path` with `options` with
  9452. * callback `(err, str)`. When `options.cache`
  9453. * is true the template string will be cached.
  9454. *
  9455. * @param {String} options
  9456. * @param {Function} cb
  9457. * @api private
  9458. */
  9459. function read(path, options, cb) {
  9460. var str = readCache[path];
  9461. var cached = options.cache && str && typeof str === 'string';
  9462. // cached (only if cached is a string and not a compiled template function)
  9463. if (cached) return cb(null, str);
  9464. // read
  9465. fs.readFile(path, 'utf8', function(err, str) {
  9466. if (err) return cb(err);
  9467. // remove extraneous utf8 BOM marker
  9468. str = str.replace(/^\uFEFF/, '');
  9469. if (options.cache) readCache[path] = str;
  9470. cb(null, str);
  9471. });
  9472. }
  9473. /**
  9474. * Read `path` with `options` with
  9475. * callback `(err, str)`. When `options.cache`
  9476. * is true the partial string will be cached.
  9477. *
  9478. * @param {String} options
  9479. * @param {Function} fn
  9480. * @api private
  9481. */
  9482. function readPartials(path, options, cb) {
  9483. if (!options.partials) return cb();
  9484. var keys = Object.keys(options.partials);
  9485. var partials = {};
  9486. function next(index) {
  9487. if (index === keys.length) return cb(null, partials);
  9488. var key = keys[index];
  9489. var partialPath = options.partials[key];
  9490. if (partialPath === undefined || partialPath === null || partialPath === false) {
  9491. return next(++index);
  9492. }
  9493. var file;
  9494. if (isAbsolute(partialPath)) {
  9495. if (extname(partialPath) !== '') {
  9496. file = partialPath;
  9497. } else {
  9498. file = join(partialPath + extname(path));
  9499. }
  9500. } else {
  9501. file = join(dirname(path), partialPath + extname(path));
  9502. }
  9503. read(file, options, function(err, str) {
  9504. if (err) return cb(err);
  9505. partials[key] = str;
  9506. next(++index);
  9507. });
  9508. }
  9509. next(0);
  9510. }
  9511. /**
  9512. * promisify
  9513. */
  9514. function promisify(cb, fn) {
  9515. return new Promise(function(resolve, reject) {
  9516. cb = cb || function(err, html) {
  9517. if (err) {
  9518. return reject(err);
  9519. }
  9520. resolve(html);
  9521. };
  9522. fn(cb);
  9523. });
  9524. }
  9525. /**
  9526. * fromStringRenderer
  9527. */
  9528. function fromStringRenderer(name) {
  9529. return function(path, options, cb) {
  9530. options.filename = path;
  9531. return promisify(cb, function(cb) {
  9532. readPartials(path, options, function(err, partials) {
  9533. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  9534. var opts = extend({}, options);
  9535. opts.partials = partials;
  9536. if (err) return cb(err);
  9537. if (cache(opts)) {
  9538. exports[name].render('', opts, cb);
  9539. } else {
  9540. read(path, opts, function(err, str) {
  9541. if (err) return cb(err);
  9542. exports[name].render(str, opts, cb);
  9543. });
  9544. }
  9545. });
  9546. });
  9547. };
  9548. }
  9549. /**
  9550. * velocity support.
  9551. */
  9552. exports.velocityjs = fromStringRenderer('velocityjs');
  9553. /**
  9554. * velocity string support.
  9555. */
  9556. exports.velocityjs.render = function(str, options, cb) {
  9557. return promisify(cb, function(cb) {
  9558. var engine = requires.velocityjs || (requires.velocityjs = require('velocityjs'));
  9559. try {
  9560. options.locals = options;
  9561. cb(null, engine.render(str, options).trimLeft());
  9562. } catch (err) {
  9563. cb(err);
  9564. }
  9565. });
  9566. };
  9567. /**
  9568. * Liquid support.
  9569. */
  9570. exports.liquid = fromStringRenderer('liquid');
  9571. /**
  9572. * Liquid string support.
  9573. */
  9574. /**
  9575. * Note that in order to get filters and custom tags we've had to push
  9576. * all user-defined locals down into @locals. However, just to make things
  9577. * backwards-compatible, any property of `options` that is left after
  9578. * processing and removing `locals`, `meta`, `filters`, `customTags` and
  9579. * `includeDir` will also become a local.
  9580. */
  9581. function _renderTinyliquid(engine, str, options, cb) {
  9582. var context = engine.newContext();
  9583. var k;
  9584. /**
  9585. * Note that there's a bug in the library that doesn't allow us to pass
  9586. * the locals to newContext(), hence looping through the keys:
  9587. */
  9588. if (options.locals) {
  9589. for (k in options.locals) {
  9590. context.setLocals(k, options.locals[k]);
  9591. }
  9592. delete options.locals;
  9593. }
  9594. if (options.meta) {
  9595. context.setLocals('page', options.meta);
  9596. delete options.meta;
  9597. }
  9598. /**
  9599. * Add any defined filters:
  9600. */
  9601. if (options.filters) {
  9602. for (k in options.filters) {
  9603. context.setFilter(k, options.filters[k]);
  9604. }
  9605. delete options.filters;
  9606. }
  9607. /**
  9608. * Set up a callback for the include directory:
  9609. */
  9610. var includeDir = options.includeDir || process.cwd();
  9611. context.onInclude(function(name, callback) {
  9612. var extname = path.extname(name) ? '' : '.liquid';
  9613. var filename = path.resolve(includeDir, name + extname);
  9614. fs.readFile(filename, {encoding: 'utf8'}, function(err, data) {
  9615. if (err) return callback(err);
  9616. callback(null, engine.parse(data));
  9617. });
  9618. });
  9619. delete options.includeDir;
  9620. /**
  9621. * The custom tag functions need to have their results pushed back
  9622. * through the parser, so set up a shim before calling the provided
  9623. * callback:
  9624. */
  9625. var compileOptions = {
  9626. customTags: {}
  9627. };
  9628. if (options.customTags) {
  9629. var tagFunctions = options.customTags;
  9630. for (k in options.customTags) {
  9631. /*Tell jshint there's no problem with having this function in the loop */
  9632. /*jshint -W083 */
  9633. compileOptions.customTags[k] = function(context, name, body) {
  9634. var tpl = tagFunctions[name](body.trim());
  9635. context.astStack.push(engine.parse(tpl));
  9636. };
  9637. /*jshint +W083 */
  9638. }
  9639. delete options.customTags;
  9640. }
  9641. /**
  9642. * Now anything left in `options` becomes a local:
  9643. */
  9644. for (k in options) {
  9645. context.setLocals(k, options[k]);
  9646. }
  9647. /**
  9648. * Finally, execute the template:
  9649. */
  9650. var tmpl = cache(context) || cache(context, engine.compile(str, compileOptions));
  9651. tmpl(context, cb);
  9652. }
  9653. exports.liquid.render = function(str, options, cb) {
  9654. return promisify(cb, function(cb) {
  9655. var engine = requires.liquid;
  9656. var Liquid;
  9657. try {
  9658. // set up tinyliquid engine
  9659. engine = requires.liquid = require('tinyliquid');
  9660. // use tinyliquid engine
  9661. _renderTinyliquid(engine, str, options, cb);
  9662. return;
  9663. } catch (err) {
  9664. // set up liquid-node engine
  9665. try {
  9666. Liquid = requires.liquid = require('liquid-node');
  9667. engine = new Liquid.Engine();
  9668. } catch (err) {
  9669. throw err;
  9670. }
  9671. }
  9672. // use liquid-node engine
  9673. try {
  9674. var locals = options.locals || {};
  9675. if (options.meta) {
  9676. locals.pages = options.meta;
  9677. delete options.meta;
  9678. }
  9679. /**
  9680. * Add any defined filters:
  9681. */
  9682. if (options.filters) {
  9683. engine.registerFilters(options.filters);
  9684. delete options.filters;
  9685. }
  9686. /**
  9687. * Set up a callback for the include directory:
  9688. */
  9689. var includeDir = options.includeDir || process.cwd();
  9690. engine.fileSystem = new Liquid.LocalFileSystem(includeDir, 'liquid');
  9691. delete options.includeDir;
  9692. /**
  9693. * The custom tag functions need to have their results pushed back
  9694. * through the parser, so set up a shim before calling the provided
  9695. * callback:
  9696. */
  9697. if (options.customTags) {
  9698. var tagFunctions = options.customTags;
  9699. for (k in options.customTags) {
  9700. engine.registerTag(k, tagFunctions[k]);
  9701. }
  9702. delete options.customTags;
  9703. }
  9704. /**
  9705. * Now anything left in `options` becomes a local:
  9706. */
  9707. for (var k in options) {
  9708. locals[k] = options[k];
  9709. }
  9710. /**
  9711. * Finally, execute the template:
  9712. */
  9713. return engine
  9714. .parseAndRender(str, locals)
  9715. .nodeify(function(err, result) {
  9716. if (err) {
  9717. throw new Error(err);
  9718. } else {
  9719. return cb(null, result);
  9720. }
  9721. });
  9722. } catch (err) {
  9723. cb(err);
  9724. }
  9725. });
  9726. };
  9727. /**
  9728. * Jade support.
  9729. */
  9730. exports.jade = function(path, options, cb) {
  9731. return promisify(cb, function(cb) {
  9732. var engine = requires.jade;
  9733. if (!engine) {
  9734. try {
  9735. engine = requires.jade = require('jade');
  9736. } catch (err) {
  9737. try {
  9738. engine = requires.jade = require('then-jade');
  9739. } catch (otherError) {
  9740. throw err;
  9741. }
  9742. }
  9743. }
  9744. try {
  9745. var tmpl = cache(options) || cache(options, engine.compileFile(path, options));
  9746. cb(null, tmpl(options));
  9747. } catch (err) {
  9748. cb(err);
  9749. }
  9750. });
  9751. };
  9752. /**
  9753. * Jade string support.
  9754. */
  9755. exports.jade.render = function(str, options, cb) {
  9756. return promisify(cb, function(cb) {
  9757. var engine = requires.jade;
  9758. if (!engine) {
  9759. try {
  9760. engine = requires.jade = require('jade');
  9761. } catch (err) {
  9762. try {
  9763. engine = requires.jade = require('then-jade');
  9764. } catch (otherError) {
  9765. throw err;
  9766. }
  9767. }
  9768. }
  9769. try {
  9770. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9771. cb(null, tmpl(options));
  9772. } catch (err) {
  9773. cb(err);
  9774. }
  9775. });
  9776. };
  9777. /**
  9778. * Dust support.
  9779. */
  9780. exports.dust = fromStringRenderer('dust');
  9781. /**
  9782. * Dust string support.
  9783. */
  9784. exports.dust.render = function(str, options, cb) {
  9785. return promisify(cb, function(cb) {
  9786. var engine = requires.dust;
  9787. if (!engine) {
  9788. try {
  9789. engine = requires.dust = require('dust');
  9790. } catch (err) {
  9791. try {
  9792. engine = requires.dust = require('dustjs-helpers');
  9793. } catch (err) {
  9794. engine = requires.dust = require('dustjs-linkedin');
  9795. }
  9796. }
  9797. }
  9798. var ext = 'dust';
  9799. var views = '.';
  9800. if (options) {
  9801. if (options.ext) ext = options.ext;
  9802. if (options.views) views = options.views;
  9803. if (options.settings && options.settings.views) views = options.settings.views;
  9804. }
  9805. if (!options || (options && !options.cache)) engine.cache = {};
  9806. engine.onLoad = function(path, callback) {
  9807. if (extname(path) === '') path += '.' + ext;
  9808. if (path[0] !== '/') path = views + '/' + path;
  9809. read(path, options, callback);
  9810. };
  9811. try {
  9812. var templateName;
  9813. if (options.filename) {
  9814. templateName = options.filename.replace(new RegExp('^' + views + '/'), '').replace(new RegExp('\\.' + ext), '');
  9815. }
  9816. var tmpl = cache(options) || cache(options, engine.compileFn(str, templateName));
  9817. tmpl(options, cb);
  9818. } catch (err) {
  9819. cb(err);
  9820. }
  9821. });
  9822. };
  9823. /**
  9824. * Swig support.
  9825. */
  9826. exports.swig = fromStringRenderer('swig');
  9827. /**
  9828. * Swig string support.
  9829. */
  9830. exports.swig.render = function(str, options, cb) {
  9831. return promisify(cb, function(cb) {
  9832. var engine = requires.swig;
  9833. if (!engine) {
  9834. try {
  9835. engine = requires.swig = require('swig');
  9836. } catch (err) {
  9837. try {
  9838. engine = requires.swig = require('swig-templates');
  9839. } catch (otherError) {
  9840. throw err;
  9841. }
  9842. }
  9843. }
  9844. try {
  9845. if (options.cache === true) options.cache = 'memory';
  9846. engine.setDefaults({ cache: options.cache });
  9847. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9848. cb(null, tmpl(options));
  9849. } catch (err) {
  9850. cb(err);
  9851. }
  9852. });
  9853. };
  9854. /**
  9855. * Razor support.
  9856. */
  9857. exports.razor = function(path, options, cb) {
  9858. return promisify(cb, function(cb) {
  9859. var engine = requires.razor;
  9860. if (!engine) {
  9861. try {
  9862. engine = requires.razor = require('razor-tmpl');
  9863. } catch (err) {
  9864. throw err;
  9865. }
  9866. }
  9867. try {
  9868. var tmpl = cache(options) || cache(options, (locals) => {
  9869. console.log('Rendering razor file', path);
  9870. return engine.renderFileSync(path, locals);
  9871. });
  9872. cb(null, tmpl(options));
  9873. } catch (err) {
  9874. cb(err);
  9875. }
  9876. });
  9877. };
  9878. /**
  9879. * razor string support.
  9880. */
  9881. exports.razor.render = function(str, options, cb) {
  9882. return promisify(cb, function(cb) {
  9883. try {
  9884. var engine = requires.razor = require('razor-tmpl');
  9885. } catch (err) {
  9886. throw err;
  9887. }
  9888. try {
  9889. var tf = engine.compile(str);
  9890. var tmpl = cache(options) || cache(options, tf);
  9891. cb(null, tmpl(options));
  9892. } catch (err) {
  9893. cb(err);
  9894. }
  9895. });
  9896. };
  9897. /**
  9898. * Atpl support.
  9899. */
  9900. exports.atpl = fromStringRenderer('atpl');
  9901. /**
  9902. * Atpl string support.
  9903. */
  9904. exports.atpl.render = function(str, options, cb) {
  9905. return promisify(cb, function(cb) {
  9906. var engine = requires.atpl || (requires.atpl = require('atpl'));
  9907. try {
  9908. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9909. cb(null, tmpl(options));
  9910. } catch (err) {
  9911. cb(err);
  9912. }
  9913. });
  9914. };
  9915. /**
  9916. * Liquor support,
  9917. */
  9918. exports.liquor = fromStringRenderer('liquor');
  9919. /**
  9920. * Liquor string support.
  9921. */
  9922. exports.liquor.render = function(str, options, cb) {
  9923. return promisify(cb, function(cb) {
  9924. var engine = requires.liquor || (requires.liquor = require('liquor'));
  9925. try {
  9926. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9927. cb(null, tmpl(options));
  9928. } catch (err) {
  9929. cb(err);
  9930. }
  9931. });
  9932. };
  9933. /**
  9934. * Twig support.
  9935. */
  9936. exports.twig = fromStringRenderer('twig');
  9937. /**
  9938. * Twig string support.
  9939. */
  9940. exports.twig.render = function(str, options, cb) {
  9941. return promisify(cb, function(cb) {
  9942. var engine = requires.twig || (requires.twig = require('twig').twig);
  9943. var templateData = {
  9944. data: str,
  9945. allowInlineIncludes: options.allowInlineIncludes,
  9946. namespaces: options.namespaces,
  9947. path: options.path
  9948. };
  9949. try {
  9950. var tmpl = cache(templateData) || cache(templateData, engine(templateData));
  9951. cb(null, tmpl.render(options));
  9952. } catch (err) {
  9953. cb(err);
  9954. }
  9955. });
  9956. };
  9957. /**
  9958. * EJS support.
  9959. */
  9960. exports.ejs = fromStringRenderer('ejs');
  9961. /**
  9962. * EJS string support.
  9963. */
  9964. exports.ejs.render = function(str, options, cb) {
  9965. return promisify(cb, function(cb) {
  9966. var engine = requires.ejs || (requires.ejs = require('ejs'));
  9967. try {
  9968. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9969. cb(null, tmpl(options));
  9970. } catch (err) {
  9971. cb(err);
  9972. }
  9973. });
  9974. };
  9975. /**
  9976. * Eco support.
  9977. */
  9978. exports.eco = fromStringRenderer('eco');
  9979. /**
  9980. * Eco string support.
  9981. */
  9982. exports.eco.render = function(str, options, cb) {
  9983. return promisify(cb, function(cb) {
  9984. var engine = requires.eco || (requires.eco = require('eco'));
  9985. try {
  9986. cb(null, engine.render(str, options));
  9987. } catch (err) {
  9988. cb(err);
  9989. }
  9990. });
  9991. };
  9992. /**
  9993. * Jazz support.
  9994. */
  9995. exports.jazz = fromStringRenderer('jazz');
  9996. /**
  9997. * Jazz string support.
  9998. */
  9999. exports.jazz.render = function(str, options, cb) {
  10000. return promisify(cb, function(cb) {
  10001. var engine = requires.jazz || (requires.jazz = require('jazz'));
  10002. try {
  10003. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10004. tmpl.eval(options, function(str) {
  10005. cb(null, str);
  10006. });
  10007. } catch (err) {
  10008. cb(err);
  10009. }
  10010. });
  10011. };
  10012. /**
  10013. * JQTPL support.
  10014. */
  10015. exports.jqtpl = fromStringRenderer('jqtpl');
  10016. /**
  10017. * JQTPL string support.
  10018. */
  10019. exports.jqtpl.render = function(str, options, cb) {
  10020. return promisify(cb, function(cb) {
  10021. var engine = requires.jqtpl || (requires.jqtpl = require('jqtpl'));
  10022. try {
  10023. engine.template(str, str);
  10024. cb(null, engine.tmpl(str, options));
  10025. } catch (err) {
  10026. cb(err);
  10027. }
  10028. });
  10029. };
  10030. /**
  10031. * Haml support.
  10032. */
  10033. exports.haml = fromStringRenderer('haml');
  10034. /**
  10035. * Haml string support.
  10036. */
  10037. exports.haml.render = function(str, options, cb) {
  10038. return promisify(cb, function(cb) {
  10039. var engine = requires.haml || (requires.haml = require('hamljs'));
  10040. try {
  10041. options.locals = options;
  10042. cb(null, engine.render(str, options).trimLeft());
  10043. } catch (err) {
  10044. cb(err);
  10045. }
  10046. });
  10047. };
  10048. /**
  10049. * Hamlet support.
  10050. */
  10051. exports.hamlet = fromStringRenderer('hamlet');
  10052. /**
  10053. * Hamlet string support.
  10054. */
  10055. exports.hamlet.render = function(str, options, cb) {
  10056. return promisify(cb, function(cb) {
  10057. var engine = requires.hamlet || (requires.hamlet = require('hamlet'));
  10058. try {
  10059. options.locals = options;
  10060. cb(null, engine.render(str, options).trimLeft());
  10061. } catch (err) {
  10062. cb(err);
  10063. }
  10064. });
  10065. };
  10066. /**
  10067. * Whiskers support.
  10068. */
  10069. exports.whiskers = function(path, options, cb) {
  10070. return promisify(cb, function(cb) {
  10071. var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
  10072. engine.__express(path, options, cb);
  10073. });
  10074. };
  10075. /**
  10076. * Whiskers string support.
  10077. */
  10078. exports.whiskers.render = function(str, options, cb) {
  10079. return promisify(cb, function(cb) {
  10080. var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
  10081. try {
  10082. cb(null, engine.render(str, options));
  10083. } catch (err) {
  10084. cb(err);
  10085. }
  10086. });
  10087. };
  10088. /**
  10089. * Coffee-HAML support.
  10090. */
  10091. exports['haml-coffee'] = fromStringRenderer('haml-coffee');
  10092. /**
  10093. * Coffee-HAML string support.
  10094. */
  10095. exports['haml-coffee'].render = function(str, options, cb) {
  10096. return promisify(cb, function(cb) {
  10097. var engine = requires['haml-coffee'] || (requires['haml-coffee'] = require('haml-coffee'));
  10098. try {
  10099. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10100. cb(null, tmpl(options));
  10101. } catch (err) {
  10102. cb(err);
  10103. }
  10104. });
  10105. };
  10106. /**
  10107. * Hogan support.
  10108. */
  10109. exports.hogan = fromStringRenderer('hogan');
  10110. /**
  10111. * Hogan string support.
  10112. */
  10113. exports.hogan.render = function(str, options, cb) {
  10114. return promisify(cb, function(cb) {
  10115. var engine = requires.hogan || (requires.hogan = require('hogan.js'));
  10116. try {
  10117. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10118. cb(null, tmpl.render(options, options.partials));
  10119. } catch (err) {
  10120. cb(err);
  10121. }
  10122. });
  10123. };
  10124. /**
  10125. * templayed.js support.
  10126. */
  10127. exports.templayed = fromStringRenderer('templayed');
  10128. /**
  10129. * templayed.js string support.
  10130. */
  10131. exports.templayed.render = function(str, options, cb) {
  10132. return promisify(cb, function(cb) {
  10133. var engine = requires.templayed || (requires.templayed = require('templayed'));
  10134. try {
  10135. var tmpl = cache(options) || cache(options, engine(str));
  10136. cb(null, tmpl(options));
  10137. } catch (err) {
  10138. cb(err);
  10139. }
  10140. });
  10141. };
  10142. /**
  10143. * Handlebars support.
  10144. */
  10145. exports.handlebars = fromStringRenderer('handlebars');
  10146. /**
  10147. * Handlebars string support.
  10148. */
  10149. exports.handlebars.render = function(str, options, cb) {
  10150. return promisify(cb, function(cb) {
  10151. var engine = requires.handlebars || (requires.handlebars = require('handlebars'));
  10152. try {
  10153. for (var partial in options.partials) {
  10154. engine.registerPartial(partial, options.partials[partial]);
  10155. }
  10156. for (var helper in options.helpers) {
  10157. engine.registerHelper(helper, options.helpers[helper]);
  10158. }
  10159. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10160. cb(null, tmpl(options));
  10161. } catch (err) {
  10162. cb(err);
  10163. }
  10164. });
  10165. };
  10166. /**
  10167. * Underscore support.
  10168. */
  10169. exports.underscore = fromStringRenderer('underscore');
  10170. /**
  10171. * Underscore string support.
  10172. */
  10173. exports.underscore.render = function(str, options, cb) {
  10174. return promisify(cb, function(cb) {
  10175. var engine = requires.underscore || (requires.underscore = require('underscore'));
  10176. try {
  10177. const partials = {};
  10178. for (var partial in options.partials) {
  10179. partials[partial] = engine.template(options.partials[partial]);
  10180. }
  10181. options.partials = partials;
  10182. var tmpl = cache(options) || cache(options, engine.template(str, null, options));
  10183. cb(null, tmpl(options).replace(/\n$/, ''));
  10184. } catch (err) {
  10185. cb(err);
  10186. }
  10187. });
  10188. };
  10189. /**
  10190. * Lodash support.
  10191. */
  10192. exports.lodash = fromStringRenderer('lodash');
  10193. /**
  10194. * Lodash string support.
  10195. */
  10196. exports.lodash.render = function(str, options, cb) {
  10197. return promisify(cb, function(cb) {
  10198. var engine = requires.lodash || (requires.lodash = require('lodash'));
  10199. try {
  10200. var tmpl = cache(options) || cache(options, engine.template(str, options));
  10201. cb(null, tmpl(options).replace(/\n$/, ''));
  10202. } catch (err) {
  10203. cb(err);
  10204. }
  10205. });
  10206. };
  10207. /**
  10208. * Pug support. (formerly Jade)
  10209. */
  10210. exports.pug = function(path, options, cb) {
  10211. return promisify(cb, function(cb) {
  10212. var engine = requires.pug;
  10213. if (!engine) {
  10214. try {
  10215. engine = requires.pug = require('pug');
  10216. } catch (err) {
  10217. try {
  10218. engine = requires.pug = require('then-pug');
  10219. } catch (otherError) {
  10220. throw err;
  10221. }
  10222. }
  10223. }
  10224. try {
  10225. var tmpl = cache(options) || cache(options, engine.compileFile(path, options));
  10226. cb(null, tmpl(options));
  10227. } catch (err) {
  10228. cb(err);
  10229. }
  10230. });
  10231. };
  10232. /**
  10233. * Pug string support.
  10234. */
  10235. exports.pug.render = function(str, options, cb) {
  10236. return promisify(cb, function(cb) {
  10237. var engine = requires.pug;
  10238. if (!engine) {
  10239. try {
  10240. engine = requires.pug = require('pug');
  10241. } catch (err) {
  10242. try {
  10243. engine = requires.pug = require('then-pug');
  10244. } catch (otherError) {
  10245. throw err;
  10246. }
  10247. }
  10248. }
  10249. try {
  10250. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10251. cb(null, tmpl(options));
  10252. } catch (err) {
  10253. cb(err);
  10254. }
  10255. });
  10256. };
  10257. /**
  10258. * QEJS support.
  10259. */
  10260. exports.qejs = fromStringRenderer('qejs');
  10261. /**
  10262. * QEJS string support.
  10263. */
  10264. exports.qejs.render = function(str, options, cb) {
  10265. return promisify(cb, function(cb) {
  10266. try {
  10267. var engine = requires.qejs || (requires.qejs = require('qejs'));
  10268. engine.render(str, options).then(function(result) {
  10269. cb(null, result);
  10270. }, function(err) {
  10271. cb(err);
  10272. }).done();
  10273. } catch (err) {
  10274. cb(err);
  10275. }
  10276. });
  10277. };
  10278. /**
  10279. * Walrus support.
  10280. */
  10281. exports.walrus = fromStringRenderer('walrus');
  10282. /**
  10283. * Walrus string support.
  10284. */
  10285. exports.walrus.render = function(str, options, cb) {
  10286. return promisify(cb, function(cb) {
  10287. var engine = requires.walrus || (requires.walrus = require('walrus'));
  10288. try {
  10289. var tmpl = cache(options) || cache(options, engine.parse(str));
  10290. cb(null, tmpl.compile(options));
  10291. } catch (err) {
  10292. cb(err);
  10293. }
  10294. });
  10295. };
  10296. /**
  10297. * Mustache support.
  10298. */
  10299. exports.mustache = fromStringRenderer('mustache');
  10300. /**
  10301. * Mustache string support.
  10302. */
  10303. exports.mustache.render = function(str, options, cb) {
  10304. return promisify(cb, function(cb) {
  10305. var engine = requires.mustache || (requires.mustache = require('mustache'));
  10306. try {
  10307. cb(null, engine.render(str, options, options.partials));
  10308. } catch (err) {
  10309. cb(err);
  10310. }
  10311. });
  10312. };
  10313. /**
  10314. * Just support.
  10315. */
  10316. exports.just = function(path, options, cb) {
  10317. return promisify(cb, function(cb) {
  10318. var engine = requires.just;
  10319. if (!engine) {
  10320. var JUST = require('just');
  10321. engine = requires.just = new JUST();
  10322. }
  10323. engine.configure({ useCache: options.cache });
  10324. engine.render(path, options, cb);
  10325. });
  10326. };
  10327. /**
  10328. * Just string support.
  10329. */
  10330. exports.just.render = function(str, options, cb) {
  10331. return promisify(cb, function(cb) {
  10332. var JUST = require('just');
  10333. var engine = new JUST({ root: { page: str }});
  10334. engine.render('page', options, cb);
  10335. });
  10336. };
  10337. /**
  10338. * ECT support.
  10339. */
  10340. exports.ect = function(path, options, cb) {
  10341. return promisify(cb, function(cb) {
  10342. var engine = requires.ect;
  10343. if (!engine) {
  10344. var ECT = require('ect');
  10345. engine = requires.ect = new ECT(options);
  10346. }
  10347. engine.configure({ cache: options.cache });
  10348. engine.render(path, options, cb);
  10349. });
  10350. };
  10351. /**
  10352. * ECT string support.
  10353. */
  10354. exports.ect.render = function(str, options, cb) {
  10355. return promisify(cb, function(cb) {
  10356. var ECT = require('ect');
  10357. var engine = new ECT({ root: { page: str }});
  10358. engine.render('page', options, cb);
  10359. });
  10360. };
  10361. /**
  10362. * mote support.
  10363. */
  10364. exports.mote = fromStringRenderer('mote');
  10365. /**
  10366. * mote string support.
  10367. */
  10368. exports.mote.render = function(str, options, cb) {
  10369. return promisify(cb, function(cb) {
  10370. var engine = requires.mote || (requires.mote = require('mote'));
  10371. try {
  10372. var tmpl = cache(options) || cache(options, engine.compile(str));
  10373. cb(null, tmpl(options));
  10374. } catch (err) {
  10375. cb(err);
  10376. }
  10377. });
  10378. };
  10379. /**
  10380. * Toffee support.
  10381. */
  10382. exports.toffee = function(path, options, cb) {
  10383. return promisify(cb, function(cb) {
  10384. var toffee = requires.toffee || (requires.toffee = require('toffee'));
  10385. toffee.__consolidate_engine_render(path, options, cb);
  10386. });
  10387. };
  10388. /**
  10389. * Toffee string support.
  10390. */
  10391. exports.toffee.render = function(str, options, cb) {
  10392. return promisify(cb, function(cb) {
  10393. var engine = requires.toffee || (requires.toffee = require('toffee'));
  10394. try {
  10395. engine.str_render(str, options, cb);
  10396. } catch (err) {
  10397. cb(err);
  10398. }
  10399. });
  10400. };
  10401. /**
  10402. * doT support.
  10403. */
  10404. exports.dot = fromStringRenderer('dot');
  10405. /**
  10406. * doT string support.
  10407. */
  10408. exports.dot.render = function(str, options, cb) {
  10409. return promisify(cb, function(cb) {
  10410. var engine = requires.dot || (requires.dot = require('dot'));
  10411. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  10412. try {
  10413. var settings = {};
  10414. settings = extend(settings, engine.templateSettings);
  10415. settings = extend(settings, options ? options.dot : {});
  10416. var tmpl = cache(options) || cache(options, engine.template(str, settings, options));
  10417. cb(null, tmpl(options));
  10418. } catch (err) {
  10419. cb(err);
  10420. }
  10421. });
  10422. };
  10423. /**
  10424. * bracket support.
  10425. */
  10426. exports.bracket = fromStringRenderer('bracket');
  10427. /**
  10428. * bracket string support.
  10429. */
  10430. exports.bracket.render = function(str, options, cb) {
  10431. return promisify(cb, function(cb) {
  10432. var engine = requires.bracket || (requires.bracket = require('bracket-template'));
  10433. try {
  10434. var tmpl = cache(options) || cache(options, engine.default.compile(str, options));
  10435. cb(null, tmpl(options));
  10436. } catch (err) {
  10437. cb(err);
  10438. }
  10439. });
  10440. };
  10441. /**
  10442. * Ractive support.
  10443. */
  10444. exports.ractive = fromStringRenderer('ractive');
  10445. /**
  10446. * Ractive string support.
  10447. */
  10448. exports.ractive.render = function(str, options, cb) {
  10449. return promisify(cb, function(cb) {
  10450. var Engine = requires.ractive || (requires.ractive = require('ractive'));
  10451. var template = cache(options) || cache(options, Engine.parse(str));
  10452. options.template = template;
  10453. if (options.data === null || options.data === undefined) {
  10454. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  10455. // Shallow clone the options object
  10456. options.data = extend({}, options);
  10457. // Remove consolidate-specific properties from the clone
  10458. var i;
  10459. var length;
  10460. var properties = ['template', 'filename', 'cache', 'partials'];
  10461. for (i = 0, length = properties.length; i < length; i++) {
  10462. var property = properties[i];
  10463. delete options.data[property];
  10464. }
  10465. }
  10466. try {
  10467. cb(null, new Engine(options).toHTML());
  10468. } catch (err) {
  10469. cb(err);
  10470. }
  10471. });
  10472. };
  10473. /**
  10474. * Nunjucks support.
  10475. */
  10476. exports.nunjucks = fromStringRenderer('nunjucks');
  10477. /**
  10478. * Nunjucks string support.
  10479. */
  10480. exports.nunjucks.render = function(str, options, cb) {
  10481. return promisify(cb, function(cb) {
  10482. try {
  10483. var engine = options.nunjucksEnv || requires.nunjucks || (requires.nunjucks = require('nunjucks'));
  10484. var env = engine;
  10485. // deprecated fallback support for express
  10486. // <https://github.com/tj/consolidate.js/pull/152>
  10487. // <https://github.com/tj/consolidate.js/pull/224>
  10488. if (options.settings && options.settings.views) {
  10489. env = engine.configure(options.settings.views);
  10490. } else if (options.nunjucks && options.nunjucks.configure) {
  10491. env = engine.configure.apply(engine, options.nunjucks.configure);
  10492. }
  10493. //
  10494. // because `renderString` does not initiate loaders
  10495. // we must manually create a loader for it based off
  10496. // either `options.settings.views` or `options.nunjucks` or `options.nunjucks.root`
  10497. //
  10498. // <https://github.com/mozilla/nunjucks/issues/730>
  10499. // <https://github.com/crocodilejs/node-email-templates/issues/182>
  10500. //
  10501. // so instead we simply check if we passed a custom loader
  10502. // otherwise we create a simple file based loader
  10503. if (options.loader) {
  10504. env = new engine.Environment(options.loader);
  10505. } else if (options.settings && options.settings.views) {
  10506. env = new engine.Environment(
  10507. new engine.FileSystemLoader(options.settings.views)
  10508. );
  10509. } else if (options.nunjucks && options.nunjucks.loader) {
  10510. if (typeof options.nunjucks.loader === 'string') {
  10511. env = new engine.Environment(new engine.FileSystemLoader(options.nunjucks.loader));
  10512. } else {
  10513. env = new engine.Environment(
  10514. new engine.FileSystemLoader(
  10515. options.nunjucks.loader[0],
  10516. options.nunjucks.loader[1]
  10517. )
  10518. );
  10519. }
  10520. }
  10521. env.renderString(str, options, cb);
  10522. } catch (err) {
  10523. throw cb(err);
  10524. }
  10525. });
  10526. };
  10527. /**
  10528. * HTMLing support.
  10529. */
  10530. exports.htmling = fromStringRenderer('htmling');
  10531. /**
  10532. * HTMLing string support.
  10533. */
  10534. exports.htmling.render = function(str, options, cb) {
  10535. return promisify(cb, function(cb) {
  10536. var engine = requires.htmling || (requires.htmling = require('htmling'));
  10537. try {
  10538. var tmpl = cache(options) || cache(options, engine.string(str));
  10539. cb(null, tmpl.render(options));
  10540. } catch (err) {
  10541. cb(err);
  10542. }
  10543. });
  10544. };
  10545. /**
  10546. * Rendering function
  10547. */
  10548. function requireReact(module, filename) {
  10549. var babel = requires.babel || (requires.babel = require('babel-core'));
  10550. var compiled = babel.transformFileSync(filename, { presets: [ 'react' ] }).code;
  10551. return module._compile(compiled, filename);
  10552. }
  10553. exports.requireReact = requireReact;
  10554. /**
  10555. * Converting a string into a node module.
  10556. */
  10557. function requireReactString(src, filename) {
  10558. var babel = requires.babel || (requires.babel = require('babel-core'));
  10559. if (!filename) filename = '';
  10560. var m = new module.constructor();
  10561. filename = filename || '';
  10562. // Compile Using React
  10563. var compiled = babel.transform(src, { presets: [ 'react' ] }).code;
  10564. // Compile as a module
  10565. m.paths = module.paths;
  10566. m._compile(compiled, filename);
  10567. return m.exports;
  10568. }
  10569. /**
  10570. * A naive helper to replace {{tags}} with options.tags content
  10571. */
  10572. function reactBaseTmpl(data, options) {
  10573. var exp;
  10574. var regex;
  10575. // Iterates through the keys in file object
  10576. // and interpolate / replace {{key}} with it's value
  10577. for (var k in options) {
  10578. if (options.hasOwnProperty(k)) {
  10579. exp = '{{' + k + '}}';
  10580. regex = new RegExp(exp, 'g');
  10581. if (data.match(regex)) {
  10582. data = data.replace(regex, options[k]);
  10583. }
  10584. }
  10585. }
  10586. return data;
  10587. }
  10588. /**
  10589. * Plates Support.
  10590. */
  10591. exports.plates = fromStringRenderer('plates');
  10592. /**
  10593. * Plates string support.
  10594. */
  10595. exports.plates.render = function(str, options, cb) {
  10596. return promisify(cb, function(cb) {
  10597. var engine = requires.plates || (requires.plates = require('plates'));
  10598. var map = options.map || undefined;
  10599. try {
  10600. var tmpl = engine.bind(str, options, map);
  10601. cb(null, tmpl);
  10602. } catch (err) {
  10603. cb(err);
  10604. }
  10605. });
  10606. };
  10607. /**
  10608. * The main render parser for React bsaed templates
  10609. */
  10610. function reactRenderer(type) {
  10611. if (commonjsRequire.extensions) {
  10612. // Ensure JSX is transformed on require
  10613. if (!commonjsRequire.extensions['.jsx']) {
  10614. commonjsRequire.extensions['.jsx'] = requireReact;
  10615. }
  10616. // Supporting .react extension as well as test cases
  10617. // Using .react extension is not recommended.
  10618. if (!commonjsRequire.extensions['.react']) {
  10619. commonjsRequire.extensions['.react'] = requireReact;
  10620. }
  10621. }
  10622. // Return rendering fx
  10623. return function(str, options, cb) {
  10624. return promisify(cb, function(cb) {
  10625. // React Import
  10626. var ReactDOM = requires.ReactDOM || (requires.ReactDOM = require('react-dom/server'));
  10627. var react = requires.react || (requires.react = require('react'));
  10628. // Assign HTML Base
  10629. var base = options.base;
  10630. delete options.base;
  10631. var enableCache = options.cache;
  10632. delete options.cache;
  10633. var isNonStatic = options.isNonStatic;
  10634. delete options.isNonStatic;
  10635. // Start Conversion
  10636. try {
  10637. var Code;
  10638. var Factory;
  10639. var baseStr;
  10640. var content;
  10641. var parsed;
  10642. if (!cache(options)) {
  10643. // Parsing
  10644. if (type === 'path') {
  10645. var path = resolve(str);
  10646. delete require.cache[path];
  10647. Code = commonjsRequire(path);
  10648. } else {
  10649. Code = requireReactString(str);
  10650. }
  10651. Factory = cache(options, react.createFactory(Code));
  10652. } else {
  10653. Factory = cache(options);
  10654. }
  10655. parsed = new Factory(options);
  10656. content = (isNonStatic) ? ReactDOM.renderToString(parsed) : ReactDOM.renderToStaticMarkup(parsed);
  10657. if (base) {
  10658. baseStr = readCache[str] || fs.readFileSync(resolve(base), 'utf8');
  10659. if (enableCache) {
  10660. readCache[str] = baseStr;
  10661. }
  10662. options.content = content;
  10663. content = reactBaseTmpl(baseStr, options);
  10664. }
  10665. cb(null, content);
  10666. } catch (err) {
  10667. cb(err);
  10668. }
  10669. });
  10670. };
  10671. }
  10672. /**
  10673. * React JS Support
  10674. */
  10675. exports.react = reactRenderer('path');
  10676. /**
  10677. * React JS string support.
  10678. */
  10679. exports.react.render = reactRenderer('string');
  10680. /**
  10681. * ARC-templates support.
  10682. */
  10683. exports['arc-templates'] = fromStringRenderer('arc-templates');
  10684. /**
  10685. * ARC-templates string support.
  10686. */
  10687. exports['arc-templates'].render = function(str, options, cb) {
  10688. var readFileWithOptions = util.promisify(read);
  10689. var consolidateFileSystem = {};
  10690. consolidateFileSystem.readFile = function(path) {
  10691. return readFileWithOptions(path, options);
  10692. };
  10693. return promisify(cb, function(cb) {
  10694. try {
  10695. var engine = requires['arc-templates'];
  10696. if (!engine) {
  10697. var Engine = require('arc-templates/dist/es5');
  10698. engine = requires['arc-templates'] = new Engine({ filesystem: consolidateFileSystem });
  10699. }
  10700. var compiler = cache(options) || cache(options, engine.compileString(str, options.filename));
  10701. compiler.then(function(func) { return func(options); })
  10702. .then(function(result) { cb(null, result.content); })
  10703. .catch(cb);
  10704. } catch (err) {
  10705. cb(err);
  10706. }
  10707. });
  10708. };
  10709. /**
  10710. * Vash support
  10711. */
  10712. exports.vash = fromStringRenderer('vash');
  10713. /**
  10714. * Vash string support
  10715. */
  10716. exports.vash.render = function(str, options, cb) {
  10717. return promisify(cb, function(cb) {
  10718. var engine = requires.vash || (requires.vash = require('vash'));
  10719. try {
  10720. // helper system : https://github.com/kirbysayshi/vash#helper-system
  10721. if (options.helpers) {
  10722. for (var key in options.helpers) {
  10723. if (!options.helpers.hasOwnProperty(key) || typeof options.helpers[key] !== 'function') {
  10724. continue;
  10725. }
  10726. engine.helpers[key] = options.helpers[key];
  10727. }
  10728. }
  10729. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10730. tmpl(options, function sealLayout(err, ctx) {
  10731. if (err) cb(err);
  10732. ctx.finishLayout();
  10733. cb(null, ctx.toString().replace(/\n$/, ''));
  10734. });
  10735. } catch (err) {
  10736. cb(err);
  10737. }
  10738. });
  10739. };
  10740. /**
  10741. * Slm support.
  10742. */
  10743. exports.slm = fromStringRenderer('slm');
  10744. /**
  10745. * Slm string support.
  10746. */
  10747. exports.slm.render = function(str, options, cb) {
  10748. return promisify(cb, function(cb) {
  10749. var engine = requires.slm || (requires.slm = require('slm'));
  10750. try {
  10751. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10752. cb(null, tmpl(options));
  10753. } catch (err) {
  10754. cb(err);
  10755. }
  10756. });
  10757. };
  10758. /**
  10759. * Marko support.
  10760. */
  10761. exports.marko = function(path, options, cb) {
  10762. return promisify(cb, function(cb) {
  10763. var engine = requires.marko || (requires.marko = require('marko'));
  10764. options.writeToDisk = !!options.cache;
  10765. try {
  10766. var tmpl = cache(options) || cache(options, engine.load(path, options));
  10767. tmpl.renderToString(options, cb);
  10768. } catch (err) {
  10769. cb(err);
  10770. }
  10771. });
  10772. };
  10773. /**
  10774. * Marko string support.
  10775. */
  10776. exports.marko.render = function(str, options, cb) {
  10777. return promisify(cb, function(cb) {
  10778. var engine = requires.marko || (requires.marko = require('marko'));
  10779. options.writeToDisk = !!options.cache;
  10780. options.filename = options.filename || 'string.marko';
  10781. try {
  10782. var tmpl = cache(options) || cache(options, engine.load(options.filename, str, options));
  10783. tmpl.renderToString(options, cb);
  10784. } catch (err) {
  10785. cb(err);
  10786. }
  10787. });
  10788. };
  10789. /**
  10790. * Teacup support.
  10791. */
  10792. exports.teacup = function(path, options, cb) {
  10793. return promisify(cb, function(cb) {
  10794. var engine = requires.teacup || (requires.teacup = require('teacup/lib/express'));
  10795. commonjsRequire.extensions['.teacup'] = commonjsRequire.extensions['.coffee'];
  10796. if (path[0] !== '/') {
  10797. path = join(process.cwd(), path);
  10798. }
  10799. if (!options.cache) {
  10800. var callback = cb;
  10801. cb = function() {
  10802. delete require.cache[path];
  10803. callback.apply(this, arguments);
  10804. };
  10805. }
  10806. engine.renderFile(path, options, cb);
  10807. });
  10808. };
  10809. /**
  10810. * Teacup string support.
  10811. */
  10812. exports.teacup.render = function(str, options, cb) {
  10813. var coffee = require('coffee-script');
  10814. var vm = require('vm');
  10815. var sandbox = {
  10816. module: {exports: {}},
  10817. require: commonjsRequire
  10818. };
  10819. return promisify(cb, function(cb) {
  10820. vm.runInNewContext(coffee.compile(str), sandbox);
  10821. var tmpl = sandbox.module.exports;
  10822. cb(null, tmpl(options));
  10823. });
  10824. };
  10825. /**
  10826. * Squirrelly support.
  10827. */
  10828. exports.squirrelly = fromStringRenderer('squirrelly');
  10829. /**
  10830. * Squirrelly string support.
  10831. */
  10832. exports.squirrelly.render = function(str, options, cb) {
  10833. return promisify(cb, function(cb) {
  10834. var engine = requires.squirrelly || (requires.squirrelly = require('squirrelly'));
  10835. try {
  10836. for (var partial in options.partials) {
  10837. engine.definePartial(partial, options.partials[partial]);
  10838. }
  10839. for (var helper in options.helpers) {
  10840. engine.defineHelper(helper, options.helpers[helper]);
  10841. }
  10842. var tmpl = cache(options) || cache(options, engine.Compile(str, options));
  10843. cb(null, tmpl(options, engine));
  10844. } catch (err) {
  10845. cb(err);
  10846. }
  10847. });
  10848. };
  10849. /**
  10850. * Twing support.
  10851. */
  10852. exports.twing = fromStringRenderer('twing');
  10853. /**
  10854. * Twing string support.
  10855. */
  10856. exports.twing.render = function(str, options, cb) {
  10857. return promisify(cb, function(cb) {
  10858. var engine = requires.twing || (requires.twing = require('twing'));
  10859. try {
  10860. new engine.TwingEnvironment(new engine.TwingLoaderNull()).createTemplate(str).then((twingTemplate) => {
  10861. twingTemplate.render(options).then((rendTmpl) => {
  10862. var tmpl = cache(options) || cache(options, rendTmpl);
  10863. cb(null, tmpl);
  10864. });
  10865. });
  10866. } catch (err) {
  10867. cb(err);
  10868. }
  10869. });
  10870. };
  10871. /**
  10872. * expose the instance of the engine
  10873. */
  10874. exports.requires = requires;
  10875. } (consolidate$1, consolidate$1.exports));
  10876. (function (module) {
  10877. module.exports = consolidate$1.exports;
  10878. } (consolidate$2));
  10879. var consolidate = /*@__PURE__*/getDefaultExportFromCjs(consolidate$2.exports);
  10880. let isStaticKey;
  10881. let isPlatformReservedTag$1;
  10882. const genStaticKeysCached = cached(genStaticKeys);
  10883. /**
  10884. * Goal of the optimizer: walk the generated template AST tree
  10885. * and detect sub-trees that are purely static, i.e. parts of
  10886. * the DOM that never needs to change.
  10887. *
  10888. * Once we detect these sub-trees, we can:
  10889. *
  10890. * 1. Hoist them into constants, so that we no longer need to
  10891. * create fresh nodes for them on each re-render;
  10892. * 2. Completely skip them in the patching process.
  10893. */
  10894. function optimize$1(root, options) {
  10895. if (!root)
  10896. return;
  10897. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10898. isPlatformReservedTag$1 = options.isReservedTag || no;
  10899. // first pass: mark all non-static nodes.
  10900. markStatic(root);
  10901. // second pass: mark static roots.
  10902. markStaticRoots(root, false);
  10903. }
  10904. function genStaticKeys(keys) {
  10905. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10906. (keys ? ',' + keys : ''));
  10907. }
  10908. function markStatic(node) {
  10909. node.static = isStatic(node);
  10910. if (node.type === 1) {
  10911. // do not make component slot content static. this avoids
  10912. // 1. components not able to mutate slot nodes
  10913. // 2. static slot content fails for hot-reloading
  10914. if (!isPlatformReservedTag$1(node.tag) &&
  10915. node.tag !== 'slot' &&
  10916. node.attrsMap['inline-template'] == null) {
  10917. return;
  10918. }
  10919. for (let i = 0, l = node.children.length; i < l; i++) {
  10920. const child = node.children[i];
  10921. markStatic(child);
  10922. if (!child.static) {
  10923. node.static = false;
  10924. }
  10925. }
  10926. if (node.ifConditions) {
  10927. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10928. const block = node.ifConditions[i].block;
  10929. markStatic(block);
  10930. if (!block.static) {
  10931. node.static = false;
  10932. }
  10933. }
  10934. }
  10935. }
  10936. }
  10937. function markStaticRoots(node, isInFor) {
  10938. if (node.type === 1) {
  10939. if (node.static || node.once) {
  10940. node.staticInFor = isInFor;
  10941. }
  10942. // For a node to qualify as a static root, it should have children that
  10943. // are not just static text. Otherwise the cost of hoisting out will
  10944. // outweigh the benefits and it's better off to just always render it fresh.
  10945. if (node.static &&
  10946. node.children.length &&
  10947. !(node.children.length === 1 && node.children[0].type === 3)) {
  10948. node.staticRoot = true;
  10949. return;
  10950. }
  10951. else {
  10952. node.staticRoot = false;
  10953. }
  10954. if (node.children) {
  10955. for (let i = 0, l = node.children.length; i < l; i++) {
  10956. markStaticRoots(node.children[i], isInFor || !!node.for);
  10957. }
  10958. }
  10959. if (node.ifConditions) {
  10960. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10961. markStaticRoots(node.ifConditions[i].block, isInFor);
  10962. }
  10963. }
  10964. }
  10965. }
  10966. function isStatic(node) {
  10967. if (node.type === 2) {
  10968. // expression
  10969. return false;
  10970. }
  10971. if (node.type === 3) {
  10972. // text
  10973. return true;
  10974. }
  10975. return !!(node.pre ||
  10976. (!node.hasBindings && // no dynamic bindings
  10977. !node.if &&
  10978. !node.for && // not v-if or v-for or v-else
  10979. !isBuiltInTag(node.tag) && // not a built-in
  10980. isPlatformReservedTag$1(node.tag) && // not a component
  10981. !isDirectChildOfTemplateFor(node) &&
  10982. Object.keys(node).every(isStaticKey)));
  10983. }
  10984. function isDirectChildOfTemplateFor(node) {
  10985. while (node.parent) {
  10986. node = node.parent;
  10987. if (node.tag !== 'template') {
  10988. return false;
  10989. }
  10990. if (node.for) {
  10991. return true;
  10992. }
  10993. }
  10994. return false;
  10995. }
  10996. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10997. const fnInvokeRE = /\([^)]*?\);*$/;
  10998. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10999. // KeyboardEvent.keyCode aliases
  11000. const keyCodes = {
  11001. esc: 27,
  11002. tab: 9,
  11003. enter: 13,
  11004. space: 32,
  11005. up: 38,
  11006. left: 37,
  11007. right: 39,
  11008. down: 40,
  11009. delete: [8, 46]
  11010. };
  11011. // KeyboardEvent.key aliases
  11012. const keyNames = {
  11013. // #7880: IE11 and Edge use `Esc` for Escape key name.
  11014. esc: ['Esc', 'Escape'],
  11015. tab: 'Tab',
  11016. enter: 'Enter',
  11017. // #9112: IE11 uses `Spacebar` for Space key name.
  11018. space: [' ', 'Spacebar'],
  11019. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  11020. up: ['Up', 'ArrowUp'],
  11021. left: ['Left', 'ArrowLeft'],
  11022. right: ['Right', 'ArrowRight'],
  11023. down: ['Down', 'ArrowDown'],
  11024. // #9112: IE11 uses `Del` for Delete key name.
  11025. delete: ['Backspace', 'Delete', 'Del']
  11026. };
  11027. // #4868: modifiers that prevent the execution of the listener
  11028. // need to explicitly return null so that we can determine whether to remove
  11029. // the listener for .once
  11030. const genGuard = condition => `if(${condition})return null;`;
  11031. const modifierCode = {
  11032. stop: '$event.stopPropagation();',
  11033. prevent: '$event.preventDefault();',
  11034. self: genGuard(`$event.target !== $event.currentTarget`),
  11035. ctrl: genGuard(`!$event.ctrlKey`),
  11036. shift: genGuard(`!$event.shiftKey`),
  11037. alt: genGuard(`!$event.altKey`),
  11038. meta: genGuard(`!$event.metaKey`),
  11039. left: genGuard(`'button' in $event && $event.button !== 0`),
  11040. middle: genGuard(`'button' in $event && $event.button !== 1`),
  11041. right: genGuard(`'button' in $event && $event.button !== 2`)
  11042. };
  11043. function genHandlers(events, isNative) {
  11044. const prefix = isNative ? 'nativeOn:' : 'on:';
  11045. let staticHandlers = ``;
  11046. let dynamicHandlers = ``;
  11047. for (const name in events) {
  11048. const handlerCode = genHandler(events[name]);
  11049. //@ts-expect-error
  11050. if (events[name] && events[name].dynamic) {
  11051. dynamicHandlers += `${name},${handlerCode},`;
  11052. }
  11053. else {
  11054. staticHandlers += `"${name}":${handlerCode},`;
  11055. }
  11056. }
  11057. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  11058. if (dynamicHandlers) {
  11059. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  11060. }
  11061. else {
  11062. return prefix + staticHandlers;
  11063. }
  11064. }
  11065. function genHandler(handler) {
  11066. if (!handler) {
  11067. return 'function(){}';
  11068. }
  11069. if (Array.isArray(handler)) {
  11070. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  11071. }
  11072. const isMethodPath = simplePathRE.test(handler.value);
  11073. const isFunctionExpression = fnExpRE.test(handler.value);
  11074. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  11075. if (!handler.modifiers) {
  11076. if (isMethodPath || isFunctionExpression) {
  11077. return handler.value;
  11078. }
  11079. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  11080. }
  11081. else {
  11082. let code = '';
  11083. let genModifierCode = '';
  11084. const keys = [];
  11085. for (const key in handler.modifiers) {
  11086. if (modifierCode[key]) {
  11087. genModifierCode += modifierCode[key];
  11088. // left/right
  11089. if (keyCodes[key]) {
  11090. keys.push(key);
  11091. }
  11092. }
  11093. else if (key === 'exact') {
  11094. const modifiers = handler.modifiers;
  11095. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  11096. .filter(keyModifier => !modifiers[keyModifier])
  11097. .map(keyModifier => `$event.${keyModifier}Key`)
  11098. .join('||'));
  11099. }
  11100. else {
  11101. keys.push(key);
  11102. }
  11103. }
  11104. if (keys.length) {
  11105. code += genKeyFilter(keys);
  11106. }
  11107. // Make sure modifiers like prevent and stop get executed after key filtering
  11108. if (genModifierCode) {
  11109. code += genModifierCode;
  11110. }
  11111. const handlerCode = isMethodPath
  11112. ? `return ${handler.value}.apply(null, arguments)`
  11113. : isFunctionExpression
  11114. ? `return (${handler.value}).apply(null, arguments)`
  11115. : isFunctionInvocation
  11116. ? `return ${handler.value}`
  11117. : handler.value;
  11118. return `function($event){${code}${handlerCode}}`;
  11119. }
  11120. }
  11121. function genKeyFilter(keys) {
  11122. return (
  11123. // make sure the key filters only apply to KeyboardEvents
  11124. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  11125. // key events that do not have keyCode property...
  11126. `if(!$event.type.indexOf('key')&&` +
  11127. `${keys.map(genFilterCode).join('&&')})return null;`);
  11128. }
  11129. function genFilterCode(key) {
  11130. const keyVal = parseInt(key, 10);
  11131. if (keyVal) {
  11132. return `$event.keyCode!==${keyVal}`;
  11133. }
  11134. const keyCode = keyCodes[key];
  11135. const keyName = keyNames[key];
  11136. return (`_k($event.keyCode,` +
  11137. `${JSON.stringify(key)},` +
  11138. `${JSON.stringify(keyCode)},` +
  11139. `$event.key,` +
  11140. `${JSON.stringify(keyName)}` +
  11141. `)`);
  11142. }
  11143. function on(el, dir) {
  11144. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  11145. warn$3(`v-on without argument does not support modifiers.`);
  11146. }
  11147. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  11148. }
  11149. function bind(el, dir) {
  11150. el.wrapData = (code) => {
  11151. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  11152. };
  11153. }
  11154. var baseDirectives = {
  11155. on,
  11156. bind,
  11157. cloak: noop
  11158. };
  11159. class CodegenState {
  11160. constructor(options) {
  11161. this.options = options;
  11162. this.warn = options.warn || baseWarn;
  11163. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  11164. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  11165. this.directives = extend(extend({}, baseDirectives), options.directives);
  11166. const isReservedTag = options.isReservedTag || no;
  11167. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  11168. this.onceId = 0;
  11169. this.staticRenderFns = [];
  11170. this.pre = false;
  11171. }
  11172. }
  11173. function generate$1(ast, options) {
  11174. const state = new CodegenState(options);
  11175. // fix #11483, Root level <script> tags should not be rendered.
  11176. const code = ast
  11177. ? ast.tag === 'script'
  11178. ? 'null'
  11179. : genElement(ast, state)
  11180. : '_c("div")';
  11181. return {
  11182. render: `with(this){return ${code}}`,
  11183. staticRenderFns: state.staticRenderFns
  11184. };
  11185. }
  11186. function genElement(el, state) {
  11187. if (el.parent) {
  11188. el.pre = el.pre || el.parent.pre;
  11189. }
  11190. if (el.staticRoot && !el.staticProcessed) {
  11191. return genStatic(el, state);
  11192. }
  11193. else if (el.once && !el.onceProcessed) {
  11194. return genOnce(el, state);
  11195. }
  11196. else if (el.for && !el.forProcessed) {
  11197. return genFor(el, state);
  11198. }
  11199. else if (el.if && !el.ifProcessed) {
  11200. return genIf(el, state);
  11201. }
  11202. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  11203. return genChildren(el, state) || 'void 0';
  11204. }
  11205. else if (el.tag === 'slot') {
  11206. return genSlot(el, state);
  11207. }
  11208. else {
  11209. // component or element
  11210. let code;
  11211. if (el.component) {
  11212. code = genComponent(el.component, el, state);
  11213. }
  11214. else {
  11215. let data;
  11216. const maybeComponent = state.maybeComponent(el);
  11217. if (!el.plain || (el.pre && maybeComponent)) {
  11218. data = genData(el, state);
  11219. }
  11220. let tag;
  11221. // check if this is a component in <script setup>
  11222. const bindings = state.options.bindings;
  11223. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  11224. tag = checkBindingType(bindings, el.tag);
  11225. }
  11226. if (!tag)
  11227. tag = `'${el.tag}'`;
  11228. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11229. code = `_c(${tag}${data ? `,${data}` : '' // data
  11230. }${children ? `,${children}` : '' // children
  11231. })`;
  11232. }
  11233. // module transforms
  11234. for (let i = 0; i < state.transforms.length; i++) {
  11235. code = state.transforms[i](el, code);
  11236. }
  11237. return code;
  11238. }
  11239. }
  11240. function checkBindingType(bindings, key) {
  11241. const camelName = camelize(key);
  11242. const PascalName = capitalize(camelName);
  11243. const checkType = (type) => {
  11244. if (bindings[key] === type) {
  11245. return key;
  11246. }
  11247. if (bindings[camelName] === type) {
  11248. return camelName;
  11249. }
  11250. if (bindings[PascalName] === type) {
  11251. return PascalName;
  11252. }
  11253. };
  11254. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  11255. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  11256. if (fromConst) {
  11257. return fromConst;
  11258. }
  11259. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  11260. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  11261. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  11262. if (fromMaybeRef) {
  11263. return fromMaybeRef;
  11264. }
  11265. }
  11266. // hoist static sub-trees out
  11267. function genStatic(el, state) {
  11268. el.staticProcessed = true;
  11269. // Some elements (templates) need to behave differently inside of a v-pre
  11270. // node. All pre nodes are static roots, so we can use this as a location to
  11271. // wrap a state change and reset it upon exiting the pre node.
  11272. const originalPreState = state.pre;
  11273. if (el.pre) {
  11274. state.pre = el.pre;
  11275. }
  11276. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  11277. state.pre = originalPreState;
  11278. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  11279. }
  11280. // v-once
  11281. function genOnce(el, state) {
  11282. el.onceProcessed = true;
  11283. if (el.if && !el.ifProcessed) {
  11284. return genIf(el, state);
  11285. }
  11286. else if (el.staticInFor) {
  11287. let key = '';
  11288. let parent = el.parent;
  11289. while (parent) {
  11290. if (parent.for) {
  11291. key = parent.key;
  11292. break;
  11293. }
  11294. parent = parent.parent;
  11295. }
  11296. if (!key) {
  11297. process.env.NODE_ENV !== 'production' &&
  11298. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  11299. return genElement(el, state);
  11300. }
  11301. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  11302. }
  11303. else {
  11304. return genStatic(el, state);
  11305. }
  11306. }
  11307. function genIf(el, state, altGen, altEmpty) {
  11308. el.ifProcessed = true; // avoid recursion
  11309. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  11310. }
  11311. function genIfConditions(conditions, state, altGen, altEmpty) {
  11312. if (!conditions.length) {
  11313. return altEmpty || '_e()';
  11314. }
  11315. const condition = conditions.shift();
  11316. if (condition.exp) {
  11317. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  11318. }
  11319. else {
  11320. return `${genTernaryExp(condition.block)}`;
  11321. }
  11322. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  11323. function genTernaryExp(el) {
  11324. return altGen
  11325. ? altGen(el, state)
  11326. : el.once
  11327. ? genOnce(el, state)
  11328. : genElement(el, state);
  11329. }
  11330. }
  11331. function genFor(el, state, altGen, altHelper) {
  11332. const exp = el.for;
  11333. const alias = el.alias;
  11334. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  11335. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  11336. if (process.env.NODE_ENV !== 'production' &&
  11337. state.maybeComponent(el) &&
  11338. el.tag !== 'slot' &&
  11339. el.tag !== 'template' &&
  11340. !el.key) {
  11341. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  11342. `v-for should have explicit keys. ` +
  11343. `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  11344. }
  11345. el.forProcessed = true; // avoid recursion
  11346. return (`${altHelper || '_l'}((${exp}),` +
  11347. `function(${alias}${iterator1}${iterator2}){` +
  11348. `return ${(altGen || genElement)(el, state)}` +
  11349. '})');
  11350. }
  11351. function genData(el, state) {
  11352. let data = '{';
  11353. // directives first.
  11354. // directives may mutate the el's other properties before they are generated.
  11355. const dirs = genDirectives(el, state);
  11356. if (dirs)
  11357. data += dirs + ',';
  11358. // key
  11359. if (el.key) {
  11360. data += `key:${el.key},`;
  11361. }
  11362. // ref
  11363. if (el.ref) {
  11364. data += `ref:${el.ref},`;
  11365. }
  11366. if (el.refInFor) {
  11367. data += `refInFor:true,`;
  11368. }
  11369. // pre
  11370. if (el.pre) {
  11371. data += `pre:true,`;
  11372. }
  11373. // record original tag name for components using "is" attribute
  11374. if (el.component) {
  11375. data += `tag:"${el.tag}",`;
  11376. }
  11377. // module data generation functions
  11378. for (let i = 0; i < state.dataGenFns.length; i++) {
  11379. data += state.dataGenFns[i](el);
  11380. }
  11381. // attributes
  11382. if (el.attrs) {
  11383. data += `attrs:${genProps(el.attrs)},`;
  11384. }
  11385. // DOM props
  11386. if (el.props) {
  11387. data += `domProps:${genProps(el.props)},`;
  11388. }
  11389. // event handlers
  11390. if (el.events) {
  11391. data += `${genHandlers(el.events, false)},`;
  11392. }
  11393. if (el.nativeEvents) {
  11394. data += `${genHandlers(el.nativeEvents, true)},`;
  11395. }
  11396. // slot target
  11397. // only for non-scoped slots
  11398. if (el.slotTarget && !el.slotScope) {
  11399. data += `slot:${el.slotTarget},`;
  11400. }
  11401. // scoped slots
  11402. if (el.scopedSlots) {
  11403. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  11404. }
  11405. // component v-model
  11406. if (el.model) {
  11407. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  11408. }
  11409. // inline-template
  11410. if (el.inlineTemplate) {
  11411. const inlineTemplate = genInlineTemplate(el, state);
  11412. if (inlineTemplate) {
  11413. data += `${inlineTemplate},`;
  11414. }
  11415. }
  11416. data = data.replace(/,$/, '') + '}';
  11417. // v-bind dynamic argument wrap
  11418. // v-bind with dynamic arguments must be applied using the same v-bind object
  11419. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  11420. if (el.dynamicAttrs) {
  11421. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  11422. }
  11423. // v-bind data wrap
  11424. if (el.wrapData) {
  11425. data = el.wrapData(data);
  11426. }
  11427. // v-on data wrap
  11428. if (el.wrapListeners) {
  11429. data = el.wrapListeners(data);
  11430. }
  11431. return data;
  11432. }
  11433. function genDirectives(el, state) {
  11434. const dirs = el.directives;
  11435. if (!dirs)
  11436. return;
  11437. let res = 'directives:[';
  11438. let hasRuntime = false;
  11439. let i, l, dir, needRuntime;
  11440. for (i = 0, l = dirs.length; i < l; i++) {
  11441. dir = dirs[i];
  11442. needRuntime = true;
  11443. const gen = state.directives[dir.name];
  11444. if (gen) {
  11445. // compile-time directive that manipulates AST.
  11446. // returns true if it also needs a runtime counterpart.
  11447. needRuntime = !!gen(el, dir, state.warn);
  11448. }
  11449. if (needRuntime) {
  11450. hasRuntime = true;
  11451. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11452. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11453. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11454. }
  11455. }
  11456. if (hasRuntime) {
  11457. return res.slice(0, -1) + ']';
  11458. }
  11459. }
  11460. function genInlineTemplate(el, state) {
  11461. const ast = el.children[0];
  11462. if (process.env.NODE_ENV !== 'production' && (el.children.length !== 1 || ast.type !== 1)) {
  11463. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11464. }
  11465. if (ast && ast.type === 1) {
  11466. const inlineRenderFns = generate$1(ast, state.options);
  11467. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11468. .map(code => `function(){${code}}`)
  11469. .join(',')}]}`;
  11470. }
  11471. }
  11472. function genScopedSlots(el, slots, state) {
  11473. // by default scoped slots are considered "stable", this allows child
  11474. // components with only scoped slots to skip forced updates from parent.
  11475. // but in some cases we have to bail-out of this optimization
  11476. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11477. let needsForceUpdate = el.for ||
  11478. Object.keys(slots).some(key => {
  11479. const slot = slots[key];
  11480. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11481. );
  11482. });
  11483. // #9534: if a component with scoped slots is inside a conditional branch,
  11484. // it's possible for the same component to be reused but with different
  11485. // compiled slot content. To avoid that, we generate a unique key based on
  11486. // the generated code of all the slot contents.
  11487. let needsKey = !!el.if;
  11488. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11489. // disconnected due to the intermediate scope variable)
  11490. // #9438, #9506
  11491. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11492. // and skip force updating ones that do not actually use scope variables.
  11493. if (!needsForceUpdate) {
  11494. let parent = el.parent;
  11495. while (parent) {
  11496. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11497. parent.for) {
  11498. needsForceUpdate = true;
  11499. break;
  11500. }
  11501. if (parent.if) {
  11502. needsKey = true;
  11503. }
  11504. parent = parent.parent;
  11505. }
  11506. }
  11507. const generatedSlots = Object.keys(slots)
  11508. .map(key => genScopedSlot(slots[key], state))
  11509. .join(',');
  11510. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11511. }
  11512. function hash(str) {
  11513. let hash = 5381;
  11514. let i = str.length;
  11515. while (i) {
  11516. hash = (hash * 33) ^ str.charCodeAt(--i);
  11517. }
  11518. return hash >>> 0;
  11519. }
  11520. function containsSlotChild(el) {
  11521. if (el.type === 1) {
  11522. if (el.tag === 'slot') {
  11523. return true;
  11524. }
  11525. return el.children.some(containsSlotChild);
  11526. }
  11527. return false;
  11528. }
  11529. function genScopedSlot(el, state) {
  11530. const isLegacySyntax = el.attrsMap['slot-scope'];
  11531. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11532. return genIf(el, state, genScopedSlot, `null`);
  11533. }
  11534. if (el.for && !el.forProcessed) {
  11535. return genFor(el, state, genScopedSlot);
  11536. }
  11537. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11538. const fn = `function(${slotScope}){` +
  11539. `return ${el.tag === 'template'
  11540. ? el.if && isLegacySyntax
  11541. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11542. : genChildren(el, state) || 'undefined'
  11543. : genElement(el, state)}}`;
  11544. // reverse proxy v-slot without scope on this.$slots
  11545. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11546. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11547. }
  11548. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11549. const children = el.children;
  11550. if (children.length) {
  11551. const el = children[0];
  11552. // optimize single v-for
  11553. if (children.length === 1 &&
  11554. el.for &&
  11555. el.tag !== 'template' &&
  11556. el.tag !== 'slot') {
  11557. const normalizationType = checkSkip
  11558. ? state.maybeComponent(el)
  11559. ? `,1`
  11560. : `,0`
  11561. : ``;
  11562. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11563. }
  11564. const normalizationType = checkSkip
  11565. ? getNormalizationType(children, state.maybeComponent)
  11566. : 0;
  11567. const gen = altGenNode || genNode;
  11568. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11569. }
  11570. }
  11571. // determine the normalization needed for the children array.
  11572. // 0: no normalization needed
  11573. // 1: simple normalization needed (possible 1-level deep nested array)
  11574. // 2: full normalization needed
  11575. function getNormalizationType(children, maybeComponent) {
  11576. let res = 0;
  11577. for (let i = 0; i < children.length; i++) {
  11578. const el = children[i];
  11579. if (el.type !== 1) {
  11580. continue;
  11581. }
  11582. if (needsNormalization(el) ||
  11583. (el.ifConditions &&
  11584. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11585. res = 2;
  11586. break;
  11587. }
  11588. if (maybeComponent(el) ||
  11589. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11590. res = 1;
  11591. }
  11592. }
  11593. return res;
  11594. }
  11595. function needsNormalization(el) {
  11596. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11597. }
  11598. function genNode(node, state) {
  11599. if (node.type === 1) {
  11600. return genElement(node, state);
  11601. }
  11602. else if (node.type === 3 && node.isComment) {
  11603. return genComment(node);
  11604. }
  11605. else {
  11606. return genText(node);
  11607. }
  11608. }
  11609. function genText(text) {
  11610. return `_v(${text.type === 2
  11611. ? text.expression // no need for () because already wrapped in _s()
  11612. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11613. }
  11614. function genComment(comment) {
  11615. return `_e(${JSON.stringify(comment.text)})`;
  11616. }
  11617. function genSlot(el, state) {
  11618. const slotName = el.slotName || '"default"';
  11619. const children = genChildren(el, state);
  11620. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11621. const attrs = el.attrs || el.dynamicAttrs
  11622. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11623. // slot props are camelized
  11624. name: camelize(attr.name),
  11625. value: attr.value,
  11626. dynamic: attr.dynamic
  11627. })))
  11628. : null;
  11629. const bind = el.attrsMap['v-bind'];
  11630. if ((attrs || bind) && !children) {
  11631. res += `,null`;
  11632. }
  11633. if (attrs) {
  11634. res += `,${attrs}`;
  11635. }
  11636. if (bind) {
  11637. res += `${attrs ? '' : ',null'},${bind}`;
  11638. }
  11639. return res + ')';
  11640. }
  11641. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11642. function genComponent(componentName, el, state) {
  11643. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11644. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11645. }
  11646. function genProps(props) {
  11647. let staticProps = ``;
  11648. let dynamicProps = ``;
  11649. for (let i = 0; i < props.length; i++) {
  11650. const prop = props[i];
  11651. const value = transformSpecialNewlines(prop.value);
  11652. if (prop.dynamic) {
  11653. dynamicProps += `${prop.name},${value},`;
  11654. }
  11655. else {
  11656. staticProps += `"${prop.name}":${value},`;
  11657. }
  11658. }
  11659. staticProps = `{${staticProps.slice(0, -1)}}`;
  11660. if (dynamicProps) {
  11661. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11662. }
  11663. else {
  11664. return staticProps;
  11665. }
  11666. }
  11667. // #3895, #4268
  11668. function transformSpecialNewlines(text) {
  11669. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11670. }
  11671. // these keywords should not appear inside expressions, but operators like
  11672. // typeof, instanceof and in are allowed
  11673. const prohibitedKeywordRE = new RegExp('\\b' +
  11674. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11675. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11676. 'extends,finally,continue,debugger,function,arguments')
  11677. .split(',')
  11678. .join('\\b|\\b') +
  11679. '\\b');
  11680. // these unary operators should not be used as property/method names
  11681. const unaryOperatorsRE = new RegExp('\\b' +
  11682. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11683. '\\s*\\([^\\)]*\\)');
  11684. // strip strings in expressions
  11685. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11686. // detect problematic expressions in a template
  11687. function detectErrors(ast, warn) {
  11688. if (ast) {
  11689. checkNode(ast, warn);
  11690. }
  11691. }
  11692. function checkNode(node, warn) {
  11693. if (node.type === 1) {
  11694. for (const name in node.attrsMap) {
  11695. if (dirRE.test(name)) {
  11696. const value = node.attrsMap[name];
  11697. if (value) {
  11698. const range = node.rawAttrsMap[name];
  11699. if (name === 'v-for') {
  11700. checkFor(node, `v-for="${value}"`, warn, range);
  11701. }
  11702. else if (name === 'v-slot' || name[0] === '#') {
  11703. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11704. }
  11705. else if (onRE.test(name)) {
  11706. checkEvent(value, `${name}="${value}"`, warn, range);
  11707. }
  11708. else {
  11709. checkExpression(value, `${name}="${value}"`, warn, range);
  11710. }
  11711. }
  11712. }
  11713. }
  11714. if (node.children) {
  11715. for (let i = 0; i < node.children.length; i++) {
  11716. checkNode(node.children[i], warn);
  11717. }
  11718. }
  11719. }
  11720. else if (node.type === 2) {
  11721. checkExpression(node.expression, node.text, warn, node);
  11722. }
  11723. }
  11724. function checkEvent(exp, text, warn, range) {
  11725. const stripped = exp.replace(stripStringRE, '');
  11726. const keywordMatch = stripped.match(unaryOperatorsRE);
  11727. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11728. warn(`avoid using JavaScript unary operator as property name: ` +
  11729. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11730. }
  11731. checkExpression(exp, text, warn, range);
  11732. }
  11733. function checkFor(node, text, warn, range) {
  11734. checkExpression(node.for || '', text, warn, range);
  11735. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11736. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11737. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11738. }
  11739. function checkIdentifier(ident, type, text, warn, range) {
  11740. if (typeof ident === 'string') {
  11741. try {
  11742. new Function(`var ${ident}=_`);
  11743. }
  11744. catch (e) {
  11745. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11746. }
  11747. }
  11748. }
  11749. function checkExpression(exp, text, warn, range) {
  11750. try {
  11751. new Function(`return ${exp}`);
  11752. }
  11753. catch (e) {
  11754. const keywordMatch = exp
  11755. .replace(stripStringRE, '')
  11756. .match(prohibitedKeywordRE);
  11757. if (keywordMatch) {
  11758. warn(`avoid using JavaScript keyword as property name: ` +
  11759. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11760. }
  11761. else {
  11762. warn(`invalid expression: ${e.message} in\n\n` +
  11763. ` ${exp}\n\n` +
  11764. ` Raw expression: ${text.trim()}\n`, range);
  11765. }
  11766. }
  11767. }
  11768. function checkFunctionParameterExpression(exp, text, warn, range) {
  11769. try {
  11770. new Function(exp, '');
  11771. }
  11772. catch (e) {
  11773. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11774. ` ${exp}\n\n` +
  11775. ` Raw expression: ${text.trim()}\n`, range);
  11776. }
  11777. }
  11778. function createFunction(code, errors) {
  11779. try {
  11780. return new Function(code);
  11781. }
  11782. catch (err) {
  11783. errors.push({ err, code });
  11784. return noop;
  11785. }
  11786. }
  11787. function createCompileToFunctionFn(compile) {
  11788. const cache = Object.create(null);
  11789. return function compileToFunctions(template, options, vm) {
  11790. options = extend({}, options);
  11791. const warn = options.warn || warn$3;
  11792. delete options.warn;
  11793. /* istanbul ignore if */
  11794. if (process.env.NODE_ENV !== 'production') {
  11795. // detect possible CSP restriction
  11796. try {
  11797. new Function('return 1');
  11798. }
  11799. catch (e) {
  11800. if (e.toString().match(/unsafe-eval|CSP/)) {
  11801. warn('It seems you are using the standalone build of Vue.js in an ' +
  11802. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11803. 'The template compiler cannot work in this environment. Consider ' +
  11804. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11805. 'templates into render functions.');
  11806. }
  11807. }
  11808. }
  11809. // check cache
  11810. const key = options.delimiters
  11811. ? String(options.delimiters) + template
  11812. : template;
  11813. if (cache[key]) {
  11814. return cache[key];
  11815. }
  11816. // compile
  11817. const compiled = compile(template, options);
  11818. // check compilation errors/tips
  11819. if (process.env.NODE_ENV !== 'production') {
  11820. if (compiled.errors && compiled.errors.length) {
  11821. if (options.outputSourceRange) {
  11822. compiled.errors.forEach(e => {
  11823. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11824. generateCodeFrame(template, e.start, e.end), vm);
  11825. });
  11826. }
  11827. else {
  11828. warn(`Error compiling template:\n\n${template}\n\n` +
  11829. compiled.errors.map(e => `- ${e}`).join('\n') +
  11830. '\n', vm);
  11831. }
  11832. }
  11833. if (compiled.tips && compiled.tips.length) {
  11834. if (options.outputSourceRange) {
  11835. compiled.tips.forEach(e => tip(e.msg, vm));
  11836. }
  11837. else {
  11838. compiled.tips.forEach(msg => tip(msg, vm));
  11839. }
  11840. }
  11841. }
  11842. // turn code into functions
  11843. const res = {};
  11844. const fnGenErrors = [];
  11845. res.render = createFunction(compiled.render, fnGenErrors);
  11846. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11847. return createFunction(code, fnGenErrors);
  11848. });
  11849. // check function generation errors.
  11850. // this should only happen if there is a bug in the compiler itself.
  11851. // mostly for codegen development use
  11852. /* istanbul ignore if */
  11853. if (process.env.NODE_ENV !== 'production') {
  11854. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11855. warn(`Failed to generate render function:\n\n` +
  11856. fnGenErrors
  11857. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11858. .join('\n'), vm);
  11859. }
  11860. }
  11861. return (cache[key] = res);
  11862. };
  11863. }
  11864. function createCompilerCreator(baseCompile) {
  11865. return function createCompiler(baseOptions) {
  11866. function compile(template, options) {
  11867. const finalOptions = Object.create(baseOptions);
  11868. const errors = [];
  11869. const tips = [];
  11870. let warn = (msg, range, tip) => {
  11871. (tip ? tips : errors).push(msg);
  11872. };
  11873. if (options) {
  11874. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  11875. // $flow-disable-line
  11876. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11877. warn = (msg, range, tip) => {
  11878. const data = typeof msg === 'string' ? { msg } : msg;
  11879. if (range) {
  11880. if (range.start != null) {
  11881. data.start = range.start + leadingSpaceLength;
  11882. }
  11883. if (range.end != null) {
  11884. data.end = range.end + leadingSpaceLength;
  11885. }
  11886. }
  11887. (tip ? tips : errors).push(data);
  11888. };
  11889. }
  11890. // merge custom modules
  11891. if (options.modules) {
  11892. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11893. }
  11894. // merge custom directives
  11895. if (options.directives) {
  11896. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11897. }
  11898. // copy other options
  11899. for (const key in options) {
  11900. if (key !== 'modules' && key !== 'directives') {
  11901. finalOptions[key] = options[key];
  11902. }
  11903. }
  11904. }
  11905. finalOptions.warn = warn;
  11906. const compiled = baseCompile(template.trim(), finalOptions);
  11907. if (process.env.NODE_ENV !== 'production') {
  11908. detectErrors(compiled.ast, warn);
  11909. }
  11910. compiled.errors = errors;
  11911. compiled.tips = tips;
  11912. return compiled;
  11913. }
  11914. return {
  11915. compile,
  11916. compileToFunctions: createCompileToFunctionFn(compile)
  11917. };
  11918. };
  11919. }
  11920. // `createCompilerCreator` allows creating compilers that use alternative
  11921. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11922. // Here we just export a default compiler using the default parts.
  11923. const createCompiler$1 = createCompilerCreator(function baseCompile(template, options) {
  11924. const ast = parse$1(template.trim(), options);
  11925. if (options.optimize !== false) {
  11926. optimize$1(ast, options);
  11927. }
  11928. const code = generate$1(ast, options);
  11929. return {
  11930. ast,
  11931. render: code.render,
  11932. staticRenderFns: code.staticRenderFns
  11933. };
  11934. });
  11935. const { compile: compile$1, compileToFunctions: compileToFunctions$1 } = createCompiler$1(baseOptions);
  11936. const isAttr = makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  11937. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  11938. 'checked,cite,class,code,codebase,color,cols,colspan,content,' +
  11939. 'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  11940. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
  11941. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  11942. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  11943. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  11944. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  11945. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  11946. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  11947. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  11948. 'target,title,usemap,value,width,wrap');
  11949. /* istanbul ignore next */
  11950. const isRenderableAttr = (name) => {
  11951. return (isAttr(name) || name.indexOf('data-') === 0 || name.indexOf('aria-') === 0);
  11952. };
  11953. const propsToAttrMap = {
  11954. acceptCharset: 'accept-charset',
  11955. className: 'class',
  11956. htmlFor: 'for',
  11957. httpEquiv: 'http-equiv'
  11958. };
  11959. const ESC = {
  11960. '<': '&lt;',
  11961. '>': '&gt;',
  11962. '"': '&quot;',
  11963. '&': '&amp;'
  11964. };
  11965. function escape(s) {
  11966. return s.replace(/[<>"&]/g, escapeChar);
  11967. }
  11968. function escapeChar(a) {
  11969. return ESC[a] || a;
  11970. }
  11971. const plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  11972. // let the model AST transform translate v-model into appropriate
  11973. // props bindings
  11974. function applyModelTransform(el, state) {
  11975. if (el.directives) {
  11976. for (let i = 0; i < el.directives.length; i++) {
  11977. const dir = el.directives[i];
  11978. if (dir.name === 'model') {
  11979. state.directives.model(el, dir, state.warn);
  11980. // remove value for textarea as its converted to text
  11981. if (el.tag === 'textarea' && el.props) {
  11982. el.props = el.props.filter(p => p.name !== 'value');
  11983. }
  11984. break;
  11985. }
  11986. }
  11987. }
  11988. }
  11989. function genAttrSegments(attrs) {
  11990. return attrs.map(({ name, value }) => genAttrSegment(name, value));
  11991. }
  11992. function genDOMPropSegments(props, attrs) {
  11993. const segments = [];
  11994. props.forEach(({ name, value }) => {
  11995. name = propsToAttrMap[name] || name.toLowerCase();
  11996. if (isRenderableAttr(name) &&
  11997. !(attrs && attrs.some(a => a.name === name))) {
  11998. segments.push(genAttrSegment(name, value));
  11999. }
  12000. });
  12001. return segments;
  12002. }
  12003. function genAttrSegment(name, value) {
  12004. if (plainStringRE.test(value)) {
  12005. // force double quote
  12006. value = value.replace(/^'|'$/g, '"');
  12007. // force enumerated attr to "true"
  12008. if (isEnumeratedAttr(name) && value !== `"false"`) {
  12009. value = `"true"`;
  12010. }
  12011. return {
  12012. type: RAW,
  12013. value: isBooleanAttr(name)
  12014. ? ` ${name}="${name}"`
  12015. : value === '""'
  12016. ? ` ${name}`
  12017. : ` ${name}="${JSON.parse(value)}"`
  12018. };
  12019. }
  12020. else {
  12021. return {
  12022. type: EXPRESSION,
  12023. value: `_ssrAttr(${JSON.stringify(name)},${value})`
  12024. };
  12025. }
  12026. }
  12027. function genClassSegments(staticClass, classBinding) {
  12028. if (staticClass && !classBinding) {
  12029. return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }];
  12030. }
  12031. else {
  12032. return [
  12033. {
  12034. type: EXPRESSION,
  12035. value: `_ssrClass(${staticClass || 'null'},${classBinding || 'null'})`
  12036. }
  12037. ];
  12038. }
  12039. }
  12040. function genStyleSegments(staticStyle, parsedStaticStyle, styleBinding, vShowExpression) {
  12041. if (staticStyle && !styleBinding && !vShowExpression) {
  12042. return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle)}` }];
  12043. }
  12044. else {
  12045. return [
  12046. {
  12047. type: EXPRESSION,
  12048. value: `_ssrStyle(${parsedStaticStyle || 'null'},${styleBinding || 'null'}, ${vShowExpression
  12049. ? `{ display: (${vShowExpression}) ? '' : 'none' }`
  12050. : 'null'})`
  12051. }
  12052. ];
  12053. }
  12054. }
  12055. /**
  12056. * In SSR, the vdom tree is generated only once and never patched, so
  12057. * we can optimize most element / trees into plain string render functions.
  12058. * The SSR optimizer walks the AST tree to detect optimizable elements and trees.
  12059. *
  12060. * The criteria for SSR optimizability is quite a bit looser than static tree
  12061. * detection (which is designed for client re-render). In SSR we bail only for
  12062. * components/slots/custom directives.
  12063. */
  12064. // optimizability constants
  12065. const optimizability = {
  12066. FALSE: 0,
  12067. FULL: 1,
  12068. SELF: 2,
  12069. CHILDREN: 3,
  12070. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  12071. };
  12072. let isPlatformReservedTag;
  12073. function optimize(root, options) {
  12074. if (!root)
  12075. return;
  12076. isPlatformReservedTag = options.isReservedTag || no;
  12077. walk(root, true);
  12078. }
  12079. function walk(node, isRoot) {
  12080. if (isUnOptimizableTree(node)) {
  12081. node.ssrOptimizability = optimizability.FALSE;
  12082. return;
  12083. }
  12084. // root node or nodes with custom directives should always be a VNode
  12085. const selfUnoptimizable = isRoot || hasCustomDirective(node);
  12086. const check = child => {
  12087. if (child.ssrOptimizability !== optimizability.FULL) {
  12088. node.ssrOptimizability = selfUnoptimizable
  12089. ? optimizability.PARTIAL
  12090. : optimizability.SELF;
  12091. }
  12092. };
  12093. if (selfUnoptimizable) {
  12094. node.ssrOptimizability = optimizability.CHILDREN;
  12095. }
  12096. if (node.type === 1) {
  12097. for (let i = 0, l = node.children.length; i < l; i++) {
  12098. const child = node.children[i];
  12099. walk(child);
  12100. check(child);
  12101. }
  12102. if (node.ifConditions) {
  12103. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  12104. const block = node.ifConditions[i].block;
  12105. walk(block, isRoot);
  12106. check(block);
  12107. }
  12108. }
  12109. if (node.ssrOptimizability == null ||
  12110. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))) {
  12111. node.ssrOptimizability = optimizability.FULL;
  12112. }
  12113. else {
  12114. node.children = optimizeSiblings(node);
  12115. }
  12116. }
  12117. else {
  12118. node.ssrOptimizability = optimizability.FULL;
  12119. }
  12120. }
  12121. function optimizeSiblings(el) {
  12122. const children = el.children;
  12123. const optimizedChildren = [];
  12124. let currentOptimizableGroup = [];
  12125. const pushGroup = () => {
  12126. if (currentOptimizableGroup.length) {
  12127. optimizedChildren.push({
  12128. type: 1,
  12129. parent: el,
  12130. tag: 'template',
  12131. attrsList: [],
  12132. attrsMap: {},
  12133. rawAttrsMap: {},
  12134. children: currentOptimizableGroup,
  12135. ssrOptimizability: optimizability.FULL
  12136. });
  12137. }
  12138. currentOptimizableGroup = [];
  12139. };
  12140. for (let i = 0; i < children.length; i++) {
  12141. const c = children[i];
  12142. if (c.ssrOptimizability === optimizability.FULL) {
  12143. currentOptimizableGroup.push(c);
  12144. }
  12145. else {
  12146. // wrap fully-optimizable adjacent siblings inside a template tag
  12147. // so that they can be optimized into a single ssrNode by codegen
  12148. pushGroup();
  12149. optimizedChildren.push(c);
  12150. }
  12151. }
  12152. pushGroup();
  12153. return optimizedChildren;
  12154. }
  12155. function isUnOptimizableTree(node) {
  12156. if (node.type === 2 || node.type === 3) {
  12157. // text or expression
  12158. return false;
  12159. }
  12160. return (isBuiltInTag(node.tag) || // built-in (slot, component)
  12161. !isPlatformReservedTag(node.tag) || // custom component
  12162. !!node.component || // "is" component
  12163. isSelectWithModel(node) // <select v-model> requires runtime inspection
  12164. );
  12165. }
  12166. const isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  12167. function hasCustomDirective(node) {
  12168. return (node.type === 1 &&
  12169. node.directives &&
  12170. node.directives.some(d => !isBuiltInDir(d.name)));
  12171. }
  12172. // <select v-model> cannot be optimized because it requires a runtime check
  12173. // to determine proper selected option
  12174. function isSelectWithModel(node) {
  12175. return (node.type === 1 &&
  12176. node.tag === 'select' &&
  12177. node.directives != null &&
  12178. node.directives.some(d => d.name === 'model'));
  12179. }
  12180. // The SSR codegen is essentially extending the default codegen to handle
  12181. // segment types
  12182. const RAW = 0;
  12183. const INTERPOLATION = 1;
  12184. const EXPRESSION = 2;
  12185. function generate(ast, options) {
  12186. const state = new CodegenState(options);
  12187. const code = ast ? genSSRElement(ast, state) : '_c("div")';
  12188. return {
  12189. render: `with(this){return ${code}}`,
  12190. staticRenderFns: state.staticRenderFns
  12191. };
  12192. }
  12193. function genSSRElement(el, state) {
  12194. if (el.for && !el.forProcessed) {
  12195. return genFor(el, state, genSSRElement);
  12196. }
  12197. else if (el.if && !el.ifProcessed) {
  12198. return genIf(el, state, genSSRElement);
  12199. }
  12200. else if (el.tag === 'template' && !el.slotTarget) {
  12201. return el.ssrOptimizability === optimizability.FULL
  12202. ? genChildrenAsStringNode(el, state)
  12203. : genSSRChildren(el, state) || 'void 0';
  12204. }
  12205. switch (el.ssrOptimizability) {
  12206. case optimizability.FULL:
  12207. // stringify whole tree
  12208. return genStringElement(el, state);
  12209. case optimizability.SELF:
  12210. // stringify self and check children
  12211. return genStringElementWithChildren(el, state);
  12212. case optimizability.CHILDREN:
  12213. // generate self as VNode and stringify children
  12214. return genNormalElement(el, state, true);
  12215. case optimizability.PARTIAL:
  12216. // generate self as VNode and check children
  12217. return genNormalElement(el, state, false);
  12218. default:
  12219. // bail whole tree
  12220. return genElement(el, state);
  12221. }
  12222. }
  12223. function genNormalElement(el, state, stringifyChildren) {
  12224. const data = el.plain ? undefined : genData(el, state);
  12225. const children = stringifyChildren
  12226. ? `[${genChildrenAsStringNode(el, state)}]`
  12227. : genSSRChildren(el, state, true);
  12228. return `_c('${el.tag}'${data ? `,${data}` : ''}${children ? `,${children}` : ''})`;
  12229. }
  12230. function genSSRChildren(el, state, checkSkip) {
  12231. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode);
  12232. }
  12233. function genSSRNode(el, state) {
  12234. return el.type === 1 ? genSSRElement(el, state) : genText(el);
  12235. }
  12236. function genChildrenAsStringNode(el, state) {
  12237. return el.children.length
  12238. ? `_ssrNode(${flattenSegments(childrenToSegments(el, state))})`
  12239. : '';
  12240. }
  12241. function genStringElement(el, state) {
  12242. return `_ssrNode(${elementToString(el, state)})`;
  12243. }
  12244. function genStringElementWithChildren(el, state) {
  12245. const children = genSSRChildren(el, state, true);
  12246. return `_ssrNode(${flattenSegments(elementToOpenTagSegments(el, state))},"</${el.tag}>"${children ? `,${children}` : ''})`;
  12247. }
  12248. function elementToString(el, state) {
  12249. return `(${flattenSegments(elementToSegments(el, state))})`;
  12250. }
  12251. function elementToSegments(el, state) {
  12252. // v-for / v-if
  12253. if (el.for && !el.forProcessed) {
  12254. el.forProcessed = true;
  12255. return [
  12256. {
  12257. type: EXPRESSION,
  12258. value: genFor(el, state, elementToString, '_ssrList')
  12259. }
  12260. ];
  12261. }
  12262. else if (el.if && !el.ifProcessed) {
  12263. el.ifProcessed = true;
  12264. return [
  12265. {
  12266. type: EXPRESSION,
  12267. value: genIf(el, state, elementToString, '"<!---->"')
  12268. }
  12269. ];
  12270. }
  12271. else if (el.tag === 'template') {
  12272. return childrenToSegments(el, state);
  12273. }
  12274. const openSegments = elementToOpenTagSegments(el, state);
  12275. const childrenSegments = childrenToSegments(el, state);
  12276. const { isUnaryTag } = state.options;
  12277. const close = isUnaryTag && isUnaryTag(el.tag)
  12278. ? []
  12279. : [{ type: RAW, value: `</${el.tag}>` }];
  12280. return openSegments.concat(childrenSegments, close);
  12281. }
  12282. function elementToOpenTagSegments(el, state) {
  12283. applyModelTransform(el, state);
  12284. let binding;
  12285. const segments = [{ type: RAW, value: `<${el.tag}` }];
  12286. // attrs
  12287. if (el.attrs) {
  12288. segments.push.apply(segments, genAttrSegments(el.attrs));
  12289. }
  12290. // domProps
  12291. if (el.props) {
  12292. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  12293. }
  12294. // v-bind="object"
  12295. if ((binding = el.attrsMap['v-bind'])) {
  12296. segments.push({ type: EXPRESSION, value: `_ssrAttrs(${binding})` });
  12297. }
  12298. // v-bind.prop="object"
  12299. if ((binding = el.attrsMap['v-bind.prop'])) {
  12300. segments.push({ type: EXPRESSION, value: `_ssrDOMProps(${binding})` });
  12301. }
  12302. // class
  12303. if (el.staticClass || el.classBinding) {
  12304. segments.push.apply(segments, genClassSegments(el.staticClass, el.classBinding));
  12305. }
  12306. // style & v-show
  12307. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  12308. segments.push.apply(segments, genStyleSegments(el.attrsMap.style, el.staticStyle, el.styleBinding, el.attrsMap['v-show']));
  12309. }
  12310. // _scopedId
  12311. if (state.options.scopeId) {
  12312. segments.push({ type: RAW, value: ` ${state.options.scopeId}` });
  12313. }
  12314. segments.push({ type: RAW, value: `>` });
  12315. return segments;
  12316. }
  12317. function childrenToSegments(el, state) {
  12318. let binding;
  12319. if ((binding = el.attrsMap['v-html'])) {
  12320. return [{ type: EXPRESSION, value: `_s(${binding})` }];
  12321. }
  12322. if ((binding = el.attrsMap['v-text'])) {
  12323. return [{ type: INTERPOLATION, value: `_s(${binding})` }];
  12324. }
  12325. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  12326. return [{ type: INTERPOLATION, value: `_s(${binding})` }];
  12327. }
  12328. return el.children ? nodesToSegments(el.children, state) : [];
  12329. }
  12330. function nodesToSegments(children, state) {
  12331. const segments = [];
  12332. for (let i = 0; i < children.length; i++) {
  12333. const c = children[i];
  12334. if (c.type === 1) {
  12335. segments.push.apply(segments, elementToSegments(c, state));
  12336. }
  12337. else if (c.type === 2) {
  12338. segments.push({ type: INTERPOLATION, value: c.expression });
  12339. }
  12340. else if (c.type === 3) {
  12341. let text = escape(c.text);
  12342. if (c.isComment) {
  12343. text = '<!--' + text + '-->';
  12344. }
  12345. segments.push({ type: RAW, value: text });
  12346. }
  12347. }
  12348. return segments;
  12349. }
  12350. function flattenSegments(segments) {
  12351. const mergedSegments = [];
  12352. let textBuffer = '';
  12353. const pushBuffer = () => {
  12354. if (textBuffer) {
  12355. mergedSegments.push(JSON.stringify(textBuffer));
  12356. textBuffer = '';
  12357. }
  12358. };
  12359. for (let i = 0; i < segments.length; i++) {
  12360. const s = segments[i];
  12361. if (s.type === RAW) {
  12362. textBuffer += s.value;
  12363. }
  12364. else if (s.type === INTERPOLATION) {
  12365. pushBuffer();
  12366. mergedSegments.push(`_ssrEscape(${s.value})`);
  12367. }
  12368. else if (s.type === EXPRESSION) {
  12369. pushBuffer();
  12370. mergedSegments.push(`(${s.value})`);
  12371. }
  12372. }
  12373. pushBuffer();
  12374. return mergedSegments.join('+');
  12375. }
  12376. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  12377. const ast = parse$1(template.trim(), options);
  12378. optimize(ast, options);
  12379. const code = generate(ast, options);
  12380. return {
  12381. ast,
  12382. render: code.render,
  12383. staticRenderFns: code.staticRenderFns
  12384. };
  12385. });
  12386. const { compile, compileToFunctions } = createCompiler(baseOptions);
  12387. var _compiler = /*#__PURE__*/Object.freeze({
  12388. __proto__: null,
  12389. parseComponent: parseComponent,
  12390. compile: compile$1,
  12391. compileToFunctions: compileToFunctions$1,
  12392. ssrCompile: compile,
  12393. ssrCompileToFunctions: compileToFunctions,
  12394. generateCodeFrame: generateCodeFrame
  12395. });
  12396. function compileTemplate(options) {
  12397. const { preprocessLang } = options;
  12398. const preprocessor = preprocessLang && consolidate[preprocessLang];
  12399. if (preprocessor) {
  12400. return actuallyCompile(Object.assign({}, options, {
  12401. source: preprocess$1(options, preprocessor)
  12402. }));
  12403. }
  12404. else if (preprocessLang) {
  12405. return {
  12406. ast: {},
  12407. code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
  12408. source: options.source,
  12409. tips: [
  12410. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  12411. ],
  12412. errors: [
  12413. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  12414. ]
  12415. };
  12416. }
  12417. else {
  12418. return actuallyCompile(options);
  12419. }
  12420. }
  12421. function preprocess$1(options, preprocessor) {
  12422. const { source, filename, preprocessOptions } = options;
  12423. const finalPreprocessOptions = Object.assign({
  12424. filename
  12425. }, preprocessOptions);
  12426. // Consolidate exposes a callback based API, but the callback is in fact
  12427. // called synchronously for most templating engines. In our case, we have to
  12428. // expose a synchronous API so that it is usable in Jest transforms (which
  12429. // have to be sync because they are applied via Node.js require hooks)
  12430. let res, err;
  12431. preprocessor.render(source, finalPreprocessOptions, (_err, _res) => {
  12432. if (_err)
  12433. err = _err;
  12434. res = _res;
  12435. });
  12436. if (err)
  12437. throw err;
  12438. return res;
  12439. }
  12440. function actuallyCompile(options) {
  12441. const { source, compiler = _compiler, compilerOptions = {}, transpileOptions = {}, transformAssetUrls, transformAssetUrlsOptions, isProduction = process.env.NODE_ENV === 'production', isFunctional = false, optimizeSSR = false, prettify = true, isTS = false, bindings } = options;
  12442. const compile = optimizeSSR && compiler.ssrCompile ? compiler.ssrCompile : compiler.compile;
  12443. let finalCompilerOptions = compilerOptions;
  12444. if (transformAssetUrls) {
  12445. const builtInModules = [
  12446. transformAssetUrls === true
  12447. ? assetUrlsModule(undefined, transformAssetUrlsOptions)
  12448. : assetUrlsModule(transformAssetUrls, transformAssetUrlsOptions),
  12449. srcsetModule(transformAssetUrlsOptions)
  12450. ];
  12451. finalCompilerOptions = Object.assign({}, compilerOptions, {
  12452. modules: [...builtInModules, ...(compilerOptions.modules || [])],
  12453. filename: options.filename
  12454. });
  12455. }
  12456. finalCompilerOptions.bindings = bindings;
  12457. const { ast, render, staticRenderFns, tips, errors } = compile(source, finalCompilerOptions);
  12458. if (errors && errors.length) {
  12459. return {
  12460. ast,
  12461. code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
  12462. source,
  12463. tips,
  12464. errors
  12465. };
  12466. }
  12467. else {
  12468. // stripping `with` usage
  12469. let code = `var __render__ = ${prefixIdentifiers(`function render(${isFunctional ? `_c,_vm` : ``}){${render}\n}`, isFunctional, isTS, transpileOptions, bindings)}\n` +
  12470. `var __staticRenderFns__ = [${staticRenderFns.map(code => prefixIdentifiers(`function (${isFunctional ? `_c,_vm` : ``}){${code}\n}`, isFunctional, isTS, transpileOptions, bindings))}]` +
  12471. `\n`;
  12472. // #23 we use __render__ to avoid `render` not being prefixed by the
  12473. // transpiler when stripping with, but revert it back to `render` to
  12474. // maintain backwards compat
  12475. code = code.replace(/\s__(render|staticRenderFns)__\s/g, ' $1 ');
  12476. if (!isProduction) {
  12477. // mark with stripped (this enables Vue to use correct runtime proxy
  12478. // detection)
  12479. code += `render._withStripped = true`;
  12480. if (prettify) {
  12481. try {
  12482. code = require('prettier').format(code, {
  12483. semi: false,
  12484. parser: 'babel'
  12485. });
  12486. }
  12487. catch (e) {
  12488. if (e.code === 'MODULE_NOT_FOUND') {
  12489. tips.push('The `prettify` option is on, but the dependency `prettier` is not found.\n' +
  12490. 'Please either turn off `prettify` or manually install `prettier`.');
  12491. }
  12492. tips.push(`Failed to prettify component ${options.filename} template source after compilation.`);
  12493. }
  12494. }
  12495. }
  12496. return {
  12497. ast,
  12498. code,
  12499. source,
  12500. tips,
  12501. errors
  12502. };
  12503. }
  12504. }
  12505. const trimPlugin = () => {
  12506. return {
  12507. postcssPlugin: 'vue-sfc-trim',
  12508. Once(root) {
  12509. root.walk(({ type, raws }) => {
  12510. if (type === 'rule' || type === 'atrule') {
  12511. if (raws.before)
  12512. raws.before = '\n';
  12513. if ('after' in raws && raws.after)
  12514. raws.after = '\n';
  12515. }
  12516. });
  12517. }
  12518. };
  12519. };
  12520. trimPlugin.postcss = true;
  12521. var dist = {exports: {}};
  12522. var processor = {exports: {}};
  12523. var parser = {exports: {}};
  12524. var root$1 = {exports: {}};
  12525. var container = {exports: {}};
  12526. var node$1 = {exports: {}};
  12527. var util = {};
  12528. var unesc = {exports: {}};
  12529. (function (module, exports) {
  12530. exports.__esModule = true;
  12531. exports["default"] = unesc;
  12532. // Many thanks for this post which made this migration much easier.
  12533. // https://mathiasbynens.be/notes/css-escapes
  12534. /**
  12535. *
  12536. * @param {string} str
  12537. * @returns {[string, number]|undefined}
  12538. */
  12539. function gobbleHex(str) {
  12540. var lower = str.toLowerCase();
  12541. var hex = '';
  12542. var spaceTerminated = false;
  12543. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  12544. var code = lower.charCodeAt(i);
  12545. // check to see if we are dealing with a valid hex char [a-f|0-9]
  12546. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  12547. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  12548. spaceTerminated = code === 32;
  12549. if (!valid) {
  12550. break;
  12551. }
  12552. hex += lower[i];
  12553. }
  12554. if (hex.length === 0) {
  12555. return undefined;
  12556. }
  12557. var codePoint = parseInt(hex, 16);
  12558. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  12559. // Add special case for
  12560. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  12561. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  12562. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  12563. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  12564. }
  12565. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  12566. }
  12567. var CONTAINS_ESCAPE = /\\/;
  12568. function unesc(str) {
  12569. var needToProcess = CONTAINS_ESCAPE.test(str);
  12570. if (!needToProcess) {
  12571. return str;
  12572. }
  12573. var ret = "";
  12574. for (var i = 0; i < str.length; i++) {
  12575. if (str[i] === "\\") {
  12576. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  12577. if (gobbled !== undefined) {
  12578. ret += gobbled[0];
  12579. i += gobbled[1];
  12580. continue;
  12581. }
  12582. // Retain a pair of \\ if double escaped `\\\\`
  12583. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  12584. if (str[i + 1] === "\\") {
  12585. ret += "\\";
  12586. i++;
  12587. continue;
  12588. }
  12589. // if \\ is at the end of the string retain it
  12590. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  12591. if (str.length === i + 1) {
  12592. ret += str[i];
  12593. }
  12594. continue;
  12595. }
  12596. ret += str[i];
  12597. }
  12598. return ret;
  12599. }
  12600. module.exports = exports.default;
  12601. } (unesc, unesc.exports));
  12602. var getProp = {exports: {}};
  12603. (function (module, exports) {
  12604. exports.__esModule = true;
  12605. exports["default"] = getProp;
  12606. function getProp(obj) {
  12607. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12608. props[_key - 1] = arguments[_key];
  12609. }
  12610. while (props.length > 0) {
  12611. var prop = props.shift();
  12612. if (!obj[prop]) {
  12613. return undefined;
  12614. }
  12615. obj = obj[prop];
  12616. }
  12617. return obj;
  12618. }
  12619. module.exports = exports.default;
  12620. } (getProp, getProp.exports));
  12621. var ensureObject = {exports: {}};
  12622. (function (module, exports) {
  12623. exports.__esModule = true;
  12624. exports["default"] = ensureObject;
  12625. function ensureObject(obj) {
  12626. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12627. props[_key - 1] = arguments[_key];
  12628. }
  12629. while (props.length > 0) {
  12630. var prop = props.shift();
  12631. if (!obj[prop]) {
  12632. obj[prop] = {};
  12633. }
  12634. obj = obj[prop];
  12635. }
  12636. }
  12637. module.exports = exports.default;
  12638. } (ensureObject, ensureObject.exports));
  12639. var stripComments = {exports: {}};
  12640. (function (module, exports) {
  12641. exports.__esModule = true;
  12642. exports["default"] = stripComments;
  12643. function stripComments(str) {
  12644. var s = "";
  12645. var commentStart = str.indexOf("/*");
  12646. var lastEnd = 0;
  12647. while (commentStart >= 0) {
  12648. s = s + str.slice(lastEnd, commentStart);
  12649. var commentEnd = str.indexOf("*/", commentStart + 2);
  12650. if (commentEnd < 0) {
  12651. return s;
  12652. }
  12653. lastEnd = commentEnd + 2;
  12654. commentStart = str.indexOf("/*", lastEnd);
  12655. }
  12656. s = s + str.slice(lastEnd);
  12657. return s;
  12658. }
  12659. module.exports = exports.default;
  12660. } (stripComments, stripComments.exports));
  12661. util.__esModule = true;
  12662. util.unesc = util.stripComments = util.getProp = util.ensureObject = void 0;
  12663. var _unesc = _interopRequireDefault$1(unesc.exports);
  12664. util.unesc = _unesc["default"];
  12665. var _getProp = _interopRequireDefault$1(getProp.exports);
  12666. util.getProp = _getProp["default"];
  12667. var _ensureObject = _interopRequireDefault$1(ensureObject.exports);
  12668. util.ensureObject = _ensureObject["default"];
  12669. var _stripComments = _interopRequireDefault$1(stripComments.exports);
  12670. util.stripComments = _stripComments["default"];
  12671. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12672. (function (module, exports) {
  12673. exports.__esModule = true;
  12674. exports["default"] = void 0;
  12675. var _util = util;
  12676. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12677. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  12678. var cloneNode = function cloneNode(obj, parent) {
  12679. if (typeof obj !== 'object' || obj === null) {
  12680. return obj;
  12681. }
  12682. var cloned = new obj.constructor();
  12683. for (var i in obj) {
  12684. if (!obj.hasOwnProperty(i)) {
  12685. continue;
  12686. }
  12687. var value = obj[i];
  12688. var type = typeof value;
  12689. if (i === 'parent' && type === 'object') {
  12690. if (parent) {
  12691. cloned[i] = parent;
  12692. }
  12693. } else if (value instanceof Array) {
  12694. cloned[i] = value.map(function (j) {
  12695. return cloneNode(j, cloned);
  12696. });
  12697. } else {
  12698. cloned[i] = cloneNode(value, cloned);
  12699. }
  12700. }
  12701. return cloned;
  12702. };
  12703. var Node = /*#__PURE__*/function () {
  12704. function Node(opts) {
  12705. if (opts === void 0) {
  12706. opts = {};
  12707. }
  12708. Object.assign(this, opts);
  12709. this.spaces = this.spaces || {};
  12710. this.spaces.before = this.spaces.before || '';
  12711. this.spaces.after = this.spaces.after || '';
  12712. }
  12713. var _proto = Node.prototype;
  12714. _proto.remove = function remove() {
  12715. if (this.parent) {
  12716. this.parent.removeChild(this);
  12717. }
  12718. this.parent = undefined;
  12719. return this;
  12720. };
  12721. _proto.replaceWith = function replaceWith() {
  12722. if (this.parent) {
  12723. for (var index in arguments) {
  12724. this.parent.insertBefore(this, arguments[index]);
  12725. }
  12726. this.remove();
  12727. }
  12728. return this;
  12729. };
  12730. _proto.next = function next() {
  12731. return this.parent.at(this.parent.index(this) + 1);
  12732. };
  12733. _proto.prev = function prev() {
  12734. return this.parent.at(this.parent.index(this) - 1);
  12735. };
  12736. _proto.clone = function clone(overrides) {
  12737. if (overrides === void 0) {
  12738. overrides = {};
  12739. }
  12740. var cloned = cloneNode(this);
  12741. for (var name in overrides) {
  12742. cloned[name] = overrides[name];
  12743. }
  12744. return cloned;
  12745. }
  12746. /**
  12747. * Some non-standard syntax doesn't follow normal escaping rules for css.
  12748. * This allows non standard syntax to be appended to an existing property
  12749. * by specifying the escaped value. By specifying the escaped value,
  12750. * illegal characters are allowed to be directly inserted into css output.
  12751. * @param {string} name the property to set
  12752. * @param {any} value the unescaped value of the property
  12753. * @param {string} valueEscaped optional. the escaped value of the property.
  12754. */;
  12755. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  12756. if (!this.raws) {
  12757. this.raws = {};
  12758. }
  12759. var originalValue = this[name];
  12760. var originalEscaped = this.raws[name];
  12761. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  12762. if (originalEscaped || valueEscaped !== value) {
  12763. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  12764. } else {
  12765. delete this.raws[name]; // delete any escaped value that was created by the setter.
  12766. }
  12767. }
  12768. /**
  12769. * Some non-standard syntax doesn't follow normal escaping rules for css.
  12770. * This allows the escaped value to be specified directly, allowing illegal
  12771. * characters to be directly inserted into css output.
  12772. * @param {string} name the property to set
  12773. * @param {any} value the unescaped value of the property
  12774. * @param {string} valueEscaped the escaped value of the property.
  12775. */;
  12776. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  12777. if (!this.raws) {
  12778. this.raws = {};
  12779. }
  12780. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  12781. this.raws[name] = valueEscaped;
  12782. }
  12783. /**
  12784. * When you want a value to passed through to CSS directly. This method
  12785. * deletes the corresponding raw value causing the stringifier to fallback
  12786. * to the unescaped value.
  12787. * @param {string} name the property to set.
  12788. * @param {any} value The value that is both escaped and unescaped.
  12789. */;
  12790. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  12791. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  12792. if (this.raws) {
  12793. delete this.raws[name];
  12794. }
  12795. }
  12796. /**
  12797. *
  12798. * @param {number} line The number (starting with 1)
  12799. * @param {number} column The column number (starting with 1)
  12800. */;
  12801. _proto.isAtPosition = function isAtPosition(line, column) {
  12802. if (this.source && this.source.start && this.source.end) {
  12803. if (this.source.start.line > line) {
  12804. return false;
  12805. }
  12806. if (this.source.end.line < line) {
  12807. return false;
  12808. }
  12809. if (this.source.start.line === line && this.source.start.column > column) {
  12810. return false;
  12811. }
  12812. if (this.source.end.line === line && this.source.end.column < column) {
  12813. return false;
  12814. }
  12815. return true;
  12816. }
  12817. return undefined;
  12818. };
  12819. _proto.stringifyProperty = function stringifyProperty(name) {
  12820. return this.raws && this.raws[name] || this[name];
  12821. };
  12822. _proto.valueToString = function valueToString() {
  12823. return String(this.stringifyProperty("value"));
  12824. };
  12825. _proto.toString = function toString() {
  12826. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  12827. };
  12828. _createClass(Node, [{
  12829. key: "rawSpaceBefore",
  12830. get: function get() {
  12831. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  12832. if (rawSpace === undefined) {
  12833. rawSpace = this.spaces && this.spaces.before;
  12834. }
  12835. return rawSpace || "";
  12836. },
  12837. set: function set(raw) {
  12838. (0, _util.ensureObject)(this, "raws", "spaces");
  12839. this.raws.spaces.before = raw;
  12840. }
  12841. }, {
  12842. key: "rawSpaceAfter",
  12843. get: function get() {
  12844. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  12845. if (rawSpace === undefined) {
  12846. rawSpace = this.spaces.after;
  12847. }
  12848. return rawSpace || "";
  12849. },
  12850. set: function set(raw) {
  12851. (0, _util.ensureObject)(this, "raws", "spaces");
  12852. this.raws.spaces.after = raw;
  12853. }
  12854. }]);
  12855. return Node;
  12856. }();
  12857. exports["default"] = Node;
  12858. module.exports = exports.default;
  12859. } (node$1, node$1.exports));
  12860. var types = {};
  12861. types.__esModule = true;
  12862. types.UNIVERSAL = types.TAG = types.STRING = types.SELECTOR = types.ROOT = types.PSEUDO = types.NESTING = types.ID = types.COMMENT = types.COMBINATOR = types.CLASS = types.ATTRIBUTE = void 0;
  12863. var TAG = 'tag';
  12864. types.TAG = TAG;
  12865. var STRING = 'string';
  12866. types.STRING = STRING;
  12867. var SELECTOR = 'selector';
  12868. types.SELECTOR = SELECTOR;
  12869. var ROOT = 'root';
  12870. types.ROOT = ROOT;
  12871. var PSEUDO = 'pseudo';
  12872. types.PSEUDO = PSEUDO;
  12873. var NESTING = 'nesting';
  12874. types.NESTING = NESTING;
  12875. var ID = 'id';
  12876. types.ID = ID;
  12877. var COMMENT = 'comment';
  12878. types.COMMENT = COMMENT;
  12879. var COMBINATOR = 'combinator';
  12880. types.COMBINATOR = COMBINATOR;
  12881. var CLASS = 'class';
  12882. types.CLASS = CLASS;
  12883. var ATTRIBUTE = 'attribute';
  12884. types.ATTRIBUTE = ATTRIBUTE;
  12885. var UNIVERSAL = 'universal';
  12886. types.UNIVERSAL = UNIVERSAL;
  12887. (function (module, exports) {
  12888. exports.__esModule = true;
  12889. exports["default"] = void 0;
  12890. var _node = _interopRequireDefault(node$1.exports);
  12891. var types$1 = _interopRequireWildcard(types);
  12892. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  12893. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  12894. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12895. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  12896. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12897. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12898. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12899. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  12900. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  12901. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12902. var Container = /*#__PURE__*/function (_Node) {
  12903. _inheritsLoose(Container, _Node);
  12904. function Container(opts) {
  12905. var _this;
  12906. _this = _Node.call(this, opts) || this;
  12907. if (!_this.nodes) {
  12908. _this.nodes = [];
  12909. }
  12910. return _this;
  12911. }
  12912. var _proto = Container.prototype;
  12913. _proto.append = function append(selector) {
  12914. selector.parent = this;
  12915. this.nodes.push(selector);
  12916. return this;
  12917. };
  12918. _proto.prepend = function prepend(selector) {
  12919. selector.parent = this;
  12920. this.nodes.unshift(selector);
  12921. return this;
  12922. };
  12923. _proto.at = function at(index) {
  12924. return this.nodes[index];
  12925. };
  12926. _proto.index = function index(child) {
  12927. if (typeof child === 'number') {
  12928. return child;
  12929. }
  12930. return this.nodes.indexOf(child);
  12931. };
  12932. _proto.removeChild = function removeChild(child) {
  12933. child = this.index(child);
  12934. this.at(child).parent = undefined;
  12935. this.nodes.splice(child, 1);
  12936. var index;
  12937. for (var id in this.indexes) {
  12938. index = this.indexes[id];
  12939. if (index >= child) {
  12940. this.indexes[id] = index - 1;
  12941. }
  12942. }
  12943. return this;
  12944. };
  12945. _proto.removeAll = function removeAll() {
  12946. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  12947. var node = _step.value;
  12948. node.parent = undefined;
  12949. }
  12950. this.nodes = [];
  12951. return this;
  12952. };
  12953. _proto.empty = function empty() {
  12954. return this.removeAll();
  12955. };
  12956. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  12957. newNode.parent = this;
  12958. var oldIndex = this.index(oldNode);
  12959. this.nodes.splice(oldIndex + 1, 0, newNode);
  12960. newNode.parent = this;
  12961. var index;
  12962. for (var id in this.indexes) {
  12963. index = this.indexes[id];
  12964. if (oldIndex <= index) {
  12965. this.indexes[id] = index + 1;
  12966. }
  12967. }
  12968. return this;
  12969. };
  12970. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  12971. newNode.parent = this;
  12972. var oldIndex = this.index(oldNode);
  12973. this.nodes.splice(oldIndex, 0, newNode);
  12974. newNode.parent = this;
  12975. var index;
  12976. for (var id in this.indexes) {
  12977. index = this.indexes[id];
  12978. if (index <= oldIndex) {
  12979. this.indexes[id] = index + 1;
  12980. }
  12981. }
  12982. return this;
  12983. };
  12984. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  12985. var found = undefined;
  12986. this.each(function (node) {
  12987. if (node.atPosition) {
  12988. var foundChild = node.atPosition(line, col);
  12989. if (foundChild) {
  12990. found = foundChild;
  12991. return false;
  12992. }
  12993. } else if (node.isAtPosition(line, col)) {
  12994. found = node;
  12995. return false;
  12996. }
  12997. });
  12998. return found;
  12999. }
  13000. /**
  13001. * Return the most specific node at the line and column number given.
  13002. * The source location is based on the original parsed location, locations aren't
  13003. * updated as selector nodes are mutated.
  13004. *
  13005. * Note that this location is relative to the location of the first character
  13006. * of the selector, and not the location of the selector in the overall document
  13007. * when used in conjunction with postcss.
  13008. *
  13009. * If not found, returns undefined.
  13010. * @param {number} line The line number of the node to find. (1-based index)
  13011. * @param {number} col The column number of the node to find. (1-based index)
  13012. */;
  13013. _proto.atPosition = function atPosition(line, col) {
  13014. if (this.isAtPosition(line, col)) {
  13015. return this._findChildAtPosition(line, col) || this;
  13016. } else {
  13017. return undefined;
  13018. }
  13019. };
  13020. _proto._inferEndPosition = function _inferEndPosition() {
  13021. if (this.last && this.last.source && this.last.source.end) {
  13022. this.source = this.source || {};
  13023. this.source.end = this.source.end || {};
  13024. Object.assign(this.source.end, this.last.source.end);
  13025. }
  13026. };
  13027. _proto.each = function each(callback) {
  13028. if (!this.lastEach) {
  13029. this.lastEach = 0;
  13030. }
  13031. if (!this.indexes) {
  13032. this.indexes = {};
  13033. }
  13034. this.lastEach++;
  13035. var id = this.lastEach;
  13036. this.indexes[id] = 0;
  13037. if (!this.length) {
  13038. return undefined;
  13039. }
  13040. var index, result;
  13041. while (this.indexes[id] < this.length) {
  13042. index = this.indexes[id];
  13043. result = callback(this.at(index), index);
  13044. if (result === false) {
  13045. break;
  13046. }
  13047. this.indexes[id] += 1;
  13048. }
  13049. delete this.indexes[id];
  13050. if (result === false) {
  13051. return false;
  13052. }
  13053. };
  13054. _proto.walk = function walk(callback) {
  13055. return this.each(function (node, i) {
  13056. var result = callback(node, i);
  13057. if (result !== false && node.length) {
  13058. result = node.walk(callback);
  13059. }
  13060. if (result === false) {
  13061. return false;
  13062. }
  13063. });
  13064. };
  13065. _proto.walkAttributes = function walkAttributes(callback) {
  13066. var _this2 = this;
  13067. return this.walk(function (selector) {
  13068. if (selector.type === types$1.ATTRIBUTE) {
  13069. return callback.call(_this2, selector);
  13070. }
  13071. });
  13072. };
  13073. _proto.walkClasses = function walkClasses(callback) {
  13074. var _this3 = this;
  13075. return this.walk(function (selector) {
  13076. if (selector.type === types$1.CLASS) {
  13077. return callback.call(_this3, selector);
  13078. }
  13079. });
  13080. };
  13081. _proto.walkCombinators = function walkCombinators(callback) {
  13082. var _this4 = this;
  13083. return this.walk(function (selector) {
  13084. if (selector.type === types$1.COMBINATOR) {
  13085. return callback.call(_this4, selector);
  13086. }
  13087. });
  13088. };
  13089. _proto.walkComments = function walkComments(callback) {
  13090. var _this5 = this;
  13091. return this.walk(function (selector) {
  13092. if (selector.type === types$1.COMMENT) {
  13093. return callback.call(_this5, selector);
  13094. }
  13095. });
  13096. };
  13097. _proto.walkIds = function walkIds(callback) {
  13098. var _this6 = this;
  13099. return this.walk(function (selector) {
  13100. if (selector.type === types$1.ID) {
  13101. return callback.call(_this6, selector);
  13102. }
  13103. });
  13104. };
  13105. _proto.walkNesting = function walkNesting(callback) {
  13106. var _this7 = this;
  13107. return this.walk(function (selector) {
  13108. if (selector.type === types$1.NESTING) {
  13109. return callback.call(_this7, selector);
  13110. }
  13111. });
  13112. };
  13113. _proto.walkPseudos = function walkPseudos(callback) {
  13114. var _this8 = this;
  13115. return this.walk(function (selector) {
  13116. if (selector.type === types$1.PSEUDO) {
  13117. return callback.call(_this8, selector);
  13118. }
  13119. });
  13120. };
  13121. _proto.walkTags = function walkTags(callback) {
  13122. var _this9 = this;
  13123. return this.walk(function (selector) {
  13124. if (selector.type === types$1.TAG) {
  13125. return callback.call(_this9, selector);
  13126. }
  13127. });
  13128. };
  13129. _proto.walkUniversals = function walkUniversals(callback) {
  13130. var _this10 = this;
  13131. return this.walk(function (selector) {
  13132. if (selector.type === types$1.UNIVERSAL) {
  13133. return callback.call(_this10, selector);
  13134. }
  13135. });
  13136. };
  13137. _proto.split = function split(callback) {
  13138. var _this11 = this;
  13139. var current = [];
  13140. return this.reduce(function (memo, node, index) {
  13141. var split = callback.call(_this11, node);
  13142. current.push(node);
  13143. if (split) {
  13144. memo.push(current);
  13145. current = [];
  13146. } else if (index === _this11.length - 1) {
  13147. memo.push(current);
  13148. }
  13149. return memo;
  13150. }, []);
  13151. };
  13152. _proto.map = function map(callback) {
  13153. return this.nodes.map(callback);
  13154. };
  13155. _proto.reduce = function reduce(callback, memo) {
  13156. return this.nodes.reduce(callback, memo);
  13157. };
  13158. _proto.every = function every(callback) {
  13159. return this.nodes.every(callback);
  13160. };
  13161. _proto.some = function some(callback) {
  13162. return this.nodes.some(callback);
  13163. };
  13164. _proto.filter = function filter(callback) {
  13165. return this.nodes.filter(callback);
  13166. };
  13167. _proto.sort = function sort(callback) {
  13168. return this.nodes.sort(callback);
  13169. };
  13170. _proto.toString = function toString() {
  13171. return this.map(String).join('');
  13172. };
  13173. _createClass(Container, [{
  13174. key: "first",
  13175. get: function get() {
  13176. return this.at(0);
  13177. }
  13178. }, {
  13179. key: "last",
  13180. get: function get() {
  13181. return this.at(this.length - 1);
  13182. }
  13183. }, {
  13184. key: "length",
  13185. get: function get() {
  13186. return this.nodes.length;
  13187. }
  13188. }]);
  13189. return Container;
  13190. }(_node["default"]);
  13191. exports["default"] = Container;
  13192. module.exports = exports.default;
  13193. } (container, container.exports));
  13194. (function (module, exports) {
  13195. exports.__esModule = true;
  13196. exports["default"] = void 0;
  13197. var _container = _interopRequireDefault(container.exports);
  13198. var _types = types;
  13199. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13200. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13201. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  13202. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13203. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13204. var Root = /*#__PURE__*/function (_Container) {
  13205. _inheritsLoose(Root, _Container);
  13206. function Root(opts) {
  13207. var _this;
  13208. _this = _Container.call(this, opts) || this;
  13209. _this.type = _types.ROOT;
  13210. return _this;
  13211. }
  13212. var _proto = Root.prototype;
  13213. _proto.toString = function toString() {
  13214. var str = this.reduce(function (memo, selector) {
  13215. memo.push(String(selector));
  13216. return memo;
  13217. }, []).join(',');
  13218. return this.trailingComma ? str + ',' : str;
  13219. };
  13220. _proto.error = function error(message, options) {
  13221. if (this._error) {
  13222. return this._error(message, options);
  13223. } else {
  13224. return new Error(message);
  13225. }
  13226. };
  13227. _createClass(Root, [{
  13228. key: "errorGenerator",
  13229. set: function set(handler) {
  13230. this._error = handler;
  13231. }
  13232. }]);
  13233. return Root;
  13234. }(_container["default"]);
  13235. exports["default"] = Root;
  13236. module.exports = exports.default;
  13237. } (root$1, root$1.exports));
  13238. var selector$1 = {exports: {}};
  13239. (function (module, exports) {
  13240. exports.__esModule = true;
  13241. exports["default"] = void 0;
  13242. var _container = _interopRequireDefault(container.exports);
  13243. var _types = types;
  13244. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13245. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13246. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13247. var Selector = /*#__PURE__*/function (_Container) {
  13248. _inheritsLoose(Selector, _Container);
  13249. function Selector(opts) {
  13250. var _this;
  13251. _this = _Container.call(this, opts) || this;
  13252. _this.type = _types.SELECTOR;
  13253. return _this;
  13254. }
  13255. return Selector;
  13256. }(_container["default"]);
  13257. exports["default"] = Selector;
  13258. module.exports = exports.default;
  13259. } (selector$1, selector$1.exports));
  13260. var className$1 = {exports: {}};
  13261. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  13262. var object = {};
  13263. var hasOwnProperty = object.hasOwnProperty;
  13264. var merge$1 = function merge(options, defaults) {
  13265. if (!options) {
  13266. return defaults;
  13267. }
  13268. var result = {};
  13269. for (var key in defaults) {
  13270. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  13271. // only recognized option names are used.
  13272. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  13273. }
  13274. return result;
  13275. };
  13276. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  13277. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  13278. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  13279. // https://mathiasbynens.be/notes/css-escapes#css
  13280. var cssesc = function cssesc(string, options) {
  13281. options = merge$1(options, cssesc.options);
  13282. if (options.quotes != 'single' && options.quotes != 'double') {
  13283. options.quotes = 'single';
  13284. }
  13285. var quote = options.quotes == 'double' ? '"' : '\'';
  13286. var isIdentifier = options.isIdentifier;
  13287. var firstChar = string.charAt(0);
  13288. var output = '';
  13289. var counter = 0;
  13290. var length = string.length;
  13291. while (counter < length) {
  13292. var character = string.charAt(counter++);
  13293. var codePoint = character.charCodeAt();
  13294. var value = void 0;
  13295. // If it’s not a printable ASCII character…
  13296. if (codePoint < 0x20 || codePoint > 0x7E) {
  13297. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  13298. // It’s a high surrogate, and there is a next character.
  13299. var extra = string.charCodeAt(counter++);
  13300. if ((extra & 0xFC00) == 0xDC00) {
  13301. // next character is low surrogate
  13302. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  13303. } else {
  13304. // It’s an unmatched surrogate; only append this code unit, in case
  13305. // the next code unit is the high surrogate of a surrogate pair.
  13306. counter--;
  13307. }
  13308. }
  13309. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13310. } else {
  13311. if (options.escapeEverything) {
  13312. if (regexAnySingleEscape.test(character)) {
  13313. value = '\\' + character;
  13314. } else {
  13315. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13316. }
  13317. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  13318. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13319. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  13320. value = '\\' + character;
  13321. } else {
  13322. value = character;
  13323. }
  13324. }
  13325. output += value;
  13326. }
  13327. if (isIdentifier) {
  13328. if (/^-[-\d]/.test(output)) {
  13329. output = '\\-' + output.slice(1);
  13330. } else if (/\d/.test(firstChar)) {
  13331. output = '\\3' + firstChar + ' ' + output.slice(1);
  13332. }
  13333. }
  13334. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  13335. // since they’re redundant. Note that this is only possible if the escape
  13336. // sequence isn’t preceded by an odd number of backslashes.
  13337. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  13338. if ($1 && $1.length % 2) {
  13339. // It’s not safe to remove the space, so don’t.
  13340. return $0;
  13341. }
  13342. // Strip the space.
  13343. return ($1 || '') + $2;
  13344. });
  13345. if (!isIdentifier && options.wrap) {
  13346. return quote + output + quote;
  13347. }
  13348. return output;
  13349. };
  13350. // Expose default options (so they can be overridden globally).
  13351. cssesc.options = {
  13352. 'escapeEverything': false,
  13353. 'isIdentifier': false,
  13354. 'quotes': 'single',
  13355. 'wrap': false
  13356. };
  13357. cssesc.version = '3.0.0';
  13358. var cssesc_1 = cssesc;
  13359. (function (module, exports) {
  13360. exports.__esModule = true;
  13361. exports["default"] = void 0;
  13362. var _cssesc = _interopRequireDefault(cssesc_1);
  13363. var _util = util;
  13364. var _node = _interopRequireDefault(node$1.exports);
  13365. var _types = types;
  13366. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13367. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13368. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  13369. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13370. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13371. var ClassName = /*#__PURE__*/function (_Node) {
  13372. _inheritsLoose(ClassName, _Node);
  13373. function ClassName(opts) {
  13374. var _this;
  13375. _this = _Node.call(this, opts) || this;
  13376. _this.type = _types.CLASS;
  13377. _this._constructed = true;
  13378. return _this;
  13379. }
  13380. var _proto = ClassName.prototype;
  13381. _proto.valueToString = function valueToString() {
  13382. return '.' + _Node.prototype.valueToString.call(this);
  13383. };
  13384. _createClass(ClassName, [{
  13385. key: "value",
  13386. get: function get() {
  13387. return this._value;
  13388. },
  13389. set: function set(v) {
  13390. if (this._constructed) {
  13391. var escaped = (0, _cssesc["default"])(v, {
  13392. isIdentifier: true
  13393. });
  13394. if (escaped !== v) {
  13395. (0, _util.ensureObject)(this, "raws");
  13396. this.raws.value = escaped;
  13397. } else if (this.raws) {
  13398. delete this.raws.value;
  13399. }
  13400. }
  13401. this._value = v;
  13402. }
  13403. }]);
  13404. return ClassName;
  13405. }(_node["default"]);
  13406. exports["default"] = ClassName;
  13407. module.exports = exports.default;
  13408. } (className$1, className$1.exports));
  13409. var comment$2 = {exports: {}};
  13410. (function (module, exports) {
  13411. exports.__esModule = true;
  13412. exports["default"] = void 0;
  13413. var _node = _interopRequireDefault(node$1.exports);
  13414. var _types = types;
  13415. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13416. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13417. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13418. var Comment = /*#__PURE__*/function (_Node) {
  13419. _inheritsLoose(Comment, _Node);
  13420. function Comment(opts) {
  13421. var _this;
  13422. _this = _Node.call(this, opts) || this;
  13423. _this.type = _types.COMMENT;
  13424. return _this;
  13425. }
  13426. return Comment;
  13427. }(_node["default"]);
  13428. exports["default"] = Comment;
  13429. module.exports = exports.default;
  13430. } (comment$2, comment$2.exports));
  13431. var id$1 = {exports: {}};
  13432. (function (module, exports) {
  13433. exports.__esModule = true;
  13434. exports["default"] = void 0;
  13435. var _node = _interopRequireDefault(node$1.exports);
  13436. var _types = types;
  13437. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13438. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13439. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13440. var ID = /*#__PURE__*/function (_Node) {
  13441. _inheritsLoose(ID, _Node);
  13442. function ID(opts) {
  13443. var _this;
  13444. _this = _Node.call(this, opts) || this;
  13445. _this.type = _types.ID;
  13446. return _this;
  13447. }
  13448. var _proto = ID.prototype;
  13449. _proto.valueToString = function valueToString() {
  13450. return '#' + _Node.prototype.valueToString.call(this);
  13451. };
  13452. return ID;
  13453. }(_node["default"]);
  13454. exports["default"] = ID;
  13455. module.exports = exports.default;
  13456. } (id$1, id$1.exports));
  13457. var tag$1 = {exports: {}};
  13458. var namespace = {exports: {}};
  13459. (function (module, exports) {
  13460. exports.__esModule = true;
  13461. exports["default"] = void 0;
  13462. var _cssesc = _interopRequireDefault(cssesc_1);
  13463. var _util = util;
  13464. var _node = _interopRequireDefault(node$1.exports);
  13465. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13466. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13467. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  13468. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13469. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13470. var Namespace = /*#__PURE__*/function (_Node) {
  13471. _inheritsLoose(Namespace, _Node);
  13472. function Namespace() {
  13473. return _Node.apply(this, arguments) || this;
  13474. }
  13475. var _proto = Namespace.prototype;
  13476. _proto.qualifiedName = function qualifiedName(value) {
  13477. if (this.namespace) {
  13478. return this.namespaceString + "|" + value;
  13479. } else {
  13480. return value;
  13481. }
  13482. };
  13483. _proto.valueToString = function valueToString() {
  13484. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  13485. };
  13486. _createClass(Namespace, [{
  13487. key: "namespace",
  13488. get: function get() {
  13489. return this._namespace;
  13490. },
  13491. set: function set(namespace) {
  13492. if (namespace === true || namespace === "*" || namespace === "&") {
  13493. this._namespace = namespace;
  13494. if (this.raws) {
  13495. delete this.raws.namespace;
  13496. }
  13497. return;
  13498. }
  13499. var escaped = (0, _cssesc["default"])(namespace, {
  13500. isIdentifier: true
  13501. });
  13502. this._namespace = namespace;
  13503. if (escaped !== namespace) {
  13504. (0, _util.ensureObject)(this, "raws");
  13505. this.raws.namespace = escaped;
  13506. } else if (this.raws) {
  13507. delete this.raws.namespace;
  13508. }
  13509. }
  13510. }, {
  13511. key: "ns",
  13512. get: function get() {
  13513. return this._namespace;
  13514. },
  13515. set: function set(namespace) {
  13516. this.namespace = namespace;
  13517. }
  13518. }, {
  13519. key: "namespaceString",
  13520. get: function get() {
  13521. if (this.namespace) {
  13522. var ns = this.stringifyProperty("namespace");
  13523. if (ns === true) {
  13524. return '';
  13525. } else {
  13526. return ns;
  13527. }
  13528. } else {
  13529. return '';
  13530. }
  13531. }
  13532. }]);
  13533. return Namespace;
  13534. }(_node["default"]);
  13535. exports["default"] = Namespace;
  13536. module.exports = exports.default;
  13537. } (namespace, namespace.exports));
  13538. (function (module, exports) {
  13539. exports.__esModule = true;
  13540. exports["default"] = void 0;
  13541. var _namespace = _interopRequireDefault(namespace.exports);
  13542. var _types = types;
  13543. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13544. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13545. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13546. var Tag = /*#__PURE__*/function (_Namespace) {
  13547. _inheritsLoose(Tag, _Namespace);
  13548. function Tag(opts) {
  13549. var _this;
  13550. _this = _Namespace.call(this, opts) || this;
  13551. _this.type = _types.TAG;
  13552. return _this;
  13553. }
  13554. return Tag;
  13555. }(_namespace["default"]);
  13556. exports["default"] = Tag;
  13557. module.exports = exports.default;
  13558. } (tag$1, tag$1.exports));
  13559. var string$1 = {exports: {}};
  13560. (function (module, exports) {
  13561. exports.__esModule = true;
  13562. exports["default"] = void 0;
  13563. var _node = _interopRequireDefault(node$1.exports);
  13564. var _types = types;
  13565. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13566. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13567. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13568. var String = /*#__PURE__*/function (_Node) {
  13569. _inheritsLoose(String, _Node);
  13570. function String(opts) {
  13571. var _this;
  13572. _this = _Node.call(this, opts) || this;
  13573. _this.type = _types.STRING;
  13574. return _this;
  13575. }
  13576. return String;
  13577. }(_node["default"]);
  13578. exports["default"] = String;
  13579. module.exports = exports.default;
  13580. } (string$1, string$1.exports));
  13581. var pseudo$1 = {exports: {}};
  13582. (function (module, exports) {
  13583. exports.__esModule = true;
  13584. exports["default"] = void 0;
  13585. var _container = _interopRequireDefault(container.exports);
  13586. var _types = types;
  13587. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13588. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13589. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13590. var Pseudo = /*#__PURE__*/function (_Container) {
  13591. _inheritsLoose(Pseudo, _Container);
  13592. function Pseudo(opts) {
  13593. var _this;
  13594. _this = _Container.call(this, opts) || this;
  13595. _this.type = _types.PSEUDO;
  13596. return _this;
  13597. }
  13598. var _proto = Pseudo.prototype;
  13599. _proto.toString = function toString() {
  13600. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  13601. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  13602. };
  13603. return Pseudo;
  13604. }(_container["default"]);
  13605. exports["default"] = Pseudo;
  13606. module.exports = exports.default;
  13607. } (pseudo$1, pseudo$1.exports));
  13608. var attribute$1 = {};
  13609. /**
  13610. * For Node.js, simply re-export the core `util.deprecate` function.
  13611. */
  13612. var node = require$$2__default["default"].deprecate;
  13613. (function (exports) {
  13614. exports.__esModule = true;
  13615. exports["default"] = void 0;
  13616. exports.unescapeValue = unescapeValue;
  13617. var _cssesc = _interopRequireDefault(cssesc_1);
  13618. var _unesc = _interopRequireDefault(unesc.exports);
  13619. var _namespace = _interopRequireDefault(namespace.exports);
  13620. var _types = types;
  13621. var _CSSESC_QUOTE_OPTIONS;
  13622. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13623. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13624. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  13625. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13626. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13627. var deprecate = node;
  13628. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  13629. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  13630. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  13631. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  13632. function unescapeValue(value) {
  13633. var deprecatedUsage = false;
  13634. var quoteMark = null;
  13635. var unescaped = value;
  13636. var m = unescaped.match(WRAPPED_IN_QUOTES);
  13637. if (m) {
  13638. quoteMark = m[1];
  13639. unescaped = m[2];
  13640. }
  13641. unescaped = (0, _unesc["default"])(unescaped);
  13642. if (unescaped !== value) {
  13643. deprecatedUsage = true;
  13644. }
  13645. return {
  13646. deprecatedUsage: deprecatedUsage,
  13647. unescaped: unescaped,
  13648. quoteMark: quoteMark
  13649. };
  13650. }
  13651. function handleDeprecatedContructorOpts(opts) {
  13652. if (opts.quoteMark !== undefined) {
  13653. return opts;
  13654. }
  13655. if (opts.value === undefined) {
  13656. return opts;
  13657. }
  13658. warnOfDeprecatedConstructor();
  13659. var _unescapeValue = unescapeValue(opts.value),
  13660. quoteMark = _unescapeValue.quoteMark,
  13661. unescaped = _unescapeValue.unescaped;
  13662. if (!opts.raws) {
  13663. opts.raws = {};
  13664. }
  13665. if (opts.raws.value === undefined) {
  13666. opts.raws.value = opts.value;
  13667. }
  13668. opts.value = unescaped;
  13669. opts.quoteMark = quoteMark;
  13670. return opts;
  13671. }
  13672. var Attribute = /*#__PURE__*/function (_Namespace) {
  13673. _inheritsLoose(Attribute, _Namespace);
  13674. function Attribute(opts) {
  13675. var _this;
  13676. if (opts === void 0) {
  13677. opts = {};
  13678. }
  13679. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  13680. _this.type = _types.ATTRIBUTE;
  13681. _this.raws = _this.raws || {};
  13682. Object.defineProperty(_this.raws, 'unquoted', {
  13683. get: deprecate(function () {
  13684. return _this.value;
  13685. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  13686. set: deprecate(function () {
  13687. return _this.value;
  13688. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  13689. });
  13690. _this._constructed = true;
  13691. return _this;
  13692. }
  13693. /**
  13694. * Returns the Attribute's value quoted such that it would be legal to use
  13695. * in the value of a css file. The original value's quotation setting
  13696. * used for stringification is left unchanged. See `setValue(value, options)`
  13697. * if you want to control the quote settings of a new value for the attribute.
  13698. *
  13699. * You can also change the quotation used for the current value by setting quoteMark.
  13700. *
  13701. * Options:
  13702. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  13703. * option is not set, the original value for quoteMark will be used. If
  13704. * indeterminate, a double quote is used. The legal values are:
  13705. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  13706. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  13707. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  13708. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  13709. * over the quoteMark option value.
  13710. * * smart {boolean} - if true, will select a quote mark based on the value
  13711. * and the other options specified here. See the `smartQuoteMark()`
  13712. * method.
  13713. **/
  13714. var _proto = Attribute.prototype;
  13715. _proto.getQuotedValue = function getQuotedValue(options) {
  13716. if (options === void 0) {
  13717. options = {};
  13718. }
  13719. var quoteMark = this._determineQuoteMark(options);
  13720. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  13721. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  13722. return escaped;
  13723. };
  13724. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  13725. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  13726. }
  13727. /**
  13728. * Set the unescaped value with the specified quotation options. The value
  13729. * provided must not include any wrapping quote marks -- those quotes will
  13730. * be interpreted as part of the value and escaped accordingly.
  13731. */;
  13732. _proto.setValue = function setValue(value, options) {
  13733. if (options === void 0) {
  13734. options = {};
  13735. }
  13736. this._value = value;
  13737. this._quoteMark = this._determineQuoteMark(options);
  13738. this._syncRawValue();
  13739. }
  13740. /**
  13741. * Intelligently select a quoteMark value based on the value's contents. If
  13742. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  13743. * mark will be picked that minimizes the number of escapes.
  13744. *
  13745. * If there's no clear winner, the quote mark from these options is used,
  13746. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  13747. * true). If the quoteMark is unspecified, a double quote is used.
  13748. *
  13749. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  13750. * from the quoteValue method.
  13751. */;
  13752. _proto.smartQuoteMark = function smartQuoteMark(options) {
  13753. var v = this.value;
  13754. var numSingleQuotes = v.replace(/[^']/g, '').length;
  13755. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  13756. if (numSingleQuotes + numDoubleQuotes === 0) {
  13757. var escaped = (0, _cssesc["default"])(v, {
  13758. isIdentifier: true
  13759. });
  13760. if (escaped === v) {
  13761. return Attribute.NO_QUOTE;
  13762. } else {
  13763. var pref = this.preferredQuoteMark(options);
  13764. if (pref === Attribute.NO_QUOTE) {
  13765. // pick a quote mark that isn't none and see if it's smaller
  13766. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  13767. var opts = CSSESC_QUOTE_OPTIONS[quote];
  13768. var quoteValue = (0, _cssesc["default"])(v, opts);
  13769. if (quoteValue.length < escaped.length) {
  13770. return quote;
  13771. }
  13772. }
  13773. return pref;
  13774. }
  13775. } else if (numDoubleQuotes === numSingleQuotes) {
  13776. return this.preferredQuoteMark(options);
  13777. } else if (numDoubleQuotes < numSingleQuotes) {
  13778. return Attribute.DOUBLE_QUOTE;
  13779. } else {
  13780. return Attribute.SINGLE_QUOTE;
  13781. }
  13782. }
  13783. /**
  13784. * Selects the preferred quote mark based on the options and the current quote mark value.
  13785. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  13786. * instead.
  13787. */;
  13788. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  13789. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  13790. if (quoteMark === undefined) {
  13791. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  13792. }
  13793. if (quoteMark === undefined) {
  13794. quoteMark = Attribute.DOUBLE_QUOTE;
  13795. }
  13796. return quoteMark;
  13797. };
  13798. _proto._syncRawValue = function _syncRawValue() {
  13799. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  13800. if (rawValue === this._value) {
  13801. if (this.raws) {
  13802. delete this.raws.value;
  13803. }
  13804. } else {
  13805. this.raws.value = rawValue;
  13806. }
  13807. };
  13808. _proto._handleEscapes = function _handleEscapes(prop, value) {
  13809. if (this._constructed) {
  13810. var escaped = (0, _cssesc["default"])(value, {
  13811. isIdentifier: true
  13812. });
  13813. if (escaped !== value) {
  13814. this.raws[prop] = escaped;
  13815. } else {
  13816. delete this.raws[prop];
  13817. }
  13818. }
  13819. };
  13820. _proto._spacesFor = function _spacesFor(name) {
  13821. var attrSpaces = {
  13822. before: '',
  13823. after: ''
  13824. };
  13825. var spaces = this.spaces[name] || {};
  13826. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  13827. return Object.assign(attrSpaces, spaces, rawSpaces);
  13828. };
  13829. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  13830. if (spaceName === void 0) {
  13831. spaceName = name;
  13832. }
  13833. if (concat === void 0) {
  13834. concat = defaultAttrConcat;
  13835. }
  13836. var attrSpaces = this._spacesFor(spaceName);
  13837. return concat(this.stringifyProperty(name), attrSpaces);
  13838. }
  13839. /**
  13840. * returns the offset of the attribute part specified relative to the
  13841. * start of the node of the output string.
  13842. *
  13843. * * "ns" - alias for "namespace"
  13844. * * "namespace" - the namespace if it exists.
  13845. * * "attribute" - the attribute name
  13846. * * "attributeNS" - the start of the attribute or its namespace
  13847. * * "operator" - the match operator of the attribute
  13848. * * "value" - The value (string or identifier)
  13849. * * "insensitive" - the case insensitivity flag;
  13850. * @param part One of the possible values inside an attribute.
  13851. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  13852. */;
  13853. _proto.offsetOf = function offsetOf(name) {
  13854. var count = 1;
  13855. var attributeSpaces = this._spacesFor("attribute");
  13856. count += attributeSpaces.before.length;
  13857. if (name === "namespace" || name === "ns") {
  13858. return this.namespace ? count : -1;
  13859. }
  13860. if (name === "attributeNS") {
  13861. return count;
  13862. }
  13863. count += this.namespaceString.length;
  13864. if (this.namespace) {
  13865. count += 1;
  13866. }
  13867. if (name === "attribute") {
  13868. return count;
  13869. }
  13870. count += this.stringifyProperty("attribute").length;
  13871. count += attributeSpaces.after.length;
  13872. var operatorSpaces = this._spacesFor("operator");
  13873. count += operatorSpaces.before.length;
  13874. var operator = this.stringifyProperty("operator");
  13875. if (name === "operator") {
  13876. return operator ? count : -1;
  13877. }
  13878. count += operator.length;
  13879. count += operatorSpaces.after.length;
  13880. var valueSpaces = this._spacesFor("value");
  13881. count += valueSpaces.before.length;
  13882. var value = this.stringifyProperty("value");
  13883. if (name === "value") {
  13884. return value ? count : -1;
  13885. }
  13886. count += value.length;
  13887. count += valueSpaces.after.length;
  13888. var insensitiveSpaces = this._spacesFor("insensitive");
  13889. count += insensitiveSpaces.before.length;
  13890. if (name === "insensitive") {
  13891. return this.insensitive ? count : -1;
  13892. }
  13893. return -1;
  13894. };
  13895. _proto.toString = function toString() {
  13896. var _this2 = this;
  13897. var selector = [this.rawSpaceBefore, '['];
  13898. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  13899. if (this.operator && (this.value || this.value === '')) {
  13900. selector.push(this._stringFor('operator'));
  13901. selector.push(this._stringFor('value'));
  13902. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  13903. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  13904. attrSpaces.before = " ";
  13905. }
  13906. return defaultAttrConcat(attrValue, attrSpaces);
  13907. }));
  13908. }
  13909. selector.push(']');
  13910. selector.push(this.rawSpaceAfter);
  13911. return selector.join('');
  13912. };
  13913. _createClass(Attribute, [{
  13914. key: "quoted",
  13915. get: function get() {
  13916. var qm = this.quoteMark;
  13917. return qm === "'" || qm === '"';
  13918. },
  13919. set: function set(value) {
  13920. warnOfDeprecatedQuotedAssignment();
  13921. }
  13922. /**
  13923. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  13924. * returns `null` if the value is not quoted.
  13925. * returns `undefined` if the quotation state is unknown (this can happen when
  13926. * the attribute is constructed without specifying a quote mark.)
  13927. */
  13928. }, {
  13929. key: "quoteMark",
  13930. get: function get() {
  13931. return this._quoteMark;
  13932. }
  13933. /**
  13934. * Set the quote mark to be used by this attribute's value.
  13935. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  13936. * value is updated accordingly.
  13937. *
  13938. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  13939. */,
  13940. set: function set(quoteMark) {
  13941. if (!this._constructed) {
  13942. this._quoteMark = quoteMark;
  13943. return;
  13944. }
  13945. if (this._quoteMark !== quoteMark) {
  13946. this._quoteMark = quoteMark;
  13947. this._syncRawValue();
  13948. }
  13949. }
  13950. }, {
  13951. key: "qualifiedAttribute",
  13952. get: function get() {
  13953. return this.qualifiedName(this.raws.attribute || this.attribute);
  13954. }
  13955. }, {
  13956. key: "insensitiveFlag",
  13957. get: function get() {
  13958. return this.insensitive ? 'i' : '';
  13959. }
  13960. }, {
  13961. key: "value",
  13962. get: function get() {
  13963. return this._value;
  13964. },
  13965. set:
  13966. /**
  13967. * Before 3.0, the value had to be set to an escaped value including any wrapped
  13968. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  13969. * is unescaped during parsing and any quote marks are removed.
  13970. *
  13971. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  13972. * a deprecation warning is raised when the new value contains any characters that would
  13973. * require escaping (including if it contains wrapped quotes).
  13974. *
  13975. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  13976. * how the new value is quoted.
  13977. */
  13978. function set(v) {
  13979. if (this._constructed) {
  13980. var _unescapeValue2 = unescapeValue(v),
  13981. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  13982. unescaped = _unescapeValue2.unescaped,
  13983. quoteMark = _unescapeValue2.quoteMark;
  13984. if (deprecatedUsage) {
  13985. warnOfDeprecatedValueAssignment();
  13986. }
  13987. if (unescaped === this._value && quoteMark === this._quoteMark) {
  13988. return;
  13989. }
  13990. this._value = unescaped;
  13991. this._quoteMark = quoteMark;
  13992. this._syncRawValue();
  13993. } else {
  13994. this._value = v;
  13995. }
  13996. }
  13997. }, {
  13998. key: "insensitive",
  13999. get: function get() {
  14000. return this._insensitive;
  14001. }
  14002. /**
  14003. * Set the case insensitive flag.
  14004. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  14005. * of the attribute is updated accordingly.
  14006. *
  14007. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  14008. */,
  14009. set: function set(insensitive) {
  14010. if (!insensitive) {
  14011. this._insensitive = false;
  14012. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  14013. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  14014. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  14015. this.raws.insensitiveFlag = undefined;
  14016. }
  14017. }
  14018. this._insensitive = insensitive;
  14019. }
  14020. }, {
  14021. key: "attribute",
  14022. get: function get() {
  14023. return this._attribute;
  14024. },
  14025. set: function set(name) {
  14026. this._handleEscapes("attribute", name);
  14027. this._attribute = name;
  14028. }
  14029. }]);
  14030. return Attribute;
  14031. }(_namespace["default"]);
  14032. exports["default"] = Attribute;
  14033. Attribute.NO_QUOTE = null;
  14034. Attribute.SINGLE_QUOTE = "'";
  14035. Attribute.DOUBLE_QUOTE = '"';
  14036. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  14037. "'": {
  14038. quotes: 'single',
  14039. wrap: true
  14040. },
  14041. '"': {
  14042. quotes: 'double',
  14043. wrap: true
  14044. }
  14045. }, _CSSESC_QUOTE_OPTIONS[null] = {
  14046. isIdentifier: true
  14047. }, _CSSESC_QUOTE_OPTIONS);
  14048. function defaultAttrConcat(attrValue, attrSpaces) {
  14049. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  14050. }
  14051. } (attribute$1));
  14052. var universal$1 = {exports: {}};
  14053. (function (module, exports) {
  14054. exports.__esModule = true;
  14055. exports["default"] = void 0;
  14056. var _namespace = _interopRequireDefault(namespace.exports);
  14057. var _types = types;
  14058. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14059. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14060. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14061. var Universal = /*#__PURE__*/function (_Namespace) {
  14062. _inheritsLoose(Universal, _Namespace);
  14063. function Universal(opts) {
  14064. var _this;
  14065. _this = _Namespace.call(this, opts) || this;
  14066. _this.type = _types.UNIVERSAL;
  14067. _this.value = '*';
  14068. return _this;
  14069. }
  14070. return Universal;
  14071. }(_namespace["default"]);
  14072. exports["default"] = Universal;
  14073. module.exports = exports.default;
  14074. } (universal$1, universal$1.exports));
  14075. var combinator$2 = {exports: {}};
  14076. (function (module, exports) {
  14077. exports.__esModule = true;
  14078. exports["default"] = void 0;
  14079. var _node = _interopRequireDefault(node$1.exports);
  14080. var _types = types;
  14081. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14082. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14083. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14084. var Combinator = /*#__PURE__*/function (_Node) {
  14085. _inheritsLoose(Combinator, _Node);
  14086. function Combinator(opts) {
  14087. var _this;
  14088. _this = _Node.call(this, opts) || this;
  14089. _this.type = _types.COMBINATOR;
  14090. return _this;
  14091. }
  14092. return Combinator;
  14093. }(_node["default"]);
  14094. exports["default"] = Combinator;
  14095. module.exports = exports.default;
  14096. } (combinator$2, combinator$2.exports));
  14097. var nesting$1 = {exports: {}};
  14098. (function (module, exports) {
  14099. exports.__esModule = true;
  14100. exports["default"] = void 0;
  14101. var _node = _interopRequireDefault(node$1.exports);
  14102. var _types = types;
  14103. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14104. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14105. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14106. var Nesting = /*#__PURE__*/function (_Node) {
  14107. _inheritsLoose(Nesting, _Node);
  14108. function Nesting(opts) {
  14109. var _this;
  14110. _this = _Node.call(this, opts) || this;
  14111. _this.type = _types.NESTING;
  14112. _this.value = '&';
  14113. return _this;
  14114. }
  14115. return Nesting;
  14116. }(_node["default"]);
  14117. exports["default"] = Nesting;
  14118. module.exports = exports.default;
  14119. } (nesting$1, nesting$1.exports));
  14120. var sortAscending = {exports: {}};
  14121. (function (module, exports) {
  14122. exports.__esModule = true;
  14123. exports["default"] = sortAscending;
  14124. function sortAscending(list) {
  14125. return list.sort(function (a, b) {
  14126. return a - b;
  14127. });
  14128. }
  14129. module.exports = exports.default;
  14130. } (sortAscending, sortAscending.exports));
  14131. var tokenize = {};
  14132. var tokenTypes = {};
  14133. tokenTypes.__esModule = true;
  14134. tokenTypes.word = tokenTypes.tilde = tokenTypes.tab = tokenTypes.str = tokenTypes.space = tokenTypes.slash = tokenTypes.singleQuote = tokenTypes.semicolon = tokenTypes.plus = tokenTypes.pipe = tokenTypes.openSquare = tokenTypes.openParenthesis = tokenTypes.newline = tokenTypes.greaterThan = tokenTypes.feed = tokenTypes.equals = tokenTypes.doubleQuote = tokenTypes.dollar = tokenTypes.cr = tokenTypes.comment = tokenTypes.comma = tokenTypes.combinator = tokenTypes.colon = tokenTypes.closeSquare = tokenTypes.closeParenthesis = tokenTypes.caret = tokenTypes.bang = tokenTypes.backslash = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  14135. var ampersand = 38; // `&`.charCodeAt(0);
  14136. tokenTypes.ampersand = ampersand;
  14137. var asterisk = 42; // `*`.charCodeAt(0);
  14138. tokenTypes.asterisk = asterisk;
  14139. var at = 64; // `@`.charCodeAt(0);
  14140. tokenTypes.at = at;
  14141. var comma = 44; // `,`.charCodeAt(0);
  14142. tokenTypes.comma = comma;
  14143. var colon = 58; // `:`.charCodeAt(0);
  14144. tokenTypes.colon = colon;
  14145. var semicolon = 59; // `;`.charCodeAt(0);
  14146. tokenTypes.semicolon = semicolon;
  14147. var openParenthesis = 40; // `(`.charCodeAt(0);
  14148. tokenTypes.openParenthesis = openParenthesis;
  14149. var closeParenthesis = 41; // `)`.charCodeAt(0);
  14150. tokenTypes.closeParenthesis = closeParenthesis;
  14151. var openSquare = 91; // `[`.charCodeAt(0);
  14152. tokenTypes.openSquare = openSquare;
  14153. var closeSquare = 93; // `]`.charCodeAt(0);
  14154. tokenTypes.closeSquare = closeSquare;
  14155. var dollar = 36; // `$`.charCodeAt(0);
  14156. tokenTypes.dollar = dollar;
  14157. var tilde = 126; // `~`.charCodeAt(0);
  14158. tokenTypes.tilde = tilde;
  14159. var caret = 94; // `^`.charCodeAt(0);
  14160. tokenTypes.caret = caret;
  14161. var plus = 43; // `+`.charCodeAt(0);
  14162. tokenTypes.plus = plus;
  14163. var equals = 61; // `=`.charCodeAt(0);
  14164. tokenTypes.equals = equals;
  14165. var pipe = 124; // `|`.charCodeAt(0);
  14166. tokenTypes.pipe = pipe;
  14167. var greaterThan = 62; // `>`.charCodeAt(0);
  14168. tokenTypes.greaterThan = greaterThan;
  14169. var space = 32; // ` `.charCodeAt(0);
  14170. tokenTypes.space = space;
  14171. var singleQuote = 39; // `'`.charCodeAt(0);
  14172. tokenTypes.singleQuote = singleQuote;
  14173. var doubleQuote = 34; // `"`.charCodeAt(0);
  14174. tokenTypes.doubleQuote = doubleQuote;
  14175. var slash = 47; // `/`.charCodeAt(0);
  14176. tokenTypes.slash = slash;
  14177. var bang = 33; // `!`.charCodeAt(0);
  14178. tokenTypes.bang = bang;
  14179. var backslash = 92; // '\\'.charCodeAt(0);
  14180. tokenTypes.backslash = backslash;
  14181. var cr = 13; // '\r'.charCodeAt(0);
  14182. tokenTypes.cr = cr;
  14183. var feed = 12; // '\f'.charCodeAt(0);
  14184. tokenTypes.feed = feed;
  14185. var newline = 10; // '\n'.charCodeAt(0);
  14186. tokenTypes.newline = newline;
  14187. var tab = 9; // '\t'.charCodeAt(0);
  14188. // Expose aliases primarily for readability.
  14189. tokenTypes.tab = tab;
  14190. var str = singleQuote;
  14191. // No good single character representation!
  14192. tokenTypes.str = str;
  14193. var comment$1 = -1;
  14194. tokenTypes.comment = comment$1;
  14195. var word = -2;
  14196. tokenTypes.word = word;
  14197. var combinator$1 = -3;
  14198. tokenTypes.combinator = combinator$1;
  14199. (function (exports) {
  14200. exports.__esModule = true;
  14201. exports.FIELDS = void 0;
  14202. exports["default"] = tokenize;
  14203. var t = _interopRequireWildcard(tokenTypes);
  14204. var _unescapable, _wordDelimiters;
  14205. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  14206. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  14207. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  14208. var wordDelimiters = (_wordDelimiters = {}, _wordDelimiters[t.space] = true, _wordDelimiters[t.tab] = true, _wordDelimiters[t.newline] = true, _wordDelimiters[t.cr] = true, _wordDelimiters[t.feed] = true, _wordDelimiters[t.ampersand] = true, _wordDelimiters[t.asterisk] = true, _wordDelimiters[t.bang] = true, _wordDelimiters[t.comma] = true, _wordDelimiters[t.colon] = true, _wordDelimiters[t.semicolon] = true, _wordDelimiters[t.openParenthesis] = true, _wordDelimiters[t.closeParenthesis] = true, _wordDelimiters[t.openSquare] = true, _wordDelimiters[t.closeSquare] = true, _wordDelimiters[t.singleQuote] = true, _wordDelimiters[t.doubleQuote] = true, _wordDelimiters[t.plus] = true, _wordDelimiters[t.pipe] = true, _wordDelimiters[t.tilde] = true, _wordDelimiters[t.greaterThan] = true, _wordDelimiters[t.equals] = true, _wordDelimiters[t.dollar] = true, _wordDelimiters[t.caret] = true, _wordDelimiters[t.slash] = true, _wordDelimiters);
  14209. var hex = {};
  14210. var hexChars = "0123456789abcdefABCDEF";
  14211. for (var i = 0; i < hexChars.length; i++) {
  14212. hex[hexChars.charCodeAt(i)] = true;
  14213. }
  14214. /**
  14215. * Returns the last index of the bar css word
  14216. * @param {string} css The string in which the word begins
  14217. * @param {number} start The index into the string where word's first letter occurs
  14218. */
  14219. function consumeWord(css, start) {
  14220. var next = start;
  14221. var code;
  14222. do {
  14223. code = css.charCodeAt(next);
  14224. if (wordDelimiters[code]) {
  14225. return next - 1;
  14226. } else if (code === t.backslash) {
  14227. next = consumeEscape(css, next) + 1;
  14228. } else {
  14229. // All other characters are part of the word
  14230. next++;
  14231. }
  14232. } while (next < css.length);
  14233. return next - 1;
  14234. }
  14235. /**
  14236. * Returns the last index of the escape sequence
  14237. * @param {string} css The string in which the sequence begins
  14238. * @param {number} start The index into the string where escape character (`\`) occurs.
  14239. */
  14240. function consumeEscape(css, start) {
  14241. var next = start;
  14242. var code = css.charCodeAt(next + 1);
  14243. if (unescapable[code]) ; else if (hex[code]) {
  14244. var hexDigits = 0;
  14245. // consume up to 6 hex chars
  14246. do {
  14247. next++;
  14248. hexDigits++;
  14249. code = css.charCodeAt(next + 1);
  14250. } while (hex[code] && hexDigits < 6);
  14251. // if fewer than 6 hex chars, a trailing space ends the escape
  14252. if (hexDigits < 6 && code === t.space) {
  14253. next++;
  14254. }
  14255. } else {
  14256. // the next char is part of the current word
  14257. next++;
  14258. }
  14259. return next;
  14260. }
  14261. var FIELDS = {
  14262. TYPE: 0,
  14263. START_LINE: 1,
  14264. START_COL: 2,
  14265. END_LINE: 3,
  14266. END_COL: 4,
  14267. START_POS: 5,
  14268. END_POS: 6
  14269. };
  14270. exports.FIELDS = FIELDS;
  14271. function tokenize(input) {
  14272. var tokens = [];
  14273. var css = input.css.valueOf();
  14274. var _css = css,
  14275. length = _css.length;
  14276. var offset = -1;
  14277. var line = 1;
  14278. var start = 0;
  14279. var end = 0;
  14280. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  14281. function unclosed(what, fix) {
  14282. if (input.safe) {
  14283. // fyi: this is never set to true.
  14284. css += fix;
  14285. next = css.length - 1;
  14286. } else {
  14287. throw input.error('Unclosed ' + what, line, start - offset, start);
  14288. }
  14289. }
  14290. while (start < length) {
  14291. code = css.charCodeAt(start);
  14292. if (code === t.newline) {
  14293. offset = start;
  14294. line += 1;
  14295. }
  14296. switch (code) {
  14297. case t.space:
  14298. case t.tab:
  14299. case t.newline:
  14300. case t.cr:
  14301. case t.feed:
  14302. next = start;
  14303. do {
  14304. next += 1;
  14305. code = css.charCodeAt(next);
  14306. if (code === t.newline) {
  14307. offset = next;
  14308. line += 1;
  14309. }
  14310. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  14311. tokenType = t.space;
  14312. endLine = line;
  14313. endColumn = next - offset - 1;
  14314. end = next;
  14315. break;
  14316. case t.plus:
  14317. case t.greaterThan:
  14318. case t.tilde:
  14319. case t.pipe:
  14320. next = start;
  14321. do {
  14322. next += 1;
  14323. code = css.charCodeAt(next);
  14324. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  14325. tokenType = t.combinator;
  14326. endLine = line;
  14327. endColumn = start - offset;
  14328. end = next;
  14329. break;
  14330. // Consume these characters as single tokens.
  14331. case t.asterisk:
  14332. case t.ampersand:
  14333. case t.bang:
  14334. case t.comma:
  14335. case t.equals:
  14336. case t.dollar:
  14337. case t.caret:
  14338. case t.openSquare:
  14339. case t.closeSquare:
  14340. case t.colon:
  14341. case t.semicolon:
  14342. case t.openParenthesis:
  14343. case t.closeParenthesis:
  14344. next = start;
  14345. tokenType = code;
  14346. endLine = line;
  14347. endColumn = start - offset;
  14348. end = next + 1;
  14349. break;
  14350. case t.singleQuote:
  14351. case t.doubleQuote:
  14352. quote = code === t.singleQuote ? "'" : '"';
  14353. next = start;
  14354. do {
  14355. escaped = false;
  14356. next = css.indexOf(quote, next + 1);
  14357. if (next === -1) {
  14358. unclosed('quote', quote);
  14359. }
  14360. escapePos = next;
  14361. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  14362. escapePos -= 1;
  14363. escaped = !escaped;
  14364. }
  14365. } while (escaped);
  14366. tokenType = t.str;
  14367. endLine = line;
  14368. endColumn = start - offset;
  14369. end = next + 1;
  14370. break;
  14371. default:
  14372. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  14373. next = css.indexOf('*/', start + 2) + 1;
  14374. if (next === 0) {
  14375. unclosed('comment', '*/');
  14376. }
  14377. content = css.slice(start, next + 1);
  14378. lines = content.split('\n');
  14379. last = lines.length - 1;
  14380. if (last > 0) {
  14381. nextLine = line + last;
  14382. nextOffset = next - lines[last].length;
  14383. } else {
  14384. nextLine = line;
  14385. nextOffset = offset;
  14386. }
  14387. tokenType = t.comment;
  14388. line = nextLine;
  14389. endLine = nextLine;
  14390. endColumn = next - nextOffset;
  14391. } else if (code === t.slash) {
  14392. next = start;
  14393. tokenType = code;
  14394. endLine = line;
  14395. endColumn = start - offset;
  14396. end = next + 1;
  14397. } else {
  14398. next = consumeWord(css, start);
  14399. tokenType = t.word;
  14400. endLine = line;
  14401. endColumn = next - offset;
  14402. }
  14403. end = next + 1;
  14404. break;
  14405. }
  14406. // Ensure that the token structure remains consistent
  14407. tokens.push([tokenType,
  14408. // [0] Token type
  14409. line,
  14410. // [1] Starting line
  14411. start - offset,
  14412. // [2] Starting column
  14413. endLine,
  14414. // [3] Ending line
  14415. endColumn,
  14416. // [4] Ending column
  14417. start,
  14418. // [5] Start position / Source index
  14419. end // [6] End position
  14420. ]);
  14421. // Reset offset for the next token
  14422. if (nextOffset) {
  14423. offset = nextOffset;
  14424. nextOffset = null;
  14425. }
  14426. start = end;
  14427. }
  14428. return tokens;
  14429. }
  14430. } (tokenize));
  14431. (function (module, exports) {
  14432. exports.__esModule = true;
  14433. exports["default"] = void 0;
  14434. var _root = _interopRequireDefault(root$1.exports);
  14435. var _selector = _interopRequireDefault(selector$1.exports);
  14436. var _className = _interopRequireDefault(className$1.exports);
  14437. var _comment = _interopRequireDefault(comment$2.exports);
  14438. var _id = _interopRequireDefault(id$1.exports);
  14439. var _tag = _interopRequireDefault(tag$1.exports);
  14440. var _string = _interopRequireDefault(string$1.exports);
  14441. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  14442. var _attribute = _interopRequireWildcard(attribute$1);
  14443. var _universal = _interopRequireDefault(universal$1.exports);
  14444. var _combinator = _interopRequireDefault(combinator$2.exports);
  14445. var _nesting = _interopRequireDefault(nesting$1.exports);
  14446. var _sortAscending = _interopRequireDefault(sortAscending.exports);
  14447. var _tokenize = _interopRequireWildcard(tokenize);
  14448. var tokens = _interopRequireWildcard(tokenTypes);
  14449. var types$1 = _interopRequireWildcard(types);
  14450. var _util = util;
  14451. var _WHITESPACE_TOKENS, _Object$assign;
  14452. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  14453. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  14454. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14455. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14456. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  14457. var WHITESPACE_TOKENS = (_WHITESPACE_TOKENS = {}, _WHITESPACE_TOKENS[tokens.space] = true, _WHITESPACE_TOKENS[tokens.cr] = true, _WHITESPACE_TOKENS[tokens.feed] = true, _WHITESPACE_TOKENS[tokens.newline] = true, _WHITESPACE_TOKENS[tokens.tab] = true, _WHITESPACE_TOKENS);
  14458. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  14459. function tokenStart(token) {
  14460. return {
  14461. line: token[_tokenize.FIELDS.START_LINE],
  14462. column: token[_tokenize.FIELDS.START_COL]
  14463. };
  14464. }
  14465. function tokenEnd(token) {
  14466. return {
  14467. line: token[_tokenize.FIELDS.END_LINE],
  14468. column: token[_tokenize.FIELDS.END_COL]
  14469. };
  14470. }
  14471. function getSource(startLine, startColumn, endLine, endColumn) {
  14472. return {
  14473. start: {
  14474. line: startLine,
  14475. column: startColumn
  14476. },
  14477. end: {
  14478. line: endLine,
  14479. column: endColumn
  14480. }
  14481. };
  14482. }
  14483. function getTokenSource(token) {
  14484. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  14485. }
  14486. function getTokenSourceSpan(startToken, endToken) {
  14487. if (!startToken) {
  14488. return undefined;
  14489. }
  14490. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  14491. }
  14492. function unescapeProp(node, prop) {
  14493. var value = node[prop];
  14494. if (typeof value !== "string") {
  14495. return;
  14496. }
  14497. if (value.indexOf("\\") !== -1) {
  14498. (0, _util.ensureObject)(node, 'raws');
  14499. node[prop] = (0, _util.unesc)(value);
  14500. if (node.raws[prop] === undefined) {
  14501. node.raws[prop] = value;
  14502. }
  14503. }
  14504. return node;
  14505. }
  14506. function indexesOf(array, item) {
  14507. var i = -1;
  14508. var indexes = [];
  14509. while ((i = array.indexOf(item, i + 1)) !== -1) {
  14510. indexes.push(i);
  14511. }
  14512. return indexes;
  14513. }
  14514. function uniqs() {
  14515. var list = Array.prototype.concat.apply([], arguments);
  14516. return list.filter(function (item, i) {
  14517. return i === list.indexOf(item);
  14518. });
  14519. }
  14520. var Parser = /*#__PURE__*/function () {
  14521. function Parser(rule, options) {
  14522. if (options === void 0) {
  14523. options = {};
  14524. }
  14525. this.rule = rule;
  14526. this.options = Object.assign({
  14527. lossy: false,
  14528. safe: false
  14529. }, options);
  14530. this.position = 0;
  14531. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  14532. this.tokens = (0, _tokenize["default"])({
  14533. css: this.css,
  14534. error: this._errorGenerator(),
  14535. safe: this.options.safe
  14536. });
  14537. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  14538. this.root = new _root["default"]({
  14539. source: rootSource
  14540. });
  14541. this.root.errorGenerator = this._errorGenerator();
  14542. var selector = new _selector["default"]({
  14543. source: {
  14544. start: {
  14545. line: 1,
  14546. column: 1
  14547. }
  14548. }
  14549. });
  14550. this.root.append(selector);
  14551. this.current = selector;
  14552. this.loop();
  14553. }
  14554. var _proto = Parser.prototype;
  14555. _proto._errorGenerator = function _errorGenerator() {
  14556. var _this = this;
  14557. return function (message, errorOptions) {
  14558. if (typeof _this.rule === 'string') {
  14559. return new Error(message);
  14560. }
  14561. return _this.rule.error(message, errorOptions);
  14562. };
  14563. };
  14564. _proto.attribute = function attribute() {
  14565. var attr = [];
  14566. var startingToken = this.currToken;
  14567. this.position++;
  14568. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  14569. attr.push(this.currToken);
  14570. this.position++;
  14571. }
  14572. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  14573. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  14574. }
  14575. var len = attr.length;
  14576. var node = {
  14577. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  14578. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  14579. };
  14580. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  14581. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  14582. }
  14583. var pos = 0;
  14584. var spaceBefore = '';
  14585. var commentBefore = '';
  14586. var lastAdded = null;
  14587. var spaceAfterMeaningfulToken = false;
  14588. while (pos < len) {
  14589. var token = attr[pos];
  14590. var content = this.content(token);
  14591. var next = attr[pos + 1];
  14592. switch (token[_tokenize.FIELDS.TYPE]) {
  14593. case tokens.space:
  14594. // if (
  14595. // len === 1 ||
  14596. // pos === 0 && this.content(next) === '|'
  14597. // ) {
  14598. // return this.expected('attribute', token[TOKEN.START_POS], content);
  14599. // }
  14600. spaceAfterMeaningfulToken = true;
  14601. if (this.options.lossy) {
  14602. break;
  14603. }
  14604. if (lastAdded) {
  14605. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  14606. var prevContent = node.spaces[lastAdded].after || '';
  14607. node.spaces[lastAdded].after = prevContent + content;
  14608. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  14609. if (existingComment) {
  14610. node.raws.spaces[lastAdded].after = existingComment + content;
  14611. }
  14612. } else {
  14613. spaceBefore = spaceBefore + content;
  14614. commentBefore = commentBefore + content;
  14615. }
  14616. break;
  14617. case tokens.asterisk:
  14618. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14619. node.operator = content;
  14620. lastAdded = 'operator';
  14621. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  14622. if (spaceBefore) {
  14623. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  14624. node.spaces.attribute.before = spaceBefore;
  14625. spaceBefore = '';
  14626. }
  14627. if (commentBefore) {
  14628. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  14629. node.raws.spaces.attribute.before = spaceBefore;
  14630. commentBefore = '';
  14631. }
  14632. node.namespace = (node.namespace || "") + content;
  14633. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  14634. if (rawValue) {
  14635. node.raws.namespace += content;
  14636. }
  14637. lastAdded = 'namespace';
  14638. }
  14639. spaceAfterMeaningfulToken = false;
  14640. break;
  14641. case tokens.dollar:
  14642. if (lastAdded === "value") {
  14643. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  14644. node.value += "$";
  14645. if (oldRawValue) {
  14646. node.raws.value = oldRawValue + "$";
  14647. }
  14648. break;
  14649. }
  14650. // Falls through
  14651. case tokens.caret:
  14652. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14653. node.operator = content;
  14654. lastAdded = 'operator';
  14655. }
  14656. spaceAfterMeaningfulToken = false;
  14657. break;
  14658. case tokens.combinator:
  14659. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14660. node.operator = content;
  14661. lastAdded = 'operator';
  14662. }
  14663. if (content !== '|') {
  14664. spaceAfterMeaningfulToken = false;
  14665. break;
  14666. }
  14667. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14668. node.operator = content;
  14669. lastAdded = 'operator';
  14670. } else if (!node.namespace && !node.attribute) {
  14671. node.namespace = true;
  14672. }
  14673. spaceAfterMeaningfulToken = false;
  14674. break;
  14675. case tokens.word:
  14676. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  14677. // this look-ahead probably fails with comment nodes involved.
  14678. !node.operator && !node.namespace) {
  14679. node.namespace = content;
  14680. lastAdded = 'namespace';
  14681. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  14682. if (spaceBefore) {
  14683. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  14684. node.spaces.attribute.before = spaceBefore;
  14685. spaceBefore = '';
  14686. }
  14687. if (commentBefore) {
  14688. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  14689. node.raws.spaces.attribute.before = commentBefore;
  14690. commentBefore = '';
  14691. }
  14692. node.attribute = (node.attribute || "") + content;
  14693. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  14694. if (_rawValue) {
  14695. node.raws.attribute += content;
  14696. }
  14697. lastAdded = 'attribute';
  14698. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  14699. var _unescaped = (0, _util.unesc)(content);
  14700. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  14701. var oldValue = node.value || '';
  14702. node.value = oldValue + _unescaped;
  14703. node.quoteMark = null;
  14704. if (_unescaped !== content || _oldRawValue) {
  14705. (0, _util.ensureObject)(node, 'raws');
  14706. node.raws.value = (_oldRawValue || oldValue) + content;
  14707. }
  14708. lastAdded = 'value';
  14709. } else {
  14710. var insensitive = content === 'i' || content === "I";
  14711. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  14712. node.insensitive = insensitive;
  14713. if (!insensitive || content === "I") {
  14714. (0, _util.ensureObject)(node, 'raws');
  14715. node.raws.insensitiveFlag = content;
  14716. }
  14717. lastAdded = 'insensitive';
  14718. if (spaceBefore) {
  14719. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  14720. node.spaces.insensitive.before = spaceBefore;
  14721. spaceBefore = '';
  14722. }
  14723. if (commentBefore) {
  14724. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  14725. node.raws.spaces.insensitive.before = commentBefore;
  14726. commentBefore = '';
  14727. }
  14728. } else if (node.value || node.value === '') {
  14729. lastAdded = 'value';
  14730. node.value += content;
  14731. if (node.raws.value) {
  14732. node.raws.value += content;
  14733. }
  14734. }
  14735. }
  14736. spaceAfterMeaningfulToken = false;
  14737. break;
  14738. case tokens.str:
  14739. if (!node.attribute || !node.operator) {
  14740. return this.error("Expected an attribute followed by an operator preceding the string.", {
  14741. index: token[_tokenize.FIELDS.START_POS]
  14742. });
  14743. }
  14744. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  14745. unescaped = _unescapeValue.unescaped,
  14746. quoteMark = _unescapeValue.quoteMark;
  14747. node.value = unescaped;
  14748. node.quoteMark = quoteMark;
  14749. lastAdded = 'value';
  14750. (0, _util.ensureObject)(node, 'raws');
  14751. node.raws.value = content;
  14752. spaceAfterMeaningfulToken = false;
  14753. break;
  14754. case tokens.equals:
  14755. if (!node.attribute) {
  14756. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  14757. }
  14758. if (node.value) {
  14759. return this.error('Unexpected "=" found; an operator was already defined.', {
  14760. index: token[_tokenize.FIELDS.START_POS]
  14761. });
  14762. }
  14763. node.operator = node.operator ? node.operator + content : content;
  14764. lastAdded = 'operator';
  14765. spaceAfterMeaningfulToken = false;
  14766. break;
  14767. case tokens.comment:
  14768. if (lastAdded) {
  14769. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  14770. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  14771. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  14772. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  14773. node.raws.spaces[lastAdded].after = rawLastComment + content;
  14774. } else {
  14775. var lastValue = node[lastAdded] || '';
  14776. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  14777. (0, _util.ensureObject)(node, 'raws');
  14778. node.raws[lastAdded] = rawLastValue + content;
  14779. }
  14780. } else {
  14781. commentBefore = commentBefore + content;
  14782. }
  14783. break;
  14784. default:
  14785. return this.error("Unexpected \"" + content + "\" found.", {
  14786. index: token[_tokenize.FIELDS.START_POS]
  14787. });
  14788. }
  14789. pos++;
  14790. }
  14791. unescapeProp(node, "attribute");
  14792. unescapeProp(node, "namespace");
  14793. this.newNode(new _attribute["default"](node));
  14794. this.position++;
  14795. }
  14796. /**
  14797. * return a node containing meaningless garbage up to (but not including) the specified token position.
  14798. * if the token position is negative, all remaining tokens are consumed.
  14799. *
  14800. * This returns an array containing a single string node if all whitespace,
  14801. * otherwise an array of comment nodes with space before and after.
  14802. *
  14803. * These tokens are not added to the current selector, the caller can add them or use them to amend
  14804. * a previous node's space metadata.
  14805. *
  14806. * In lossy mode, this returns only comments.
  14807. */;
  14808. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  14809. if (stopPosition < 0) {
  14810. stopPosition = this.tokens.length;
  14811. }
  14812. var startPosition = this.position;
  14813. var nodes = [];
  14814. var space = "";
  14815. var lastComment = undefined;
  14816. do {
  14817. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  14818. if (!this.options.lossy) {
  14819. space += this.content();
  14820. }
  14821. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  14822. var spaces = {};
  14823. if (space) {
  14824. spaces.before = space;
  14825. space = "";
  14826. }
  14827. lastComment = new _comment["default"]({
  14828. value: this.content(),
  14829. source: getTokenSource(this.currToken),
  14830. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  14831. spaces: spaces
  14832. });
  14833. nodes.push(lastComment);
  14834. }
  14835. } while (++this.position < stopPosition);
  14836. if (space) {
  14837. if (lastComment) {
  14838. lastComment.spaces.after = space;
  14839. } else if (!this.options.lossy) {
  14840. var firstToken = this.tokens[startPosition];
  14841. var lastToken = this.tokens[this.position - 1];
  14842. nodes.push(new _string["default"]({
  14843. value: '',
  14844. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  14845. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  14846. spaces: {
  14847. before: space,
  14848. after: ''
  14849. }
  14850. }));
  14851. }
  14852. }
  14853. return nodes;
  14854. }
  14855. /**
  14856. *
  14857. * @param {*} nodes
  14858. */;
  14859. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  14860. var _this2 = this;
  14861. if (requiredSpace === void 0) {
  14862. requiredSpace = false;
  14863. }
  14864. var space = "";
  14865. var rawSpace = "";
  14866. nodes.forEach(function (n) {
  14867. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  14868. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  14869. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  14870. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  14871. });
  14872. if (rawSpace === space) {
  14873. rawSpace = undefined;
  14874. }
  14875. var result = {
  14876. space: space,
  14877. rawSpace: rawSpace
  14878. };
  14879. return result;
  14880. };
  14881. _proto.isNamedCombinator = function isNamedCombinator(position) {
  14882. if (position === void 0) {
  14883. position = this.position;
  14884. }
  14885. return this.tokens[position + 0] && this.tokens[position + 0][_tokenize.FIELDS.TYPE] === tokens.slash && this.tokens[position + 1] && this.tokens[position + 1][_tokenize.FIELDS.TYPE] === tokens.word && this.tokens[position + 2] && this.tokens[position + 2][_tokenize.FIELDS.TYPE] === tokens.slash;
  14886. };
  14887. _proto.namedCombinator = function namedCombinator() {
  14888. if (this.isNamedCombinator()) {
  14889. var nameRaw = this.content(this.tokens[this.position + 1]);
  14890. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  14891. var raws = {};
  14892. if (name !== nameRaw) {
  14893. raws.value = "/" + nameRaw + "/";
  14894. }
  14895. var node = new _combinator["default"]({
  14896. value: "/" + name + "/",
  14897. source: getSource(this.currToken[_tokenize.FIELDS.START_LINE], this.currToken[_tokenize.FIELDS.START_COL], this.tokens[this.position + 2][_tokenize.FIELDS.END_LINE], this.tokens[this.position + 2][_tokenize.FIELDS.END_COL]),
  14898. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  14899. raws: raws
  14900. });
  14901. this.position = this.position + 3;
  14902. return node;
  14903. } else {
  14904. this.unexpected();
  14905. }
  14906. };
  14907. _proto.combinator = function combinator() {
  14908. var _this3 = this;
  14909. if (this.content() === '|') {
  14910. return this.namespace();
  14911. }
  14912. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  14913. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  14914. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  14915. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  14916. if (nodes.length > 0) {
  14917. var last = this.current.last;
  14918. if (last) {
  14919. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  14920. space = _this$convertWhitespa.space,
  14921. rawSpace = _this$convertWhitespa.rawSpace;
  14922. if (rawSpace !== undefined) {
  14923. last.rawSpaceAfter += rawSpace;
  14924. }
  14925. last.spaces.after += space;
  14926. } else {
  14927. nodes.forEach(function (n) {
  14928. return _this3.newNode(n);
  14929. });
  14930. }
  14931. }
  14932. return;
  14933. }
  14934. var firstToken = this.currToken;
  14935. var spaceOrDescendantSelectorNodes = undefined;
  14936. if (nextSigTokenPos > this.position) {
  14937. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  14938. }
  14939. var node;
  14940. if (this.isNamedCombinator()) {
  14941. node = this.namedCombinator();
  14942. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  14943. node = new _combinator["default"]({
  14944. value: this.content(),
  14945. source: getTokenSource(this.currToken),
  14946. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  14947. });
  14948. this.position++;
  14949. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  14950. this.unexpected();
  14951. }
  14952. if (node) {
  14953. if (spaceOrDescendantSelectorNodes) {
  14954. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  14955. _space = _this$convertWhitespa2.space,
  14956. _rawSpace = _this$convertWhitespa2.rawSpace;
  14957. node.spaces.before = _space;
  14958. node.rawSpaceBefore = _rawSpace;
  14959. }
  14960. } else {
  14961. // descendant combinator
  14962. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  14963. _space2 = _this$convertWhitespa3.space,
  14964. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  14965. if (!_rawSpace2) {
  14966. _rawSpace2 = _space2;
  14967. }
  14968. var spaces = {};
  14969. var raws = {
  14970. spaces: {}
  14971. };
  14972. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  14973. spaces.before = _space2.slice(0, _space2.length - 1);
  14974. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  14975. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  14976. spaces.after = _space2.slice(1);
  14977. raws.spaces.after = _rawSpace2.slice(1);
  14978. } else {
  14979. raws.value = _rawSpace2;
  14980. }
  14981. node = new _combinator["default"]({
  14982. value: ' ',
  14983. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  14984. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  14985. spaces: spaces,
  14986. raws: raws
  14987. });
  14988. }
  14989. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  14990. node.spaces.after = this.optionalSpace(this.content());
  14991. this.position++;
  14992. }
  14993. return this.newNode(node);
  14994. };
  14995. _proto.comma = function comma() {
  14996. if (this.position === this.tokens.length - 1) {
  14997. this.root.trailingComma = true;
  14998. this.position++;
  14999. return;
  15000. }
  15001. this.current._inferEndPosition();
  15002. var selector = new _selector["default"]({
  15003. source: {
  15004. start: tokenStart(this.tokens[this.position + 1])
  15005. }
  15006. });
  15007. this.current.parent.append(selector);
  15008. this.current = selector;
  15009. this.position++;
  15010. };
  15011. _proto.comment = function comment() {
  15012. var current = this.currToken;
  15013. this.newNode(new _comment["default"]({
  15014. value: this.content(),
  15015. source: getTokenSource(current),
  15016. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15017. }));
  15018. this.position++;
  15019. };
  15020. _proto.error = function error(message, opts) {
  15021. throw this.root.error(message, opts);
  15022. };
  15023. _proto.missingBackslash = function missingBackslash() {
  15024. return this.error('Expected a backslash preceding the semicolon.', {
  15025. index: this.currToken[_tokenize.FIELDS.START_POS]
  15026. });
  15027. };
  15028. _proto.missingParenthesis = function missingParenthesis() {
  15029. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  15030. };
  15031. _proto.missingSquareBracket = function missingSquareBracket() {
  15032. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  15033. };
  15034. _proto.unexpected = function unexpected() {
  15035. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  15036. };
  15037. _proto.unexpectedPipe = function unexpectedPipe() {
  15038. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  15039. };
  15040. _proto.namespace = function namespace() {
  15041. var before = this.prevToken && this.content(this.prevToken) || true;
  15042. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  15043. this.position++;
  15044. return this.word(before);
  15045. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  15046. this.position++;
  15047. return this.universal(before);
  15048. }
  15049. this.unexpectedPipe();
  15050. };
  15051. _proto.nesting = function nesting() {
  15052. if (this.nextToken) {
  15053. var nextContent = this.content(this.nextToken);
  15054. if (nextContent === "|") {
  15055. this.position++;
  15056. return;
  15057. }
  15058. }
  15059. var current = this.currToken;
  15060. this.newNode(new _nesting["default"]({
  15061. value: this.content(),
  15062. source: getTokenSource(current),
  15063. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15064. }));
  15065. this.position++;
  15066. };
  15067. _proto.parentheses = function parentheses() {
  15068. var last = this.current.last;
  15069. var unbalanced = 1;
  15070. this.position++;
  15071. if (last && last.type === types$1.PSEUDO) {
  15072. var selector = new _selector["default"]({
  15073. source: {
  15074. start: tokenStart(this.tokens[this.position - 1])
  15075. }
  15076. });
  15077. var cache = this.current;
  15078. last.append(selector);
  15079. this.current = selector;
  15080. while (this.position < this.tokens.length && unbalanced) {
  15081. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15082. unbalanced++;
  15083. }
  15084. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15085. unbalanced--;
  15086. }
  15087. if (unbalanced) {
  15088. this.parse();
  15089. } else {
  15090. this.current.source.end = tokenEnd(this.currToken);
  15091. this.current.parent.source.end = tokenEnd(this.currToken);
  15092. this.position++;
  15093. }
  15094. }
  15095. this.current = cache;
  15096. } else {
  15097. // I think this case should be an error. It's used to implement a basic parse of media queries
  15098. // but I don't think it's a good idea.
  15099. var parenStart = this.currToken;
  15100. var parenValue = "(";
  15101. var parenEnd;
  15102. while (this.position < this.tokens.length && unbalanced) {
  15103. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15104. unbalanced++;
  15105. }
  15106. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15107. unbalanced--;
  15108. }
  15109. parenEnd = this.currToken;
  15110. parenValue += this.parseParenthesisToken(this.currToken);
  15111. this.position++;
  15112. }
  15113. if (last) {
  15114. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  15115. } else {
  15116. this.newNode(new _string["default"]({
  15117. value: parenValue,
  15118. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  15119. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  15120. }));
  15121. }
  15122. }
  15123. if (unbalanced) {
  15124. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  15125. }
  15126. };
  15127. _proto.pseudo = function pseudo() {
  15128. var _this4 = this;
  15129. var pseudoStr = '';
  15130. var startingToken = this.currToken;
  15131. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  15132. pseudoStr += this.content();
  15133. this.position++;
  15134. }
  15135. if (!this.currToken) {
  15136. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  15137. }
  15138. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  15139. this.splitWord(false, function (first, length) {
  15140. pseudoStr += first;
  15141. _this4.newNode(new _pseudo["default"]({
  15142. value: pseudoStr,
  15143. source: getTokenSourceSpan(startingToken, _this4.currToken),
  15144. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  15145. }));
  15146. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15147. _this4.error('Misplaced parenthesis.', {
  15148. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  15149. });
  15150. }
  15151. });
  15152. } else {
  15153. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  15154. }
  15155. };
  15156. _proto.space = function space() {
  15157. var content = this.content();
  15158. // Handle space before and after the selector
  15159. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  15160. return node.type === 'comment';
  15161. })) {
  15162. this.spaces = this.optionalSpace(content);
  15163. this.position++;
  15164. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15165. this.current.last.spaces.after = this.optionalSpace(content);
  15166. this.position++;
  15167. } else {
  15168. this.combinator();
  15169. }
  15170. };
  15171. _proto.string = function string() {
  15172. var current = this.currToken;
  15173. this.newNode(new _string["default"]({
  15174. value: this.content(),
  15175. source: getTokenSource(current),
  15176. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15177. }));
  15178. this.position++;
  15179. };
  15180. _proto.universal = function universal(namespace) {
  15181. var nextToken = this.nextToken;
  15182. if (nextToken && this.content(nextToken) === '|') {
  15183. this.position++;
  15184. return this.namespace();
  15185. }
  15186. var current = this.currToken;
  15187. this.newNode(new _universal["default"]({
  15188. value: this.content(),
  15189. source: getTokenSource(current),
  15190. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15191. }), namespace);
  15192. this.position++;
  15193. };
  15194. _proto.splitWord = function splitWord(namespace, firstCallback) {
  15195. var _this5 = this;
  15196. var nextToken = this.nextToken;
  15197. var word = this.content();
  15198. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  15199. this.position++;
  15200. var current = this.content();
  15201. word += current;
  15202. if (current.lastIndexOf('\\') === current.length - 1) {
  15203. var next = this.nextToken;
  15204. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  15205. word += this.requiredSpace(this.content(next));
  15206. this.position++;
  15207. }
  15208. }
  15209. nextToken = this.nextToken;
  15210. }
  15211. var hasClass = indexesOf(word, '.').filter(function (i) {
  15212. // Allow escaped dot within class name
  15213. var escapedDot = word[i - 1] === '\\';
  15214. // Allow decimal numbers percent in @keyframes
  15215. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  15216. return !escapedDot && !isKeyframesPercent;
  15217. });
  15218. var hasId = indexesOf(word, '#').filter(function (i) {
  15219. return word[i - 1] !== '\\';
  15220. });
  15221. // Eliminate Sass interpolations from the list of id indexes
  15222. var interpolations = indexesOf(word, '#{');
  15223. if (interpolations.length) {
  15224. hasId = hasId.filter(function (hashIndex) {
  15225. return !~interpolations.indexOf(hashIndex);
  15226. });
  15227. }
  15228. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  15229. indices.forEach(function (ind, i) {
  15230. var index = indices[i + 1] || word.length;
  15231. var value = word.slice(ind, index);
  15232. if (i === 0 && firstCallback) {
  15233. return firstCallback.call(_this5, value, indices.length);
  15234. }
  15235. var node;
  15236. var current = _this5.currToken;
  15237. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  15238. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  15239. if (~hasClass.indexOf(ind)) {
  15240. var classNameOpts = {
  15241. value: value.slice(1),
  15242. source: source,
  15243. sourceIndex: sourceIndex
  15244. };
  15245. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  15246. } else if (~hasId.indexOf(ind)) {
  15247. var idOpts = {
  15248. value: value.slice(1),
  15249. source: source,
  15250. sourceIndex: sourceIndex
  15251. };
  15252. node = new _id["default"](unescapeProp(idOpts, "value"));
  15253. } else {
  15254. var tagOpts = {
  15255. value: value,
  15256. source: source,
  15257. sourceIndex: sourceIndex
  15258. };
  15259. unescapeProp(tagOpts, "value");
  15260. node = new _tag["default"](tagOpts);
  15261. }
  15262. _this5.newNode(node, namespace);
  15263. // Ensure that the namespace is used only once
  15264. namespace = null;
  15265. });
  15266. this.position++;
  15267. };
  15268. _proto.word = function word(namespace) {
  15269. var nextToken = this.nextToken;
  15270. if (nextToken && this.content(nextToken) === '|') {
  15271. this.position++;
  15272. return this.namespace();
  15273. }
  15274. return this.splitWord(namespace);
  15275. };
  15276. _proto.loop = function loop() {
  15277. while (this.position < this.tokens.length) {
  15278. this.parse(true);
  15279. }
  15280. this.current._inferEndPosition();
  15281. return this.root;
  15282. };
  15283. _proto.parse = function parse(throwOnParenthesis) {
  15284. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  15285. case tokens.space:
  15286. this.space();
  15287. break;
  15288. case tokens.comment:
  15289. this.comment();
  15290. break;
  15291. case tokens.openParenthesis:
  15292. this.parentheses();
  15293. break;
  15294. case tokens.closeParenthesis:
  15295. if (throwOnParenthesis) {
  15296. this.missingParenthesis();
  15297. }
  15298. break;
  15299. case tokens.openSquare:
  15300. this.attribute();
  15301. break;
  15302. case tokens.dollar:
  15303. case tokens.caret:
  15304. case tokens.equals:
  15305. case tokens.word:
  15306. this.word();
  15307. break;
  15308. case tokens.colon:
  15309. this.pseudo();
  15310. break;
  15311. case tokens.comma:
  15312. this.comma();
  15313. break;
  15314. case tokens.asterisk:
  15315. this.universal();
  15316. break;
  15317. case tokens.ampersand:
  15318. this.nesting();
  15319. break;
  15320. case tokens.slash:
  15321. case tokens.combinator:
  15322. this.combinator();
  15323. break;
  15324. case tokens.str:
  15325. this.string();
  15326. break;
  15327. // These cases throw; no break needed.
  15328. case tokens.closeSquare:
  15329. this.missingSquareBracket();
  15330. case tokens.semicolon:
  15331. this.missingBackslash();
  15332. default:
  15333. this.unexpected();
  15334. }
  15335. }
  15336. /**
  15337. * Helpers
  15338. */;
  15339. _proto.expected = function expected(description, index, found) {
  15340. if (Array.isArray(description)) {
  15341. var last = description.pop();
  15342. description = description.join(', ') + " or " + last;
  15343. }
  15344. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  15345. if (!found) {
  15346. return this.error("Expected " + an + " " + description + ".", {
  15347. index: index
  15348. });
  15349. }
  15350. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  15351. index: index
  15352. });
  15353. };
  15354. _proto.requiredSpace = function requiredSpace(space) {
  15355. return this.options.lossy ? ' ' : space;
  15356. };
  15357. _proto.optionalSpace = function optionalSpace(space) {
  15358. return this.options.lossy ? '' : space;
  15359. };
  15360. _proto.lossySpace = function lossySpace(space, required) {
  15361. if (this.options.lossy) {
  15362. return required ? ' ' : '';
  15363. } else {
  15364. return space;
  15365. }
  15366. };
  15367. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  15368. var content = this.content(token);
  15369. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  15370. return this.requiredSpace(content);
  15371. } else {
  15372. return content;
  15373. }
  15374. };
  15375. _proto.newNode = function newNode(node, namespace) {
  15376. if (namespace) {
  15377. if (/^ +$/.test(namespace)) {
  15378. if (!this.options.lossy) {
  15379. this.spaces = (this.spaces || '') + namespace;
  15380. }
  15381. namespace = true;
  15382. }
  15383. node.namespace = namespace;
  15384. unescapeProp(node, "namespace");
  15385. }
  15386. if (this.spaces) {
  15387. node.spaces.before = this.spaces;
  15388. this.spaces = '';
  15389. }
  15390. return this.current.append(node);
  15391. };
  15392. _proto.content = function content(token) {
  15393. if (token === void 0) {
  15394. token = this.currToken;
  15395. }
  15396. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  15397. };
  15398. /**
  15399. * returns the index of the next non-whitespace, non-comment token.
  15400. * returns -1 if no meaningful token is found.
  15401. */
  15402. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  15403. if (startPosition === void 0) {
  15404. startPosition = this.position + 1;
  15405. }
  15406. var searchPosition = startPosition;
  15407. while (searchPosition < this.tokens.length) {
  15408. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  15409. searchPosition++;
  15410. continue;
  15411. } else {
  15412. return searchPosition;
  15413. }
  15414. }
  15415. return -1;
  15416. };
  15417. _createClass(Parser, [{
  15418. key: "currToken",
  15419. get: function get() {
  15420. return this.tokens[this.position];
  15421. }
  15422. }, {
  15423. key: "nextToken",
  15424. get: function get() {
  15425. return this.tokens[this.position + 1];
  15426. }
  15427. }, {
  15428. key: "prevToken",
  15429. get: function get() {
  15430. return this.tokens[this.position - 1];
  15431. }
  15432. }]);
  15433. return Parser;
  15434. }();
  15435. exports["default"] = Parser;
  15436. module.exports = exports.default;
  15437. } (parser, parser.exports));
  15438. (function (module, exports) {
  15439. exports.__esModule = true;
  15440. exports["default"] = void 0;
  15441. var _parser = _interopRequireDefault(parser.exports);
  15442. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15443. var Processor = /*#__PURE__*/function () {
  15444. function Processor(func, options) {
  15445. this.func = func || function noop() {};
  15446. this.funcRes = null;
  15447. this.options = options;
  15448. }
  15449. var _proto = Processor.prototype;
  15450. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  15451. if (options === void 0) {
  15452. options = {};
  15453. }
  15454. var merged = Object.assign({}, this.options, options);
  15455. if (merged.updateSelector === false) {
  15456. return false;
  15457. } else {
  15458. return typeof rule !== "string";
  15459. }
  15460. };
  15461. _proto._isLossy = function _isLossy(options) {
  15462. if (options === void 0) {
  15463. options = {};
  15464. }
  15465. var merged = Object.assign({}, this.options, options);
  15466. if (merged.lossless === false) {
  15467. return true;
  15468. } else {
  15469. return false;
  15470. }
  15471. };
  15472. _proto._root = function _root(rule, options) {
  15473. if (options === void 0) {
  15474. options = {};
  15475. }
  15476. var parser = new _parser["default"](rule, this._parseOptions(options));
  15477. return parser.root;
  15478. };
  15479. _proto._parseOptions = function _parseOptions(options) {
  15480. return {
  15481. lossy: this._isLossy(options)
  15482. };
  15483. };
  15484. _proto._run = function _run(rule, options) {
  15485. var _this = this;
  15486. if (options === void 0) {
  15487. options = {};
  15488. }
  15489. return new Promise(function (resolve, reject) {
  15490. try {
  15491. var root = _this._root(rule, options);
  15492. Promise.resolve(_this.func(root)).then(function (transform) {
  15493. var string = undefined;
  15494. if (_this._shouldUpdateSelector(rule, options)) {
  15495. string = root.toString();
  15496. rule.selector = string;
  15497. }
  15498. return {
  15499. transform: transform,
  15500. root: root,
  15501. string: string
  15502. };
  15503. }).then(resolve, reject);
  15504. } catch (e) {
  15505. reject(e);
  15506. return;
  15507. }
  15508. });
  15509. };
  15510. _proto._runSync = function _runSync(rule, options) {
  15511. if (options === void 0) {
  15512. options = {};
  15513. }
  15514. var root = this._root(rule, options);
  15515. var transform = this.func(root);
  15516. if (transform && typeof transform.then === "function") {
  15517. throw new Error("Selector processor returned a promise to a synchronous call.");
  15518. }
  15519. var string = undefined;
  15520. if (options.updateSelector && typeof rule !== "string") {
  15521. string = root.toString();
  15522. rule.selector = string;
  15523. }
  15524. return {
  15525. transform: transform,
  15526. root: root,
  15527. string: string
  15528. };
  15529. }
  15530. /**
  15531. * Process rule into a selector AST.
  15532. *
  15533. * @param rule {postcss.Rule | string} The css selector to be processed
  15534. * @param options The options for processing
  15535. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  15536. */;
  15537. _proto.ast = function ast(rule, options) {
  15538. return this._run(rule, options).then(function (result) {
  15539. return result.root;
  15540. });
  15541. }
  15542. /**
  15543. * Process rule into a selector AST synchronously.
  15544. *
  15545. * @param rule {postcss.Rule | string} The css selector to be processed
  15546. * @param options The options for processing
  15547. * @returns {parser.Root} The AST of the selector after processing it.
  15548. */;
  15549. _proto.astSync = function astSync(rule, options) {
  15550. return this._runSync(rule, options).root;
  15551. }
  15552. /**
  15553. * Process a selector into a transformed value asynchronously
  15554. *
  15555. * @param rule {postcss.Rule | string} The css selector to be processed
  15556. * @param options The options for processing
  15557. * @returns {Promise<any>} The value returned by the processor.
  15558. */;
  15559. _proto.transform = function transform(rule, options) {
  15560. return this._run(rule, options).then(function (result) {
  15561. return result.transform;
  15562. });
  15563. }
  15564. /**
  15565. * Process a selector into a transformed value synchronously.
  15566. *
  15567. * @param rule {postcss.Rule | string} The css selector to be processed
  15568. * @param options The options for processing
  15569. * @returns {any} The value returned by the processor.
  15570. */;
  15571. _proto.transformSync = function transformSync(rule, options) {
  15572. return this._runSync(rule, options).transform;
  15573. }
  15574. /**
  15575. * Process a selector into a new selector string asynchronously.
  15576. *
  15577. * @param rule {postcss.Rule | string} The css selector to be processed
  15578. * @param options The options for processing
  15579. * @returns {string} the selector after processing.
  15580. */;
  15581. _proto.process = function process(rule, options) {
  15582. return this._run(rule, options).then(function (result) {
  15583. return result.string || result.root.toString();
  15584. });
  15585. }
  15586. /**
  15587. * Process a selector into a new selector string synchronously.
  15588. *
  15589. * @param rule {postcss.Rule | string} The css selector to be processed
  15590. * @param options The options for processing
  15591. * @returns {string} the selector after processing.
  15592. */;
  15593. _proto.processSync = function processSync(rule, options) {
  15594. var result = this._runSync(rule, options);
  15595. return result.string || result.root.toString();
  15596. };
  15597. return Processor;
  15598. }();
  15599. exports["default"] = Processor;
  15600. module.exports = exports.default;
  15601. } (processor, processor.exports));
  15602. var selectors = {};
  15603. var constructors = {};
  15604. constructors.__esModule = true;
  15605. constructors.universal = constructors.tag = constructors.string = constructors.selector = constructors.root = constructors.pseudo = constructors.nesting = constructors.id = constructors.comment = constructors.combinator = constructors.className = constructors.attribute = void 0;
  15606. var _attribute = _interopRequireDefault(attribute$1);
  15607. var _className = _interopRequireDefault(className$1.exports);
  15608. var _combinator = _interopRequireDefault(combinator$2.exports);
  15609. var _comment = _interopRequireDefault(comment$2.exports);
  15610. var _id = _interopRequireDefault(id$1.exports);
  15611. var _nesting = _interopRequireDefault(nesting$1.exports);
  15612. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  15613. var _root = _interopRequireDefault(root$1.exports);
  15614. var _selector = _interopRequireDefault(selector$1.exports);
  15615. var _string = _interopRequireDefault(string$1.exports);
  15616. var _tag = _interopRequireDefault(tag$1.exports);
  15617. var _universal = _interopRequireDefault(universal$1.exports);
  15618. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15619. var attribute = function attribute(opts) {
  15620. return new _attribute["default"](opts);
  15621. };
  15622. constructors.attribute = attribute;
  15623. var className = function className(opts) {
  15624. return new _className["default"](opts);
  15625. };
  15626. constructors.className = className;
  15627. var combinator = function combinator(opts) {
  15628. return new _combinator["default"](opts);
  15629. };
  15630. constructors.combinator = combinator;
  15631. var comment = function comment(opts) {
  15632. return new _comment["default"](opts);
  15633. };
  15634. constructors.comment = comment;
  15635. var id = function id(opts) {
  15636. return new _id["default"](opts);
  15637. };
  15638. constructors.id = id;
  15639. var nesting = function nesting(opts) {
  15640. return new _nesting["default"](opts);
  15641. };
  15642. constructors.nesting = nesting;
  15643. var pseudo = function pseudo(opts) {
  15644. return new _pseudo["default"](opts);
  15645. };
  15646. constructors.pseudo = pseudo;
  15647. var root = function root(opts) {
  15648. return new _root["default"](opts);
  15649. };
  15650. constructors.root = root;
  15651. var selector = function selector(opts) {
  15652. return new _selector["default"](opts);
  15653. };
  15654. constructors.selector = selector;
  15655. var string = function string(opts) {
  15656. return new _string["default"](opts);
  15657. };
  15658. constructors.string = string;
  15659. var tag = function tag(opts) {
  15660. return new _tag["default"](opts);
  15661. };
  15662. constructors.tag = tag;
  15663. var universal = function universal(opts) {
  15664. return new _universal["default"](opts);
  15665. };
  15666. constructors.universal = universal;
  15667. var guards = {};
  15668. guards.__esModule = true;
  15669. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  15670. guards.isContainer = isContainer;
  15671. guards.isIdentifier = void 0;
  15672. guards.isNamespace = isNamespace;
  15673. guards.isNesting = void 0;
  15674. guards.isNode = isNode;
  15675. guards.isPseudo = void 0;
  15676. guards.isPseudoClass = isPseudoClass;
  15677. guards.isPseudoElement = isPseudoElement;
  15678. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  15679. var _types = types;
  15680. var _IS_TYPE;
  15681. var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE);
  15682. function isNode(node) {
  15683. return typeof node === "object" && IS_TYPE[node.type];
  15684. }
  15685. function isNodeType(type, node) {
  15686. return isNode(node) && node.type === type;
  15687. }
  15688. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  15689. guards.isAttribute = isAttribute;
  15690. var isClassName = isNodeType.bind(null, _types.CLASS);
  15691. guards.isClassName = isClassName;
  15692. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  15693. guards.isCombinator = isCombinator;
  15694. var isComment = isNodeType.bind(null, _types.COMMENT);
  15695. guards.isComment = isComment;
  15696. var isIdentifier = isNodeType.bind(null, _types.ID);
  15697. guards.isIdentifier = isIdentifier;
  15698. var isNesting = isNodeType.bind(null, _types.NESTING);
  15699. guards.isNesting = isNesting;
  15700. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  15701. guards.isPseudo = isPseudo;
  15702. var isRoot = isNodeType.bind(null, _types.ROOT);
  15703. guards.isRoot = isRoot;
  15704. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  15705. guards.isSelector = isSelector;
  15706. var isString = isNodeType.bind(null, _types.STRING);
  15707. guards.isString = isString;
  15708. var isTag = isNodeType.bind(null, _types.TAG);
  15709. guards.isTag = isTag;
  15710. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  15711. guards.isUniversal = isUniversal;
  15712. function isPseudoElement(node) {
  15713. return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
  15714. }
  15715. function isPseudoClass(node) {
  15716. return isPseudo(node) && !isPseudoElement(node);
  15717. }
  15718. function isContainer(node) {
  15719. return !!(isNode(node) && node.walk);
  15720. }
  15721. function isNamespace(node) {
  15722. return isAttribute(node) || isTag(node);
  15723. }
  15724. (function (exports) {
  15725. exports.__esModule = true;
  15726. var _types = types;
  15727. Object.keys(_types).forEach(function (key) {
  15728. if (key === "default" || key === "__esModule") return;
  15729. if (key in exports && exports[key] === _types[key]) return;
  15730. exports[key] = _types[key];
  15731. });
  15732. var _constructors = constructors;
  15733. Object.keys(_constructors).forEach(function (key) {
  15734. if (key === "default" || key === "__esModule") return;
  15735. if (key in exports && exports[key] === _constructors[key]) return;
  15736. exports[key] = _constructors[key];
  15737. });
  15738. var _guards = guards;
  15739. Object.keys(_guards).forEach(function (key) {
  15740. if (key === "default" || key === "__esModule") return;
  15741. if (key in exports && exports[key] === _guards[key]) return;
  15742. exports[key] = _guards[key];
  15743. });
  15744. } (selectors));
  15745. (function (module, exports) {
  15746. exports.__esModule = true;
  15747. exports["default"] = void 0;
  15748. var _processor = _interopRequireDefault(processor.exports);
  15749. var selectors$1 = _interopRequireWildcard(selectors);
  15750. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  15751. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  15752. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15753. var parser = function parser(processor) {
  15754. return new _processor["default"](processor);
  15755. };
  15756. Object.assign(parser, selectors$1);
  15757. delete parser.__esModule;
  15758. var _default = parser;
  15759. exports["default"] = _default;
  15760. module.exports = exports.default;
  15761. } (dist, dist.exports));
  15762. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(dist.exports);
  15763. const animationNameRE = /^(-\w+-)?animation-name$/;
  15764. const animationRE = /^(-\w+-)?animation$/;
  15765. const scopedPlugin = (id = '') => {
  15766. const keyframes = Object.create(null);
  15767. const shortId = id.replace(/^data-v-/, '');
  15768. return {
  15769. postcssPlugin: 'vue-sfc-scoped',
  15770. Rule(rule) {
  15771. processRule(id, rule);
  15772. },
  15773. AtRule(node) {
  15774. if (/-?keyframes$/.test(node.name) &&
  15775. !node.params.endsWith(`-${shortId}`)) {
  15776. // register keyframes
  15777. keyframes[node.params] = node.params = node.params + '-' + shortId;
  15778. }
  15779. },
  15780. OnceExit(root) {
  15781. if (Object.keys(keyframes).length) {
  15782. // If keyframes are found in this <style>, find and rewrite animation names
  15783. // in declarations.
  15784. // Caveat: this only works for keyframes and animation rules in the same
  15785. // <style> element.
  15786. // individual animation-name declaration
  15787. root.walkDecls(decl => {
  15788. if (animationNameRE.test(decl.prop)) {
  15789. decl.value = decl.value
  15790. .split(',')
  15791. .map(v => keyframes[v.trim()] || v.trim())
  15792. .join(',');
  15793. }
  15794. // shorthand
  15795. if (animationRE.test(decl.prop)) {
  15796. decl.value = decl.value
  15797. .split(',')
  15798. .map(v => {
  15799. const vals = v.trim().split(/\s+/);
  15800. const i = vals.findIndex(val => keyframes[val]);
  15801. if (i !== -1) {
  15802. vals.splice(i, 1, keyframes[vals[i]]);
  15803. return vals.join(' ');
  15804. }
  15805. else {
  15806. return v;
  15807. }
  15808. })
  15809. .join(',');
  15810. }
  15811. });
  15812. }
  15813. }
  15814. };
  15815. };
  15816. const processedRules = new WeakSet();
  15817. function processRule(id, rule) {
  15818. if (processedRules.has(rule) ||
  15819. (rule.parent &&
  15820. rule.parent.type === 'atrule' &&
  15821. /-?keyframes$/.test(rule.parent.name))) {
  15822. return;
  15823. }
  15824. processedRules.add(rule);
  15825. rule.selector = selectorParser(selectorRoot => {
  15826. selectorRoot.each(selector => {
  15827. rewriteSelector(id, selector, selectorRoot);
  15828. });
  15829. }).processSync(rule.selector);
  15830. }
  15831. function rewriteSelector(id, selector, selectorRoot) {
  15832. let node = null;
  15833. // find the last child node to insert attribute selector
  15834. selector.each(n => {
  15835. // DEPRECATED ">>>" and "/deep/" combinator
  15836. if (n.type === 'combinator' &&
  15837. (n.value === '>>>' || n.value === '/deep/')) {
  15838. n.value = ' ';
  15839. n.spaces.before = n.spaces.after = '';
  15840. // warn(
  15841. // `the >>> and /deep/ combinators have been deprecated. ` +
  15842. // `Use :deep() instead.`
  15843. // )
  15844. return false;
  15845. }
  15846. if (n.type === 'pseudo') {
  15847. const { value } = n;
  15848. // deep: inject [id] attribute at the node before the ::v-deep
  15849. // combinator.
  15850. if (value === ':deep' || value === '::v-deep') {
  15851. if (n.nodes.length) {
  15852. // .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar
  15853. // replace the current node with ::v-deep's inner selector
  15854. let last = n;
  15855. n.nodes[0].each(ss => {
  15856. selector.insertAfter(last, ss);
  15857. last = ss;
  15858. });
  15859. // insert a space combinator before if it doesn't already have one
  15860. const prev = selector.at(selector.index(n) - 1);
  15861. if (!prev || !isSpaceCombinator(prev)) {
  15862. selector.insertAfter(n, selectorParser.combinator({
  15863. value: ' '
  15864. }));
  15865. }
  15866. selector.removeChild(n);
  15867. }
  15868. else {
  15869. // DEPRECATED usage in v3
  15870. // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
  15871. // warn(
  15872. // `::v-deep usage as a combinator has ` +
  15873. // `been deprecated. Use :deep(<inner-selector>) instead.`
  15874. // )
  15875. const prev = selector.at(selector.index(n) - 1);
  15876. if (prev && isSpaceCombinator(prev)) {
  15877. selector.removeChild(prev);
  15878. }
  15879. selector.removeChild(n);
  15880. }
  15881. return false;
  15882. }
  15883. // !!! Vue 2 does not have :slotted support
  15884. // ::v-slotted(.foo) -> .foo[xxxxxxx-s]
  15885. // if (value === ':slotted' || value === '::v-slotted') {
  15886. // rewriteSelector(id, n.nodes[0], selectorRoot, true /* slotted */)
  15887. // let last: selectorParser.Selector['nodes'][0] = n
  15888. // n.nodes[0].each(ss => {
  15889. // selector.insertAfter(last, ss)
  15890. // last = ss
  15891. // })
  15892. // // selector.insertAfter(n, n.nodes[0])
  15893. // selector.removeChild(n)
  15894. // // since slotted attribute already scopes the selector there's no
  15895. // // need for the non-slot attribute.
  15896. // shouldInject = false
  15897. // return false
  15898. // }
  15899. // global: replace with inner selector and do not inject [id].
  15900. // ::v-global(.foo) -> .foo
  15901. if (value === ':global' || value === '::v-global') {
  15902. selectorRoot.insertAfter(selector, n.nodes[0]);
  15903. selectorRoot.removeChild(selector);
  15904. return false;
  15905. }
  15906. }
  15907. if (n.type !== 'pseudo' && n.type !== 'combinator') {
  15908. node = n;
  15909. }
  15910. });
  15911. if (node) {
  15912. node.spaces.after = '';
  15913. }
  15914. else {
  15915. // For deep selectors & standalone pseudo selectors,
  15916. // the attribute selectors are prepended rather than appended.
  15917. // So all leading spaces must be eliminated to avoid problems.
  15918. selector.first.spaces.before = '';
  15919. }
  15920. {
  15921. selector.insertAfter(
  15922. // If node is null it means we need to inject [id] at the start
  15923. // insertAfter can handle `null` here
  15924. node, selectorParser.attribute({
  15925. attribute: id,
  15926. value: id,
  15927. raws: {},
  15928. quoteMark: `"`
  15929. }));
  15930. }
  15931. }
  15932. function isSpaceCombinator(node) {
  15933. return node.type === 'combinator' && /^\s+$/.test(node.value);
  15934. }
  15935. scopedPlugin.postcss = true;
  15936. var sourceMap = require$$0__default$1["default"];
  15937. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  15938. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  15939. var mergeSourceMap = merge;
  15940. /**
  15941. * Merge old source map and new source map and return merged.
  15942. * If old or new source map value is falsy, return another one as it is.
  15943. *
  15944. * @param {object|string} [oldMap] old source map object
  15945. * @param {object|string} [newmap] new source map object
  15946. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  15947. */
  15948. function merge(oldMap, newMap) {
  15949. if (!oldMap) return newMap
  15950. if (!newMap) return oldMap
  15951. var oldMapConsumer = new SourceMapConsumer(oldMap);
  15952. var newMapConsumer = new SourceMapConsumer(newMap);
  15953. var mergedMapGenerator = new SourceMapGenerator();
  15954. // iterate on new map and overwrite original position of new map with one of old map
  15955. newMapConsumer.eachMapping(function(m) {
  15956. // pass when `originalLine` is null.
  15957. // It occurs in case that the node does not have origin in original code.
  15958. if (m.originalLine == null) return
  15959. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  15960. line: m.originalLine,
  15961. column: m.originalColumn
  15962. });
  15963. if (origPosInOldMap.source == null) return
  15964. mergedMapGenerator.addMapping({
  15965. original: {
  15966. line: origPosInOldMap.line,
  15967. column: origPosInOldMap.column
  15968. },
  15969. generated: {
  15970. line: m.generatedLine,
  15971. column: m.generatedColumn
  15972. },
  15973. source: origPosInOldMap.source,
  15974. name: origPosInOldMap.name
  15975. });
  15976. });
  15977. var consumers = [oldMapConsumer, newMapConsumer];
  15978. consumers.forEach(function(consumer) {
  15979. consumer.sources.forEach(function(sourceFile) {
  15980. mergedMapGenerator._sources.add(sourceFile);
  15981. var sourceContent = consumer.sourceContentFor(sourceFile);
  15982. if (sourceContent != null) {
  15983. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  15984. }
  15985. });
  15986. });
  15987. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  15988. mergedMapGenerator._file = oldMap.file;
  15989. return JSON.parse(mergedMapGenerator.toString())
  15990. }
  15991. // .scss/.sass processor
  15992. const scss = (source, map, options) => {
  15993. const nodeSass = require('sass');
  15994. const finalOptions = Object.assign(Object.assign({}, options), { data: getSource(source, options.filename, options.additionalData), file: options.filename, outFile: options.filename, sourceMap: !!map });
  15995. try {
  15996. const result = nodeSass.renderSync(finalOptions);
  15997. const dependencies = result.stats.includedFiles;
  15998. if (map) {
  15999. return {
  16000. code: result.css.toString(),
  16001. map: mergeSourceMap(map, JSON.parse(result.map.toString())),
  16002. errors: [],
  16003. dependencies
  16004. };
  16005. }
  16006. return { code: result.css.toString(), errors: [], dependencies };
  16007. }
  16008. catch (e) {
  16009. return { code: '', errors: [e], dependencies: [] };
  16010. }
  16011. };
  16012. const sass = (source, map, options) => scss(source, map, Object.assign(Object.assign({}, options), { indentedSyntax: true }));
  16013. // .less
  16014. const less = (source, map, options) => {
  16015. const nodeLess = require('less');
  16016. let result;
  16017. let error = null;
  16018. nodeLess.render(getSource(source, options.filename, options.additionalData), Object.assign(Object.assign({}, options), { syncImport: true }), (err, output) => {
  16019. error = err;
  16020. result = output;
  16021. });
  16022. if (error)
  16023. return { code: '', errors: [error], dependencies: [] };
  16024. const dependencies = result.imports;
  16025. if (map) {
  16026. return {
  16027. code: result.css.toString(),
  16028. map: mergeSourceMap(map, result.map),
  16029. errors: [],
  16030. dependencies: dependencies
  16031. };
  16032. }
  16033. return {
  16034. code: result.css.toString(),
  16035. errors: [],
  16036. dependencies: dependencies
  16037. };
  16038. };
  16039. // .styl
  16040. const styl = (source, map, options) => {
  16041. const nodeStylus = require('stylus');
  16042. try {
  16043. const ref = nodeStylus(source);
  16044. Object.keys(options).forEach(key => ref.set(key, options[key]));
  16045. if (map)
  16046. ref.set('sourcemap', { inline: false, comment: false });
  16047. const result = ref.render();
  16048. const dependencies = ref.deps();
  16049. if (map) {
  16050. return {
  16051. code: result,
  16052. map: mergeSourceMap(map, ref.sourcemap),
  16053. errors: [],
  16054. dependencies
  16055. };
  16056. }
  16057. return { code: result, errors: [], dependencies };
  16058. }
  16059. catch (e) {
  16060. return { code: '', errors: [e], dependencies: [] };
  16061. }
  16062. };
  16063. function getSource(source, filename, additionalData) {
  16064. if (!additionalData)
  16065. return source;
  16066. if (isFunction(additionalData)) {
  16067. return additionalData(source, filename);
  16068. }
  16069. return additionalData + source;
  16070. }
  16071. const processors = {
  16072. less,
  16073. sass,
  16074. scss,
  16075. styl,
  16076. stylus: styl
  16077. };
  16078. const postcss = require('postcss');
  16079. function compileStyle(options) {
  16080. return doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: false }));
  16081. }
  16082. function compileStyleAsync(options) {
  16083. return Promise.resolve(doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: true })));
  16084. }
  16085. function doCompileStyle(options) {
  16086. const { filename, id, scoped = true, trim = true, isProd = false, preprocessLang, postcssOptions, postcssPlugins } = options;
  16087. const preprocessor = preprocessLang && processors[preprocessLang];
  16088. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  16089. const map = preProcessedSource ? preProcessedSource.map : options.map;
  16090. const source = preProcessedSource ? preProcessedSource.code : options.source;
  16091. const plugins = (postcssPlugins || []).slice();
  16092. plugins.unshift(cssVarsPlugin({ id: id.replace(/^data-v-/, ''), isProd }));
  16093. if (trim) {
  16094. plugins.push(trimPlugin());
  16095. }
  16096. if (scoped) {
  16097. plugins.push(scopedPlugin(id));
  16098. }
  16099. const postCSSOptions = Object.assign(Object.assign({}, postcssOptions), { to: filename, from: filename });
  16100. if (map) {
  16101. postCSSOptions.map = {
  16102. inline: false,
  16103. annotation: false,
  16104. prev: map
  16105. };
  16106. }
  16107. let result, code, outMap;
  16108. const errors = [];
  16109. if (preProcessedSource && preProcessedSource.errors.length) {
  16110. errors.push(...preProcessedSource.errors);
  16111. }
  16112. try {
  16113. result = postcss(plugins).process(source, postCSSOptions);
  16114. // In async mode, return a promise.
  16115. if (options.isAsync) {
  16116. return result
  16117. .then((result) => ({
  16118. code: result.css || '',
  16119. map: result.map && result.map.toJSON(),
  16120. errors,
  16121. rawResult: result
  16122. }))
  16123. .catch((error) => ({
  16124. code: '',
  16125. map: undefined,
  16126. errors: [...errors, error.message],
  16127. rawResult: undefined
  16128. }));
  16129. }
  16130. // force synchronous transform (we know we only have sync plugins)
  16131. code = result.css;
  16132. outMap = result.map;
  16133. }
  16134. catch (e) {
  16135. errors.push(e);
  16136. }
  16137. return {
  16138. code: code || ``,
  16139. map: outMap && outMap.toJSON(),
  16140. errors,
  16141. rawResult: result
  16142. };
  16143. }
  16144. function preprocess(options, preprocessor) {
  16145. return preprocessor(options.source, options.map, Object.assign({
  16146. filename: options.filename
  16147. }, options.preprocessOptions));
  16148. }
  16149. exports.compileScript = compileScript;
  16150. exports.compileStyle = compileStyle;
  16151. exports.compileStyleAsync = compileStyleAsync;
  16152. exports.compileTemplate = compileTemplate;
  16153. exports.generateCodeFrame = generateCodeFrame;
  16154. exports.parse = parse;
  16155. exports.parseComponent = parseComponent;
  16156. exports.rewriteDefault = rewriteDefault;