compiler-sfc.js 643 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889
  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, null, 2)
  132. : String(val);
  133. }
  134. /**
  135. * Convert an input value to a number for persistence.
  136. * If the conversion fails, return original string.
  137. */
  138. function toNumber(val) {
  139. const n = parseFloat(val);
  140. return isNaN(n) ? val : n;
  141. }
  142. /**
  143. * Make a map and return a function for checking if a key
  144. * is in that map.
  145. */
  146. function makeMap(str, expectsLowerCase) {
  147. const map = Object.create(null);
  148. const list = str.split(',');
  149. for (let i = 0; i < list.length; i++) {
  150. map[list[i]] = true;
  151. }
  152. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  153. }
  154. /**
  155. * Check if a tag is a built-in tag.
  156. */
  157. const isBuiltInTag = makeMap('slot,component', true);
  158. /**
  159. * Check if an attribute is a reserved attribute.
  160. */
  161. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  162. /**
  163. * Check whether an object has the property.
  164. */
  165. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  166. function hasOwn(obj, key) {
  167. return hasOwnProperty$1.call(obj, key);
  168. }
  169. /**
  170. * Create a cached version of a pure function.
  171. */
  172. function cached(fn) {
  173. const cache = Object.create(null);
  174. return function cachedFn(str) {
  175. const hit = cache[str];
  176. return hit || (cache[str] = fn(str));
  177. };
  178. }
  179. /**
  180. * Camelize a hyphen-delimited string.
  181. */
  182. const camelizeRE = /-(\w)/g;
  183. const camelize = cached((str) => {
  184. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  185. });
  186. /**
  187. * Capitalize a string.
  188. */
  189. const capitalize = cached((str) => {
  190. return str.charAt(0).toUpperCase() + str.slice(1);
  191. });
  192. /**
  193. * Hyphenate a camelCase string.
  194. */
  195. const hyphenateRE = /\B([A-Z])/g;
  196. const hyphenate = cached((str) => {
  197. return str.replace(hyphenateRE, '-$1').toLowerCase();
  198. });
  199. /**
  200. * Mix properties into target object.
  201. */
  202. function extend(to, _from) {
  203. for (const key in _from) {
  204. to[key] = _from[key];
  205. }
  206. return to;
  207. }
  208. /**
  209. * Merge an Array of Objects into a single Object.
  210. */
  211. function toObject(arr) {
  212. const res = {};
  213. for (let i = 0; i < arr.length; i++) {
  214. if (arr[i]) {
  215. extend(res, arr[i]);
  216. }
  217. }
  218. return res;
  219. }
  220. /* eslint-disable no-unused-vars */
  221. /**
  222. * Perform no operation.
  223. * Stubbing args to make Flow happy without leaving useless transpiled code
  224. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  225. */
  226. function noop(a, b, c) { }
  227. /**
  228. * Always return false.
  229. */
  230. const no = (a, b, c) => false;
  231. /* eslint-enable no-unused-vars */
  232. /**
  233. * Return the same value.
  234. */
  235. const identity = (_) => _;
  236. /**
  237. * Generate a string containing static keys from compiler modules.
  238. */
  239. function genStaticKeys$1(modules) {
  240. return modules
  241. .reduce((keys, m) => {
  242. return keys.concat(m.staticKeys || []);
  243. }, [])
  244. .join(',');
  245. }
  246. /**
  247. * Check if two values are loosely equal - that is,
  248. * if they are plain objects, do they have the same shape?
  249. */
  250. function looseEqual(a, b) {
  251. if (a === b)
  252. return true;
  253. const isObjectA = isObject$1(a);
  254. const isObjectB = isObject$1(b);
  255. if (isObjectA && isObjectB) {
  256. try {
  257. const isArrayA = Array.isArray(a);
  258. const isArrayB = Array.isArray(b);
  259. if (isArrayA && isArrayB) {
  260. return (a.length === b.length &&
  261. a.every((e, i) => {
  262. return looseEqual(e, b[i]);
  263. }));
  264. }
  265. else if (a instanceof Date && b instanceof Date) {
  266. return a.getTime() === b.getTime();
  267. }
  268. else if (!isArrayA && !isArrayB) {
  269. const keysA = Object.keys(a);
  270. const keysB = Object.keys(b);
  271. return (keysA.length === keysB.length &&
  272. keysA.every(key => {
  273. return looseEqual(a[key], b[key]);
  274. }));
  275. }
  276. else {
  277. /* istanbul ignore next */
  278. return false;
  279. }
  280. }
  281. catch (e) {
  282. /* istanbul ignore next */
  283. return false;
  284. }
  285. }
  286. else if (!isObjectA && !isObjectB) {
  287. return String(a) === String(b);
  288. }
  289. else {
  290. return false;
  291. }
  292. }
  293. /**
  294. * Return the first index at which a loosely equal value can be
  295. * found in the array (if value is a plain object, the array must
  296. * contain an object of the same shape), or -1 if it is not present.
  297. */
  298. function looseIndexOf(arr, val) {
  299. for (let i = 0; i < arr.length; i++) {
  300. if (looseEqual(arr[i], val))
  301. return i;
  302. }
  303. return -1;
  304. }
  305. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  306. function hasChanged(x, y) {
  307. if (x === y) {
  308. return x === 0 && 1 / x !== 1 / y;
  309. }
  310. else {
  311. return x === x || y === y;
  312. }
  313. }
  314. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  315. 'link,meta,param,source,track,wbr');
  316. // Elements that you can, intentionally, leave open
  317. // (and which close themselves)
  318. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  319. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  320. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  321. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  322. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  323. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  324. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  325. 'title,tr,track');
  326. /**
  327. * unicode letters used for parsing html tags, component names and property paths.
  328. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  329. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  330. */
  331. 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/;
  332. /**
  333. * Define a property.
  334. */
  335. function def(obj, key, val, enumerable) {
  336. Object.defineProperty(obj, key, {
  337. value: val,
  338. enumerable: !!enumerable,
  339. writable: true,
  340. configurable: true
  341. });
  342. }
  343. /**
  344. * Not type-checking this file because it's mostly vendor code.
  345. */
  346. // Regular Expressions for parsing tags and attributes
  347. const attribute$2 = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  348. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  349. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  350. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  351. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  352. const startTagClose = /^\s*(\/?)>/;
  353. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  354. const doctype = /^<!DOCTYPE [^>]+>/i;
  355. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  356. const comment$3 = /^<!\--/;
  357. const conditionalComment = /^<!\[/;
  358. // Special Elements (can contain anything)
  359. const isPlainTextElement = makeMap('script,style,textarea', true);
  360. const reCache = {};
  361. const decodingMap = {
  362. '&lt;': '<',
  363. '&gt;': '>',
  364. '&quot;': '"',
  365. '&amp;': '&',
  366. '&#10;': '\n',
  367. '&#9;': '\t',
  368. '&#39;': "'"
  369. };
  370. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  371. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  372. // #5992
  373. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  374. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  375. function decodeAttr(value, shouldDecodeNewlines) {
  376. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  377. return value.replace(re, match => decodingMap[match]);
  378. }
  379. function parseHTML(html, options) {
  380. const stack = [];
  381. const expectHTML = options.expectHTML;
  382. const isUnaryTag = options.isUnaryTag || no;
  383. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  384. let index = 0;
  385. let last, lastTag;
  386. while (html) {
  387. last = html;
  388. // Make sure we're not in a plaintext content element like script/style
  389. if (!lastTag || !isPlainTextElement(lastTag)) {
  390. let textEnd = html.indexOf('<');
  391. if (textEnd === 0) {
  392. // Comment:
  393. if (comment$3.test(html)) {
  394. const commentEnd = html.indexOf('-->');
  395. if (commentEnd >= 0) {
  396. if (options.shouldKeepComment && options.comment) {
  397. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  398. }
  399. advance(commentEnd + 3);
  400. continue;
  401. }
  402. }
  403. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  404. if (conditionalComment.test(html)) {
  405. const conditionalEnd = html.indexOf(']>');
  406. if (conditionalEnd >= 0) {
  407. advance(conditionalEnd + 2);
  408. continue;
  409. }
  410. }
  411. // Doctype:
  412. const doctypeMatch = html.match(doctype);
  413. if (doctypeMatch) {
  414. advance(doctypeMatch[0].length);
  415. continue;
  416. }
  417. // End tag:
  418. const endTagMatch = html.match(endTag);
  419. if (endTagMatch) {
  420. const curIndex = index;
  421. advance(endTagMatch[0].length);
  422. parseEndTag(endTagMatch[1], curIndex, index);
  423. continue;
  424. }
  425. // Start tag:
  426. const startTagMatch = parseStartTag();
  427. if (startTagMatch) {
  428. handleStartTag(startTagMatch);
  429. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  430. advance(1);
  431. }
  432. continue;
  433. }
  434. }
  435. let text, rest, next;
  436. if (textEnd >= 0) {
  437. rest = html.slice(textEnd);
  438. while (!endTag.test(rest) &&
  439. !startTagOpen.test(rest) &&
  440. !comment$3.test(rest) &&
  441. !conditionalComment.test(rest)) {
  442. // < in plain text, be forgiving and treat it as text
  443. next = rest.indexOf('<', 1);
  444. if (next < 0)
  445. break;
  446. textEnd += next;
  447. rest = html.slice(textEnd);
  448. }
  449. text = html.substring(0, textEnd);
  450. }
  451. if (textEnd < 0) {
  452. text = html;
  453. }
  454. if (text) {
  455. advance(text.length);
  456. }
  457. if (options.chars && text) {
  458. options.chars(text, index - text.length, index);
  459. }
  460. }
  461. else {
  462. let endTagLength = 0;
  463. const stackedTag = lastTag.toLowerCase();
  464. const reStackedTag = reCache[stackedTag] ||
  465. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  466. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  467. endTagLength = endTag.length;
  468. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  469. text = text
  470. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  471. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  472. }
  473. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  474. text = text.slice(1);
  475. }
  476. if (options.chars) {
  477. options.chars(text);
  478. }
  479. return '';
  480. });
  481. index += html.length - rest.length;
  482. html = rest;
  483. parseEndTag(stackedTag, index - endTagLength, index);
  484. }
  485. if (html === last) {
  486. options.chars && options.chars(html);
  487. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  488. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  489. start: index + html.length
  490. });
  491. }
  492. break;
  493. }
  494. }
  495. // Clean up any remaining tags
  496. parseEndTag();
  497. function advance(n) {
  498. index += n;
  499. html = html.substring(n);
  500. }
  501. function parseStartTag() {
  502. const start = html.match(startTagOpen);
  503. if (start) {
  504. const match = {
  505. tagName: start[1],
  506. attrs: [],
  507. start: index
  508. };
  509. advance(start[0].length);
  510. let end, attr;
  511. while (!(end = html.match(startTagClose)) &&
  512. (attr = html.match(dynamicArgAttribute) || html.match(attribute$2))) {
  513. attr.start = index;
  514. advance(attr[0].length);
  515. attr.end = index;
  516. match.attrs.push(attr);
  517. }
  518. if (end) {
  519. match.unarySlash = end[1];
  520. advance(end[0].length);
  521. match.end = index;
  522. return match;
  523. }
  524. }
  525. }
  526. function handleStartTag(match) {
  527. const tagName = match.tagName;
  528. const unarySlash = match.unarySlash;
  529. if (expectHTML) {
  530. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  531. parseEndTag(lastTag);
  532. }
  533. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  534. parseEndTag(tagName);
  535. }
  536. }
  537. const unary = isUnaryTag(tagName) || !!unarySlash;
  538. const l = match.attrs.length;
  539. const attrs = new Array(l);
  540. for (let i = 0; i < l; i++) {
  541. const args = match.attrs[i];
  542. const value = args[3] || args[4] || args[5] || '';
  543. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  544. ? options.shouldDecodeNewlinesForHref
  545. : options.shouldDecodeNewlines;
  546. attrs[i] = {
  547. name: args[1],
  548. value: decodeAttr(value, shouldDecodeNewlines)
  549. };
  550. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  551. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  552. attrs[i].end = args.end;
  553. }
  554. }
  555. if (!unary) {
  556. stack.push({
  557. tag: tagName,
  558. lowerCasedTag: tagName.toLowerCase(),
  559. attrs: attrs,
  560. start: match.start,
  561. end: match.end
  562. });
  563. lastTag = tagName;
  564. }
  565. if (options.start) {
  566. options.start(tagName, attrs, unary, match.start, match.end);
  567. }
  568. }
  569. function parseEndTag(tagName, start, end) {
  570. let pos, lowerCasedTagName;
  571. if (start == null)
  572. start = index;
  573. if (end == null)
  574. end = index;
  575. // Find the closest opened tag of the same type
  576. if (tagName) {
  577. lowerCasedTagName = tagName.toLowerCase();
  578. for (pos = stack.length - 1; pos >= 0; pos--) {
  579. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  580. break;
  581. }
  582. }
  583. }
  584. else {
  585. // If no tag name is provided, clean shop
  586. pos = 0;
  587. }
  588. if (pos >= 0) {
  589. // Close all the open elements, up the stack
  590. for (let i = stack.length - 1; i >= pos; i--) {
  591. if (process.env.NODE_ENV !== 'production' && (i > pos || !tagName) && options.warn) {
  592. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  593. start: stack[i].start,
  594. end: stack[i].end
  595. });
  596. }
  597. if (options.end) {
  598. options.end(stack[i].tag, start, end);
  599. }
  600. }
  601. // Remove the open elements from the stack
  602. stack.length = pos;
  603. lastTag = pos && stack[pos - 1].tag;
  604. }
  605. else if (lowerCasedTagName === 'br') {
  606. if (options.start) {
  607. options.start(tagName, [], true, start, end);
  608. }
  609. }
  610. else if (lowerCasedTagName === 'p') {
  611. if (options.start) {
  612. options.start(tagName, [], false, start, end);
  613. }
  614. if (options.end) {
  615. options.end(tagName, start, end);
  616. }
  617. }
  618. }
  619. }
  620. const DEFAULT_FILENAME = 'anonymous.vue';
  621. const splitRE$1 = /\r?\n/g;
  622. const replaceRE = /./g;
  623. const isSpecialTag = makeMap('script,style,template', true);
  624. /**
  625. * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
  626. */
  627. function parseComponent(source, options = {}) {
  628. const sfc = {
  629. source,
  630. filename: DEFAULT_FILENAME,
  631. template: null,
  632. script: null,
  633. scriptSetup: null,
  634. styles: [],
  635. customBlocks: [],
  636. cssVars: [],
  637. errors: [],
  638. shouldForceReload: null // attached in parse() by compiler-sfc
  639. };
  640. let depth = 0;
  641. let currentBlock = null;
  642. let warn = msg => {
  643. sfc.errors.push(msg);
  644. };
  645. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  646. warn = (msg, range) => {
  647. const data = { msg };
  648. if (range.start != null) {
  649. data.start = range.start;
  650. }
  651. if (range.end != null) {
  652. data.end = range.end;
  653. }
  654. sfc.errors.push(data);
  655. };
  656. }
  657. function start(tag, attrs, unary, start, end) {
  658. if (depth === 0) {
  659. currentBlock = {
  660. type: tag,
  661. content: '',
  662. start: end,
  663. end: 0,
  664. attrs: attrs.reduce((cumulated, { name, value }) => {
  665. cumulated[name] = value || true;
  666. return cumulated;
  667. }, {})
  668. };
  669. if (typeof currentBlock.attrs.src === 'string') {
  670. currentBlock.src = currentBlock.attrs.src;
  671. }
  672. if (isSpecialTag(tag)) {
  673. checkAttrs(currentBlock, attrs);
  674. if (tag === 'script') {
  675. const block = currentBlock;
  676. if (block.attrs.setup) {
  677. block.setup = currentBlock.attrs.setup;
  678. sfc.scriptSetup = block;
  679. }
  680. else {
  681. sfc.script = block;
  682. }
  683. }
  684. else if (tag === 'style') {
  685. sfc.styles.push(currentBlock);
  686. }
  687. else {
  688. sfc[tag] = currentBlock;
  689. }
  690. }
  691. else {
  692. // custom blocks
  693. sfc.customBlocks.push(currentBlock);
  694. }
  695. }
  696. if (!unary) {
  697. depth++;
  698. }
  699. }
  700. function checkAttrs(block, attrs) {
  701. for (let i = 0; i < attrs.length; i++) {
  702. const attr = attrs[i];
  703. if (attr.name === 'lang') {
  704. block.lang = attr.value;
  705. }
  706. if (attr.name === 'scoped') {
  707. block.scoped = true;
  708. }
  709. if (attr.name === 'module') {
  710. block.module = attr.value || true;
  711. }
  712. }
  713. }
  714. function end(tag, start) {
  715. if (depth === 1 && currentBlock) {
  716. currentBlock.end = start;
  717. let text = source.slice(currentBlock.start, currentBlock.end);
  718. if (options.deindent === true ||
  719. // by default, deindent unless it's script with default lang or (j/t)sx?
  720. (options.deindent !== false &&
  721. !(currentBlock.type === 'script' &&
  722. (!currentBlock.lang || /^(j|t)sx?$/.test(currentBlock.lang))))) {
  723. text = deIndent(text);
  724. }
  725. // pad content so that linters and pre-processors can output correct
  726. // line numbers in errors and warnings
  727. if (currentBlock.type !== 'template' && options.pad) {
  728. text = padContent(currentBlock, options.pad) + text;
  729. }
  730. currentBlock.content = text;
  731. currentBlock = null;
  732. }
  733. depth--;
  734. }
  735. function padContent(block, pad) {
  736. if (pad === 'space') {
  737. return source.slice(0, block.start).replace(replaceRE, ' ');
  738. }
  739. else {
  740. const offset = source.slice(0, block.start).split(splitRE$1).length;
  741. const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n';
  742. return Array(offset).join(padChar);
  743. }
  744. }
  745. parseHTML(source, {
  746. warn,
  747. start,
  748. end,
  749. outputSourceRange: options.outputSourceRange
  750. });
  751. return sfc;
  752. }
  753. function pad (hash, len) {
  754. while (hash.length < len) {
  755. hash = '0' + hash;
  756. }
  757. return hash;
  758. }
  759. function fold (hash, text) {
  760. var i;
  761. var chr;
  762. var len;
  763. if (text.length === 0) {
  764. return hash;
  765. }
  766. for (i = 0, len = text.length; i < len; i++) {
  767. chr = text.charCodeAt(i);
  768. hash = ((hash << 5) - hash) + chr;
  769. hash |= 0;
  770. }
  771. return hash < 0 ? hash * -2 : hash;
  772. }
  773. function foldObject (hash, o, seen) {
  774. return Object.keys(o).sort().reduce(foldKey, hash);
  775. function foldKey (hash, key) {
  776. return foldValue(hash, o[key], key, seen);
  777. }
  778. }
  779. function foldValue (input, value, key, seen) {
  780. var hash = fold(fold(fold(input, key), toString$1(value)), typeof value);
  781. if (value === null) {
  782. return fold(hash, 'null');
  783. }
  784. if (value === undefined) {
  785. return fold(hash, 'undefined');
  786. }
  787. if (typeof value === 'object' || typeof value === 'function') {
  788. if (seen.indexOf(value) !== -1) {
  789. return fold(hash, '[Circular]' + key);
  790. }
  791. seen.push(value);
  792. var objHash = foldObject(hash, value, seen);
  793. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  794. return objHash;
  795. }
  796. try {
  797. return fold(objHash, String(value.valueOf()))
  798. } catch (err) {
  799. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  800. }
  801. }
  802. return fold(hash, value.toString());
  803. }
  804. function toString$1 (o) {
  805. return Object.prototype.toString.call(o);
  806. }
  807. function sum (o) {
  808. return pad(foldValue(0, o, '', []).toString(16), 8);
  809. }
  810. var hashSum = sum;
  811. var iterator;
  812. var hasRequiredIterator;
  813. function requireIterator () {
  814. if (hasRequiredIterator) return iterator;
  815. hasRequiredIterator = 1;
  816. iterator = function (Yallist) {
  817. Yallist.prototype[Symbol.iterator] = function* () {
  818. for (let walker = this.head; walker; walker = walker.next) {
  819. yield walker.value;
  820. }
  821. };
  822. };
  823. return iterator;
  824. }
  825. var yallist = Yallist$1;
  826. Yallist$1.Node = Node;
  827. Yallist$1.create = Yallist$1;
  828. function Yallist$1 (list) {
  829. var self = this;
  830. if (!(self instanceof Yallist$1)) {
  831. self = new Yallist$1();
  832. }
  833. self.tail = null;
  834. self.head = null;
  835. self.length = 0;
  836. if (list && typeof list.forEach === 'function') {
  837. list.forEach(function (item) {
  838. self.push(item);
  839. });
  840. } else if (arguments.length > 0) {
  841. for (var i = 0, l = arguments.length; i < l; i++) {
  842. self.push(arguments[i]);
  843. }
  844. }
  845. return self
  846. }
  847. Yallist$1.prototype.removeNode = function (node) {
  848. if (node.list !== this) {
  849. throw new Error('removing node which does not belong to this list')
  850. }
  851. var next = node.next;
  852. var prev = node.prev;
  853. if (next) {
  854. next.prev = prev;
  855. }
  856. if (prev) {
  857. prev.next = next;
  858. }
  859. if (node === this.head) {
  860. this.head = next;
  861. }
  862. if (node === this.tail) {
  863. this.tail = prev;
  864. }
  865. node.list.length--;
  866. node.next = null;
  867. node.prev = null;
  868. node.list = null;
  869. return next
  870. };
  871. Yallist$1.prototype.unshiftNode = function (node) {
  872. if (node === this.head) {
  873. return
  874. }
  875. if (node.list) {
  876. node.list.removeNode(node);
  877. }
  878. var head = this.head;
  879. node.list = this;
  880. node.next = head;
  881. if (head) {
  882. head.prev = node;
  883. }
  884. this.head = node;
  885. if (!this.tail) {
  886. this.tail = node;
  887. }
  888. this.length++;
  889. };
  890. Yallist$1.prototype.pushNode = function (node) {
  891. if (node === this.tail) {
  892. return
  893. }
  894. if (node.list) {
  895. node.list.removeNode(node);
  896. }
  897. var tail = this.tail;
  898. node.list = this;
  899. node.prev = tail;
  900. if (tail) {
  901. tail.next = node;
  902. }
  903. this.tail = node;
  904. if (!this.head) {
  905. this.head = node;
  906. }
  907. this.length++;
  908. };
  909. Yallist$1.prototype.push = function () {
  910. for (var i = 0, l = arguments.length; i < l; i++) {
  911. push(this, arguments[i]);
  912. }
  913. return this.length
  914. };
  915. Yallist$1.prototype.unshift = function () {
  916. for (var i = 0, l = arguments.length; i < l; i++) {
  917. unshift(this, arguments[i]);
  918. }
  919. return this.length
  920. };
  921. Yallist$1.prototype.pop = function () {
  922. if (!this.tail) {
  923. return undefined
  924. }
  925. var res = this.tail.value;
  926. this.tail = this.tail.prev;
  927. if (this.tail) {
  928. this.tail.next = null;
  929. } else {
  930. this.head = null;
  931. }
  932. this.length--;
  933. return res
  934. };
  935. Yallist$1.prototype.shift = function () {
  936. if (!this.head) {
  937. return undefined
  938. }
  939. var res = this.head.value;
  940. this.head = this.head.next;
  941. if (this.head) {
  942. this.head.prev = null;
  943. } else {
  944. this.tail = null;
  945. }
  946. this.length--;
  947. return res
  948. };
  949. Yallist$1.prototype.forEach = function (fn, thisp) {
  950. thisp = thisp || this;
  951. for (var walker = this.head, i = 0; walker !== null; i++) {
  952. fn.call(thisp, walker.value, i, this);
  953. walker = walker.next;
  954. }
  955. };
  956. Yallist$1.prototype.forEachReverse = function (fn, thisp) {
  957. thisp = thisp || this;
  958. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  959. fn.call(thisp, walker.value, i, this);
  960. walker = walker.prev;
  961. }
  962. };
  963. Yallist$1.prototype.get = function (n) {
  964. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  965. // abort out of the list early if we hit a cycle
  966. walker = walker.next;
  967. }
  968. if (i === n && walker !== null) {
  969. return walker.value
  970. }
  971. };
  972. Yallist$1.prototype.getReverse = function (n) {
  973. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  974. // abort out of the list early if we hit a cycle
  975. walker = walker.prev;
  976. }
  977. if (i === n && walker !== null) {
  978. return walker.value
  979. }
  980. };
  981. Yallist$1.prototype.map = function (fn, thisp) {
  982. thisp = thisp || this;
  983. var res = new Yallist$1();
  984. for (var walker = this.head; walker !== null;) {
  985. res.push(fn.call(thisp, walker.value, this));
  986. walker = walker.next;
  987. }
  988. return res
  989. };
  990. Yallist$1.prototype.mapReverse = function (fn, thisp) {
  991. thisp = thisp || this;
  992. var res = new Yallist$1();
  993. for (var walker = this.tail; walker !== null;) {
  994. res.push(fn.call(thisp, walker.value, this));
  995. walker = walker.prev;
  996. }
  997. return res
  998. };
  999. Yallist$1.prototype.reduce = function (fn, initial) {
  1000. var acc;
  1001. var walker = this.head;
  1002. if (arguments.length > 1) {
  1003. acc = initial;
  1004. } else if (this.head) {
  1005. walker = this.head.next;
  1006. acc = this.head.value;
  1007. } else {
  1008. throw new TypeError('Reduce of empty list with no initial value')
  1009. }
  1010. for (var i = 0; walker !== null; i++) {
  1011. acc = fn(acc, walker.value, i);
  1012. walker = walker.next;
  1013. }
  1014. return acc
  1015. };
  1016. Yallist$1.prototype.reduceReverse = function (fn, initial) {
  1017. var acc;
  1018. var walker = this.tail;
  1019. if (arguments.length > 1) {
  1020. acc = initial;
  1021. } else if (this.tail) {
  1022. walker = this.tail.prev;
  1023. acc = this.tail.value;
  1024. } else {
  1025. throw new TypeError('Reduce of empty list with no initial value')
  1026. }
  1027. for (var i = this.length - 1; walker !== null; i--) {
  1028. acc = fn(acc, walker.value, i);
  1029. walker = walker.prev;
  1030. }
  1031. return acc
  1032. };
  1033. Yallist$1.prototype.toArray = function () {
  1034. var arr = new Array(this.length);
  1035. for (var i = 0, walker = this.head; walker !== null; i++) {
  1036. arr[i] = walker.value;
  1037. walker = walker.next;
  1038. }
  1039. return arr
  1040. };
  1041. Yallist$1.prototype.toArrayReverse = function () {
  1042. var arr = new Array(this.length);
  1043. for (var i = 0, walker = this.tail; walker !== null; i++) {
  1044. arr[i] = walker.value;
  1045. walker = walker.prev;
  1046. }
  1047. return arr
  1048. };
  1049. Yallist$1.prototype.slice = function (from, to) {
  1050. to = to || this.length;
  1051. if (to < 0) {
  1052. to += this.length;
  1053. }
  1054. from = from || 0;
  1055. if (from < 0) {
  1056. from += this.length;
  1057. }
  1058. var ret = new Yallist$1();
  1059. if (to < from || to < 0) {
  1060. return ret
  1061. }
  1062. if (from < 0) {
  1063. from = 0;
  1064. }
  1065. if (to > this.length) {
  1066. to = this.length;
  1067. }
  1068. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  1069. walker = walker.next;
  1070. }
  1071. for (; walker !== null && i < to; i++, walker = walker.next) {
  1072. ret.push(walker.value);
  1073. }
  1074. return ret
  1075. };
  1076. Yallist$1.prototype.sliceReverse = function (from, to) {
  1077. to = to || this.length;
  1078. if (to < 0) {
  1079. to += this.length;
  1080. }
  1081. from = from || 0;
  1082. if (from < 0) {
  1083. from += this.length;
  1084. }
  1085. var ret = new Yallist$1();
  1086. if (to < from || to < 0) {
  1087. return ret
  1088. }
  1089. if (from < 0) {
  1090. from = 0;
  1091. }
  1092. if (to > this.length) {
  1093. to = this.length;
  1094. }
  1095. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  1096. walker = walker.prev;
  1097. }
  1098. for (; walker !== null && i > from; i--, walker = walker.prev) {
  1099. ret.push(walker.value);
  1100. }
  1101. return ret
  1102. };
  1103. Yallist$1.prototype.splice = function (start, deleteCount /*, ...nodes */) {
  1104. if (start > this.length) {
  1105. start = this.length - 1;
  1106. }
  1107. if (start < 0) {
  1108. start = this.length + start;
  1109. }
  1110. for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
  1111. walker = walker.next;
  1112. }
  1113. var ret = [];
  1114. for (var i = 0; walker && i < deleteCount; i++) {
  1115. ret.push(walker.value);
  1116. walker = this.removeNode(walker);
  1117. }
  1118. if (walker === null) {
  1119. walker = this.tail;
  1120. }
  1121. if (walker !== this.head && walker !== this.tail) {
  1122. walker = walker.prev;
  1123. }
  1124. for (var i = 2; i < arguments.length; i++) {
  1125. walker = insert(this, walker, arguments[i]);
  1126. }
  1127. return ret;
  1128. };
  1129. Yallist$1.prototype.reverse = function () {
  1130. var head = this.head;
  1131. var tail = this.tail;
  1132. for (var walker = head; walker !== null; walker = walker.prev) {
  1133. var p = walker.prev;
  1134. walker.prev = walker.next;
  1135. walker.next = p;
  1136. }
  1137. this.head = tail;
  1138. this.tail = head;
  1139. return this
  1140. };
  1141. function insert (self, node, value) {
  1142. var inserted = node === self.head ?
  1143. new Node(value, null, node, self) :
  1144. new Node(value, node, node.next, self);
  1145. if (inserted.next === null) {
  1146. self.tail = inserted;
  1147. }
  1148. if (inserted.prev === null) {
  1149. self.head = inserted;
  1150. }
  1151. self.length++;
  1152. return inserted
  1153. }
  1154. function push (self, item) {
  1155. self.tail = new Node(item, self.tail, null, self);
  1156. if (!self.head) {
  1157. self.head = self.tail;
  1158. }
  1159. self.length++;
  1160. }
  1161. function unshift (self, item) {
  1162. self.head = new Node(item, null, self.head, self);
  1163. if (!self.tail) {
  1164. self.tail = self.head;
  1165. }
  1166. self.length++;
  1167. }
  1168. function Node (value, prev, next, list) {
  1169. if (!(this instanceof Node)) {
  1170. return new Node(value, prev, next, list)
  1171. }
  1172. this.list = list;
  1173. this.value = value;
  1174. if (prev) {
  1175. prev.next = this;
  1176. this.prev = prev;
  1177. } else {
  1178. this.prev = null;
  1179. }
  1180. if (next) {
  1181. next.prev = this;
  1182. this.next = next;
  1183. } else {
  1184. this.next = null;
  1185. }
  1186. }
  1187. try {
  1188. // add if support for Symbol.iterator is present
  1189. requireIterator()(Yallist$1);
  1190. } catch (er) {}
  1191. // A linked list to keep track of recently-used-ness
  1192. const Yallist = yallist;
  1193. const MAX = Symbol('max');
  1194. const LENGTH = Symbol('length');
  1195. const LENGTH_CALCULATOR = Symbol('lengthCalculator');
  1196. const ALLOW_STALE = Symbol('allowStale');
  1197. const MAX_AGE = Symbol('maxAge');
  1198. const DISPOSE = Symbol('dispose');
  1199. const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
  1200. const LRU_LIST = Symbol('lruList');
  1201. const CACHE = Symbol('cache');
  1202. const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
  1203. const naiveLength = () => 1;
  1204. // lruList is a yallist where the head is the youngest
  1205. // item, and the tail is the oldest. the list contains the Hit
  1206. // objects as the entries.
  1207. // Each Hit object has a reference to its Yallist.Node. This
  1208. // never changes.
  1209. //
  1210. // cache is a Map (or PseudoMap) that matches the keys to
  1211. // the Yallist.Node object.
  1212. class LRUCache {
  1213. constructor (options) {
  1214. if (typeof options === 'number')
  1215. options = { max: options };
  1216. if (!options)
  1217. options = {};
  1218. if (options.max && (typeof options.max !== 'number' || options.max < 0))
  1219. throw new TypeError('max must be a non-negative number')
  1220. // Kind of weird to have a default max of Infinity, but oh well.
  1221. this[MAX] = options.max || Infinity;
  1222. const lc = options.length || naiveLength;
  1223. this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
  1224. this[ALLOW_STALE] = options.stale || false;
  1225. if (options.maxAge && typeof options.maxAge !== 'number')
  1226. throw new TypeError('maxAge must be a number')
  1227. this[MAX_AGE] = options.maxAge || 0;
  1228. this[DISPOSE] = options.dispose;
  1229. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  1230. this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
  1231. this.reset();
  1232. }
  1233. // resize the cache when the max changes.
  1234. set max (mL) {
  1235. if (typeof mL !== 'number' || mL < 0)
  1236. throw new TypeError('max must be a non-negative number')
  1237. this[MAX] = mL || Infinity;
  1238. trim(this);
  1239. }
  1240. get max () {
  1241. return this[MAX]
  1242. }
  1243. set allowStale (allowStale) {
  1244. this[ALLOW_STALE] = !!allowStale;
  1245. }
  1246. get allowStale () {
  1247. return this[ALLOW_STALE]
  1248. }
  1249. set maxAge (mA) {
  1250. if (typeof mA !== 'number')
  1251. throw new TypeError('maxAge must be a non-negative number')
  1252. this[MAX_AGE] = mA;
  1253. trim(this);
  1254. }
  1255. get maxAge () {
  1256. return this[MAX_AGE]
  1257. }
  1258. // resize the cache when the lengthCalculator changes.
  1259. set lengthCalculator (lC) {
  1260. if (typeof lC !== 'function')
  1261. lC = naiveLength;
  1262. if (lC !== this[LENGTH_CALCULATOR]) {
  1263. this[LENGTH_CALCULATOR] = lC;
  1264. this[LENGTH] = 0;
  1265. this[LRU_LIST].forEach(hit => {
  1266. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  1267. this[LENGTH] += hit.length;
  1268. });
  1269. }
  1270. trim(this);
  1271. }
  1272. get lengthCalculator () { return this[LENGTH_CALCULATOR] }
  1273. get length () { return this[LENGTH] }
  1274. get itemCount () { return this[LRU_LIST].length }
  1275. rforEach (fn, thisp) {
  1276. thisp = thisp || this;
  1277. for (let walker = this[LRU_LIST].tail; walker !== null;) {
  1278. const prev = walker.prev;
  1279. forEachStep(this, fn, walker, thisp);
  1280. walker = prev;
  1281. }
  1282. }
  1283. forEach (fn, thisp) {
  1284. thisp = thisp || this;
  1285. for (let walker = this[LRU_LIST].head; walker !== null;) {
  1286. const next = walker.next;
  1287. forEachStep(this, fn, walker, thisp);
  1288. walker = next;
  1289. }
  1290. }
  1291. keys () {
  1292. return this[LRU_LIST].toArray().map(k => k.key)
  1293. }
  1294. values () {
  1295. return this[LRU_LIST].toArray().map(k => k.value)
  1296. }
  1297. reset () {
  1298. if (this[DISPOSE] &&
  1299. this[LRU_LIST] &&
  1300. this[LRU_LIST].length) {
  1301. this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
  1302. }
  1303. this[CACHE] = new Map(); // hash of items by key
  1304. this[LRU_LIST] = new Yallist(); // list of items in order of use recency
  1305. this[LENGTH] = 0; // length of items in the list
  1306. }
  1307. dump () {
  1308. return this[LRU_LIST].map(hit =>
  1309. isStale(this, hit) ? false : {
  1310. k: hit.key,
  1311. v: hit.value,
  1312. e: hit.now + (hit.maxAge || 0)
  1313. }).toArray().filter(h => h)
  1314. }
  1315. dumpLru () {
  1316. return this[LRU_LIST]
  1317. }
  1318. set (key, value, maxAge) {
  1319. maxAge = maxAge || this[MAX_AGE];
  1320. if (maxAge && typeof maxAge !== 'number')
  1321. throw new TypeError('maxAge must be a number')
  1322. const now = maxAge ? Date.now() : 0;
  1323. const len = this[LENGTH_CALCULATOR](value, key);
  1324. if (this[CACHE].has(key)) {
  1325. if (len > this[MAX]) {
  1326. del(this, this[CACHE].get(key));
  1327. return false
  1328. }
  1329. const node = this[CACHE].get(key);
  1330. const item = node.value;
  1331. // dispose of the old one before overwriting
  1332. // split out into 2 ifs for better coverage tracking
  1333. if (this[DISPOSE]) {
  1334. if (!this[NO_DISPOSE_ON_SET])
  1335. this[DISPOSE](key, item.value);
  1336. }
  1337. item.now = now;
  1338. item.maxAge = maxAge;
  1339. item.value = value;
  1340. this[LENGTH] += len - item.length;
  1341. item.length = len;
  1342. this.get(key);
  1343. trim(this);
  1344. return true
  1345. }
  1346. const hit = new Entry(key, value, len, now, maxAge);
  1347. // oversized objects fall out of cache automatically.
  1348. if (hit.length > this[MAX]) {
  1349. if (this[DISPOSE])
  1350. this[DISPOSE](key, value);
  1351. return false
  1352. }
  1353. this[LENGTH] += hit.length;
  1354. this[LRU_LIST].unshift(hit);
  1355. this[CACHE].set(key, this[LRU_LIST].head);
  1356. trim(this);
  1357. return true
  1358. }
  1359. has (key) {
  1360. if (!this[CACHE].has(key)) return false
  1361. const hit = this[CACHE].get(key).value;
  1362. return !isStale(this, hit)
  1363. }
  1364. get (key) {
  1365. return get(this, key, true)
  1366. }
  1367. peek (key) {
  1368. return get(this, key, false)
  1369. }
  1370. pop () {
  1371. const node = this[LRU_LIST].tail;
  1372. if (!node)
  1373. return null
  1374. del(this, node);
  1375. return node.value
  1376. }
  1377. del (key) {
  1378. del(this, this[CACHE].get(key));
  1379. }
  1380. load (arr) {
  1381. // reset the cache
  1382. this.reset();
  1383. const now = Date.now();
  1384. // A previous serialized cache has the most recent items first
  1385. for (let l = arr.length - 1; l >= 0; l--) {
  1386. const hit = arr[l];
  1387. const expiresAt = hit.e || 0;
  1388. if (expiresAt === 0)
  1389. // the item was created without expiration in a non aged cache
  1390. this.set(hit.k, hit.v);
  1391. else {
  1392. const maxAge = expiresAt - now;
  1393. // dont add already expired items
  1394. if (maxAge > 0) {
  1395. this.set(hit.k, hit.v, maxAge);
  1396. }
  1397. }
  1398. }
  1399. }
  1400. prune () {
  1401. this[CACHE].forEach((value, key) => get(this, key, false));
  1402. }
  1403. }
  1404. const get = (self, key, doUse) => {
  1405. const node = self[CACHE].get(key);
  1406. if (node) {
  1407. const hit = node.value;
  1408. if (isStale(self, hit)) {
  1409. del(self, node);
  1410. if (!self[ALLOW_STALE])
  1411. return undefined
  1412. } else {
  1413. if (doUse) {
  1414. if (self[UPDATE_AGE_ON_GET])
  1415. node.value.now = Date.now();
  1416. self[LRU_LIST].unshiftNode(node);
  1417. }
  1418. }
  1419. return hit.value
  1420. }
  1421. };
  1422. const isStale = (self, hit) => {
  1423. if (!hit || (!hit.maxAge && !self[MAX_AGE]))
  1424. return false
  1425. const diff = Date.now() - hit.now;
  1426. return hit.maxAge ? diff > hit.maxAge
  1427. : self[MAX_AGE] && (diff > self[MAX_AGE])
  1428. };
  1429. const trim = self => {
  1430. if (self[LENGTH] > self[MAX]) {
  1431. for (let walker = self[LRU_LIST].tail;
  1432. self[LENGTH] > self[MAX] && walker !== null;) {
  1433. // We know that we're about to delete this one, and also
  1434. // what the next least recently used key will be, so just
  1435. // go ahead and set it now.
  1436. const prev = walker.prev;
  1437. del(self, walker);
  1438. walker = prev;
  1439. }
  1440. }
  1441. };
  1442. const del = (self, node) => {
  1443. if (node) {
  1444. const hit = node.value;
  1445. if (self[DISPOSE])
  1446. self[DISPOSE](hit.key, hit.value);
  1447. self[LENGTH] -= hit.length;
  1448. self[CACHE].delete(hit.key);
  1449. self[LRU_LIST].removeNode(node);
  1450. }
  1451. };
  1452. class Entry {
  1453. constructor (key, value, length, now, maxAge) {
  1454. this.key = key;
  1455. this.value = value;
  1456. this.length = length;
  1457. this.now = now;
  1458. this.maxAge = maxAge || 0;
  1459. }
  1460. }
  1461. const forEachStep = (self, fn, node, thisp) => {
  1462. let hit = node.value;
  1463. if (isStale(self, hit)) {
  1464. del(self, node);
  1465. if (!self[ALLOW_STALE])
  1466. hit = undefined;
  1467. }
  1468. if (hit)
  1469. fn.call(thisp, hit.value, hit.key, self);
  1470. };
  1471. var lruCache = LRUCache;
  1472. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1473. function encode(decoded) {
  1474. var sourceFileIndex = 0; // second field
  1475. var sourceCodeLine = 0; // third field
  1476. var sourceCodeColumn = 0; // fourth field
  1477. var nameIndex = 0; // fifth field
  1478. var mappings = '';
  1479. for (var i = 0; i < decoded.length; i++) {
  1480. var line = decoded[i];
  1481. if (i > 0)
  1482. mappings += ';';
  1483. if (line.length === 0)
  1484. continue;
  1485. var generatedCodeColumn = 0; // first field
  1486. var lineMappings = [];
  1487. for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
  1488. var segment = line_1[_i];
  1489. var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
  1490. generatedCodeColumn = segment[0];
  1491. if (segment.length > 1) {
  1492. segmentMappings +=
  1493. encodeInteger(segment[1] - sourceFileIndex) +
  1494. encodeInteger(segment[2] - sourceCodeLine) +
  1495. encodeInteger(segment[3] - sourceCodeColumn);
  1496. sourceFileIndex = segment[1];
  1497. sourceCodeLine = segment[2];
  1498. sourceCodeColumn = segment[3];
  1499. }
  1500. if (segment.length === 5) {
  1501. segmentMappings += encodeInteger(segment[4] - nameIndex);
  1502. nameIndex = segment[4];
  1503. }
  1504. lineMappings.push(segmentMappings);
  1505. }
  1506. mappings += lineMappings.join(',');
  1507. }
  1508. return mappings;
  1509. }
  1510. function encodeInteger(num) {
  1511. var result = '';
  1512. num = num < 0 ? (-num << 1) | 1 : num << 1;
  1513. do {
  1514. var clamped = num & 31;
  1515. num >>>= 5;
  1516. if (num > 0) {
  1517. clamped |= 32;
  1518. }
  1519. result += chars[clamped];
  1520. } while (num > 0);
  1521. return result;
  1522. }
  1523. var BitSet = function BitSet(arg) {
  1524. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  1525. };
  1526. BitSet.prototype.add = function add (n) {
  1527. this.bits[n >> 5] |= 1 << (n & 31);
  1528. };
  1529. BitSet.prototype.has = function has (n) {
  1530. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  1531. };
  1532. var Chunk = function Chunk(start, end, content) {
  1533. this.start = start;
  1534. this.end = end;
  1535. this.original = content;
  1536. this.intro = '';
  1537. this.outro = '';
  1538. this.content = content;
  1539. this.storeName = false;
  1540. this.edited = false;
  1541. // we make these non-enumerable, for sanity while debugging
  1542. Object.defineProperties(this, {
  1543. previous: { writable: true, value: null },
  1544. next: { writable: true, value: null },
  1545. });
  1546. };
  1547. Chunk.prototype.appendLeft = function appendLeft (content) {
  1548. this.outro += content;
  1549. };
  1550. Chunk.prototype.appendRight = function appendRight (content) {
  1551. this.intro = this.intro + content;
  1552. };
  1553. Chunk.prototype.clone = function clone () {
  1554. var chunk = new Chunk(this.start, this.end, this.original);
  1555. chunk.intro = this.intro;
  1556. chunk.outro = this.outro;
  1557. chunk.content = this.content;
  1558. chunk.storeName = this.storeName;
  1559. chunk.edited = this.edited;
  1560. return chunk;
  1561. };
  1562. Chunk.prototype.contains = function contains (index) {
  1563. return this.start < index && index < this.end;
  1564. };
  1565. Chunk.prototype.eachNext = function eachNext (fn) {
  1566. var chunk = this;
  1567. while (chunk) {
  1568. fn(chunk);
  1569. chunk = chunk.next;
  1570. }
  1571. };
  1572. Chunk.prototype.eachPrevious = function eachPrevious (fn) {
  1573. var chunk = this;
  1574. while (chunk) {
  1575. fn(chunk);
  1576. chunk = chunk.previous;
  1577. }
  1578. };
  1579. Chunk.prototype.edit = function edit (content, storeName, contentOnly) {
  1580. this.content = content;
  1581. if (!contentOnly) {
  1582. this.intro = '';
  1583. this.outro = '';
  1584. }
  1585. this.storeName = storeName;
  1586. this.edited = true;
  1587. return this;
  1588. };
  1589. Chunk.prototype.prependLeft = function prependLeft (content) {
  1590. this.outro = content + this.outro;
  1591. };
  1592. Chunk.prototype.prependRight = function prependRight (content) {
  1593. this.intro = content + this.intro;
  1594. };
  1595. Chunk.prototype.split = function split (index) {
  1596. var sliceIndex = index - this.start;
  1597. var originalBefore = this.original.slice(0, sliceIndex);
  1598. var originalAfter = this.original.slice(sliceIndex);
  1599. this.original = originalBefore;
  1600. var newChunk = new Chunk(index, this.end, originalAfter);
  1601. newChunk.outro = this.outro;
  1602. this.outro = '';
  1603. this.end = index;
  1604. if (this.edited) {
  1605. // TODO is this block necessary?...
  1606. newChunk.edit('', false);
  1607. this.content = '';
  1608. } else {
  1609. this.content = originalBefore;
  1610. }
  1611. newChunk.next = this.next;
  1612. if (newChunk.next) { newChunk.next.previous = newChunk; }
  1613. newChunk.previous = this;
  1614. this.next = newChunk;
  1615. return newChunk;
  1616. };
  1617. Chunk.prototype.toString = function toString () {
  1618. return this.intro + this.content + this.outro;
  1619. };
  1620. Chunk.prototype.trimEnd = function trimEnd (rx) {
  1621. this.outro = this.outro.replace(rx, '');
  1622. if (this.outro.length) { return true; }
  1623. var trimmed = this.content.replace(rx, '');
  1624. if (trimmed.length) {
  1625. if (trimmed !== this.content) {
  1626. this.split(this.start + trimmed.length).edit('', undefined, true);
  1627. }
  1628. return true;
  1629. } else {
  1630. this.edit('', undefined, true);
  1631. this.intro = this.intro.replace(rx, '');
  1632. if (this.intro.length) { return true; }
  1633. }
  1634. };
  1635. Chunk.prototype.trimStart = function trimStart (rx) {
  1636. this.intro = this.intro.replace(rx, '');
  1637. if (this.intro.length) { return true; }
  1638. var trimmed = this.content.replace(rx, '');
  1639. if (trimmed.length) {
  1640. if (trimmed !== this.content) {
  1641. this.split(this.end - trimmed.length);
  1642. this.edit('', undefined, true);
  1643. }
  1644. return true;
  1645. } else {
  1646. this.edit('', undefined, true);
  1647. this.outro = this.outro.replace(rx, '');
  1648. if (this.outro.length) { return true; }
  1649. }
  1650. };
  1651. var btoa = function () {
  1652. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  1653. };
  1654. if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
  1655. btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
  1656. } else if (typeof Buffer === 'function') {
  1657. btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
  1658. }
  1659. var SourceMap = function SourceMap(properties) {
  1660. this.version = 3;
  1661. this.file = properties.file;
  1662. this.sources = properties.sources;
  1663. this.sourcesContent = properties.sourcesContent;
  1664. this.names = properties.names;
  1665. this.mappings = encode(properties.mappings);
  1666. };
  1667. SourceMap.prototype.toString = function toString () {
  1668. return JSON.stringify(this);
  1669. };
  1670. SourceMap.prototype.toUrl = function toUrl () {
  1671. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  1672. };
  1673. function guessIndent(code) {
  1674. var lines = code.split('\n');
  1675. var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
  1676. var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
  1677. if (tabbed.length === 0 && spaced.length === 0) {
  1678. return null;
  1679. }
  1680. // More lines tabbed than spaced? Assume tabs, and
  1681. // default to tabs in the case of a tie (or nothing
  1682. // to go on)
  1683. if (tabbed.length >= spaced.length) {
  1684. return '\t';
  1685. }
  1686. // Otherwise, we need to guess the multiple
  1687. var min = spaced.reduce(function (previous, current) {
  1688. var numSpaces = /^ +/.exec(current)[0].length;
  1689. return Math.min(numSpaces, previous);
  1690. }, Infinity);
  1691. return new Array(min + 1).join(' ');
  1692. }
  1693. function getRelativePath(from, to) {
  1694. var fromParts = from.split(/[/\\]/);
  1695. var toParts = to.split(/[/\\]/);
  1696. fromParts.pop(); // get dirname
  1697. while (fromParts[0] === toParts[0]) {
  1698. fromParts.shift();
  1699. toParts.shift();
  1700. }
  1701. if (fromParts.length) {
  1702. var i = fromParts.length;
  1703. while (i--) { fromParts[i] = '..'; }
  1704. }
  1705. return fromParts.concat(toParts).join('/');
  1706. }
  1707. var toString = Object.prototype.toString;
  1708. function isObject(thing) {
  1709. return toString.call(thing) === '[object Object]';
  1710. }
  1711. function getLocator(source) {
  1712. var originalLines = source.split('\n');
  1713. var lineOffsets = [];
  1714. for (var i = 0, pos = 0; i < originalLines.length; i++) {
  1715. lineOffsets.push(pos);
  1716. pos += originalLines[i].length + 1;
  1717. }
  1718. return function locate(index) {
  1719. var i = 0;
  1720. var j = lineOffsets.length;
  1721. while (i < j) {
  1722. var m = (i + j) >> 1;
  1723. if (index < lineOffsets[m]) {
  1724. j = m;
  1725. } else {
  1726. i = m + 1;
  1727. }
  1728. }
  1729. var line = i - 1;
  1730. var column = index - lineOffsets[line];
  1731. return { line: line, column: column };
  1732. };
  1733. }
  1734. var Mappings = function Mappings(hires) {
  1735. this.hires = hires;
  1736. this.generatedCodeLine = 0;
  1737. this.generatedCodeColumn = 0;
  1738. this.raw = [];
  1739. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  1740. this.pending = null;
  1741. };
  1742. Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) {
  1743. if (content.length) {
  1744. var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  1745. if (nameIndex >= 0) {
  1746. segment.push(nameIndex);
  1747. }
  1748. this.rawSegments.push(segment);
  1749. } else if (this.pending) {
  1750. this.rawSegments.push(this.pending);
  1751. }
  1752. this.advance(content);
  1753. this.pending = null;
  1754. };
  1755. Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
  1756. var originalCharIndex = chunk.start;
  1757. var first = true;
  1758. while (originalCharIndex < chunk.end) {
  1759. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  1760. this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
  1761. }
  1762. if (original[originalCharIndex] === '\n') {
  1763. loc.line += 1;
  1764. loc.column = 0;
  1765. this.generatedCodeLine += 1;
  1766. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  1767. this.generatedCodeColumn = 0;
  1768. first = true;
  1769. } else {
  1770. loc.column += 1;
  1771. this.generatedCodeColumn += 1;
  1772. first = false;
  1773. }
  1774. originalCharIndex += 1;
  1775. }
  1776. this.pending = null;
  1777. };
  1778. Mappings.prototype.advance = function advance (str) {
  1779. if (!str) { return; }
  1780. var lines = str.split('\n');
  1781. if (lines.length > 1) {
  1782. for (var i = 0; i < lines.length - 1; i++) {
  1783. this.generatedCodeLine++;
  1784. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  1785. }
  1786. this.generatedCodeColumn = 0;
  1787. }
  1788. this.generatedCodeColumn += lines[lines.length - 1].length;
  1789. };
  1790. var n = '\n';
  1791. var warned = {
  1792. insertLeft: false,
  1793. insertRight: false,
  1794. storeName: false,
  1795. };
  1796. var MagicString = function MagicString(string, options) {
  1797. if ( options === void 0 ) options = {};
  1798. var chunk = new Chunk(0, string.length, string);
  1799. Object.defineProperties(this, {
  1800. original: { writable: true, value: string },
  1801. outro: { writable: true, value: '' },
  1802. intro: { writable: true, value: '' },
  1803. firstChunk: { writable: true, value: chunk },
  1804. lastChunk: { writable: true, value: chunk },
  1805. lastSearchedChunk: { writable: true, value: chunk },
  1806. byStart: { writable: true, value: {} },
  1807. byEnd: { writable: true, value: {} },
  1808. filename: { writable: true, value: options.filename },
  1809. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  1810. sourcemapLocations: { writable: true, value: new BitSet() },
  1811. storedNames: { writable: true, value: {} },
  1812. indentStr: { writable: true, value: guessIndent(string) },
  1813. });
  1814. this.byStart[0] = chunk;
  1815. this.byEnd[string.length] = chunk;
  1816. };
  1817. MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) {
  1818. this.sourcemapLocations.add(char);
  1819. };
  1820. MagicString.prototype.append = function append (content) {
  1821. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  1822. this.outro += content;
  1823. return this;
  1824. };
  1825. MagicString.prototype.appendLeft = function appendLeft (index, content) {
  1826. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  1827. this._split(index);
  1828. var chunk = this.byEnd[index];
  1829. if (chunk) {
  1830. chunk.appendLeft(content);
  1831. } else {
  1832. this.intro += content;
  1833. }
  1834. return this;
  1835. };
  1836. MagicString.prototype.appendRight = function appendRight (index, content) {
  1837. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  1838. this._split(index);
  1839. var chunk = this.byStart[index];
  1840. if (chunk) {
  1841. chunk.appendRight(content);
  1842. } else {
  1843. this.outro += content;
  1844. }
  1845. return this;
  1846. };
  1847. MagicString.prototype.clone = function clone () {
  1848. var cloned = new MagicString(this.original, { filename: this.filename });
  1849. var originalChunk = this.firstChunk;
  1850. var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  1851. while (originalChunk) {
  1852. cloned.byStart[clonedChunk.start] = clonedChunk;
  1853. cloned.byEnd[clonedChunk.end] = clonedChunk;
  1854. var nextOriginalChunk = originalChunk.next;
  1855. var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  1856. if (nextClonedChunk) {
  1857. clonedChunk.next = nextClonedChunk;
  1858. nextClonedChunk.previous = clonedChunk;
  1859. clonedChunk = nextClonedChunk;
  1860. }
  1861. originalChunk = nextOriginalChunk;
  1862. }
  1863. cloned.lastChunk = clonedChunk;
  1864. if (this.indentExclusionRanges) {
  1865. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  1866. }
  1867. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  1868. cloned.intro = this.intro;
  1869. cloned.outro = this.outro;
  1870. return cloned;
  1871. };
  1872. MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) {
  1873. var this$1$1 = this;
  1874. options = options || {};
  1875. var sourceIndex = 0;
  1876. var names = Object.keys(this.storedNames);
  1877. var mappings = new Mappings(options.hires);
  1878. var locate = getLocator(this.original);
  1879. if (this.intro) {
  1880. mappings.advance(this.intro);
  1881. }
  1882. this.firstChunk.eachNext(function (chunk) {
  1883. var loc = locate(chunk.start);
  1884. if (chunk.intro.length) { mappings.advance(chunk.intro); }
  1885. if (chunk.edited) {
  1886. mappings.addEdit(
  1887. sourceIndex,
  1888. chunk.content,
  1889. loc,
  1890. chunk.storeName ? names.indexOf(chunk.original) : -1
  1891. );
  1892. } else {
  1893. mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations);
  1894. }
  1895. if (chunk.outro.length) { mappings.advance(chunk.outro); }
  1896. });
  1897. return {
  1898. file: options.file ? options.file.split(/[/\\]/).pop() : null,
  1899. sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
  1900. sourcesContent: options.includeContent ? [this.original] : [null],
  1901. names: names,
  1902. mappings: mappings.raw,
  1903. };
  1904. };
  1905. MagicString.prototype.generateMap = function generateMap (options) {
  1906. return new SourceMap(this.generateDecodedMap(options));
  1907. };
  1908. MagicString.prototype.getIndentString = function getIndentString () {
  1909. return this.indentStr === null ? '\t' : this.indentStr;
  1910. };
  1911. MagicString.prototype.indent = function indent (indentStr, options) {
  1912. var pattern = /^[^\r\n]/gm;
  1913. if (isObject(indentStr)) {
  1914. options = indentStr;
  1915. indentStr = undefined;
  1916. }
  1917. indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
  1918. if (indentStr === '') { return this; } // noop
  1919. options = options || {};
  1920. // Process exclusion ranges
  1921. var isExcluded = {};
  1922. if (options.exclude) {
  1923. var exclusions =
  1924. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  1925. exclusions.forEach(function (exclusion) {
  1926. for (var i = exclusion[0]; i < exclusion[1]; i += 1) {
  1927. isExcluded[i] = true;
  1928. }
  1929. });
  1930. }
  1931. var shouldIndentNextCharacter = options.indentStart !== false;
  1932. var replacer = function (match) {
  1933. if (shouldIndentNextCharacter) { return ("" + indentStr + match); }
  1934. shouldIndentNextCharacter = true;
  1935. return match;
  1936. };
  1937. this.intro = this.intro.replace(pattern, replacer);
  1938. var charIndex = 0;
  1939. var chunk = this.firstChunk;
  1940. while (chunk) {
  1941. var end = chunk.end;
  1942. if (chunk.edited) {
  1943. if (!isExcluded[charIndex]) {
  1944. chunk.content = chunk.content.replace(pattern, replacer);
  1945. if (chunk.content.length) {
  1946. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  1947. }
  1948. }
  1949. } else {
  1950. charIndex = chunk.start;
  1951. while (charIndex < end) {
  1952. if (!isExcluded[charIndex]) {
  1953. var char = this.original[charIndex];
  1954. if (char === '\n') {
  1955. shouldIndentNextCharacter = true;
  1956. } else if (char !== '\r' && shouldIndentNextCharacter) {
  1957. shouldIndentNextCharacter = false;
  1958. if (charIndex === chunk.start) {
  1959. chunk.prependRight(indentStr);
  1960. } else {
  1961. this._splitChunk(chunk, charIndex);
  1962. chunk = chunk.next;
  1963. chunk.prependRight(indentStr);
  1964. }
  1965. }
  1966. }
  1967. charIndex += 1;
  1968. }
  1969. }
  1970. charIndex = chunk.end;
  1971. chunk = chunk.next;
  1972. }
  1973. this.outro = this.outro.replace(pattern, replacer);
  1974. return this;
  1975. };
  1976. MagicString.prototype.insert = function insert () {
  1977. throw new Error(
  1978. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
  1979. );
  1980. };
  1981. MagicString.prototype.insertLeft = function insertLeft (index, content) {
  1982. if (!warned.insertLeft) {
  1983. console.warn(
  1984. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
  1985. ); // eslint-disable-line no-console
  1986. warned.insertLeft = true;
  1987. }
  1988. return this.appendLeft(index, content);
  1989. };
  1990. MagicString.prototype.insertRight = function insertRight (index, content) {
  1991. if (!warned.insertRight) {
  1992. console.warn(
  1993. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
  1994. ); // eslint-disable-line no-console
  1995. warned.insertRight = true;
  1996. }
  1997. return this.prependRight(index, content);
  1998. };
  1999. MagicString.prototype.move = function move (start, end, index) {
  2000. if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); }
  2001. this._split(start);
  2002. this._split(end);
  2003. this._split(index);
  2004. var first = this.byStart[start];
  2005. var last = this.byEnd[end];
  2006. var oldLeft = first.previous;
  2007. var oldRight = last.next;
  2008. var newRight = this.byStart[index];
  2009. if (!newRight && last === this.lastChunk) { return this; }
  2010. var newLeft = newRight ? newRight.previous : this.lastChunk;
  2011. if (oldLeft) { oldLeft.next = oldRight; }
  2012. if (oldRight) { oldRight.previous = oldLeft; }
  2013. if (newLeft) { newLeft.next = first; }
  2014. if (newRight) { newRight.previous = last; }
  2015. if (!first.previous) { this.firstChunk = last.next; }
  2016. if (!last.next) {
  2017. this.lastChunk = first.previous;
  2018. this.lastChunk.next = null;
  2019. }
  2020. first.previous = newLeft;
  2021. last.next = newRight || null;
  2022. if (!newLeft) { this.firstChunk = first; }
  2023. if (!newRight) { this.lastChunk = last; }
  2024. return this;
  2025. };
  2026. MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
  2027. if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
  2028. while (start < 0) { start += this.original.length; }
  2029. while (end < 0) { end += this.original.length; }
  2030. if (end > this.original.length) { throw new Error('end is out of bounds'); }
  2031. if (start === end)
  2032. { throw new Error(
  2033. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
  2034. ); }
  2035. this._split(start);
  2036. this._split(end);
  2037. if (options === true) {
  2038. if (!warned.storeName) {
  2039. console.warn(
  2040. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
  2041. ); // eslint-disable-line no-console
  2042. warned.storeName = true;
  2043. }
  2044. options = { storeName: true };
  2045. }
  2046. var storeName = options !== undefined ? options.storeName : false;
  2047. var contentOnly = options !== undefined ? options.contentOnly : false;
  2048. if (storeName) {
  2049. var original = this.original.slice(start, end);
  2050. Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });
  2051. }
  2052. var first = this.byStart[start];
  2053. var last = this.byEnd[end];
  2054. if (first) {
  2055. var chunk = first;
  2056. while (chunk !== last) {
  2057. if (chunk.next !== this.byStart[chunk.end]) {
  2058. throw new Error('Cannot overwrite across a split point');
  2059. }
  2060. chunk = chunk.next;
  2061. chunk.edit('', false);
  2062. }
  2063. first.edit(content, storeName, contentOnly);
  2064. } else {
  2065. // must be inserting at the end
  2066. var newChunk = new Chunk(start, end, '').edit(content, storeName);
  2067. // TODO last chunk in the array may not be the last chunk, if it's moved...
  2068. last.next = newChunk;
  2069. newChunk.previous = last;
  2070. }
  2071. return this;
  2072. };
  2073. MagicString.prototype.prepend = function prepend (content) {
  2074. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  2075. this.intro = content + this.intro;
  2076. return this;
  2077. };
  2078. MagicString.prototype.prependLeft = function prependLeft (index, content) {
  2079. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  2080. this._split(index);
  2081. var chunk = this.byEnd[index];
  2082. if (chunk) {
  2083. chunk.prependLeft(content);
  2084. } else {
  2085. this.intro = content + this.intro;
  2086. }
  2087. return this;
  2088. };
  2089. MagicString.prototype.prependRight = function prependRight (index, content) {
  2090. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  2091. this._split(index);
  2092. var chunk = this.byStart[index];
  2093. if (chunk) {
  2094. chunk.prependRight(content);
  2095. } else {
  2096. this.outro = content + this.outro;
  2097. }
  2098. return this;
  2099. };
  2100. MagicString.prototype.remove = function remove (start, end) {
  2101. while (start < 0) { start += this.original.length; }
  2102. while (end < 0) { end += this.original.length; }
  2103. if (start === end) { return this; }
  2104. if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); }
  2105. if (start > end) { throw new Error('end must be greater than start'); }
  2106. this._split(start);
  2107. this._split(end);
  2108. var chunk = this.byStart[start];
  2109. while (chunk) {
  2110. chunk.intro = '';
  2111. chunk.outro = '';
  2112. chunk.edit('');
  2113. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  2114. }
  2115. return this;
  2116. };
  2117. MagicString.prototype.lastChar = function lastChar () {
  2118. if (this.outro.length) { return this.outro[this.outro.length - 1]; }
  2119. var chunk = this.lastChunk;
  2120. do {
  2121. if (chunk.outro.length) { return chunk.outro[chunk.outro.length - 1]; }
  2122. if (chunk.content.length) { return chunk.content[chunk.content.length - 1]; }
  2123. if (chunk.intro.length) { return chunk.intro[chunk.intro.length - 1]; }
  2124. } while ((chunk = chunk.previous));
  2125. if (this.intro.length) { return this.intro[this.intro.length - 1]; }
  2126. return '';
  2127. };
  2128. MagicString.prototype.lastLine = function lastLine () {
  2129. var lineIndex = this.outro.lastIndexOf(n);
  2130. if (lineIndex !== -1) { return this.outro.substr(lineIndex + 1); }
  2131. var lineStr = this.outro;
  2132. var chunk = this.lastChunk;
  2133. do {
  2134. if (chunk.outro.length > 0) {
  2135. lineIndex = chunk.outro.lastIndexOf(n);
  2136. if (lineIndex !== -1) { return chunk.outro.substr(lineIndex + 1) + lineStr; }
  2137. lineStr = chunk.outro + lineStr;
  2138. }
  2139. if (chunk.content.length > 0) {
  2140. lineIndex = chunk.content.lastIndexOf(n);
  2141. if (lineIndex !== -1) { return chunk.content.substr(lineIndex + 1) + lineStr; }
  2142. lineStr = chunk.content + lineStr;
  2143. }
  2144. if (chunk.intro.length > 0) {
  2145. lineIndex = chunk.intro.lastIndexOf(n);
  2146. if (lineIndex !== -1) { return chunk.intro.substr(lineIndex + 1) + lineStr; }
  2147. lineStr = chunk.intro + lineStr;
  2148. }
  2149. } while ((chunk = chunk.previous));
  2150. lineIndex = this.intro.lastIndexOf(n);
  2151. if (lineIndex !== -1) { return this.intro.substr(lineIndex + 1) + lineStr; }
  2152. return this.intro + lineStr;
  2153. };
  2154. MagicString.prototype.slice = function slice (start, end) {
  2155. if ( start === void 0 ) start = 0;
  2156. if ( end === void 0 ) end = this.original.length;
  2157. while (start < 0) { start += this.original.length; }
  2158. while (end < 0) { end += this.original.length; }
  2159. var result = '';
  2160. // find start chunk
  2161. var chunk = this.firstChunk;
  2162. while (chunk && (chunk.start > start || chunk.end <= start)) {
  2163. // found end chunk before start
  2164. if (chunk.start < end && chunk.end >= end) {
  2165. return result;
  2166. }
  2167. chunk = chunk.next;
  2168. }
  2169. if (chunk && chunk.edited && chunk.start !== start)
  2170. { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
  2171. var startChunk = chunk;
  2172. while (chunk) {
  2173. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  2174. result += chunk.intro;
  2175. }
  2176. var containsEnd = chunk.start < end && chunk.end >= end;
  2177. if (containsEnd && chunk.edited && chunk.end !== end)
  2178. { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
  2179. var sliceStart = startChunk === chunk ? start - chunk.start : 0;
  2180. var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  2181. result += chunk.content.slice(sliceStart, sliceEnd);
  2182. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  2183. result += chunk.outro;
  2184. }
  2185. if (containsEnd) {
  2186. break;
  2187. }
  2188. chunk = chunk.next;
  2189. }
  2190. return result;
  2191. };
  2192. // TODO deprecate this? not really very useful
  2193. MagicString.prototype.snip = function snip (start, end) {
  2194. var clone = this.clone();
  2195. clone.remove(0, start);
  2196. clone.remove(end, clone.original.length);
  2197. return clone;
  2198. };
  2199. MagicString.prototype._split = function _split (index) {
  2200. if (this.byStart[index] || this.byEnd[index]) { return; }
  2201. var chunk = this.lastSearchedChunk;
  2202. var searchForward = index > chunk.end;
  2203. while (chunk) {
  2204. if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
  2205. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  2206. }
  2207. };
  2208. MagicString.prototype._splitChunk = function _splitChunk (chunk, index) {
  2209. if (chunk.edited && chunk.content.length) {
  2210. // zero-length edited chunks are a special case (overlapping replacements)
  2211. var loc = getLocator(this.original)(index);
  2212. throw new Error(
  2213. ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")")
  2214. );
  2215. }
  2216. var newChunk = chunk.split(index);
  2217. this.byEnd[index] = chunk;
  2218. this.byStart[index] = newChunk;
  2219. this.byEnd[newChunk.end] = newChunk;
  2220. if (chunk === this.lastChunk) { this.lastChunk = newChunk; }
  2221. this.lastSearchedChunk = chunk;
  2222. return true;
  2223. };
  2224. MagicString.prototype.toString = function toString () {
  2225. var str = this.intro;
  2226. var chunk = this.firstChunk;
  2227. while (chunk) {
  2228. str += chunk.toString();
  2229. chunk = chunk.next;
  2230. }
  2231. return str + this.outro;
  2232. };
  2233. MagicString.prototype.isEmpty = function isEmpty () {
  2234. var chunk = this.firstChunk;
  2235. do {
  2236. if (
  2237. (chunk.intro.length && chunk.intro.trim()) ||
  2238. (chunk.content.length && chunk.content.trim()) ||
  2239. (chunk.outro.length && chunk.outro.trim())
  2240. )
  2241. { return false; }
  2242. } while ((chunk = chunk.next));
  2243. return true;
  2244. };
  2245. MagicString.prototype.length = function length () {
  2246. var chunk = this.firstChunk;
  2247. var length = 0;
  2248. do {
  2249. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  2250. } while ((chunk = chunk.next));
  2251. return length;
  2252. };
  2253. MagicString.prototype.trimLines = function trimLines () {
  2254. return this.trim('[\\r\\n]');
  2255. };
  2256. MagicString.prototype.trim = function trim (charType) {
  2257. return this.trimStart(charType).trimEnd(charType);
  2258. };
  2259. MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
  2260. var rx = new RegExp((charType || '\\s') + '+$');
  2261. this.outro = this.outro.replace(rx, '');
  2262. if (this.outro.length) { return true; }
  2263. var chunk = this.lastChunk;
  2264. do {
  2265. var end = chunk.end;
  2266. var aborted = chunk.trimEnd(rx);
  2267. // if chunk was trimmed, we have a new lastChunk
  2268. if (chunk.end !== end) {
  2269. if (this.lastChunk === chunk) {
  2270. this.lastChunk = chunk.next;
  2271. }
  2272. this.byEnd[chunk.end] = chunk;
  2273. this.byStart[chunk.next.start] = chunk.next;
  2274. this.byEnd[chunk.next.end] = chunk.next;
  2275. }
  2276. if (aborted) { return true; }
  2277. chunk = chunk.previous;
  2278. } while (chunk);
  2279. return false;
  2280. };
  2281. MagicString.prototype.trimEnd = function trimEnd (charType) {
  2282. this.trimEndAborted(charType);
  2283. return this;
  2284. };
  2285. MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
  2286. var rx = new RegExp('^' + (charType || '\\s') + '+');
  2287. this.intro = this.intro.replace(rx, '');
  2288. if (this.intro.length) { return true; }
  2289. var chunk = this.firstChunk;
  2290. do {
  2291. var end = chunk.end;
  2292. var aborted = chunk.trimStart(rx);
  2293. if (chunk.end !== end) {
  2294. // special case...
  2295. if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
  2296. this.byEnd[chunk.end] = chunk;
  2297. this.byStart[chunk.next.start] = chunk.next;
  2298. this.byEnd[chunk.next.end] = chunk.next;
  2299. }
  2300. if (aborted) { return true; }
  2301. chunk = chunk.next;
  2302. } while (chunk);
  2303. return false;
  2304. };
  2305. MagicString.prototype.trimStart = function trimStart (charType) {
  2306. this.trimStartAborted(charType);
  2307. return this;
  2308. };
  2309. // @ts-check
  2310. /** @typedef { import('estree').BaseNode} BaseNode */
  2311. /** @typedef {{
  2312. skip: () => void;
  2313. remove: () => void;
  2314. replace: (node: BaseNode) => void;
  2315. }} WalkerContext */
  2316. class WalkerBase {
  2317. constructor() {
  2318. /** @type {boolean} */
  2319. this.should_skip = false;
  2320. /** @type {boolean} */
  2321. this.should_remove = false;
  2322. /** @type {BaseNode | null} */
  2323. this.replacement = null;
  2324. /** @type {WalkerContext} */
  2325. this.context = {
  2326. skip: () => (this.should_skip = true),
  2327. remove: () => (this.should_remove = true),
  2328. replace: (node) => (this.replacement = node)
  2329. };
  2330. }
  2331. /**
  2332. *
  2333. * @param {any} parent
  2334. * @param {string} prop
  2335. * @param {number} index
  2336. * @param {BaseNode} node
  2337. */
  2338. replace(parent, prop, index, node) {
  2339. if (parent) {
  2340. if (index !== null) {
  2341. parent[prop][index] = node;
  2342. } else {
  2343. parent[prop] = node;
  2344. }
  2345. }
  2346. }
  2347. /**
  2348. *
  2349. * @param {any} parent
  2350. * @param {string} prop
  2351. * @param {number} index
  2352. */
  2353. remove(parent, prop, index) {
  2354. if (parent) {
  2355. if (index !== null) {
  2356. parent[prop].splice(index, 1);
  2357. } else {
  2358. delete parent[prop];
  2359. }
  2360. }
  2361. }
  2362. }
  2363. // @ts-check
  2364. /** @typedef { import('estree').BaseNode} BaseNode */
  2365. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  2366. /** @typedef {(
  2367. * this: WalkerContext,
  2368. * node: BaseNode,
  2369. * parent: BaseNode,
  2370. * key: string,
  2371. * index: number
  2372. * ) => void} SyncHandler */
  2373. class SyncWalker extends WalkerBase {
  2374. /**
  2375. *
  2376. * @param {SyncHandler} enter
  2377. * @param {SyncHandler} leave
  2378. */
  2379. constructor(enter, leave) {
  2380. super();
  2381. /** @type {SyncHandler} */
  2382. this.enter = enter;
  2383. /** @type {SyncHandler} */
  2384. this.leave = leave;
  2385. }
  2386. /**
  2387. *
  2388. * @param {BaseNode} node
  2389. * @param {BaseNode} parent
  2390. * @param {string} [prop]
  2391. * @param {number} [index]
  2392. * @returns {BaseNode}
  2393. */
  2394. visit(node, parent, prop, index) {
  2395. if (node) {
  2396. if (this.enter) {
  2397. const _should_skip = this.should_skip;
  2398. const _should_remove = this.should_remove;
  2399. const _replacement = this.replacement;
  2400. this.should_skip = false;
  2401. this.should_remove = false;
  2402. this.replacement = null;
  2403. this.enter.call(this.context, node, parent, prop, index);
  2404. if (this.replacement) {
  2405. node = this.replacement;
  2406. this.replace(parent, prop, index, node);
  2407. }
  2408. if (this.should_remove) {
  2409. this.remove(parent, prop, index);
  2410. }
  2411. const skipped = this.should_skip;
  2412. const removed = this.should_remove;
  2413. this.should_skip = _should_skip;
  2414. this.should_remove = _should_remove;
  2415. this.replacement = _replacement;
  2416. if (skipped) return node;
  2417. if (removed) return null;
  2418. }
  2419. for (const key in node) {
  2420. const value = node[key];
  2421. if (typeof value !== "object") {
  2422. continue;
  2423. } else if (Array.isArray(value)) {
  2424. for (let i = 0; i < value.length; i += 1) {
  2425. if (value[i] !== null && typeof value[i].type === 'string') {
  2426. if (!this.visit(value[i], node, key, i)) {
  2427. // removed
  2428. i--;
  2429. }
  2430. }
  2431. }
  2432. } else if (value !== null && typeof value.type === "string") {
  2433. this.visit(value, node, key, null);
  2434. }
  2435. }
  2436. if (this.leave) {
  2437. const _replacement = this.replacement;
  2438. const _should_remove = this.should_remove;
  2439. this.replacement = null;
  2440. this.should_remove = false;
  2441. this.leave.call(this.context, node, parent, prop, index);
  2442. if (this.replacement) {
  2443. node = this.replacement;
  2444. this.replace(parent, prop, index, node);
  2445. }
  2446. if (this.should_remove) {
  2447. this.remove(parent, prop, index);
  2448. }
  2449. const removed = this.should_remove;
  2450. this.replacement = _replacement;
  2451. this.should_remove = _should_remove;
  2452. if (removed) return null;
  2453. }
  2454. }
  2455. return node;
  2456. }
  2457. }
  2458. // @ts-check
  2459. /** @typedef { import('estree').BaseNode} BaseNode */
  2460. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  2461. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  2462. /**
  2463. *
  2464. * @param {BaseNode} ast
  2465. * @param {{
  2466. * enter?: SyncHandler
  2467. * leave?: SyncHandler
  2468. * }} walker
  2469. * @returns {BaseNode}
  2470. */
  2471. function walk$1(ast, { enter, leave }) {
  2472. const instance = new SyncWalker(enter, leave);
  2473. return instance.visit(ast, null);
  2474. }
  2475. // https://github.com/vuejs/core/blob/main/packages/compiler-core/src/babelUtils.ts
  2476. function walkIdentifiers(root, onIdentifier, onNode) {
  2477. const parentStack = [];
  2478. const knownIds = Object.create(null);
  2479. const rootExp = root.type === 'Program' &&
  2480. root.body[0].type === 'ExpressionStatement' &&
  2481. root.body[0].expression;
  2482. walk$1(root, {
  2483. enter(node, parent) {
  2484. parent && parentStack.push(parent);
  2485. if (parent &&
  2486. parent.type.startsWith('TS') &&
  2487. parent.type !== 'TSAsExpression' &&
  2488. parent.type !== 'TSNonNullExpression' &&
  2489. parent.type !== 'TSTypeAssertion') {
  2490. return this.skip();
  2491. }
  2492. if (onNode)
  2493. onNode(node);
  2494. if (node.type === 'Identifier') {
  2495. const isLocal = !!knownIds[node.name];
  2496. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  2497. if ((isRefed && !isLocal)) {
  2498. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  2499. }
  2500. }
  2501. else if (node.type === 'ObjectProperty' &&
  2502. parent.type === 'ObjectPattern') {
  2503. node.inPattern = true;
  2504. }
  2505. else if (isFunctionType(node)) {
  2506. // walk function expressions and add its arguments to known identifiers
  2507. // so that we don't prefix them
  2508. walkFunctionParams(node, id => markScopeIdentifier(node, id, knownIds));
  2509. }
  2510. else if (node.type === 'BlockStatement') {
  2511. // #3445 record block-level local variables
  2512. walkBlockDeclarations(node, id => markScopeIdentifier(node, id, knownIds));
  2513. }
  2514. },
  2515. leave(node, parent) {
  2516. parent && parentStack.pop();
  2517. if (node !== rootExp && node.scopeIds) {
  2518. for (const id of node.scopeIds) {
  2519. knownIds[id]--;
  2520. if (knownIds[id] === 0) {
  2521. delete knownIds[id];
  2522. }
  2523. }
  2524. }
  2525. }
  2526. });
  2527. }
  2528. function isReferencedIdentifier(id, parent, parentStack) {
  2529. if (!parent) {
  2530. return true;
  2531. }
  2532. // is a special keyword but parsed as identifier
  2533. if (id.name === 'arguments') {
  2534. return false;
  2535. }
  2536. if (isReferenced(id, parent)) {
  2537. return true;
  2538. }
  2539. // babel's isReferenced check returns false for ids being assigned to, so we
  2540. // need to cover those cases here
  2541. switch (parent.type) {
  2542. case 'AssignmentExpression':
  2543. case 'AssignmentPattern':
  2544. return true;
  2545. case 'ObjectPattern':
  2546. case 'ArrayPattern':
  2547. return isInDestructureAssignment(parent, parentStack);
  2548. }
  2549. return false;
  2550. }
  2551. function isInDestructureAssignment(parent, parentStack) {
  2552. if (parent &&
  2553. (parent.type === 'ObjectProperty' || parent.type === 'ArrayPattern')) {
  2554. let i = parentStack.length;
  2555. while (i--) {
  2556. const p = parentStack[i];
  2557. if (p.type === 'AssignmentExpression') {
  2558. return true;
  2559. }
  2560. else if (p.type !== 'ObjectProperty' && !p.type.endsWith('Pattern')) {
  2561. break;
  2562. }
  2563. }
  2564. }
  2565. return false;
  2566. }
  2567. function walkFunctionParams(node, onIdent) {
  2568. for (const p of node.params) {
  2569. for (const id of extractIdentifiers(p)) {
  2570. onIdent(id);
  2571. }
  2572. }
  2573. }
  2574. function walkBlockDeclarations(block, onIdent) {
  2575. for (const stmt of block.body) {
  2576. if (stmt.type === 'VariableDeclaration') {
  2577. if (stmt.declare)
  2578. continue;
  2579. for (const decl of stmt.declarations) {
  2580. for (const id of extractIdentifiers(decl.id)) {
  2581. onIdent(id);
  2582. }
  2583. }
  2584. }
  2585. else if (stmt.type === 'FunctionDeclaration' ||
  2586. stmt.type === 'ClassDeclaration') {
  2587. if (stmt.declare || !stmt.id)
  2588. continue;
  2589. onIdent(stmt.id);
  2590. }
  2591. }
  2592. }
  2593. function extractIdentifiers(param, nodes = []) {
  2594. switch (param.type) {
  2595. case 'Identifier':
  2596. nodes.push(param);
  2597. break;
  2598. case 'MemberExpression':
  2599. let object = param;
  2600. while (object.type === 'MemberExpression') {
  2601. object = object.object;
  2602. }
  2603. nodes.push(object);
  2604. break;
  2605. case 'ObjectPattern':
  2606. for (const prop of param.properties) {
  2607. if (prop.type === 'RestElement') {
  2608. extractIdentifiers(prop.argument, nodes);
  2609. }
  2610. else {
  2611. extractIdentifiers(prop.value, nodes);
  2612. }
  2613. }
  2614. break;
  2615. case 'ArrayPattern':
  2616. param.elements.forEach(element => {
  2617. if (element)
  2618. extractIdentifiers(element, nodes);
  2619. });
  2620. break;
  2621. case 'RestElement':
  2622. extractIdentifiers(param.argument, nodes);
  2623. break;
  2624. case 'AssignmentPattern':
  2625. extractIdentifiers(param.left, nodes);
  2626. break;
  2627. }
  2628. return nodes;
  2629. }
  2630. function markScopeIdentifier(node, child, knownIds) {
  2631. const { name } = child;
  2632. if (node.scopeIds && node.scopeIds.has(name)) {
  2633. return;
  2634. }
  2635. if (name in knownIds) {
  2636. knownIds[name]++;
  2637. }
  2638. else {
  2639. knownIds[name] = 1;
  2640. }
  2641. (node.scopeIds || (node.scopeIds = new Set())).add(name);
  2642. }
  2643. const isFunctionType = (node) => {
  2644. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  2645. };
  2646. const isStaticProperty = (node) => node &&
  2647. (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
  2648. !node.computed;
  2649. /**
  2650. * Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
  2651. * To avoid runtime dependency on @babel/types (which includes process references)
  2652. * This file should not change very often in babel but we may need to keep it
  2653. * up-to-date from time to time.
  2654. *
  2655. * https://github.com/babel/babel/blob/main/LICENSE
  2656. *
  2657. */
  2658. function isReferenced(node, parent, grandparent) {
  2659. switch (parent.type) {
  2660. // yes: PARENT[NODE]
  2661. // yes: NODE.child
  2662. // no: parent.NODE
  2663. case 'MemberExpression':
  2664. case 'OptionalMemberExpression':
  2665. if (parent.property === node) {
  2666. return !!parent.computed;
  2667. }
  2668. return parent.object === node;
  2669. case 'JSXMemberExpression':
  2670. return parent.object === node;
  2671. // no: let NODE = init;
  2672. // yes: let id = NODE;
  2673. case 'VariableDeclarator':
  2674. return parent.init === node;
  2675. // yes: () => NODE
  2676. // no: (NODE) => {}
  2677. case 'ArrowFunctionExpression':
  2678. return parent.body === node;
  2679. // no: class { #NODE; }
  2680. // no: class { get #NODE() {} }
  2681. // no: class { #NODE() {} }
  2682. // no: class { fn() { return this.#NODE; } }
  2683. case 'PrivateName':
  2684. return false;
  2685. // no: class { NODE() {} }
  2686. // yes: class { [NODE]() {} }
  2687. // no: class { foo(NODE) {} }
  2688. case 'ClassMethod':
  2689. case 'ClassPrivateMethod':
  2690. case 'ObjectMethod':
  2691. if (parent.key === node) {
  2692. return !!parent.computed;
  2693. }
  2694. return false;
  2695. // yes: { [NODE]: "" }
  2696. // no: { NODE: "" }
  2697. // depends: { NODE }
  2698. // depends: { key: NODE }
  2699. case 'ObjectProperty':
  2700. if (parent.key === node) {
  2701. return !!parent.computed;
  2702. }
  2703. // parent.value === node
  2704. return !grandparent || grandparent.type !== 'ObjectPattern';
  2705. // no: class { NODE = value; }
  2706. // yes: class { [NODE] = value; }
  2707. // yes: class { key = NODE; }
  2708. case 'ClassProperty':
  2709. if (parent.key === node) {
  2710. return !!parent.computed;
  2711. }
  2712. return true;
  2713. case 'ClassPrivateProperty':
  2714. return parent.key !== node;
  2715. // no: class NODE {}
  2716. // yes: class Foo extends NODE {}
  2717. case 'ClassDeclaration':
  2718. case 'ClassExpression':
  2719. return parent.superClass === node;
  2720. // yes: left = NODE;
  2721. // no: NODE = right;
  2722. case 'AssignmentExpression':
  2723. return parent.right === node;
  2724. // no: [NODE = foo] = [];
  2725. // yes: [foo = NODE] = [];
  2726. case 'AssignmentPattern':
  2727. return parent.right === node;
  2728. // no: NODE: for (;;) {}
  2729. case 'LabeledStatement':
  2730. return false;
  2731. // no: try {} catch (NODE) {}
  2732. case 'CatchClause':
  2733. return false;
  2734. // no: function foo(...NODE) {}
  2735. case 'RestElement':
  2736. return false;
  2737. case 'BreakStatement':
  2738. case 'ContinueStatement':
  2739. return false;
  2740. // no: function NODE() {}
  2741. // no: function foo(NODE) {}
  2742. case 'FunctionDeclaration':
  2743. case 'FunctionExpression':
  2744. return false;
  2745. // no: export NODE from "foo";
  2746. // no: export * as NODE from "foo";
  2747. case 'ExportNamespaceSpecifier':
  2748. case 'ExportDefaultSpecifier':
  2749. return false;
  2750. // no: export { foo as NODE };
  2751. // yes: export { NODE as foo };
  2752. // no: export { NODE as foo } from "foo";
  2753. case 'ExportSpecifier':
  2754. // @ts-expect-error
  2755. if (grandparent === null || grandparent === void 0 ? void 0 : grandparent.source) {
  2756. return false;
  2757. }
  2758. return parent.local === node;
  2759. // no: import NODE from "foo";
  2760. // no: import * as NODE from "foo";
  2761. // no: import { NODE as foo } from "foo";
  2762. // no: import { foo as NODE } from "foo";
  2763. // no: import NODE from "bar";
  2764. case 'ImportDefaultSpecifier':
  2765. case 'ImportNamespaceSpecifier':
  2766. case 'ImportSpecifier':
  2767. return false;
  2768. // no: import "foo" assert { NODE: "json" }
  2769. case 'ImportAttribute':
  2770. return false;
  2771. // no: <div NODE="foo" />
  2772. case 'JSXAttribute':
  2773. return false;
  2774. // no: [NODE] = [];
  2775. // no: ({ NODE }) = [];
  2776. case 'ObjectPattern':
  2777. case 'ArrayPattern':
  2778. return false;
  2779. // no: new.NODE
  2780. // no: NODE.target
  2781. case 'MetaProperty':
  2782. return false;
  2783. // yes: type X = { someProperty: NODE }
  2784. // no: type X = { NODE: OtherType }
  2785. case 'ObjectTypeProperty':
  2786. return parent.key !== node;
  2787. // yes: enum X { Foo = NODE }
  2788. // no: enum X { NODE }
  2789. case 'TSEnumMember':
  2790. return parent.id !== node;
  2791. // yes: { [NODE]: value }
  2792. // no: { NODE: value }
  2793. case 'TSPropertySignature':
  2794. if (parent.key === node) {
  2795. return !!parent.computed;
  2796. }
  2797. return true;
  2798. }
  2799. return true;
  2800. }
  2801. const range = 2;
  2802. function generateCodeFrame(source, start = 0, end = source.length) {
  2803. const lines = source.split(/\r?\n/);
  2804. let count = 0;
  2805. const res = [];
  2806. for (let i = 0; i < lines.length; i++) {
  2807. count += lines[i].length + 1;
  2808. if (count >= start) {
  2809. for (let j = i - range; j <= i + range || end > count; j++) {
  2810. if (j < 0 || j >= lines.length)
  2811. continue;
  2812. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  2813. const lineLength = lines[j].length;
  2814. if (j === i) {
  2815. // push underline
  2816. const pad = start - (count - lineLength) + 1;
  2817. const length = end > count ? lineLength - pad : end - start;
  2818. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  2819. }
  2820. else if (j > i) {
  2821. if (end > count) {
  2822. const length = Math.min(end - count, lineLength);
  2823. res.push(` | ` + repeat(`^`, length));
  2824. }
  2825. count += lineLength + 1;
  2826. }
  2827. }
  2828. break;
  2829. }
  2830. }
  2831. return res.join('\n');
  2832. }
  2833. function repeat(str, n) {
  2834. let result = '';
  2835. if (n > 0) {
  2836. // eslint-disable-next-line no-constant-condition
  2837. while (true) {
  2838. // eslint-disable-line
  2839. if (n & 1)
  2840. result += str;
  2841. n >>>= 1;
  2842. if (n <= 0)
  2843. break;
  2844. str += str;
  2845. }
  2846. }
  2847. return result;
  2848. }
  2849. // can we use __proto__?
  2850. const hasProto = '__proto__' in {};
  2851. // Browser environment sniffing
  2852. const inBrowser = typeof window !== 'undefined';
  2853. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  2854. const isIE = UA && /msie|trident/.test(UA);
  2855. UA && UA.indexOf('msie 9.0') > 0;
  2856. const isEdge = UA && UA.indexOf('edge/') > 0;
  2857. UA && UA.indexOf('android') > 0;
  2858. UA && /iphone|ipad|ipod|ios/.test(UA);
  2859. UA && /chrome\/\d+/.test(UA) && !isEdge;
  2860. UA && /phantomjs/.test(UA);
  2861. UA && UA.match(/firefox\/(\d+)/);
  2862. // Firefox has a "watch" function on Object.prototype...
  2863. // @ts-expect-error firebox support
  2864. const nativeWatch = {}.watch;
  2865. let supportsPassive = false;
  2866. if (inBrowser) {
  2867. try {
  2868. const opts = {};
  2869. Object.defineProperty(opts, 'passive', {
  2870. get() {
  2871. /* istanbul ignore next */
  2872. supportsPassive = true;
  2873. }
  2874. }); // https://github.com/facebook/flow/issues/285
  2875. window.addEventListener('test-passive', null, opts);
  2876. }
  2877. catch (e) { }
  2878. }
  2879. // this needs to be lazy-evaled because vue may be required before
  2880. // vue-server-renderer can set VUE_ENV
  2881. let _isServer;
  2882. const isServerRendering = () => {
  2883. if (_isServer === undefined) {
  2884. /* istanbul ignore if */
  2885. if (!inBrowser && typeof global !== 'undefined') {
  2886. // detect presence of vue-server-renderer and avoid
  2887. // Webpack shimming the process
  2888. _isServer =
  2889. global['process'] && global['process'].env.VUE_ENV === 'server';
  2890. }
  2891. else {
  2892. _isServer = false;
  2893. }
  2894. }
  2895. return _isServer;
  2896. };
  2897. /* istanbul ignore next */
  2898. function isNative(Ctor) {
  2899. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  2900. }
  2901. const hasSymbol = typeof Symbol !== 'undefined' &&
  2902. isNative(Symbol) &&
  2903. typeof Reflect !== 'undefined' &&
  2904. isNative(Reflect.ownKeys);
  2905. let _Set; // $flow-disable-line
  2906. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  2907. // use native Set when available.
  2908. _Set = Set;
  2909. }
  2910. else {
  2911. // a non-standard Set polyfill that only works with primitive keys.
  2912. _Set = class Set {
  2913. constructor() {
  2914. this.set = Object.create(null);
  2915. }
  2916. has(key) {
  2917. return this.set[key] === true;
  2918. }
  2919. add(key) {
  2920. this.set[key] = true;
  2921. }
  2922. clear() {
  2923. this.set = Object.create(null);
  2924. }
  2925. };
  2926. }
  2927. const ASSET_TYPES = ['component', 'directive', 'filter'];
  2928. const LIFECYCLE_HOOKS = [
  2929. 'beforeCreate',
  2930. 'created',
  2931. 'beforeMount',
  2932. 'mounted',
  2933. 'beforeUpdate',
  2934. 'updated',
  2935. 'beforeDestroy',
  2936. 'destroyed',
  2937. 'activated',
  2938. 'deactivated',
  2939. 'errorCaptured',
  2940. 'serverPrefetch',
  2941. 'renderTracked',
  2942. 'renderTriggered'
  2943. ];
  2944. var config = {
  2945. /**
  2946. * Option merge strategies (used in core/util/options)
  2947. */
  2948. // $flow-disable-line
  2949. optionMergeStrategies: Object.create(null),
  2950. /**
  2951. * Whether to suppress warnings.
  2952. */
  2953. silent: false,
  2954. /**
  2955. * Show production mode tip message on boot?
  2956. */
  2957. productionTip: process.env.NODE_ENV !== 'production',
  2958. /**
  2959. * Whether to enable devtools
  2960. */
  2961. devtools: process.env.NODE_ENV !== 'production',
  2962. /**
  2963. * Whether to record perf
  2964. */
  2965. performance: false,
  2966. /**
  2967. * Error handler for watcher errors
  2968. */
  2969. errorHandler: null,
  2970. /**
  2971. * Warn handler for watcher warns
  2972. */
  2973. warnHandler: null,
  2974. /**
  2975. * Ignore certain custom elements
  2976. */
  2977. ignoredElements: [],
  2978. /**
  2979. * Custom user key aliases for v-on
  2980. */
  2981. // $flow-disable-line
  2982. keyCodes: Object.create(null),
  2983. /**
  2984. * Check if a tag is reserved so that it cannot be registered as a
  2985. * component. This is platform-dependent and may be overwritten.
  2986. */
  2987. isReservedTag: no,
  2988. /**
  2989. * Check if an attribute is reserved so that it cannot be used as a component
  2990. * prop. This is platform-dependent and may be overwritten.
  2991. */
  2992. isReservedAttr: no,
  2993. /**
  2994. * Check if a tag is an unknown element.
  2995. * Platform-dependent.
  2996. */
  2997. isUnknownElement: no,
  2998. /**
  2999. * Get the namespace of an element
  3000. */
  3001. getTagNamespace: noop,
  3002. /**
  3003. * Parse the real tag name for the specific platform.
  3004. */
  3005. parsePlatformTagName: identity,
  3006. /**
  3007. * Check if an attribute must be bound using property, e.g. value
  3008. * Platform-dependent.
  3009. */
  3010. mustUseProp: no,
  3011. /**
  3012. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  3013. * This will significantly reduce performance if set to false.
  3014. */
  3015. async: true,
  3016. /**
  3017. * Exposed for legacy reasons
  3018. */
  3019. _lifecycleHooks: LIFECYCLE_HOOKS
  3020. };
  3021. let currentInstance = null;
  3022. /**
  3023. * @internal
  3024. */
  3025. function setCurrentInstance(vm = null) {
  3026. if (!vm)
  3027. currentInstance && currentInstance._scope.off();
  3028. currentInstance = vm;
  3029. vm && vm._scope.on();
  3030. }
  3031. /**
  3032. * @internal
  3033. */
  3034. class VNode {
  3035. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  3036. this.tag = tag;
  3037. this.data = data;
  3038. this.children = children;
  3039. this.text = text;
  3040. this.elm = elm;
  3041. this.ns = undefined;
  3042. this.context = context;
  3043. this.fnContext = undefined;
  3044. this.fnOptions = undefined;
  3045. this.fnScopeId = undefined;
  3046. this.key = data && data.key;
  3047. this.componentOptions = componentOptions;
  3048. this.componentInstance = undefined;
  3049. this.parent = undefined;
  3050. this.raw = false;
  3051. this.isStatic = false;
  3052. this.isRootInsert = true;
  3053. this.isComment = false;
  3054. this.isCloned = false;
  3055. this.isOnce = false;
  3056. this.asyncFactory = asyncFactory;
  3057. this.asyncMeta = undefined;
  3058. this.isAsyncPlaceholder = false;
  3059. }
  3060. // DEPRECATED: alias for componentInstance for backwards compat.
  3061. /* istanbul ignore next */
  3062. get child() {
  3063. return this.componentInstance;
  3064. }
  3065. }
  3066. const createEmptyVNode = (text = '') => {
  3067. const node = new VNode();
  3068. node.text = text;
  3069. node.isComment = true;
  3070. return node;
  3071. };
  3072. function createTextVNode(val) {
  3073. return new VNode(undefined, undefined, undefined, String(val));
  3074. }
  3075. // optimized shallow clone
  3076. // used for static nodes and slot nodes because they may be reused across
  3077. // multiple renders, cloning them avoids errors when DOM manipulations rely
  3078. // on their elm reference.
  3079. function cloneVNode(vnode) {
  3080. const cloned = new VNode(vnode.tag, vnode.data,
  3081. // #7975
  3082. // clone children array to avoid mutating original in case of cloning
  3083. // a child.
  3084. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  3085. cloned.ns = vnode.ns;
  3086. cloned.isStatic = vnode.isStatic;
  3087. cloned.key = vnode.key;
  3088. cloned.isComment = vnode.isComment;
  3089. cloned.fnContext = vnode.fnContext;
  3090. cloned.fnOptions = vnode.fnOptions;
  3091. cloned.fnScopeId = vnode.fnScopeId;
  3092. cloned.asyncMeta = vnode.asyncMeta;
  3093. cloned.isCloned = true;
  3094. return cloned;
  3095. }
  3096. /* not type checking this file because flow doesn't play well with Proxy */
  3097. if (process.env.NODE_ENV !== 'production') {
  3098. makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  3099. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  3100. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  3101. 'require' // for Webpack/Browserify
  3102. );
  3103. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  3104. if (hasProxy) {
  3105. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  3106. config.keyCodes = new Proxy(config.keyCodes, {
  3107. set(target, key, value) {
  3108. if (isBuiltInModifier(key)) {
  3109. warn$3(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  3110. return false;
  3111. }
  3112. else {
  3113. target[key] = value;
  3114. return true;
  3115. }
  3116. }
  3117. });
  3118. }
  3119. }
  3120. let uid = 0;
  3121. /**
  3122. * A dep is an observable that can have multiple
  3123. * directives subscribing to it.
  3124. * @internal
  3125. */
  3126. class Dep {
  3127. constructor() {
  3128. // pending subs cleanup
  3129. this._pending = false;
  3130. this.id = uid++;
  3131. this.subs = [];
  3132. }
  3133. addSub(sub) {
  3134. this.subs.push(sub);
  3135. }
  3136. removeSub(sub) {
  3137. // #12696 deps with massive amount of subscribers are extremely slow to
  3138. // clean up in Chromium
  3139. // to workaround this, we unset the sub for now, and clear them on
  3140. // next scheduler flush.
  3141. this.subs[this.subs.indexOf(sub)] = null;
  3142. if (!this._pending) {
  3143. this._pending = true;
  3144. }
  3145. }
  3146. depend(info) {
  3147. if (Dep.target) {
  3148. Dep.target.addDep(this);
  3149. if (process.env.NODE_ENV !== 'production' && info && Dep.target.onTrack) {
  3150. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  3151. }
  3152. }
  3153. }
  3154. notify(info) {
  3155. // stabilize the subscriber list first
  3156. const subs = this.subs.filter(s => s);
  3157. if (process.env.NODE_ENV !== 'production' && !config.async) {
  3158. // subs aren't sorted in scheduler if not running async
  3159. // we need to sort them now to make sure they fire in correct
  3160. // order
  3161. subs.sort((a, b) => a.id - b.id);
  3162. }
  3163. for (let i = 0, l = subs.length; i < l; i++) {
  3164. const sub = subs[i];
  3165. if (process.env.NODE_ENV !== 'production' && info) {
  3166. sub.onTrigger &&
  3167. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  3168. }
  3169. sub.update();
  3170. }
  3171. }
  3172. }
  3173. // The current target watcher being evaluated.
  3174. // This is globally unique because only one watcher
  3175. // can be evaluated at a time.
  3176. Dep.target = null;
  3177. const targetStack = [];
  3178. function pushTarget(target) {
  3179. targetStack.push(target);
  3180. Dep.target = target;
  3181. }
  3182. function popTarget() {
  3183. targetStack.pop();
  3184. Dep.target = targetStack[targetStack.length - 1];
  3185. }
  3186. /*
  3187. * not type checking this file because flow doesn't play well with
  3188. * dynamically accessing methods on Array prototype
  3189. */
  3190. const arrayProto = Array.prototype;
  3191. const arrayMethods = Object.create(arrayProto);
  3192. const methodsToPatch = [
  3193. 'push',
  3194. 'pop',
  3195. 'shift',
  3196. 'unshift',
  3197. 'splice',
  3198. 'sort',
  3199. 'reverse'
  3200. ];
  3201. /**
  3202. * Intercept mutating methods and emit events
  3203. */
  3204. methodsToPatch.forEach(function (method) {
  3205. // cache original method
  3206. const original = arrayProto[method];
  3207. def(arrayMethods, method, function mutator(...args) {
  3208. const result = original.apply(this, args);
  3209. const ob = this.__ob__;
  3210. let inserted;
  3211. switch (method) {
  3212. case 'push':
  3213. case 'unshift':
  3214. inserted = args;
  3215. break;
  3216. case 'splice':
  3217. inserted = args.slice(2);
  3218. break;
  3219. }
  3220. if (inserted)
  3221. ob.observeArray(inserted);
  3222. // notify change
  3223. if (process.env.NODE_ENV !== 'production') {
  3224. ob.dep.notify({
  3225. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  3226. target: this,
  3227. key: method
  3228. });
  3229. }
  3230. else {
  3231. ob.dep.notify();
  3232. }
  3233. return result;
  3234. });
  3235. });
  3236. const rawMap = new WeakMap();
  3237. function isReadonly(value) {
  3238. return !!(value && value.__v_isReadonly);
  3239. }
  3240. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  3241. const NO_INIITIAL_VALUE = {};
  3242. /**
  3243. * In some cases we may want to disable observation inside a component's
  3244. * update computation.
  3245. */
  3246. let shouldObserve = true;
  3247. function toggleObserving(value) {
  3248. shouldObserve = value;
  3249. }
  3250. // ssr mock dep
  3251. const mockDep = {
  3252. notify: noop,
  3253. depend: noop,
  3254. addSub: noop,
  3255. removeSub: noop
  3256. };
  3257. /**
  3258. * Observer class that is attached to each observed
  3259. * object. Once attached, the observer converts the target
  3260. * object's property keys into getter/setters that
  3261. * collect dependencies and dispatch updates.
  3262. */
  3263. class Observer {
  3264. constructor(value, shallow = false, mock = false) {
  3265. this.value = value;
  3266. this.shallow = shallow;
  3267. this.mock = mock;
  3268. // this.value = value
  3269. this.dep = mock ? mockDep : new Dep();
  3270. this.vmCount = 0;
  3271. def(value, '__ob__', this);
  3272. if (isArray(value)) {
  3273. if (!mock) {
  3274. if (hasProto) {
  3275. value.__proto__ = arrayMethods;
  3276. /* eslint-enable no-proto */
  3277. }
  3278. else {
  3279. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  3280. const key = arrayKeys[i];
  3281. def(value, key, arrayMethods[key]);
  3282. }
  3283. }
  3284. }
  3285. if (!shallow) {
  3286. this.observeArray(value);
  3287. }
  3288. }
  3289. else {
  3290. /**
  3291. * Walk through all properties and convert them into
  3292. * getter/setters. This method should only be called when
  3293. * value type is Object.
  3294. */
  3295. const keys = Object.keys(value);
  3296. for (let i = 0; i < keys.length; i++) {
  3297. const key = keys[i];
  3298. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  3299. }
  3300. }
  3301. }
  3302. /**
  3303. * Observe a list of Array items.
  3304. */
  3305. observeArray(value) {
  3306. for (let i = 0, l = value.length; i < l; i++) {
  3307. observe(value[i], false, this.mock);
  3308. }
  3309. }
  3310. }
  3311. // helpers
  3312. /**
  3313. * Attempt to create an observer instance for a value,
  3314. * returns the new observer if successfully observed,
  3315. * or the existing observer if the value already has one.
  3316. */
  3317. function observe(value, shallow, ssrMockReactivity) {
  3318. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  3319. return value.__ob__;
  3320. }
  3321. if (shouldObserve &&
  3322. (ssrMockReactivity || !isServerRendering()) &&
  3323. (isArray(value) || isPlainObject(value)) &&
  3324. Object.isExtensible(value) &&
  3325. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  3326. !rawMap.has(value) &&
  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) {
  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_INIITIAL_VALUE || arguments.length === 2)) {
  3346. val = obj[key];
  3347. }
  3348. let childOb = !shallow && 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 && 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 isRef(r) {
  3476. return !!(r && r.__v_isRef === true);
  3477. }
  3478. if (process.env.NODE_ENV !== 'production') ;
  3479. const normalizeEvent = cached((name) => {
  3480. const passive = name.charAt(0) === '&';
  3481. name = passive ? name.slice(1) : name;
  3482. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  3483. name = once ? name.slice(1) : name;
  3484. const capture = name.charAt(0) === '!';
  3485. name = capture ? name.slice(1) : name;
  3486. return {
  3487. name,
  3488. once,
  3489. capture,
  3490. passive
  3491. };
  3492. });
  3493. function createFnInvoker(fns, vm) {
  3494. function invoker() {
  3495. const fns = invoker.fns;
  3496. if (isArray(fns)) {
  3497. const cloned = fns.slice();
  3498. for (let i = 0; i < cloned.length; i++) {
  3499. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  3500. }
  3501. }
  3502. else {
  3503. // return handler return value for single handlers
  3504. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  3505. }
  3506. }
  3507. invoker.fns = fns;
  3508. return invoker;
  3509. }
  3510. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  3511. let name, cur, old, event;
  3512. for (name in on) {
  3513. cur = on[name];
  3514. old = oldOn[name];
  3515. event = normalizeEvent(name);
  3516. if (isUndef(cur)) {
  3517. process.env.NODE_ENV !== 'production' &&
  3518. warn$3(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  3519. }
  3520. else if (isUndef(old)) {
  3521. if (isUndef(cur.fns)) {
  3522. cur = on[name] = createFnInvoker(cur, vm);
  3523. }
  3524. if (isTrue(event.once)) {
  3525. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  3526. }
  3527. add(event.name, cur, event.capture, event.passive, event.params);
  3528. }
  3529. else if (cur !== old) {
  3530. old.fns = cur;
  3531. on[name] = old;
  3532. }
  3533. }
  3534. for (name in oldOn) {
  3535. if (isUndef(on[name])) {
  3536. event = normalizeEvent(name);
  3537. remove(event.name, oldOn[name], event.capture);
  3538. }
  3539. }
  3540. }
  3541. function extractPropsFromVNodeData(data, Ctor, tag) {
  3542. // we are only extracting raw values here.
  3543. // validation and default values are handled in the child
  3544. // component itself.
  3545. const propOptions = Ctor.options.props;
  3546. if (isUndef(propOptions)) {
  3547. return;
  3548. }
  3549. const res = {};
  3550. const { attrs, props } = data;
  3551. if (isDef(attrs) || isDef(props)) {
  3552. for (const key in propOptions) {
  3553. const altKey = hyphenate(key);
  3554. if (process.env.NODE_ENV !== 'production') {
  3555. const keyInLowerCase = key.toLowerCase();
  3556. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  3557. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  3558. `${formatComponentName(
  3559. // @ts-expect-error tag is string
  3560. tag || Ctor)}, but the declared prop name is` +
  3561. ` "${key}". ` +
  3562. `Note that HTML attributes are case-insensitive and camelCased ` +
  3563. `props need to use their kebab-case equivalents when using in-DOM ` +
  3564. `templates. You should probably use "${altKey}" instead of "${key}".`);
  3565. }
  3566. }
  3567. checkProp(res, props, key, altKey, true) ||
  3568. checkProp(res, attrs, key, altKey, false);
  3569. }
  3570. }
  3571. return res;
  3572. }
  3573. function checkProp(res, hash, key, altKey, preserve) {
  3574. if (isDef(hash)) {
  3575. if (hasOwn(hash, key)) {
  3576. res[key] = hash[key];
  3577. if (!preserve) {
  3578. delete hash[key];
  3579. }
  3580. return true;
  3581. }
  3582. else if (hasOwn(hash, altKey)) {
  3583. res[key] = hash[altKey];
  3584. if (!preserve) {
  3585. delete hash[altKey];
  3586. }
  3587. return true;
  3588. }
  3589. }
  3590. return false;
  3591. }
  3592. // The template compiler attempts to minimize the need for normalization by
  3593. // statically analyzing the template at compile time.
  3594. //
  3595. // For plain HTML markup, normalization can be completely skipped because the
  3596. // generated render function is guaranteed to return Array<VNode>. There are
  3597. // two cases where extra normalization is needed:
  3598. // 1. When the children contains components - because a functional component
  3599. // may return an Array instead of a single root. In this case, just a simple
  3600. // normalization is needed - if any child is an Array, we flatten the whole
  3601. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  3602. // because functional components already normalize their own children.
  3603. function simpleNormalizeChildren(children) {
  3604. for (let i = 0; i < children.length; i++) {
  3605. if (isArray(children[i])) {
  3606. return Array.prototype.concat.apply([], children);
  3607. }
  3608. }
  3609. return children;
  3610. }
  3611. // 2. When the children contains constructs that always generated nested Arrays,
  3612. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  3613. // with hand-written render functions / JSX. In such cases a full normalization
  3614. // is needed to cater to all possible types of children values.
  3615. function normalizeChildren(children) {
  3616. return isPrimitive(children)
  3617. ? [createTextVNode(children)]
  3618. : isArray(children)
  3619. ? normalizeArrayChildren(children)
  3620. : undefined;
  3621. }
  3622. function isTextNode(node) {
  3623. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  3624. }
  3625. function normalizeArrayChildren(children, nestedIndex) {
  3626. const res = [];
  3627. let i, c, lastIndex, last;
  3628. for (i = 0; i < children.length; i++) {
  3629. c = children[i];
  3630. if (isUndef(c) || typeof c === 'boolean')
  3631. continue;
  3632. lastIndex = res.length - 1;
  3633. last = res[lastIndex];
  3634. // nested
  3635. if (isArray(c)) {
  3636. if (c.length > 0) {
  3637. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  3638. // merge adjacent text nodes
  3639. if (isTextNode(c[0]) && isTextNode(last)) {
  3640. res[lastIndex] = createTextVNode(last.text + c[0].text);
  3641. c.shift();
  3642. }
  3643. res.push.apply(res, c);
  3644. }
  3645. }
  3646. else if (isPrimitive(c)) {
  3647. if (isTextNode(last)) {
  3648. // merge adjacent text nodes
  3649. // this is necessary for SSR hydration because text nodes are
  3650. // essentially merged when rendered to HTML strings
  3651. res[lastIndex] = createTextVNode(last.text + c);
  3652. }
  3653. else if (c !== '') {
  3654. // convert primitive to vnode
  3655. res.push(createTextVNode(c));
  3656. }
  3657. }
  3658. else {
  3659. if (isTextNode(c) && isTextNode(last)) {
  3660. // merge adjacent text nodes
  3661. res[lastIndex] = createTextVNode(last.text + c.text);
  3662. }
  3663. else {
  3664. // default key for nested array children (likely generated by v-for)
  3665. if (isTrue(children._isVList) &&
  3666. isDef(c.tag) &&
  3667. isUndef(c.key) &&
  3668. isDef(nestedIndex)) {
  3669. c.key = `__vlist${nestedIndex}_${i}__`;
  3670. }
  3671. res.push(c);
  3672. }
  3673. }
  3674. }
  3675. return res;
  3676. }
  3677. const SIMPLE_NORMALIZE = 1;
  3678. const ALWAYS_NORMALIZE = 2;
  3679. // wrapper function for providing a more flexible interface
  3680. // without getting yelled at by flow
  3681. function createElement(context, tag, data, children, normalizationType, alwaysNormalize) {
  3682. if (isArray(data) || isPrimitive(data)) {
  3683. normalizationType = children;
  3684. children = data;
  3685. data = undefined;
  3686. }
  3687. if (isTrue(alwaysNormalize)) {
  3688. normalizationType = ALWAYS_NORMALIZE;
  3689. }
  3690. return _createElement(context, tag, data, children, normalizationType);
  3691. }
  3692. function _createElement(context, tag, data, children, normalizationType) {
  3693. if (isDef(data) && isDef(data.__ob__)) {
  3694. process.env.NODE_ENV !== 'production' &&
  3695. warn$3(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  3696. return createEmptyVNode();
  3697. }
  3698. // object syntax in v-bind
  3699. if (isDef(data) && isDef(data.is)) {
  3700. tag = data.is;
  3701. }
  3702. if (!tag) {
  3703. // in case of component :is set to falsy value
  3704. return createEmptyVNode();
  3705. }
  3706. // warn against non-primitive key
  3707. if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  3708. warn$3('Avoid using non-primitive value as key, ' +
  3709. 'use string/number value instead.', context);
  3710. }
  3711. // support single function children as default scoped slot
  3712. if (isArray(children) && isFunction(children[0])) {
  3713. data = data || {};
  3714. data.scopedSlots = { default: children[0] };
  3715. children.length = 0;
  3716. }
  3717. if (normalizationType === ALWAYS_NORMALIZE) {
  3718. children = normalizeChildren(children);
  3719. }
  3720. else if (normalizationType === SIMPLE_NORMALIZE) {
  3721. children = simpleNormalizeChildren(children);
  3722. }
  3723. let vnode, ns;
  3724. if (typeof tag === 'string') {
  3725. let Ctor;
  3726. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  3727. if ((!data || !data.pre) &&
  3728. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  3729. // component
  3730. vnode = createComponent(Ctor, data, context, children, tag);
  3731. }
  3732. else {
  3733. // unknown or unlisted namespaced elements
  3734. // check at runtime because it may get assigned a namespace when its
  3735. // parent normalizes children
  3736. vnode = new VNode(tag, data, children, undefined, undefined, context);
  3737. }
  3738. }
  3739. else {
  3740. // direct component options / constructor
  3741. vnode = createComponent(tag, data, context, children);
  3742. }
  3743. if (isArray(vnode)) {
  3744. return vnode;
  3745. }
  3746. else if (isDef(vnode)) {
  3747. if (isDef(ns))
  3748. applyNS(vnode, ns);
  3749. if (isDef(data))
  3750. registerDeepBindings(data);
  3751. return vnode;
  3752. }
  3753. else {
  3754. return createEmptyVNode();
  3755. }
  3756. }
  3757. function applyNS(vnode, ns, force) {
  3758. vnode.ns = ns;
  3759. if (vnode.tag === 'foreignObject') {
  3760. // use default namespace inside foreignObject
  3761. ns = undefined;
  3762. force = true;
  3763. }
  3764. if (isDef(vnode.children)) {
  3765. for (let i = 0, l = vnode.children.length; i < l; i++) {
  3766. const child = vnode.children[i];
  3767. if (isDef(child.tag) &&
  3768. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3769. applyNS(child, ns, force);
  3770. }
  3771. }
  3772. }
  3773. }
  3774. // ref #5318
  3775. // necessary to ensure parent re-render when deep bindings like :style and
  3776. // :class are used on slot nodes
  3777. function registerDeepBindings(data) {
  3778. if (isObject$1(data.style)) {
  3779. traverse(data.style);
  3780. }
  3781. if (isObject$1(data.class)) {
  3782. traverse(data.class);
  3783. }
  3784. }
  3785. /**
  3786. * Runtime helper for rendering v-for lists.
  3787. */
  3788. function renderList(val, render) {
  3789. let ret = null, i, l, keys, key;
  3790. if (isArray(val) || typeof val === 'string') {
  3791. ret = new Array(val.length);
  3792. for (i = 0, l = val.length; i < l; i++) {
  3793. ret[i] = render(val[i], i);
  3794. }
  3795. }
  3796. else if (typeof val === 'number') {
  3797. ret = new Array(val);
  3798. for (i = 0; i < val; i++) {
  3799. ret[i] = render(i + 1, i);
  3800. }
  3801. }
  3802. else if (isObject$1(val)) {
  3803. if (hasSymbol && val[Symbol.iterator]) {
  3804. ret = [];
  3805. const iterator = val[Symbol.iterator]();
  3806. let result = iterator.next();
  3807. while (!result.done) {
  3808. ret.push(render(result.value, ret.length));
  3809. result = iterator.next();
  3810. }
  3811. }
  3812. else {
  3813. keys = Object.keys(val);
  3814. ret = new Array(keys.length);
  3815. for (i = 0, l = keys.length; i < l; i++) {
  3816. key = keys[i];
  3817. ret[i] = render(val[key], key, i);
  3818. }
  3819. }
  3820. }
  3821. if (!isDef(ret)) {
  3822. ret = [];
  3823. }
  3824. ret._isVList = true;
  3825. return ret;
  3826. }
  3827. /**
  3828. * Runtime helper for rendering <slot>
  3829. */
  3830. function renderSlot(name, fallbackRender, props, bindObject) {
  3831. const scopedSlotFn = this.$scopedSlots[name];
  3832. let nodes;
  3833. if (scopedSlotFn) {
  3834. // scoped slot
  3835. props = props || {};
  3836. if (bindObject) {
  3837. if (process.env.NODE_ENV !== 'production' && !isObject$1(bindObject)) {
  3838. warn$3('slot v-bind without argument expects an Object', this);
  3839. }
  3840. props = extend(extend({}, bindObject), props);
  3841. }
  3842. nodes =
  3843. scopedSlotFn(props) ||
  3844. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  3845. }
  3846. else {
  3847. nodes =
  3848. this.$slots[name] ||
  3849. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  3850. }
  3851. const target = props && props.slot;
  3852. if (target) {
  3853. return this.$createElement('template', { slot: target }, nodes);
  3854. }
  3855. else {
  3856. return nodes;
  3857. }
  3858. }
  3859. /**
  3860. * Runtime helper for resolving filters
  3861. */
  3862. function resolveFilter(id) {
  3863. return resolveAsset(this.$options, 'filters', id, true) || identity;
  3864. }
  3865. function isKeyNotMatch(expect, actual) {
  3866. if (isArray(expect)) {
  3867. return expect.indexOf(actual) === -1;
  3868. }
  3869. else {
  3870. return expect !== actual;
  3871. }
  3872. }
  3873. /**
  3874. * Runtime helper for checking keyCodes from config.
  3875. * exposed as Vue.prototype._k
  3876. * passing in eventKeyName as last argument separately for backwards compat
  3877. */
  3878. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  3879. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  3880. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  3881. return isKeyNotMatch(builtInKeyName, eventKeyName);
  3882. }
  3883. else if (mappedKeyCode) {
  3884. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  3885. }
  3886. else if (eventKeyName) {
  3887. return hyphenate(eventKeyName) !== key;
  3888. }
  3889. return eventKeyCode === undefined;
  3890. }
  3891. /**
  3892. * Runtime helper for merging v-bind="object" into a VNode's data.
  3893. */
  3894. function bindObjectProps(data, tag, value, asProp, isSync) {
  3895. if (value) {
  3896. if (!isObject$1(value)) {
  3897. process.env.NODE_ENV !== 'production' &&
  3898. warn$3('v-bind without argument expects an Object or Array value', this);
  3899. }
  3900. else {
  3901. if (isArray(value)) {
  3902. value = toObject(value);
  3903. }
  3904. let hash;
  3905. for (const key in value) {
  3906. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  3907. hash = data;
  3908. }
  3909. else {
  3910. const type = data.attrs && data.attrs.type;
  3911. hash =
  3912. asProp || config.mustUseProp(tag, type, key)
  3913. ? data.domProps || (data.domProps = {})
  3914. : data.attrs || (data.attrs = {});
  3915. }
  3916. const camelizedKey = camelize(key);
  3917. const hyphenatedKey = hyphenate(key);
  3918. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  3919. hash[key] = value[key];
  3920. if (isSync) {
  3921. const on = data.on || (data.on = {});
  3922. on[`update:${key}`] = function ($event) {
  3923. value[key] = $event;
  3924. };
  3925. }
  3926. }
  3927. }
  3928. }
  3929. }
  3930. return data;
  3931. }
  3932. /**
  3933. * Runtime helper for rendering static trees.
  3934. */
  3935. function renderStatic(index, isInFor) {
  3936. const cached = this._staticTrees || (this._staticTrees = []);
  3937. let tree = cached[index];
  3938. // if has already-rendered static tree and not inside v-for,
  3939. // we can reuse the same tree.
  3940. if (tree && !isInFor) {
  3941. return tree;
  3942. }
  3943. // otherwise, render a fresh tree.
  3944. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  3945. );
  3946. markStatic$1(tree, `__static__${index}`, false);
  3947. return tree;
  3948. }
  3949. /**
  3950. * Runtime helper for v-once.
  3951. * Effectively it means marking the node as static with a unique key.
  3952. */
  3953. function markOnce(tree, index, key) {
  3954. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  3955. return tree;
  3956. }
  3957. function markStatic$1(tree, key, isOnce) {
  3958. if (isArray(tree)) {
  3959. for (let i = 0; i < tree.length; i++) {
  3960. if (tree[i] && typeof tree[i] !== 'string') {
  3961. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  3962. }
  3963. }
  3964. }
  3965. else {
  3966. markStaticNode(tree, key, isOnce);
  3967. }
  3968. }
  3969. function markStaticNode(node, key, isOnce) {
  3970. node.isStatic = true;
  3971. node.key = key;
  3972. node.isOnce = isOnce;
  3973. }
  3974. function bindObjectListeners(data, value) {
  3975. if (value) {
  3976. if (!isPlainObject(value)) {
  3977. process.env.NODE_ENV !== 'production' && warn$3('v-on without argument expects an Object value', this);
  3978. }
  3979. else {
  3980. const on = (data.on = data.on ? extend({}, data.on) : {});
  3981. for (const key in value) {
  3982. const existing = on[key];
  3983. const ours = value[key];
  3984. on[key] = existing ? [].concat(existing, ours) : ours;
  3985. }
  3986. }
  3987. }
  3988. return data;
  3989. }
  3990. function resolveScopedSlots(fns, res,
  3991. // the following are added in 2.6
  3992. hasDynamicKeys, contentHashKey) {
  3993. res = res || { $stable: !hasDynamicKeys };
  3994. for (let i = 0; i < fns.length; i++) {
  3995. const slot = fns[i];
  3996. if (isArray(slot)) {
  3997. resolveScopedSlots(slot, res, hasDynamicKeys);
  3998. }
  3999. else if (slot) {
  4000. // marker for reverse proxying v-slot without scope on this.$slots
  4001. // @ts-expect-error
  4002. if (slot.proxy) {
  4003. // @ts-expect-error
  4004. slot.fn.proxy = true;
  4005. }
  4006. res[slot.key] = slot.fn;
  4007. }
  4008. }
  4009. if (contentHashKey) {
  4010. res.$key = contentHashKey;
  4011. }
  4012. return res;
  4013. }
  4014. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  4015. function bindDynamicKeys(baseObj, values) {
  4016. for (let i = 0; i < values.length; i += 2) {
  4017. const key = values[i];
  4018. if (typeof key === 'string' && key) {
  4019. baseObj[values[i]] = values[i + 1];
  4020. }
  4021. else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
  4022. // null is a special value for explicitly removing a binding
  4023. warn$3(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  4024. }
  4025. }
  4026. return baseObj;
  4027. }
  4028. // helper to dynamically append modifier runtime markers to event names.
  4029. // ensure only append when value is already string, otherwise it will be cast
  4030. // to string and cause the type check to miss.
  4031. function prependModifier(value, symbol) {
  4032. return typeof value === 'string' ? symbol + value : value;
  4033. }
  4034. function installRenderHelpers(target) {
  4035. target._o = markOnce;
  4036. target._n = toNumber;
  4037. target._s = toString$2;
  4038. target._l = renderList;
  4039. target._t = renderSlot;
  4040. target._q = looseEqual;
  4041. target._i = looseIndexOf;
  4042. target._m = renderStatic;
  4043. target._f = resolveFilter;
  4044. target._k = checkKeyCodes;
  4045. target._b = bindObjectProps;
  4046. target._v = createTextVNode;
  4047. target._e = createEmptyVNode;
  4048. target._u = resolveScopedSlots;
  4049. target._g = bindObjectListeners;
  4050. target._d = bindDynamicKeys;
  4051. target._p = prependModifier;
  4052. }
  4053. /**
  4054. * Runtime helper for resolving raw children VNodes into a slot object.
  4055. */
  4056. function resolveSlots(children, context) {
  4057. if (!children || !children.length) {
  4058. return {};
  4059. }
  4060. const slots = {};
  4061. for (let i = 0, l = children.length; i < l; i++) {
  4062. const child = children[i];
  4063. const data = child.data;
  4064. // remove slot attribute if the node is resolved as a Vue slot node
  4065. if (data && data.attrs && data.attrs.slot) {
  4066. delete data.attrs.slot;
  4067. }
  4068. // named slots should only be respected if the vnode was rendered in the
  4069. // same context.
  4070. if ((child.context === context || child.fnContext === context) &&
  4071. data &&
  4072. data.slot != null) {
  4073. const name = data.slot;
  4074. const slot = slots[name] || (slots[name] = []);
  4075. if (child.tag === 'template') {
  4076. slot.push.apply(slot, child.children || []);
  4077. }
  4078. else {
  4079. slot.push(child);
  4080. }
  4081. }
  4082. else {
  4083. (slots.default || (slots.default = [])).push(child);
  4084. }
  4085. }
  4086. // ignore slots that contains only whitespace
  4087. for (const name in slots) {
  4088. if (slots[name].every(isWhitespace)) {
  4089. delete slots[name];
  4090. }
  4091. }
  4092. return slots;
  4093. }
  4094. function isWhitespace(node) {
  4095. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  4096. }
  4097. function isAsyncPlaceholder(node) {
  4098. // @ts-expect-error not really boolean type
  4099. return node.isComment && node.asyncFactory;
  4100. }
  4101. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  4102. let res;
  4103. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  4104. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  4105. const key = scopedSlots && scopedSlots.$key;
  4106. if (!scopedSlots) {
  4107. res = {};
  4108. }
  4109. else if (scopedSlots._normalized) {
  4110. // fast path 1: child component re-render only, parent did not change
  4111. return scopedSlots._normalized;
  4112. }
  4113. else if (isStable &&
  4114. prevScopedSlots &&
  4115. prevScopedSlots !== emptyObject &&
  4116. key === prevScopedSlots.$key &&
  4117. !hasNormalSlots &&
  4118. !prevScopedSlots.$hasNormal) {
  4119. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  4120. // only need to normalize once
  4121. return prevScopedSlots;
  4122. }
  4123. else {
  4124. res = {};
  4125. for (const key in scopedSlots) {
  4126. if (scopedSlots[key] && key[0] !== '$') {
  4127. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  4128. }
  4129. }
  4130. }
  4131. // expose normal slots on scopedSlots
  4132. for (const key in normalSlots) {
  4133. if (!(key in res)) {
  4134. res[key] = proxyNormalSlot(normalSlots, key);
  4135. }
  4136. }
  4137. // avoriaz seems to mock a non-extensible $scopedSlots object
  4138. // and when that is passed down this would cause an error
  4139. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  4140. scopedSlots._normalized = res;
  4141. }
  4142. def(res, '$stable', isStable);
  4143. def(res, '$key', key);
  4144. def(res, '$hasNormal', hasNormalSlots);
  4145. return res;
  4146. }
  4147. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  4148. const normalized = function () {
  4149. const cur = currentInstance;
  4150. setCurrentInstance(vm);
  4151. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  4152. res =
  4153. res && typeof res === 'object' && !isArray(res)
  4154. ? [res] // single vnode
  4155. : normalizeChildren(res);
  4156. const vnode = res && res[0];
  4157. setCurrentInstance(cur);
  4158. return res &&
  4159. (!vnode ||
  4160. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  4161. ? undefined
  4162. : res;
  4163. };
  4164. // this is a slot using the new v-slot syntax without scope. although it is
  4165. // compiled as a scoped slot, render fn users would expect it to be present
  4166. // on this.$slots because the usage is semantically a normal slot.
  4167. if (fn.proxy) {
  4168. Object.defineProperty(normalSlots, key, {
  4169. get: normalized,
  4170. enumerable: true,
  4171. configurable: true
  4172. });
  4173. }
  4174. return normalized;
  4175. }
  4176. function proxyNormalSlot(slots, key) {
  4177. return () => slots[key];
  4178. }
  4179. function syncSetupProxy(to, from, prev, instance, type) {
  4180. let changed = false;
  4181. for (const key in from) {
  4182. if (!(key in to)) {
  4183. changed = true;
  4184. defineProxyAttr(to, key, instance, type);
  4185. }
  4186. else if (from[key] !== prev[key]) {
  4187. changed = true;
  4188. }
  4189. }
  4190. for (const key in to) {
  4191. if (!(key in from)) {
  4192. changed = true;
  4193. delete to[key];
  4194. }
  4195. }
  4196. return changed;
  4197. }
  4198. function defineProxyAttr(proxy, key, instance, type) {
  4199. Object.defineProperty(proxy, key, {
  4200. enumerable: true,
  4201. configurable: true,
  4202. get() {
  4203. return instance[type][key];
  4204. }
  4205. });
  4206. }
  4207. function createAsyncPlaceholder(factory, data, context, children, tag) {
  4208. const node = createEmptyVNode();
  4209. node.asyncFactory = factory;
  4210. node.asyncMeta = { data, context, children, tag };
  4211. return node;
  4212. }
  4213. function resolveAsyncComponent(factory, baseCtor) {
  4214. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  4215. return factory.errorComp;
  4216. }
  4217. if (isDef(factory.resolved)) {
  4218. return factory.resolved;
  4219. }
  4220. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  4221. return factory.loadingComp;
  4222. }
  4223. }
  4224. let target;
  4225. function add(event, fn) {
  4226. target.$on(event, fn);
  4227. }
  4228. function remove(event, fn) {
  4229. target.$off(event, fn);
  4230. }
  4231. function createOnceHandler(event, fn) {
  4232. const _target = target;
  4233. return function onceHandler() {
  4234. const res = fn.apply(null, arguments);
  4235. if (res !== null) {
  4236. _target.$off(event, onceHandler);
  4237. }
  4238. };
  4239. }
  4240. function updateComponentListeners(vm, listeners, oldListeners) {
  4241. target = vm;
  4242. updateListeners(listeners, oldListeners || {}, add, remove, createOnceHandler, vm);
  4243. target = undefined;
  4244. }
  4245. let activeInstance = null;
  4246. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  4247. if (process.env.NODE_ENV !== 'production') ;
  4248. // determine whether component has slot children
  4249. // we need to do this before overwriting $options._renderChildren.
  4250. // check if there are dynamic scopedSlots (hand-written or compiled but with
  4251. // dynamic slot names). Static scoped slots compiled from template has the
  4252. // "$stable" marker.
  4253. const newScopedSlots = parentVnode.data.scopedSlots;
  4254. const oldScopedSlots = vm.$scopedSlots;
  4255. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  4256. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  4257. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  4258. (!newScopedSlots && vm.$scopedSlots.$key));
  4259. // Any static slot children from the parent may have changed during parent's
  4260. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  4261. // update is necessary to ensure correctness.
  4262. let needsForceUpdate = !!(renderChildren || // has new static slots
  4263. vm.$options._renderChildren || // has old static slots
  4264. hasDynamicScopedSlot);
  4265. const prevVNode = vm.$vnode;
  4266. vm.$options._parentVnode = parentVnode;
  4267. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  4268. if (vm._vnode) {
  4269. // update child tree's parent
  4270. vm._vnode.parent = parentVnode;
  4271. }
  4272. vm.$options._renderChildren = renderChildren;
  4273. // update $attrs and $listeners hash
  4274. // these are also reactive so they may trigger child update if the child
  4275. // used them during render
  4276. const attrs = parentVnode.data.attrs || emptyObject;
  4277. if (vm._attrsProxy) {
  4278. // force update if attrs are accessed and has changed since it may be
  4279. // passed to a child component.
  4280. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  4281. needsForceUpdate = true;
  4282. }
  4283. }
  4284. vm.$attrs = attrs;
  4285. // update listeners
  4286. listeners = listeners || emptyObject;
  4287. const prevListeners = vm.$options._parentListeners;
  4288. if (vm._listenersProxy) {
  4289. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  4290. }
  4291. vm.$listeners = vm.$options._parentListeners = listeners;
  4292. updateComponentListeners(vm, listeners, prevListeners);
  4293. // update props
  4294. if (propsData && vm.$options.props) {
  4295. toggleObserving(false);
  4296. const props = vm._props;
  4297. const propKeys = vm.$options._propKeys || [];
  4298. for (let i = 0; i < propKeys.length; i++) {
  4299. const key = propKeys[i];
  4300. const propOptions = vm.$options.props; // wtf flow?
  4301. props[key] = validateProp(key, propOptions, propsData, vm);
  4302. }
  4303. toggleObserving(true);
  4304. // keep a copy of raw propsData
  4305. vm.$options.propsData = propsData;
  4306. }
  4307. // resolve slots + force update if has children
  4308. if (needsForceUpdate) {
  4309. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  4310. vm.$forceUpdate();
  4311. }
  4312. if (process.env.NODE_ENV !== 'production') ;
  4313. }
  4314. function isInInactiveTree(vm) {
  4315. while (vm && (vm = vm.$parent)) {
  4316. if (vm._inactive)
  4317. return true;
  4318. }
  4319. return false;
  4320. }
  4321. function activateChildComponent(vm, direct) {
  4322. if (direct) {
  4323. vm._directInactive = false;
  4324. if (isInInactiveTree(vm)) {
  4325. return;
  4326. }
  4327. }
  4328. else if (vm._directInactive) {
  4329. return;
  4330. }
  4331. if (vm._inactive || vm._inactive === null) {
  4332. vm._inactive = false;
  4333. for (let i = 0; i < vm.$children.length; i++) {
  4334. activateChildComponent(vm.$children[i]);
  4335. }
  4336. callHook(vm, 'activated');
  4337. }
  4338. }
  4339. function deactivateChildComponent(vm, direct) {
  4340. if (direct) {
  4341. vm._directInactive = true;
  4342. if (isInInactiveTree(vm)) {
  4343. return;
  4344. }
  4345. }
  4346. if (!vm._inactive) {
  4347. vm._inactive = true;
  4348. for (let i = 0; i < vm.$children.length; i++) {
  4349. deactivateChildComponent(vm.$children[i]);
  4350. }
  4351. callHook(vm, 'deactivated');
  4352. }
  4353. }
  4354. function callHook(vm, hook, args, setContext = true) {
  4355. // #7573 disable dep collection when invoking lifecycle hooks
  4356. pushTarget();
  4357. const prev = currentInstance;
  4358. setContext && setCurrentInstance(vm);
  4359. const handlers = vm.$options[hook];
  4360. const info = `${hook} hook`;
  4361. if (handlers) {
  4362. for (let i = 0, j = handlers.length; i < j; i++) {
  4363. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  4364. }
  4365. }
  4366. if (vm._hasHookEvent) {
  4367. vm.$emit('hook:' + hook);
  4368. }
  4369. setContext && setCurrentInstance(prev);
  4370. popTarget();
  4371. }
  4372. // Async edge case fix requires storing an event listener's attach timestamp.
  4373. let getNow = Date.now;
  4374. // Determine what event timestamp the browser is using. Annoyingly, the
  4375. // timestamp can either be hi-res (relative to page load) or low-res
  4376. // (relative to UNIX epoch), so in order to compare time we have to use the
  4377. // same timestamp type when saving the flush timestamp.
  4378. // All IE versions use low-res event timestamps, and have problematic clock
  4379. // implementations (#9632)
  4380. if (inBrowser && !isIE) {
  4381. const performance = window.performance;
  4382. if (performance &&
  4383. typeof performance.now === 'function' &&
  4384. getNow() > document.createEvent('Event').timeStamp) {
  4385. // if the event timestamp, although evaluated AFTER the Date.now(), is
  4386. // smaller than it, it means the event is using a hi-res timestamp,
  4387. // and we need to use the hi-res version for event listener timestamps as
  4388. // well.
  4389. getNow = () => performance.now();
  4390. }
  4391. }
  4392. /**
  4393. * Queue a kept-alive component that was activated during patch.
  4394. * The queue will be processed after the entire tree has been patched.
  4395. */
  4396. function queueActivatedComponent(vm) {
  4397. // setting _inactive to false here so that a render function can
  4398. // rely on checking whether it's in an inactive tree (e.g. router-view)
  4399. vm._inactive = false;
  4400. }
  4401. function handleError(err, vm, info) {
  4402. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  4403. // See: https://github.com/vuejs/vuex/issues/1505
  4404. pushTarget();
  4405. try {
  4406. if (vm) {
  4407. let cur = vm;
  4408. while ((cur = cur.$parent)) {
  4409. const hooks = cur.$options.errorCaptured;
  4410. if (hooks) {
  4411. for (let i = 0; i < hooks.length; i++) {
  4412. try {
  4413. const capture = hooks[i].call(cur, err, vm, info) === false;
  4414. if (capture)
  4415. return;
  4416. }
  4417. catch (e) {
  4418. globalHandleError(e, cur, 'errorCaptured hook');
  4419. }
  4420. }
  4421. }
  4422. }
  4423. }
  4424. globalHandleError(err, vm, info);
  4425. }
  4426. finally {
  4427. popTarget();
  4428. }
  4429. }
  4430. function invokeWithErrorHandling(handler, context, args, vm, info) {
  4431. let res;
  4432. try {
  4433. res = args ? handler.apply(context, args) : handler.call(context);
  4434. if (res && !res._isVue && isPromise(res) && !res._handled) {
  4435. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  4436. res._handled = true;
  4437. }
  4438. }
  4439. catch (e) {
  4440. handleError(e, vm, info);
  4441. }
  4442. return res;
  4443. }
  4444. function globalHandleError(err, vm, info) {
  4445. logError(err, vm, info);
  4446. }
  4447. function logError(err, vm, info) {
  4448. if (process.env.NODE_ENV !== 'production') {
  4449. warn$3(`Error in ${info}: "${err.toString()}"`, vm);
  4450. }
  4451. /* istanbul ignore else */
  4452. if (inBrowser && typeof console !== 'undefined') {
  4453. console.error(err);
  4454. }
  4455. else {
  4456. throw err;
  4457. }
  4458. }
  4459. /* globals MutationObserver */
  4460. const callbacks = [];
  4461. function flushCallbacks() {
  4462. const copies = callbacks.slice(0);
  4463. callbacks.length = 0;
  4464. for (let i = 0; i < copies.length; i++) {
  4465. copies[i]();
  4466. }
  4467. }
  4468. // The nextTick behavior leverages the microtask queue, which can be accessed
  4469. // via either native Promise.then or MutationObserver.
  4470. // MutationObserver has wider support, however it is seriously bugged in
  4471. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  4472. // completely stops working after triggering a few times... so, if native
  4473. // Promise is available, we will use it:
  4474. /* istanbul ignore next, $flow-disable-line */
  4475. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  4476. Promise.resolve();
  4477. }
  4478. else if (!isIE &&
  4479. typeof MutationObserver !== 'undefined' &&
  4480. (isNative(MutationObserver) ||
  4481. // PhantomJS and iOS 7.x
  4482. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  4483. // Use MutationObserver where native Promise is not available,
  4484. // e.g. PhantomJS, iOS7, Android 4.4
  4485. // (#6466 MutationObserver is unreliable in IE11)
  4486. let counter = 1;
  4487. const observer = new MutationObserver(flushCallbacks);
  4488. const textNode = document.createTextNode(String(counter));
  4489. observer.observe(textNode, {
  4490. characterData: true
  4491. });
  4492. }
  4493. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ;
  4494. else ;
  4495. const seenObjects = new _Set();
  4496. /**
  4497. * Recursively traverse an object to evoke all converted
  4498. * getters, so that every nested property inside the object
  4499. * is collected as a "deep" dependency.
  4500. */
  4501. function traverse(val) {
  4502. _traverse(val, seenObjects);
  4503. seenObjects.clear();
  4504. return val;
  4505. }
  4506. function _traverse(val, seen) {
  4507. let i, keys;
  4508. const isA = isArray(val);
  4509. if ((!isA && !isObject$1(val)) ||
  4510. Object.isFrozen(val) ||
  4511. val instanceof VNode) {
  4512. return;
  4513. }
  4514. if (val.__ob__) {
  4515. const depId = val.__ob__.dep.id;
  4516. if (seen.has(depId)) {
  4517. return;
  4518. }
  4519. seen.add(depId);
  4520. }
  4521. if (isA) {
  4522. i = val.length;
  4523. while (i--)
  4524. _traverse(val[i], seen);
  4525. }
  4526. else if (isRef(val)) {
  4527. _traverse(val.value, seen);
  4528. }
  4529. else {
  4530. keys = Object.keys(val);
  4531. i = keys.length;
  4532. while (i--)
  4533. _traverse(val[keys[i]], seen);
  4534. }
  4535. }
  4536. function resolveInject(inject, vm) {
  4537. if (inject) {
  4538. // inject is :any because flow is not smart enough to figure out cached
  4539. const result = Object.create(null);
  4540. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4541. for (let i = 0; i < keys.length; i++) {
  4542. const key = keys[i];
  4543. // #6574 in case the inject object is observed...
  4544. if (key === '__ob__')
  4545. continue;
  4546. const provideKey = inject[key].from;
  4547. if (provideKey in vm._provided) {
  4548. result[key] = vm._provided[provideKey];
  4549. }
  4550. else if ('default' in inject[key]) {
  4551. const provideDefault = inject[key].default;
  4552. result[key] = isFunction(provideDefault)
  4553. ? provideDefault.call(vm)
  4554. : provideDefault;
  4555. }
  4556. else if (process.env.NODE_ENV !== 'production') {
  4557. warn$3(`Injection "${key}" not found`, vm);
  4558. }
  4559. }
  4560. return result;
  4561. }
  4562. }
  4563. function resolveConstructorOptions(Ctor) {
  4564. let options = Ctor.options;
  4565. if (Ctor.super) {
  4566. const superOptions = resolveConstructorOptions(Ctor.super);
  4567. const cachedSuperOptions = Ctor.superOptions;
  4568. if (superOptions !== cachedSuperOptions) {
  4569. // super option changed,
  4570. // need to resolve new options.
  4571. Ctor.superOptions = superOptions;
  4572. // check if there are any late-modified/attached options (#4976)
  4573. const modifiedOptions = resolveModifiedOptions(Ctor);
  4574. // update base extend options
  4575. if (modifiedOptions) {
  4576. extend(Ctor.extendOptions, modifiedOptions);
  4577. }
  4578. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4579. if (options.name) {
  4580. options.components[options.name] = Ctor;
  4581. }
  4582. }
  4583. }
  4584. return options;
  4585. }
  4586. function resolveModifiedOptions(Ctor) {
  4587. let modified;
  4588. const latest = Ctor.options;
  4589. const sealed = Ctor.sealedOptions;
  4590. for (const key in latest) {
  4591. if (latest[key] !== sealed[key]) {
  4592. if (!modified)
  4593. modified = {};
  4594. modified[key] = latest[key];
  4595. }
  4596. }
  4597. return modified;
  4598. }
  4599. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4600. const options = Ctor.options;
  4601. // ensure the createElement function in functional components
  4602. // gets a unique context - this is necessary for correct named slot check
  4603. let contextVm;
  4604. if (hasOwn(parent, '_uid')) {
  4605. contextVm = Object.create(parent);
  4606. contextVm._original = parent;
  4607. }
  4608. else {
  4609. // the context vm passed in is a functional context as well.
  4610. // in this case we want to make sure we are able to get a hold to the
  4611. // real context instance.
  4612. contextVm = parent;
  4613. // @ts-ignore
  4614. parent = parent._original;
  4615. }
  4616. const isCompiled = isTrue(options._compiled);
  4617. const needNormalization = !isCompiled;
  4618. this.data = data;
  4619. this.props = props;
  4620. this.children = children;
  4621. this.parent = parent;
  4622. this.listeners = data.on || emptyObject;
  4623. this.injections = resolveInject(options.inject, parent);
  4624. this.slots = () => {
  4625. if (!this.$slots) {
  4626. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4627. }
  4628. return this.$slots;
  4629. };
  4630. Object.defineProperty(this, 'scopedSlots', {
  4631. enumerable: true,
  4632. get() {
  4633. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4634. }
  4635. });
  4636. // support for compiled functional template
  4637. if (isCompiled) {
  4638. // exposing $options for renderStatic()
  4639. this.$options = options;
  4640. // pre-resolve slots for renderSlot()
  4641. this.$slots = this.slots();
  4642. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4643. }
  4644. if (options._scopeId) {
  4645. this._c = (a, b, c, d) => {
  4646. const vnode = createElement(contextVm, a, b, c, d, needNormalization);
  4647. if (vnode && !isArray(vnode)) {
  4648. vnode.fnScopeId = options._scopeId;
  4649. vnode.fnContext = parent;
  4650. }
  4651. return vnode;
  4652. };
  4653. }
  4654. else {
  4655. this._c = (a, b, c, d) => createElement(contextVm, a, b, c, d, needNormalization);
  4656. }
  4657. }
  4658. installRenderHelpers(FunctionalRenderContext.prototype);
  4659. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4660. const options = Ctor.options;
  4661. const props = {};
  4662. const propOptions = options.props;
  4663. if (isDef(propOptions)) {
  4664. for (const key in propOptions) {
  4665. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4666. }
  4667. }
  4668. else {
  4669. if (isDef(data.attrs))
  4670. mergeProps(props, data.attrs);
  4671. if (isDef(data.props))
  4672. mergeProps(props, data.props);
  4673. }
  4674. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4675. const vnode = options.render.call(null, renderContext._c, renderContext);
  4676. if (vnode instanceof VNode) {
  4677. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4678. }
  4679. else if (isArray(vnode)) {
  4680. const vnodes = normalizeChildren(vnode) || [];
  4681. const res = new Array(vnodes.length);
  4682. for (let i = 0; i < vnodes.length; i++) {
  4683. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4684. }
  4685. return res;
  4686. }
  4687. }
  4688. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4689. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4690. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4691. // that should not be matched to match.
  4692. const clone = cloneVNode(vnode);
  4693. clone.fnContext = contextVm;
  4694. clone.fnOptions = options;
  4695. if (process.env.NODE_ENV !== 'production') {
  4696. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4697. renderContext;
  4698. }
  4699. if (data.slot) {
  4700. (clone.data || (clone.data = {})).slot = data.slot;
  4701. }
  4702. return clone;
  4703. }
  4704. function mergeProps(to, from) {
  4705. for (const key in from) {
  4706. to[camelize(key)] = from[key];
  4707. }
  4708. }
  4709. function getComponentName(options) {
  4710. return options.name || options.__name || options._componentTag;
  4711. }
  4712. // inline hooks to be invoked on component VNodes during patch
  4713. const componentVNodeHooks = {
  4714. init(vnode, hydrating) {
  4715. if (vnode.componentInstance &&
  4716. !vnode.componentInstance._isDestroyed &&
  4717. vnode.data.keepAlive) {
  4718. // kept-alive components, treat as a patch
  4719. const mountedNode = vnode; // work around flow
  4720. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4721. }
  4722. else {
  4723. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4724. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4725. }
  4726. },
  4727. prepatch(oldVnode, vnode) {
  4728. const options = vnode.componentOptions;
  4729. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4730. updateChildComponent(child, options.propsData, // updated props
  4731. options.listeners, // updated listeners
  4732. vnode, // new parent vnode
  4733. options.children // new children
  4734. );
  4735. },
  4736. insert(vnode) {
  4737. const { context, componentInstance } = vnode;
  4738. if (!componentInstance._isMounted) {
  4739. componentInstance._isMounted = true;
  4740. callHook(componentInstance, 'mounted');
  4741. }
  4742. if (vnode.data.keepAlive) {
  4743. if (context._isMounted) {
  4744. // vue-router#1212
  4745. // During updates, a kept-alive component's child components may
  4746. // change, so directly walking the tree here may call activated hooks
  4747. // on incorrect children. Instead we push them into a queue which will
  4748. // be processed after the whole patch process ended.
  4749. queueActivatedComponent(componentInstance);
  4750. }
  4751. else {
  4752. activateChildComponent(componentInstance, true /* direct */);
  4753. }
  4754. }
  4755. },
  4756. destroy(vnode) {
  4757. const { componentInstance } = vnode;
  4758. if (!componentInstance._isDestroyed) {
  4759. if (!vnode.data.keepAlive) {
  4760. componentInstance.$destroy();
  4761. }
  4762. else {
  4763. deactivateChildComponent(componentInstance, true /* direct */);
  4764. }
  4765. }
  4766. }
  4767. };
  4768. const hooksToMerge = Object.keys(componentVNodeHooks);
  4769. function createComponent(Ctor, data, context, children, tag) {
  4770. if (isUndef(Ctor)) {
  4771. return;
  4772. }
  4773. const baseCtor = context.$options._base;
  4774. // plain options object: turn it into a constructor
  4775. if (isObject$1(Ctor)) {
  4776. Ctor = baseCtor.extend(Ctor);
  4777. }
  4778. // if at this stage it's not a constructor or an async component factory,
  4779. // reject.
  4780. if (typeof Ctor !== 'function') {
  4781. if (process.env.NODE_ENV !== 'production') {
  4782. warn$3(`Invalid Component definition: ${String(Ctor)}`, context);
  4783. }
  4784. return;
  4785. }
  4786. // async component
  4787. let asyncFactory;
  4788. // @ts-expect-error
  4789. if (isUndef(Ctor.cid)) {
  4790. asyncFactory = Ctor;
  4791. Ctor = resolveAsyncComponent(asyncFactory);
  4792. if (Ctor === undefined) {
  4793. // return a placeholder node for async component, which is rendered
  4794. // as a comment node but preserves all the raw information for the node.
  4795. // the information will be used for async server-rendering and hydration.
  4796. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4797. }
  4798. }
  4799. data = data || {};
  4800. // resolve constructor options in case global mixins are applied after
  4801. // component constructor creation
  4802. resolveConstructorOptions(Ctor);
  4803. // transform component v-model data into props & events
  4804. if (isDef(data.model)) {
  4805. // @ts-expect-error
  4806. transformModel(Ctor.options, data);
  4807. }
  4808. // extract props
  4809. // @ts-expect-error
  4810. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4811. // functional component
  4812. // @ts-expect-error
  4813. if (isTrue(Ctor.options.functional)) {
  4814. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4815. }
  4816. // extract listeners, since these needs to be treated as
  4817. // child component listeners instead of DOM listeners
  4818. const listeners = data.on;
  4819. // replace with listeners with .native modifier
  4820. // so it gets processed during parent component patch.
  4821. data.on = data.nativeOn;
  4822. // @ts-expect-error
  4823. if (isTrue(Ctor.options.abstract)) {
  4824. // abstract components do not keep anything
  4825. // other than props & listeners & slot
  4826. // work around flow
  4827. const slot = data.slot;
  4828. data = {};
  4829. if (slot) {
  4830. data.slot = slot;
  4831. }
  4832. }
  4833. // install component management hooks onto the placeholder node
  4834. installComponentHooks(data);
  4835. // return a placeholder vnode
  4836. // @ts-expect-error
  4837. const name = getComponentName(Ctor.options) || tag;
  4838. const vnode = new VNode(
  4839. // @ts-expect-error
  4840. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4841. // @ts-expect-error
  4842. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4843. return vnode;
  4844. }
  4845. function createComponentInstanceForVnode(
  4846. // we know it's MountedComponentVNode but flow doesn't
  4847. vnode,
  4848. // activeInstance in lifecycle state
  4849. parent) {
  4850. const options = {
  4851. _isComponent: true,
  4852. _parentVnode: vnode,
  4853. parent
  4854. };
  4855. // check inline-template render functions
  4856. const inlineTemplate = vnode.data.inlineTemplate;
  4857. if (isDef(inlineTemplate)) {
  4858. options.render = inlineTemplate.render;
  4859. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4860. }
  4861. return new vnode.componentOptions.Ctor(options);
  4862. }
  4863. function installComponentHooks(data) {
  4864. const hooks = data.hook || (data.hook = {});
  4865. for (let i = 0; i < hooksToMerge.length; i++) {
  4866. const key = hooksToMerge[i];
  4867. const existing = hooks[key];
  4868. const toMerge = componentVNodeHooks[key];
  4869. // @ts-expect-error
  4870. if (existing !== toMerge && !(existing && existing._merged)) {
  4871. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4872. }
  4873. }
  4874. }
  4875. function mergeHook(f1, f2) {
  4876. const merged = (a, b) => {
  4877. // flow complains about extra args which is why we use any
  4878. f1(a, b);
  4879. f2(a, b);
  4880. };
  4881. merged._merged = true;
  4882. return merged;
  4883. }
  4884. // transform component v-model info (value and callback) into
  4885. // prop and event handler respectively.
  4886. function transformModel(options, data) {
  4887. const prop = (options.model && options.model.prop) || 'value';
  4888. const event = (options.model && options.model.event) || 'input';
  4889. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4890. const on = data.on || (data.on = {});
  4891. const existing = on[event];
  4892. const callback = data.model.callback;
  4893. if (isDef(existing)) {
  4894. if (isArray(existing)
  4895. ? existing.indexOf(callback) === -1
  4896. : existing !== callback) {
  4897. on[event] = [callback].concat(existing);
  4898. }
  4899. }
  4900. else {
  4901. on[event] = callback;
  4902. }
  4903. }
  4904. let warn$3 = noop;
  4905. let tip = noop;
  4906. let generateComponentTrace; // work around flow check
  4907. let formatComponentName;
  4908. if (process.env.NODE_ENV !== 'production') {
  4909. const hasConsole = typeof console !== 'undefined';
  4910. const classifyRE = /(?:^|[-_])(\w)/g;
  4911. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4912. warn$3 = (msg, vm = currentInstance) => {
  4913. const trace = vm ? generateComponentTrace(vm) : '';
  4914. if (hasConsole && !config.silent) {
  4915. console.error(`[Vue warn]: ${msg}${trace}`);
  4916. }
  4917. };
  4918. tip = (msg, vm) => {
  4919. if (hasConsole && !config.silent) {
  4920. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4921. }
  4922. };
  4923. formatComponentName = (vm, includeFile) => {
  4924. if (vm.$root === vm) {
  4925. return '<Root>';
  4926. }
  4927. const options = isFunction(vm) && vm.cid != null
  4928. ? vm.options
  4929. : vm._isVue
  4930. ? vm.$options || vm.constructor.options
  4931. : vm;
  4932. let name = getComponentName(options);
  4933. const file = options.__file;
  4934. if (!name && file) {
  4935. const match = file.match(/([^/\\]+)\.vue$/);
  4936. name = match && match[1];
  4937. }
  4938. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4939. (file && includeFile !== false ? ` at ${file}` : ''));
  4940. };
  4941. const repeat = (str, n) => {
  4942. let res = '';
  4943. while (n) {
  4944. if (n % 2 === 1)
  4945. res += str;
  4946. if (n > 1)
  4947. str += str;
  4948. n >>= 1;
  4949. }
  4950. return res;
  4951. };
  4952. generateComponentTrace = (vm) => {
  4953. if (vm._isVue && vm.$parent) {
  4954. const tree = [];
  4955. let currentRecursiveSequence = 0;
  4956. while (vm) {
  4957. if (tree.length > 0) {
  4958. const last = tree[tree.length - 1];
  4959. if (last.constructor === vm.constructor) {
  4960. currentRecursiveSequence++;
  4961. vm = vm.$parent;
  4962. continue;
  4963. }
  4964. else if (currentRecursiveSequence > 0) {
  4965. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4966. currentRecursiveSequence = 0;
  4967. }
  4968. }
  4969. tree.push(vm);
  4970. vm = vm.$parent;
  4971. }
  4972. return ('\n\nfound in\n\n' +
  4973. tree
  4974. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4975. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4976. : formatComponentName(vm)}`)
  4977. .join('\n'));
  4978. }
  4979. else {
  4980. return `\n\n(found in ${formatComponentName(vm)})`;
  4981. }
  4982. };
  4983. }
  4984. /**
  4985. * Option overwriting strategies are functions that handle
  4986. * how to merge a parent option value and a child option
  4987. * value into the final value.
  4988. */
  4989. const strats = config.optionMergeStrategies;
  4990. /**
  4991. * Options with restrictions
  4992. */
  4993. if (process.env.NODE_ENV !== 'production') {
  4994. strats.el = strats.propsData = function (parent, child, vm, key) {
  4995. if (!vm) {
  4996. warn$3(`option "${key}" can only be used during instance ` +
  4997. 'creation with the `new` keyword.');
  4998. }
  4999. return defaultStrat(parent, child);
  5000. };
  5001. }
  5002. /**
  5003. * Helper that recursively merges two data objects together.
  5004. */
  5005. function mergeData(to, from) {
  5006. if (!from)
  5007. return to;
  5008. let key, toVal, fromVal;
  5009. const keys = hasSymbol
  5010. ? Reflect.ownKeys(from)
  5011. : Object.keys(from);
  5012. for (let i = 0; i < keys.length; i++) {
  5013. key = keys[i];
  5014. // in case the object is already observed...
  5015. if (key === '__ob__')
  5016. continue;
  5017. toVal = to[key];
  5018. fromVal = from[key];
  5019. if (!hasOwn(to, key)) {
  5020. set(to, key, fromVal);
  5021. }
  5022. else if (toVal !== fromVal &&
  5023. isPlainObject(toVal) &&
  5024. isPlainObject(fromVal)) {
  5025. mergeData(toVal, fromVal);
  5026. }
  5027. }
  5028. return to;
  5029. }
  5030. /**
  5031. * Data
  5032. */
  5033. function mergeDataOrFn(parentVal, childVal, vm) {
  5034. if (!vm) {
  5035. // in a Vue.extend merge, both should be functions
  5036. if (!childVal) {
  5037. return parentVal;
  5038. }
  5039. if (!parentVal) {
  5040. return childVal;
  5041. }
  5042. // when parentVal & childVal are both present,
  5043. // we need to return a function that returns the
  5044. // merged result of both functions... no need to
  5045. // check if parentVal is a function here because
  5046. // it has to be a function to pass previous merges.
  5047. return function mergedDataFn() {
  5048. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5049. };
  5050. }
  5051. else {
  5052. return function mergedInstanceDataFn() {
  5053. // instance merge
  5054. const instanceData = isFunction(childVal)
  5055. ? childVal.call(vm, vm)
  5056. : childVal;
  5057. const defaultData = isFunction(parentVal)
  5058. ? parentVal.call(vm, vm)
  5059. : parentVal;
  5060. if (instanceData) {
  5061. return mergeData(instanceData, defaultData);
  5062. }
  5063. else {
  5064. return defaultData;
  5065. }
  5066. };
  5067. }
  5068. }
  5069. strats.data = function (parentVal, childVal, vm) {
  5070. if (!vm) {
  5071. if (childVal && typeof childVal !== 'function') {
  5072. process.env.NODE_ENV !== 'production' &&
  5073. warn$3('The "data" option should be a function ' +
  5074. 'that returns a per-instance value in component ' +
  5075. 'definitions.', vm);
  5076. return parentVal;
  5077. }
  5078. return mergeDataOrFn(parentVal, childVal);
  5079. }
  5080. return mergeDataOrFn(parentVal, childVal, vm);
  5081. };
  5082. /**
  5083. * Hooks and props are merged as arrays.
  5084. */
  5085. function mergeLifecycleHook(parentVal, childVal) {
  5086. const res = childVal
  5087. ? parentVal
  5088. ? parentVal.concat(childVal)
  5089. : isArray(childVal)
  5090. ? childVal
  5091. : [childVal]
  5092. : parentVal;
  5093. return res ? dedupeHooks(res) : res;
  5094. }
  5095. function dedupeHooks(hooks) {
  5096. const res = [];
  5097. for (let i = 0; i < hooks.length; i++) {
  5098. if (res.indexOf(hooks[i]) === -1) {
  5099. res.push(hooks[i]);
  5100. }
  5101. }
  5102. return res;
  5103. }
  5104. LIFECYCLE_HOOKS.forEach(hook => {
  5105. strats[hook] = mergeLifecycleHook;
  5106. });
  5107. /**
  5108. * Assets
  5109. *
  5110. * When a vm is present (instance creation), we need to do
  5111. * a three-way merge between constructor options, instance
  5112. * options and parent options.
  5113. */
  5114. function mergeAssets(parentVal, childVal, vm, key) {
  5115. const res = Object.create(parentVal || null);
  5116. if (childVal) {
  5117. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  5118. return extend(res, childVal);
  5119. }
  5120. else {
  5121. return res;
  5122. }
  5123. }
  5124. ASSET_TYPES.forEach(function (type) {
  5125. strats[type + 's'] = mergeAssets;
  5126. });
  5127. /**
  5128. * Watchers.
  5129. *
  5130. * Watchers hashes should not overwrite one
  5131. * another, so we merge them as arrays.
  5132. */
  5133. strats.watch = function (parentVal, childVal, vm, key) {
  5134. // work around Firefox's Object.prototype.watch...
  5135. //@ts-expect-error work around
  5136. if (parentVal === nativeWatch)
  5137. parentVal = undefined;
  5138. //@ts-expect-error work around
  5139. if (childVal === nativeWatch)
  5140. childVal = undefined;
  5141. /* istanbul ignore if */
  5142. if (!childVal)
  5143. return Object.create(parentVal || null);
  5144. if (process.env.NODE_ENV !== 'production') {
  5145. assertObjectType(key, childVal, vm);
  5146. }
  5147. if (!parentVal)
  5148. return childVal;
  5149. const ret = {};
  5150. extend(ret, parentVal);
  5151. for (const key in childVal) {
  5152. let parent = ret[key];
  5153. const child = childVal[key];
  5154. if (parent && !isArray(parent)) {
  5155. parent = [parent];
  5156. }
  5157. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5158. }
  5159. return ret;
  5160. };
  5161. /**
  5162. * Other object hashes.
  5163. */
  5164. strats.props =
  5165. strats.methods =
  5166. strats.inject =
  5167. strats.computed =
  5168. function (parentVal, childVal, vm, key) {
  5169. if (childVal && process.env.NODE_ENV !== 'production') {
  5170. assertObjectType(key, childVal, vm);
  5171. }
  5172. if (!parentVal)
  5173. return childVal;
  5174. const ret = Object.create(null);
  5175. extend(ret, parentVal);
  5176. if (childVal)
  5177. extend(ret, childVal);
  5178. return ret;
  5179. };
  5180. strats.provide = mergeDataOrFn;
  5181. /**
  5182. * Default strategy.
  5183. */
  5184. const defaultStrat = function (parentVal, childVal) {
  5185. return childVal === undefined ? parentVal : childVal;
  5186. };
  5187. /**
  5188. * Validate component names
  5189. */
  5190. function checkComponents(options) {
  5191. for (const key in options.components) {
  5192. validateComponentName(key);
  5193. }
  5194. }
  5195. function validateComponentName(name) {
  5196. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5197. warn$3('Invalid component name: "' +
  5198. name +
  5199. '". Component names ' +
  5200. 'should conform to valid custom element name in html5 specification.');
  5201. }
  5202. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5203. warn$3('Do not use built-in or reserved HTML elements as component ' +
  5204. 'id: ' +
  5205. name);
  5206. }
  5207. }
  5208. /**
  5209. * Ensure all props option syntax are normalized into the
  5210. * Object-based format.
  5211. */
  5212. function normalizeProps(options, vm) {
  5213. const props = options.props;
  5214. if (!props)
  5215. return;
  5216. const res = {};
  5217. let i, val, name;
  5218. if (isArray(props)) {
  5219. i = props.length;
  5220. while (i--) {
  5221. val = props[i];
  5222. if (typeof val === 'string') {
  5223. name = camelize(val);
  5224. res[name] = { type: null };
  5225. }
  5226. else if (process.env.NODE_ENV !== 'production') {
  5227. warn$3('props must be strings when using array syntax.');
  5228. }
  5229. }
  5230. }
  5231. else if (isPlainObject(props)) {
  5232. for (const key in props) {
  5233. val = props[key];
  5234. name = camelize(key);
  5235. res[name] = isPlainObject(val) ? val : { type: val };
  5236. }
  5237. }
  5238. else if (process.env.NODE_ENV !== 'production') {
  5239. warn$3(`Invalid value for option "props": expected an Array or an Object, ` +
  5240. `but got ${toRawType(props)}.`, vm);
  5241. }
  5242. options.props = res;
  5243. }
  5244. /**
  5245. * Normalize all injections into Object-based format
  5246. */
  5247. function normalizeInject(options, vm) {
  5248. const inject = options.inject;
  5249. if (!inject)
  5250. return;
  5251. const normalized = (options.inject = {});
  5252. if (isArray(inject)) {
  5253. for (let i = 0; i < inject.length; i++) {
  5254. normalized[inject[i]] = { from: inject[i] };
  5255. }
  5256. }
  5257. else if (isPlainObject(inject)) {
  5258. for (const key in inject) {
  5259. const val = inject[key];
  5260. normalized[key] = isPlainObject(val)
  5261. ? extend({ from: key }, val)
  5262. : { from: val };
  5263. }
  5264. }
  5265. else if (process.env.NODE_ENV !== 'production') {
  5266. warn$3(`Invalid value for option "inject": expected an Array or an Object, ` +
  5267. `but got ${toRawType(inject)}.`, vm);
  5268. }
  5269. }
  5270. /**
  5271. * Normalize raw function directives into object format.
  5272. */
  5273. function normalizeDirectives(options) {
  5274. const dirs = options.directives;
  5275. if (dirs) {
  5276. for (const key in dirs) {
  5277. const def = dirs[key];
  5278. if (isFunction(def)) {
  5279. dirs[key] = { bind: def, update: def };
  5280. }
  5281. }
  5282. }
  5283. }
  5284. function assertObjectType(name, value, vm) {
  5285. if (!isPlainObject(value)) {
  5286. warn$3(`Invalid value for option "${name}": expected an Object, ` +
  5287. `but got ${toRawType(value)}.`, vm);
  5288. }
  5289. }
  5290. /**
  5291. * Merge two option objects into a new one.
  5292. * Core utility used in both instantiation and inheritance.
  5293. */
  5294. function mergeOptions(parent, child, vm) {
  5295. if (process.env.NODE_ENV !== 'production') {
  5296. checkComponents(child);
  5297. }
  5298. if (isFunction(child)) {
  5299. // @ts-expect-error
  5300. child = child.options;
  5301. }
  5302. normalizeProps(child, vm);
  5303. normalizeInject(child, vm);
  5304. normalizeDirectives(child);
  5305. // Apply extends and mixins on the child options,
  5306. // but only if it is a raw options object that isn't
  5307. // the result of another mergeOptions call.
  5308. // Only merged options has the _base property.
  5309. if (!child._base) {
  5310. if (child.extends) {
  5311. parent = mergeOptions(parent, child.extends, vm);
  5312. }
  5313. if (child.mixins) {
  5314. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5315. parent = mergeOptions(parent, child.mixins[i], vm);
  5316. }
  5317. }
  5318. }
  5319. const options = {};
  5320. let key;
  5321. for (key in parent) {
  5322. mergeField(key);
  5323. }
  5324. for (key in child) {
  5325. if (!hasOwn(parent, key)) {
  5326. mergeField(key);
  5327. }
  5328. }
  5329. function mergeField(key) {
  5330. const strat = strats[key] || defaultStrat;
  5331. options[key] = strat(parent[key], child[key], vm, key);
  5332. }
  5333. return options;
  5334. }
  5335. /**
  5336. * Resolve an asset.
  5337. * This function is used because child instances need access
  5338. * to assets defined in its ancestor chain.
  5339. */
  5340. function resolveAsset(options, type, id, warnMissing) {
  5341. /* istanbul ignore if */
  5342. if (typeof id !== 'string') {
  5343. return;
  5344. }
  5345. const assets = options[type];
  5346. // check local registration variations first
  5347. if (hasOwn(assets, id))
  5348. return assets[id];
  5349. const camelizedId = camelize(id);
  5350. if (hasOwn(assets, camelizedId))
  5351. return assets[camelizedId];
  5352. const PascalCaseId = capitalize(camelizedId);
  5353. if (hasOwn(assets, PascalCaseId))
  5354. return assets[PascalCaseId];
  5355. // fallback to prototype chain
  5356. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5357. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  5358. warn$3('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5359. }
  5360. return res;
  5361. }
  5362. function validateProp(key, propOptions, propsData, vm) {
  5363. const prop = propOptions[key];
  5364. const absent = !hasOwn(propsData, key);
  5365. let value = propsData[key];
  5366. // boolean casting
  5367. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5368. if (booleanIndex > -1) {
  5369. if (absent && !hasOwn(prop, 'default')) {
  5370. value = false;
  5371. }
  5372. else if (value === '' || value === hyphenate(key)) {
  5373. // only cast empty string / same name to boolean if
  5374. // boolean has higher priority
  5375. const stringIndex = getTypeIndex(String, prop.type);
  5376. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5377. value = true;
  5378. }
  5379. }
  5380. }
  5381. // check default value
  5382. if (value === undefined) {
  5383. value = getPropDefaultValue(vm, prop, key);
  5384. // since the default value is a fresh copy,
  5385. // make sure to observe it.
  5386. const prevShouldObserve = shouldObserve;
  5387. toggleObserving(true);
  5388. observe(value);
  5389. toggleObserving(prevShouldObserve);
  5390. }
  5391. if (process.env.NODE_ENV !== 'production') {
  5392. assertProp(prop, key, value, vm, absent);
  5393. }
  5394. return value;
  5395. }
  5396. /**
  5397. * Get the default value of a prop.
  5398. */
  5399. function getPropDefaultValue(vm, prop, key) {
  5400. // no default, return undefined
  5401. if (!hasOwn(prop, 'default')) {
  5402. return undefined;
  5403. }
  5404. const def = prop.default;
  5405. // warn against non-factory defaults for Object & Array
  5406. if (process.env.NODE_ENV !== 'production' && isObject$1(def)) {
  5407. warn$3('Invalid default value for prop "' +
  5408. key +
  5409. '": ' +
  5410. 'Props with type Object/Array must use a factory function ' +
  5411. 'to return the default value.', vm);
  5412. }
  5413. // the raw prop value was also undefined from previous render,
  5414. // return previous default value to avoid unnecessary watcher trigger
  5415. if (vm &&
  5416. vm.$options.propsData &&
  5417. vm.$options.propsData[key] === undefined &&
  5418. vm._props[key] !== undefined) {
  5419. return vm._props[key];
  5420. }
  5421. // call factory function for non-Function types
  5422. // a value is Function if its prototype is function even across different execution context
  5423. return isFunction(def) && getType(prop.type) !== 'Function'
  5424. ? def.call(vm)
  5425. : def;
  5426. }
  5427. /**
  5428. * Assert whether a prop is valid.
  5429. */
  5430. function assertProp(prop, name, value, vm, absent) {
  5431. if (prop.required && absent) {
  5432. warn$3('Missing required prop: "' + name + '"', vm);
  5433. return;
  5434. }
  5435. if (value == null && !prop.required) {
  5436. return;
  5437. }
  5438. let type = prop.type;
  5439. let valid = !type || type === true;
  5440. const expectedTypes = [];
  5441. if (type) {
  5442. if (!isArray(type)) {
  5443. type = [type];
  5444. }
  5445. for (let i = 0; i < type.length && !valid; i++) {
  5446. const assertedType = assertType(value, type[i], vm);
  5447. expectedTypes.push(assertedType.expectedType || '');
  5448. valid = assertedType.valid;
  5449. }
  5450. }
  5451. const haveExpectedTypes = expectedTypes.some(t => t);
  5452. if (!valid && haveExpectedTypes) {
  5453. warn$3(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5454. return;
  5455. }
  5456. const validator = prop.validator;
  5457. if (validator) {
  5458. if (!validator(value)) {
  5459. warn$3('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5460. }
  5461. }
  5462. }
  5463. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5464. function assertType(value, type, vm) {
  5465. let valid;
  5466. const expectedType = getType(type);
  5467. if (simpleCheckRE.test(expectedType)) {
  5468. const t = typeof value;
  5469. valid = t === expectedType.toLowerCase();
  5470. // for primitive wrapper objects
  5471. if (!valid && t === 'object') {
  5472. valid = value instanceof type;
  5473. }
  5474. }
  5475. else if (expectedType === 'Object') {
  5476. valid = isPlainObject(value);
  5477. }
  5478. else if (expectedType === 'Array') {
  5479. valid = isArray(value);
  5480. }
  5481. else {
  5482. try {
  5483. valid = value instanceof type;
  5484. }
  5485. catch (e) {
  5486. warn$3('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5487. valid = false;
  5488. }
  5489. }
  5490. return {
  5491. valid,
  5492. expectedType
  5493. };
  5494. }
  5495. const functionTypeCheckRE = /^\s*function (\w+)/;
  5496. /**
  5497. * Use function string name to check built-in types,
  5498. * because a simple equality check will fail when running
  5499. * across different vms / iframes.
  5500. */
  5501. function getType(fn) {
  5502. const match = fn && fn.toString().match(functionTypeCheckRE);
  5503. return match ? match[1] : '';
  5504. }
  5505. function isSameType(a, b) {
  5506. return getType(a) === getType(b);
  5507. }
  5508. function getTypeIndex(type, expectedTypes) {
  5509. if (!isArray(expectedTypes)) {
  5510. return isSameType(expectedTypes, type) ? 0 : -1;
  5511. }
  5512. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5513. if (isSameType(expectedTypes[i], type)) {
  5514. return i;
  5515. }
  5516. }
  5517. return -1;
  5518. }
  5519. function getInvalidTypeMessage(name, value, expectedTypes) {
  5520. let message = `Invalid prop: type check failed for prop "${name}".` +
  5521. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5522. const expectedType = expectedTypes[0];
  5523. const receivedType = toRawType(value);
  5524. // check if we need to specify expected value
  5525. if (expectedTypes.length === 1 &&
  5526. isExplicable(expectedType) &&
  5527. isExplicable(typeof value) &&
  5528. !isBoolean(expectedType, receivedType)) {
  5529. message += ` with value ${styleValue(value, expectedType)}`;
  5530. }
  5531. message += `, got ${receivedType} `;
  5532. // check if we need to specify received value
  5533. if (isExplicable(receivedType)) {
  5534. message += `with value ${styleValue(value, receivedType)}.`;
  5535. }
  5536. return message;
  5537. }
  5538. function styleValue(value, type) {
  5539. if (type === 'String') {
  5540. return `"${value}"`;
  5541. }
  5542. else if (type === 'Number') {
  5543. return `${Number(value)}`;
  5544. }
  5545. else {
  5546. return `${value}`;
  5547. }
  5548. }
  5549. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5550. function isExplicable(value) {
  5551. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5552. }
  5553. function isBoolean(...args) {
  5554. return args.some(elem => elem.toLowerCase() === 'boolean');
  5555. }
  5556. // these are reserved for web because they are directly compiled away
  5557. // during template compilation
  5558. makeMap('style,class');
  5559. // attributes that should be using props for binding
  5560. const acceptValue = makeMap('input,textarea,option,select,progress');
  5561. const mustUseProp = (tag, type, attr) => {
  5562. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5563. (attr === 'selected' && tag === 'option') ||
  5564. (attr === 'checked' && tag === 'input') ||
  5565. (attr === 'muted' && tag === 'video'));
  5566. };
  5567. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5568. makeMap('events,caret,typing,plaintext-only');
  5569. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5570. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5571. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5572. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5573. 'required,reversed,scoped,seamless,selected,sortable,' +
  5574. 'truespeed,typemustmatch,visible');
  5575. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  5576. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5577. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5578. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5579. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5580. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5581. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5582. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5583. 'output,progress,select,textarea,' +
  5584. 'details,dialog,menu,menuitem,summary,' +
  5585. 'content,element,shadow,template,blockquote,iframe,tfoot');
  5586. // this map is intentionally selective, only covering SVG elements that may
  5587. // contain child elements.
  5588. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5589. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5590. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  5591. const isPreTag = (tag) => tag === 'pre';
  5592. const isReservedTag = (tag) => {
  5593. return isHTMLTag(tag) || isSVG(tag);
  5594. };
  5595. function getTagNamespace(tag) {
  5596. if (isSVG(tag)) {
  5597. return 'svg';
  5598. }
  5599. // basic support for MathML
  5600. // note it doesn't support other MathML elements being component roots
  5601. if (tag === 'math') {
  5602. return 'math';
  5603. }
  5604. }
  5605. makeMap('text,number,password,search,email,tel,url');
  5606. const validDivisionCharRE = /[\w).+\-_$\]]/;
  5607. function parseFilters(exp) {
  5608. let inSingle = false;
  5609. let inDouble = false;
  5610. let inTemplateString = false;
  5611. let inRegex = false;
  5612. let curly = 0;
  5613. let square = 0;
  5614. let paren = 0;
  5615. let lastFilterIndex = 0;
  5616. let c, prev, i, expression, filters;
  5617. for (i = 0; i < exp.length; i++) {
  5618. prev = c;
  5619. c = exp.charCodeAt(i);
  5620. if (inSingle) {
  5621. if (c === 0x27 && prev !== 0x5c)
  5622. inSingle = false;
  5623. }
  5624. else if (inDouble) {
  5625. if (c === 0x22 && prev !== 0x5c)
  5626. inDouble = false;
  5627. }
  5628. else if (inTemplateString) {
  5629. if (c === 0x60 && prev !== 0x5c)
  5630. inTemplateString = false;
  5631. }
  5632. else if (inRegex) {
  5633. if (c === 0x2f && prev !== 0x5c)
  5634. inRegex = false;
  5635. }
  5636. else if (c === 0x7c && // pipe
  5637. exp.charCodeAt(i + 1) !== 0x7c &&
  5638. exp.charCodeAt(i - 1) !== 0x7c &&
  5639. !curly &&
  5640. !square &&
  5641. !paren) {
  5642. if (expression === undefined) {
  5643. // first filter, end of expression
  5644. lastFilterIndex = i + 1;
  5645. expression = exp.slice(0, i).trim();
  5646. }
  5647. else {
  5648. pushFilter();
  5649. }
  5650. }
  5651. else {
  5652. switch (c) {
  5653. case 0x22:
  5654. inDouble = true;
  5655. break; // "
  5656. case 0x27:
  5657. inSingle = true;
  5658. break; // '
  5659. case 0x60:
  5660. inTemplateString = true;
  5661. break; // `
  5662. case 0x28:
  5663. paren++;
  5664. break; // (
  5665. case 0x29:
  5666. paren--;
  5667. break; // )
  5668. case 0x5b:
  5669. square++;
  5670. break; // [
  5671. case 0x5d:
  5672. square--;
  5673. break; // ]
  5674. case 0x7b:
  5675. curly++;
  5676. break; // {
  5677. case 0x7d:
  5678. curly--;
  5679. break; // }
  5680. }
  5681. if (c === 0x2f) {
  5682. // /
  5683. let j = i - 1;
  5684. let p;
  5685. // find first non-whitespace prev char
  5686. for (; j >= 0; j--) {
  5687. p = exp.charAt(j);
  5688. if (p !== ' ')
  5689. break;
  5690. }
  5691. if (!p || !validDivisionCharRE.test(p)) {
  5692. inRegex = true;
  5693. }
  5694. }
  5695. }
  5696. }
  5697. if (expression === undefined) {
  5698. expression = exp.slice(0, i).trim();
  5699. }
  5700. else if (lastFilterIndex !== 0) {
  5701. pushFilter();
  5702. }
  5703. function pushFilter() {
  5704. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  5705. lastFilterIndex = i + 1;
  5706. }
  5707. if (filters) {
  5708. for (i = 0; i < filters.length; i++) {
  5709. expression = wrapFilter(expression, filters[i]);
  5710. }
  5711. }
  5712. return expression;
  5713. }
  5714. function wrapFilter(exp, filter) {
  5715. const i = filter.indexOf('(');
  5716. if (i < 0) {
  5717. // _f: resolveFilter
  5718. return `_f("${filter}")(${exp})`;
  5719. }
  5720. else {
  5721. const name = filter.slice(0, i);
  5722. const args = filter.slice(i + 1);
  5723. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  5724. }
  5725. }
  5726. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  5727. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  5728. const buildRegex = cached(delimiters => {
  5729. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  5730. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  5731. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  5732. });
  5733. function parseText(text, delimiters) {
  5734. //@ts-expect-error
  5735. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  5736. if (!tagRE.test(text)) {
  5737. return;
  5738. }
  5739. const tokens = [];
  5740. const rawTokens = [];
  5741. let lastIndex = (tagRE.lastIndex = 0);
  5742. let match, index, tokenValue;
  5743. while ((match = tagRE.exec(text))) {
  5744. index = match.index;
  5745. // push text token
  5746. if (index > lastIndex) {
  5747. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  5748. tokens.push(JSON.stringify(tokenValue));
  5749. }
  5750. // tag token
  5751. const exp = parseFilters(match[1].trim());
  5752. tokens.push(`_s(${exp})`);
  5753. rawTokens.push({ '@binding': exp });
  5754. lastIndex = index + match[0].length;
  5755. }
  5756. if (lastIndex < text.length) {
  5757. rawTokens.push((tokenValue = text.slice(lastIndex)));
  5758. tokens.push(JSON.stringify(tokenValue));
  5759. }
  5760. return {
  5761. expression: tokens.join('+'),
  5762. tokens: rawTokens
  5763. };
  5764. }
  5765. /* eslint-disable no-unused-vars */
  5766. function baseWarn(msg, range) {
  5767. console.error(`[Vue compiler]: ${msg}`);
  5768. }
  5769. /* eslint-enable no-unused-vars */
  5770. function pluckModuleFunction(modules, key) {
  5771. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  5772. }
  5773. function addProp(el, name, value, range, dynamic) {
  5774. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  5775. el.plain = false;
  5776. }
  5777. function addAttr(el, name, value, range, dynamic) {
  5778. const attrs = dynamic
  5779. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  5780. : el.attrs || (el.attrs = []);
  5781. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  5782. el.plain = false;
  5783. }
  5784. // add a raw attr (use this in preTransforms)
  5785. function addRawAttr(el, name, value, range) {
  5786. el.attrsMap[name] = value;
  5787. el.attrsList.push(rangeSetItem({ name, value }, range));
  5788. }
  5789. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  5790. (el.directives || (el.directives = [])).push(rangeSetItem({
  5791. name,
  5792. rawName,
  5793. value,
  5794. arg,
  5795. isDynamicArg,
  5796. modifiers
  5797. }, range));
  5798. el.plain = false;
  5799. }
  5800. function prependModifierMarker(symbol, name, dynamic) {
  5801. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  5802. }
  5803. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  5804. modifiers = modifiers || emptyObject;
  5805. // warn prevent and passive modifier
  5806. /* istanbul ignore if */
  5807. if (process.env.NODE_ENV !== 'production' && warn && modifiers.prevent && modifiers.passive) {
  5808. warn("passive and prevent can't be used together. " +
  5809. "Passive handler can't prevent default event.", range);
  5810. }
  5811. // normalize click.right and click.middle since they don't actually fire
  5812. // this is technically browser-specific, but at least for now browsers are
  5813. // the only target envs that have right/middle clicks.
  5814. if (modifiers.right) {
  5815. if (dynamic) {
  5816. name = `(${name})==='click'?'contextmenu':(${name})`;
  5817. }
  5818. else if (name === 'click') {
  5819. name = 'contextmenu';
  5820. delete modifiers.right;
  5821. }
  5822. }
  5823. else if (modifiers.middle) {
  5824. if (dynamic) {
  5825. name = `(${name})==='click'?'mouseup':(${name})`;
  5826. }
  5827. else if (name === 'click') {
  5828. name = 'mouseup';
  5829. }
  5830. }
  5831. // check capture modifier
  5832. if (modifiers.capture) {
  5833. delete modifiers.capture;
  5834. name = prependModifierMarker('!', name, dynamic);
  5835. }
  5836. if (modifiers.once) {
  5837. delete modifiers.once;
  5838. name = prependModifierMarker('~', name, dynamic);
  5839. }
  5840. /* istanbul ignore if */
  5841. if (modifiers.passive) {
  5842. delete modifiers.passive;
  5843. name = prependModifierMarker('&', name, dynamic);
  5844. }
  5845. let events;
  5846. if (modifiers.native) {
  5847. delete modifiers.native;
  5848. events = el.nativeEvents || (el.nativeEvents = {});
  5849. }
  5850. else {
  5851. events = el.events || (el.events = {});
  5852. }
  5853. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  5854. if (modifiers !== emptyObject) {
  5855. newHandler.modifiers = modifiers;
  5856. }
  5857. const handlers = events[name];
  5858. /* istanbul ignore if */
  5859. if (Array.isArray(handlers)) {
  5860. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  5861. }
  5862. else if (handlers) {
  5863. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  5864. }
  5865. else {
  5866. events[name] = newHandler;
  5867. }
  5868. el.plain = false;
  5869. }
  5870. function getRawBindingAttr(el, name) {
  5871. return (el.rawAttrsMap[':' + name] ||
  5872. el.rawAttrsMap['v-bind:' + name] ||
  5873. el.rawAttrsMap[name]);
  5874. }
  5875. function getBindingAttr(el, name, getStatic) {
  5876. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  5877. if (dynamicValue != null) {
  5878. return parseFilters(dynamicValue);
  5879. }
  5880. else if (getStatic !== false) {
  5881. const staticValue = getAndRemoveAttr(el, name);
  5882. if (staticValue != null) {
  5883. return JSON.stringify(staticValue);
  5884. }
  5885. }
  5886. }
  5887. // note: this only removes the attr from the Array (attrsList) so that it
  5888. // doesn't get processed by processAttrs.
  5889. // By default it does NOT remove it from the map (attrsMap) because the map is
  5890. // needed during codegen.
  5891. function getAndRemoveAttr(el, name, removeFromMap) {
  5892. let val;
  5893. if ((val = el.attrsMap[name]) != null) {
  5894. const list = el.attrsList;
  5895. for (let i = 0, l = list.length; i < l; i++) {
  5896. if (list[i].name === name) {
  5897. list.splice(i, 1);
  5898. break;
  5899. }
  5900. }
  5901. }
  5902. if (removeFromMap) {
  5903. delete el.attrsMap[name];
  5904. }
  5905. return val;
  5906. }
  5907. function getAndRemoveAttrByRegex(el, name) {
  5908. const list = el.attrsList;
  5909. for (let i = 0, l = list.length; i < l; i++) {
  5910. const attr = list[i];
  5911. if (name.test(attr.name)) {
  5912. list.splice(i, 1);
  5913. return attr;
  5914. }
  5915. }
  5916. }
  5917. function rangeSetItem(item, range) {
  5918. if (range) {
  5919. if (range.start != null) {
  5920. item.start = range.start;
  5921. }
  5922. if (range.end != null) {
  5923. item.end = range.end;
  5924. }
  5925. }
  5926. return item;
  5927. }
  5928. function transformNode$1(el, options) {
  5929. const warn = options.warn || baseWarn;
  5930. const staticClass = getAndRemoveAttr(el, 'class');
  5931. if (process.env.NODE_ENV !== 'production' && staticClass) {
  5932. const res = parseText(staticClass, options.delimiters);
  5933. if (res) {
  5934. warn(`class="${staticClass}": ` +
  5935. 'Interpolation inside attributes has been removed. ' +
  5936. 'Use v-bind or the colon shorthand instead. For example, ' +
  5937. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  5938. }
  5939. }
  5940. if (staticClass) {
  5941. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  5942. }
  5943. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  5944. if (classBinding) {
  5945. el.classBinding = classBinding;
  5946. }
  5947. }
  5948. function genData$2(el) {
  5949. let data = '';
  5950. if (el.staticClass) {
  5951. data += `staticClass:${el.staticClass},`;
  5952. }
  5953. if (el.classBinding) {
  5954. data += `class:${el.classBinding},`;
  5955. }
  5956. return data;
  5957. }
  5958. var klass = {
  5959. staticKeys: ['staticClass'],
  5960. transformNode: transformNode$1,
  5961. genData: genData$2
  5962. };
  5963. const parseStyleText = cached(function (cssText) {
  5964. const res = {};
  5965. const listDelimiter = /;(?![^(]*\))/g;
  5966. const propertyDelimiter = /:(.+)/;
  5967. cssText.split(listDelimiter).forEach(function (item) {
  5968. if (item) {
  5969. const tmp = item.split(propertyDelimiter);
  5970. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  5971. }
  5972. });
  5973. return res;
  5974. });
  5975. function transformNode(el, options) {
  5976. const warn = options.warn || baseWarn;
  5977. const staticStyle = getAndRemoveAttr(el, 'style');
  5978. if (staticStyle) {
  5979. /* istanbul ignore if */
  5980. if (process.env.NODE_ENV !== 'production') {
  5981. const res = parseText(staticStyle, options.delimiters);
  5982. if (res) {
  5983. warn(`style="${staticStyle}": ` +
  5984. 'Interpolation inside attributes has been removed. ' +
  5985. 'Use v-bind or the colon shorthand instead. For example, ' +
  5986. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  5987. }
  5988. }
  5989. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  5990. }
  5991. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  5992. if (styleBinding) {
  5993. el.styleBinding = styleBinding;
  5994. }
  5995. }
  5996. function genData$1(el) {
  5997. let data = '';
  5998. if (el.staticStyle) {
  5999. data += `staticStyle:${el.staticStyle},`;
  6000. }
  6001. if (el.styleBinding) {
  6002. data += `style:(${el.styleBinding}),`;
  6003. }
  6004. return data;
  6005. }
  6006. var style = {
  6007. staticKeys: ['staticStyle'],
  6008. transformNode,
  6009. genData: genData$1
  6010. };
  6011. var he$1 = {exports: {}};
  6012. /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
  6013. (function (module, exports) {
  6014. (function(root) {
  6015. // Detect free variables `exports`.
  6016. var freeExports = exports;
  6017. // Detect free variable `module`.
  6018. var freeModule = module &&
  6019. module.exports == freeExports && module;
  6020. // Detect free variable `global`, from Node.js or Browserified code,
  6021. // and use it as `root`.
  6022. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
  6023. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  6024. root = freeGlobal;
  6025. }
  6026. /*--------------------------------------------------------------------------*/
  6027. // All astral symbols.
  6028. var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  6029. // All ASCII symbols (not just printable ASCII) except those listed in the
  6030. // first column of the overrides table.
  6031. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
  6032. var regexAsciiWhitelist = /[\x01-\x7F]/g;
  6033. // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
  6034. // code points listed in the first column of the overrides table on
  6035. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
  6036. var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
  6037. 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;
  6038. 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'};
  6039. var regexEscape = /["&'<>`]/g;
  6040. var escapeMap = {
  6041. '"': '&quot;',
  6042. '&': '&amp;',
  6043. '\'': '&#x27;',
  6044. '<': '&lt;',
  6045. // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
  6046. // following is not strictly necessary unless it’s part of a tag or an
  6047. // unquoted attribute value. We’re only escaping it to support those
  6048. // situations, and for XML support.
  6049. '>': '&gt;',
  6050. // In Internet Explorer ≤ 8, the backtick character can be used
  6051. // to break out of (un)quoted attribute values or HTML comments.
  6052. // See http://html5sec.org/#102, http://html5sec.org/#108, and
  6053. // http://html5sec.org/#133.
  6054. '`': '&#x60;'
  6055. };
  6056. var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
  6057. 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]/;
  6058. 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;
  6059. 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'};
  6060. 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'};
  6061. 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'};
  6062. 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];
  6063. /*--------------------------------------------------------------------------*/
  6064. var stringFromCharCode = String.fromCharCode;
  6065. var object = {};
  6066. var hasOwnProperty = object.hasOwnProperty;
  6067. var has = function(object, propertyName) {
  6068. return hasOwnProperty.call(object, propertyName);
  6069. };
  6070. var contains = function(array, value) {
  6071. var index = -1;
  6072. var length = array.length;
  6073. while (++index < length) {
  6074. if (array[index] == value) {
  6075. return true;
  6076. }
  6077. }
  6078. return false;
  6079. };
  6080. var merge = function(options, defaults) {
  6081. if (!options) {
  6082. return defaults;
  6083. }
  6084. var result = {};
  6085. var key;
  6086. for (key in defaults) {
  6087. // A `hasOwnProperty` check is not needed here, since only recognized
  6088. // option names are used anyway. Any others are ignored.
  6089. result[key] = has(options, key) ? options[key] : defaults[key];
  6090. }
  6091. return result;
  6092. };
  6093. // Modified version of `ucs2encode`; see https://mths.be/punycode.
  6094. var codePointToSymbol = function(codePoint, strict) {
  6095. var output = '';
  6096. if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
  6097. // See issue #4:
  6098. // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
  6099. // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
  6100. // REPLACEMENT CHARACTER.”
  6101. if (strict) {
  6102. parseError('character reference outside the permissible Unicode range');
  6103. }
  6104. return '\uFFFD';
  6105. }
  6106. if (has(decodeMapNumeric, codePoint)) {
  6107. if (strict) {
  6108. parseError('disallowed character reference');
  6109. }
  6110. return decodeMapNumeric[codePoint];
  6111. }
  6112. if (strict && contains(invalidReferenceCodePoints, codePoint)) {
  6113. parseError('disallowed character reference');
  6114. }
  6115. if (codePoint > 0xFFFF) {
  6116. codePoint -= 0x10000;
  6117. output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
  6118. codePoint = 0xDC00 | codePoint & 0x3FF;
  6119. }
  6120. output += stringFromCharCode(codePoint);
  6121. return output;
  6122. };
  6123. var hexEscape = function(codePoint) {
  6124. return '&#x' + codePoint.toString(16).toUpperCase() + ';';
  6125. };
  6126. var decEscape = function(codePoint) {
  6127. return '&#' + codePoint + ';';
  6128. };
  6129. var parseError = function(message) {
  6130. throw Error('Parse error: ' + message);
  6131. };
  6132. /*--------------------------------------------------------------------------*/
  6133. var encode = function(string, options) {
  6134. options = merge(options, encode.options);
  6135. var strict = options.strict;
  6136. if (strict && regexInvalidRawCodePoint.test(string)) {
  6137. parseError('forbidden code point');
  6138. }
  6139. var encodeEverything = options.encodeEverything;
  6140. var useNamedReferences = options.useNamedReferences;
  6141. var allowUnsafeSymbols = options.allowUnsafeSymbols;
  6142. var escapeCodePoint = options.decimal ? decEscape : hexEscape;
  6143. var escapeBmpSymbol = function(symbol) {
  6144. return escapeCodePoint(symbol.charCodeAt(0));
  6145. };
  6146. if (encodeEverything) {
  6147. // Encode ASCII symbols.
  6148. string = string.replace(regexAsciiWhitelist, function(symbol) {
  6149. // Use named references if requested & possible.
  6150. if (useNamedReferences && has(encodeMap, symbol)) {
  6151. return '&' + encodeMap[symbol] + ';';
  6152. }
  6153. return escapeBmpSymbol(symbol);
  6154. });
  6155. // Shorten a few escapes that represent two symbols, of which at least one
  6156. // is within the ASCII range.
  6157. if (useNamedReferences) {
  6158. string = string
  6159. .replace(/&gt;\u20D2/g, '&nvgt;')
  6160. .replace(/&lt;\u20D2/g, '&nvlt;')
  6161. .replace(/&#x66;&#x6A;/g, '&fjlig;');
  6162. }
  6163. // Encode non-ASCII symbols.
  6164. if (useNamedReferences) {
  6165. // Encode non-ASCII symbols that can be replaced with a named reference.
  6166. string = string.replace(regexEncodeNonAscii, function(string) {
  6167. // Note: there is no need to check `has(encodeMap, string)` here.
  6168. return '&' + encodeMap[string] + ';';
  6169. });
  6170. }
  6171. // Note: any remaining non-ASCII symbols are handled outside of the `if`.
  6172. } else if (useNamedReferences) {
  6173. // Apply named character references.
  6174. // Encode `<>"'&` using named character references.
  6175. if (!allowUnsafeSymbols) {
  6176. string = string.replace(regexEscape, function(string) {
  6177. return '&' + encodeMap[string] + ';'; // no need to check `has()` here
  6178. });
  6179. }
  6180. // Shorten escapes that represent two symbols, of which at least one is
  6181. // `<>"'&`.
  6182. string = string
  6183. .replace(/&gt;\u20D2/g, '&nvgt;')
  6184. .replace(/&lt;\u20D2/g, '&nvlt;');
  6185. // Encode non-ASCII symbols that can be replaced with a named reference.
  6186. string = string.replace(regexEncodeNonAscii, function(string) {
  6187. // Note: there is no need to check `has(encodeMap, string)` here.
  6188. return '&' + encodeMap[string] + ';';
  6189. });
  6190. } else if (!allowUnsafeSymbols) {
  6191. // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
  6192. // using named character references.
  6193. string = string.replace(regexEscape, escapeBmpSymbol);
  6194. }
  6195. return string
  6196. // Encode astral symbols.
  6197. .replace(regexAstralSymbols, function($0) {
  6198. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  6199. var high = $0.charCodeAt(0);
  6200. var low = $0.charCodeAt(1);
  6201. var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
  6202. return escapeCodePoint(codePoint);
  6203. })
  6204. // Encode any remaining BMP symbols that are not printable ASCII symbols
  6205. // using a hexadecimal escape.
  6206. .replace(regexBmpWhitelist, escapeBmpSymbol);
  6207. };
  6208. // Expose default options (so they can be overridden globally).
  6209. encode.options = {
  6210. 'allowUnsafeSymbols': false,
  6211. 'encodeEverything': false,
  6212. 'strict': false,
  6213. 'useNamedReferences': false,
  6214. 'decimal' : false
  6215. };
  6216. var decode = function(html, options) {
  6217. options = merge(options, decode.options);
  6218. var strict = options.strict;
  6219. if (strict && regexInvalidEntity.test(html)) {
  6220. parseError('malformed character reference');
  6221. }
  6222. return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
  6223. var codePoint;
  6224. var semicolon;
  6225. var decDigits;
  6226. var hexDigits;
  6227. var reference;
  6228. var next;
  6229. if ($1) {
  6230. reference = $1;
  6231. // Note: there is no need to check `has(decodeMap, reference)`.
  6232. return decodeMap[reference];
  6233. }
  6234. if ($2) {
  6235. // Decode named character references without trailing `;`, e.g. `&amp`.
  6236. // This is only a parse error if it gets converted to `&`, or if it is
  6237. // followed by `=` in an attribute context.
  6238. reference = $2;
  6239. next = $3;
  6240. if (next && options.isAttributeValue) {
  6241. if (strict && next == '=') {
  6242. parseError('`&` did not start a character reference');
  6243. }
  6244. return $0;
  6245. } else {
  6246. if (strict) {
  6247. parseError(
  6248. 'named character reference was not terminated by a semicolon'
  6249. );
  6250. }
  6251. // Note: there is no need to check `has(decodeMapLegacy, reference)`.
  6252. return decodeMapLegacy[reference] + (next || '');
  6253. }
  6254. }
  6255. if ($4) {
  6256. // Decode decimal escapes, e.g. `&#119558;`.
  6257. decDigits = $4;
  6258. semicolon = $5;
  6259. if (strict && !semicolon) {
  6260. parseError('character reference was not terminated by a semicolon');
  6261. }
  6262. codePoint = parseInt(decDigits, 10);
  6263. return codePointToSymbol(codePoint, strict);
  6264. }
  6265. if ($6) {
  6266. // Decode hexadecimal escapes, e.g. `&#x1D306;`.
  6267. hexDigits = $6;
  6268. semicolon = $7;
  6269. if (strict && !semicolon) {
  6270. parseError('character reference was not terminated by a semicolon');
  6271. }
  6272. codePoint = parseInt(hexDigits, 16);
  6273. return codePointToSymbol(codePoint, strict);
  6274. }
  6275. // If we’re still here, `if ($7)` is implied; it’s an ambiguous
  6276. // ampersand for sure. https://mths.be/notes/ambiguous-ampersands
  6277. if (strict) {
  6278. parseError(
  6279. 'named character reference was not terminated by a semicolon'
  6280. );
  6281. }
  6282. return $0;
  6283. });
  6284. };
  6285. // Expose default options (so they can be overridden globally).
  6286. decode.options = {
  6287. 'isAttributeValue': false,
  6288. 'strict': false
  6289. };
  6290. var escape = function(string) {
  6291. return string.replace(regexEscape, function($0) {
  6292. // Note: there is no need to check `has(escapeMap, $0)` here.
  6293. return escapeMap[$0];
  6294. });
  6295. };
  6296. /*--------------------------------------------------------------------------*/
  6297. var he = {
  6298. 'version': '1.2.0',
  6299. 'encode': encode,
  6300. 'decode': decode,
  6301. 'escape': escape,
  6302. 'unescape': decode
  6303. };
  6304. // Some AMD build optimizers, like r.js, check for specific condition patterns
  6305. // like the following:
  6306. if (freeExports && !freeExports.nodeType) {
  6307. if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
  6308. freeModule.exports = he;
  6309. } else { // in Narwhal or RingoJS v0.7.0-
  6310. for (var key in he) {
  6311. has(he, key) && (freeExports[key] = he[key]);
  6312. }
  6313. }
  6314. } else { // in Rhino or a web browser
  6315. root.he = he;
  6316. }
  6317. }(commonjsGlobal));
  6318. } (he$1, he$1.exports));
  6319. var he = he$1.exports;
  6320. /**
  6321. * Cross-platform code generation for component v-model
  6322. */
  6323. function genComponentModel(el, value, modifiers) {
  6324. const { number, trim } = modifiers || {};
  6325. const baseValueExpression = '$$v';
  6326. let valueExpression = baseValueExpression;
  6327. if (trim) {
  6328. valueExpression =
  6329. `(typeof ${baseValueExpression} === 'string'` +
  6330. `? ${baseValueExpression}.trim()` +
  6331. `: ${baseValueExpression})`;
  6332. }
  6333. if (number) {
  6334. valueExpression = `_n(${valueExpression})`;
  6335. }
  6336. const assignment = genAssignmentCode(value, valueExpression);
  6337. el.model = {
  6338. value: `(${value})`,
  6339. expression: JSON.stringify(value),
  6340. callback: `function (${baseValueExpression}) {${assignment}}`
  6341. };
  6342. }
  6343. /**
  6344. * Cross-platform codegen helper for generating v-model value assignment code.
  6345. */
  6346. function genAssignmentCode(value, assignment) {
  6347. const res = parseModel(value);
  6348. if (res.key === null) {
  6349. return `${value}=${assignment}`;
  6350. }
  6351. else {
  6352. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  6353. }
  6354. }
  6355. /**
  6356. * Parse a v-model expression into a base path and a final key segment.
  6357. * Handles both dot-path and possible square brackets.
  6358. *
  6359. * Possible cases:
  6360. *
  6361. * - test
  6362. * - test[key]
  6363. * - test[test1[key]]
  6364. * - test["a"][key]
  6365. * - xxx.test[a[a].test1[key]]
  6366. * - test.xxx.a["asa"][test1[key]]
  6367. *
  6368. */
  6369. let len, str$1, chr, index, expressionPos, expressionEndPos;
  6370. function parseModel(val) {
  6371. // Fix https://github.com/vuejs/vue/pull/7730
  6372. // allow v-model="obj.val " (trailing whitespace)
  6373. val = val.trim();
  6374. len = val.length;
  6375. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6376. index = val.lastIndexOf('.');
  6377. if (index > -1) {
  6378. return {
  6379. exp: val.slice(0, index),
  6380. key: '"' + val.slice(index + 1) + '"'
  6381. };
  6382. }
  6383. else {
  6384. return {
  6385. exp: val,
  6386. key: null
  6387. };
  6388. }
  6389. }
  6390. str$1 = val;
  6391. index = expressionPos = expressionEndPos = 0;
  6392. while (!eof()) {
  6393. chr = next();
  6394. /* istanbul ignore if */
  6395. if (isStringStart(chr)) {
  6396. parseString(chr);
  6397. }
  6398. else if (chr === 0x5b) {
  6399. parseBracket(chr);
  6400. }
  6401. }
  6402. return {
  6403. exp: val.slice(0, expressionPos),
  6404. key: val.slice(expressionPos + 1, expressionEndPos)
  6405. };
  6406. }
  6407. function next() {
  6408. return str$1.charCodeAt(++index);
  6409. }
  6410. function eof() {
  6411. return index >= len;
  6412. }
  6413. function isStringStart(chr) {
  6414. return chr === 0x22 || chr === 0x27;
  6415. }
  6416. function parseBracket(chr) {
  6417. let inBracket = 1;
  6418. expressionPos = index;
  6419. while (!eof()) {
  6420. chr = next();
  6421. if (isStringStart(chr)) {
  6422. parseString(chr);
  6423. continue;
  6424. }
  6425. if (chr === 0x5b)
  6426. inBracket++;
  6427. if (chr === 0x5d)
  6428. inBracket--;
  6429. if (inBracket === 0) {
  6430. expressionEndPos = index;
  6431. break;
  6432. }
  6433. }
  6434. }
  6435. function parseString(chr) {
  6436. const stringQuote = chr;
  6437. while (!eof()) {
  6438. chr = next();
  6439. if (chr === stringQuote) {
  6440. break;
  6441. }
  6442. }
  6443. }
  6444. const onRE = /^@|^v-on:/;
  6445. const dirRE = /^v-|^@|^:|^#/;
  6446. const forAliasRE$1 = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  6447. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  6448. const stripParensRE = /^\(|\)$/g;
  6449. const dynamicArgRE = /^\[.*\]$/;
  6450. const argRE = /:(.*)$/;
  6451. const bindRE = /^:|^\.|^v-bind:/;
  6452. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  6453. const slotRE = /^v-slot(:|$)|^#/;
  6454. const lineBreakRE = /[\r\n]/;
  6455. const whitespaceRE = /[ \f\t\r\n]+/g;
  6456. const invalidAttributeRE = /[\s"'<>\/=]/;
  6457. const decodeHTMLCached = cached(he.decode);
  6458. const emptySlotScopeToken = `_empty_`;
  6459. // configurable state
  6460. let warn$2;
  6461. let delimiters;
  6462. let transforms;
  6463. let preTransforms;
  6464. let postTransforms;
  6465. let platformIsPreTag;
  6466. let platformMustUseProp;
  6467. let platformGetTagNamespace;
  6468. let maybeComponent;
  6469. function createASTElement(tag, attrs, parent) {
  6470. return {
  6471. type: 1,
  6472. tag,
  6473. attrsList: attrs,
  6474. attrsMap: makeAttrsMap(attrs),
  6475. rawAttrsMap: {},
  6476. parent,
  6477. children: []
  6478. };
  6479. }
  6480. /**
  6481. * Convert HTML string to AST.
  6482. */
  6483. function parse$1(template, options) {
  6484. warn$2 = options.warn || baseWarn;
  6485. platformIsPreTag = options.isPreTag || no;
  6486. platformMustUseProp = options.mustUseProp || no;
  6487. platformGetTagNamespace = options.getTagNamespace || no;
  6488. const isReservedTag = options.isReservedTag || no;
  6489. maybeComponent = (el) => !!(el.component ||
  6490. el.attrsMap[':is'] ||
  6491. el.attrsMap['v-bind:is'] ||
  6492. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  6493. transforms = pluckModuleFunction(options.modules, 'transformNode');
  6494. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  6495. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  6496. delimiters = options.delimiters;
  6497. const stack = [];
  6498. const preserveWhitespace = options.preserveWhitespace !== false;
  6499. const whitespaceOption = options.whitespace;
  6500. let root;
  6501. let currentParent;
  6502. let inVPre = false;
  6503. let inPre = false;
  6504. let warned = false;
  6505. function warnOnce(msg, range) {
  6506. if (!warned) {
  6507. warned = true;
  6508. warn$2(msg, range);
  6509. }
  6510. }
  6511. function closeElement(element) {
  6512. trimEndingWhitespace(element);
  6513. if (!inVPre && !element.processed) {
  6514. element = processElement(element, options);
  6515. }
  6516. // tree management
  6517. if (!stack.length && element !== root) {
  6518. // allow root elements with v-if, v-else-if and v-else
  6519. if (root.if && (element.elseif || element.else)) {
  6520. if (process.env.NODE_ENV !== 'production') {
  6521. checkRootConstraints(element);
  6522. }
  6523. addIfCondition(root, {
  6524. exp: element.elseif,
  6525. block: element
  6526. });
  6527. }
  6528. else if (process.env.NODE_ENV !== 'production') {
  6529. warnOnce(`Component template should contain exactly one root element. ` +
  6530. `If you are using v-if on multiple elements, ` +
  6531. `use v-else-if to chain them instead.`, { start: element.start });
  6532. }
  6533. }
  6534. if (currentParent && !element.forbidden) {
  6535. if (element.elseif || element.else) {
  6536. processIfConditions(element, currentParent);
  6537. }
  6538. else {
  6539. if (element.slotScope) {
  6540. // scoped slot
  6541. // keep it in the children list so that v-else(-if) conditions can
  6542. // find it as the prev node.
  6543. const name = element.slotTarget || '"default"';
  6544. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  6545. }
  6546. currentParent.children.push(element);
  6547. element.parent = currentParent;
  6548. }
  6549. }
  6550. // final children cleanup
  6551. // filter out scoped slots
  6552. element.children = element.children.filter(c => !c.slotScope);
  6553. // remove trailing whitespace node again
  6554. trimEndingWhitespace(element);
  6555. // check pre state
  6556. if (element.pre) {
  6557. inVPre = false;
  6558. }
  6559. if (platformIsPreTag(element.tag)) {
  6560. inPre = false;
  6561. }
  6562. // apply post-transforms
  6563. for (let i = 0; i < postTransforms.length; i++) {
  6564. postTransforms[i](element, options);
  6565. }
  6566. }
  6567. function trimEndingWhitespace(el) {
  6568. // remove trailing whitespace node
  6569. if (!inPre) {
  6570. let lastNode;
  6571. while ((lastNode = el.children[el.children.length - 1]) &&
  6572. lastNode.type === 3 &&
  6573. lastNode.text === ' ') {
  6574. el.children.pop();
  6575. }
  6576. }
  6577. }
  6578. function checkRootConstraints(el) {
  6579. if (el.tag === 'slot' || el.tag === 'template') {
  6580. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  6581. 'contain multiple nodes.', { start: el.start });
  6582. }
  6583. if (el.attrsMap.hasOwnProperty('v-for')) {
  6584. warnOnce('Cannot use v-for on stateful component root element because ' +
  6585. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  6586. }
  6587. }
  6588. parseHTML(template, {
  6589. warn: warn$2,
  6590. expectHTML: options.expectHTML,
  6591. isUnaryTag: options.isUnaryTag,
  6592. canBeLeftOpenTag: options.canBeLeftOpenTag,
  6593. shouldDecodeNewlines: options.shouldDecodeNewlines,
  6594. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  6595. shouldKeepComment: options.comments,
  6596. outputSourceRange: options.outputSourceRange,
  6597. start(tag, attrs, unary, start, end) {
  6598. // check namespace.
  6599. // inherit parent ns if there is one
  6600. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  6601. // handle IE svg bug
  6602. /* istanbul ignore if */
  6603. if (isIE && ns === 'svg') {
  6604. attrs = guardIESVGBug(attrs);
  6605. }
  6606. let element = createASTElement(tag, attrs, currentParent);
  6607. if (ns) {
  6608. element.ns = ns;
  6609. }
  6610. if (process.env.NODE_ENV !== 'production') {
  6611. if (options.outputSourceRange) {
  6612. element.start = start;
  6613. element.end = end;
  6614. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  6615. cumulated[attr.name] = attr;
  6616. return cumulated;
  6617. }, {});
  6618. }
  6619. attrs.forEach(attr => {
  6620. if (invalidAttributeRE.test(attr.name)) {
  6621. warn$2(`Invalid dynamic argument expression: attribute names cannot contain ` +
  6622. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  6623. ? {
  6624. start: attr.start + attr.name.indexOf(`[`),
  6625. end: attr.start + attr.name.length
  6626. }
  6627. : undefined);
  6628. }
  6629. });
  6630. }
  6631. if (isForbiddenTag(element) && !isServerRendering()) {
  6632. element.forbidden = true;
  6633. process.env.NODE_ENV !== 'production' &&
  6634. warn$2('Templates should only be responsible for mapping the state to the ' +
  6635. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  6636. `<${tag}>` +
  6637. ', as they will not be parsed.', { start: element.start });
  6638. }
  6639. // apply pre-transforms
  6640. for (let i = 0; i < preTransforms.length; i++) {
  6641. element = preTransforms[i](element, options) || element;
  6642. }
  6643. if (!inVPre) {
  6644. processPre(element);
  6645. if (element.pre) {
  6646. inVPre = true;
  6647. }
  6648. }
  6649. if (platformIsPreTag(element.tag)) {
  6650. inPre = true;
  6651. }
  6652. if (inVPre) {
  6653. processRawAttrs(element);
  6654. }
  6655. else if (!element.processed) {
  6656. // structural directives
  6657. processFor(element);
  6658. processIf(element);
  6659. processOnce(element);
  6660. }
  6661. if (!root) {
  6662. root = element;
  6663. if (process.env.NODE_ENV !== 'production') {
  6664. checkRootConstraints(root);
  6665. }
  6666. }
  6667. if (!unary) {
  6668. currentParent = element;
  6669. stack.push(element);
  6670. }
  6671. else {
  6672. closeElement(element);
  6673. }
  6674. },
  6675. end(tag, start, end) {
  6676. const element = stack[stack.length - 1];
  6677. // pop stack
  6678. stack.length -= 1;
  6679. currentParent = stack[stack.length - 1];
  6680. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6681. element.end = end;
  6682. }
  6683. closeElement(element);
  6684. },
  6685. chars(text, start, end) {
  6686. if (!currentParent) {
  6687. if (process.env.NODE_ENV !== 'production') {
  6688. if (text === template) {
  6689. warnOnce('Component template requires a root element, rather than just text.', { start });
  6690. }
  6691. else if ((text = text.trim())) {
  6692. warnOnce(`text "${text}" outside root element will be ignored.`, {
  6693. start
  6694. });
  6695. }
  6696. }
  6697. return;
  6698. }
  6699. // IE textarea placeholder bug
  6700. /* istanbul ignore if */
  6701. if (isIE &&
  6702. currentParent.tag === 'textarea' &&
  6703. currentParent.attrsMap.placeholder === text) {
  6704. return;
  6705. }
  6706. const children = currentParent.children;
  6707. if (inPre || text.trim()) {
  6708. text = isTextTag(currentParent)
  6709. ? text
  6710. : decodeHTMLCached(text);
  6711. }
  6712. else if (!children.length) {
  6713. // remove the whitespace-only node right after an opening tag
  6714. text = '';
  6715. }
  6716. else if (whitespaceOption) {
  6717. if (whitespaceOption === 'condense') {
  6718. // in condense mode, remove the whitespace node if it contains
  6719. // line break, otherwise condense to a single space
  6720. text = lineBreakRE.test(text) ? '' : ' ';
  6721. }
  6722. else {
  6723. text = ' ';
  6724. }
  6725. }
  6726. else {
  6727. text = preserveWhitespace ? ' ' : '';
  6728. }
  6729. if (text) {
  6730. if (!inPre && whitespaceOption === 'condense') {
  6731. // condense consecutive whitespaces into single space
  6732. text = text.replace(whitespaceRE, ' ');
  6733. }
  6734. let res;
  6735. let child;
  6736. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  6737. child = {
  6738. type: 2,
  6739. expression: res.expression,
  6740. tokens: res.tokens,
  6741. text
  6742. };
  6743. }
  6744. else if (text !== ' ' ||
  6745. !children.length ||
  6746. children[children.length - 1].text !== ' ') {
  6747. child = {
  6748. type: 3,
  6749. text
  6750. };
  6751. }
  6752. if (child) {
  6753. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6754. child.start = start;
  6755. child.end = end;
  6756. }
  6757. children.push(child);
  6758. }
  6759. }
  6760. },
  6761. comment(text, start, end) {
  6762. // adding anything as a sibling to the root node is forbidden
  6763. // comments should still be allowed, but ignored
  6764. if (currentParent) {
  6765. const child = {
  6766. type: 3,
  6767. text,
  6768. isComment: true
  6769. };
  6770. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6771. child.start = start;
  6772. child.end = end;
  6773. }
  6774. currentParent.children.push(child);
  6775. }
  6776. }
  6777. });
  6778. return root;
  6779. }
  6780. function processPre(el) {
  6781. if (getAndRemoveAttr(el, 'v-pre') != null) {
  6782. el.pre = true;
  6783. }
  6784. }
  6785. function processRawAttrs(el) {
  6786. const list = el.attrsList;
  6787. const len = list.length;
  6788. if (len) {
  6789. const attrs = (el.attrs = new Array(len));
  6790. for (let i = 0; i < len; i++) {
  6791. attrs[i] = {
  6792. name: list[i].name,
  6793. value: JSON.stringify(list[i].value)
  6794. };
  6795. if (list[i].start != null) {
  6796. attrs[i].start = list[i].start;
  6797. attrs[i].end = list[i].end;
  6798. }
  6799. }
  6800. }
  6801. else if (!el.pre) {
  6802. // non root node in pre blocks with no attributes
  6803. el.plain = true;
  6804. }
  6805. }
  6806. function processElement(element, options) {
  6807. processKey(element);
  6808. // determine whether this is a plain element after
  6809. // removing structural attributes
  6810. element.plain =
  6811. !element.key && !element.scopedSlots && !element.attrsList.length;
  6812. processRef(element);
  6813. processSlotContent(element);
  6814. processSlotOutlet(element);
  6815. processComponent(element);
  6816. for (let i = 0; i < transforms.length; i++) {
  6817. element = transforms[i](element, options) || element;
  6818. }
  6819. processAttrs(element);
  6820. return element;
  6821. }
  6822. function processKey(el) {
  6823. const exp = getBindingAttr(el, 'key');
  6824. if (exp) {
  6825. if (process.env.NODE_ENV !== 'production') {
  6826. if (el.tag === 'template') {
  6827. warn$2(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  6828. }
  6829. if (el.for) {
  6830. const iterator = el.iterator2 || el.iterator1;
  6831. const parent = el.parent;
  6832. if (iterator &&
  6833. iterator === exp &&
  6834. parent &&
  6835. parent.tag === 'transition-group') {
  6836. warn$2(`Do not use v-for index as key on <transition-group> children, ` +
  6837. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  6838. }
  6839. }
  6840. }
  6841. el.key = exp;
  6842. }
  6843. }
  6844. function processRef(el) {
  6845. const ref = getBindingAttr(el, 'ref');
  6846. if (ref) {
  6847. el.ref = ref;
  6848. el.refInFor = checkInFor(el);
  6849. }
  6850. }
  6851. function processFor(el) {
  6852. let exp;
  6853. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  6854. const res = parseFor(exp);
  6855. if (res) {
  6856. extend(el, res);
  6857. }
  6858. else if (process.env.NODE_ENV !== 'production') {
  6859. warn$2(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  6860. }
  6861. }
  6862. }
  6863. function parseFor(exp) {
  6864. const inMatch = exp.match(forAliasRE$1);
  6865. if (!inMatch)
  6866. return;
  6867. const res = {};
  6868. res.for = inMatch[2].trim();
  6869. const alias = inMatch[1].trim().replace(stripParensRE, '');
  6870. const iteratorMatch = alias.match(forIteratorRE);
  6871. if (iteratorMatch) {
  6872. res.alias = alias.replace(forIteratorRE, '').trim();
  6873. res.iterator1 = iteratorMatch[1].trim();
  6874. if (iteratorMatch[2]) {
  6875. res.iterator2 = iteratorMatch[2].trim();
  6876. }
  6877. }
  6878. else {
  6879. res.alias = alias;
  6880. }
  6881. return res;
  6882. }
  6883. function processIf(el) {
  6884. const exp = getAndRemoveAttr(el, 'v-if');
  6885. if (exp) {
  6886. el.if = exp;
  6887. addIfCondition(el, {
  6888. exp: exp,
  6889. block: el
  6890. });
  6891. }
  6892. else {
  6893. if (getAndRemoveAttr(el, 'v-else') != null) {
  6894. el.else = true;
  6895. }
  6896. const elseif = getAndRemoveAttr(el, 'v-else-if');
  6897. if (elseif) {
  6898. el.elseif = elseif;
  6899. }
  6900. }
  6901. }
  6902. function processIfConditions(el, parent) {
  6903. const prev = findPrevElement(parent.children);
  6904. if (prev && prev.if) {
  6905. addIfCondition(prev, {
  6906. exp: el.elseif,
  6907. block: el
  6908. });
  6909. }
  6910. else if (process.env.NODE_ENV !== 'production') {
  6911. warn$2(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  6912. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  6913. }
  6914. }
  6915. function findPrevElement(children) {
  6916. let i = children.length;
  6917. while (i--) {
  6918. if (children[i].type === 1) {
  6919. return children[i];
  6920. }
  6921. else {
  6922. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  6923. warn$2(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  6924. `will be ignored.`, children[i]);
  6925. }
  6926. children.pop();
  6927. }
  6928. }
  6929. }
  6930. function addIfCondition(el, condition) {
  6931. if (!el.ifConditions) {
  6932. el.ifConditions = [];
  6933. }
  6934. el.ifConditions.push(condition);
  6935. }
  6936. function processOnce(el) {
  6937. const once = getAndRemoveAttr(el, 'v-once');
  6938. if (once != null) {
  6939. el.once = true;
  6940. }
  6941. }
  6942. // handle content being passed to a component as slot,
  6943. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  6944. function processSlotContent(el) {
  6945. let slotScope;
  6946. if (el.tag === 'template') {
  6947. slotScope = getAndRemoveAttr(el, 'scope');
  6948. /* istanbul ignore if */
  6949. if (process.env.NODE_ENV !== 'production' && slotScope) {
  6950. warn$2(`the "scope" attribute for scoped slots have been deprecated and ` +
  6951. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  6952. `can also be used on plain elements in addition to <template> to ` +
  6953. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  6954. }
  6955. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  6956. }
  6957. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  6958. /* istanbul ignore if */
  6959. if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
  6960. warn$2(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  6961. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  6962. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  6963. }
  6964. el.slotScope = slotScope;
  6965. }
  6966. // slot="xxx"
  6967. const slotTarget = getBindingAttr(el, 'slot');
  6968. if (slotTarget) {
  6969. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  6970. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  6971. // preserve slot as an attribute for native shadow DOM compat
  6972. // only for non-scoped slots.
  6973. if (el.tag !== 'template' && !el.slotScope) {
  6974. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  6975. }
  6976. }
  6977. // 2.6 v-slot syntax
  6978. {
  6979. if (el.tag === 'template') {
  6980. // v-slot on <template>
  6981. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  6982. if (slotBinding) {
  6983. if (process.env.NODE_ENV !== 'production') {
  6984. if (el.slotTarget || el.slotScope) {
  6985. warn$2(`Unexpected mixed usage of different slot syntaxes.`, el);
  6986. }
  6987. if (el.parent && !maybeComponent(el.parent)) {
  6988. warn$2(`<template v-slot> can only appear at the root level inside ` +
  6989. `the receiving component`, el);
  6990. }
  6991. }
  6992. const { name, dynamic } = getSlotName(slotBinding);
  6993. el.slotTarget = name;
  6994. el.slotTargetDynamic = dynamic;
  6995. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  6996. }
  6997. }
  6998. else {
  6999. // v-slot on component, denotes default slot
  7000. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  7001. if (slotBinding) {
  7002. if (process.env.NODE_ENV !== 'production') {
  7003. if (!maybeComponent(el)) {
  7004. warn$2(`v-slot can only be used on components or <template>.`, slotBinding);
  7005. }
  7006. if (el.slotScope || el.slotTarget) {
  7007. warn$2(`Unexpected mixed usage of different slot syntaxes.`, el);
  7008. }
  7009. if (el.scopedSlots) {
  7010. warn$2(`To avoid scope ambiguity, the default slot should also use ` +
  7011. `<template> syntax when there are other named slots.`, slotBinding);
  7012. }
  7013. }
  7014. // add the component's children to its default slot
  7015. const slots = el.scopedSlots || (el.scopedSlots = {});
  7016. const { name, dynamic } = getSlotName(slotBinding);
  7017. const slotContainer = (slots[name] = createASTElement('template', [], el));
  7018. slotContainer.slotTarget = name;
  7019. slotContainer.slotTargetDynamic = dynamic;
  7020. slotContainer.children = el.children.filter((c) => {
  7021. if (!c.slotScope) {
  7022. c.parent = slotContainer;
  7023. return true;
  7024. }
  7025. });
  7026. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  7027. // remove children as they are returned from scopedSlots now
  7028. el.children = [];
  7029. // mark el non-plain so data gets generated
  7030. el.plain = false;
  7031. }
  7032. }
  7033. }
  7034. }
  7035. function getSlotName(binding) {
  7036. let name = binding.name.replace(slotRE, '');
  7037. if (!name) {
  7038. if (binding.name[0] !== '#') {
  7039. name = 'default';
  7040. }
  7041. else if (process.env.NODE_ENV !== 'production') {
  7042. warn$2(`v-slot shorthand syntax requires a slot name.`, binding);
  7043. }
  7044. }
  7045. return dynamicArgRE.test(name)
  7046. ? // dynamic [name]
  7047. { name: name.slice(1, -1), dynamic: true }
  7048. : // static name
  7049. { name: `"${name}"`, dynamic: false };
  7050. }
  7051. // handle <slot/> outlets
  7052. function processSlotOutlet(el) {
  7053. if (el.tag === 'slot') {
  7054. el.slotName = getBindingAttr(el, 'name');
  7055. if (process.env.NODE_ENV !== 'production' && el.key) {
  7056. warn$2(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  7057. `and can possibly expand into multiple elements. ` +
  7058. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  7059. }
  7060. }
  7061. }
  7062. function processComponent(el) {
  7063. let binding;
  7064. if ((binding = getBindingAttr(el, 'is'))) {
  7065. el.component = binding;
  7066. }
  7067. if (getAndRemoveAttr(el, 'inline-template') != null) {
  7068. el.inlineTemplate = true;
  7069. }
  7070. }
  7071. function processAttrs(el) {
  7072. const list = el.attrsList;
  7073. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  7074. for (i = 0, l = list.length; i < l; i++) {
  7075. name = rawName = list[i].name;
  7076. value = list[i].value;
  7077. if (dirRE.test(name)) {
  7078. // mark element as dynamic
  7079. el.hasBindings = true;
  7080. // modifiers
  7081. modifiers = parseModifiers(name.replace(dirRE, ''));
  7082. // support .foo shorthand syntax for the .prop modifier
  7083. if (modifiers) {
  7084. name = name.replace(modifierRE, '');
  7085. }
  7086. if (bindRE.test(name)) {
  7087. // v-bind
  7088. name = name.replace(bindRE, '');
  7089. value = parseFilters(value);
  7090. isDynamic = dynamicArgRE.test(name);
  7091. if (isDynamic) {
  7092. name = name.slice(1, -1);
  7093. }
  7094. if (process.env.NODE_ENV !== 'production' && value.trim().length === 0) {
  7095. warn$2(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  7096. }
  7097. if (modifiers) {
  7098. if (modifiers.prop && !isDynamic) {
  7099. name = camelize(name);
  7100. if (name === 'innerHtml')
  7101. name = 'innerHTML';
  7102. }
  7103. if (modifiers.camel && !isDynamic) {
  7104. name = camelize(name);
  7105. }
  7106. if (modifiers.sync) {
  7107. syncGen = genAssignmentCode(value, `$event`);
  7108. if (!isDynamic) {
  7109. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn$2, list[i]);
  7110. if (hyphenate(name) !== camelize(name)) {
  7111. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn$2, list[i]);
  7112. }
  7113. }
  7114. else {
  7115. // handler w/ dynamic event name
  7116. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn$2, list[i], true // dynamic
  7117. );
  7118. }
  7119. }
  7120. }
  7121. if ((modifiers && modifiers.prop) ||
  7122. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  7123. addProp(el, name, value, list[i], isDynamic);
  7124. }
  7125. else {
  7126. addAttr(el, name, value, list[i], isDynamic);
  7127. }
  7128. }
  7129. else if (onRE.test(name)) {
  7130. // v-on
  7131. name = name.replace(onRE, '');
  7132. isDynamic = dynamicArgRE.test(name);
  7133. if (isDynamic) {
  7134. name = name.slice(1, -1);
  7135. }
  7136. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  7137. }
  7138. else {
  7139. // normal directives
  7140. name = name.replace(dirRE, '');
  7141. // parse arg
  7142. const argMatch = name.match(argRE);
  7143. let arg = argMatch && argMatch[1];
  7144. isDynamic = false;
  7145. if (arg) {
  7146. name = name.slice(0, -(arg.length + 1));
  7147. if (dynamicArgRE.test(arg)) {
  7148. arg = arg.slice(1, -1);
  7149. isDynamic = true;
  7150. }
  7151. }
  7152. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  7153. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  7154. checkForAliasModel(el, value);
  7155. }
  7156. }
  7157. }
  7158. else {
  7159. // literal attribute
  7160. if (process.env.NODE_ENV !== 'production') {
  7161. const res = parseText(value, delimiters);
  7162. if (res) {
  7163. warn$2(`${name}="${value}": ` +
  7164. 'Interpolation inside attributes has been removed. ' +
  7165. 'Use v-bind or the colon shorthand instead. For example, ' +
  7166. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  7167. }
  7168. }
  7169. addAttr(el, name, JSON.stringify(value), list[i]);
  7170. // #6887 firefox doesn't update muted state if set via attribute
  7171. // even immediately after element creation
  7172. if (!el.component &&
  7173. name === 'muted' &&
  7174. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  7175. addProp(el, name, 'true', list[i]);
  7176. }
  7177. }
  7178. }
  7179. }
  7180. function checkInFor(el) {
  7181. let parent = el;
  7182. while (parent) {
  7183. if (parent.for !== undefined) {
  7184. return true;
  7185. }
  7186. parent = parent.parent;
  7187. }
  7188. return false;
  7189. }
  7190. function parseModifiers(name) {
  7191. const match = name.match(modifierRE);
  7192. if (match) {
  7193. const ret = {};
  7194. match.forEach(m => {
  7195. ret[m.slice(1)] = true;
  7196. });
  7197. return ret;
  7198. }
  7199. }
  7200. function makeAttrsMap(attrs) {
  7201. const map = {};
  7202. for (let i = 0, l = attrs.length; i < l; i++) {
  7203. if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE && !isEdge) {
  7204. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  7205. }
  7206. map[attrs[i].name] = attrs[i].value;
  7207. }
  7208. return map;
  7209. }
  7210. // for script (e.g. type="x/template") or style, do not decode content
  7211. function isTextTag(el) {
  7212. return el.tag === 'script' || el.tag === 'style';
  7213. }
  7214. function isForbiddenTag(el) {
  7215. return (el.tag === 'style' ||
  7216. (el.tag === 'script' &&
  7217. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  7218. }
  7219. const ieNSBug = /^xmlns:NS\d+/;
  7220. const ieNSPrefix = /^NS\d+:/;
  7221. /* istanbul ignore next */
  7222. function guardIESVGBug(attrs) {
  7223. const res = [];
  7224. for (let i = 0; i < attrs.length; i++) {
  7225. const attr = attrs[i];
  7226. if (!ieNSBug.test(attr.name)) {
  7227. attr.name = attr.name.replace(ieNSPrefix, '');
  7228. res.push(attr);
  7229. }
  7230. }
  7231. return res;
  7232. }
  7233. function checkForAliasModel(el, value) {
  7234. let _el = el;
  7235. while (_el) {
  7236. if (_el.for && _el.alias === value) {
  7237. warn$2(`<${el.tag} v-model="${value}">: ` +
  7238. `You are binding v-model directly to a v-for iteration alias. ` +
  7239. `This will not be able to modify the v-for source array because ` +
  7240. `writing to the alias is like modifying a function local variable. ` +
  7241. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  7242. }
  7243. _el = _el.parent;
  7244. }
  7245. }
  7246. /**
  7247. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  7248. * Turn this:
  7249. * <input v-model="data[type]" :type="type">
  7250. * into this:
  7251. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  7252. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  7253. * <input v-else :type="type" v-model="data[type]">
  7254. */
  7255. function preTransformNode(el, options) {
  7256. if (el.tag === 'input') {
  7257. const map = el.attrsMap;
  7258. if (!map['v-model']) {
  7259. return;
  7260. }
  7261. let typeBinding;
  7262. if (map[':type'] || map['v-bind:type']) {
  7263. typeBinding = getBindingAttr(el, 'type');
  7264. }
  7265. if (!map.type && !typeBinding && map['v-bind']) {
  7266. typeBinding = `(${map['v-bind']}).type`;
  7267. }
  7268. if (typeBinding) {
  7269. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  7270. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  7271. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  7272. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  7273. // 1. checkbox
  7274. const branch0 = cloneASTElement(el);
  7275. // process for on the main node
  7276. processFor(branch0);
  7277. addRawAttr(branch0, 'type', 'checkbox');
  7278. processElement(branch0, options);
  7279. branch0.processed = true; // prevent it from double-processed
  7280. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  7281. addIfCondition(branch0, {
  7282. exp: branch0.if,
  7283. block: branch0
  7284. });
  7285. // 2. add radio else-if condition
  7286. const branch1 = cloneASTElement(el);
  7287. getAndRemoveAttr(branch1, 'v-for', true);
  7288. addRawAttr(branch1, 'type', 'radio');
  7289. processElement(branch1, options);
  7290. addIfCondition(branch0, {
  7291. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  7292. block: branch1
  7293. });
  7294. // 3. other
  7295. const branch2 = cloneASTElement(el);
  7296. getAndRemoveAttr(branch2, 'v-for', true);
  7297. addRawAttr(branch2, ':type', typeBinding);
  7298. processElement(branch2, options);
  7299. addIfCondition(branch0, {
  7300. exp: ifCondition,
  7301. block: branch2
  7302. });
  7303. if (hasElse) {
  7304. branch0.else = true;
  7305. }
  7306. else if (elseIfCondition) {
  7307. branch0.elseif = elseIfCondition;
  7308. }
  7309. return branch0;
  7310. }
  7311. }
  7312. }
  7313. function cloneASTElement(el) {
  7314. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  7315. }
  7316. var model$1 = {
  7317. preTransformNode
  7318. };
  7319. var modules = [klass, style, model$1];
  7320. let warn$1;
  7321. // in some cases, the event used has to be determined at runtime
  7322. // so we used some reserved tokens during compile.
  7323. const RANGE_TOKEN = '__r';
  7324. function model(el, dir, _warn) {
  7325. warn$1 = _warn;
  7326. const value = dir.value;
  7327. const modifiers = dir.modifiers;
  7328. const tag = el.tag;
  7329. const type = el.attrsMap.type;
  7330. if (process.env.NODE_ENV !== 'production') {
  7331. // inputs with type="file" are read only and setting the input's
  7332. // value will throw an error.
  7333. if (tag === 'input' && type === 'file') {
  7334. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7335. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7336. }
  7337. }
  7338. if (el.component) {
  7339. genComponentModel(el, value, modifiers);
  7340. // component v-model doesn't need extra runtime
  7341. return false;
  7342. }
  7343. else if (tag === 'select') {
  7344. genSelect(el, value, modifiers);
  7345. }
  7346. else if (tag === 'input' && type === 'checkbox') {
  7347. genCheckboxModel(el, value, modifiers);
  7348. }
  7349. else if (tag === 'input' && type === 'radio') {
  7350. genRadioModel(el, value, modifiers);
  7351. }
  7352. else if (tag === 'input' || tag === 'textarea') {
  7353. genDefaultModel(el, value, modifiers);
  7354. }
  7355. else {
  7356. genComponentModel(el, value, modifiers);
  7357. // component v-model doesn't need extra runtime
  7358. return false;
  7359. }
  7360. // ensure runtime directive metadata
  7361. return true;
  7362. }
  7363. function genCheckboxModel(el, value, modifiers) {
  7364. const number = modifiers && modifiers.number;
  7365. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7366. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7367. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7368. addProp(el, 'checked', `Array.isArray(${value})` +
  7369. `?_i(${value},${valueBinding})>-1` +
  7370. (trueValueBinding === 'true'
  7371. ? `:(${value})`
  7372. : `:_q(${value},${trueValueBinding})`));
  7373. addHandler(el, 'change', `var $$a=${value},` +
  7374. '$$el=$event.target,' +
  7375. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7376. 'if(Array.isArray($$a)){' +
  7377. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7378. '$$i=_i($$a,$$v);' +
  7379. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7380. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7381. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7382. }
  7383. function genRadioModel(el, value, modifiers) {
  7384. const number = modifiers && modifiers.number;
  7385. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7386. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7387. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7388. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7389. }
  7390. function genSelect(el, value, modifiers) {
  7391. const number = modifiers && modifiers.number;
  7392. const selectedVal = `Array.prototype.filter` +
  7393. `.call($event.target.options,function(o){return o.selected})` +
  7394. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7395. `return ${number ? '_n(val)' : 'val'}})`;
  7396. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7397. let code = `var $$selectedVal = ${selectedVal};`;
  7398. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7399. addHandler(el, 'change', code, null, true);
  7400. }
  7401. function genDefaultModel(el, value, modifiers) {
  7402. const type = el.attrsMap.type;
  7403. // warn if v-bind:value conflicts with v-model
  7404. // except for inputs with v-bind:type
  7405. if (process.env.NODE_ENV !== 'production') {
  7406. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7407. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7408. if (value && !typeBinding) {
  7409. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7410. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7411. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7412. }
  7413. }
  7414. const { lazy, number, trim } = modifiers || {};
  7415. const needCompositionGuard = !lazy && type !== 'range';
  7416. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7417. let valueExpression = '$event.target.value';
  7418. if (trim) {
  7419. valueExpression = `$event.target.value.trim()`;
  7420. }
  7421. if (number) {
  7422. valueExpression = `_n(${valueExpression})`;
  7423. }
  7424. let code = genAssignmentCode(value, valueExpression);
  7425. if (needCompositionGuard) {
  7426. code = `if($event.target.composing)return;${code}`;
  7427. }
  7428. addProp(el, 'value', `(${value})`);
  7429. addHandler(el, event, code, null, true);
  7430. if (trim || number) {
  7431. addHandler(el, 'blur', '$forceUpdate()');
  7432. }
  7433. }
  7434. function text(el, dir) {
  7435. if (dir.value) {
  7436. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  7437. }
  7438. }
  7439. function html(el, dir) {
  7440. if (dir.value) {
  7441. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  7442. }
  7443. }
  7444. var directives = {
  7445. model,
  7446. text,
  7447. html
  7448. };
  7449. const baseOptions = {
  7450. expectHTML: true,
  7451. modules,
  7452. directives,
  7453. isPreTag,
  7454. isUnaryTag,
  7455. mustUseProp,
  7456. canBeLeftOpenTag,
  7457. isReservedTag,
  7458. getTagNamespace,
  7459. staticKeys: genStaticKeys$1(modules)
  7460. };
  7461. const hasWarned = {};
  7462. function warnOnce(msg) {
  7463. const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
  7464. if (!isNodeProd && !hasWarned[msg]) {
  7465. hasWarned[msg] = true;
  7466. warn(msg);
  7467. }
  7468. }
  7469. function warn(msg) {
  7470. console.warn(`\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`);
  7471. }
  7472. const doNotPrefix = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  7473. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  7474. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  7475. 'require,' + // for webpack
  7476. 'arguments,' + // parsed as identifier but is a special keyword...
  7477. '_c' // cached to save property access
  7478. );
  7479. /**
  7480. * The input is expected to be a valid expression.
  7481. */
  7482. function prefixIdentifiers(source, isFunctional = false, isTS = false, babelOptions = {}, bindings) {
  7483. const s = new MagicString(source);
  7484. const plugins = [
  7485. ...(isTS ? ['typescript'] : []),
  7486. ...((babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [])
  7487. ];
  7488. const ast = parser$1.parseExpression(source, Object.assign(Object.assign({}, babelOptions), { plugins }));
  7489. const isScriptSetup = bindings && bindings.__isScriptSetup !== false;
  7490. walkIdentifiers(ast, (ident, parent) => {
  7491. const { name } = ident;
  7492. if (doNotPrefix(name)) {
  7493. return;
  7494. }
  7495. let prefix = `_vm.`;
  7496. if (isScriptSetup) {
  7497. const type = bindings[name];
  7498. if (type && type.startsWith('setup')) {
  7499. prefix = `_setup.`;
  7500. }
  7501. }
  7502. if (isStaticProperty(parent) && parent.shorthand) {
  7503. // property shorthand like { foo }, we need to add the key since
  7504. // we rewrite the value
  7505. // { foo } -> { foo: _vm.foo }
  7506. s.appendLeft(ident.end, `: ${prefix}${name}`);
  7507. }
  7508. else {
  7509. s.prependRight(ident.start, prefix);
  7510. }
  7511. }, node => {
  7512. if (node.type === 'WithStatement') {
  7513. s.remove(node.start, node.body.start + 1);
  7514. s.remove(node.end - 1, node.end);
  7515. if (!isFunctional) {
  7516. s.prependRight(node.start, `var _vm=this,_c=_vm._self._c${isScriptSetup ? `,_setup=_vm._self._setupProxy;` : `;`}`);
  7517. }
  7518. }
  7519. });
  7520. return s.toString();
  7521. }
  7522. const CSS_VARS_HELPER = `useCssVars`;
  7523. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  7524. return `{\n ${vars
  7525. .map(key => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`)
  7526. .join(',\n ')}\n}`;
  7527. }
  7528. function genVarName(id, raw, isProd) {
  7529. if (isProd) {
  7530. return hashSum(id + raw);
  7531. }
  7532. else {
  7533. return `${id}-${raw.replace(/([^\w-])/g, '_')}`;
  7534. }
  7535. }
  7536. function normalizeExpression(exp) {
  7537. exp = exp.trim();
  7538. if ((exp[0] === `'` && exp[exp.length - 1] === `'`) ||
  7539. (exp[0] === `"` && exp[exp.length - 1] === `"`)) {
  7540. return exp.slice(1, -1);
  7541. }
  7542. return exp;
  7543. }
  7544. const vBindRE = /v-bind\s*\(/g;
  7545. function parseCssVars(sfc) {
  7546. const vars = [];
  7547. sfc.styles.forEach(style => {
  7548. let match;
  7549. // ignore v-bind() in comments /* ... */
  7550. const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
  7551. while ((match = vBindRE.exec(content))) {
  7552. const start = match.index + match[0].length;
  7553. const end = lexBinding(content, start);
  7554. if (end !== null) {
  7555. const variable = normalizeExpression(content.slice(start, end));
  7556. if (!vars.includes(variable)) {
  7557. vars.push(variable);
  7558. }
  7559. }
  7560. }
  7561. });
  7562. return vars;
  7563. }
  7564. function lexBinding(content, start) {
  7565. let state = 0 /* LexerState.inParens */;
  7566. let parenDepth = 0;
  7567. for (let i = start; i < content.length; i++) {
  7568. const char = content.charAt(i);
  7569. switch (state) {
  7570. case 0 /* LexerState.inParens */:
  7571. if (char === `'`) {
  7572. state = 1 /* LexerState.inSingleQuoteString */;
  7573. }
  7574. else if (char === `"`) {
  7575. state = 2 /* LexerState.inDoubleQuoteString */;
  7576. }
  7577. else if (char === `(`) {
  7578. parenDepth++;
  7579. }
  7580. else if (char === `)`) {
  7581. if (parenDepth > 0) {
  7582. parenDepth--;
  7583. }
  7584. else {
  7585. return i;
  7586. }
  7587. }
  7588. break;
  7589. case 1 /* LexerState.inSingleQuoteString */:
  7590. if (char === `'`) {
  7591. state = 0 /* LexerState.inParens */;
  7592. }
  7593. break;
  7594. case 2 /* LexerState.inDoubleQuoteString */:
  7595. if (char === `"`) {
  7596. state = 0 /* LexerState.inParens */;
  7597. }
  7598. break;
  7599. }
  7600. }
  7601. return null;
  7602. }
  7603. const cssVarsPlugin = opts => {
  7604. const { id, isProd } = opts;
  7605. return {
  7606. postcssPlugin: 'vue-sfc-vars',
  7607. Declaration(decl) {
  7608. // rewrite CSS variables
  7609. const value = decl.value;
  7610. if (vBindRE.test(value)) {
  7611. vBindRE.lastIndex = 0;
  7612. let transformed = '';
  7613. let lastIndex = 0;
  7614. let match;
  7615. while ((match = vBindRE.exec(value))) {
  7616. const start = match.index + match[0].length;
  7617. const end = lexBinding(value, start);
  7618. if (end !== null) {
  7619. const variable = normalizeExpression(value.slice(start, end));
  7620. transformed +=
  7621. value.slice(lastIndex, match.index) +
  7622. `var(--${genVarName(id, variable, isProd)})`;
  7623. lastIndex = end + 1;
  7624. }
  7625. }
  7626. decl.value = transformed + value.slice(lastIndex);
  7627. }
  7628. }
  7629. };
  7630. };
  7631. cssVarsPlugin.postcss = true;
  7632. function genCssVarsCode(vars, bindings, id, isProd) {
  7633. const varsExp = genCssVarsFromList(vars, id, isProd);
  7634. return `_${CSS_VARS_HELPER}((_vm, _setup) => ${prefixIdentifiers(`(${varsExp})`, false, false, undefined, bindings)})`;
  7635. }
  7636. // <script setup> already gets the calls injected as part of the transform
  7637. // this is only for single normal <script>
  7638. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd) {
  7639. return (`\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\n` +
  7640. `const __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\n` +
  7641. `const __setup__ = __default__.setup\n` +
  7642. `__default__.setup = __setup__\n` +
  7643. ` ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n` +
  7644. ` : __injectCSSVars__\n`);
  7645. }
  7646. const defaultExportRE = /((?:^|\n|;)\s*)export(\s*)default/;
  7647. const namedDefaultExportRE = /((?:^|\n|;)\s*)export(.+)(?:as)?(\s*)default/s;
  7648. const exportDefaultClassRE = /((?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/;
  7649. /**
  7650. * Utility for rewriting `export default` in a script block into a variable
  7651. * declaration so that we can inject things into it
  7652. */
  7653. function rewriteDefault(input, as, parserPlugins) {
  7654. if (!hasDefaultExport(input)) {
  7655. return input + `\nconst ${as} = {}`;
  7656. }
  7657. let replaced;
  7658. const classMatch = input.match(exportDefaultClassRE);
  7659. if (classMatch) {
  7660. replaced =
  7661. input.replace(exportDefaultClassRE, '$1class $2') +
  7662. `\nconst ${as} = ${classMatch[2]}`;
  7663. }
  7664. else {
  7665. replaced = input.replace(defaultExportRE, `$1const ${as} =`);
  7666. }
  7667. if (!hasDefaultExport(replaced)) {
  7668. return replaced;
  7669. }
  7670. // if the script somehow still contains `default export`, it probably has
  7671. // multi-line comments or template strings. fallback to a full parse.
  7672. const s = new MagicString(input);
  7673. const ast = parser$1.parse(input, {
  7674. sourceType: 'module',
  7675. plugins: parserPlugins
  7676. }).program.body;
  7677. ast.forEach(node => {
  7678. if (node.type === 'ExportDefaultDeclaration') {
  7679. if (node.declaration.type === 'ClassDeclaration') {
  7680. s.overwrite(node.start, node.declaration.id.start, `class `);
  7681. s.append(`\nconst ${as} = ${node.declaration.id.name}`);
  7682. }
  7683. else {
  7684. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  7685. }
  7686. }
  7687. if (node.type === 'ExportNamedDeclaration') {
  7688. for (const specifier of node.specifiers) {
  7689. if (specifier.type === 'ExportSpecifier' &&
  7690. specifier.exported.type === 'Identifier' &&
  7691. specifier.exported.name === 'default') {
  7692. if (node.source) {
  7693. if (specifier.local.name === 'default') {
  7694. const end = specifierEnd(input, specifier.local.end, node.end);
  7695. s.prepend(`import { default as __VUE_DEFAULT__ } from '${node.source.value}'\n`);
  7696. s.overwrite(specifier.start, end, ``);
  7697. s.append(`\nconst ${as} = __VUE_DEFAULT__`);
  7698. continue;
  7699. }
  7700. else {
  7701. const end = specifierEnd(input, specifier.exported.end, node.end);
  7702. s.prepend(`import { ${input.slice(specifier.local.start, specifier.local.end)} } from '${node.source.value}'\n`);
  7703. s.overwrite(specifier.start, end, ``);
  7704. s.append(`\nconst ${as} = ${specifier.local.name}`);
  7705. continue;
  7706. }
  7707. }
  7708. const end = specifierEnd(input, specifier.end, node.end);
  7709. s.overwrite(specifier.start, end, ``);
  7710. s.append(`\nconst ${as} = ${specifier.local.name}`);
  7711. }
  7712. }
  7713. }
  7714. });
  7715. return s.toString();
  7716. }
  7717. function hasDefaultExport(input) {
  7718. return defaultExportRE.test(input) || namedDefaultExportRE.test(input);
  7719. }
  7720. function specifierEnd(input, end, nodeEnd) {
  7721. // export { default , foo } ...
  7722. let hasCommas = false;
  7723. let oldEnd = end;
  7724. while (end < nodeEnd) {
  7725. if (/\s/.test(input.charAt(end))) {
  7726. end++;
  7727. }
  7728. else if (input.charAt(end) === ',') {
  7729. end++;
  7730. hasCommas = true;
  7731. break;
  7732. }
  7733. else if (input.charAt(end) === '}') {
  7734. break;
  7735. }
  7736. }
  7737. return hasCommas ? end : oldEnd;
  7738. }
  7739. // Special compiler macros
  7740. const DEFINE_PROPS = 'defineProps';
  7741. const DEFINE_EMITS = 'defineEmits';
  7742. const DEFINE_EXPOSE = 'defineExpose';
  7743. const WITH_DEFAULTS = 'withDefaults';
  7744. // constants
  7745. const DEFAULT_VAR = `__default__`;
  7746. const isBuiltInDir$1 = makeMap(`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
  7747. /**
  7748. * Compile `<script setup>`
  7749. * It requires the whole SFC descriptor because we need to handle and merge
  7750. * normal `<script>` + `<script setup>` if both are present.
  7751. */
  7752. function compileScript(sfc, options = { id: '' }) {
  7753. let { filename, script, scriptSetup, source } = sfc;
  7754. const isProd = !!options.isProd;
  7755. const genSourceMap = options.sourceMap !== false;
  7756. const cssVars = sfc.cssVars;
  7757. const scopeId = options.id ? options.id.replace(/^data-v-/, '') : '';
  7758. const scriptLang = script && script.lang;
  7759. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  7760. const isTS = scriptLang === 'ts' ||
  7761. scriptLang === 'tsx' ||
  7762. scriptSetupLang === 'ts' ||
  7763. scriptSetupLang === 'tsx';
  7764. // resolve parser plugins
  7765. const plugins = [];
  7766. if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
  7767. plugins.push('jsx');
  7768. }
  7769. else {
  7770. // If don't match the case of adding jsx, should remove the jsx from the babelParserPlugins
  7771. if (options.babelParserPlugins)
  7772. options.babelParserPlugins = options.babelParserPlugins.filter(n => n !== 'jsx');
  7773. }
  7774. if (options.babelParserPlugins)
  7775. plugins.push(...options.babelParserPlugins);
  7776. if (isTS) {
  7777. plugins.push('typescript');
  7778. if (!plugins.includes('decorators')) {
  7779. plugins.push('decorators-legacy');
  7780. }
  7781. }
  7782. if (!scriptSetup) {
  7783. if (!script) {
  7784. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  7785. }
  7786. if (scriptLang && !isTS && scriptLang !== 'jsx') {
  7787. // do not process non js/ts script blocks
  7788. return script;
  7789. }
  7790. try {
  7791. let content = script.content;
  7792. let map = script.map;
  7793. const scriptAst = parser$1.parse(content, {
  7794. plugins,
  7795. sourceType: 'module'
  7796. }).program;
  7797. const bindings = analyzeScriptBindings(scriptAst.body);
  7798. if (cssVars.length) {
  7799. content = rewriteDefault(content, DEFAULT_VAR, plugins);
  7800. content += genNormalScriptCssVarsCode(cssVars, bindings, scopeId, isProd);
  7801. content += `\nexport default ${DEFAULT_VAR}`;
  7802. }
  7803. return Object.assign(Object.assign({}, script), { content,
  7804. map,
  7805. bindings, scriptAst: scriptAst.body });
  7806. }
  7807. catch (e) {
  7808. // silently fallback if parse fails since user may be using custom
  7809. // babel syntax
  7810. return script;
  7811. }
  7812. }
  7813. if (script && scriptLang !== scriptSetupLang) {
  7814. throw new Error(`[@vue/compiler-sfc] <script> and <script setup> must have the same ` +
  7815. `language type.`);
  7816. }
  7817. if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
  7818. // do not process non js/ts script blocks
  7819. return scriptSetup;
  7820. }
  7821. // metadata that needs to be returned
  7822. const bindingMetadata = {};
  7823. const helperImports = new Set();
  7824. const userImports = Object.create(null);
  7825. const userImportAlias = Object.create(null);
  7826. const scriptBindings = Object.create(null);
  7827. const setupBindings = Object.create(null);
  7828. let defaultExport;
  7829. let hasDefinePropsCall = false;
  7830. let hasDefineEmitCall = false;
  7831. let hasDefineExposeCall = false;
  7832. let hasDefaultExportName = false;
  7833. let propsRuntimeDecl;
  7834. let propsRuntimeDefaults;
  7835. let propsDestructureDecl;
  7836. let propsTypeDecl;
  7837. let propsTypeDeclRaw;
  7838. let propsIdentifier;
  7839. let emitsRuntimeDecl;
  7840. let emitsTypeDecl;
  7841. let emitsTypeDeclRaw;
  7842. let emitIdentifier;
  7843. // props/emits declared via types
  7844. const typeDeclaredProps = {};
  7845. const typeDeclaredEmits = new Set();
  7846. // record declared types for runtime props type generation
  7847. const declaredTypes = {};
  7848. // props destructure data
  7849. const propsDestructuredBindings = Object.create(null);
  7850. // magic-string state
  7851. const s = new MagicString(source);
  7852. const startOffset = scriptSetup.start;
  7853. const endOffset = scriptSetup.end;
  7854. const scriptStartOffset = script && script.start;
  7855. const scriptEndOffset = script && script.end;
  7856. function helper(key) {
  7857. helperImports.add(key);
  7858. return `_${key}`;
  7859. }
  7860. function parse(input, options, offset) {
  7861. try {
  7862. return parser$1.parse(input, options).program;
  7863. }
  7864. catch (e) {
  7865. e.message = `[@vue/compiler-sfc] ${e.message}\n\n${filename}\n${generateCodeFrame(source, e.pos + offset, e.pos + offset + 1)}`;
  7866. throw e;
  7867. }
  7868. }
  7869. function error(msg, node, end = node.end + startOffset) {
  7870. throw new Error(`[@vue/compiler-sfc] ${msg}\n\n${filename}\n${generateCodeFrame(source, node.start + startOffset, end)}`);
  7871. }
  7872. function registerUserImport(source, local, imported, isType, isFromSetup) {
  7873. if (source === 'vue' && imported) {
  7874. userImportAlias[imported] = local;
  7875. }
  7876. let isUsedInTemplate = true;
  7877. if (sfc.template && !sfc.template.src && !sfc.template.lang) {
  7878. isUsedInTemplate = isImportUsed(local, sfc, isTS);
  7879. }
  7880. userImports[local] = {
  7881. isType,
  7882. imported: imported || 'default',
  7883. source,
  7884. isFromSetup,
  7885. isUsedInTemplate
  7886. };
  7887. }
  7888. function processDefineProps(node, declId) {
  7889. if (!isCallOf(node, DEFINE_PROPS)) {
  7890. return false;
  7891. }
  7892. if (hasDefinePropsCall) {
  7893. error(`duplicate ${DEFINE_PROPS}() call`, node);
  7894. }
  7895. hasDefinePropsCall = true;
  7896. propsRuntimeDecl = node.arguments[0];
  7897. // call has type parameters - infer runtime types from it
  7898. if (node.typeParameters) {
  7899. if (propsRuntimeDecl) {
  7900. error(`${DEFINE_PROPS}() cannot accept both type and non-type arguments ` +
  7901. `at the same time. Use one or the other.`, node);
  7902. }
  7903. propsTypeDeclRaw = node.typeParameters.params[0];
  7904. propsTypeDecl = resolveQualifiedType(propsTypeDeclRaw, node => node.type === 'TSTypeLiteral');
  7905. if (!propsTypeDecl) {
  7906. error(`type argument passed to ${DEFINE_PROPS}() must be a literal type, ` +
  7907. `or a reference to an interface or literal type.`, propsTypeDeclRaw);
  7908. }
  7909. }
  7910. if (declId) {
  7911. propsIdentifier = scriptSetup.content.slice(declId.start, declId.end);
  7912. }
  7913. return true;
  7914. }
  7915. function processWithDefaults(node, declId) {
  7916. if (!isCallOf(node, WITH_DEFAULTS)) {
  7917. return false;
  7918. }
  7919. if (processDefineProps(node.arguments[0], declId)) {
  7920. if (propsRuntimeDecl) {
  7921. error(`${WITH_DEFAULTS} can only be used with type-based ` +
  7922. `${DEFINE_PROPS} declaration.`, node);
  7923. }
  7924. propsRuntimeDefaults = node.arguments[1];
  7925. if (!propsRuntimeDefaults ||
  7926. propsRuntimeDefaults.type !== 'ObjectExpression') {
  7927. error(`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`, propsRuntimeDefaults || node);
  7928. }
  7929. }
  7930. else {
  7931. error(`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`, node.arguments[0] || node);
  7932. }
  7933. return true;
  7934. }
  7935. function processDefineEmits(node, declId) {
  7936. if (!isCallOf(node, DEFINE_EMITS)) {
  7937. return false;
  7938. }
  7939. if (hasDefineEmitCall) {
  7940. error(`duplicate ${DEFINE_EMITS}() call`, node);
  7941. }
  7942. hasDefineEmitCall = true;
  7943. emitsRuntimeDecl = node.arguments[0];
  7944. if (node.typeParameters) {
  7945. if (emitsRuntimeDecl) {
  7946. error(`${DEFINE_EMITS}() cannot accept both type and non-type arguments ` +
  7947. `at the same time. Use one or the other.`, node);
  7948. }
  7949. emitsTypeDeclRaw = node.typeParameters.params[0];
  7950. emitsTypeDecl = resolveQualifiedType(emitsTypeDeclRaw, node => node.type === 'TSFunctionType' || node.type === 'TSTypeLiteral');
  7951. if (!emitsTypeDecl) {
  7952. error(`type argument passed to ${DEFINE_EMITS}() must be a function type, ` +
  7953. `a literal type with call signatures, or a reference to the above types.`, emitsTypeDeclRaw);
  7954. }
  7955. }
  7956. if (declId) {
  7957. emitIdentifier = scriptSetup.content.slice(declId.start, declId.end);
  7958. }
  7959. return true;
  7960. }
  7961. function resolveQualifiedType(node, qualifier) {
  7962. if (qualifier(node)) {
  7963. return node;
  7964. }
  7965. if (node.type === 'TSTypeReference' &&
  7966. node.typeName.type === 'Identifier') {
  7967. const refName = node.typeName.name;
  7968. const isQualifiedType = (node) => {
  7969. if (node.type === 'TSInterfaceDeclaration' &&
  7970. node.id.name === refName) {
  7971. return node.body;
  7972. }
  7973. else if (node.type === 'TSTypeAliasDeclaration' &&
  7974. node.id.name === refName &&
  7975. qualifier(node.typeAnnotation)) {
  7976. return node.typeAnnotation;
  7977. }
  7978. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  7979. return isQualifiedType(node.declaration);
  7980. }
  7981. };
  7982. const body = scriptAst
  7983. ? [...scriptSetupAst.body, ...scriptAst.body]
  7984. : scriptSetupAst.body;
  7985. for (const node of body) {
  7986. const qualified = isQualifiedType(node);
  7987. if (qualified) {
  7988. return qualified;
  7989. }
  7990. }
  7991. }
  7992. }
  7993. function processDefineExpose(node) {
  7994. if (isCallOf(node, DEFINE_EXPOSE)) {
  7995. if (hasDefineExposeCall) {
  7996. error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  7997. }
  7998. hasDefineExposeCall = true;
  7999. return true;
  8000. }
  8001. return false;
  8002. }
  8003. function checkInvalidScopeReference(node, method) {
  8004. if (!node)
  8005. return;
  8006. walkIdentifiers(node, id => {
  8007. if (setupBindings[id.name]) {
  8008. error(`\`${method}()\` in <script setup> cannot reference locally ` +
  8009. `declared variables because it will be hoisted outside of the ` +
  8010. `setup() function. If your component options require initialization ` +
  8011. `in the module scope, use a separate normal <script> to export ` +
  8012. `the options instead.`, id);
  8013. }
  8014. });
  8015. }
  8016. /**
  8017. * check defaults. If the default object is an object literal with only
  8018. * static properties, we can directly generate more optimized default
  8019. * declarations. Otherwise we will have to fallback to runtime merging.
  8020. */
  8021. function hasStaticWithDefaults() {
  8022. return (propsRuntimeDefaults &&
  8023. propsRuntimeDefaults.type === 'ObjectExpression' &&
  8024. propsRuntimeDefaults.properties.every(node => (node.type === 'ObjectProperty' && !node.computed) ||
  8025. node.type === 'ObjectMethod'));
  8026. }
  8027. function genRuntimeProps(props) {
  8028. const keys = Object.keys(props);
  8029. if (!keys.length) {
  8030. return ``;
  8031. }
  8032. const hasStaticDefaults = hasStaticWithDefaults();
  8033. const scriptSetupSource = scriptSetup.content;
  8034. let propsDecls = `{
  8035. ${keys
  8036. .map(key => {
  8037. let defaultString;
  8038. const destructured = genDestructuredDefaultValue(key);
  8039. if (destructured) {
  8040. defaultString = `default: ${destructured}`;
  8041. }
  8042. else if (hasStaticDefaults) {
  8043. const prop = propsRuntimeDefaults.properties.find((node) => node.key.name === key);
  8044. if (prop) {
  8045. if (prop.type === 'ObjectProperty') {
  8046. // prop has corresponding static default value
  8047. defaultString = `default: ${scriptSetupSource.slice(prop.value.start, prop.value.end)}`;
  8048. }
  8049. else {
  8050. defaultString = `default() ${scriptSetupSource.slice(prop.body.start, prop.body.end)}`;
  8051. }
  8052. }
  8053. }
  8054. const { type, required } = props[key];
  8055. if (!isProd) {
  8056. return `${key}: { type: ${toRuntimeTypeString(type)}, required: ${required}${defaultString ? `, ${defaultString}` : ``} }`;
  8057. }
  8058. else if (type.some(el => el === 'Boolean' || (defaultString && el === 'Function'))) {
  8059. // #4783 production: if boolean or defaultString and function exists, should keep the type.
  8060. return `${key}: { type: ${toRuntimeTypeString(type)}${defaultString ? `, ${defaultString}` : ``} }`;
  8061. }
  8062. else {
  8063. // production: checks are useless
  8064. return `${key}: ${defaultString ? `{ ${defaultString} }` : 'null'}`;
  8065. }
  8066. })
  8067. .join(',\n ')}\n }`;
  8068. if (propsRuntimeDefaults && !hasStaticDefaults) {
  8069. propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(propsRuntimeDefaults.start + startOffset, propsRuntimeDefaults.end + startOffset)})`;
  8070. }
  8071. return `\n props: ${propsDecls},`;
  8072. }
  8073. function genDestructuredDefaultValue(key) {
  8074. const destructured = propsDestructuredBindings[key];
  8075. if (destructured && destructured.default) {
  8076. const value = scriptSetup.content.slice(destructured.default.start, destructured.default.end);
  8077. const isLiteral = destructured.default.type.endsWith('Literal');
  8078. return isLiteral ? value : `() => (${value})`;
  8079. }
  8080. }
  8081. function genSetupPropsType(node) {
  8082. const scriptSetupSource = scriptSetup.content;
  8083. if (hasStaticWithDefaults()) {
  8084. // if withDefaults() is used, we need to remove the optional flags
  8085. // on props that have default values
  8086. let res = `{ `;
  8087. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8088. for (const m of members) {
  8089. if ((m.type === 'TSPropertySignature' ||
  8090. m.type === 'TSMethodSignature') &&
  8091. m.typeAnnotation &&
  8092. m.key.type === 'Identifier') {
  8093. if (propsRuntimeDefaults.properties.some((p) => p.key.name === m.key.name)) {
  8094. res +=
  8095. m.key.name +
  8096. (m.type === 'TSMethodSignature' ? '()' : '') +
  8097. scriptSetupSource.slice(m.typeAnnotation.start, m.typeAnnotation.end) +
  8098. ', ';
  8099. }
  8100. else {
  8101. res +=
  8102. scriptSetupSource.slice(m.start, m.typeAnnotation.end) + `, `;
  8103. }
  8104. }
  8105. }
  8106. return (res.length ? res.slice(0, -2) : res) + ` }`;
  8107. }
  8108. else {
  8109. return scriptSetupSource.slice(node.start, node.end);
  8110. }
  8111. }
  8112. // 1. process normal <script> first if it exists
  8113. let scriptAst;
  8114. if (script) {
  8115. scriptAst = parse(script.content, {
  8116. plugins,
  8117. sourceType: 'module'
  8118. }, scriptStartOffset);
  8119. for (const node of scriptAst.body) {
  8120. if (node.type === 'ImportDeclaration') {
  8121. // record imports for dedupe
  8122. for (const specifier of node.specifiers) {
  8123. const imported = specifier.type === 'ImportSpecifier' &&
  8124. specifier.imported.type === 'Identifier' &&
  8125. specifier.imported.name;
  8126. registerUserImport(node.source.value, specifier.local.name, imported, node.importKind === 'type' ||
  8127. (specifier.type === 'ImportSpecifier' &&
  8128. specifier.importKind === 'type'), false);
  8129. }
  8130. }
  8131. else if (node.type === 'ExportDefaultDeclaration') {
  8132. // export default
  8133. defaultExport = node;
  8134. // check if user has manually specified `name` or 'render` option in
  8135. // export default
  8136. // if has name, skip name inference
  8137. // if has render and no template, generate return object instead of
  8138. // empty render function (#4980)
  8139. let optionProperties;
  8140. if (defaultExport.declaration.type === 'ObjectExpression') {
  8141. optionProperties = defaultExport.declaration.properties;
  8142. }
  8143. else if (defaultExport.declaration.type === 'CallExpression' &&
  8144. defaultExport.declaration.arguments[0].type === 'ObjectExpression') {
  8145. optionProperties = defaultExport.declaration.arguments[0].properties;
  8146. }
  8147. if (optionProperties) {
  8148. for (const s of optionProperties) {
  8149. if (s.type === 'ObjectProperty' &&
  8150. s.key.type === 'Identifier' &&
  8151. s.key.name === 'name') {
  8152. hasDefaultExportName = true;
  8153. }
  8154. }
  8155. }
  8156. // export default { ... } --> const __default__ = { ... }
  8157. const start = node.start + scriptStartOffset;
  8158. const end = node.declaration.start + scriptStartOffset;
  8159. s.overwrite(start, end, `const ${DEFAULT_VAR} = `);
  8160. }
  8161. else if (node.type === 'ExportNamedDeclaration') {
  8162. const defaultSpecifier = node.specifiers.find(s => s.exported.type === 'Identifier' && s.exported.name === 'default');
  8163. if (defaultSpecifier) {
  8164. defaultExport = node;
  8165. // 1. remove specifier
  8166. if (node.specifiers.length > 1) {
  8167. s.remove(defaultSpecifier.start + scriptStartOffset, defaultSpecifier.end + scriptStartOffset);
  8168. }
  8169. else {
  8170. s.remove(node.start + scriptStartOffset, node.end + scriptStartOffset);
  8171. }
  8172. if (node.source) {
  8173. // export { x as default } from './x'
  8174. // rewrite to `import { x as __default__ } from './x'` and
  8175. // add to top
  8176. s.prepend(`import { ${defaultSpecifier.local.name} as ${DEFAULT_VAR} } from '${node.source.value}'\n`);
  8177. }
  8178. else {
  8179. // export { x as default }
  8180. // rewrite to `const __default__ = x` and move to end
  8181. s.appendLeft(scriptEndOffset, `\nconst ${DEFAULT_VAR} = ${defaultSpecifier.local.name}\n`);
  8182. }
  8183. }
  8184. if (node.declaration) {
  8185. walkDeclaration(node.declaration, scriptBindings, userImportAlias);
  8186. }
  8187. }
  8188. else if ((node.type === 'VariableDeclaration' ||
  8189. node.type === 'FunctionDeclaration' ||
  8190. node.type === 'ClassDeclaration' ||
  8191. node.type === 'TSEnumDeclaration') &&
  8192. !node.declare) {
  8193. walkDeclaration(node, scriptBindings, userImportAlias);
  8194. }
  8195. }
  8196. // apply reactivity transform
  8197. // if (enableReactivityTransform && shouldTransform(script.content)) {
  8198. // const { rootRefs, importedHelpers } = transformAST(
  8199. // scriptAst,
  8200. // s,
  8201. // scriptStartOffset!
  8202. // )
  8203. // refBindings = rootRefs
  8204. // for (const h of importedHelpers) {
  8205. // helperImports.add(h)
  8206. // }
  8207. // }
  8208. // <script> after <script setup>
  8209. // we need to move the block up so that `const __default__` is
  8210. // declared before being used in the actual component definition
  8211. if (scriptStartOffset > startOffset) {
  8212. // if content doesn't end with newline, add one
  8213. if (!/\n$/.test(script.content.trim())) {
  8214. s.appendLeft(scriptEndOffset, `\n`);
  8215. }
  8216. s.move(scriptStartOffset, scriptEndOffset, 0);
  8217. }
  8218. }
  8219. // 2. parse <script setup> and walk over top level statements
  8220. const scriptSetupAst = parse(scriptSetup.content, {
  8221. plugins: [
  8222. ...plugins,
  8223. // allow top level await but only inside <script setup>
  8224. 'topLevelAwait'
  8225. ],
  8226. sourceType: 'module'
  8227. }, startOffset);
  8228. for (const node of scriptSetupAst.body) {
  8229. const start = node.start + startOffset;
  8230. let end = node.end + startOffset;
  8231. // locate comment
  8232. if (node.trailingComments && node.trailingComments.length > 0) {
  8233. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  8234. end = lastCommentNode.end + startOffset;
  8235. }
  8236. // locate the end of whitespace between this statement and the next
  8237. while (end <= source.length) {
  8238. if (!/\s/.test(source.charAt(end))) {
  8239. break;
  8240. }
  8241. end++;
  8242. }
  8243. // (Dropped) `ref: x` bindings
  8244. if (node.type === 'LabeledStatement' &&
  8245. node.label.name === 'ref' &&
  8246. node.body.type === 'ExpressionStatement') {
  8247. error(`ref sugar using the label syntax was an experimental proposal and ` +
  8248. `has been dropped based on community feedback. Please check out ` +
  8249. `the new proposal at https://github.com/vuejs/rfcs/discussions/369`, node);
  8250. }
  8251. if (node.type === 'ImportDeclaration') {
  8252. // import declarations are moved to top
  8253. s.move(start, end, 0);
  8254. // dedupe imports
  8255. let removed = 0;
  8256. const removeSpecifier = (i) => {
  8257. const removeLeft = i > removed;
  8258. removed++;
  8259. const current = node.specifiers[i];
  8260. const next = node.specifiers[i + 1];
  8261. s.remove(removeLeft
  8262. ? node.specifiers[i - 1].end + startOffset
  8263. : current.start + startOffset, next && !removeLeft
  8264. ? next.start + startOffset
  8265. : current.end + startOffset);
  8266. };
  8267. for (let i = 0; i < node.specifiers.length; i++) {
  8268. const specifier = node.specifiers[i];
  8269. const local = specifier.local.name;
  8270. let imported = specifier.type === 'ImportSpecifier' &&
  8271. specifier.imported.type === 'Identifier' &&
  8272. specifier.imported.name;
  8273. if (specifier.type === 'ImportNamespaceSpecifier') {
  8274. imported = '*';
  8275. }
  8276. const source = node.source.value;
  8277. const existing = userImports[local];
  8278. if (source === 'vue' &&
  8279. (imported === DEFINE_PROPS ||
  8280. imported === DEFINE_EMITS ||
  8281. imported === DEFINE_EXPOSE)) {
  8282. warnOnce(`\`${imported}\` is a compiler macro and no longer needs to be imported.`);
  8283. removeSpecifier(i);
  8284. }
  8285. else if (existing) {
  8286. if (existing.source === source && existing.imported === imported) {
  8287. // already imported in <script setup>, dedupe
  8288. removeSpecifier(i);
  8289. }
  8290. else {
  8291. error(`different imports aliased to same local name.`, specifier);
  8292. }
  8293. }
  8294. else {
  8295. registerUserImport(source, local, imported, node.importKind === 'type' ||
  8296. (specifier.type === 'ImportSpecifier' &&
  8297. specifier.importKind === 'type'), true);
  8298. }
  8299. }
  8300. if (node.specifiers.length && removed === node.specifiers.length) {
  8301. s.remove(node.start + startOffset, node.end + startOffset);
  8302. }
  8303. }
  8304. if (node.type === 'ExpressionStatement') {
  8305. // process `defineProps` and `defineEmit(s)` calls
  8306. if (processDefineProps(node.expression) ||
  8307. processDefineEmits(node.expression) ||
  8308. processWithDefaults(node.expression)) {
  8309. s.remove(node.start + startOffset, node.end + startOffset);
  8310. }
  8311. else if (processDefineExpose(node.expression)) {
  8312. // defineExpose({}) -> expose({})
  8313. const callee = node.expression.callee;
  8314. s.overwrite(callee.start + startOffset, callee.end + startOffset, 'expose');
  8315. }
  8316. }
  8317. if (node.type === 'VariableDeclaration' && !node.declare) {
  8318. const total = node.declarations.length;
  8319. let left = total;
  8320. for (let i = 0; i < total; i++) {
  8321. const decl = node.declarations[i];
  8322. if (decl.init) {
  8323. // defineProps / defineEmits
  8324. const isDefineProps = processDefineProps(decl.init, decl.id) ||
  8325. processWithDefaults(decl.init, decl.id);
  8326. const isDefineEmits = processDefineEmits(decl.init, decl.id);
  8327. if (isDefineProps || isDefineEmits) {
  8328. if (left === 1) {
  8329. s.remove(node.start + startOffset, node.end + startOffset);
  8330. }
  8331. else {
  8332. let start = decl.start + startOffset;
  8333. let end = decl.end + startOffset;
  8334. if (i < total - 1) {
  8335. // not the last one, locate the start of the next
  8336. end = node.declarations[i + 1].start + startOffset;
  8337. }
  8338. else {
  8339. // last one, locate the end of the prev
  8340. start = node.declarations[i - 1].end + startOffset;
  8341. }
  8342. s.remove(start, end);
  8343. left--;
  8344. }
  8345. }
  8346. }
  8347. }
  8348. }
  8349. // walk declarations to record declared bindings
  8350. if ((node.type === 'VariableDeclaration' ||
  8351. node.type === 'FunctionDeclaration' ||
  8352. node.type === 'ClassDeclaration') &&
  8353. !node.declare) {
  8354. walkDeclaration(node, setupBindings, userImportAlias);
  8355. }
  8356. // walk statements & named exports / variable declarations for top level
  8357. // await
  8358. if ((node.type === 'VariableDeclaration' && !node.declare) ||
  8359. node.type.endsWith('Statement')) {
  8360. const scope = [scriptSetupAst.body];
  8361. walk$1(node, {
  8362. enter(child, parent) {
  8363. if (isFunctionType(child)) {
  8364. this.skip();
  8365. }
  8366. if (child.type === 'BlockStatement') {
  8367. scope.push(child.body);
  8368. }
  8369. if (child.type === 'AwaitExpression') {
  8370. error(`Vue 2 does not support top level await in <script setup>.`, child);
  8371. }
  8372. },
  8373. exit(node) {
  8374. if (node.type === 'BlockStatement')
  8375. scope.pop();
  8376. }
  8377. });
  8378. }
  8379. if ((node.type === 'ExportNamedDeclaration' && node.exportKind !== 'type') ||
  8380. node.type === 'ExportAllDeclaration' ||
  8381. node.type === 'ExportDefaultDeclaration') {
  8382. error(`<script setup> cannot contain ES module exports. ` +
  8383. `If you are using a previous version of <script setup>, please ` +
  8384. `consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`, node);
  8385. }
  8386. if (isTS) {
  8387. // runtime enum
  8388. if (node.type === 'TSEnumDeclaration') {
  8389. registerBinding(setupBindings, node.id, "setup-const" /* BindingTypes.SETUP_CONST */);
  8390. }
  8391. // move all Type declarations to outer scope
  8392. if (node.type.startsWith('TS') ||
  8393. (node.type === 'ExportNamedDeclaration' &&
  8394. node.exportKind === 'type') ||
  8395. (node.type === 'VariableDeclaration' && node.declare)) {
  8396. recordType(node, declaredTypes);
  8397. s.move(start, end, 0);
  8398. }
  8399. }
  8400. }
  8401. // 3. Apply reactivity transform
  8402. // if (
  8403. // (enableReactivityTransform &&
  8404. // // normal <script> had ref bindings that maybe used in <script setup>
  8405. // (refBindings || shouldTransform(scriptSetup.content))) ||
  8406. // propsDestructureDecl
  8407. // ) {
  8408. // const { rootRefs, importedHelpers } = transformAST(
  8409. // scriptSetupAst,
  8410. // s,
  8411. // startOffset,
  8412. // refBindings,
  8413. // propsDestructuredBindings
  8414. // )
  8415. // refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs
  8416. // for (const h of importedHelpers) {
  8417. // helperImports.add(h)
  8418. // }
  8419. // }
  8420. // 4. extract runtime props/emits code from setup context type
  8421. if (propsTypeDecl) {
  8422. extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes);
  8423. }
  8424. if (emitsTypeDecl) {
  8425. extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits);
  8426. }
  8427. // 5. check useOptions args to make sure it doesn't reference setup scope
  8428. // variables
  8429. checkInvalidScopeReference(propsRuntimeDecl, DEFINE_PROPS);
  8430. checkInvalidScopeReference(propsRuntimeDefaults, DEFINE_PROPS);
  8431. checkInvalidScopeReference(propsDestructureDecl, DEFINE_PROPS);
  8432. checkInvalidScopeReference(emitsRuntimeDecl, DEFINE_EMITS);
  8433. // 6. remove non-script content
  8434. if (script) {
  8435. if (startOffset < scriptStartOffset) {
  8436. // <script setup> before <script>
  8437. s.remove(0, startOffset);
  8438. s.remove(endOffset, scriptStartOffset);
  8439. s.remove(scriptEndOffset, source.length);
  8440. }
  8441. else {
  8442. // <script> before <script setup>
  8443. s.remove(0, scriptStartOffset);
  8444. s.remove(scriptEndOffset, startOffset);
  8445. s.remove(endOffset, source.length);
  8446. }
  8447. }
  8448. else {
  8449. // only <script setup>
  8450. s.remove(0, startOffset);
  8451. s.remove(endOffset, source.length);
  8452. }
  8453. // 7. analyze binding metadata
  8454. if (scriptAst) {
  8455. Object.assign(bindingMetadata, analyzeScriptBindings(scriptAst.body));
  8456. }
  8457. if (propsRuntimeDecl) {
  8458. for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
  8459. bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
  8460. }
  8461. }
  8462. for (const key in typeDeclaredProps) {
  8463. bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
  8464. }
  8465. // props aliases
  8466. // if (propsDestructureDecl) {
  8467. // if (propsDestructureRestId) {
  8468. // bindingMetadata[propsDestructureRestId] =
  8469. // BindingTypes.SETUP_REACTIVE_CONST
  8470. // }
  8471. // for (const key in propsDestructuredBindings) {
  8472. // const { local } = propsDestructuredBindings[key]
  8473. // if (local !== key) {
  8474. // bindingMetadata[local] = BindingTypes.PROPS_ALIASED
  8475. // ;(bindingMetadata.__propsAliases ||
  8476. // (bindingMetadata.__propsAliases = {}))[local] = key
  8477. // }
  8478. // }
  8479. // }
  8480. for (const [key, { isType, imported, source }] of Object.entries(userImports)) {
  8481. if (isType)
  8482. continue;
  8483. bindingMetadata[key] =
  8484. imported === '*' ||
  8485. (imported === 'default' && source.endsWith('.vue')) ||
  8486. source === 'vue'
  8487. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8488. : "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
  8489. }
  8490. for (const key in scriptBindings) {
  8491. bindingMetadata[key] = scriptBindings[key];
  8492. }
  8493. for (const key in setupBindings) {
  8494. bindingMetadata[key] = setupBindings[key];
  8495. }
  8496. // 8. inject `useCssVars` calls
  8497. if (cssVars.length) {
  8498. helperImports.add(CSS_VARS_HELPER);
  8499. s.prependRight(startOffset, `\n${genCssVarsCode(cssVars, bindingMetadata, scopeId, isProd)}\n`);
  8500. }
  8501. // 9. finalize setup() argument signature
  8502. let args = `__props`;
  8503. if (propsTypeDecl) {
  8504. // mark as any and only cast on assignment
  8505. // since the user defined complex types may be incompatible with the
  8506. // inferred type from generated runtime declarations
  8507. args += `: any`;
  8508. }
  8509. // inject user assignment of props
  8510. // we use a default __props so that template expressions referencing props
  8511. // can use it directly
  8512. if (propsIdentifier) {
  8513. s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}\n`);
  8514. }
  8515. const destructureElements = hasDefineExposeCall ? [`expose`] : [];
  8516. if (emitIdentifier) {
  8517. destructureElements.push(emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}`);
  8518. }
  8519. if (destructureElements.length) {
  8520. args += `, { ${destructureElements.join(', ')} }`;
  8521. if (emitsTypeDecl) {
  8522. args += `: { emit: (${scriptSetup.content.slice(emitsTypeDecl.start, emitsTypeDecl.end)}), expose: any, slots: any, attrs: any }`;
  8523. }
  8524. }
  8525. // 10. generate return statement
  8526. const allBindings = Object.assign(Object.assign({}, scriptBindings), setupBindings);
  8527. for (const key in userImports) {
  8528. if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
  8529. allBindings[key] = true;
  8530. }
  8531. }
  8532. // __sfc marker indicates these bindings are compiled from <script setup>
  8533. // and should not be proxied on `this`
  8534. const returned = `{ ${`__sfc: true,`}${Object.keys(allBindings).join(', ')} }`;
  8535. s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`);
  8536. // 11. finalize default export
  8537. let runtimeOptions = ``;
  8538. if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  8539. const match = filename.match(/([^/\\]+)\.\w+$/);
  8540. if (match) {
  8541. runtimeOptions += `\n __name: '${match[1]}',`;
  8542. }
  8543. }
  8544. if (propsRuntimeDecl) {
  8545. let declCode = scriptSetup.content
  8546. .slice(propsRuntimeDecl.start, propsRuntimeDecl.end)
  8547. .trim();
  8548. runtimeOptions += `\n props: ${declCode},`;
  8549. }
  8550. else if (propsTypeDecl) {
  8551. runtimeOptions += genRuntimeProps(typeDeclaredProps);
  8552. }
  8553. if (emitsRuntimeDecl) {
  8554. runtimeOptions += `\n emits: ${scriptSetup.content
  8555. .slice(emitsRuntimeDecl.start, emitsRuntimeDecl.end)
  8556. .trim()},`;
  8557. }
  8558. else if (emitsTypeDecl) {
  8559. runtimeOptions += genRuntimeEmits(typeDeclaredEmits);
  8560. }
  8561. // wrap setup code with function.
  8562. if (isTS) {
  8563. // for TS, make sure the exported type is still valid type with
  8564. // correct props information
  8565. // we have to use object spread for types to be merged properly
  8566. // user's TS setting should compile it down to proper targets
  8567. // export default defineComponent({ ...__default__, ... })
  8568. const def = defaultExport ? `\n ...${DEFAULT_VAR},` : ``;
  8569. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup(${args}) {\n`);
  8570. s.appendRight(endOffset, `})`);
  8571. }
  8572. else {
  8573. if (defaultExport) {
  8574. // without TS, can't rely on rest spread, so we use Object.assign
  8575. // export default Object.assign(__default__, { ... })
  8576. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/Object.assign(${DEFAULT_VAR}, {${runtimeOptions}\n ` +
  8577. `setup(${args}) {\n`);
  8578. s.appendRight(endOffset, `})`);
  8579. }
  8580. else {
  8581. s.prependLeft(startOffset, `\nexport default {${runtimeOptions}\n setup(${args}) {\n`);
  8582. s.appendRight(endOffset, `}`);
  8583. }
  8584. }
  8585. // 12. finalize Vue helper imports
  8586. if (helperImports.size > 0) {
  8587. s.prepend(`import { ${[...helperImports]
  8588. .map(h => `${h} as _${h}`)
  8589. .join(', ')} } from 'vue'\n`);
  8590. }
  8591. s.trim();
  8592. return Object.assign(Object.assign({}, scriptSetup), { bindings: bindingMetadata, imports: userImports, content: s.toString(), map: genSourceMap
  8593. ? s.generateMap({
  8594. source: filename,
  8595. hires: true,
  8596. includeContent: true
  8597. })
  8598. : undefined, scriptAst: scriptAst === null || scriptAst === void 0 ? void 0 : scriptAst.body, scriptSetupAst: scriptSetupAst === null || scriptSetupAst === void 0 ? void 0 : scriptSetupAst.body });
  8599. }
  8600. function registerBinding(bindings, node, type) {
  8601. bindings[node.name] = type;
  8602. }
  8603. function walkDeclaration(node, bindings, userImportAlias) {
  8604. if (node.type === 'VariableDeclaration') {
  8605. const isConst = node.kind === 'const';
  8606. // export const foo = ...
  8607. for (const { id, init } of node.declarations) {
  8608. const isDefineCall = !!(isConst &&
  8609. isCallOf(init, c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS));
  8610. if (id.type === 'Identifier') {
  8611. let bindingType;
  8612. const userReactiveBinding = userImportAlias['reactive'] || 'reactive';
  8613. if (isCallOf(init, userReactiveBinding)) {
  8614. // treat reactive() calls as let since it's meant to be mutable
  8615. bindingType = isConst
  8616. ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
  8617. : "setup-let" /* BindingTypes.SETUP_LET */;
  8618. }
  8619. else if (
  8620. // if a declaration is a const literal, we can mark it so that
  8621. // the generated render fn code doesn't need to unref() it
  8622. isDefineCall ||
  8623. (isConst && canNeverBeRef(init, userReactiveBinding))) {
  8624. bindingType = isCallOf(init, DEFINE_PROPS)
  8625. ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
  8626. : "setup-const" /* BindingTypes.SETUP_CONST */;
  8627. }
  8628. else if (isConst) {
  8629. if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
  8630. bindingType = "setup-ref" /* BindingTypes.SETUP_REF */;
  8631. }
  8632. else {
  8633. bindingType = "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
  8634. }
  8635. }
  8636. else {
  8637. bindingType = "setup-let" /* BindingTypes.SETUP_LET */;
  8638. }
  8639. registerBinding(bindings, id, bindingType);
  8640. }
  8641. else {
  8642. if (isCallOf(init, DEFINE_PROPS)) {
  8643. // skip walking props destructure
  8644. return;
  8645. }
  8646. if (id.type === 'ObjectPattern') {
  8647. walkObjectPattern(id, bindings, isConst, isDefineCall);
  8648. }
  8649. else if (id.type === 'ArrayPattern') {
  8650. walkArrayPattern(id, bindings, isConst, isDefineCall);
  8651. }
  8652. }
  8653. }
  8654. }
  8655. else if (node.type === 'TSEnumDeclaration' ||
  8656. node.type === 'FunctionDeclaration' ||
  8657. node.type === 'ClassDeclaration') {
  8658. // export function foo() {} / export class Foo {}
  8659. // export declarations must be named.
  8660. bindings[node.id.name] = "setup-const" /* BindingTypes.SETUP_CONST */;
  8661. }
  8662. }
  8663. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  8664. for (const p of node.properties) {
  8665. if (p.type === 'ObjectProperty') {
  8666. if (p.key.type === 'Identifier' && p.key === p.value) {
  8667. // shorthand: const { x } = ...
  8668. const type = isDefineCall
  8669. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8670. : isConst
  8671. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8672. : "setup-let" /* BindingTypes.SETUP_LET */;
  8673. registerBinding(bindings, p.key, type);
  8674. }
  8675. else {
  8676. walkPattern(p.value, bindings, isConst, isDefineCall);
  8677. }
  8678. }
  8679. else {
  8680. // ...rest
  8681. // argument can only be identifier when destructuring
  8682. const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
  8683. registerBinding(bindings, p.argument, type);
  8684. }
  8685. }
  8686. }
  8687. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  8688. for (const e of node.elements) {
  8689. e && walkPattern(e, bindings, isConst, isDefineCall);
  8690. }
  8691. }
  8692. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  8693. if (node.type === 'Identifier') {
  8694. const type = isDefineCall
  8695. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8696. : isConst
  8697. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8698. : "setup-let" /* BindingTypes.SETUP_LET */;
  8699. registerBinding(bindings, node, type);
  8700. }
  8701. else if (node.type === 'RestElement') {
  8702. // argument can only be identifier when destructuring
  8703. const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
  8704. registerBinding(bindings, node.argument, type);
  8705. }
  8706. else if (node.type === 'ObjectPattern') {
  8707. walkObjectPattern(node, bindings, isConst);
  8708. }
  8709. else if (node.type === 'ArrayPattern') {
  8710. walkArrayPattern(node, bindings, isConst);
  8711. }
  8712. else if (node.type === 'AssignmentPattern') {
  8713. if (node.left.type === 'Identifier') {
  8714. const type = isDefineCall
  8715. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8716. : isConst
  8717. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8718. : "setup-let" /* BindingTypes.SETUP_LET */;
  8719. registerBinding(bindings, node.left, type);
  8720. }
  8721. else {
  8722. walkPattern(node.left, bindings, isConst);
  8723. }
  8724. }
  8725. }
  8726. function recordType(node, declaredTypes) {
  8727. if (node.type === 'TSInterfaceDeclaration') {
  8728. declaredTypes[node.id.name] = [`Object`];
  8729. }
  8730. else if (node.type === 'TSTypeAliasDeclaration') {
  8731. declaredTypes[node.id.name] = inferRuntimeType(node.typeAnnotation, declaredTypes);
  8732. }
  8733. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  8734. recordType(node.declaration, declaredTypes);
  8735. }
  8736. }
  8737. function extractRuntimeProps(node, props, declaredTypes, isProd) {
  8738. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8739. for (const m of members) {
  8740. if ((m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
  8741. m.key.type === 'Identifier') {
  8742. let type;
  8743. if (m.type === 'TSMethodSignature') {
  8744. type = ['Function'];
  8745. }
  8746. else if (m.typeAnnotation) {
  8747. type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
  8748. }
  8749. props[m.key.name] = {
  8750. key: m.key.name,
  8751. required: !m.optional,
  8752. type: type || [`null`]
  8753. };
  8754. }
  8755. }
  8756. }
  8757. function inferRuntimeType(node, declaredTypes) {
  8758. switch (node.type) {
  8759. case 'TSStringKeyword':
  8760. return ['String'];
  8761. case 'TSNumberKeyword':
  8762. return ['Number'];
  8763. case 'TSBooleanKeyword':
  8764. return ['Boolean'];
  8765. case 'TSObjectKeyword':
  8766. return ['Object'];
  8767. case 'TSTypeLiteral':
  8768. // TODO (nice to have) generate runtime property validation
  8769. return ['Object'];
  8770. case 'TSFunctionType':
  8771. return ['Function'];
  8772. case 'TSArrayType':
  8773. case 'TSTupleType':
  8774. // TODO (nice to have) generate runtime element type/length checks
  8775. return ['Array'];
  8776. case 'TSLiteralType':
  8777. switch (node.literal.type) {
  8778. case 'StringLiteral':
  8779. return ['String'];
  8780. case 'BooleanLiteral':
  8781. return ['Boolean'];
  8782. case 'NumericLiteral':
  8783. case 'BigIntLiteral':
  8784. return ['Number'];
  8785. default:
  8786. return [`null`];
  8787. }
  8788. case 'TSTypeReference':
  8789. if (node.typeName.type === 'Identifier') {
  8790. if (declaredTypes[node.typeName.name]) {
  8791. return declaredTypes[node.typeName.name];
  8792. }
  8793. switch (node.typeName.name) {
  8794. case 'Array':
  8795. case 'Function':
  8796. case 'Object':
  8797. case 'Set':
  8798. case 'Map':
  8799. case 'WeakSet':
  8800. case 'WeakMap':
  8801. case 'Date':
  8802. case 'Promise':
  8803. return [node.typeName.name];
  8804. case 'Record':
  8805. case 'Partial':
  8806. case 'Readonly':
  8807. case 'Pick':
  8808. case 'Omit':
  8809. case 'Exclude':
  8810. case 'Extract':
  8811. case 'Required':
  8812. case 'InstanceType':
  8813. return ['Object'];
  8814. }
  8815. }
  8816. return [`null`];
  8817. case 'TSParenthesizedType':
  8818. return inferRuntimeType(node.typeAnnotation, declaredTypes);
  8819. case 'TSUnionType':
  8820. return [
  8821. ...new Set([].concat(...node.types.map(t => inferRuntimeType(t, declaredTypes))))
  8822. ];
  8823. case 'TSIntersectionType':
  8824. return ['Object'];
  8825. case 'TSSymbolKeyword':
  8826. return ['Symbol'];
  8827. default:
  8828. return [`null`]; // no runtime check
  8829. }
  8830. }
  8831. function toRuntimeTypeString(types) {
  8832. return types.length > 1 ? `[${types.join(', ')}]` : types[0];
  8833. }
  8834. function extractRuntimeEmits(node, emits) {
  8835. if (node.type === 'TSTypeLiteral' || node.type === 'TSInterfaceBody') {
  8836. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8837. for (let t of members) {
  8838. if (t.type === 'TSCallSignatureDeclaration') {
  8839. extractEventNames(t.parameters[0], emits);
  8840. }
  8841. }
  8842. return;
  8843. }
  8844. else {
  8845. extractEventNames(node.parameters[0], emits);
  8846. }
  8847. }
  8848. function extractEventNames(eventName, emits) {
  8849. if (eventName.type === 'Identifier' &&
  8850. eventName.typeAnnotation &&
  8851. eventName.typeAnnotation.type === 'TSTypeAnnotation') {
  8852. const typeNode = eventName.typeAnnotation.typeAnnotation;
  8853. if (typeNode.type === 'TSLiteralType') {
  8854. if (typeNode.literal.type !== 'UnaryExpression' &&
  8855. typeNode.literal.type !== 'TemplateLiteral') {
  8856. emits.add(String(typeNode.literal.value));
  8857. }
  8858. }
  8859. else if (typeNode.type === 'TSUnionType') {
  8860. for (const t of typeNode.types) {
  8861. if (t.type === 'TSLiteralType' &&
  8862. t.literal.type !== 'UnaryExpression' &&
  8863. t.literal.type !== 'TemplateLiteral') {
  8864. emits.add(String(t.literal.value));
  8865. }
  8866. }
  8867. }
  8868. }
  8869. }
  8870. function genRuntimeEmits(emits) {
  8871. return emits.size
  8872. ? `\n emits: [${Array.from(emits)
  8873. .map(p => JSON.stringify(p))
  8874. .join(', ')}],`
  8875. : ``;
  8876. }
  8877. function isCallOf(node, test) {
  8878. return !!(node &&
  8879. node.type === 'CallExpression' &&
  8880. node.callee.type === 'Identifier' &&
  8881. (typeof test === 'string'
  8882. ? node.callee.name === test
  8883. : test(node.callee.name)));
  8884. }
  8885. function canNeverBeRef(node, userReactiveImport) {
  8886. if (isCallOf(node, userReactiveImport)) {
  8887. return true;
  8888. }
  8889. switch (node.type) {
  8890. case 'UnaryExpression':
  8891. case 'BinaryExpression':
  8892. case 'ArrayExpression':
  8893. case 'ObjectExpression':
  8894. case 'FunctionExpression':
  8895. case 'ArrowFunctionExpression':
  8896. case 'UpdateExpression':
  8897. case 'ClassExpression':
  8898. case 'TaggedTemplateExpression':
  8899. return true;
  8900. case 'SequenceExpression':
  8901. return canNeverBeRef(node.expressions[node.expressions.length - 1], userReactiveImport);
  8902. default:
  8903. if (node.type.endsWith('Literal')) {
  8904. return true;
  8905. }
  8906. return false;
  8907. }
  8908. }
  8909. /**
  8910. * Analyze bindings in normal `<script>`
  8911. * Note that `compileScriptSetup` already analyzes bindings as part of its
  8912. * compilation process so this should only be used on single `<script>` SFCs.
  8913. */
  8914. function analyzeScriptBindings(ast) {
  8915. for (const node of ast) {
  8916. if (node.type === 'ExportDefaultDeclaration' &&
  8917. node.declaration.type === 'ObjectExpression') {
  8918. return analyzeBindingsFromOptions(node.declaration);
  8919. }
  8920. }
  8921. return {};
  8922. }
  8923. function analyzeBindingsFromOptions(node) {
  8924. const bindings = {};
  8925. // #3270, #3275
  8926. // mark non-script-setup so we don't resolve components/directives from these
  8927. Object.defineProperty(bindings, '__isScriptSetup', {
  8928. enumerable: false,
  8929. value: false
  8930. });
  8931. for (const property of node.properties) {
  8932. if (property.type === 'ObjectProperty' &&
  8933. !property.computed &&
  8934. property.key.type === 'Identifier') {
  8935. // props
  8936. if (property.key.name === 'props') {
  8937. // props: ['foo']
  8938. // props: { foo: ... }
  8939. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  8940. bindings[key] = "props" /* BindingTypes.PROPS */;
  8941. }
  8942. }
  8943. // inject
  8944. else if (property.key.name === 'inject') {
  8945. // inject: ['foo']
  8946. // inject: { foo: {} }
  8947. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  8948. bindings[key] = "options" /* BindingTypes.OPTIONS */;
  8949. }
  8950. }
  8951. // computed & methods
  8952. else if (property.value.type === 'ObjectExpression' &&
  8953. (property.key.name === 'computed' || property.key.name === 'methods')) {
  8954. // methods: { foo() {} }
  8955. // computed: { foo() {} }
  8956. for (const key of getObjectExpressionKeys(property.value)) {
  8957. bindings[key] = "options" /* BindingTypes.OPTIONS */;
  8958. }
  8959. }
  8960. }
  8961. // setup & data
  8962. else if (property.type === 'ObjectMethod' &&
  8963. property.key.type === 'Identifier' &&
  8964. (property.key.name === 'setup' || property.key.name === 'data')) {
  8965. for (const bodyItem of property.body.body) {
  8966. // setup() {
  8967. // return {
  8968. // foo: null
  8969. // }
  8970. // }
  8971. if (bodyItem.type === 'ReturnStatement' &&
  8972. bodyItem.argument &&
  8973. bodyItem.argument.type === 'ObjectExpression') {
  8974. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  8975. bindings[key] =
  8976. property.key.name === 'setup'
  8977. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8978. : "data" /* BindingTypes.DATA */;
  8979. }
  8980. }
  8981. }
  8982. }
  8983. }
  8984. return bindings;
  8985. }
  8986. function getObjectExpressionKeys(node) {
  8987. const keys = [];
  8988. for (const prop of node.properties) {
  8989. if ((prop.type === 'ObjectProperty' || prop.type === 'ObjectMethod') &&
  8990. !prop.computed) {
  8991. if (prop.key.type === 'Identifier') {
  8992. keys.push(prop.key.name);
  8993. }
  8994. else if (prop.key.type === 'StringLiteral') {
  8995. keys.push(prop.key.value);
  8996. }
  8997. }
  8998. }
  8999. return keys;
  9000. }
  9001. function getArrayExpressionKeys(node) {
  9002. const keys = [];
  9003. for (const element of node.elements) {
  9004. if (element && element.type === 'StringLiteral') {
  9005. keys.push(element.value);
  9006. }
  9007. }
  9008. return keys;
  9009. }
  9010. function getObjectOrArrayExpressionKeys(value) {
  9011. if (value.type === 'ArrayExpression') {
  9012. return getArrayExpressionKeys(value);
  9013. }
  9014. if (value.type === 'ObjectExpression') {
  9015. return getObjectExpressionKeys(value);
  9016. }
  9017. return [];
  9018. }
  9019. const templateUsageCheckCache = new lruCache(512);
  9020. function resolveTemplateUsageCheckString(sfc, isTS) {
  9021. const { content } = sfc.template;
  9022. const cached = templateUsageCheckCache.get(content);
  9023. if (cached) {
  9024. return cached;
  9025. }
  9026. let code = '';
  9027. parseHTML(content, Object.assign(Object.assign({}, baseOptions), { start(tag, attrs) {
  9028. if (!isBuiltInTag(tag) && !isReservedTag(tag)) {
  9029. code += `,${camelize(tag)},${capitalize(camelize(tag))}`;
  9030. }
  9031. for (let i = 0; i < attrs.length; i++) {
  9032. const { name, value } = attrs[i];
  9033. if (dirRE.test(name)) {
  9034. const baseName = onRE.test(name)
  9035. ? 'on'
  9036. : bindRE.test(name)
  9037. ? 'bind'
  9038. : name.replace(dirRE, '');
  9039. if (!isBuiltInDir$1(baseName)) {
  9040. code += `,v${capitalize(camelize(baseName))}`;
  9041. }
  9042. if (value) {
  9043. code += `,${processExp(value, isTS, baseName)}`;
  9044. }
  9045. }
  9046. }
  9047. },
  9048. chars(text) {
  9049. const res = parseText(text);
  9050. if (res) {
  9051. code += `,${processExp(res.expression, isTS)}`;
  9052. }
  9053. } }));
  9054. code += ';';
  9055. templateUsageCheckCache.set(content, code);
  9056. return code;
  9057. }
  9058. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9059. function processExp(exp, isTS, dir) {
  9060. if (isTS && / as\s+\w|<.*>|:/.test(exp)) {
  9061. if (dir === 'slot') {
  9062. exp = `(${exp})=>{}`;
  9063. }
  9064. else if (dir === 'on') {
  9065. exp = `()=>{${exp}}`;
  9066. }
  9067. else if (dir === 'for') {
  9068. const inMatch = exp.match(forAliasRE);
  9069. if (inMatch) {
  9070. const [, LHS, RHS] = inMatch;
  9071. return processExp(`(${LHS})=>{}`, true) + processExp(RHS, true);
  9072. }
  9073. }
  9074. let ret = '';
  9075. // has potential type cast or generic arguments that uses types
  9076. const ast = parser$1.parseExpression(exp, { plugins: ['typescript'] });
  9077. walkIdentifiers(ast, node => {
  9078. ret += `,` + node.name;
  9079. });
  9080. return ret;
  9081. }
  9082. return stripStrings(exp);
  9083. }
  9084. function stripStrings(exp) {
  9085. return exp
  9086. .replace(/'[^']*'|"[^"]*"/g, '')
  9087. .replace(/`[^`]+`/g, stripTemplateString);
  9088. }
  9089. function stripTemplateString(str) {
  9090. const interpMatch = str.match(/\${[^}]+}/g);
  9091. if (interpMatch) {
  9092. return interpMatch.map(m => m.slice(2, -1)).join(',');
  9093. }
  9094. return '';
  9095. }
  9096. function isImportUsed(local, sfc, isTS) {
  9097. return new RegExp(
  9098. // #4274 escape $ since it's a special char in regex
  9099. // (and is the only regex special char that is valid in identifiers)
  9100. `[^\\w$_]${local.replace(/\$/g, '\\$')}[^\\w$_]`).test(resolveTemplateUsageCheckString(sfc, isTS));
  9101. }
  9102. /**
  9103. * Note: this comparison assumes the prev/next script are already identical,
  9104. * and only checks the special case where <script setup> unused import
  9105. * pruning result changes due to template changes.
  9106. */
  9107. function hmrShouldReload(prevImports, next) {
  9108. if (!next.scriptSetup) {
  9109. return false;
  9110. }
  9111. const isTS = next.scriptSetup.lang === 'ts' || next.scriptSetup.lang === 'tsx';
  9112. // for each previous import, check if its used status remain the same based on
  9113. // the next descriptor's template
  9114. for (const key in prevImports) {
  9115. // if an import was previous unused, but now is used, we need to force
  9116. // reload so that the script now includes that import.
  9117. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next, isTS)) {
  9118. return true;
  9119. }
  9120. }
  9121. return false;
  9122. }
  9123. const cache = new lruCache(100);
  9124. const splitRE = /\r?\n/g;
  9125. const emptyRE = /^(?:\/\/)?\s*$/;
  9126. function parse(options) {
  9127. const { source, filename = DEFAULT_FILENAME, compiler, compilerParseOptions = { pad: false }, sourceRoot = '', needMap = true, sourceMap = needMap } = options;
  9128. const cacheKey = hashSum(filename + source + JSON.stringify(compilerParseOptions));
  9129. let output = cache.get(cacheKey);
  9130. if (output) {
  9131. return output;
  9132. }
  9133. if (compiler) {
  9134. // user-provided compiler
  9135. output = compiler.parseComponent(source, compilerParseOptions);
  9136. }
  9137. else {
  9138. // use built-in compiler
  9139. output = parseComponent(source, compilerParseOptions);
  9140. }
  9141. output.filename = filename;
  9142. // parse CSS vars
  9143. output.cssVars = parseCssVars(output);
  9144. output.shouldForceReload = prevImports => hmrShouldReload(prevImports, output);
  9145. if (sourceMap) {
  9146. if (output.script && !output.script.src) {
  9147. output.script.map = generateSourceMap(filename, source, output.script.content, sourceRoot, compilerParseOptions.pad);
  9148. }
  9149. if (output.styles) {
  9150. output.styles.forEach(style => {
  9151. if (!style.src) {
  9152. style.map = generateSourceMap(filename, source, style.content, sourceRoot, compilerParseOptions.pad);
  9153. }
  9154. });
  9155. }
  9156. }
  9157. cache.set(cacheKey, output);
  9158. return output;
  9159. }
  9160. function generateSourceMap(filename, source, generated, sourceRoot, pad) {
  9161. const map = new require$$0.SourceMapGenerator({
  9162. file: filename.replace(/\\/g, '/'),
  9163. sourceRoot: sourceRoot.replace(/\\/g, '/')
  9164. });
  9165. let offset = 0;
  9166. if (!pad) {
  9167. offset = source.split(generated).shift().split(splitRE).length - 1;
  9168. }
  9169. map.setSourceContent(filename, source);
  9170. generated.split(splitRE).forEach((line, index) => {
  9171. if (!emptyRE.test(line)) {
  9172. map.addMapping({
  9173. source: filename,
  9174. original: {
  9175. line: index + 1 + offset,
  9176. column: 0
  9177. },
  9178. generated: {
  9179. line: index + 1,
  9180. column: 0
  9181. }
  9182. });
  9183. }
  9184. });
  9185. return JSON.parse(map.toString());
  9186. }
  9187. function urlToRequire(url, transformAssetUrlsOption = {}) {
  9188. const returnValue = `"${url}"`;
  9189. // same logic as in transform-require.js
  9190. const firstChar = url.charAt(0);
  9191. if (firstChar === '~') {
  9192. const secondChar = url.charAt(1);
  9193. url = url.slice(secondChar === '/' ? 2 : 1);
  9194. }
  9195. if (isExternalUrl(url) || isDataUrl(url) || firstChar === '#') {
  9196. return returnValue;
  9197. }
  9198. const uriParts = parseUriParts(url);
  9199. if (transformAssetUrlsOption.base) {
  9200. // explicit base - directly rewrite the url into absolute url
  9201. // does not apply to absolute urls or urls that start with `@`
  9202. // since they are aliases
  9203. if (firstChar === '.' || firstChar === '~') {
  9204. // Allow for full hostnames provided in options.base
  9205. const base = parseUriParts(transformAssetUrlsOption.base);
  9206. const protocol = base.protocol || '';
  9207. const host = base.host ? protocol + '//' + base.host : '';
  9208. const basePath = base.path || '/';
  9209. // when packaged in the browser, path will be using the posix-
  9210. // only version provided by rollup-plugin-node-builtins.
  9211. return `"${host}${(path__default["default"].posix || path__default["default"]).join(basePath, uriParts.path + (uriParts.hash || ''))}"`;
  9212. }
  9213. }
  9214. if (transformAssetUrlsOption.includeAbsolute ||
  9215. firstChar === '.' ||
  9216. firstChar === '~' ||
  9217. firstChar === '@') {
  9218. if (!uriParts.hash) {
  9219. return `require("${url}")`;
  9220. }
  9221. else {
  9222. // support uri fragment case by excluding it from
  9223. // the require and instead appending it as string;
  9224. // assuming that the path part is sufficient according to
  9225. // the above caseing(t.i. no protocol-auth-host parts expected)
  9226. return `require("${uriParts.path}") + "${uriParts.hash}"`;
  9227. }
  9228. }
  9229. return returnValue;
  9230. }
  9231. /**
  9232. * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
  9233. * @param urlString an url as a string
  9234. */
  9235. function parseUriParts(urlString) {
  9236. // initialize return value
  9237. const returnValue = url.parse('');
  9238. if (urlString) {
  9239. // A TypeError is thrown if urlString is not a string
  9240. // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
  9241. if ('string' === typeof urlString) {
  9242. // check is an uri
  9243. return url.parse(urlString, false, true); // take apart the uri
  9244. }
  9245. }
  9246. return returnValue;
  9247. }
  9248. const externalRE = /^(https?:)?\/\//;
  9249. function isExternalUrl(url) {
  9250. return externalRE.test(url);
  9251. }
  9252. const dataUrlRE = /^\s*data:/i;
  9253. function isDataUrl(url) {
  9254. return dataUrlRE.test(url);
  9255. }
  9256. // vue compiler module for transforming `<tag>:<attribute>` to `require`
  9257. const defaultOptions = {
  9258. audio: 'src',
  9259. video: ['src', 'poster'],
  9260. source: 'src',
  9261. img: 'src',
  9262. image: ['xlink:href', 'href'],
  9263. use: ['xlink:href', 'href']
  9264. };
  9265. var assetUrlsModule = (userOptions, transformAssetUrlsOption) => {
  9266. const options = userOptions
  9267. ? Object.assign({}, defaultOptions, userOptions)
  9268. : defaultOptions;
  9269. return {
  9270. postTransformNode: (node) => {
  9271. transform$1(node, options, transformAssetUrlsOption);
  9272. }
  9273. };
  9274. };
  9275. function transform$1(node, options, transformAssetUrlsOption) {
  9276. if (node.type !== 1 || !node.attrs)
  9277. return;
  9278. for (const tag in options) {
  9279. if (tag === '*' || node.tag === tag) {
  9280. const attributes = options[tag];
  9281. if (typeof attributes === 'string') {
  9282. node.attrs.some(attr => rewrite(attr, attributes, transformAssetUrlsOption));
  9283. }
  9284. else if (Array.isArray(attributes)) {
  9285. attributes.forEach(item => node.attrs.some(attr => rewrite(attr, item, transformAssetUrlsOption)));
  9286. }
  9287. }
  9288. }
  9289. }
  9290. function rewrite(attr, name, transformAssetUrlsOption) {
  9291. if (attr.name === name) {
  9292. const value = attr.value;
  9293. // only transform static URLs
  9294. if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
  9295. attr.value = urlToRequire(value.slice(1, -1), transformAssetUrlsOption);
  9296. return true;
  9297. }
  9298. }
  9299. return false;
  9300. }
  9301. // vue compiler module for transforming `img:srcset` to a number of `require`s
  9302. var srcsetModule = (transformAssetUrlsOptions) => ({
  9303. postTransformNode: (node) => {
  9304. transform(node, transformAssetUrlsOptions);
  9305. }
  9306. });
  9307. // http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
  9308. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  9309. function transform(node, transformAssetUrlsOptions) {
  9310. if (node.type !== 1 || !node.attrs) {
  9311. return;
  9312. }
  9313. if (node.tag === 'img' || node.tag === 'source') {
  9314. node.attrs.forEach(attr => {
  9315. if (attr.name === 'srcset') {
  9316. // same logic as in transform-require.js
  9317. const value = attr.value;
  9318. const isStatic = value.charAt(0) === '"' && value.charAt(value.length - 1) === '"';
  9319. if (!isStatic) {
  9320. return;
  9321. }
  9322. const imageCandidates = value
  9323. .slice(1, -1)
  9324. .split(',')
  9325. .map(s => {
  9326. // The attribute value arrives here with all whitespace, except
  9327. // normal spaces, represented by escape sequences
  9328. const [url, descriptor] = s
  9329. .replace(escapedSpaceCharacters, ' ')
  9330. .trim()
  9331. .split(' ', 2);
  9332. return {
  9333. require: urlToRequire(url, transformAssetUrlsOptions),
  9334. descriptor
  9335. };
  9336. });
  9337. // "require(url1)"
  9338. // "require(url1) 1x"
  9339. // "require(url1), require(url2)"
  9340. // "require(url1), require(url2) 2x"
  9341. // "require(url1) 1x, require(url2)"
  9342. // "require(url1) 1x, require(url2) 2x"
  9343. const code = imageCandidates
  9344. .map(({ require, descriptor }) => `${require} + "${descriptor ? ' ' + descriptor : ''}, " + `)
  9345. .join('')
  9346. .slice(0, -6)
  9347. .concat('"')
  9348. .replace(/ \+ ""$/, '');
  9349. attr.value = code;
  9350. }
  9351. });
  9352. }
  9353. }
  9354. var consolidate$2 = {exports: {}};
  9355. function commonjsRequire(path) {
  9356. 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.');
  9357. }
  9358. var consolidate$1 = {exports: {}};
  9359. (function (module, exports) {
  9360. /*
  9361. * Engines which do not support caching of their file contents
  9362. * should use the `read()` function defined in consolidate.js
  9363. * On top of this, when an engine compiles to a `Function`,
  9364. * these functions should either be cached within consolidate.js
  9365. * or the engine itself via `options.cache`. This will allow
  9366. * users and frameworks to pass `options.cache = true` for
  9367. * `NODE_ENV=production`, however edit the file(s) without
  9368. * re-loading the application in development.
  9369. */
  9370. /**
  9371. * Module dependencies.
  9372. */
  9373. var fs = require$$0__default["default"];
  9374. var path = path__default["default"];
  9375. var util = require$$2__default["default"];
  9376. var join = path.join;
  9377. var resolve = path.resolve;
  9378. var extname = path.extname;
  9379. var dirname = path.dirname;
  9380. var isAbsolute = path.isAbsolute;
  9381. var readCache = {};
  9382. /**
  9383. * Require cache.
  9384. */
  9385. var cacheStore = {};
  9386. /**
  9387. * Require cache.
  9388. */
  9389. var requires = {};
  9390. /**
  9391. * Clear the cache.
  9392. *
  9393. * @api public
  9394. */
  9395. exports.clearCache = function() {
  9396. readCache = {};
  9397. cacheStore = {};
  9398. };
  9399. /**
  9400. * Conditionally cache `compiled` template based
  9401. * on the `options` filename and `.cache` boolean.
  9402. *
  9403. * @param {Object} options
  9404. * @param {Function} compiled
  9405. * @return {Function}
  9406. * @api private
  9407. */
  9408. function cache(options, compiled) {
  9409. // cachable
  9410. if (compiled && options.filename && options.cache) {
  9411. delete readCache[options.filename];
  9412. cacheStore[options.filename] = compiled;
  9413. return compiled;
  9414. }
  9415. // check cache
  9416. if (options.filename && options.cache) {
  9417. return cacheStore[options.filename];
  9418. }
  9419. return compiled;
  9420. }
  9421. /**
  9422. * Read `path` with `options` with
  9423. * callback `(err, str)`. When `options.cache`
  9424. * is true the template string will be cached.
  9425. *
  9426. * @param {String} options
  9427. * @param {Function} cb
  9428. * @api private
  9429. */
  9430. function read(path, options, cb) {
  9431. var str = readCache[path];
  9432. var cached = options.cache && str && typeof str === 'string';
  9433. // cached (only if cached is a string and not a compiled template function)
  9434. if (cached) return cb(null, str);
  9435. // read
  9436. fs.readFile(path, 'utf8', function(err, str) {
  9437. if (err) return cb(err);
  9438. // remove extraneous utf8 BOM marker
  9439. str = str.replace(/^\uFEFF/, '');
  9440. if (options.cache) readCache[path] = str;
  9441. cb(null, str);
  9442. });
  9443. }
  9444. /**
  9445. * Read `path` with `options` with
  9446. * callback `(err, str)`. When `options.cache`
  9447. * is true the partial string will be cached.
  9448. *
  9449. * @param {String} options
  9450. * @param {Function} fn
  9451. * @api private
  9452. */
  9453. function readPartials(path, options, cb) {
  9454. if (!options.partials) return cb();
  9455. var keys = Object.keys(options.partials);
  9456. var partials = {};
  9457. function next(index) {
  9458. if (index === keys.length) return cb(null, partials);
  9459. var key = keys[index];
  9460. var partialPath = options.partials[key];
  9461. if (partialPath === undefined || partialPath === null || partialPath === false) {
  9462. return next(++index);
  9463. }
  9464. var file;
  9465. if (isAbsolute(partialPath)) {
  9466. if (extname(partialPath) !== '') {
  9467. file = partialPath;
  9468. } else {
  9469. file = join(partialPath + extname(path));
  9470. }
  9471. } else {
  9472. file = join(dirname(path), partialPath + extname(path));
  9473. }
  9474. read(file, options, function(err, str) {
  9475. if (err) return cb(err);
  9476. partials[key] = str;
  9477. next(++index);
  9478. });
  9479. }
  9480. next(0);
  9481. }
  9482. /**
  9483. * promisify
  9484. */
  9485. function promisify(cb, fn) {
  9486. return new Promise(function(resolve, reject) {
  9487. cb = cb || function(err, html) {
  9488. if (err) {
  9489. return reject(err);
  9490. }
  9491. resolve(html);
  9492. };
  9493. fn(cb);
  9494. });
  9495. }
  9496. /**
  9497. * fromStringRenderer
  9498. */
  9499. function fromStringRenderer(name) {
  9500. return function(path, options, cb) {
  9501. options.filename = path;
  9502. return promisify(cb, function(cb) {
  9503. readPartials(path, options, function(err, partials) {
  9504. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  9505. var opts = extend({}, options);
  9506. opts.partials = partials;
  9507. if (err) return cb(err);
  9508. if (cache(opts)) {
  9509. exports[name].render('', opts, cb);
  9510. } else {
  9511. read(path, opts, function(err, str) {
  9512. if (err) return cb(err);
  9513. exports[name].render(str, opts, cb);
  9514. });
  9515. }
  9516. });
  9517. });
  9518. };
  9519. }
  9520. /**
  9521. * velocity support.
  9522. */
  9523. exports.velocityjs = fromStringRenderer('velocityjs');
  9524. /**
  9525. * velocity string support.
  9526. */
  9527. exports.velocityjs.render = function(str, options, cb) {
  9528. return promisify(cb, function(cb) {
  9529. var engine = requires.velocityjs || (requires.velocityjs = require('velocityjs'));
  9530. try {
  9531. options.locals = options;
  9532. cb(null, engine.render(str, options).trimLeft());
  9533. } catch (err) {
  9534. cb(err);
  9535. }
  9536. });
  9537. };
  9538. /**
  9539. * Liquid support.
  9540. */
  9541. exports.liquid = fromStringRenderer('liquid');
  9542. /**
  9543. * Liquid string support.
  9544. */
  9545. /**
  9546. * Note that in order to get filters and custom tags we've had to push
  9547. * all user-defined locals down into @locals. However, just to make things
  9548. * backwards-compatible, any property of `options` that is left after
  9549. * processing and removing `locals`, `meta`, `filters`, `customTags` and
  9550. * `includeDir` will also become a local.
  9551. */
  9552. function _renderTinyliquid(engine, str, options, cb) {
  9553. var context = engine.newContext();
  9554. var k;
  9555. /**
  9556. * Note that there's a bug in the library that doesn't allow us to pass
  9557. * the locals to newContext(), hence looping through the keys:
  9558. */
  9559. if (options.locals) {
  9560. for (k in options.locals) {
  9561. context.setLocals(k, options.locals[k]);
  9562. }
  9563. delete options.locals;
  9564. }
  9565. if (options.meta) {
  9566. context.setLocals('page', options.meta);
  9567. delete options.meta;
  9568. }
  9569. /**
  9570. * Add any defined filters:
  9571. */
  9572. if (options.filters) {
  9573. for (k in options.filters) {
  9574. context.setFilter(k, options.filters[k]);
  9575. }
  9576. delete options.filters;
  9577. }
  9578. /**
  9579. * Set up a callback for the include directory:
  9580. */
  9581. var includeDir = options.includeDir || process.cwd();
  9582. context.onInclude(function(name, callback) {
  9583. var extname = path.extname(name) ? '' : '.liquid';
  9584. var filename = path.resolve(includeDir, name + extname);
  9585. fs.readFile(filename, {encoding: 'utf8'}, function(err, data) {
  9586. if (err) return callback(err);
  9587. callback(null, engine.parse(data));
  9588. });
  9589. });
  9590. delete options.includeDir;
  9591. /**
  9592. * The custom tag functions need to have their results pushed back
  9593. * through the parser, so set up a shim before calling the provided
  9594. * callback:
  9595. */
  9596. var compileOptions = {
  9597. customTags: {}
  9598. };
  9599. if (options.customTags) {
  9600. var tagFunctions = options.customTags;
  9601. for (k in options.customTags) {
  9602. /*Tell jshint there's no problem with having this function in the loop */
  9603. /*jshint -W083 */
  9604. compileOptions.customTags[k] = function(context, name, body) {
  9605. var tpl = tagFunctions[name](body.trim());
  9606. context.astStack.push(engine.parse(tpl));
  9607. };
  9608. /*jshint +W083 */
  9609. }
  9610. delete options.customTags;
  9611. }
  9612. /**
  9613. * Now anything left in `options` becomes a local:
  9614. */
  9615. for (k in options) {
  9616. context.setLocals(k, options[k]);
  9617. }
  9618. /**
  9619. * Finally, execute the template:
  9620. */
  9621. var tmpl = cache(context) || cache(context, engine.compile(str, compileOptions));
  9622. tmpl(context, cb);
  9623. }
  9624. exports.liquid.render = function(str, options, cb) {
  9625. return promisify(cb, function(cb) {
  9626. var engine = requires.liquid;
  9627. var Liquid;
  9628. try {
  9629. // set up tinyliquid engine
  9630. engine = requires.liquid = require('tinyliquid');
  9631. // use tinyliquid engine
  9632. _renderTinyliquid(engine, str, options, cb);
  9633. return;
  9634. } catch (err) {
  9635. // set up liquid-node engine
  9636. try {
  9637. Liquid = requires.liquid = require('liquid-node');
  9638. engine = new Liquid.Engine();
  9639. } catch (err) {
  9640. throw err;
  9641. }
  9642. }
  9643. // use liquid-node engine
  9644. try {
  9645. var locals = options.locals || {};
  9646. if (options.meta) {
  9647. locals.pages = options.meta;
  9648. delete options.meta;
  9649. }
  9650. /**
  9651. * Add any defined filters:
  9652. */
  9653. if (options.filters) {
  9654. engine.registerFilters(options.filters);
  9655. delete options.filters;
  9656. }
  9657. /**
  9658. * Set up a callback for the include directory:
  9659. */
  9660. var includeDir = options.includeDir || process.cwd();
  9661. engine.fileSystem = new Liquid.LocalFileSystem(includeDir, 'liquid');
  9662. delete options.includeDir;
  9663. /**
  9664. * The custom tag functions need to have their results pushed back
  9665. * through the parser, so set up a shim before calling the provided
  9666. * callback:
  9667. */
  9668. if (options.customTags) {
  9669. var tagFunctions = options.customTags;
  9670. for (k in options.customTags) {
  9671. engine.registerTag(k, tagFunctions[k]);
  9672. }
  9673. delete options.customTags;
  9674. }
  9675. /**
  9676. * Now anything left in `options` becomes a local:
  9677. */
  9678. for (var k in options) {
  9679. locals[k] = options[k];
  9680. }
  9681. /**
  9682. * Finally, execute the template:
  9683. */
  9684. return engine
  9685. .parseAndRender(str, locals)
  9686. .nodeify(function(err, result) {
  9687. if (err) {
  9688. throw new Error(err);
  9689. } else {
  9690. return cb(null, result);
  9691. }
  9692. });
  9693. } catch (err) {
  9694. cb(err);
  9695. }
  9696. });
  9697. };
  9698. /**
  9699. * Jade support.
  9700. */
  9701. exports.jade = function(path, options, cb) {
  9702. return promisify(cb, function(cb) {
  9703. var engine = requires.jade;
  9704. if (!engine) {
  9705. try {
  9706. engine = requires.jade = require('jade');
  9707. } catch (err) {
  9708. try {
  9709. engine = requires.jade = require('then-jade');
  9710. } catch (otherError) {
  9711. throw err;
  9712. }
  9713. }
  9714. }
  9715. try {
  9716. var tmpl = cache(options) || cache(options, engine.compileFile(path, options));
  9717. cb(null, tmpl(options));
  9718. } catch (err) {
  9719. cb(err);
  9720. }
  9721. });
  9722. };
  9723. /**
  9724. * Jade string support.
  9725. */
  9726. exports.jade.render = function(str, options, cb) {
  9727. return promisify(cb, function(cb) {
  9728. var engine = requires.jade;
  9729. if (!engine) {
  9730. try {
  9731. engine = requires.jade = require('jade');
  9732. } catch (err) {
  9733. try {
  9734. engine = requires.jade = require('then-jade');
  9735. } catch (otherError) {
  9736. throw err;
  9737. }
  9738. }
  9739. }
  9740. try {
  9741. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9742. cb(null, tmpl(options));
  9743. } catch (err) {
  9744. cb(err);
  9745. }
  9746. });
  9747. };
  9748. /**
  9749. * Dust support.
  9750. */
  9751. exports.dust = fromStringRenderer('dust');
  9752. /**
  9753. * Dust string support.
  9754. */
  9755. exports.dust.render = function(str, options, cb) {
  9756. return promisify(cb, function(cb) {
  9757. var engine = requires.dust;
  9758. if (!engine) {
  9759. try {
  9760. engine = requires.dust = require('dust');
  9761. } catch (err) {
  9762. try {
  9763. engine = requires.dust = require('dustjs-helpers');
  9764. } catch (err) {
  9765. engine = requires.dust = require('dustjs-linkedin');
  9766. }
  9767. }
  9768. }
  9769. var ext = 'dust';
  9770. var views = '.';
  9771. if (options) {
  9772. if (options.ext) ext = options.ext;
  9773. if (options.views) views = options.views;
  9774. if (options.settings && options.settings.views) views = options.settings.views;
  9775. }
  9776. if (!options || (options && !options.cache)) engine.cache = {};
  9777. engine.onLoad = function(path, callback) {
  9778. if (extname(path) === '') path += '.' + ext;
  9779. if (path[0] !== '/') path = views + '/' + path;
  9780. read(path, options, callback);
  9781. };
  9782. try {
  9783. var templateName;
  9784. if (options.filename) {
  9785. templateName = options.filename.replace(new RegExp('^' + views + '/'), '').replace(new RegExp('\\.' + ext), '');
  9786. }
  9787. var tmpl = cache(options) || cache(options, engine.compileFn(str, templateName));
  9788. tmpl(options, cb);
  9789. } catch (err) {
  9790. cb(err);
  9791. }
  9792. });
  9793. };
  9794. /**
  9795. * Swig support.
  9796. */
  9797. exports.swig = fromStringRenderer('swig');
  9798. /**
  9799. * Swig string support.
  9800. */
  9801. exports.swig.render = function(str, options, cb) {
  9802. return promisify(cb, function(cb) {
  9803. var engine = requires.swig;
  9804. if (!engine) {
  9805. try {
  9806. engine = requires.swig = require('swig');
  9807. } catch (err) {
  9808. try {
  9809. engine = requires.swig = require('swig-templates');
  9810. } catch (otherError) {
  9811. throw err;
  9812. }
  9813. }
  9814. }
  9815. try {
  9816. if (options.cache === true) options.cache = 'memory';
  9817. engine.setDefaults({ cache: options.cache });
  9818. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9819. cb(null, tmpl(options));
  9820. } catch (err) {
  9821. cb(err);
  9822. }
  9823. });
  9824. };
  9825. /**
  9826. * Razor support.
  9827. */
  9828. exports.razor = function(path, options, cb) {
  9829. return promisify(cb, function(cb) {
  9830. var engine = requires.razor;
  9831. if (!engine) {
  9832. try {
  9833. engine = requires.razor = require('razor-tmpl');
  9834. } catch (err) {
  9835. throw err;
  9836. }
  9837. }
  9838. try {
  9839. var tmpl = cache(options) || cache(options, (locals) => {
  9840. console.log('Rendering razor file', path);
  9841. return engine.renderFileSync(path, locals);
  9842. });
  9843. cb(null, tmpl(options));
  9844. } catch (err) {
  9845. cb(err);
  9846. }
  9847. });
  9848. };
  9849. /**
  9850. * razor string support.
  9851. */
  9852. exports.razor.render = function(str, options, cb) {
  9853. return promisify(cb, function(cb) {
  9854. try {
  9855. var engine = requires.razor = require('razor-tmpl');
  9856. } catch (err) {
  9857. throw err;
  9858. }
  9859. try {
  9860. var tf = engine.compile(str);
  9861. var tmpl = cache(options) || cache(options, tf);
  9862. cb(null, tmpl(options));
  9863. } catch (err) {
  9864. cb(err);
  9865. }
  9866. });
  9867. };
  9868. /**
  9869. * Atpl support.
  9870. */
  9871. exports.atpl = fromStringRenderer('atpl');
  9872. /**
  9873. * Atpl string support.
  9874. */
  9875. exports.atpl.render = function(str, options, cb) {
  9876. return promisify(cb, function(cb) {
  9877. var engine = requires.atpl || (requires.atpl = require('atpl'));
  9878. try {
  9879. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9880. cb(null, tmpl(options));
  9881. } catch (err) {
  9882. cb(err);
  9883. }
  9884. });
  9885. };
  9886. /**
  9887. * Liquor support,
  9888. */
  9889. exports.liquor = fromStringRenderer('liquor');
  9890. /**
  9891. * Liquor string support.
  9892. */
  9893. exports.liquor.render = function(str, options, cb) {
  9894. return promisify(cb, function(cb) {
  9895. var engine = requires.liquor || (requires.liquor = require('liquor'));
  9896. try {
  9897. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9898. cb(null, tmpl(options));
  9899. } catch (err) {
  9900. cb(err);
  9901. }
  9902. });
  9903. };
  9904. /**
  9905. * Twig support.
  9906. */
  9907. exports.twig = fromStringRenderer('twig');
  9908. /**
  9909. * Twig string support.
  9910. */
  9911. exports.twig.render = function(str, options, cb) {
  9912. return promisify(cb, function(cb) {
  9913. var engine = requires.twig || (requires.twig = require('twig').twig);
  9914. var templateData = {
  9915. data: str,
  9916. allowInlineIncludes: options.allowInlineIncludes,
  9917. namespaces: options.namespaces,
  9918. path: options.path
  9919. };
  9920. try {
  9921. var tmpl = cache(templateData) || cache(templateData, engine(templateData));
  9922. cb(null, tmpl.render(options));
  9923. } catch (err) {
  9924. cb(err);
  9925. }
  9926. });
  9927. };
  9928. /**
  9929. * EJS support.
  9930. */
  9931. exports.ejs = fromStringRenderer('ejs');
  9932. /**
  9933. * EJS string support.
  9934. */
  9935. exports.ejs.render = function(str, options, cb) {
  9936. return promisify(cb, function(cb) {
  9937. var engine = requires.ejs || (requires.ejs = require('ejs'));
  9938. try {
  9939. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9940. cb(null, tmpl(options));
  9941. } catch (err) {
  9942. cb(err);
  9943. }
  9944. });
  9945. };
  9946. /**
  9947. * Eco support.
  9948. */
  9949. exports.eco = fromStringRenderer('eco');
  9950. /**
  9951. * Eco string support.
  9952. */
  9953. exports.eco.render = function(str, options, cb) {
  9954. return promisify(cb, function(cb) {
  9955. var engine = requires.eco || (requires.eco = require('eco'));
  9956. try {
  9957. cb(null, engine.render(str, options));
  9958. } catch (err) {
  9959. cb(err);
  9960. }
  9961. });
  9962. };
  9963. /**
  9964. * Jazz support.
  9965. */
  9966. exports.jazz = fromStringRenderer('jazz');
  9967. /**
  9968. * Jazz string support.
  9969. */
  9970. exports.jazz.render = function(str, options, cb) {
  9971. return promisify(cb, function(cb) {
  9972. var engine = requires.jazz || (requires.jazz = require('jazz'));
  9973. try {
  9974. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9975. tmpl.eval(options, function(str) {
  9976. cb(null, str);
  9977. });
  9978. } catch (err) {
  9979. cb(err);
  9980. }
  9981. });
  9982. };
  9983. /**
  9984. * JQTPL support.
  9985. */
  9986. exports.jqtpl = fromStringRenderer('jqtpl');
  9987. /**
  9988. * JQTPL string support.
  9989. */
  9990. exports.jqtpl.render = function(str, options, cb) {
  9991. return promisify(cb, function(cb) {
  9992. var engine = requires.jqtpl || (requires.jqtpl = require('jqtpl'));
  9993. try {
  9994. engine.template(str, str);
  9995. cb(null, engine.tmpl(str, options));
  9996. } catch (err) {
  9997. cb(err);
  9998. }
  9999. });
  10000. };
  10001. /**
  10002. * Haml support.
  10003. */
  10004. exports.haml = fromStringRenderer('haml');
  10005. /**
  10006. * Haml string support.
  10007. */
  10008. exports.haml.render = function(str, options, cb) {
  10009. return promisify(cb, function(cb) {
  10010. var engine = requires.haml || (requires.haml = require('hamljs'));
  10011. try {
  10012. options.locals = options;
  10013. cb(null, engine.render(str, options).trimLeft());
  10014. } catch (err) {
  10015. cb(err);
  10016. }
  10017. });
  10018. };
  10019. /**
  10020. * Hamlet support.
  10021. */
  10022. exports.hamlet = fromStringRenderer('hamlet');
  10023. /**
  10024. * Hamlet string support.
  10025. */
  10026. exports.hamlet.render = function(str, options, cb) {
  10027. return promisify(cb, function(cb) {
  10028. var engine = requires.hamlet || (requires.hamlet = require('hamlet'));
  10029. try {
  10030. options.locals = options;
  10031. cb(null, engine.render(str, options).trimLeft());
  10032. } catch (err) {
  10033. cb(err);
  10034. }
  10035. });
  10036. };
  10037. /**
  10038. * Whiskers support.
  10039. */
  10040. exports.whiskers = function(path, options, cb) {
  10041. return promisify(cb, function(cb) {
  10042. var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
  10043. engine.__express(path, options, cb);
  10044. });
  10045. };
  10046. /**
  10047. * Whiskers string support.
  10048. */
  10049. exports.whiskers.render = function(str, options, cb) {
  10050. return promisify(cb, function(cb) {
  10051. var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
  10052. try {
  10053. cb(null, engine.render(str, options));
  10054. } catch (err) {
  10055. cb(err);
  10056. }
  10057. });
  10058. };
  10059. /**
  10060. * Coffee-HAML support.
  10061. */
  10062. exports['haml-coffee'] = fromStringRenderer('haml-coffee');
  10063. /**
  10064. * Coffee-HAML string support.
  10065. */
  10066. exports['haml-coffee'].render = function(str, options, cb) {
  10067. return promisify(cb, function(cb) {
  10068. var engine = requires['haml-coffee'] || (requires['haml-coffee'] = require('haml-coffee'));
  10069. try {
  10070. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10071. cb(null, tmpl(options));
  10072. } catch (err) {
  10073. cb(err);
  10074. }
  10075. });
  10076. };
  10077. /**
  10078. * Hogan support.
  10079. */
  10080. exports.hogan = fromStringRenderer('hogan');
  10081. /**
  10082. * Hogan string support.
  10083. */
  10084. exports.hogan.render = function(str, options, cb) {
  10085. return promisify(cb, function(cb) {
  10086. var engine = requires.hogan || (requires.hogan = require('hogan.js'));
  10087. try {
  10088. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10089. cb(null, tmpl.render(options, options.partials));
  10090. } catch (err) {
  10091. cb(err);
  10092. }
  10093. });
  10094. };
  10095. /**
  10096. * templayed.js support.
  10097. */
  10098. exports.templayed = fromStringRenderer('templayed');
  10099. /**
  10100. * templayed.js string support.
  10101. */
  10102. exports.templayed.render = function(str, options, cb) {
  10103. return promisify(cb, function(cb) {
  10104. var engine = requires.templayed || (requires.templayed = require('templayed'));
  10105. try {
  10106. var tmpl = cache(options) || cache(options, engine(str));
  10107. cb(null, tmpl(options));
  10108. } catch (err) {
  10109. cb(err);
  10110. }
  10111. });
  10112. };
  10113. /**
  10114. * Handlebars support.
  10115. */
  10116. exports.handlebars = fromStringRenderer('handlebars');
  10117. /**
  10118. * Handlebars string support.
  10119. */
  10120. exports.handlebars.render = function(str, options, cb) {
  10121. return promisify(cb, function(cb) {
  10122. var engine = requires.handlebars || (requires.handlebars = require('handlebars'));
  10123. try {
  10124. for (var partial in options.partials) {
  10125. engine.registerPartial(partial, options.partials[partial]);
  10126. }
  10127. for (var helper in options.helpers) {
  10128. engine.registerHelper(helper, options.helpers[helper]);
  10129. }
  10130. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10131. cb(null, tmpl(options));
  10132. } catch (err) {
  10133. cb(err);
  10134. }
  10135. });
  10136. };
  10137. /**
  10138. * Underscore support.
  10139. */
  10140. exports.underscore = fromStringRenderer('underscore');
  10141. /**
  10142. * Underscore string support.
  10143. */
  10144. exports.underscore.render = function(str, options, cb) {
  10145. return promisify(cb, function(cb) {
  10146. var engine = requires.underscore || (requires.underscore = require('underscore'));
  10147. try {
  10148. const partials = {};
  10149. for (var partial in options.partials) {
  10150. partials[partial] = engine.template(options.partials[partial]);
  10151. }
  10152. options.partials = partials;
  10153. var tmpl = cache(options) || cache(options, engine.template(str, null, options));
  10154. cb(null, tmpl(options).replace(/\n$/, ''));
  10155. } catch (err) {
  10156. cb(err);
  10157. }
  10158. });
  10159. };
  10160. /**
  10161. * Lodash support.
  10162. */
  10163. exports.lodash = fromStringRenderer('lodash');
  10164. /**
  10165. * Lodash string support.
  10166. */
  10167. exports.lodash.render = function(str, options, cb) {
  10168. return promisify(cb, function(cb) {
  10169. var engine = requires.lodash || (requires.lodash = require('lodash'));
  10170. try {
  10171. var tmpl = cache(options) || cache(options, engine.template(str, options));
  10172. cb(null, tmpl(options).replace(/\n$/, ''));
  10173. } catch (err) {
  10174. cb(err);
  10175. }
  10176. });
  10177. };
  10178. /**
  10179. * Pug support. (formerly Jade)
  10180. */
  10181. exports.pug = function(path, options, cb) {
  10182. return promisify(cb, function(cb) {
  10183. var engine = requires.pug;
  10184. if (!engine) {
  10185. try {
  10186. engine = requires.pug = require('pug');
  10187. } catch (err) {
  10188. try {
  10189. engine = requires.pug = require('then-pug');
  10190. } catch (otherError) {
  10191. throw err;
  10192. }
  10193. }
  10194. }
  10195. try {
  10196. var tmpl = cache(options) || cache(options, engine.compileFile(path, options));
  10197. cb(null, tmpl(options));
  10198. } catch (err) {
  10199. cb(err);
  10200. }
  10201. });
  10202. };
  10203. /**
  10204. * Pug string support.
  10205. */
  10206. exports.pug.render = function(str, options, cb) {
  10207. return promisify(cb, function(cb) {
  10208. var engine = requires.pug;
  10209. if (!engine) {
  10210. try {
  10211. engine = requires.pug = require('pug');
  10212. } catch (err) {
  10213. try {
  10214. engine = requires.pug = require('then-pug');
  10215. } catch (otherError) {
  10216. throw err;
  10217. }
  10218. }
  10219. }
  10220. try {
  10221. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10222. cb(null, tmpl(options));
  10223. } catch (err) {
  10224. cb(err);
  10225. }
  10226. });
  10227. };
  10228. /**
  10229. * QEJS support.
  10230. */
  10231. exports.qejs = fromStringRenderer('qejs');
  10232. /**
  10233. * QEJS string support.
  10234. */
  10235. exports.qejs.render = function(str, options, cb) {
  10236. return promisify(cb, function(cb) {
  10237. try {
  10238. var engine = requires.qejs || (requires.qejs = require('qejs'));
  10239. engine.render(str, options).then(function(result) {
  10240. cb(null, result);
  10241. }, function(err) {
  10242. cb(err);
  10243. }).done();
  10244. } catch (err) {
  10245. cb(err);
  10246. }
  10247. });
  10248. };
  10249. /**
  10250. * Walrus support.
  10251. */
  10252. exports.walrus = fromStringRenderer('walrus');
  10253. /**
  10254. * Walrus string support.
  10255. */
  10256. exports.walrus.render = function(str, options, cb) {
  10257. return promisify(cb, function(cb) {
  10258. var engine = requires.walrus || (requires.walrus = require('walrus'));
  10259. try {
  10260. var tmpl = cache(options) || cache(options, engine.parse(str));
  10261. cb(null, tmpl.compile(options));
  10262. } catch (err) {
  10263. cb(err);
  10264. }
  10265. });
  10266. };
  10267. /**
  10268. * Mustache support.
  10269. */
  10270. exports.mustache = fromStringRenderer('mustache');
  10271. /**
  10272. * Mustache string support.
  10273. */
  10274. exports.mustache.render = function(str, options, cb) {
  10275. return promisify(cb, function(cb) {
  10276. var engine = requires.mustache || (requires.mustache = require('mustache'));
  10277. try {
  10278. cb(null, engine.render(str, options, options.partials));
  10279. } catch (err) {
  10280. cb(err);
  10281. }
  10282. });
  10283. };
  10284. /**
  10285. * Just support.
  10286. */
  10287. exports.just = function(path, options, cb) {
  10288. return promisify(cb, function(cb) {
  10289. var engine = requires.just;
  10290. if (!engine) {
  10291. var JUST = require('just');
  10292. engine = requires.just = new JUST();
  10293. }
  10294. engine.configure({ useCache: options.cache });
  10295. engine.render(path, options, cb);
  10296. });
  10297. };
  10298. /**
  10299. * Just string support.
  10300. */
  10301. exports.just.render = function(str, options, cb) {
  10302. return promisify(cb, function(cb) {
  10303. var JUST = require('just');
  10304. var engine = new JUST({ root: { page: str }});
  10305. engine.render('page', options, cb);
  10306. });
  10307. };
  10308. /**
  10309. * ECT support.
  10310. */
  10311. exports.ect = function(path, options, cb) {
  10312. return promisify(cb, function(cb) {
  10313. var engine = requires.ect;
  10314. if (!engine) {
  10315. var ECT = require('ect');
  10316. engine = requires.ect = new ECT(options);
  10317. }
  10318. engine.configure({ cache: options.cache });
  10319. engine.render(path, options, cb);
  10320. });
  10321. };
  10322. /**
  10323. * ECT string support.
  10324. */
  10325. exports.ect.render = function(str, options, cb) {
  10326. return promisify(cb, function(cb) {
  10327. var ECT = require('ect');
  10328. var engine = new ECT({ root: { page: str }});
  10329. engine.render('page', options, cb);
  10330. });
  10331. };
  10332. /**
  10333. * mote support.
  10334. */
  10335. exports.mote = fromStringRenderer('mote');
  10336. /**
  10337. * mote string support.
  10338. */
  10339. exports.mote.render = function(str, options, cb) {
  10340. return promisify(cb, function(cb) {
  10341. var engine = requires.mote || (requires.mote = require('mote'));
  10342. try {
  10343. var tmpl = cache(options) || cache(options, engine.compile(str));
  10344. cb(null, tmpl(options));
  10345. } catch (err) {
  10346. cb(err);
  10347. }
  10348. });
  10349. };
  10350. /**
  10351. * Toffee support.
  10352. */
  10353. exports.toffee = function(path, options, cb) {
  10354. return promisify(cb, function(cb) {
  10355. var toffee = requires.toffee || (requires.toffee = require('toffee'));
  10356. toffee.__consolidate_engine_render(path, options, cb);
  10357. });
  10358. };
  10359. /**
  10360. * Toffee string support.
  10361. */
  10362. exports.toffee.render = function(str, options, cb) {
  10363. return promisify(cb, function(cb) {
  10364. var engine = requires.toffee || (requires.toffee = require('toffee'));
  10365. try {
  10366. engine.str_render(str, options, cb);
  10367. } catch (err) {
  10368. cb(err);
  10369. }
  10370. });
  10371. };
  10372. /**
  10373. * doT support.
  10374. */
  10375. exports.dot = fromStringRenderer('dot');
  10376. /**
  10377. * doT string support.
  10378. */
  10379. exports.dot.render = function(str, options, cb) {
  10380. return promisify(cb, function(cb) {
  10381. var engine = requires.dot || (requires.dot = require('dot'));
  10382. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  10383. try {
  10384. var settings = {};
  10385. settings = extend(settings, engine.templateSettings);
  10386. settings = extend(settings, options ? options.dot : {});
  10387. var tmpl = cache(options) || cache(options, engine.template(str, settings, options));
  10388. cb(null, tmpl(options));
  10389. } catch (err) {
  10390. cb(err);
  10391. }
  10392. });
  10393. };
  10394. /**
  10395. * bracket support.
  10396. */
  10397. exports.bracket = fromStringRenderer('bracket');
  10398. /**
  10399. * bracket string support.
  10400. */
  10401. exports.bracket.render = function(str, options, cb) {
  10402. return promisify(cb, function(cb) {
  10403. var engine = requires.bracket || (requires.bracket = require('bracket-template'));
  10404. try {
  10405. var tmpl = cache(options) || cache(options, engine.default.compile(str, options));
  10406. cb(null, tmpl(options));
  10407. } catch (err) {
  10408. cb(err);
  10409. }
  10410. });
  10411. };
  10412. /**
  10413. * Ractive support.
  10414. */
  10415. exports.ractive = fromStringRenderer('ractive');
  10416. /**
  10417. * Ractive string support.
  10418. */
  10419. exports.ractive.render = function(str, options, cb) {
  10420. return promisify(cb, function(cb) {
  10421. var Engine = requires.ractive || (requires.ractive = require('ractive'));
  10422. var template = cache(options) || cache(options, Engine.parse(str));
  10423. options.template = template;
  10424. if (options.data === null || options.data === undefined) {
  10425. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  10426. // Shallow clone the options object
  10427. options.data = extend({}, options);
  10428. // Remove consolidate-specific properties from the clone
  10429. var i;
  10430. var length;
  10431. var properties = ['template', 'filename', 'cache', 'partials'];
  10432. for (i = 0, length = properties.length; i < length; i++) {
  10433. var property = properties[i];
  10434. delete options.data[property];
  10435. }
  10436. }
  10437. try {
  10438. cb(null, new Engine(options).toHTML());
  10439. } catch (err) {
  10440. cb(err);
  10441. }
  10442. });
  10443. };
  10444. /**
  10445. * Nunjucks support.
  10446. */
  10447. exports.nunjucks = fromStringRenderer('nunjucks');
  10448. /**
  10449. * Nunjucks string support.
  10450. */
  10451. exports.nunjucks.render = function(str, options, cb) {
  10452. return promisify(cb, function(cb) {
  10453. try {
  10454. var engine = options.nunjucksEnv || requires.nunjucks || (requires.nunjucks = require('nunjucks'));
  10455. var env = engine;
  10456. // deprecated fallback support for express
  10457. // <https://github.com/tj/consolidate.js/pull/152>
  10458. // <https://github.com/tj/consolidate.js/pull/224>
  10459. if (options.settings && options.settings.views) {
  10460. env = engine.configure(options.settings.views);
  10461. } else if (options.nunjucks && options.nunjucks.configure) {
  10462. env = engine.configure.apply(engine, options.nunjucks.configure);
  10463. }
  10464. //
  10465. // because `renderString` does not initiate loaders
  10466. // we must manually create a loader for it based off
  10467. // either `options.settings.views` or `options.nunjucks` or `options.nunjucks.root`
  10468. //
  10469. // <https://github.com/mozilla/nunjucks/issues/730>
  10470. // <https://github.com/crocodilejs/node-email-templates/issues/182>
  10471. //
  10472. // so instead we simply check if we passed a custom loader
  10473. // otherwise we create a simple file based loader
  10474. if (options.loader) {
  10475. env = new engine.Environment(options.loader);
  10476. } else if (options.settings && options.settings.views) {
  10477. env = new engine.Environment(
  10478. new engine.FileSystemLoader(options.settings.views)
  10479. );
  10480. } else if (options.nunjucks && options.nunjucks.loader) {
  10481. if (typeof options.nunjucks.loader === 'string') {
  10482. env = new engine.Environment(new engine.FileSystemLoader(options.nunjucks.loader));
  10483. } else {
  10484. env = new engine.Environment(
  10485. new engine.FileSystemLoader(
  10486. options.nunjucks.loader[0],
  10487. options.nunjucks.loader[1]
  10488. )
  10489. );
  10490. }
  10491. }
  10492. env.renderString(str, options, cb);
  10493. } catch (err) {
  10494. throw cb(err);
  10495. }
  10496. });
  10497. };
  10498. /**
  10499. * HTMLing support.
  10500. */
  10501. exports.htmling = fromStringRenderer('htmling');
  10502. /**
  10503. * HTMLing string support.
  10504. */
  10505. exports.htmling.render = function(str, options, cb) {
  10506. return promisify(cb, function(cb) {
  10507. var engine = requires.htmling || (requires.htmling = require('htmling'));
  10508. try {
  10509. var tmpl = cache(options) || cache(options, engine.string(str));
  10510. cb(null, tmpl.render(options));
  10511. } catch (err) {
  10512. cb(err);
  10513. }
  10514. });
  10515. };
  10516. /**
  10517. * Rendering function
  10518. */
  10519. function requireReact(module, filename) {
  10520. var babel = requires.babel || (requires.babel = require('babel-core'));
  10521. var compiled = babel.transformFileSync(filename, { presets: [ 'react' ] }).code;
  10522. return module._compile(compiled, filename);
  10523. }
  10524. exports.requireReact = requireReact;
  10525. /**
  10526. * Converting a string into a node module.
  10527. */
  10528. function requireReactString(src, filename) {
  10529. var babel = requires.babel || (requires.babel = require('babel-core'));
  10530. if (!filename) filename = '';
  10531. var m = new module.constructor();
  10532. filename = filename || '';
  10533. // Compile Using React
  10534. var compiled = babel.transform(src, { presets: [ 'react' ] }).code;
  10535. // Compile as a module
  10536. m.paths = module.paths;
  10537. m._compile(compiled, filename);
  10538. return m.exports;
  10539. }
  10540. /**
  10541. * A naive helper to replace {{tags}} with options.tags content
  10542. */
  10543. function reactBaseTmpl(data, options) {
  10544. var exp;
  10545. var regex;
  10546. // Iterates through the keys in file object
  10547. // and interpolate / replace {{key}} with it's value
  10548. for (var k in options) {
  10549. if (options.hasOwnProperty(k)) {
  10550. exp = '{{' + k + '}}';
  10551. regex = new RegExp(exp, 'g');
  10552. if (data.match(regex)) {
  10553. data = data.replace(regex, options[k]);
  10554. }
  10555. }
  10556. }
  10557. return data;
  10558. }
  10559. /**
  10560. * Plates Support.
  10561. */
  10562. exports.plates = fromStringRenderer('plates');
  10563. /**
  10564. * Plates string support.
  10565. */
  10566. exports.plates.render = function(str, options, cb) {
  10567. return promisify(cb, function(cb) {
  10568. var engine = requires.plates || (requires.plates = require('plates'));
  10569. var map = options.map || undefined;
  10570. try {
  10571. var tmpl = engine.bind(str, options, map);
  10572. cb(null, tmpl);
  10573. } catch (err) {
  10574. cb(err);
  10575. }
  10576. });
  10577. };
  10578. /**
  10579. * The main render parser for React bsaed templates
  10580. */
  10581. function reactRenderer(type) {
  10582. if (commonjsRequire.extensions) {
  10583. // Ensure JSX is transformed on require
  10584. if (!commonjsRequire.extensions['.jsx']) {
  10585. commonjsRequire.extensions['.jsx'] = requireReact;
  10586. }
  10587. // Supporting .react extension as well as test cases
  10588. // Using .react extension is not recommended.
  10589. if (!commonjsRequire.extensions['.react']) {
  10590. commonjsRequire.extensions['.react'] = requireReact;
  10591. }
  10592. }
  10593. // Return rendering fx
  10594. return function(str, options, cb) {
  10595. return promisify(cb, function(cb) {
  10596. // React Import
  10597. var ReactDOM = requires.ReactDOM || (requires.ReactDOM = require('react-dom/server'));
  10598. var react = requires.react || (requires.react = require('react'));
  10599. // Assign HTML Base
  10600. var base = options.base;
  10601. delete options.base;
  10602. var enableCache = options.cache;
  10603. delete options.cache;
  10604. var isNonStatic = options.isNonStatic;
  10605. delete options.isNonStatic;
  10606. // Start Conversion
  10607. try {
  10608. var Code;
  10609. var Factory;
  10610. var baseStr;
  10611. var content;
  10612. var parsed;
  10613. if (!cache(options)) {
  10614. // Parsing
  10615. if (type === 'path') {
  10616. var path = resolve(str);
  10617. delete require.cache[path];
  10618. Code = commonjsRequire(path);
  10619. } else {
  10620. Code = requireReactString(str);
  10621. }
  10622. Factory = cache(options, react.createFactory(Code));
  10623. } else {
  10624. Factory = cache(options);
  10625. }
  10626. parsed = new Factory(options);
  10627. content = (isNonStatic) ? ReactDOM.renderToString(parsed) : ReactDOM.renderToStaticMarkup(parsed);
  10628. if (base) {
  10629. baseStr = readCache[str] || fs.readFileSync(resolve(base), 'utf8');
  10630. if (enableCache) {
  10631. readCache[str] = baseStr;
  10632. }
  10633. options.content = content;
  10634. content = reactBaseTmpl(baseStr, options);
  10635. }
  10636. cb(null, content);
  10637. } catch (err) {
  10638. cb(err);
  10639. }
  10640. });
  10641. };
  10642. }
  10643. /**
  10644. * React JS Support
  10645. */
  10646. exports.react = reactRenderer('path');
  10647. /**
  10648. * React JS string support.
  10649. */
  10650. exports.react.render = reactRenderer('string');
  10651. /**
  10652. * ARC-templates support.
  10653. */
  10654. exports['arc-templates'] = fromStringRenderer('arc-templates');
  10655. /**
  10656. * ARC-templates string support.
  10657. */
  10658. exports['arc-templates'].render = function(str, options, cb) {
  10659. var readFileWithOptions = util.promisify(read);
  10660. var consolidateFileSystem = {};
  10661. consolidateFileSystem.readFile = function(path) {
  10662. return readFileWithOptions(path, options);
  10663. };
  10664. return promisify(cb, function(cb) {
  10665. try {
  10666. var engine = requires['arc-templates'];
  10667. if (!engine) {
  10668. var Engine = require('arc-templates/dist/es5');
  10669. engine = requires['arc-templates'] = new Engine({ filesystem: consolidateFileSystem });
  10670. }
  10671. var compiler = cache(options) || cache(options, engine.compileString(str, options.filename));
  10672. compiler.then(function(func) { return func(options); })
  10673. .then(function(result) { cb(null, result.content); })
  10674. .catch(cb);
  10675. } catch (err) {
  10676. cb(err);
  10677. }
  10678. });
  10679. };
  10680. /**
  10681. * Vash support
  10682. */
  10683. exports.vash = fromStringRenderer('vash');
  10684. /**
  10685. * Vash string support
  10686. */
  10687. exports.vash.render = function(str, options, cb) {
  10688. return promisify(cb, function(cb) {
  10689. var engine = requires.vash || (requires.vash = require('vash'));
  10690. try {
  10691. // helper system : https://github.com/kirbysayshi/vash#helper-system
  10692. if (options.helpers) {
  10693. for (var key in options.helpers) {
  10694. if (!options.helpers.hasOwnProperty(key) || typeof options.helpers[key] !== 'function') {
  10695. continue;
  10696. }
  10697. engine.helpers[key] = options.helpers[key];
  10698. }
  10699. }
  10700. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10701. tmpl(options, function sealLayout(err, ctx) {
  10702. if (err) cb(err);
  10703. ctx.finishLayout();
  10704. cb(null, ctx.toString().replace(/\n$/, ''));
  10705. });
  10706. } catch (err) {
  10707. cb(err);
  10708. }
  10709. });
  10710. };
  10711. /**
  10712. * Slm support.
  10713. */
  10714. exports.slm = fromStringRenderer('slm');
  10715. /**
  10716. * Slm string support.
  10717. */
  10718. exports.slm.render = function(str, options, cb) {
  10719. return promisify(cb, function(cb) {
  10720. var engine = requires.slm || (requires.slm = require('slm'));
  10721. try {
  10722. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10723. cb(null, tmpl(options));
  10724. } catch (err) {
  10725. cb(err);
  10726. }
  10727. });
  10728. };
  10729. /**
  10730. * Marko support.
  10731. */
  10732. exports.marko = function(path, options, cb) {
  10733. return promisify(cb, function(cb) {
  10734. var engine = requires.marko || (requires.marko = require('marko'));
  10735. options.writeToDisk = !!options.cache;
  10736. try {
  10737. var tmpl = cache(options) || cache(options, engine.load(path, options));
  10738. tmpl.renderToString(options, cb);
  10739. } catch (err) {
  10740. cb(err);
  10741. }
  10742. });
  10743. };
  10744. /**
  10745. * Marko string support.
  10746. */
  10747. exports.marko.render = function(str, options, cb) {
  10748. return promisify(cb, function(cb) {
  10749. var engine = requires.marko || (requires.marko = require('marko'));
  10750. options.writeToDisk = !!options.cache;
  10751. options.filename = options.filename || 'string.marko';
  10752. try {
  10753. var tmpl = cache(options) || cache(options, engine.load(options.filename, str, options));
  10754. tmpl.renderToString(options, cb);
  10755. } catch (err) {
  10756. cb(err);
  10757. }
  10758. });
  10759. };
  10760. /**
  10761. * Teacup support.
  10762. */
  10763. exports.teacup = function(path, options, cb) {
  10764. return promisify(cb, function(cb) {
  10765. var engine = requires.teacup || (requires.teacup = require('teacup/lib/express'));
  10766. commonjsRequire.extensions['.teacup'] = commonjsRequire.extensions['.coffee'];
  10767. if (path[0] !== '/') {
  10768. path = join(process.cwd(), path);
  10769. }
  10770. if (!options.cache) {
  10771. var callback = cb;
  10772. cb = function() {
  10773. delete require.cache[path];
  10774. callback.apply(this, arguments);
  10775. };
  10776. }
  10777. engine.renderFile(path, options, cb);
  10778. });
  10779. };
  10780. /**
  10781. * Teacup string support.
  10782. */
  10783. exports.teacup.render = function(str, options, cb) {
  10784. var coffee = require('coffee-script');
  10785. var vm = require('vm');
  10786. var sandbox = {
  10787. module: {exports: {}},
  10788. require: commonjsRequire
  10789. };
  10790. return promisify(cb, function(cb) {
  10791. vm.runInNewContext(coffee.compile(str), sandbox);
  10792. var tmpl = sandbox.module.exports;
  10793. cb(null, tmpl(options));
  10794. });
  10795. };
  10796. /**
  10797. * Squirrelly support.
  10798. */
  10799. exports.squirrelly = fromStringRenderer('squirrelly');
  10800. /**
  10801. * Squirrelly string support.
  10802. */
  10803. exports.squirrelly.render = function(str, options, cb) {
  10804. return promisify(cb, function(cb) {
  10805. var engine = requires.squirrelly || (requires.squirrelly = require('squirrelly'));
  10806. try {
  10807. for (var partial in options.partials) {
  10808. engine.definePartial(partial, options.partials[partial]);
  10809. }
  10810. for (var helper in options.helpers) {
  10811. engine.defineHelper(helper, options.helpers[helper]);
  10812. }
  10813. var tmpl = cache(options) || cache(options, engine.Compile(str, options));
  10814. cb(null, tmpl(options, engine));
  10815. } catch (err) {
  10816. cb(err);
  10817. }
  10818. });
  10819. };
  10820. /**
  10821. * Twing support.
  10822. */
  10823. exports.twing = fromStringRenderer('twing');
  10824. /**
  10825. * Twing string support.
  10826. */
  10827. exports.twing.render = function(str, options, cb) {
  10828. return promisify(cb, function(cb) {
  10829. var engine = requires.twing || (requires.twing = require('twing'));
  10830. try {
  10831. new engine.TwingEnvironment(new engine.TwingLoaderNull()).createTemplate(str).then((twingTemplate) => {
  10832. twingTemplate.render(options).then((rendTmpl) => {
  10833. var tmpl = cache(options) || cache(options, rendTmpl);
  10834. cb(null, tmpl);
  10835. });
  10836. });
  10837. } catch (err) {
  10838. cb(err);
  10839. }
  10840. });
  10841. };
  10842. /**
  10843. * expose the instance of the engine
  10844. */
  10845. exports.requires = requires;
  10846. } (consolidate$1, consolidate$1.exports));
  10847. (function (module) {
  10848. module.exports = consolidate$1.exports;
  10849. } (consolidate$2));
  10850. var consolidate = /*@__PURE__*/getDefaultExportFromCjs(consolidate$2.exports);
  10851. let isStaticKey;
  10852. let isPlatformReservedTag$1;
  10853. const genStaticKeysCached = cached(genStaticKeys);
  10854. /**
  10855. * Goal of the optimizer: walk the generated template AST tree
  10856. * and detect sub-trees that are purely static, i.e. parts of
  10857. * the DOM that never needs to change.
  10858. *
  10859. * Once we detect these sub-trees, we can:
  10860. *
  10861. * 1. Hoist them into constants, so that we no longer need to
  10862. * create fresh nodes for them on each re-render;
  10863. * 2. Completely skip them in the patching process.
  10864. */
  10865. function optimize$1(root, options) {
  10866. if (!root)
  10867. return;
  10868. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10869. isPlatformReservedTag$1 = options.isReservedTag || no;
  10870. // first pass: mark all non-static nodes.
  10871. markStatic(root);
  10872. // second pass: mark static roots.
  10873. markStaticRoots(root, false);
  10874. }
  10875. function genStaticKeys(keys) {
  10876. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10877. (keys ? ',' + keys : ''));
  10878. }
  10879. function markStatic(node) {
  10880. node.static = isStatic(node);
  10881. if (node.type === 1) {
  10882. // do not make component slot content static. this avoids
  10883. // 1. components not able to mutate slot nodes
  10884. // 2. static slot content fails for hot-reloading
  10885. if (!isPlatformReservedTag$1(node.tag) &&
  10886. node.tag !== 'slot' &&
  10887. node.attrsMap['inline-template'] == null) {
  10888. return;
  10889. }
  10890. for (let i = 0, l = node.children.length; i < l; i++) {
  10891. const child = node.children[i];
  10892. markStatic(child);
  10893. if (!child.static) {
  10894. node.static = false;
  10895. }
  10896. }
  10897. if (node.ifConditions) {
  10898. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10899. const block = node.ifConditions[i].block;
  10900. markStatic(block);
  10901. if (!block.static) {
  10902. node.static = false;
  10903. }
  10904. }
  10905. }
  10906. }
  10907. }
  10908. function markStaticRoots(node, isInFor) {
  10909. if (node.type === 1) {
  10910. if (node.static || node.once) {
  10911. node.staticInFor = isInFor;
  10912. }
  10913. // For a node to qualify as a static root, it should have children that
  10914. // are not just static text. Otherwise the cost of hoisting out will
  10915. // outweigh the benefits and it's better off to just always render it fresh.
  10916. if (node.static &&
  10917. node.children.length &&
  10918. !(node.children.length === 1 && node.children[0].type === 3)) {
  10919. node.staticRoot = true;
  10920. return;
  10921. }
  10922. else {
  10923. node.staticRoot = false;
  10924. }
  10925. if (node.children) {
  10926. for (let i = 0, l = node.children.length; i < l; i++) {
  10927. markStaticRoots(node.children[i], isInFor || !!node.for);
  10928. }
  10929. }
  10930. if (node.ifConditions) {
  10931. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10932. markStaticRoots(node.ifConditions[i].block, isInFor);
  10933. }
  10934. }
  10935. }
  10936. }
  10937. function isStatic(node) {
  10938. if (node.type === 2) {
  10939. // expression
  10940. return false;
  10941. }
  10942. if (node.type === 3) {
  10943. // text
  10944. return true;
  10945. }
  10946. return !!(node.pre ||
  10947. (!node.hasBindings && // no dynamic bindings
  10948. !node.if &&
  10949. !node.for && // not v-if or v-for or v-else
  10950. !isBuiltInTag(node.tag) && // not a built-in
  10951. isPlatformReservedTag$1(node.tag) && // not a component
  10952. !isDirectChildOfTemplateFor(node) &&
  10953. Object.keys(node).every(isStaticKey)));
  10954. }
  10955. function isDirectChildOfTemplateFor(node) {
  10956. while (node.parent) {
  10957. node = node.parent;
  10958. if (node.tag !== 'template') {
  10959. return false;
  10960. }
  10961. if (node.for) {
  10962. return true;
  10963. }
  10964. }
  10965. return false;
  10966. }
  10967. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10968. const fnInvokeRE = /\([^)]*?\);*$/;
  10969. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10970. // KeyboardEvent.keyCode aliases
  10971. const keyCodes = {
  10972. esc: 27,
  10973. tab: 9,
  10974. enter: 13,
  10975. space: 32,
  10976. up: 38,
  10977. left: 37,
  10978. right: 39,
  10979. down: 40,
  10980. delete: [8, 46]
  10981. };
  10982. // KeyboardEvent.key aliases
  10983. const keyNames = {
  10984. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10985. esc: ['Esc', 'Escape'],
  10986. tab: 'Tab',
  10987. enter: 'Enter',
  10988. // #9112: IE11 uses `Spacebar` for Space key name.
  10989. space: [' ', 'Spacebar'],
  10990. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10991. up: ['Up', 'ArrowUp'],
  10992. left: ['Left', 'ArrowLeft'],
  10993. right: ['Right', 'ArrowRight'],
  10994. down: ['Down', 'ArrowDown'],
  10995. // #9112: IE11 uses `Del` for Delete key name.
  10996. delete: ['Backspace', 'Delete', 'Del']
  10997. };
  10998. // #4868: modifiers that prevent the execution of the listener
  10999. // need to explicitly return null so that we can determine whether to remove
  11000. // the listener for .once
  11001. const genGuard = condition => `if(${condition})return null;`;
  11002. const modifierCode = {
  11003. stop: '$event.stopPropagation();',
  11004. prevent: '$event.preventDefault();',
  11005. self: genGuard(`$event.target !== $event.currentTarget`),
  11006. ctrl: genGuard(`!$event.ctrlKey`),
  11007. shift: genGuard(`!$event.shiftKey`),
  11008. alt: genGuard(`!$event.altKey`),
  11009. meta: genGuard(`!$event.metaKey`),
  11010. left: genGuard(`'button' in $event && $event.button !== 0`),
  11011. middle: genGuard(`'button' in $event && $event.button !== 1`),
  11012. right: genGuard(`'button' in $event && $event.button !== 2`)
  11013. };
  11014. function genHandlers(events, isNative) {
  11015. const prefix = isNative ? 'nativeOn:' : 'on:';
  11016. let staticHandlers = ``;
  11017. let dynamicHandlers = ``;
  11018. for (const name in events) {
  11019. const handlerCode = genHandler(events[name]);
  11020. //@ts-expect-error
  11021. if (events[name] && events[name].dynamic) {
  11022. dynamicHandlers += `${name},${handlerCode},`;
  11023. }
  11024. else {
  11025. staticHandlers += `"${name}":${handlerCode},`;
  11026. }
  11027. }
  11028. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  11029. if (dynamicHandlers) {
  11030. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  11031. }
  11032. else {
  11033. return prefix + staticHandlers;
  11034. }
  11035. }
  11036. function genHandler(handler) {
  11037. if (!handler) {
  11038. return 'function(){}';
  11039. }
  11040. if (Array.isArray(handler)) {
  11041. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  11042. }
  11043. const isMethodPath = simplePathRE.test(handler.value);
  11044. const isFunctionExpression = fnExpRE.test(handler.value);
  11045. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  11046. if (!handler.modifiers) {
  11047. if (isMethodPath || isFunctionExpression) {
  11048. return handler.value;
  11049. }
  11050. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  11051. }
  11052. else {
  11053. let code = '';
  11054. let genModifierCode = '';
  11055. const keys = [];
  11056. for (const key in handler.modifiers) {
  11057. if (modifierCode[key]) {
  11058. genModifierCode += modifierCode[key];
  11059. // left/right
  11060. if (keyCodes[key]) {
  11061. keys.push(key);
  11062. }
  11063. }
  11064. else if (key === 'exact') {
  11065. const modifiers = handler.modifiers;
  11066. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  11067. .filter(keyModifier => !modifiers[keyModifier])
  11068. .map(keyModifier => `$event.${keyModifier}Key`)
  11069. .join('||'));
  11070. }
  11071. else {
  11072. keys.push(key);
  11073. }
  11074. }
  11075. if (keys.length) {
  11076. code += genKeyFilter(keys);
  11077. }
  11078. // Make sure modifiers like prevent and stop get executed after key filtering
  11079. if (genModifierCode) {
  11080. code += genModifierCode;
  11081. }
  11082. const handlerCode = isMethodPath
  11083. ? `return ${handler.value}.apply(null, arguments)`
  11084. : isFunctionExpression
  11085. ? `return (${handler.value}).apply(null, arguments)`
  11086. : isFunctionInvocation
  11087. ? `return ${handler.value}`
  11088. : handler.value;
  11089. return `function($event){${code}${handlerCode}}`;
  11090. }
  11091. }
  11092. function genKeyFilter(keys) {
  11093. return (
  11094. // make sure the key filters only apply to KeyboardEvents
  11095. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  11096. // key events that do not have keyCode property...
  11097. `if(!$event.type.indexOf('key')&&` +
  11098. `${keys.map(genFilterCode).join('&&')})return null;`);
  11099. }
  11100. function genFilterCode(key) {
  11101. const keyVal = parseInt(key, 10);
  11102. if (keyVal) {
  11103. return `$event.keyCode!==${keyVal}`;
  11104. }
  11105. const keyCode = keyCodes[key];
  11106. const keyName = keyNames[key];
  11107. return (`_k($event.keyCode,` +
  11108. `${JSON.stringify(key)},` +
  11109. `${JSON.stringify(keyCode)},` +
  11110. `$event.key,` +
  11111. `${JSON.stringify(keyName)}` +
  11112. `)`);
  11113. }
  11114. function on(el, dir) {
  11115. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  11116. warn$3(`v-on without argument does not support modifiers.`);
  11117. }
  11118. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  11119. }
  11120. function bind(el, dir) {
  11121. el.wrapData = (code) => {
  11122. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  11123. };
  11124. }
  11125. var baseDirectives = {
  11126. on,
  11127. bind,
  11128. cloak: noop
  11129. };
  11130. class CodegenState {
  11131. constructor(options) {
  11132. this.options = options;
  11133. this.warn = options.warn || baseWarn;
  11134. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  11135. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  11136. this.directives = extend(extend({}, baseDirectives), options.directives);
  11137. const isReservedTag = options.isReservedTag || no;
  11138. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  11139. this.onceId = 0;
  11140. this.staticRenderFns = [];
  11141. this.pre = false;
  11142. }
  11143. }
  11144. function generate$1(ast, options) {
  11145. const state = new CodegenState(options);
  11146. // fix #11483, Root level <script> tags should not be rendered.
  11147. const code = ast
  11148. ? ast.tag === 'script'
  11149. ? 'null'
  11150. : genElement(ast, state)
  11151. : '_c("div")';
  11152. return {
  11153. render: `with(this){return ${code}}`,
  11154. staticRenderFns: state.staticRenderFns
  11155. };
  11156. }
  11157. function genElement(el, state) {
  11158. if (el.parent) {
  11159. el.pre = el.pre || el.parent.pre;
  11160. }
  11161. if (el.staticRoot && !el.staticProcessed) {
  11162. return genStatic(el, state);
  11163. }
  11164. else if (el.once && !el.onceProcessed) {
  11165. return genOnce(el, state);
  11166. }
  11167. else if (el.for && !el.forProcessed) {
  11168. return genFor(el, state);
  11169. }
  11170. else if (el.if && !el.ifProcessed) {
  11171. return genIf(el, state);
  11172. }
  11173. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  11174. return genChildren(el, state) || 'void 0';
  11175. }
  11176. else if (el.tag === 'slot') {
  11177. return genSlot(el, state);
  11178. }
  11179. else {
  11180. // component or element
  11181. let code;
  11182. if (el.component) {
  11183. code = genComponent(el.component, el, state);
  11184. }
  11185. else {
  11186. let data;
  11187. const maybeComponent = state.maybeComponent(el);
  11188. if (!el.plain || (el.pre && maybeComponent)) {
  11189. data = genData(el, state);
  11190. }
  11191. let tag;
  11192. // check if this is a component in <script setup>
  11193. const bindings = state.options.bindings;
  11194. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  11195. tag = checkBindingType(bindings, el.tag);
  11196. }
  11197. if (!tag)
  11198. tag = `'${el.tag}'`;
  11199. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11200. code = `_c(${tag}${data ? `,${data}` : '' // data
  11201. }${children ? `,${children}` : '' // children
  11202. })`;
  11203. }
  11204. // module transforms
  11205. for (let i = 0; i < state.transforms.length; i++) {
  11206. code = state.transforms[i](el, code);
  11207. }
  11208. return code;
  11209. }
  11210. }
  11211. function checkBindingType(bindings, key) {
  11212. const camelName = camelize(key);
  11213. const PascalName = capitalize(camelName);
  11214. const checkType = (type) => {
  11215. if (bindings[key] === type) {
  11216. return key;
  11217. }
  11218. if (bindings[camelName] === type) {
  11219. return camelName;
  11220. }
  11221. if (bindings[PascalName] === type) {
  11222. return PascalName;
  11223. }
  11224. };
  11225. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  11226. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  11227. if (fromConst) {
  11228. return fromConst;
  11229. }
  11230. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  11231. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  11232. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  11233. if (fromMaybeRef) {
  11234. return fromMaybeRef;
  11235. }
  11236. }
  11237. // hoist static sub-trees out
  11238. function genStatic(el, state) {
  11239. el.staticProcessed = true;
  11240. // Some elements (templates) need to behave differently inside of a v-pre
  11241. // node. All pre nodes are static roots, so we can use this as a location to
  11242. // wrap a state change and reset it upon exiting the pre node.
  11243. const originalPreState = state.pre;
  11244. if (el.pre) {
  11245. state.pre = el.pre;
  11246. }
  11247. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  11248. state.pre = originalPreState;
  11249. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  11250. }
  11251. // v-once
  11252. function genOnce(el, state) {
  11253. el.onceProcessed = true;
  11254. if (el.if && !el.ifProcessed) {
  11255. return genIf(el, state);
  11256. }
  11257. else if (el.staticInFor) {
  11258. let key = '';
  11259. let parent = el.parent;
  11260. while (parent) {
  11261. if (parent.for) {
  11262. key = parent.key;
  11263. break;
  11264. }
  11265. parent = parent.parent;
  11266. }
  11267. if (!key) {
  11268. process.env.NODE_ENV !== 'production' &&
  11269. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  11270. return genElement(el, state);
  11271. }
  11272. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  11273. }
  11274. else {
  11275. return genStatic(el, state);
  11276. }
  11277. }
  11278. function genIf(el, state, altGen, altEmpty) {
  11279. el.ifProcessed = true; // avoid recursion
  11280. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  11281. }
  11282. function genIfConditions(conditions, state, altGen, altEmpty) {
  11283. if (!conditions.length) {
  11284. return altEmpty || '_e()';
  11285. }
  11286. const condition = conditions.shift();
  11287. if (condition.exp) {
  11288. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  11289. }
  11290. else {
  11291. return `${genTernaryExp(condition.block)}`;
  11292. }
  11293. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  11294. function genTernaryExp(el) {
  11295. return altGen
  11296. ? altGen(el, state)
  11297. : el.once
  11298. ? genOnce(el, state)
  11299. : genElement(el, state);
  11300. }
  11301. }
  11302. function genFor(el, state, altGen, altHelper) {
  11303. const exp = el.for;
  11304. const alias = el.alias;
  11305. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  11306. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  11307. if (process.env.NODE_ENV !== 'production' &&
  11308. state.maybeComponent(el) &&
  11309. el.tag !== 'slot' &&
  11310. el.tag !== 'template' &&
  11311. !el.key) {
  11312. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  11313. `v-for should have explicit keys. ` +
  11314. `See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  11315. }
  11316. el.forProcessed = true; // avoid recursion
  11317. return (`${altHelper || '_l'}((${exp}),` +
  11318. `function(${alias}${iterator1}${iterator2}){` +
  11319. `return ${(altGen || genElement)(el, state)}` +
  11320. '})');
  11321. }
  11322. function genData(el, state) {
  11323. let data = '{';
  11324. // directives first.
  11325. // directives may mutate the el's other properties before they are generated.
  11326. const dirs = genDirectives(el, state);
  11327. if (dirs)
  11328. data += dirs + ',';
  11329. // key
  11330. if (el.key) {
  11331. data += `key:${el.key},`;
  11332. }
  11333. // ref
  11334. if (el.ref) {
  11335. data += `ref:${el.ref},`;
  11336. }
  11337. if (el.refInFor) {
  11338. data += `refInFor:true,`;
  11339. }
  11340. // pre
  11341. if (el.pre) {
  11342. data += `pre:true,`;
  11343. }
  11344. // record original tag name for components using "is" attribute
  11345. if (el.component) {
  11346. data += `tag:"${el.tag}",`;
  11347. }
  11348. // module data generation functions
  11349. for (let i = 0; i < state.dataGenFns.length; i++) {
  11350. data += state.dataGenFns[i](el);
  11351. }
  11352. // attributes
  11353. if (el.attrs) {
  11354. data += `attrs:${genProps(el.attrs)},`;
  11355. }
  11356. // DOM props
  11357. if (el.props) {
  11358. data += `domProps:${genProps(el.props)},`;
  11359. }
  11360. // event handlers
  11361. if (el.events) {
  11362. data += `${genHandlers(el.events, false)},`;
  11363. }
  11364. if (el.nativeEvents) {
  11365. data += `${genHandlers(el.nativeEvents, true)},`;
  11366. }
  11367. // slot target
  11368. // only for non-scoped slots
  11369. if (el.slotTarget && !el.slotScope) {
  11370. data += `slot:${el.slotTarget},`;
  11371. }
  11372. // scoped slots
  11373. if (el.scopedSlots) {
  11374. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  11375. }
  11376. // component v-model
  11377. if (el.model) {
  11378. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  11379. }
  11380. // inline-template
  11381. if (el.inlineTemplate) {
  11382. const inlineTemplate = genInlineTemplate(el, state);
  11383. if (inlineTemplate) {
  11384. data += `${inlineTemplate},`;
  11385. }
  11386. }
  11387. data = data.replace(/,$/, '') + '}';
  11388. // v-bind dynamic argument wrap
  11389. // v-bind with dynamic arguments must be applied using the same v-bind object
  11390. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  11391. if (el.dynamicAttrs) {
  11392. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  11393. }
  11394. // v-bind data wrap
  11395. if (el.wrapData) {
  11396. data = el.wrapData(data);
  11397. }
  11398. // v-on data wrap
  11399. if (el.wrapListeners) {
  11400. data = el.wrapListeners(data);
  11401. }
  11402. return data;
  11403. }
  11404. function genDirectives(el, state) {
  11405. const dirs = el.directives;
  11406. if (!dirs)
  11407. return;
  11408. let res = 'directives:[';
  11409. let hasRuntime = false;
  11410. let i, l, dir, needRuntime;
  11411. for (i = 0, l = dirs.length; i < l; i++) {
  11412. dir = dirs[i];
  11413. needRuntime = true;
  11414. const gen = state.directives[dir.name];
  11415. if (gen) {
  11416. // compile-time directive that manipulates AST.
  11417. // returns true if it also needs a runtime counterpart.
  11418. needRuntime = !!gen(el, dir, state.warn);
  11419. }
  11420. if (needRuntime) {
  11421. hasRuntime = true;
  11422. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11423. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11424. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11425. }
  11426. }
  11427. if (hasRuntime) {
  11428. return res.slice(0, -1) + ']';
  11429. }
  11430. }
  11431. function genInlineTemplate(el, state) {
  11432. const ast = el.children[0];
  11433. if (process.env.NODE_ENV !== 'production' && (el.children.length !== 1 || ast.type !== 1)) {
  11434. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11435. }
  11436. if (ast && ast.type === 1) {
  11437. const inlineRenderFns = generate$1(ast, state.options);
  11438. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11439. .map(code => `function(){${code}}`)
  11440. .join(',')}]}`;
  11441. }
  11442. }
  11443. function genScopedSlots(el, slots, state) {
  11444. // by default scoped slots are considered "stable", this allows child
  11445. // components with only scoped slots to skip forced updates from parent.
  11446. // but in some cases we have to bail-out of this optimization
  11447. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11448. let needsForceUpdate = el.for ||
  11449. Object.keys(slots).some(key => {
  11450. const slot = slots[key];
  11451. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11452. );
  11453. });
  11454. // #9534: if a component with scoped slots is inside a conditional branch,
  11455. // it's possible for the same component to be reused but with different
  11456. // compiled slot content. To avoid that, we generate a unique key based on
  11457. // the generated code of all the slot contents.
  11458. let needsKey = !!el.if;
  11459. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11460. // disconnected due to the intermediate scope variable)
  11461. // #9438, #9506
  11462. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11463. // and skip force updating ones that do not actually use scope variables.
  11464. if (!needsForceUpdate) {
  11465. let parent = el.parent;
  11466. while (parent) {
  11467. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11468. parent.for) {
  11469. needsForceUpdate = true;
  11470. break;
  11471. }
  11472. if (parent.if) {
  11473. needsKey = true;
  11474. }
  11475. parent = parent.parent;
  11476. }
  11477. }
  11478. const generatedSlots = Object.keys(slots)
  11479. .map(key => genScopedSlot(slots[key], state))
  11480. .join(',');
  11481. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11482. }
  11483. function hash(str) {
  11484. let hash = 5381;
  11485. let i = str.length;
  11486. while (i) {
  11487. hash = (hash * 33) ^ str.charCodeAt(--i);
  11488. }
  11489. return hash >>> 0;
  11490. }
  11491. function containsSlotChild(el) {
  11492. if (el.type === 1) {
  11493. if (el.tag === 'slot') {
  11494. return true;
  11495. }
  11496. return el.children.some(containsSlotChild);
  11497. }
  11498. return false;
  11499. }
  11500. function genScopedSlot(el, state) {
  11501. const isLegacySyntax = el.attrsMap['slot-scope'];
  11502. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11503. return genIf(el, state, genScopedSlot, `null`);
  11504. }
  11505. if (el.for && !el.forProcessed) {
  11506. return genFor(el, state, genScopedSlot);
  11507. }
  11508. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11509. const fn = `function(${slotScope}){` +
  11510. `return ${el.tag === 'template'
  11511. ? el.if && isLegacySyntax
  11512. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11513. : genChildren(el, state) || 'undefined'
  11514. : genElement(el, state)}}`;
  11515. // reverse proxy v-slot without scope on this.$slots
  11516. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11517. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11518. }
  11519. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11520. const children = el.children;
  11521. if (children.length) {
  11522. const el = children[0];
  11523. // optimize single v-for
  11524. if (children.length === 1 &&
  11525. el.for &&
  11526. el.tag !== 'template' &&
  11527. el.tag !== 'slot') {
  11528. const normalizationType = checkSkip
  11529. ? state.maybeComponent(el)
  11530. ? `,1`
  11531. : `,0`
  11532. : ``;
  11533. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11534. }
  11535. const normalizationType = checkSkip
  11536. ? getNormalizationType(children, state.maybeComponent)
  11537. : 0;
  11538. const gen = altGenNode || genNode;
  11539. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11540. }
  11541. }
  11542. // determine the normalization needed for the children array.
  11543. // 0: no normalization needed
  11544. // 1: simple normalization needed (possible 1-level deep nested array)
  11545. // 2: full normalization needed
  11546. function getNormalizationType(children, maybeComponent) {
  11547. let res = 0;
  11548. for (let i = 0; i < children.length; i++) {
  11549. const el = children[i];
  11550. if (el.type !== 1) {
  11551. continue;
  11552. }
  11553. if (needsNormalization(el) ||
  11554. (el.ifConditions &&
  11555. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11556. res = 2;
  11557. break;
  11558. }
  11559. if (maybeComponent(el) ||
  11560. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11561. res = 1;
  11562. }
  11563. }
  11564. return res;
  11565. }
  11566. function needsNormalization(el) {
  11567. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11568. }
  11569. function genNode(node, state) {
  11570. if (node.type === 1) {
  11571. return genElement(node, state);
  11572. }
  11573. else if (node.type === 3 && node.isComment) {
  11574. return genComment(node);
  11575. }
  11576. else {
  11577. return genText(node);
  11578. }
  11579. }
  11580. function genText(text) {
  11581. return `_v(${text.type === 2
  11582. ? text.expression // no need for () because already wrapped in _s()
  11583. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11584. }
  11585. function genComment(comment) {
  11586. return `_e(${JSON.stringify(comment.text)})`;
  11587. }
  11588. function genSlot(el, state) {
  11589. const slotName = el.slotName || '"default"';
  11590. const children = genChildren(el, state);
  11591. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11592. const attrs = el.attrs || el.dynamicAttrs
  11593. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11594. // slot props are camelized
  11595. name: camelize(attr.name),
  11596. value: attr.value,
  11597. dynamic: attr.dynamic
  11598. })))
  11599. : null;
  11600. const bind = el.attrsMap['v-bind'];
  11601. if ((attrs || bind) && !children) {
  11602. res += `,null`;
  11603. }
  11604. if (attrs) {
  11605. res += `,${attrs}`;
  11606. }
  11607. if (bind) {
  11608. res += `${attrs ? '' : ',null'},${bind}`;
  11609. }
  11610. return res + ')';
  11611. }
  11612. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11613. function genComponent(componentName, el, state) {
  11614. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11615. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11616. }
  11617. function genProps(props) {
  11618. let staticProps = ``;
  11619. let dynamicProps = ``;
  11620. for (let i = 0; i < props.length; i++) {
  11621. const prop = props[i];
  11622. const value = transformSpecialNewlines(prop.value);
  11623. if (prop.dynamic) {
  11624. dynamicProps += `${prop.name},${value},`;
  11625. }
  11626. else {
  11627. staticProps += `"${prop.name}":${value},`;
  11628. }
  11629. }
  11630. staticProps = `{${staticProps.slice(0, -1)}}`;
  11631. if (dynamicProps) {
  11632. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11633. }
  11634. else {
  11635. return staticProps;
  11636. }
  11637. }
  11638. // #3895, #4268
  11639. function transformSpecialNewlines(text) {
  11640. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11641. }
  11642. // these keywords should not appear inside expressions, but operators like
  11643. // typeof, instanceof and in are allowed
  11644. const prohibitedKeywordRE = new RegExp('\\b' +
  11645. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11646. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11647. 'extends,finally,continue,debugger,function,arguments')
  11648. .split(',')
  11649. .join('\\b|\\b') +
  11650. '\\b');
  11651. // these unary operators should not be used as property/method names
  11652. const unaryOperatorsRE = new RegExp('\\b' +
  11653. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11654. '\\s*\\([^\\)]*\\)');
  11655. // strip strings in expressions
  11656. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11657. // detect problematic expressions in a template
  11658. function detectErrors(ast, warn) {
  11659. if (ast) {
  11660. checkNode(ast, warn);
  11661. }
  11662. }
  11663. function checkNode(node, warn) {
  11664. if (node.type === 1) {
  11665. for (const name in node.attrsMap) {
  11666. if (dirRE.test(name)) {
  11667. const value = node.attrsMap[name];
  11668. if (value) {
  11669. const range = node.rawAttrsMap[name];
  11670. if (name === 'v-for') {
  11671. checkFor(node, `v-for="${value}"`, warn, range);
  11672. }
  11673. else if (name === 'v-slot' || name[0] === '#') {
  11674. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11675. }
  11676. else if (onRE.test(name)) {
  11677. checkEvent(value, `${name}="${value}"`, warn, range);
  11678. }
  11679. else {
  11680. checkExpression(value, `${name}="${value}"`, warn, range);
  11681. }
  11682. }
  11683. }
  11684. }
  11685. if (node.children) {
  11686. for (let i = 0; i < node.children.length; i++) {
  11687. checkNode(node.children[i], warn);
  11688. }
  11689. }
  11690. }
  11691. else if (node.type === 2) {
  11692. checkExpression(node.expression, node.text, warn, node);
  11693. }
  11694. }
  11695. function checkEvent(exp, text, warn, range) {
  11696. const stripped = exp.replace(stripStringRE, '');
  11697. const keywordMatch = stripped.match(unaryOperatorsRE);
  11698. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11699. warn(`avoid using JavaScript unary operator as property name: ` +
  11700. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11701. }
  11702. checkExpression(exp, text, warn, range);
  11703. }
  11704. function checkFor(node, text, warn, range) {
  11705. checkExpression(node.for || '', text, warn, range);
  11706. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11707. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11708. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11709. }
  11710. function checkIdentifier(ident, type, text, warn, range) {
  11711. if (typeof ident === 'string') {
  11712. try {
  11713. new Function(`var ${ident}=_`);
  11714. }
  11715. catch (e) {
  11716. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11717. }
  11718. }
  11719. }
  11720. function checkExpression(exp, text, warn, range) {
  11721. try {
  11722. new Function(`return ${exp}`);
  11723. }
  11724. catch (e) {
  11725. const keywordMatch = exp
  11726. .replace(stripStringRE, '')
  11727. .match(prohibitedKeywordRE);
  11728. if (keywordMatch) {
  11729. warn(`avoid using JavaScript keyword as property name: ` +
  11730. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11731. }
  11732. else {
  11733. warn(`invalid expression: ${e.message} in\n\n` +
  11734. ` ${exp}\n\n` +
  11735. ` Raw expression: ${text.trim()}\n`, range);
  11736. }
  11737. }
  11738. }
  11739. function checkFunctionParameterExpression(exp, text, warn, range) {
  11740. try {
  11741. new Function(exp, '');
  11742. }
  11743. catch (e) {
  11744. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11745. ` ${exp}\n\n` +
  11746. ` Raw expression: ${text.trim()}\n`, range);
  11747. }
  11748. }
  11749. function createFunction(code, errors) {
  11750. try {
  11751. return new Function(code);
  11752. }
  11753. catch (err) {
  11754. errors.push({ err, code });
  11755. return noop;
  11756. }
  11757. }
  11758. function createCompileToFunctionFn(compile) {
  11759. const cache = Object.create(null);
  11760. return function compileToFunctions(template, options, vm) {
  11761. options = extend({}, options);
  11762. const warn = options.warn || warn$3;
  11763. delete options.warn;
  11764. /* istanbul ignore if */
  11765. if (process.env.NODE_ENV !== 'production') {
  11766. // detect possible CSP restriction
  11767. try {
  11768. new Function('return 1');
  11769. }
  11770. catch (e) {
  11771. if (e.toString().match(/unsafe-eval|CSP/)) {
  11772. warn('It seems you are using the standalone build of Vue.js in an ' +
  11773. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11774. 'The template compiler cannot work in this environment. Consider ' +
  11775. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11776. 'templates into render functions.');
  11777. }
  11778. }
  11779. }
  11780. // check cache
  11781. const key = options.delimiters
  11782. ? String(options.delimiters) + template
  11783. : template;
  11784. if (cache[key]) {
  11785. return cache[key];
  11786. }
  11787. // compile
  11788. const compiled = compile(template, options);
  11789. // check compilation errors/tips
  11790. if (process.env.NODE_ENV !== 'production') {
  11791. if (compiled.errors && compiled.errors.length) {
  11792. if (options.outputSourceRange) {
  11793. compiled.errors.forEach(e => {
  11794. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11795. generateCodeFrame(template, e.start, e.end), vm);
  11796. });
  11797. }
  11798. else {
  11799. warn(`Error compiling template:\n\n${template}\n\n` +
  11800. compiled.errors.map(e => `- ${e}`).join('\n') +
  11801. '\n', vm);
  11802. }
  11803. }
  11804. if (compiled.tips && compiled.tips.length) {
  11805. if (options.outputSourceRange) {
  11806. compiled.tips.forEach(e => tip(e.msg, vm));
  11807. }
  11808. else {
  11809. compiled.tips.forEach(msg => tip(msg, vm));
  11810. }
  11811. }
  11812. }
  11813. // turn code into functions
  11814. const res = {};
  11815. const fnGenErrors = [];
  11816. res.render = createFunction(compiled.render, fnGenErrors);
  11817. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11818. return createFunction(code, fnGenErrors);
  11819. });
  11820. // check function generation errors.
  11821. // this should only happen if there is a bug in the compiler itself.
  11822. // mostly for codegen development use
  11823. /* istanbul ignore if */
  11824. if (process.env.NODE_ENV !== 'production') {
  11825. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11826. warn(`Failed to generate render function:\n\n` +
  11827. fnGenErrors
  11828. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11829. .join('\n'), vm);
  11830. }
  11831. }
  11832. return (cache[key] = res);
  11833. };
  11834. }
  11835. function createCompilerCreator(baseCompile) {
  11836. return function createCompiler(baseOptions) {
  11837. function compile(template, options) {
  11838. const finalOptions = Object.create(baseOptions);
  11839. const errors = [];
  11840. const tips = [];
  11841. let warn = (msg, range, tip) => {
  11842. (tip ? tips : errors).push(msg);
  11843. };
  11844. if (options) {
  11845. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  11846. // $flow-disable-line
  11847. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11848. warn = (msg, range, tip) => {
  11849. const data = typeof msg === 'string' ? { msg } : msg;
  11850. if (range) {
  11851. if (range.start != null) {
  11852. data.start = range.start + leadingSpaceLength;
  11853. }
  11854. if (range.end != null) {
  11855. data.end = range.end + leadingSpaceLength;
  11856. }
  11857. }
  11858. (tip ? tips : errors).push(data);
  11859. };
  11860. }
  11861. // merge custom modules
  11862. if (options.modules) {
  11863. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11864. }
  11865. // merge custom directives
  11866. if (options.directives) {
  11867. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11868. }
  11869. // copy other options
  11870. for (const key in options) {
  11871. if (key !== 'modules' && key !== 'directives') {
  11872. finalOptions[key] = options[key];
  11873. }
  11874. }
  11875. }
  11876. finalOptions.warn = warn;
  11877. const compiled = baseCompile(template.trim(), finalOptions);
  11878. if (process.env.NODE_ENV !== 'production') {
  11879. detectErrors(compiled.ast, warn);
  11880. }
  11881. compiled.errors = errors;
  11882. compiled.tips = tips;
  11883. return compiled;
  11884. }
  11885. return {
  11886. compile,
  11887. compileToFunctions: createCompileToFunctionFn(compile)
  11888. };
  11889. };
  11890. }
  11891. // `createCompilerCreator` allows creating compilers that use alternative
  11892. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11893. // Here we just export a default compiler using the default parts.
  11894. const createCompiler$1 = createCompilerCreator(function baseCompile(template, options) {
  11895. const ast = parse$1(template.trim(), options);
  11896. if (options.optimize !== false) {
  11897. optimize$1(ast, options);
  11898. }
  11899. const code = generate$1(ast, options);
  11900. return {
  11901. ast,
  11902. render: code.render,
  11903. staticRenderFns: code.staticRenderFns
  11904. };
  11905. });
  11906. const { compile: compile$1, compileToFunctions: compileToFunctions$1 } = createCompiler$1(baseOptions);
  11907. const isAttr = makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  11908. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  11909. 'checked,cite,class,code,codebase,color,cols,colspan,content,' +
  11910. 'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  11911. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
  11912. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  11913. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  11914. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  11915. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  11916. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  11917. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  11918. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  11919. 'target,title,usemap,value,width,wrap');
  11920. /* istanbul ignore next */
  11921. const isRenderableAttr = (name) => {
  11922. return (isAttr(name) || name.indexOf('data-') === 0 || name.indexOf('aria-') === 0);
  11923. };
  11924. const propsToAttrMap = {
  11925. acceptCharset: 'accept-charset',
  11926. className: 'class',
  11927. htmlFor: 'for',
  11928. httpEquiv: 'http-equiv'
  11929. };
  11930. const ESC = {
  11931. '<': '&lt;',
  11932. '>': '&gt;',
  11933. '"': '&quot;',
  11934. '&': '&amp;'
  11935. };
  11936. function escape(s) {
  11937. return s.replace(/[<>"&]/g, escapeChar);
  11938. }
  11939. function escapeChar(a) {
  11940. return ESC[a] || a;
  11941. }
  11942. const plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  11943. // let the model AST transform translate v-model into appropriate
  11944. // props bindings
  11945. function applyModelTransform(el, state) {
  11946. if (el.directives) {
  11947. for (let i = 0; i < el.directives.length; i++) {
  11948. const dir = el.directives[i];
  11949. if (dir.name === 'model') {
  11950. state.directives.model(el, dir, state.warn);
  11951. // remove value for textarea as its converted to text
  11952. if (el.tag === 'textarea' && el.props) {
  11953. el.props = el.props.filter(p => p.name !== 'value');
  11954. }
  11955. break;
  11956. }
  11957. }
  11958. }
  11959. }
  11960. function genAttrSegments(attrs) {
  11961. return attrs.map(({ name, value }) => genAttrSegment(name, value));
  11962. }
  11963. function genDOMPropSegments(props, attrs) {
  11964. const segments = [];
  11965. props.forEach(({ name, value }) => {
  11966. name = propsToAttrMap[name] || name.toLowerCase();
  11967. if (isRenderableAttr(name) &&
  11968. !(attrs && attrs.some(a => a.name === name))) {
  11969. segments.push(genAttrSegment(name, value));
  11970. }
  11971. });
  11972. return segments;
  11973. }
  11974. function genAttrSegment(name, value) {
  11975. if (plainStringRE.test(value)) {
  11976. // force double quote
  11977. value = value.replace(/^'|'$/g, '"');
  11978. // force enumerated attr to "true"
  11979. if (isEnumeratedAttr(name) && value !== `"false"`) {
  11980. value = `"true"`;
  11981. }
  11982. return {
  11983. type: RAW,
  11984. value: isBooleanAttr(name)
  11985. ? ` ${name}="${name}"`
  11986. : value === '""'
  11987. ? ` ${name}`
  11988. : ` ${name}="${JSON.parse(value)}"`
  11989. };
  11990. }
  11991. else {
  11992. return {
  11993. type: EXPRESSION,
  11994. value: `_ssrAttr(${JSON.stringify(name)},${value})`
  11995. };
  11996. }
  11997. }
  11998. function genClassSegments(staticClass, classBinding) {
  11999. if (staticClass && !classBinding) {
  12000. return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }];
  12001. }
  12002. else {
  12003. return [
  12004. {
  12005. type: EXPRESSION,
  12006. value: `_ssrClass(${staticClass || 'null'},${classBinding || 'null'})`
  12007. }
  12008. ];
  12009. }
  12010. }
  12011. function genStyleSegments(staticStyle, parsedStaticStyle, styleBinding, vShowExpression) {
  12012. if (staticStyle && !styleBinding && !vShowExpression) {
  12013. return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle)}` }];
  12014. }
  12015. else {
  12016. return [
  12017. {
  12018. type: EXPRESSION,
  12019. value: `_ssrStyle(${parsedStaticStyle || 'null'},${styleBinding || 'null'}, ${vShowExpression
  12020. ? `{ display: (${vShowExpression}) ? '' : 'none' }`
  12021. : 'null'})`
  12022. }
  12023. ];
  12024. }
  12025. }
  12026. /**
  12027. * In SSR, the vdom tree is generated only once and never patched, so
  12028. * we can optimize most element / trees into plain string render functions.
  12029. * The SSR optimizer walks the AST tree to detect optimizable elements and trees.
  12030. *
  12031. * The criteria for SSR optimizability is quite a bit looser than static tree
  12032. * detection (which is designed for client re-render). In SSR we bail only for
  12033. * components/slots/custom directives.
  12034. */
  12035. // optimizability constants
  12036. const optimizability = {
  12037. FALSE: 0,
  12038. FULL: 1,
  12039. SELF: 2,
  12040. CHILDREN: 3,
  12041. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  12042. };
  12043. let isPlatformReservedTag;
  12044. function optimize(root, options) {
  12045. if (!root)
  12046. return;
  12047. isPlatformReservedTag = options.isReservedTag || no;
  12048. walk(root, true);
  12049. }
  12050. function walk(node, isRoot) {
  12051. if (isUnOptimizableTree(node)) {
  12052. node.ssrOptimizability = optimizability.FALSE;
  12053. return;
  12054. }
  12055. // root node or nodes with custom directives should always be a VNode
  12056. const selfUnoptimizable = isRoot || hasCustomDirective(node);
  12057. const check = child => {
  12058. if (child.ssrOptimizability !== optimizability.FULL) {
  12059. node.ssrOptimizability = selfUnoptimizable
  12060. ? optimizability.PARTIAL
  12061. : optimizability.SELF;
  12062. }
  12063. };
  12064. if (selfUnoptimizable) {
  12065. node.ssrOptimizability = optimizability.CHILDREN;
  12066. }
  12067. if (node.type === 1) {
  12068. for (let i = 0, l = node.children.length; i < l; i++) {
  12069. const child = node.children[i];
  12070. walk(child);
  12071. check(child);
  12072. }
  12073. if (node.ifConditions) {
  12074. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  12075. const block = node.ifConditions[i].block;
  12076. walk(block, isRoot);
  12077. check(block);
  12078. }
  12079. }
  12080. if (node.ssrOptimizability == null ||
  12081. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))) {
  12082. node.ssrOptimizability = optimizability.FULL;
  12083. }
  12084. else {
  12085. node.children = optimizeSiblings(node);
  12086. }
  12087. }
  12088. else {
  12089. node.ssrOptimizability = optimizability.FULL;
  12090. }
  12091. }
  12092. function optimizeSiblings(el) {
  12093. const children = el.children;
  12094. const optimizedChildren = [];
  12095. let currentOptimizableGroup = [];
  12096. const pushGroup = () => {
  12097. if (currentOptimizableGroup.length) {
  12098. optimizedChildren.push({
  12099. type: 1,
  12100. parent: el,
  12101. tag: 'template',
  12102. attrsList: [],
  12103. attrsMap: {},
  12104. rawAttrsMap: {},
  12105. children: currentOptimizableGroup,
  12106. ssrOptimizability: optimizability.FULL
  12107. });
  12108. }
  12109. currentOptimizableGroup = [];
  12110. };
  12111. for (let i = 0; i < children.length; i++) {
  12112. const c = children[i];
  12113. if (c.ssrOptimizability === optimizability.FULL) {
  12114. currentOptimizableGroup.push(c);
  12115. }
  12116. else {
  12117. // wrap fully-optimizable adjacent siblings inside a template tag
  12118. // so that they can be optimized into a single ssrNode by codegen
  12119. pushGroup();
  12120. optimizedChildren.push(c);
  12121. }
  12122. }
  12123. pushGroup();
  12124. return optimizedChildren;
  12125. }
  12126. function isUnOptimizableTree(node) {
  12127. if (node.type === 2 || node.type === 3) {
  12128. // text or expression
  12129. return false;
  12130. }
  12131. return (isBuiltInTag(node.tag) || // built-in (slot, component)
  12132. !isPlatformReservedTag(node.tag) || // custom component
  12133. !!node.component || // "is" component
  12134. isSelectWithModel(node) // <select v-model> requires runtime inspection
  12135. );
  12136. }
  12137. const isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  12138. function hasCustomDirective(node) {
  12139. return (node.type === 1 &&
  12140. node.directives &&
  12141. node.directives.some(d => !isBuiltInDir(d.name)));
  12142. }
  12143. // <select v-model> cannot be optimized because it requires a runtime check
  12144. // to determine proper selected option
  12145. function isSelectWithModel(node) {
  12146. return (node.type === 1 &&
  12147. node.tag === 'select' &&
  12148. node.directives != null &&
  12149. node.directives.some(d => d.name === 'model'));
  12150. }
  12151. // The SSR codegen is essentially extending the default codegen to handle
  12152. // segment types
  12153. const RAW = 0;
  12154. const INTERPOLATION = 1;
  12155. const EXPRESSION = 2;
  12156. function generate(ast, options) {
  12157. const state = new CodegenState(options);
  12158. const code = ast ? genSSRElement(ast, state) : '_c("div")';
  12159. return {
  12160. render: `with(this){return ${code}}`,
  12161. staticRenderFns: state.staticRenderFns
  12162. };
  12163. }
  12164. function genSSRElement(el, state) {
  12165. if (el.for && !el.forProcessed) {
  12166. return genFor(el, state, genSSRElement);
  12167. }
  12168. else if (el.if && !el.ifProcessed) {
  12169. return genIf(el, state, genSSRElement);
  12170. }
  12171. else if (el.tag === 'template' && !el.slotTarget) {
  12172. return el.ssrOptimizability === optimizability.FULL
  12173. ? genChildrenAsStringNode(el, state)
  12174. : genSSRChildren(el, state) || 'void 0';
  12175. }
  12176. switch (el.ssrOptimizability) {
  12177. case optimizability.FULL:
  12178. // stringify whole tree
  12179. return genStringElement(el, state);
  12180. case optimizability.SELF:
  12181. // stringify self and check children
  12182. return genStringElementWithChildren(el, state);
  12183. case optimizability.CHILDREN:
  12184. // generate self as VNode and stringify children
  12185. return genNormalElement(el, state, true);
  12186. case optimizability.PARTIAL:
  12187. // generate self as VNode and check children
  12188. return genNormalElement(el, state, false);
  12189. default:
  12190. // bail whole tree
  12191. return genElement(el, state);
  12192. }
  12193. }
  12194. function genNormalElement(el, state, stringifyChildren) {
  12195. const data = el.plain ? undefined : genData(el, state);
  12196. const children = stringifyChildren
  12197. ? `[${genChildrenAsStringNode(el, state)}]`
  12198. : genSSRChildren(el, state, true);
  12199. return `_c('${el.tag}'${data ? `,${data}` : ''}${children ? `,${children}` : ''})`;
  12200. }
  12201. function genSSRChildren(el, state, checkSkip) {
  12202. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode);
  12203. }
  12204. function genSSRNode(el, state) {
  12205. return el.type === 1 ? genSSRElement(el, state) : genText(el);
  12206. }
  12207. function genChildrenAsStringNode(el, state) {
  12208. return el.children.length
  12209. ? `_ssrNode(${flattenSegments(childrenToSegments(el, state))})`
  12210. : '';
  12211. }
  12212. function genStringElement(el, state) {
  12213. return `_ssrNode(${elementToString(el, state)})`;
  12214. }
  12215. function genStringElementWithChildren(el, state) {
  12216. const children = genSSRChildren(el, state, true);
  12217. return `_ssrNode(${flattenSegments(elementToOpenTagSegments(el, state))},"</${el.tag}>"${children ? `,${children}` : ''})`;
  12218. }
  12219. function elementToString(el, state) {
  12220. return `(${flattenSegments(elementToSegments(el, state))})`;
  12221. }
  12222. function elementToSegments(el, state) {
  12223. // v-for / v-if
  12224. if (el.for && !el.forProcessed) {
  12225. el.forProcessed = true;
  12226. return [
  12227. {
  12228. type: EXPRESSION,
  12229. value: genFor(el, state, elementToString, '_ssrList')
  12230. }
  12231. ];
  12232. }
  12233. else if (el.if && !el.ifProcessed) {
  12234. el.ifProcessed = true;
  12235. return [
  12236. {
  12237. type: EXPRESSION,
  12238. value: genIf(el, state, elementToString, '"<!---->"')
  12239. }
  12240. ];
  12241. }
  12242. else if (el.tag === 'template') {
  12243. return childrenToSegments(el, state);
  12244. }
  12245. const openSegments = elementToOpenTagSegments(el, state);
  12246. const childrenSegments = childrenToSegments(el, state);
  12247. const { isUnaryTag } = state.options;
  12248. const close = isUnaryTag && isUnaryTag(el.tag)
  12249. ? []
  12250. : [{ type: RAW, value: `</${el.tag}>` }];
  12251. return openSegments.concat(childrenSegments, close);
  12252. }
  12253. function elementToOpenTagSegments(el, state) {
  12254. applyModelTransform(el, state);
  12255. let binding;
  12256. const segments = [{ type: RAW, value: `<${el.tag}` }];
  12257. // attrs
  12258. if (el.attrs) {
  12259. segments.push.apply(segments, genAttrSegments(el.attrs));
  12260. }
  12261. // domProps
  12262. if (el.props) {
  12263. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  12264. }
  12265. // v-bind="object"
  12266. if ((binding = el.attrsMap['v-bind'])) {
  12267. segments.push({ type: EXPRESSION, value: `_ssrAttrs(${binding})` });
  12268. }
  12269. // v-bind.prop="object"
  12270. if ((binding = el.attrsMap['v-bind.prop'])) {
  12271. segments.push({ type: EXPRESSION, value: `_ssrDOMProps(${binding})` });
  12272. }
  12273. // class
  12274. if (el.staticClass || el.classBinding) {
  12275. segments.push.apply(segments, genClassSegments(el.staticClass, el.classBinding));
  12276. }
  12277. // style & v-show
  12278. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  12279. segments.push.apply(segments, genStyleSegments(el.attrsMap.style, el.staticStyle, el.styleBinding, el.attrsMap['v-show']));
  12280. }
  12281. // _scopedId
  12282. if (state.options.scopeId) {
  12283. segments.push({ type: RAW, value: ` ${state.options.scopeId}` });
  12284. }
  12285. segments.push({ type: RAW, value: `>` });
  12286. return segments;
  12287. }
  12288. function childrenToSegments(el, state) {
  12289. let binding;
  12290. if ((binding = el.attrsMap['v-html'])) {
  12291. return [{ type: EXPRESSION, value: `_s(${binding})` }];
  12292. }
  12293. if ((binding = el.attrsMap['v-text'])) {
  12294. return [{ type: INTERPOLATION, value: `_s(${binding})` }];
  12295. }
  12296. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  12297. return [{ type: INTERPOLATION, value: `_s(${binding})` }];
  12298. }
  12299. return el.children ? nodesToSegments(el.children, state) : [];
  12300. }
  12301. function nodesToSegments(children, state) {
  12302. const segments = [];
  12303. for (let i = 0; i < children.length; i++) {
  12304. const c = children[i];
  12305. if (c.type === 1) {
  12306. segments.push.apply(segments, elementToSegments(c, state));
  12307. }
  12308. else if (c.type === 2) {
  12309. segments.push({ type: INTERPOLATION, value: c.expression });
  12310. }
  12311. else if (c.type === 3) {
  12312. let text = escape(c.text);
  12313. if (c.isComment) {
  12314. text = '<!--' + text + '-->';
  12315. }
  12316. segments.push({ type: RAW, value: text });
  12317. }
  12318. }
  12319. return segments;
  12320. }
  12321. function flattenSegments(segments) {
  12322. const mergedSegments = [];
  12323. let textBuffer = '';
  12324. const pushBuffer = () => {
  12325. if (textBuffer) {
  12326. mergedSegments.push(JSON.stringify(textBuffer));
  12327. textBuffer = '';
  12328. }
  12329. };
  12330. for (let i = 0; i < segments.length; i++) {
  12331. const s = segments[i];
  12332. if (s.type === RAW) {
  12333. textBuffer += s.value;
  12334. }
  12335. else if (s.type === INTERPOLATION) {
  12336. pushBuffer();
  12337. mergedSegments.push(`_ssrEscape(${s.value})`);
  12338. }
  12339. else if (s.type === EXPRESSION) {
  12340. pushBuffer();
  12341. mergedSegments.push(`(${s.value})`);
  12342. }
  12343. }
  12344. pushBuffer();
  12345. return mergedSegments.join('+');
  12346. }
  12347. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  12348. const ast = parse$1(template.trim(), options);
  12349. optimize(ast, options);
  12350. const code = generate(ast, options);
  12351. return {
  12352. ast,
  12353. render: code.render,
  12354. staticRenderFns: code.staticRenderFns
  12355. };
  12356. });
  12357. const { compile, compileToFunctions } = createCompiler(baseOptions);
  12358. var _compiler = /*#__PURE__*/Object.freeze({
  12359. __proto__: null,
  12360. parseComponent: parseComponent,
  12361. compile: compile$1,
  12362. compileToFunctions: compileToFunctions$1,
  12363. ssrCompile: compile,
  12364. ssrCompileToFunctions: compileToFunctions,
  12365. generateCodeFrame: generateCodeFrame
  12366. });
  12367. function compileTemplate(options) {
  12368. const { preprocessLang } = options;
  12369. const preprocessor = preprocessLang && consolidate[preprocessLang];
  12370. if (preprocessor) {
  12371. return actuallyCompile(Object.assign({}, options, {
  12372. source: preprocess$1(options, preprocessor)
  12373. }));
  12374. }
  12375. else if (preprocessLang) {
  12376. return {
  12377. ast: {},
  12378. code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
  12379. source: options.source,
  12380. tips: [
  12381. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  12382. ],
  12383. errors: [
  12384. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  12385. ]
  12386. };
  12387. }
  12388. else {
  12389. return actuallyCompile(options);
  12390. }
  12391. }
  12392. function preprocess$1(options, preprocessor) {
  12393. const { source, filename, preprocessOptions } = options;
  12394. const finalPreprocessOptions = Object.assign({
  12395. filename
  12396. }, preprocessOptions);
  12397. // Consolidate exposes a callback based API, but the callback is in fact
  12398. // called synchronously for most templating engines. In our case, we have to
  12399. // expose a synchronous API so that it is usable in Jest transforms (which
  12400. // have to be sync because they are applied via Node.js require hooks)
  12401. let res, err;
  12402. preprocessor.render(source, finalPreprocessOptions, (_err, _res) => {
  12403. if (_err)
  12404. err = _err;
  12405. res = _res;
  12406. });
  12407. if (err)
  12408. throw err;
  12409. return res;
  12410. }
  12411. function actuallyCompile(options) {
  12412. const { source, compiler = _compiler, compilerOptions = {}, transpileOptions = {}, transformAssetUrls, transformAssetUrlsOptions, isProduction = process.env.NODE_ENV === 'production', isFunctional = false, optimizeSSR = false, prettify = true, isTS = false, bindings } = options;
  12413. const compile = optimizeSSR && compiler.ssrCompile ? compiler.ssrCompile : compiler.compile;
  12414. let finalCompilerOptions = compilerOptions;
  12415. if (transformAssetUrls) {
  12416. const builtInModules = [
  12417. transformAssetUrls === true
  12418. ? assetUrlsModule(undefined, transformAssetUrlsOptions)
  12419. : assetUrlsModule(transformAssetUrls, transformAssetUrlsOptions),
  12420. srcsetModule(transformAssetUrlsOptions)
  12421. ];
  12422. finalCompilerOptions = Object.assign({}, compilerOptions, {
  12423. modules: [...builtInModules, ...(compilerOptions.modules || [])],
  12424. filename: options.filename
  12425. });
  12426. }
  12427. finalCompilerOptions.bindings = bindings;
  12428. const { ast, render, staticRenderFns, tips, errors } = compile(source, finalCompilerOptions);
  12429. if (errors && errors.length) {
  12430. return {
  12431. ast,
  12432. code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
  12433. source,
  12434. tips,
  12435. errors
  12436. };
  12437. }
  12438. else {
  12439. // stripping `with` usage
  12440. let code = `var __render__ = ${prefixIdentifiers(`function render(${isFunctional ? `_c,_vm` : ``}){${render}\n}`, isFunctional, isTS, transpileOptions, bindings)}\n` +
  12441. `var __staticRenderFns__ = [${staticRenderFns.map(code => prefixIdentifiers(`function (${isFunctional ? `_c,_vm` : ``}){${code}\n}`, isFunctional, isTS, transpileOptions, bindings))}]` +
  12442. `\n`;
  12443. // #23 we use __render__ to avoid `render` not being prefixed by the
  12444. // transpiler when stripping with, but revert it back to `render` to
  12445. // maintain backwards compat
  12446. code = code.replace(/\s__(render|staticRenderFns)__\s/g, ' $1 ');
  12447. if (!isProduction) {
  12448. // mark with stripped (this enables Vue to use correct runtime proxy
  12449. // detection)
  12450. code += `render._withStripped = true`;
  12451. if (prettify) {
  12452. try {
  12453. code = require('prettier').format(code, {
  12454. semi: false,
  12455. parser: 'babel'
  12456. });
  12457. }
  12458. catch (e) {
  12459. if (e.code === 'MODULE_NOT_FOUND') {
  12460. tips.push('The `prettify` option is on, but the dependency `prettier` is not found.\n' +
  12461. 'Please either turn off `prettify` or manually install `prettier`.');
  12462. }
  12463. tips.push(`Failed to prettify component ${options.filename} template source after compilation.`);
  12464. }
  12465. }
  12466. }
  12467. return {
  12468. ast,
  12469. code,
  12470. source,
  12471. tips,
  12472. errors
  12473. };
  12474. }
  12475. }
  12476. const trimPlugin = () => {
  12477. return {
  12478. postcssPlugin: 'vue-sfc-trim',
  12479. Once(root) {
  12480. root.walk(({ type, raws }) => {
  12481. if (type === 'rule' || type === 'atrule') {
  12482. if (raws.before)
  12483. raws.before = '\n';
  12484. if ('after' in raws && raws.after)
  12485. raws.after = '\n';
  12486. }
  12487. });
  12488. }
  12489. };
  12490. };
  12491. trimPlugin.postcss = true;
  12492. var dist = {exports: {}};
  12493. var processor = {exports: {}};
  12494. var parser = {exports: {}};
  12495. var root$1 = {exports: {}};
  12496. var container = {exports: {}};
  12497. var node$1 = {exports: {}};
  12498. var util = {};
  12499. var unesc = {exports: {}};
  12500. (function (module, exports) {
  12501. exports.__esModule = true;
  12502. exports["default"] = unesc;
  12503. // Many thanks for this post which made this migration much easier.
  12504. // https://mathiasbynens.be/notes/css-escapes
  12505. /**
  12506. *
  12507. * @param {string} str
  12508. * @returns {[string, number]|undefined}
  12509. */
  12510. function gobbleHex(str) {
  12511. var lower = str.toLowerCase();
  12512. var hex = '';
  12513. var spaceTerminated = false;
  12514. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  12515. var code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]
  12516. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  12517. spaceTerminated = code === 32;
  12518. if (!valid) {
  12519. break;
  12520. }
  12521. hex += lower[i];
  12522. }
  12523. if (hex.length === 0) {
  12524. return undefined;
  12525. }
  12526. var codePoint = parseInt(hex, 16);
  12527. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; // Add special case for
  12528. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  12529. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  12530. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  12531. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  12532. }
  12533. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  12534. }
  12535. var CONTAINS_ESCAPE = /\\/;
  12536. function unesc(str) {
  12537. var needToProcess = CONTAINS_ESCAPE.test(str);
  12538. if (!needToProcess) {
  12539. return str;
  12540. }
  12541. var ret = "";
  12542. for (var i = 0; i < str.length; i++) {
  12543. if (str[i] === "\\") {
  12544. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  12545. if (gobbled !== undefined) {
  12546. ret += gobbled[0];
  12547. i += gobbled[1];
  12548. continue;
  12549. } // Retain a pair of \\ if double escaped `\\\\`
  12550. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  12551. if (str[i + 1] === "\\") {
  12552. ret += "\\";
  12553. i++;
  12554. continue;
  12555. } // if \\ is at the end of the string retain it
  12556. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  12557. if (str.length === i + 1) {
  12558. ret += str[i];
  12559. }
  12560. continue;
  12561. }
  12562. ret += str[i];
  12563. }
  12564. return ret;
  12565. }
  12566. module.exports = exports.default;
  12567. } (unesc, unesc.exports));
  12568. var getProp = {exports: {}};
  12569. (function (module, exports) {
  12570. exports.__esModule = true;
  12571. exports["default"] = getProp;
  12572. function getProp(obj) {
  12573. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12574. props[_key - 1] = arguments[_key];
  12575. }
  12576. while (props.length > 0) {
  12577. var prop = props.shift();
  12578. if (!obj[prop]) {
  12579. return undefined;
  12580. }
  12581. obj = obj[prop];
  12582. }
  12583. return obj;
  12584. }
  12585. module.exports = exports.default;
  12586. } (getProp, getProp.exports));
  12587. var ensureObject = {exports: {}};
  12588. (function (module, exports) {
  12589. exports.__esModule = true;
  12590. exports["default"] = ensureObject;
  12591. function ensureObject(obj) {
  12592. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12593. props[_key - 1] = arguments[_key];
  12594. }
  12595. while (props.length > 0) {
  12596. var prop = props.shift();
  12597. if (!obj[prop]) {
  12598. obj[prop] = {};
  12599. }
  12600. obj = obj[prop];
  12601. }
  12602. }
  12603. module.exports = exports.default;
  12604. } (ensureObject, ensureObject.exports));
  12605. var stripComments = {exports: {}};
  12606. (function (module, exports) {
  12607. exports.__esModule = true;
  12608. exports["default"] = stripComments;
  12609. function stripComments(str) {
  12610. var s = "";
  12611. var commentStart = str.indexOf("/*");
  12612. var lastEnd = 0;
  12613. while (commentStart >= 0) {
  12614. s = s + str.slice(lastEnd, commentStart);
  12615. var commentEnd = str.indexOf("*/", commentStart + 2);
  12616. if (commentEnd < 0) {
  12617. return s;
  12618. }
  12619. lastEnd = commentEnd + 2;
  12620. commentStart = str.indexOf("/*", lastEnd);
  12621. }
  12622. s = s + str.slice(lastEnd);
  12623. return s;
  12624. }
  12625. module.exports = exports.default;
  12626. } (stripComments, stripComments.exports));
  12627. util.__esModule = true;
  12628. util.stripComments = util.ensureObject = util.getProp = util.unesc = void 0;
  12629. var _unesc = _interopRequireDefault$1(unesc.exports);
  12630. util.unesc = _unesc["default"];
  12631. var _getProp = _interopRequireDefault$1(getProp.exports);
  12632. util.getProp = _getProp["default"];
  12633. var _ensureObject = _interopRequireDefault$1(ensureObject.exports);
  12634. util.ensureObject = _ensureObject["default"];
  12635. var _stripComments = _interopRequireDefault$1(stripComments.exports);
  12636. util.stripComments = _stripComments["default"];
  12637. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12638. (function (module, exports) {
  12639. exports.__esModule = true;
  12640. exports["default"] = void 0;
  12641. var _util = util;
  12642. 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); } }
  12643. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12644. var cloneNode = function cloneNode(obj, parent) {
  12645. if (typeof obj !== 'object' || obj === null) {
  12646. return obj;
  12647. }
  12648. var cloned = new obj.constructor();
  12649. for (var i in obj) {
  12650. if (!obj.hasOwnProperty(i)) {
  12651. continue;
  12652. }
  12653. var value = obj[i];
  12654. var type = typeof value;
  12655. if (i === 'parent' && type === 'object') {
  12656. if (parent) {
  12657. cloned[i] = parent;
  12658. }
  12659. } else if (value instanceof Array) {
  12660. cloned[i] = value.map(function (j) {
  12661. return cloneNode(j, cloned);
  12662. });
  12663. } else {
  12664. cloned[i] = cloneNode(value, cloned);
  12665. }
  12666. }
  12667. return cloned;
  12668. };
  12669. var Node = /*#__PURE__*/function () {
  12670. function Node(opts) {
  12671. if (opts === void 0) {
  12672. opts = {};
  12673. }
  12674. Object.assign(this, opts);
  12675. this.spaces = this.spaces || {};
  12676. this.spaces.before = this.spaces.before || '';
  12677. this.spaces.after = this.spaces.after || '';
  12678. }
  12679. var _proto = Node.prototype;
  12680. _proto.remove = function remove() {
  12681. if (this.parent) {
  12682. this.parent.removeChild(this);
  12683. }
  12684. this.parent = undefined;
  12685. return this;
  12686. };
  12687. _proto.replaceWith = function replaceWith() {
  12688. if (this.parent) {
  12689. for (var index in arguments) {
  12690. this.parent.insertBefore(this, arguments[index]);
  12691. }
  12692. this.remove();
  12693. }
  12694. return this;
  12695. };
  12696. _proto.next = function next() {
  12697. return this.parent.at(this.parent.index(this) + 1);
  12698. };
  12699. _proto.prev = function prev() {
  12700. return this.parent.at(this.parent.index(this) - 1);
  12701. };
  12702. _proto.clone = function clone(overrides) {
  12703. if (overrides === void 0) {
  12704. overrides = {};
  12705. }
  12706. var cloned = cloneNode(this);
  12707. for (var name in overrides) {
  12708. cloned[name] = overrides[name];
  12709. }
  12710. return cloned;
  12711. }
  12712. /**
  12713. * Some non-standard syntax doesn't follow normal escaping rules for css.
  12714. * This allows non standard syntax to be appended to an existing property
  12715. * by specifying the escaped value. By specifying the escaped value,
  12716. * illegal characters are allowed to be directly inserted into css output.
  12717. * @param {string} name the property to set
  12718. * @param {any} value the unescaped value of the property
  12719. * @param {string} valueEscaped optional. the escaped value of the property.
  12720. */
  12721. ;
  12722. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  12723. if (!this.raws) {
  12724. this.raws = {};
  12725. }
  12726. var originalValue = this[name];
  12727. var originalEscaped = this.raws[name];
  12728. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  12729. if (originalEscaped || valueEscaped !== value) {
  12730. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  12731. } else {
  12732. delete this.raws[name]; // delete any escaped value that was created by the setter.
  12733. }
  12734. }
  12735. /**
  12736. * Some non-standard syntax doesn't follow normal escaping rules for css.
  12737. * This allows the escaped value to be specified directly, allowing illegal
  12738. * characters to be directly inserted into css output.
  12739. * @param {string} name the property to set
  12740. * @param {any} value the unescaped value of the property
  12741. * @param {string} valueEscaped the escaped value of the property.
  12742. */
  12743. ;
  12744. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  12745. if (!this.raws) {
  12746. this.raws = {};
  12747. }
  12748. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  12749. this.raws[name] = valueEscaped;
  12750. }
  12751. /**
  12752. * When you want a value to passed through to CSS directly. This method
  12753. * deletes the corresponding raw value causing the stringifier to fallback
  12754. * to the unescaped value.
  12755. * @param {string} name the property to set.
  12756. * @param {any} value The value that is both escaped and unescaped.
  12757. */
  12758. ;
  12759. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  12760. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  12761. if (this.raws) {
  12762. delete this.raws[name];
  12763. }
  12764. }
  12765. /**
  12766. *
  12767. * @param {number} line The number (starting with 1)
  12768. * @param {number} column The column number (starting with 1)
  12769. */
  12770. ;
  12771. _proto.isAtPosition = function isAtPosition(line, column) {
  12772. if (this.source && this.source.start && this.source.end) {
  12773. if (this.source.start.line > line) {
  12774. return false;
  12775. }
  12776. if (this.source.end.line < line) {
  12777. return false;
  12778. }
  12779. if (this.source.start.line === line && this.source.start.column > column) {
  12780. return false;
  12781. }
  12782. if (this.source.end.line === line && this.source.end.column < column) {
  12783. return false;
  12784. }
  12785. return true;
  12786. }
  12787. return undefined;
  12788. };
  12789. _proto.stringifyProperty = function stringifyProperty(name) {
  12790. return this.raws && this.raws[name] || this[name];
  12791. };
  12792. _proto.valueToString = function valueToString() {
  12793. return String(this.stringifyProperty("value"));
  12794. };
  12795. _proto.toString = function toString() {
  12796. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  12797. };
  12798. _createClass(Node, [{
  12799. key: "rawSpaceBefore",
  12800. get: function get() {
  12801. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  12802. if (rawSpace === undefined) {
  12803. rawSpace = this.spaces && this.spaces.before;
  12804. }
  12805. return rawSpace || "";
  12806. },
  12807. set: function set(raw) {
  12808. (0, _util.ensureObject)(this, "raws", "spaces");
  12809. this.raws.spaces.before = raw;
  12810. }
  12811. }, {
  12812. key: "rawSpaceAfter",
  12813. get: function get() {
  12814. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  12815. if (rawSpace === undefined) {
  12816. rawSpace = this.spaces.after;
  12817. }
  12818. return rawSpace || "";
  12819. },
  12820. set: function set(raw) {
  12821. (0, _util.ensureObject)(this, "raws", "spaces");
  12822. this.raws.spaces.after = raw;
  12823. }
  12824. }]);
  12825. return Node;
  12826. }();
  12827. exports["default"] = Node;
  12828. module.exports = exports.default;
  12829. } (node$1, node$1.exports));
  12830. var types = {};
  12831. types.__esModule = true;
  12832. types.UNIVERSAL = types.ATTRIBUTE = types.CLASS = types.COMBINATOR = types.COMMENT = types.ID = types.NESTING = types.PSEUDO = types.ROOT = types.SELECTOR = types.STRING = types.TAG = void 0;
  12833. var TAG = 'tag';
  12834. types.TAG = TAG;
  12835. var STRING = 'string';
  12836. types.STRING = STRING;
  12837. var SELECTOR = 'selector';
  12838. types.SELECTOR = SELECTOR;
  12839. var ROOT = 'root';
  12840. types.ROOT = ROOT;
  12841. var PSEUDO = 'pseudo';
  12842. types.PSEUDO = PSEUDO;
  12843. var NESTING = 'nesting';
  12844. types.NESTING = NESTING;
  12845. var ID = 'id';
  12846. types.ID = ID;
  12847. var COMMENT = 'comment';
  12848. types.COMMENT = COMMENT;
  12849. var COMBINATOR = 'combinator';
  12850. types.COMBINATOR = COMBINATOR;
  12851. var CLASS = 'class';
  12852. types.CLASS = CLASS;
  12853. var ATTRIBUTE = 'attribute';
  12854. types.ATTRIBUTE = ATTRIBUTE;
  12855. var UNIVERSAL = 'universal';
  12856. types.UNIVERSAL = UNIVERSAL;
  12857. (function (module, exports) {
  12858. exports.__esModule = true;
  12859. exports["default"] = void 0;
  12860. var _node = _interopRequireDefault(node$1.exports);
  12861. var types$1 = _interopRequireWildcard(types);
  12862. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  12863. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
  12864. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12865. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  12866. 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); }
  12867. 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; }
  12868. 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); } }
  12869. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12870. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  12871. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12872. var Container = /*#__PURE__*/function (_Node) {
  12873. _inheritsLoose(Container, _Node);
  12874. function Container(opts) {
  12875. var _this;
  12876. _this = _Node.call(this, opts) || this;
  12877. if (!_this.nodes) {
  12878. _this.nodes = [];
  12879. }
  12880. return _this;
  12881. }
  12882. var _proto = Container.prototype;
  12883. _proto.append = function append(selector) {
  12884. selector.parent = this;
  12885. this.nodes.push(selector);
  12886. return this;
  12887. };
  12888. _proto.prepend = function prepend(selector) {
  12889. selector.parent = this;
  12890. this.nodes.unshift(selector);
  12891. return this;
  12892. };
  12893. _proto.at = function at(index) {
  12894. return this.nodes[index];
  12895. };
  12896. _proto.index = function index(child) {
  12897. if (typeof child === 'number') {
  12898. return child;
  12899. }
  12900. return this.nodes.indexOf(child);
  12901. };
  12902. _proto.removeChild = function removeChild(child) {
  12903. child = this.index(child);
  12904. this.at(child).parent = undefined;
  12905. this.nodes.splice(child, 1);
  12906. var index;
  12907. for (var id in this.indexes) {
  12908. index = this.indexes[id];
  12909. if (index >= child) {
  12910. this.indexes[id] = index - 1;
  12911. }
  12912. }
  12913. return this;
  12914. };
  12915. _proto.removeAll = function removeAll() {
  12916. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  12917. var node = _step.value;
  12918. node.parent = undefined;
  12919. }
  12920. this.nodes = [];
  12921. return this;
  12922. };
  12923. _proto.empty = function empty() {
  12924. return this.removeAll();
  12925. };
  12926. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  12927. newNode.parent = this;
  12928. var oldIndex = this.index(oldNode);
  12929. this.nodes.splice(oldIndex + 1, 0, newNode);
  12930. newNode.parent = this;
  12931. var index;
  12932. for (var id in this.indexes) {
  12933. index = this.indexes[id];
  12934. if (oldIndex <= index) {
  12935. this.indexes[id] = index + 1;
  12936. }
  12937. }
  12938. return this;
  12939. };
  12940. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  12941. newNode.parent = this;
  12942. var oldIndex = this.index(oldNode);
  12943. this.nodes.splice(oldIndex, 0, newNode);
  12944. newNode.parent = this;
  12945. var index;
  12946. for (var id in this.indexes) {
  12947. index = this.indexes[id];
  12948. if (index <= oldIndex) {
  12949. this.indexes[id] = index + 1;
  12950. }
  12951. }
  12952. return this;
  12953. };
  12954. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  12955. var found = undefined;
  12956. this.each(function (node) {
  12957. if (node.atPosition) {
  12958. var foundChild = node.atPosition(line, col);
  12959. if (foundChild) {
  12960. found = foundChild;
  12961. return false;
  12962. }
  12963. } else if (node.isAtPosition(line, col)) {
  12964. found = node;
  12965. return false;
  12966. }
  12967. });
  12968. return found;
  12969. }
  12970. /**
  12971. * Return the most specific node at the line and column number given.
  12972. * The source location is based on the original parsed location, locations aren't
  12973. * updated as selector nodes are mutated.
  12974. *
  12975. * Note that this location is relative to the location of the first character
  12976. * of the selector, and not the location of the selector in the overall document
  12977. * when used in conjunction with postcss.
  12978. *
  12979. * If not found, returns undefined.
  12980. * @param {number} line The line number of the node to find. (1-based index)
  12981. * @param {number} col The column number of the node to find. (1-based index)
  12982. */
  12983. ;
  12984. _proto.atPosition = function atPosition(line, col) {
  12985. if (this.isAtPosition(line, col)) {
  12986. return this._findChildAtPosition(line, col) || this;
  12987. } else {
  12988. return undefined;
  12989. }
  12990. };
  12991. _proto._inferEndPosition = function _inferEndPosition() {
  12992. if (this.last && this.last.source && this.last.source.end) {
  12993. this.source = this.source || {};
  12994. this.source.end = this.source.end || {};
  12995. Object.assign(this.source.end, this.last.source.end);
  12996. }
  12997. };
  12998. _proto.each = function each(callback) {
  12999. if (!this.lastEach) {
  13000. this.lastEach = 0;
  13001. }
  13002. if (!this.indexes) {
  13003. this.indexes = {};
  13004. }
  13005. this.lastEach++;
  13006. var id = this.lastEach;
  13007. this.indexes[id] = 0;
  13008. if (!this.length) {
  13009. return undefined;
  13010. }
  13011. var index, result;
  13012. while (this.indexes[id] < this.length) {
  13013. index = this.indexes[id];
  13014. result = callback(this.at(index), index);
  13015. if (result === false) {
  13016. break;
  13017. }
  13018. this.indexes[id] += 1;
  13019. }
  13020. delete this.indexes[id];
  13021. if (result === false) {
  13022. return false;
  13023. }
  13024. };
  13025. _proto.walk = function walk(callback) {
  13026. return this.each(function (node, i) {
  13027. var result = callback(node, i);
  13028. if (result !== false && node.length) {
  13029. result = node.walk(callback);
  13030. }
  13031. if (result === false) {
  13032. return false;
  13033. }
  13034. });
  13035. };
  13036. _proto.walkAttributes = function walkAttributes(callback) {
  13037. var _this2 = this;
  13038. return this.walk(function (selector) {
  13039. if (selector.type === types$1.ATTRIBUTE) {
  13040. return callback.call(_this2, selector);
  13041. }
  13042. });
  13043. };
  13044. _proto.walkClasses = function walkClasses(callback) {
  13045. var _this3 = this;
  13046. return this.walk(function (selector) {
  13047. if (selector.type === types$1.CLASS) {
  13048. return callback.call(_this3, selector);
  13049. }
  13050. });
  13051. };
  13052. _proto.walkCombinators = function walkCombinators(callback) {
  13053. var _this4 = this;
  13054. return this.walk(function (selector) {
  13055. if (selector.type === types$1.COMBINATOR) {
  13056. return callback.call(_this4, selector);
  13057. }
  13058. });
  13059. };
  13060. _proto.walkComments = function walkComments(callback) {
  13061. var _this5 = this;
  13062. return this.walk(function (selector) {
  13063. if (selector.type === types$1.COMMENT) {
  13064. return callback.call(_this5, selector);
  13065. }
  13066. });
  13067. };
  13068. _proto.walkIds = function walkIds(callback) {
  13069. var _this6 = this;
  13070. return this.walk(function (selector) {
  13071. if (selector.type === types$1.ID) {
  13072. return callback.call(_this6, selector);
  13073. }
  13074. });
  13075. };
  13076. _proto.walkNesting = function walkNesting(callback) {
  13077. var _this7 = this;
  13078. return this.walk(function (selector) {
  13079. if (selector.type === types$1.NESTING) {
  13080. return callback.call(_this7, selector);
  13081. }
  13082. });
  13083. };
  13084. _proto.walkPseudos = function walkPseudos(callback) {
  13085. var _this8 = this;
  13086. return this.walk(function (selector) {
  13087. if (selector.type === types$1.PSEUDO) {
  13088. return callback.call(_this8, selector);
  13089. }
  13090. });
  13091. };
  13092. _proto.walkTags = function walkTags(callback) {
  13093. var _this9 = this;
  13094. return this.walk(function (selector) {
  13095. if (selector.type === types$1.TAG) {
  13096. return callback.call(_this9, selector);
  13097. }
  13098. });
  13099. };
  13100. _proto.walkUniversals = function walkUniversals(callback) {
  13101. var _this10 = this;
  13102. return this.walk(function (selector) {
  13103. if (selector.type === types$1.UNIVERSAL) {
  13104. return callback.call(_this10, selector);
  13105. }
  13106. });
  13107. };
  13108. _proto.split = function split(callback) {
  13109. var _this11 = this;
  13110. var current = [];
  13111. return this.reduce(function (memo, node, index) {
  13112. var split = callback.call(_this11, node);
  13113. current.push(node);
  13114. if (split) {
  13115. memo.push(current);
  13116. current = [];
  13117. } else if (index === _this11.length - 1) {
  13118. memo.push(current);
  13119. }
  13120. return memo;
  13121. }, []);
  13122. };
  13123. _proto.map = function map(callback) {
  13124. return this.nodes.map(callback);
  13125. };
  13126. _proto.reduce = function reduce(callback, memo) {
  13127. return this.nodes.reduce(callback, memo);
  13128. };
  13129. _proto.every = function every(callback) {
  13130. return this.nodes.every(callback);
  13131. };
  13132. _proto.some = function some(callback) {
  13133. return this.nodes.some(callback);
  13134. };
  13135. _proto.filter = function filter(callback) {
  13136. return this.nodes.filter(callback);
  13137. };
  13138. _proto.sort = function sort(callback) {
  13139. return this.nodes.sort(callback);
  13140. };
  13141. _proto.toString = function toString() {
  13142. return this.map(String).join('');
  13143. };
  13144. _createClass(Container, [{
  13145. key: "first",
  13146. get: function get() {
  13147. return this.at(0);
  13148. }
  13149. }, {
  13150. key: "last",
  13151. get: function get() {
  13152. return this.at(this.length - 1);
  13153. }
  13154. }, {
  13155. key: "length",
  13156. get: function get() {
  13157. return this.nodes.length;
  13158. }
  13159. }]);
  13160. return Container;
  13161. }(_node["default"]);
  13162. exports["default"] = Container;
  13163. module.exports = exports.default;
  13164. } (container, container.exports));
  13165. (function (module, exports) {
  13166. exports.__esModule = true;
  13167. exports["default"] = void 0;
  13168. var _container = _interopRequireDefault(container.exports);
  13169. var _types = types;
  13170. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13171. 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); } }
  13172. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13173. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13174. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13175. var Root = /*#__PURE__*/function (_Container) {
  13176. _inheritsLoose(Root, _Container);
  13177. function Root(opts) {
  13178. var _this;
  13179. _this = _Container.call(this, opts) || this;
  13180. _this.type = _types.ROOT;
  13181. return _this;
  13182. }
  13183. var _proto = Root.prototype;
  13184. _proto.toString = function toString() {
  13185. var str = this.reduce(function (memo, selector) {
  13186. memo.push(String(selector));
  13187. return memo;
  13188. }, []).join(',');
  13189. return this.trailingComma ? str + ',' : str;
  13190. };
  13191. _proto.error = function error(message, options) {
  13192. if (this._error) {
  13193. return this._error(message, options);
  13194. } else {
  13195. return new Error(message);
  13196. }
  13197. };
  13198. _createClass(Root, [{
  13199. key: "errorGenerator",
  13200. set: function set(handler) {
  13201. this._error = handler;
  13202. }
  13203. }]);
  13204. return Root;
  13205. }(_container["default"]);
  13206. exports["default"] = Root;
  13207. module.exports = exports.default;
  13208. } (root$1, root$1.exports));
  13209. var selector$1 = {exports: {}};
  13210. (function (module, exports) {
  13211. exports.__esModule = true;
  13212. exports["default"] = void 0;
  13213. var _container = _interopRequireDefault(container.exports);
  13214. var _types = types;
  13215. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13216. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13217. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13218. var Selector = /*#__PURE__*/function (_Container) {
  13219. _inheritsLoose(Selector, _Container);
  13220. function Selector(opts) {
  13221. var _this;
  13222. _this = _Container.call(this, opts) || this;
  13223. _this.type = _types.SELECTOR;
  13224. return _this;
  13225. }
  13226. return Selector;
  13227. }(_container["default"]);
  13228. exports["default"] = Selector;
  13229. module.exports = exports.default;
  13230. } (selector$1, selector$1.exports));
  13231. var className$1 = {exports: {}};
  13232. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  13233. var object = {};
  13234. var hasOwnProperty = object.hasOwnProperty;
  13235. var merge$1 = function merge(options, defaults) {
  13236. if (!options) {
  13237. return defaults;
  13238. }
  13239. var result = {};
  13240. for (var key in defaults) {
  13241. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  13242. // only recognized option names are used.
  13243. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  13244. }
  13245. return result;
  13246. };
  13247. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  13248. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  13249. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  13250. // https://mathiasbynens.be/notes/css-escapes#css
  13251. var cssesc = function cssesc(string, options) {
  13252. options = merge$1(options, cssesc.options);
  13253. if (options.quotes != 'single' && options.quotes != 'double') {
  13254. options.quotes = 'single';
  13255. }
  13256. var quote = options.quotes == 'double' ? '"' : '\'';
  13257. var isIdentifier = options.isIdentifier;
  13258. var firstChar = string.charAt(0);
  13259. var output = '';
  13260. var counter = 0;
  13261. var length = string.length;
  13262. while (counter < length) {
  13263. var character = string.charAt(counter++);
  13264. var codePoint = character.charCodeAt();
  13265. var value = void 0;
  13266. // If it’s not a printable ASCII character…
  13267. if (codePoint < 0x20 || codePoint > 0x7E) {
  13268. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  13269. // It’s a high surrogate, and there is a next character.
  13270. var extra = string.charCodeAt(counter++);
  13271. if ((extra & 0xFC00) == 0xDC00) {
  13272. // next character is low surrogate
  13273. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  13274. } else {
  13275. // It’s an unmatched surrogate; only append this code unit, in case
  13276. // the next code unit is the high surrogate of a surrogate pair.
  13277. counter--;
  13278. }
  13279. }
  13280. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13281. } else {
  13282. if (options.escapeEverything) {
  13283. if (regexAnySingleEscape.test(character)) {
  13284. value = '\\' + character;
  13285. } else {
  13286. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13287. }
  13288. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  13289. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13290. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  13291. value = '\\' + character;
  13292. } else {
  13293. value = character;
  13294. }
  13295. }
  13296. output += value;
  13297. }
  13298. if (isIdentifier) {
  13299. if (/^-[-\d]/.test(output)) {
  13300. output = '\\-' + output.slice(1);
  13301. } else if (/\d/.test(firstChar)) {
  13302. output = '\\3' + firstChar + ' ' + output.slice(1);
  13303. }
  13304. }
  13305. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  13306. // since they’re redundant. Note that this is only possible if the escape
  13307. // sequence isn’t preceded by an odd number of backslashes.
  13308. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  13309. if ($1 && $1.length % 2) {
  13310. // It’s not safe to remove the space, so don’t.
  13311. return $0;
  13312. }
  13313. // Strip the space.
  13314. return ($1 || '') + $2;
  13315. });
  13316. if (!isIdentifier && options.wrap) {
  13317. return quote + output + quote;
  13318. }
  13319. return output;
  13320. };
  13321. // Expose default options (so they can be overridden globally).
  13322. cssesc.options = {
  13323. 'escapeEverything': false,
  13324. 'isIdentifier': false,
  13325. 'quotes': 'single',
  13326. 'wrap': false
  13327. };
  13328. cssesc.version = '3.0.0';
  13329. var cssesc_1 = cssesc;
  13330. (function (module, exports) {
  13331. exports.__esModule = true;
  13332. exports["default"] = void 0;
  13333. var _cssesc = _interopRequireDefault(cssesc_1);
  13334. var _util = util;
  13335. var _node = _interopRequireDefault(node$1.exports);
  13336. var _types = types;
  13337. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13338. 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); } }
  13339. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13340. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13341. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13342. var ClassName = /*#__PURE__*/function (_Node) {
  13343. _inheritsLoose(ClassName, _Node);
  13344. function ClassName(opts) {
  13345. var _this;
  13346. _this = _Node.call(this, opts) || this;
  13347. _this.type = _types.CLASS;
  13348. _this._constructed = true;
  13349. return _this;
  13350. }
  13351. var _proto = ClassName.prototype;
  13352. _proto.valueToString = function valueToString() {
  13353. return '.' + _Node.prototype.valueToString.call(this);
  13354. };
  13355. _createClass(ClassName, [{
  13356. key: "value",
  13357. get: function get() {
  13358. return this._value;
  13359. },
  13360. set: function set(v) {
  13361. if (this._constructed) {
  13362. var escaped = (0, _cssesc["default"])(v, {
  13363. isIdentifier: true
  13364. });
  13365. if (escaped !== v) {
  13366. (0, _util.ensureObject)(this, "raws");
  13367. this.raws.value = escaped;
  13368. } else if (this.raws) {
  13369. delete this.raws.value;
  13370. }
  13371. }
  13372. this._value = v;
  13373. }
  13374. }]);
  13375. return ClassName;
  13376. }(_node["default"]);
  13377. exports["default"] = ClassName;
  13378. module.exports = exports.default;
  13379. } (className$1, className$1.exports));
  13380. var comment$2 = {exports: {}};
  13381. (function (module, exports) {
  13382. exports.__esModule = true;
  13383. exports["default"] = void 0;
  13384. var _node = _interopRequireDefault(node$1.exports);
  13385. var _types = types;
  13386. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13387. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13388. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13389. var Comment = /*#__PURE__*/function (_Node) {
  13390. _inheritsLoose(Comment, _Node);
  13391. function Comment(opts) {
  13392. var _this;
  13393. _this = _Node.call(this, opts) || this;
  13394. _this.type = _types.COMMENT;
  13395. return _this;
  13396. }
  13397. return Comment;
  13398. }(_node["default"]);
  13399. exports["default"] = Comment;
  13400. module.exports = exports.default;
  13401. } (comment$2, comment$2.exports));
  13402. var id$1 = {exports: {}};
  13403. (function (module, exports) {
  13404. exports.__esModule = true;
  13405. exports["default"] = void 0;
  13406. var _node = _interopRequireDefault(node$1.exports);
  13407. var _types = types;
  13408. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13409. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13410. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13411. var ID = /*#__PURE__*/function (_Node) {
  13412. _inheritsLoose(ID, _Node);
  13413. function ID(opts) {
  13414. var _this;
  13415. _this = _Node.call(this, opts) || this;
  13416. _this.type = _types.ID;
  13417. return _this;
  13418. }
  13419. var _proto = ID.prototype;
  13420. _proto.valueToString = function valueToString() {
  13421. return '#' + _Node.prototype.valueToString.call(this);
  13422. };
  13423. return ID;
  13424. }(_node["default"]);
  13425. exports["default"] = ID;
  13426. module.exports = exports.default;
  13427. } (id$1, id$1.exports));
  13428. var tag$1 = {exports: {}};
  13429. var namespace = {exports: {}};
  13430. (function (module, exports) {
  13431. exports.__esModule = true;
  13432. exports["default"] = void 0;
  13433. var _cssesc = _interopRequireDefault(cssesc_1);
  13434. var _util = util;
  13435. var _node = _interopRequireDefault(node$1.exports);
  13436. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13437. 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); } }
  13438. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13439. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13440. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13441. var Namespace = /*#__PURE__*/function (_Node) {
  13442. _inheritsLoose(Namespace, _Node);
  13443. function Namespace() {
  13444. return _Node.apply(this, arguments) || this;
  13445. }
  13446. var _proto = Namespace.prototype;
  13447. _proto.qualifiedName = function qualifiedName(value) {
  13448. if (this.namespace) {
  13449. return this.namespaceString + "|" + value;
  13450. } else {
  13451. return value;
  13452. }
  13453. };
  13454. _proto.valueToString = function valueToString() {
  13455. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  13456. };
  13457. _createClass(Namespace, [{
  13458. key: "namespace",
  13459. get: function get() {
  13460. return this._namespace;
  13461. },
  13462. set: function set(namespace) {
  13463. if (namespace === true || namespace === "*" || namespace === "&") {
  13464. this._namespace = namespace;
  13465. if (this.raws) {
  13466. delete this.raws.namespace;
  13467. }
  13468. return;
  13469. }
  13470. var escaped = (0, _cssesc["default"])(namespace, {
  13471. isIdentifier: true
  13472. });
  13473. this._namespace = namespace;
  13474. if (escaped !== namespace) {
  13475. (0, _util.ensureObject)(this, "raws");
  13476. this.raws.namespace = escaped;
  13477. } else if (this.raws) {
  13478. delete this.raws.namespace;
  13479. }
  13480. }
  13481. }, {
  13482. key: "ns",
  13483. get: function get() {
  13484. return this._namespace;
  13485. },
  13486. set: function set(namespace) {
  13487. this.namespace = namespace;
  13488. }
  13489. }, {
  13490. key: "namespaceString",
  13491. get: function get() {
  13492. if (this.namespace) {
  13493. var ns = this.stringifyProperty("namespace");
  13494. if (ns === true) {
  13495. return '';
  13496. } else {
  13497. return ns;
  13498. }
  13499. } else {
  13500. return '';
  13501. }
  13502. }
  13503. }]);
  13504. return Namespace;
  13505. }(_node["default"]);
  13506. exports["default"] = Namespace;
  13507. module.exports = exports.default;
  13508. } (namespace, namespace.exports));
  13509. (function (module, exports) {
  13510. exports.__esModule = true;
  13511. exports["default"] = void 0;
  13512. var _namespace = _interopRequireDefault(namespace.exports);
  13513. var _types = types;
  13514. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13515. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13516. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13517. var Tag = /*#__PURE__*/function (_Namespace) {
  13518. _inheritsLoose(Tag, _Namespace);
  13519. function Tag(opts) {
  13520. var _this;
  13521. _this = _Namespace.call(this, opts) || this;
  13522. _this.type = _types.TAG;
  13523. return _this;
  13524. }
  13525. return Tag;
  13526. }(_namespace["default"]);
  13527. exports["default"] = Tag;
  13528. module.exports = exports.default;
  13529. } (tag$1, tag$1.exports));
  13530. var string$1 = {exports: {}};
  13531. (function (module, exports) {
  13532. exports.__esModule = true;
  13533. exports["default"] = void 0;
  13534. var _node = _interopRequireDefault(node$1.exports);
  13535. var _types = types;
  13536. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13537. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13538. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13539. var String = /*#__PURE__*/function (_Node) {
  13540. _inheritsLoose(String, _Node);
  13541. function String(opts) {
  13542. var _this;
  13543. _this = _Node.call(this, opts) || this;
  13544. _this.type = _types.STRING;
  13545. return _this;
  13546. }
  13547. return String;
  13548. }(_node["default"]);
  13549. exports["default"] = String;
  13550. module.exports = exports.default;
  13551. } (string$1, string$1.exports));
  13552. var pseudo$1 = {exports: {}};
  13553. (function (module, exports) {
  13554. exports.__esModule = true;
  13555. exports["default"] = void 0;
  13556. var _container = _interopRequireDefault(container.exports);
  13557. var _types = types;
  13558. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13559. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13560. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13561. var Pseudo = /*#__PURE__*/function (_Container) {
  13562. _inheritsLoose(Pseudo, _Container);
  13563. function Pseudo(opts) {
  13564. var _this;
  13565. _this = _Container.call(this, opts) || this;
  13566. _this.type = _types.PSEUDO;
  13567. return _this;
  13568. }
  13569. var _proto = Pseudo.prototype;
  13570. _proto.toString = function toString() {
  13571. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  13572. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  13573. };
  13574. return Pseudo;
  13575. }(_container["default"]);
  13576. exports["default"] = Pseudo;
  13577. module.exports = exports.default;
  13578. } (pseudo$1, pseudo$1.exports));
  13579. var attribute$1 = {};
  13580. /**
  13581. * For Node.js, simply re-export the core `util.deprecate` function.
  13582. */
  13583. var node = require$$2__default["default"].deprecate;
  13584. (function (exports) {
  13585. exports.__esModule = true;
  13586. exports.unescapeValue = unescapeValue;
  13587. exports["default"] = void 0;
  13588. var _cssesc = _interopRequireDefault(cssesc_1);
  13589. var _unesc = _interopRequireDefault(unesc.exports);
  13590. var _namespace = _interopRequireDefault(namespace.exports);
  13591. var _types = types;
  13592. var _CSSESC_QUOTE_OPTIONS;
  13593. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13594. 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); } }
  13595. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13596. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13597. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13598. var deprecate = node;
  13599. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  13600. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  13601. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  13602. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  13603. function unescapeValue(value) {
  13604. var deprecatedUsage = false;
  13605. var quoteMark = null;
  13606. var unescaped = value;
  13607. var m = unescaped.match(WRAPPED_IN_QUOTES);
  13608. if (m) {
  13609. quoteMark = m[1];
  13610. unescaped = m[2];
  13611. }
  13612. unescaped = (0, _unesc["default"])(unescaped);
  13613. if (unescaped !== value) {
  13614. deprecatedUsage = true;
  13615. }
  13616. return {
  13617. deprecatedUsage: deprecatedUsage,
  13618. unescaped: unescaped,
  13619. quoteMark: quoteMark
  13620. };
  13621. }
  13622. function handleDeprecatedContructorOpts(opts) {
  13623. if (opts.quoteMark !== undefined) {
  13624. return opts;
  13625. }
  13626. if (opts.value === undefined) {
  13627. return opts;
  13628. }
  13629. warnOfDeprecatedConstructor();
  13630. var _unescapeValue = unescapeValue(opts.value),
  13631. quoteMark = _unescapeValue.quoteMark,
  13632. unescaped = _unescapeValue.unescaped;
  13633. if (!opts.raws) {
  13634. opts.raws = {};
  13635. }
  13636. if (opts.raws.value === undefined) {
  13637. opts.raws.value = opts.value;
  13638. }
  13639. opts.value = unescaped;
  13640. opts.quoteMark = quoteMark;
  13641. return opts;
  13642. }
  13643. var Attribute = /*#__PURE__*/function (_Namespace) {
  13644. _inheritsLoose(Attribute, _Namespace);
  13645. function Attribute(opts) {
  13646. var _this;
  13647. if (opts === void 0) {
  13648. opts = {};
  13649. }
  13650. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  13651. _this.type = _types.ATTRIBUTE;
  13652. _this.raws = _this.raws || {};
  13653. Object.defineProperty(_this.raws, 'unquoted', {
  13654. get: deprecate(function () {
  13655. return _this.value;
  13656. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  13657. set: deprecate(function () {
  13658. return _this.value;
  13659. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  13660. });
  13661. _this._constructed = true;
  13662. return _this;
  13663. }
  13664. /**
  13665. * Returns the Attribute's value quoted such that it would be legal to use
  13666. * in the value of a css file. The original value's quotation setting
  13667. * used for stringification is left unchanged. See `setValue(value, options)`
  13668. * if you want to control the quote settings of a new value for the attribute.
  13669. *
  13670. * You can also change the quotation used for the current value by setting quoteMark.
  13671. *
  13672. * Options:
  13673. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  13674. * option is not set, the original value for quoteMark will be used. If
  13675. * indeterminate, a double quote is used. The legal values are:
  13676. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  13677. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  13678. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  13679. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  13680. * over the quoteMark option value.
  13681. * * smart {boolean} - if true, will select a quote mark based on the value
  13682. * and the other options specified here. See the `smartQuoteMark()`
  13683. * method.
  13684. **/
  13685. var _proto = Attribute.prototype;
  13686. _proto.getQuotedValue = function getQuotedValue(options) {
  13687. if (options === void 0) {
  13688. options = {};
  13689. }
  13690. var quoteMark = this._determineQuoteMark(options);
  13691. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  13692. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  13693. return escaped;
  13694. };
  13695. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  13696. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  13697. }
  13698. /**
  13699. * Set the unescaped value with the specified quotation options. The value
  13700. * provided must not include any wrapping quote marks -- those quotes will
  13701. * be interpreted as part of the value and escaped accordingly.
  13702. */
  13703. ;
  13704. _proto.setValue = function setValue(value, options) {
  13705. if (options === void 0) {
  13706. options = {};
  13707. }
  13708. this._value = value;
  13709. this._quoteMark = this._determineQuoteMark(options);
  13710. this._syncRawValue();
  13711. }
  13712. /**
  13713. * Intelligently select a quoteMark value based on the value's contents. If
  13714. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  13715. * mark will be picked that minimizes the number of escapes.
  13716. *
  13717. * If there's no clear winner, the quote mark from these options is used,
  13718. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  13719. * true). If the quoteMark is unspecified, a double quote is used.
  13720. *
  13721. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  13722. * from the quoteValue method.
  13723. */
  13724. ;
  13725. _proto.smartQuoteMark = function smartQuoteMark(options) {
  13726. var v = this.value;
  13727. var numSingleQuotes = v.replace(/[^']/g, '').length;
  13728. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  13729. if (numSingleQuotes + numDoubleQuotes === 0) {
  13730. var escaped = (0, _cssesc["default"])(v, {
  13731. isIdentifier: true
  13732. });
  13733. if (escaped === v) {
  13734. return Attribute.NO_QUOTE;
  13735. } else {
  13736. var pref = this.preferredQuoteMark(options);
  13737. if (pref === Attribute.NO_QUOTE) {
  13738. // pick a quote mark that isn't none and see if it's smaller
  13739. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  13740. var opts = CSSESC_QUOTE_OPTIONS[quote];
  13741. var quoteValue = (0, _cssesc["default"])(v, opts);
  13742. if (quoteValue.length < escaped.length) {
  13743. return quote;
  13744. }
  13745. }
  13746. return pref;
  13747. }
  13748. } else if (numDoubleQuotes === numSingleQuotes) {
  13749. return this.preferredQuoteMark(options);
  13750. } else if (numDoubleQuotes < numSingleQuotes) {
  13751. return Attribute.DOUBLE_QUOTE;
  13752. } else {
  13753. return Attribute.SINGLE_QUOTE;
  13754. }
  13755. }
  13756. /**
  13757. * Selects the preferred quote mark based on the options and the current quote mark value.
  13758. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  13759. * instead.
  13760. */
  13761. ;
  13762. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  13763. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  13764. if (quoteMark === undefined) {
  13765. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  13766. }
  13767. if (quoteMark === undefined) {
  13768. quoteMark = Attribute.DOUBLE_QUOTE;
  13769. }
  13770. return quoteMark;
  13771. };
  13772. _proto._syncRawValue = function _syncRawValue() {
  13773. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  13774. if (rawValue === this._value) {
  13775. if (this.raws) {
  13776. delete this.raws.value;
  13777. }
  13778. } else {
  13779. this.raws.value = rawValue;
  13780. }
  13781. };
  13782. _proto._handleEscapes = function _handleEscapes(prop, value) {
  13783. if (this._constructed) {
  13784. var escaped = (0, _cssesc["default"])(value, {
  13785. isIdentifier: true
  13786. });
  13787. if (escaped !== value) {
  13788. this.raws[prop] = escaped;
  13789. } else {
  13790. delete this.raws[prop];
  13791. }
  13792. }
  13793. };
  13794. _proto._spacesFor = function _spacesFor(name) {
  13795. var attrSpaces = {
  13796. before: '',
  13797. after: ''
  13798. };
  13799. var spaces = this.spaces[name] || {};
  13800. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  13801. return Object.assign(attrSpaces, spaces, rawSpaces);
  13802. };
  13803. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  13804. if (spaceName === void 0) {
  13805. spaceName = name;
  13806. }
  13807. if (concat === void 0) {
  13808. concat = defaultAttrConcat;
  13809. }
  13810. var attrSpaces = this._spacesFor(spaceName);
  13811. return concat(this.stringifyProperty(name), attrSpaces);
  13812. }
  13813. /**
  13814. * returns the offset of the attribute part specified relative to the
  13815. * start of the node of the output string.
  13816. *
  13817. * * "ns" - alias for "namespace"
  13818. * * "namespace" - the namespace if it exists.
  13819. * * "attribute" - the attribute name
  13820. * * "attributeNS" - the start of the attribute or its namespace
  13821. * * "operator" - the match operator of the attribute
  13822. * * "value" - The value (string or identifier)
  13823. * * "insensitive" - the case insensitivity flag;
  13824. * @param part One of the possible values inside an attribute.
  13825. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  13826. */
  13827. ;
  13828. _proto.offsetOf = function offsetOf(name) {
  13829. var count = 1;
  13830. var attributeSpaces = this._spacesFor("attribute");
  13831. count += attributeSpaces.before.length;
  13832. if (name === "namespace" || name === "ns") {
  13833. return this.namespace ? count : -1;
  13834. }
  13835. if (name === "attributeNS") {
  13836. return count;
  13837. }
  13838. count += this.namespaceString.length;
  13839. if (this.namespace) {
  13840. count += 1;
  13841. }
  13842. if (name === "attribute") {
  13843. return count;
  13844. }
  13845. count += this.stringifyProperty("attribute").length;
  13846. count += attributeSpaces.after.length;
  13847. var operatorSpaces = this._spacesFor("operator");
  13848. count += operatorSpaces.before.length;
  13849. var operator = this.stringifyProperty("operator");
  13850. if (name === "operator") {
  13851. return operator ? count : -1;
  13852. }
  13853. count += operator.length;
  13854. count += operatorSpaces.after.length;
  13855. var valueSpaces = this._spacesFor("value");
  13856. count += valueSpaces.before.length;
  13857. var value = this.stringifyProperty("value");
  13858. if (name === "value") {
  13859. return value ? count : -1;
  13860. }
  13861. count += value.length;
  13862. count += valueSpaces.after.length;
  13863. var insensitiveSpaces = this._spacesFor("insensitive");
  13864. count += insensitiveSpaces.before.length;
  13865. if (name === "insensitive") {
  13866. return this.insensitive ? count : -1;
  13867. }
  13868. return -1;
  13869. };
  13870. _proto.toString = function toString() {
  13871. var _this2 = this;
  13872. var selector = [this.rawSpaceBefore, '['];
  13873. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  13874. if (this.operator && (this.value || this.value === '')) {
  13875. selector.push(this._stringFor('operator'));
  13876. selector.push(this._stringFor('value'));
  13877. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  13878. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  13879. attrSpaces.before = " ";
  13880. }
  13881. return defaultAttrConcat(attrValue, attrSpaces);
  13882. }));
  13883. }
  13884. selector.push(']');
  13885. selector.push(this.rawSpaceAfter);
  13886. return selector.join('');
  13887. };
  13888. _createClass(Attribute, [{
  13889. key: "quoted",
  13890. get: function get() {
  13891. var qm = this.quoteMark;
  13892. return qm === "'" || qm === '"';
  13893. },
  13894. set: function set(value) {
  13895. warnOfDeprecatedQuotedAssignment();
  13896. }
  13897. /**
  13898. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  13899. * returns `null` if the value is not quoted.
  13900. * returns `undefined` if the quotation state is unknown (this can happen when
  13901. * the attribute is constructed without specifying a quote mark.)
  13902. */
  13903. }, {
  13904. key: "quoteMark",
  13905. get: function get() {
  13906. return this._quoteMark;
  13907. }
  13908. /**
  13909. * Set the quote mark to be used by this attribute's value.
  13910. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  13911. * value is updated accordingly.
  13912. *
  13913. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  13914. */
  13915. ,
  13916. set: function set(quoteMark) {
  13917. if (!this._constructed) {
  13918. this._quoteMark = quoteMark;
  13919. return;
  13920. }
  13921. if (this._quoteMark !== quoteMark) {
  13922. this._quoteMark = quoteMark;
  13923. this._syncRawValue();
  13924. }
  13925. }
  13926. }, {
  13927. key: "qualifiedAttribute",
  13928. get: function get() {
  13929. return this.qualifiedName(this.raws.attribute || this.attribute);
  13930. }
  13931. }, {
  13932. key: "insensitiveFlag",
  13933. get: function get() {
  13934. return this.insensitive ? 'i' : '';
  13935. }
  13936. }, {
  13937. key: "value",
  13938. get: function get() {
  13939. return this._value;
  13940. }
  13941. /**
  13942. * Before 3.0, the value had to be set to an escaped value including any wrapped
  13943. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  13944. * is unescaped during parsing and any quote marks are removed.
  13945. *
  13946. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  13947. * a deprecation warning is raised when the new value contains any characters that would
  13948. * require escaping (including if it contains wrapped quotes).
  13949. *
  13950. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  13951. * how the new value is quoted.
  13952. */
  13953. ,
  13954. set: function set(v) {
  13955. if (this._constructed) {
  13956. var _unescapeValue2 = unescapeValue(v),
  13957. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  13958. unescaped = _unescapeValue2.unescaped,
  13959. quoteMark = _unescapeValue2.quoteMark;
  13960. if (deprecatedUsage) {
  13961. warnOfDeprecatedValueAssignment();
  13962. }
  13963. if (unescaped === this._value && quoteMark === this._quoteMark) {
  13964. return;
  13965. }
  13966. this._value = unescaped;
  13967. this._quoteMark = quoteMark;
  13968. this._syncRawValue();
  13969. } else {
  13970. this._value = v;
  13971. }
  13972. }
  13973. }, {
  13974. key: "attribute",
  13975. get: function get() {
  13976. return this._attribute;
  13977. },
  13978. set: function set(name) {
  13979. this._handleEscapes("attribute", name);
  13980. this._attribute = name;
  13981. }
  13982. }]);
  13983. return Attribute;
  13984. }(_namespace["default"]);
  13985. exports["default"] = Attribute;
  13986. Attribute.NO_QUOTE = null;
  13987. Attribute.SINGLE_QUOTE = "'";
  13988. Attribute.DOUBLE_QUOTE = '"';
  13989. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  13990. "'": {
  13991. quotes: 'single',
  13992. wrap: true
  13993. },
  13994. '"': {
  13995. quotes: 'double',
  13996. wrap: true
  13997. }
  13998. }, _CSSESC_QUOTE_OPTIONS[null] = {
  13999. isIdentifier: true
  14000. }, _CSSESC_QUOTE_OPTIONS);
  14001. function defaultAttrConcat(attrValue, attrSpaces) {
  14002. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  14003. }
  14004. } (attribute$1));
  14005. var universal$1 = {exports: {}};
  14006. (function (module, exports) {
  14007. exports.__esModule = true;
  14008. exports["default"] = void 0;
  14009. var _namespace = _interopRequireDefault(namespace.exports);
  14010. var _types = types;
  14011. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14012. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14013. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14014. var Universal = /*#__PURE__*/function (_Namespace) {
  14015. _inheritsLoose(Universal, _Namespace);
  14016. function Universal(opts) {
  14017. var _this;
  14018. _this = _Namespace.call(this, opts) || this;
  14019. _this.type = _types.UNIVERSAL;
  14020. _this.value = '*';
  14021. return _this;
  14022. }
  14023. return Universal;
  14024. }(_namespace["default"]);
  14025. exports["default"] = Universal;
  14026. module.exports = exports.default;
  14027. } (universal$1, universal$1.exports));
  14028. var combinator$2 = {exports: {}};
  14029. (function (module, exports) {
  14030. exports.__esModule = true;
  14031. exports["default"] = void 0;
  14032. var _node = _interopRequireDefault(node$1.exports);
  14033. var _types = types;
  14034. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14035. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14036. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14037. var Combinator = /*#__PURE__*/function (_Node) {
  14038. _inheritsLoose(Combinator, _Node);
  14039. function Combinator(opts) {
  14040. var _this;
  14041. _this = _Node.call(this, opts) || this;
  14042. _this.type = _types.COMBINATOR;
  14043. return _this;
  14044. }
  14045. return Combinator;
  14046. }(_node["default"]);
  14047. exports["default"] = Combinator;
  14048. module.exports = exports.default;
  14049. } (combinator$2, combinator$2.exports));
  14050. var nesting$1 = {exports: {}};
  14051. (function (module, exports) {
  14052. exports.__esModule = true;
  14053. exports["default"] = void 0;
  14054. var _node = _interopRequireDefault(node$1.exports);
  14055. var _types = types;
  14056. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14057. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14058. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14059. var Nesting = /*#__PURE__*/function (_Node) {
  14060. _inheritsLoose(Nesting, _Node);
  14061. function Nesting(opts) {
  14062. var _this;
  14063. _this = _Node.call(this, opts) || this;
  14064. _this.type = _types.NESTING;
  14065. _this.value = '&';
  14066. return _this;
  14067. }
  14068. return Nesting;
  14069. }(_node["default"]);
  14070. exports["default"] = Nesting;
  14071. module.exports = exports.default;
  14072. } (nesting$1, nesting$1.exports));
  14073. var sortAscending = {exports: {}};
  14074. (function (module, exports) {
  14075. exports.__esModule = true;
  14076. exports["default"] = sortAscending;
  14077. function sortAscending(list) {
  14078. return list.sort(function (a, b) {
  14079. return a - b;
  14080. });
  14081. }
  14082. module.exports = exports.default;
  14083. } (sortAscending, sortAscending.exports));
  14084. var tokenize = {};
  14085. var tokenTypes = {};
  14086. tokenTypes.__esModule = true;
  14087. tokenTypes.combinator = tokenTypes.word = tokenTypes.comment = tokenTypes.str = tokenTypes.tab = tokenTypes.newline = tokenTypes.feed = tokenTypes.cr = tokenTypes.backslash = tokenTypes.bang = tokenTypes.slash = tokenTypes.doubleQuote = tokenTypes.singleQuote = tokenTypes.space = tokenTypes.greaterThan = tokenTypes.pipe = tokenTypes.equals = tokenTypes.plus = tokenTypes.caret = tokenTypes.tilde = tokenTypes.dollar = tokenTypes.closeSquare = tokenTypes.openSquare = tokenTypes.closeParenthesis = tokenTypes.openParenthesis = tokenTypes.semicolon = tokenTypes.colon = tokenTypes.comma = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  14088. var ampersand = 38; // `&`.charCodeAt(0);
  14089. tokenTypes.ampersand = ampersand;
  14090. var asterisk = 42; // `*`.charCodeAt(0);
  14091. tokenTypes.asterisk = asterisk;
  14092. var at = 64; // `@`.charCodeAt(0);
  14093. tokenTypes.at = at;
  14094. var comma = 44; // `,`.charCodeAt(0);
  14095. tokenTypes.comma = comma;
  14096. var colon = 58; // `:`.charCodeAt(0);
  14097. tokenTypes.colon = colon;
  14098. var semicolon = 59; // `;`.charCodeAt(0);
  14099. tokenTypes.semicolon = semicolon;
  14100. var openParenthesis = 40; // `(`.charCodeAt(0);
  14101. tokenTypes.openParenthesis = openParenthesis;
  14102. var closeParenthesis = 41; // `)`.charCodeAt(0);
  14103. tokenTypes.closeParenthesis = closeParenthesis;
  14104. var openSquare = 91; // `[`.charCodeAt(0);
  14105. tokenTypes.openSquare = openSquare;
  14106. var closeSquare = 93; // `]`.charCodeAt(0);
  14107. tokenTypes.closeSquare = closeSquare;
  14108. var dollar = 36; // `$`.charCodeAt(0);
  14109. tokenTypes.dollar = dollar;
  14110. var tilde = 126; // `~`.charCodeAt(0);
  14111. tokenTypes.tilde = tilde;
  14112. var caret = 94; // `^`.charCodeAt(0);
  14113. tokenTypes.caret = caret;
  14114. var plus = 43; // `+`.charCodeAt(0);
  14115. tokenTypes.plus = plus;
  14116. var equals = 61; // `=`.charCodeAt(0);
  14117. tokenTypes.equals = equals;
  14118. var pipe = 124; // `|`.charCodeAt(0);
  14119. tokenTypes.pipe = pipe;
  14120. var greaterThan = 62; // `>`.charCodeAt(0);
  14121. tokenTypes.greaterThan = greaterThan;
  14122. var space = 32; // ` `.charCodeAt(0);
  14123. tokenTypes.space = space;
  14124. var singleQuote = 39; // `'`.charCodeAt(0);
  14125. tokenTypes.singleQuote = singleQuote;
  14126. var doubleQuote = 34; // `"`.charCodeAt(0);
  14127. tokenTypes.doubleQuote = doubleQuote;
  14128. var slash = 47; // `/`.charCodeAt(0);
  14129. tokenTypes.slash = slash;
  14130. var bang = 33; // `!`.charCodeAt(0);
  14131. tokenTypes.bang = bang;
  14132. var backslash = 92; // '\\'.charCodeAt(0);
  14133. tokenTypes.backslash = backslash;
  14134. var cr = 13; // '\r'.charCodeAt(0);
  14135. tokenTypes.cr = cr;
  14136. var feed = 12; // '\f'.charCodeAt(0);
  14137. tokenTypes.feed = feed;
  14138. var newline = 10; // '\n'.charCodeAt(0);
  14139. tokenTypes.newline = newline;
  14140. var tab = 9; // '\t'.charCodeAt(0);
  14141. // Expose aliases primarily for readability.
  14142. tokenTypes.tab = tab;
  14143. var str = singleQuote; // No good single character representation!
  14144. tokenTypes.str = str;
  14145. var comment$1 = -1;
  14146. tokenTypes.comment = comment$1;
  14147. var word = -2;
  14148. tokenTypes.word = word;
  14149. var combinator$1 = -3;
  14150. tokenTypes.combinator = combinator$1;
  14151. (function (exports) {
  14152. exports.__esModule = true;
  14153. exports["default"] = tokenize;
  14154. exports.FIELDS = void 0;
  14155. var t = _interopRequireWildcard(tokenTypes);
  14156. var _unescapable, _wordDelimiters;
  14157. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  14158. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
  14159. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  14160. 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);
  14161. var hex = {};
  14162. var hexChars = "0123456789abcdefABCDEF";
  14163. for (var i = 0; i < hexChars.length; i++) {
  14164. hex[hexChars.charCodeAt(i)] = true;
  14165. }
  14166. /**
  14167. * Returns the last index of the bar css word
  14168. * @param {string} css The string in which the word begins
  14169. * @param {number} start The index into the string where word's first letter occurs
  14170. */
  14171. function consumeWord(css, start) {
  14172. var next = start;
  14173. var code;
  14174. do {
  14175. code = css.charCodeAt(next);
  14176. if (wordDelimiters[code]) {
  14177. return next - 1;
  14178. } else if (code === t.backslash) {
  14179. next = consumeEscape(css, next) + 1;
  14180. } else {
  14181. // All other characters are part of the word
  14182. next++;
  14183. }
  14184. } while (next < css.length);
  14185. return next - 1;
  14186. }
  14187. /**
  14188. * Returns the last index of the escape sequence
  14189. * @param {string} css The string in which the sequence begins
  14190. * @param {number} start The index into the string where escape character (`\`) occurs.
  14191. */
  14192. function consumeEscape(css, start) {
  14193. var next = start;
  14194. var code = css.charCodeAt(next + 1);
  14195. if (unescapable[code]) ; else if (hex[code]) {
  14196. var hexDigits = 0; // consume up to 6 hex chars
  14197. do {
  14198. next++;
  14199. hexDigits++;
  14200. code = css.charCodeAt(next + 1);
  14201. } while (hex[code] && hexDigits < 6); // if fewer than 6 hex chars, a trailing space ends the escape
  14202. if (hexDigits < 6 && code === t.space) {
  14203. next++;
  14204. }
  14205. } else {
  14206. // the next char is part of the current word
  14207. next++;
  14208. }
  14209. return next;
  14210. }
  14211. var FIELDS = {
  14212. TYPE: 0,
  14213. START_LINE: 1,
  14214. START_COL: 2,
  14215. END_LINE: 3,
  14216. END_COL: 4,
  14217. START_POS: 5,
  14218. END_POS: 6
  14219. };
  14220. exports.FIELDS = FIELDS;
  14221. function tokenize(input) {
  14222. var tokens = [];
  14223. var css = input.css.valueOf();
  14224. var _css = css,
  14225. length = _css.length;
  14226. var offset = -1;
  14227. var line = 1;
  14228. var start = 0;
  14229. var end = 0;
  14230. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  14231. function unclosed(what, fix) {
  14232. if (input.safe) {
  14233. // fyi: this is never set to true.
  14234. css += fix;
  14235. next = css.length - 1;
  14236. } else {
  14237. throw input.error('Unclosed ' + what, line, start - offset, start);
  14238. }
  14239. }
  14240. while (start < length) {
  14241. code = css.charCodeAt(start);
  14242. if (code === t.newline) {
  14243. offset = start;
  14244. line += 1;
  14245. }
  14246. switch (code) {
  14247. case t.space:
  14248. case t.tab:
  14249. case t.newline:
  14250. case t.cr:
  14251. case t.feed:
  14252. next = start;
  14253. do {
  14254. next += 1;
  14255. code = css.charCodeAt(next);
  14256. if (code === t.newline) {
  14257. offset = next;
  14258. line += 1;
  14259. }
  14260. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  14261. tokenType = t.space;
  14262. endLine = line;
  14263. endColumn = next - offset - 1;
  14264. end = next;
  14265. break;
  14266. case t.plus:
  14267. case t.greaterThan:
  14268. case t.tilde:
  14269. case t.pipe:
  14270. next = start;
  14271. do {
  14272. next += 1;
  14273. code = css.charCodeAt(next);
  14274. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  14275. tokenType = t.combinator;
  14276. endLine = line;
  14277. endColumn = start - offset;
  14278. end = next;
  14279. break;
  14280. // Consume these characters as single tokens.
  14281. case t.asterisk:
  14282. case t.ampersand:
  14283. case t.bang:
  14284. case t.comma:
  14285. case t.equals:
  14286. case t.dollar:
  14287. case t.caret:
  14288. case t.openSquare:
  14289. case t.closeSquare:
  14290. case t.colon:
  14291. case t.semicolon:
  14292. case t.openParenthesis:
  14293. case t.closeParenthesis:
  14294. next = start;
  14295. tokenType = code;
  14296. endLine = line;
  14297. endColumn = start - offset;
  14298. end = next + 1;
  14299. break;
  14300. case t.singleQuote:
  14301. case t.doubleQuote:
  14302. quote = code === t.singleQuote ? "'" : '"';
  14303. next = start;
  14304. do {
  14305. escaped = false;
  14306. next = css.indexOf(quote, next + 1);
  14307. if (next === -1) {
  14308. unclosed('quote', quote);
  14309. }
  14310. escapePos = next;
  14311. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  14312. escapePos -= 1;
  14313. escaped = !escaped;
  14314. }
  14315. } while (escaped);
  14316. tokenType = t.str;
  14317. endLine = line;
  14318. endColumn = start - offset;
  14319. end = next + 1;
  14320. break;
  14321. default:
  14322. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  14323. next = css.indexOf('*/', start + 2) + 1;
  14324. if (next === 0) {
  14325. unclosed('comment', '*/');
  14326. }
  14327. content = css.slice(start, next + 1);
  14328. lines = content.split('\n');
  14329. last = lines.length - 1;
  14330. if (last > 0) {
  14331. nextLine = line + last;
  14332. nextOffset = next - lines[last].length;
  14333. } else {
  14334. nextLine = line;
  14335. nextOffset = offset;
  14336. }
  14337. tokenType = t.comment;
  14338. line = nextLine;
  14339. endLine = nextLine;
  14340. endColumn = next - nextOffset;
  14341. } else if (code === t.slash) {
  14342. next = start;
  14343. tokenType = code;
  14344. endLine = line;
  14345. endColumn = start - offset;
  14346. end = next + 1;
  14347. } else {
  14348. next = consumeWord(css, start);
  14349. tokenType = t.word;
  14350. endLine = line;
  14351. endColumn = next - offset;
  14352. }
  14353. end = next + 1;
  14354. break;
  14355. } // Ensure that the token structure remains consistent
  14356. tokens.push([tokenType, // [0] Token type
  14357. line, // [1] Starting line
  14358. start - offset, // [2] Starting column
  14359. endLine, // [3] Ending line
  14360. endColumn, // [4] Ending column
  14361. start, // [5] Start position / Source index
  14362. end // [6] End position
  14363. ]); // Reset offset for the next token
  14364. if (nextOffset) {
  14365. offset = nextOffset;
  14366. nextOffset = null;
  14367. }
  14368. start = end;
  14369. }
  14370. return tokens;
  14371. }
  14372. } (tokenize));
  14373. (function (module, exports) {
  14374. exports.__esModule = true;
  14375. exports["default"] = void 0;
  14376. var _root = _interopRequireDefault(root$1.exports);
  14377. var _selector = _interopRequireDefault(selector$1.exports);
  14378. var _className = _interopRequireDefault(className$1.exports);
  14379. var _comment = _interopRequireDefault(comment$2.exports);
  14380. var _id = _interopRequireDefault(id$1.exports);
  14381. var _tag = _interopRequireDefault(tag$1.exports);
  14382. var _string = _interopRequireDefault(string$1.exports);
  14383. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  14384. var _attribute = _interopRequireWildcard(attribute$1);
  14385. var _universal = _interopRequireDefault(universal$1.exports);
  14386. var _combinator = _interopRequireDefault(combinator$2.exports);
  14387. var _nesting = _interopRequireDefault(nesting$1.exports);
  14388. var _sortAscending = _interopRequireDefault(sortAscending.exports);
  14389. var _tokenize = _interopRequireWildcard(tokenize);
  14390. var tokens = _interopRequireWildcard(tokenTypes);
  14391. var types$1 = _interopRequireWildcard(types);
  14392. var _util = util;
  14393. var _WHITESPACE_TOKENS, _Object$assign;
  14394. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  14395. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
  14396. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14397. 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); } }
  14398. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14399. 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);
  14400. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  14401. function tokenStart(token) {
  14402. return {
  14403. line: token[_tokenize.FIELDS.START_LINE],
  14404. column: token[_tokenize.FIELDS.START_COL]
  14405. };
  14406. }
  14407. function tokenEnd(token) {
  14408. return {
  14409. line: token[_tokenize.FIELDS.END_LINE],
  14410. column: token[_tokenize.FIELDS.END_COL]
  14411. };
  14412. }
  14413. function getSource(startLine, startColumn, endLine, endColumn) {
  14414. return {
  14415. start: {
  14416. line: startLine,
  14417. column: startColumn
  14418. },
  14419. end: {
  14420. line: endLine,
  14421. column: endColumn
  14422. }
  14423. };
  14424. }
  14425. function getTokenSource(token) {
  14426. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  14427. }
  14428. function getTokenSourceSpan(startToken, endToken) {
  14429. if (!startToken) {
  14430. return undefined;
  14431. }
  14432. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  14433. }
  14434. function unescapeProp(node, prop) {
  14435. var value = node[prop];
  14436. if (typeof value !== "string") {
  14437. return;
  14438. }
  14439. if (value.indexOf("\\") !== -1) {
  14440. (0, _util.ensureObject)(node, 'raws');
  14441. node[prop] = (0, _util.unesc)(value);
  14442. if (node.raws[prop] === undefined) {
  14443. node.raws[prop] = value;
  14444. }
  14445. }
  14446. return node;
  14447. }
  14448. function indexesOf(array, item) {
  14449. var i = -1;
  14450. var indexes = [];
  14451. while ((i = array.indexOf(item, i + 1)) !== -1) {
  14452. indexes.push(i);
  14453. }
  14454. return indexes;
  14455. }
  14456. function uniqs() {
  14457. var list = Array.prototype.concat.apply([], arguments);
  14458. return list.filter(function (item, i) {
  14459. return i === list.indexOf(item);
  14460. });
  14461. }
  14462. var Parser = /*#__PURE__*/function () {
  14463. function Parser(rule, options) {
  14464. if (options === void 0) {
  14465. options = {};
  14466. }
  14467. this.rule = rule;
  14468. this.options = Object.assign({
  14469. lossy: false,
  14470. safe: false
  14471. }, options);
  14472. this.position = 0;
  14473. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  14474. this.tokens = (0, _tokenize["default"])({
  14475. css: this.css,
  14476. error: this._errorGenerator(),
  14477. safe: this.options.safe
  14478. });
  14479. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  14480. this.root = new _root["default"]({
  14481. source: rootSource
  14482. });
  14483. this.root.errorGenerator = this._errorGenerator();
  14484. var selector = new _selector["default"]({
  14485. source: {
  14486. start: {
  14487. line: 1,
  14488. column: 1
  14489. }
  14490. }
  14491. });
  14492. this.root.append(selector);
  14493. this.current = selector;
  14494. this.loop();
  14495. }
  14496. var _proto = Parser.prototype;
  14497. _proto._errorGenerator = function _errorGenerator() {
  14498. var _this = this;
  14499. return function (message, errorOptions) {
  14500. if (typeof _this.rule === 'string') {
  14501. return new Error(message);
  14502. }
  14503. return _this.rule.error(message, errorOptions);
  14504. };
  14505. };
  14506. _proto.attribute = function attribute() {
  14507. var attr = [];
  14508. var startingToken = this.currToken;
  14509. this.position++;
  14510. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  14511. attr.push(this.currToken);
  14512. this.position++;
  14513. }
  14514. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  14515. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  14516. }
  14517. var len = attr.length;
  14518. var node = {
  14519. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  14520. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  14521. };
  14522. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  14523. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  14524. }
  14525. var pos = 0;
  14526. var spaceBefore = '';
  14527. var commentBefore = '';
  14528. var lastAdded = null;
  14529. var spaceAfterMeaningfulToken = false;
  14530. while (pos < len) {
  14531. var token = attr[pos];
  14532. var content = this.content(token);
  14533. var next = attr[pos + 1];
  14534. switch (token[_tokenize.FIELDS.TYPE]) {
  14535. case tokens.space:
  14536. // if (
  14537. // len === 1 ||
  14538. // pos === 0 && this.content(next) === '|'
  14539. // ) {
  14540. // return this.expected('attribute', token[TOKEN.START_POS], content);
  14541. // }
  14542. spaceAfterMeaningfulToken = true;
  14543. if (this.options.lossy) {
  14544. break;
  14545. }
  14546. if (lastAdded) {
  14547. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  14548. var prevContent = node.spaces[lastAdded].after || '';
  14549. node.spaces[lastAdded].after = prevContent + content;
  14550. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  14551. if (existingComment) {
  14552. node.raws.spaces[lastAdded].after = existingComment + content;
  14553. }
  14554. } else {
  14555. spaceBefore = spaceBefore + content;
  14556. commentBefore = commentBefore + content;
  14557. }
  14558. break;
  14559. case tokens.asterisk:
  14560. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14561. node.operator = content;
  14562. lastAdded = 'operator';
  14563. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  14564. if (spaceBefore) {
  14565. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  14566. node.spaces.attribute.before = spaceBefore;
  14567. spaceBefore = '';
  14568. }
  14569. if (commentBefore) {
  14570. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  14571. node.raws.spaces.attribute.before = spaceBefore;
  14572. commentBefore = '';
  14573. }
  14574. node.namespace = (node.namespace || "") + content;
  14575. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  14576. if (rawValue) {
  14577. node.raws.namespace += content;
  14578. }
  14579. lastAdded = 'namespace';
  14580. }
  14581. spaceAfterMeaningfulToken = false;
  14582. break;
  14583. case tokens.dollar:
  14584. if (lastAdded === "value") {
  14585. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  14586. node.value += "$";
  14587. if (oldRawValue) {
  14588. node.raws.value = oldRawValue + "$";
  14589. }
  14590. break;
  14591. }
  14592. // Falls through
  14593. case tokens.caret:
  14594. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14595. node.operator = content;
  14596. lastAdded = 'operator';
  14597. }
  14598. spaceAfterMeaningfulToken = false;
  14599. break;
  14600. case tokens.combinator:
  14601. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14602. node.operator = content;
  14603. lastAdded = 'operator';
  14604. }
  14605. if (content !== '|') {
  14606. spaceAfterMeaningfulToken = false;
  14607. break;
  14608. }
  14609. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14610. node.operator = content;
  14611. lastAdded = 'operator';
  14612. } else if (!node.namespace && !node.attribute) {
  14613. node.namespace = true;
  14614. }
  14615. spaceAfterMeaningfulToken = false;
  14616. break;
  14617. case tokens.word:
  14618. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && // this look-ahead probably fails with comment nodes involved.
  14619. !node.operator && !node.namespace) {
  14620. node.namespace = content;
  14621. lastAdded = 'namespace';
  14622. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  14623. if (spaceBefore) {
  14624. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  14625. node.spaces.attribute.before = spaceBefore;
  14626. spaceBefore = '';
  14627. }
  14628. if (commentBefore) {
  14629. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  14630. node.raws.spaces.attribute.before = commentBefore;
  14631. commentBefore = '';
  14632. }
  14633. node.attribute = (node.attribute || "") + content;
  14634. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  14635. if (_rawValue) {
  14636. node.raws.attribute += content;
  14637. }
  14638. lastAdded = 'attribute';
  14639. } else if (!node.value && node.value !== "" || lastAdded === "value" && !spaceAfterMeaningfulToken) {
  14640. var _unescaped = (0, _util.unesc)(content);
  14641. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  14642. var oldValue = node.value || '';
  14643. node.value = oldValue + _unescaped;
  14644. node.quoteMark = null;
  14645. if (_unescaped !== content || _oldRawValue) {
  14646. (0, _util.ensureObject)(node, 'raws');
  14647. node.raws.value = (_oldRawValue || oldValue) + content;
  14648. }
  14649. lastAdded = 'value';
  14650. } else {
  14651. var insensitive = content === 'i' || content === "I";
  14652. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  14653. node.insensitive = insensitive;
  14654. if (!insensitive || content === "I") {
  14655. (0, _util.ensureObject)(node, 'raws');
  14656. node.raws.insensitiveFlag = content;
  14657. }
  14658. lastAdded = 'insensitive';
  14659. if (spaceBefore) {
  14660. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  14661. node.spaces.insensitive.before = spaceBefore;
  14662. spaceBefore = '';
  14663. }
  14664. if (commentBefore) {
  14665. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  14666. node.raws.spaces.insensitive.before = commentBefore;
  14667. commentBefore = '';
  14668. }
  14669. } else if (node.value || node.value === '') {
  14670. lastAdded = 'value';
  14671. node.value += content;
  14672. if (node.raws.value) {
  14673. node.raws.value += content;
  14674. }
  14675. }
  14676. }
  14677. spaceAfterMeaningfulToken = false;
  14678. break;
  14679. case tokens.str:
  14680. if (!node.attribute || !node.operator) {
  14681. return this.error("Expected an attribute followed by an operator preceding the string.", {
  14682. index: token[_tokenize.FIELDS.START_POS]
  14683. });
  14684. }
  14685. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  14686. unescaped = _unescapeValue.unescaped,
  14687. quoteMark = _unescapeValue.quoteMark;
  14688. node.value = unescaped;
  14689. node.quoteMark = quoteMark;
  14690. lastAdded = 'value';
  14691. (0, _util.ensureObject)(node, 'raws');
  14692. node.raws.value = content;
  14693. spaceAfterMeaningfulToken = false;
  14694. break;
  14695. case tokens.equals:
  14696. if (!node.attribute) {
  14697. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  14698. }
  14699. if (node.value) {
  14700. return this.error('Unexpected "=" found; an operator was already defined.', {
  14701. index: token[_tokenize.FIELDS.START_POS]
  14702. });
  14703. }
  14704. node.operator = node.operator ? node.operator + content : content;
  14705. lastAdded = 'operator';
  14706. spaceAfterMeaningfulToken = false;
  14707. break;
  14708. case tokens.comment:
  14709. if (lastAdded) {
  14710. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  14711. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  14712. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  14713. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  14714. node.raws.spaces[lastAdded].after = rawLastComment + content;
  14715. } else {
  14716. var lastValue = node[lastAdded] || '';
  14717. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  14718. (0, _util.ensureObject)(node, 'raws');
  14719. node.raws[lastAdded] = rawLastValue + content;
  14720. }
  14721. } else {
  14722. commentBefore = commentBefore + content;
  14723. }
  14724. break;
  14725. default:
  14726. return this.error("Unexpected \"" + content + "\" found.", {
  14727. index: token[_tokenize.FIELDS.START_POS]
  14728. });
  14729. }
  14730. pos++;
  14731. }
  14732. unescapeProp(node, "attribute");
  14733. unescapeProp(node, "namespace");
  14734. this.newNode(new _attribute["default"](node));
  14735. this.position++;
  14736. }
  14737. /**
  14738. * return a node containing meaningless garbage up to (but not including) the specified token position.
  14739. * if the token position is negative, all remaining tokens are consumed.
  14740. *
  14741. * This returns an array containing a single string node if all whitespace,
  14742. * otherwise an array of comment nodes with space before and after.
  14743. *
  14744. * These tokens are not added to the current selector, the caller can add them or use them to amend
  14745. * a previous node's space metadata.
  14746. *
  14747. * In lossy mode, this returns only comments.
  14748. */
  14749. ;
  14750. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  14751. if (stopPosition < 0) {
  14752. stopPosition = this.tokens.length;
  14753. }
  14754. var startPosition = this.position;
  14755. var nodes = [];
  14756. var space = "";
  14757. var lastComment = undefined;
  14758. do {
  14759. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  14760. if (!this.options.lossy) {
  14761. space += this.content();
  14762. }
  14763. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  14764. var spaces = {};
  14765. if (space) {
  14766. spaces.before = space;
  14767. space = "";
  14768. }
  14769. lastComment = new _comment["default"]({
  14770. value: this.content(),
  14771. source: getTokenSource(this.currToken),
  14772. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  14773. spaces: spaces
  14774. });
  14775. nodes.push(lastComment);
  14776. }
  14777. } while (++this.position < stopPosition);
  14778. if (space) {
  14779. if (lastComment) {
  14780. lastComment.spaces.after = space;
  14781. } else if (!this.options.lossy) {
  14782. var firstToken = this.tokens[startPosition];
  14783. var lastToken = this.tokens[this.position - 1];
  14784. nodes.push(new _string["default"]({
  14785. value: '',
  14786. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  14787. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  14788. spaces: {
  14789. before: space,
  14790. after: ''
  14791. }
  14792. }));
  14793. }
  14794. }
  14795. return nodes;
  14796. }
  14797. /**
  14798. *
  14799. * @param {*} nodes
  14800. */
  14801. ;
  14802. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  14803. var _this2 = this;
  14804. if (requiredSpace === void 0) {
  14805. requiredSpace = false;
  14806. }
  14807. var space = "";
  14808. var rawSpace = "";
  14809. nodes.forEach(function (n) {
  14810. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  14811. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  14812. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  14813. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  14814. });
  14815. if (rawSpace === space) {
  14816. rawSpace = undefined;
  14817. }
  14818. var result = {
  14819. space: space,
  14820. rawSpace: rawSpace
  14821. };
  14822. return result;
  14823. };
  14824. _proto.isNamedCombinator = function isNamedCombinator(position) {
  14825. if (position === void 0) {
  14826. position = this.position;
  14827. }
  14828. 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;
  14829. };
  14830. _proto.namedCombinator = function namedCombinator() {
  14831. if (this.isNamedCombinator()) {
  14832. var nameRaw = this.content(this.tokens[this.position + 1]);
  14833. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  14834. var raws = {};
  14835. if (name !== nameRaw) {
  14836. raws.value = "/" + nameRaw + "/";
  14837. }
  14838. var node = new _combinator["default"]({
  14839. value: "/" + name + "/",
  14840. 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]),
  14841. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  14842. raws: raws
  14843. });
  14844. this.position = this.position + 3;
  14845. return node;
  14846. } else {
  14847. this.unexpected();
  14848. }
  14849. };
  14850. _proto.combinator = function combinator() {
  14851. var _this3 = this;
  14852. if (this.content() === '|') {
  14853. return this.namespace();
  14854. } // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  14855. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  14856. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  14857. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  14858. if (nodes.length > 0) {
  14859. var last = this.current.last;
  14860. if (last) {
  14861. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  14862. space = _this$convertWhitespa.space,
  14863. rawSpace = _this$convertWhitespa.rawSpace;
  14864. if (rawSpace !== undefined) {
  14865. last.rawSpaceAfter += rawSpace;
  14866. }
  14867. last.spaces.after += space;
  14868. } else {
  14869. nodes.forEach(function (n) {
  14870. return _this3.newNode(n);
  14871. });
  14872. }
  14873. }
  14874. return;
  14875. }
  14876. var firstToken = this.currToken;
  14877. var spaceOrDescendantSelectorNodes = undefined;
  14878. if (nextSigTokenPos > this.position) {
  14879. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  14880. }
  14881. var node;
  14882. if (this.isNamedCombinator()) {
  14883. node = this.namedCombinator();
  14884. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  14885. node = new _combinator["default"]({
  14886. value: this.content(),
  14887. source: getTokenSource(this.currToken),
  14888. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  14889. });
  14890. this.position++;
  14891. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  14892. this.unexpected();
  14893. }
  14894. if (node) {
  14895. if (spaceOrDescendantSelectorNodes) {
  14896. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  14897. _space = _this$convertWhitespa2.space,
  14898. _rawSpace = _this$convertWhitespa2.rawSpace;
  14899. node.spaces.before = _space;
  14900. node.rawSpaceBefore = _rawSpace;
  14901. }
  14902. } else {
  14903. // descendant combinator
  14904. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  14905. _space2 = _this$convertWhitespa3.space,
  14906. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  14907. if (!_rawSpace2) {
  14908. _rawSpace2 = _space2;
  14909. }
  14910. var spaces = {};
  14911. var raws = {
  14912. spaces: {}
  14913. };
  14914. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  14915. spaces.before = _space2.slice(0, _space2.length - 1);
  14916. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  14917. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  14918. spaces.after = _space2.slice(1);
  14919. raws.spaces.after = _rawSpace2.slice(1);
  14920. } else {
  14921. raws.value = _rawSpace2;
  14922. }
  14923. node = new _combinator["default"]({
  14924. value: ' ',
  14925. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  14926. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  14927. spaces: spaces,
  14928. raws: raws
  14929. });
  14930. }
  14931. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  14932. node.spaces.after = this.optionalSpace(this.content());
  14933. this.position++;
  14934. }
  14935. return this.newNode(node);
  14936. };
  14937. _proto.comma = function comma() {
  14938. if (this.position === this.tokens.length - 1) {
  14939. this.root.trailingComma = true;
  14940. this.position++;
  14941. return;
  14942. }
  14943. this.current._inferEndPosition();
  14944. var selector = new _selector["default"]({
  14945. source: {
  14946. start: tokenStart(this.tokens[this.position + 1])
  14947. }
  14948. });
  14949. this.current.parent.append(selector);
  14950. this.current = selector;
  14951. this.position++;
  14952. };
  14953. _proto.comment = function comment() {
  14954. var current = this.currToken;
  14955. this.newNode(new _comment["default"]({
  14956. value: this.content(),
  14957. source: getTokenSource(current),
  14958. sourceIndex: current[_tokenize.FIELDS.START_POS]
  14959. }));
  14960. this.position++;
  14961. };
  14962. _proto.error = function error(message, opts) {
  14963. throw this.root.error(message, opts);
  14964. };
  14965. _proto.missingBackslash = function missingBackslash() {
  14966. return this.error('Expected a backslash preceding the semicolon.', {
  14967. index: this.currToken[_tokenize.FIELDS.START_POS]
  14968. });
  14969. };
  14970. _proto.missingParenthesis = function missingParenthesis() {
  14971. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  14972. };
  14973. _proto.missingSquareBracket = function missingSquareBracket() {
  14974. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  14975. };
  14976. _proto.unexpected = function unexpected() {
  14977. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  14978. };
  14979. _proto.namespace = function namespace() {
  14980. var before = this.prevToken && this.content(this.prevToken) || true;
  14981. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  14982. this.position++;
  14983. return this.word(before);
  14984. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  14985. this.position++;
  14986. return this.universal(before);
  14987. }
  14988. };
  14989. _proto.nesting = function nesting() {
  14990. if (this.nextToken) {
  14991. var nextContent = this.content(this.nextToken);
  14992. if (nextContent === "|") {
  14993. this.position++;
  14994. return;
  14995. }
  14996. }
  14997. var current = this.currToken;
  14998. this.newNode(new _nesting["default"]({
  14999. value: this.content(),
  15000. source: getTokenSource(current),
  15001. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15002. }));
  15003. this.position++;
  15004. };
  15005. _proto.parentheses = function parentheses() {
  15006. var last = this.current.last;
  15007. var unbalanced = 1;
  15008. this.position++;
  15009. if (last && last.type === types$1.PSEUDO) {
  15010. var selector = new _selector["default"]({
  15011. source: {
  15012. start: tokenStart(this.tokens[this.position - 1])
  15013. }
  15014. });
  15015. var cache = this.current;
  15016. last.append(selector);
  15017. this.current = selector;
  15018. while (this.position < this.tokens.length && unbalanced) {
  15019. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15020. unbalanced++;
  15021. }
  15022. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15023. unbalanced--;
  15024. }
  15025. if (unbalanced) {
  15026. this.parse();
  15027. } else {
  15028. this.current.source.end = tokenEnd(this.currToken);
  15029. this.current.parent.source.end = tokenEnd(this.currToken);
  15030. this.position++;
  15031. }
  15032. }
  15033. this.current = cache;
  15034. } else {
  15035. // I think this case should be an error. It's used to implement a basic parse of media queries
  15036. // but I don't think it's a good idea.
  15037. var parenStart = this.currToken;
  15038. var parenValue = "(";
  15039. var parenEnd;
  15040. while (this.position < this.tokens.length && unbalanced) {
  15041. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15042. unbalanced++;
  15043. }
  15044. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15045. unbalanced--;
  15046. }
  15047. parenEnd = this.currToken;
  15048. parenValue += this.parseParenthesisToken(this.currToken);
  15049. this.position++;
  15050. }
  15051. if (last) {
  15052. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  15053. } else {
  15054. this.newNode(new _string["default"]({
  15055. value: parenValue,
  15056. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  15057. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  15058. }));
  15059. }
  15060. }
  15061. if (unbalanced) {
  15062. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  15063. }
  15064. };
  15065. _proto.pseudo = function pseudo() {
  15066. var _this4 = this;
  15067. var pseudoStr = '';
  15068. var startingToken = this.currToken;
  15069. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  15070. pseudoStr += this.content();
  15071. this.position++;
  15072. }
  15073. if (!this.currToken) {
  15074. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  15075. }
  15076. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  15077. this.splitWord(false, function (first, length) {
  15078. pseudoStr += first;
  15079. _this4.newNode(new _pseudo["default"]({
  15080. value: pseudoStr,
  15081. source: getTokenSourceSpan(startingToken, _this4.currToken),
  15082. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  15083. }));
  15084. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15085. _this4.error('Misplaced parenthesis.', {
  15086. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  15087. });
  15088. }
  15089. });
  15090. } else {
  15091. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  15092. }
  15093. };
  15094. _proto.space = function space() {
  15095. var content = this.content(); // Handle space before and after the selector
  15096. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  15097. return node.type === 'comment';
  15098. })) {
  15099. this.spaces = this.optionalSpace(content);
  15100. this.position++;
  15101. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15102. this.current.last.spaces.after = this.optionalSpace(content);
  15103. this.position++;
  15104. } else {
  15105. this.combinator();
  15106. }
  15107. };
  15108. _proto.string = function string() {
  15109. var current = this.currToken;
  15110. this.newNode(new _string["default"]({
  15111. value: this.content(),
  15112. source: getTokenSource(current),
  15113. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15114. }));
  15115. this.position++;
  15116. };
  15117. _proto.universal = function universal(namespace) {
  15118. var nextToken = this.nextToken;
  15119. if (nextToken && this.content(nextToken) === '|') {
  15120. this.position++;
  15121. return this.namespace();
  15122. }
  15123. var current = this.currToken;
  15124. this.newNode(new _universal["default"]({
  15125. value: this.content(),
  15126. source: getTokenSource(current),
  15127. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15128. }), namespace);
  15129. this.position++;
  15130. };
  15131. _proto.splitWord = function splitWord(namespace, firstCallback) {
  15132. var _this5 = this;
  15133. var nextToken = this.nextToken;
  15134. var word = this.content();
  15135. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  15136. this.position++;
  15137. var current = this.content();
  15138. word += current;
  15139. if (current.lastIndexOf('\\') === current.length - 1) {
  15140. var next = this.nextToken;
  15141. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  15142. word += this.requiredSpace(this.content(next));
  15143. this.position++;
  15144. }
  15145. }
  15146. nextToken = this.nextToken;
  15147. }
  15148. var hasClass = indexesOf(word, '.').filter(function (i) {
  15149. // Allow escaped dot within class name
  15150. var escapedDot = word[i - 1] === '\\'; // Allow decimal numbers percent in @keyframes
  15151. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  15152. return !escapedDot && !isKeyframesPercent;
  15153. });
  15154. var hasId = indexesOf(word, '#').filter(function (i) {
  15155. return word[i - 1] !== '\\';
  15156. }); // Eliminate Sass interpolations from the list of id indexes
  15157. var interpolations = indexesOf(word, '#{');
  15158. if (interpolations.length) {
  15159. hasId = hasId.filter(function (hashIndex) {
  15160. return !~interpolations.indexOf(hashIndex);
  15161. });
  15162. }
  15163. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  15164. indices.forEach(function (ind, i) {
  15165. var index = indices[i + 1] || word.length;
  15166. var value = word.slice(ind, index);
  15167. if (i === 0 && firstCallback) {
  15168. return firstCallback.call(_this5, value, indices.length);
  15169. }
  15170. var node;
  15171. var current = _this5.currToken;
  15172. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  15173. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  15174. if (~hasClass.indexOf(ind)) {
  15175. var classNameOpts = {
  15176. value: value.slice(1),
  15177. source: source,
  15178. sourceIndex: sourceIndex
  15179. };
  15180. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  15181. } else if (~hasId.indexOf(ind)) {
  15182. var idOpts = {
  15183. value: value.slice(1),
  15184. source: source,
  15185. sourceIndex: sourceIndex
  15186. };
  15187. node = new _id["default"](unescapeProp(idOpts, "value"));
  15188. } else {
  15189. var tagOpts = {
  15190. value: value,
  15191. source: source,
  15192. sourceIndex: sourceIndex
  15193. };
  15194. unescapeProp(tagOpts, "value");
  15195. node = new _tag["default"](tagOpts);
  15196. }
  15197. _this5.newNode(node, namespace); // Ensure that the namespace is used only once
  15198. namespace = null;
  15199. });
  15200. this.position++;
  15201. };
  15202. _proto.word = function word(namespace) {
  15203. var nextToken = this.nextToken;
  15204. if (nextToken && this.content(nextToken) === '|') {
  15205. this.position++;
  15206. return this.namespace();
  15207. }
  15208. return this.splitWord(namespace);
  15209. };
  15210. _proto.loop = function loop() {
  15211. while (this.position < this.tokens.length) {
  15212. this.parse(true);
  15213. }
  15214. this.current._inferEndPosition();
  15215. return this.root;
  15216. };
  15217. _proto.parse = function parse(throwOnParenthesis) {
  15218. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  15219. case tokens.space:
  15220. this.space();
  15221. break;
  15222. case tokens.comment:
  15223. this.comment();
  15224. break;
  15225. case tokens.openParenthesis:
  15226. this.parentheses();
  15227. break;
  15228. case tokens.closeParenthesis:
  15229. if (throwOnParenthesis) {
  15230. this.missingParenthesis();
  15231. }
  15232. break;
  15233. case tokens.openSquare:
  15234. this.attribute();
  15235. break;
  15236. case tokens.dollar:
  15237. case tokens.caret:
  15238. case tokens.equals:
  15239. case tokens.word:
  15240. this.word();
  15241. break;
  15242. case tokens.colon:
  15243. this.pseudo();
  15244. break;
  15245. case tokens.comma:
  15246. this.comma();
  15247. break;
  15248. case tokens.asterisk:
  15249. this.universal();
  15250. break;
  15251. case tokens.ampersand:
  15252. this.nesting();
  15253. break;
  15254. case tokens.slash:
  15255. case tokens.combinator:
  15256. this.combinator();
  15257. break;
  15258. case tokens.str:
  15259. this.string();
  15260. break;
  15261. // These cases throw; no break needed.
  15262. case tokens.closeSquare:
  15263. this.missingSquareBracket();
  15264. case tokens.semicolon:
  15265. this.missingBackslash();
  15266. default:
  15267. this.unexpected();
  15268. }
  15269. }
  15270. /**
  15271. * Helpers
  15272. */
  15273. ;
  15274. _proto.expected = function expected(description, index, found) {
  15275. if (Array.isArray(description)) {
  15276. var last = description.pop();
  15277. description = description.join(', ') + " or " + last;
  15278. }
  15279. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  15280. if (!found) {
  15281. return this.error("Expected " + an + " " + description + ".", {
  15282. index: index
  15283. });
  15284. }
  15285. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  15286. index: index
  15287. });
  15288. };
  15289. _proto.requiredSpace = function requiredSpace(space) {
  15290. return this.options.lossy ? ' ' : space;
  15291. };
  15292. _proto.optionalSpace = function optionalSpace(space) {
  15293. return this.options.lossy ? '' : space;
  15294. };
  15295. _proto.lossySpace = function lossySpace(space, required) {
  15296. if (this.options.lossy) {
  15297. return required ? ' ' : '';
  15298. } else {
  15299. return space;
  15300. }
  15301. };
  15302. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  15303. var content = this.content(token);
  15304. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  15305. return this.requiredSpace(content);
  15306. } else {
  15307. return content;
  15308. }
  15309. };
  15310. _proto.newNode = function newNode(node, namespace) {
  15311. if (namespace) {
  15312. if (/^ +$/.test(namespace)) {
  15313. if (!this.options.lossy) {
  15314. this.spaces = (this.spaces || '') + namespace;
  15315. }
  15316. namespace = true;
  15317. }
  15318. node.namespace = namespace;
  15319. unescapeProp(node, "namespace");
  15320. }
  15321. if (this.spaces) {
  15322. node.spaces.before = this.spaces;
  15323. this.spaces = '';
  15324. }
  15325. return this.current.append(node);
  15326. };
  15327. _proto.content = function content(token) {
  15328. if (token === void 0) {
  15329. token = this.currToken;
  15330. }
  15331. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  15332. };
  15333. /**
  15334. * returns the index of the next non-whitespace, non-comment token.
  15335. * returns -1 if no meaningful token is found.
  15336. */
  15337. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  15338. if (startPosition === void 0) {
  15339. startPosition = this.position + 1;
  15340. }
  15341. var searchPosition = startPosition;
  15342. while (searchPosition < this.tokens.length) {
  15343. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  15344. searchPosition++;
  15345. continue;
  15346. } else {
  15347. return searchPosition;
  15348. }
  15349. }
  15350. return -1;
  15351. };
  15352. _createClass(Parser, [{
  15353. key: "currToken",
  15354. get: function get() {
  15355. return this.tokens[this.position];
  15356. }
  15357. }, {
  15358. key: "nextToken",
  15359. get: function get() {
  15360. return this.tokens[this.position + 1];
  15361. }
  15362. }, {
  15363. key: "prevToken",
  15364. get: function get() {
  15365. return this.tokens[this.position - 1];
  15366. }
  15367. }]);
  15368. return Parser;
  15369. }();
  15370. exports["default"] = Parser;
  15371. module.exports = exports.default;
  15372. } (parser, parser.exports));
  15373. (function (module, exports) {
  15374. exports.__esModule = true;
  15375. exports["default"] = void 0;
  15376. var _parser = _interopRequireDefault(parser.exports);
  15377. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15378. var Processor = /*#__PURE__*/function () {
  15379. function Processor(func, options) {
  15380. this.func = func || function noop() {};
  15381. this.funcRes = null;
  15382. this.options = options;
  15383. }
  15384. var _proto = Processor.prototype;
  15385. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  15386. if (options === void 0) {
  15387. options = {};
  15388. }
  15389. var merged = Object.assign({}, this.options, options);
  15390. if (merged.updateSelector === false) {
  15391. return false;
  15392. } else {
  15393. return typeof rule !== "string";
  15394. }
  15395. };
  15396. _proto._isLossy = function _isLossy(options) {
  15397. if (options === void 0) {
  15398. options = {};
  15399. }
  15400. var merged = Object.assign({}, this.options, options);
  15401. if (merged.lossless === false) {
  15402. return true;
  15403. } else {
  15404. return false;
  15405. }
  15406. };
  15407. _proto._root = function _root(rule, options) {
  15408. if (options === void 0) {
  15409. options = {};
  15410. }
  15411. var parser = new _parser["default"](rule, this._parseOptions(options));
  15412. return parser.root;
  15413. };
  15414. _proto._parseOptions = function _parseOptions(options) {
  15415. return {
  15416. lossy: this._isLossy(options)
  15417. };
  15418. };
  15419. _proto._run = function _run(rule, options) {
  15420. var _this = this;
  15421. if (options === void 0) {
  15422. options = {};
  15423. }
  15424. return new Promise(function (resolve, reject) {
  15425. try {
  15426. var root = _this._root(rule, options);
  15427. Promise.resolve(_this.func(root)).then(function (transform) {
  15428. var string = undefined;
  15429. if (_this._shouldUpdateSelector(rule, options)) {
  15430. string = root.toString();
  15431. rule.selector = string;
  15432. }
  15433. return {
  15434. transform: transform,
  15435. root: root,
  15436. string: string
  15437. };
  15438. }).then(resolve, reject);
  15439. } catch (e) {
  15440. reject(e);
  15441. return;
  15442. }
  15443. });
  15444. };
  15445. _proto._runSync = function _runSync(rule, options) {
  15446. if (options === void 0) {
  15447. options = {};
  15448. }
  15449. var root = this._root(rule, options);
  15450. var transform = this.func(root);
  15451. if (transform && typeof transform.then === "function") {
  15452. throw new Error("Selector processor returned a promise to a synchronous call.");
  15453. }
  15454. var string = undefined;
  15455. if (options.updateSelector && typeof rule !== "string") {
  15456. string = root.toString();
  15457. rule.selector = string;
  15458. }
  15459. return {
  15460. transform: transform,
  15461. root: root,
  15462. string: string
  15463. };
  15464. }
  15465. /**
  15466. * Process rule into a selector AST.
  15467. *
  15468. * @param rule {postcss.Rule | string} The css selector to be processed
  15469. * @param options The options for processing
  15470. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  15471. */
  15472. ;
  15473. _proto.ast = function ast(rule, options) {
  15474. return this._run(rule, options).then(function (result) {
  15475. return result.root;
  15476. });
  15477. }
  15478. /**
  15479. * Process rule into a selector AST synchronously.
  15480. *
  15481. * @param rule {postcss.Rule | string} The css selector to be processed
  15482. * @param options The options for processing
  15483. * @returns {parser.Root} The AST of the selector after processing it.
  15484. */
  15485. ;
  15486. _proto.astSync = function astSync(rule, options) {
  15487. return this._runSync(rule, options).root;
  15488. }
  15489. /**
  15490. * Process a selector into a transformed value asynchronously
  15491. *
  15492. * @param rule {postcss.Rule | string} The css selector to be processed
  15493. * @param options The options for processing
  15494. * @returns {Promise<any>} The value returned by the processor.
  15495. */
  15496. ;
  15497. _proto.transform = function transform(rule, options) {
  15498. return this._run(rule, options).then(function (result) {
  15499. return result.transform;
  15500. });
  15501. }
  15502. /**
  15503. * Process a selector into a transformed value synchronously.
  15504. *
  15505. * @param rule {postcss.Rule | string} The css selector to be processed
  15506. * @param options The options for processing
  15507. * @returns {any} The value returned by the processor.
  15508. */
  15509. ;
  15510. _proto.transformSync = function transformSync(rule, options) {
  15511. return this._runSync(rule, options).transform;
  15512. }
  15513. /**
  15514. * Process a selector into a new selector string asynchronously.
  15515. *
  15516. * @param rule {postcss.Rule | string} The css selector to be processed
  15517. * @param options The options for processing
  15518. * @returns {string} the selector after processing.
  15519. */
  15520. ;
  15521. _proto.process = function process(rule, options) {
  15522. return this._run(rule, options).then(function (result) {
  15523. return result.string || result.root.toString();
  15524. });
  15525. }
  15526. /**
  15527. * Process a selector into a new selector string synchronously.
  15528. *
  15529. * @param rule {postcss.Rule | string} The css selector to be processed
  15530. * @param options The options for processing
  15531. * @returns {string} the selector after processing.
  15532. */
  15533. ;
  15534. _proto.processSync = function processSync(rule, options) {
  15535. var result = this._runSync(rule, options);
  15536. return result.string || result.root.toString();
  15537. };
  15538. return Processor;
  15539. }();
  15540. exports["default"] = Processor;
  15541. module.exports = exports.default;
  15542. } (processor, processor.exports));
  15543. var selectors = {};
  15544. var constructors = {};
  15545. constructors.__esModule = true;
  15546. 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;
  15547. var _attribute = _interopRequireDefault(attribute$1);
  15548. var _className = _interopRequireDefault(className$1.exports);
  15549. var _combinator = _interopRequireDefault(combinator$2.exports);
  15550. var _comment = _interopRequireDefault(comment$2.exports);
  15551. var _id = _interopRequireDefault(id$1.exports);
  15552. var _nesting = _interopRequireDefault(nesting$1.exports);
  15553. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  15554. var _root = _interopRequireDefault(root$1.exports);
  15555. var _selector = _interopRequireDefault(selector$1.exports);
  15556. var _string = _interopRequireDefault(string$1.exports);
  15557. var _tag = _interopRequireDefault(tag$1.exports);
  15558. var _universal = _interopRequireDefault(universal$1.exports);
  15559. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15560. var attribute = function attribute(opts) {
  15561. return new _attribute["default"](opts);
  15562. };
  15563. constructors.attribute = attribute;
  15564. var className = function className(opts) {
  15565. return new _className["default"](opts);
  15566. };
  15567. constructors.className = className;
  15568. var combinator = function combinator(opts) {
  15569. return new _combinator["default"](opts);
  15570. };
  15571. constructors.combinator = combinator;
  15572. var comment = function comment(opts) {
  15573. return new _comment["default"](opts);
  15574. };
  15575. constructors.comment = comment;
  15576. var id = function id(opts) {
  15577. return new _id["default"](opts);
  15578. };
  15579. constructors.id = id;
  15580. var nesting = function nesting(opts) {
  15581. return new _nesting["default"](opts);
  15582. };
  15583. constructors.nesting = nesting;
  15584. var pseudo = function pseudo(opts) {
  15585. return new _pseudo["default"](opts);
  15586. };
  15587. constructors.pseudo = pseudo;
  15588. var root = function root(opts) {
  15589. return new _root["default"](opts);
  15590. };
  15591. constructors.root = root;
  15592. var selector = function selector(opts) {
  15593. return new _selector["default"](opts);
  15594. };
  15595. constructors.selector = selector;
  15596. var string = function string(opts) {
  15597. return new _string["default"](opts);
  15598. };
  15599. constructors.string = string;
  15600. var tag = function tag(opts) {
  15601. return new _tag["default"](opts);
  15602. };
  15603. constructors.tag = tag;
  15604. var universal = function universal(opts) {
  15605. return new _universal["default"](opts);
  15606. };
  15607. constructors.universal = universal;
  15608. var guards = {};
  15609. guards.__esModule = true;
  15610. guards.isNode = isNode;
  15611. guards.isPseudoElement = isPseudoElement;
  15612. guards.isPseudoClass = isPseudoClass;
  15613. guards.isContainer = isContainer;
  15614. guards.isNamespace = isNamespace;
  15615. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = guards.isPseudo = guards.isNesting = guards.isIdentifier = guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  15616. var _types = types;
  15617. var _IS_TYPE;
  15618. 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);
  15619. function isNode(node) {
  15620. return typeof node === "object" && IS_TYPE[node.type];
  15621. }
  15622. function isNodeType(type, node) {
  15623. return isNode(node) && node.type === type;
  15624. }
  15625. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  15626. guards.isAttribute = isAttribute;
  15627. var isClassName = isNodeType.bind(null, _types.CLASS);
  15628. guards.isClassName = isClassName;
  15629. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  15630. guards.isCombinator = isCombinator;
  15631. var isComment = isNodeType.bind(null, _types.COMMENT);
  15632. guards.isComment = isComment;
  15633. var isIdentifier = isNodeType.bind(null, _types.ID);
  15634. guards.isIdentifier = isIdentifier;
  15635. var isNesting = isNodeType.bind(null, _types.NESTING);
  15636. guards.isNesting = isNesting;
  15637. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  15638. guards.isPseudo = isPseudo;
  15639. var isRoot = isNodeType.bind(null, _types.ROOT);
  15640. guards.isRoot = isRoot;
  15641. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  15642. guards.isSelector = isSelector;
  15643. var isString = isNodeType.bind(null, _types.STRING);
  15644. guards.isString = isString;
  15645. var isTag = isNodeType.bind(null, _types.TAG);
  15646. guards.isTag = isTag;
  15647. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  15648. guards.isUniversal = isUniversal;
  15649. function isPseudoElement(node) {
  15650. 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");
  15651. }
  15652. function isPseudoClass(node) {
  15653. return isPseudo(node) && !isPseudoElement(node);
  15654. }
  15655. function isContainer(node) {
  15656. return !!(isNode(node) && node.walk);
  15657. }
  15658. function isNamespace(node) {
  15659. return isAttribute(node) || isTag(node);
  15660. }
  15661. (function (exports) {
  15662. exports.__esModule = true;
  15663. var _types = types;
  15664. Object.keys(_types).forEach(function (key) {
  15665. if (key === "default" || key === "__esModule") return;
  15666. if (key in exports && exports[key] === _types[key]) return;
  15667. exports[key] = _types[key];
  15668. });
  15669. var _constructors = constructors;
  15670. Object.keys(_constructors).forEach(function (key) {
  15671. if (key === "default" || key === "__esModule") return;
  15672. if (key in exports && exports[key] === _constructors[key]) return;
  15673. exports[key] = _constructors[key];
  15674. });
  15675. var _guards = guards;
  15676. Object.keys(_guards).forEach(function (key) {
  15677. if (key === "default" || key === "__esModule") return;
  15678. if (key in exports && exports[key] === _guards[key]) return;
  15679. exports[key] = _guards[key];
  15680. });
  15681. } (selectors));
  15682. (function (module, exports) {
  15683. exports.__esModule = true;
  15684. exports["default"] = void 0;
  15685. var _processor = _interopRequireDefault(processor.exports);
  15686. var selectors$1 = _interopRequireWildcard(selectors);
  15687. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  15688. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
  15689. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15690. var parser = function parser(processor) {
  15691. return new _processor["default"](processor);
  15692. };
  15693. Object.assign(parser, selectors$1);
  15694. delete parser.__esModule;
  15695. var _default = parser;
  15696. exports["default"] = _default;
  15697. module.exports = exports.default;
  15698. } (dist, dist.exports));
  15699. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(dist.exports);
  15700. const animationNameRE = /^(-\w+-)?animation-name$/;
  15701. const animationRE = /^(-\w+-)?animation$/;
  15702. const scopedPlugin = (id = '') => {
  15703. const keyframes = Object.create(null);
  15704. const shortId = id.replace(/^data-v-/, '');
  15705. return {
  15706. postcssPlugin: 'vue-sfc-scoped',
  15707. Rule(rule) {
  15708. processRule(id, rule);
  15709. },
  15710. AtRule(node) {
  15711. if (/-?keyframes$/.test(node.name) &&
  15712. !node.params.endsWith(`-${shortId}`)) {
  15713. // register keyframes
  15714. keyframes[node.params] = node.params = node.params + '-' + shortId;
  15715. }
  15716. },
  15717. OnceExit(root) {
  15718. if (Object.keys(keyframes).length) {
  15719. // If keyframes are found in this <style>, find and rewrite animation names
  15720. // in declarations.
  15721. // Caveat: this only works for keyframes and animation rules in the same
  15722. // <style> element.
  15723. // individual animation-name declaration
  15724. root.walkDecls(decl => {
  15725. if (animationNameRE.test(decl.prop)) {
  15726. decl.value = decl.value
  15727. .split(',')
  15728. .map(v => keyframes[v.trim()] || v.trim())
  15729. .join(',');
  15730. }
  15731. // shorthand
  15732. if (animationRE.test(decl.prop)) {
  15733. decl.value = decl.value
  15734. .split(',')
  15735. .map(v => {
  15736. const vals = v.trim().split(/\s+/);
  15737. const i = vals.findIndex(val => keyframes[val]);
  15738. if (i !== -1) {
  15739. vals.splice(i, 1, keyframes[vals[i]]);
  15740. return vals.join(' ');
  15741. }
  15742. else {
  15743. return v;
  15744. }
  15745. })
  15746. .join(',');
  15747. }
  15748. });
  15749. }
  15750. }
  15751. };
  15752. };
  15753. const processedRules = new WeakSet();
  15754. function processRule(id, rule) {
  15755. if (processedRules.has(rule) ||
  15756. (rule.parent &&
  15757. rule.parent.type === 'atrule' &&
  15758. /-?keyframes$/.test(rule.parent.name))) {
  15759. return;
  15760. }
  15761. processedRules.add(rule);
  15762. rule.selector = selectorParser(selectorRoot => {
  15763. selectorRoot.each(selector => {
  15764. rewriteSelector(id, selector, selectorRoot);
  15765. });
  15766. }).processSync(rule.selector);
  15767. }
  15768. function rewriteSelector(id, selector, selectorRoot) {
  15769. let node = null;
  15770. // find the last child node to insert attribute selector
  15771. selector.each(n => {
  15772. // DEPRECATED ">>>" and "/deep/" combinator
  15773. if (n.type === 'combinator' &&
  15774. (n.value === '>>>' || n.value === '/deep/')) {
  15775. n.value = ' ';
  15776. n.spaces.before = n.spaces.after = '';
  15777. // warn(
  15778. // `the >>> and /deep/ combinators have been deprecated. ` +
  15779. // `Use :deep() instead.`
  15780. // )
  15781. return false;
  15782. }
  15783. if (n.type === 'pseudo') {
  15784. const { value } = n;
  15785. // deep: inject [id] attribute at the node before the ::v-deep
  15786. // combinator.
  15787. if (value === ':deep' || value === '::v-deep') {
  15788. if (n.nodes.length) {
  15789. // .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar
  15790. // replace the current node with ::v-deep's inner selector
  15791. let last = n;
  15792. n.nodes[0].each(ss => {
  15793. selector.insertAfter(last, ss);
  15794. last = ss;
  15795. });
  15796. // insert a space combinator before if it doesn't already have one
  15797. const prev = selector.at(selector.index(n) - 1);
  15798. if (!prev || !isSpaceCombinator(prev)) {
  15799. selector.insertAfter(n, selectorParser.combinator({
  15800. value: ' '
  15801. }));
  15802. }
  15803. selector.removeChild(n);
  15804. }
  15805. else {
  15806. // DEPRECATED usage in v3
  15807. // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
  15808. // warn(
  15809. // `::v-deep usage as a combinator has ` +
  15810. // `been deprecated. Use :deep(<inner-selector>) instead.`
  15811. // )
  15812. const prev = selector.at(selector.index(n) - 1);
  15813. if (prev && isSpaceCombinator(prev)) {
  15814. selector.removeChild(prev);
  15815. }
  15816. selector.removeChild(n);
  15817. }
  15818. return false;
  15819. }
  15820. // !!! Vue 2 does not have :slotted support
  15821. // ::v-slotted(.foo) -> .foo[xxxxxxx-s]
  15822. // if (value === ':slotted' || value === '::v-slotted') {
  15823. // rewriteSelector(id, n.nodes[0], selectorRoot, true /* slotted */)
  15824. // let last: selectorParser.Selector['nodes'][0] = n
  15825. // n.nodes[0].each(ss => {
  15826. // selector.insertAfter(last, ss)
  15827. // last = ss
  15828. // })
  15829. // // selector.insertAfter(n, n.nodes[0])
  15830. // selector.removeChild(n)
  15831. // // since slotted attribute already scopes the selector there's no
  15832. // // need for the non-slot attribute.
  15833. // shouldInject = false
  15834. // return false
  15835. // }
  15836. // global: replace with inner selector and do not inject [id].
  15837. // ::v-global(.foo) -> .foo
  15838. if (value === ':global' || value === '::v-global') {
  15839. selectorRoot.insertAfter(selector, n.nodes[0]);
  15840. selectorRoot.removeChild(selector);
  15841. return false;
  15842. }
  15843. }
  15844. if (n.type !== 'pseudo' && n.type !== 'combinator') {
  15845. node = n;
  15846. }
  15847. });
  15848. if (node) {
  15849. node.spaces.after = '';
  15850. }
  15851. else {
  15852. // For deep selectors & standalone pseudo selectors,
  15853. // the attribute selectors are prepended rather than appended.
  15854. // So all leading spaces must be eliminated to avoid problems.
  15855. selector.first.spaces.before = '';
  15856. }
  15857. {
  15858. selector.insertAfter(
  15859. // If node is null it means we need to inject [id] at the start
  15860. // insertAfter can handle `null` here
  15861. node, selectorParser.attribute({
  15862. attribute: id,
  15863. value: id,
  15864. raws: {},
  15865. quoteMark: `"`
  15866. }));
  15867. }
  15868. }
  15869. function isSpaceCombinator(node) {
  15870. return node.type === 'combinator' && /^\s+$/.test(node.value);
  15871. }
  15872. scopedPlugin.postcss = true;
  15873. var sourceMap = require$$0__default$1["default"];
  15874. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  15875. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  15876. var mergeSourceMap = merge;
  15877. /**
  15878. * Merge old source map and new source map and return merged.
  15879. * If old or new source map value is falsy, return another one as it is.
  15880. *
  15881. * @param {object|string} [oldMap] old source map object
  15882. * @param {object|string} [newmap] new source map object
  15883. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  15884. */
  15885. function merge(oldMap, newMap) {
  15886. if (!oldMap) return newMap
  15887. if (!newMap) return oldMap
  15888. var oldMapConsumer = new SourceMapConsumer(oldMap);
  15889. var newMapConsumer = new SourceMapConsumer(newMap);
  15890. var mergedMapGenerator = new SourceMapGenerator();
  15891. // iterate on new map and overwrite original position of new map with one of old map
  15892. newMapConsumer.eachMapping(function(m) {
  15893. // pass when `originalLine` is null.
  15894. // It occurs in case that the node does not have origin in original code.
  15895. if (m.originalLine == null) return
  15896. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  15897. line: m.originalLine,
  15898. column: m.originalColumn
  15899. });
  15900. if (origPosInOldMap.source == null) return
  15901. mergedMapGenerator.addMapping({
  15902. original: {
  15903. line: origPosInOldMap.line,
  15904. column: origPosInOldMap.column
  15905. },
  15906. generated: {
  15907. line: m.generatedLine,
  15908. column: m.generatedColumn
  15909. },
  15910. source: origPosInOldMap.source,
  15911. name: origPosInOldMap.name
  15912. });
  15913. });
  15914. var consumers = [oldMapConsumer, newMapConsumer];
  15915. consumers.forEach(function(consumer) {
  15916. consumer.sources.forEach(function(sourceFile) {
  15917. mergedMapGenerator._sources.add(sourceFile);
  15918. var sourceContent = consumer.sourceContentFor(sourceFile);
  15919. if (sourceContent != null) {
  15920. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  15921. }
  15922. });
  15923. });
  15924. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  15925. mergedMapGenerator._file = oldMap.file;
  15926. return JSON.parse(mergedMapGenerator.toString())
  15927. }
  15928. // .scss/.sass processor
  15929. const scss = (source, map, options) => {
  15930. const nodeSass = require('sass');
  15931. const finalOptions = Object.assign(Object.assign({}, options), { data: getSource(source, options.filename, options.additionalData), file: options.filename, outFile: options.filename, sourceMap: !!map });
  15932. try {
  15933. const result = nodeSass.renderSync(finalOptions);
  15934. const dependencies = result.stats.includedFiles;
  15935. if (map) {
  15936. return {
  15937. code: result.css.toString(),
  15938. map: mergeSourceMap(map, JSON.parse(result.map.toString())),
  15939. errors: [],
  15940. dependencies
  15941. };
  15942. }
  15943. return { code: result.css.toString(), errors: [], dependencies };
  15944. }
  15945. catch (e) {
  15946. return { code: '', errors: [e], dependencies: [] };
  15947. }
  15948. };
  15949. const sass = (source, map, options) => scss(source, map, Object.assign(Object.assign({}, options), { indentedSyntax: true }));
  15950. // .less
  15951. const less = (source, map, options) => {
  15952. const nodeLess = require('less');
  15953. let result;
  15954. let error = null;
  15955. nodeLess.render(getSource(source, options.filename, options.additionalData), Object.assign(Object.assign({}, options), { syncImport: true }), (err, output) => {
  15956. error = err;
  15957. result = output;
  15958. });
  15959. if (error)
  15960. return { code: '', errors: [error], dependencies: [] };
  15961. const dependencies = result.imports;
  15962. if (map) {
  15963. return {
  15964. code: result.css.toString(),
  15965. map: mergeSourceMap(map, result.map),
  15966. errors: [],
  15967. dependencies: dependencies
  15968. };
  15969. }
  15970. return {
  15971. code: result.css.toString(),
  15972. errors: [],
  15973. dependencies: dependencies
  15974. };
  15975. };
  15976. // .styl
  15977. const styl = (source, map, options) => {
  15978. const nodeStylus = require('stylus');
  15979. try {
  15980. const ref = nodeStylus(source);
  15981. Object.keys(options).forEach(key => ref.set(key, options[key]));
  15982. if (map)
  15983. ref.set('sourcemap', { inline: false, comment: false });
  15984. const result = ref.render();
  15985. const dependencies = ref.deps();
  15986. if (map) {
  15987. return {
  15988. code: result,
  15989. map: mergeSourceMap(map, ref.sourcemap),
  15990. errors: [],
  15991. dependencies
  15992. };
  15993. }
  15994. return { code: result, errors: [], dependencies };
  15995. }
  15996. catch (e) {
  15997. return { code: '', errors: [e], dependencies: [] };
  15998. }
  15999. };
  16000. function getSource(source, filename, additionalData) {
  16001. if (!additionalData)
  16002. return source;
  16003. if (isFunction(additionalData)) {
  16004. return additionalData(source, filename);
  16005. }
  16006. return additionalData + source;
  16007. }
  16008. const processors = {
  16009. less,
  16010. sass,
  16011. scss,
  16012. styl,
  16013. stylus: styl
  16014. };
  16015. const postcss = require('postcss');
  16016. function compileStyle(options) {
  16017. return doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: false }));
  16018. }
  16019. function compileStyleAsync(options) {
  16020. return Promise.resolve(doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: true })));
  16021. }
  16022. function doCompileStyle(options) {
  16023. const { filename, id, scoped = true, trim = true, isProd = false, preprocessLang, postcssOptions, postcssPlugins } = options;
  16024. const preprocessor = preprocessLang && processors[preprocessLang];
  16025. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  16026. const map = preProcessedSource ? preProcessedSource.map : options.map;
  16027. const source = preProcessedSource ? preProcessedSource.code : options.source;
  16028. const plugins = (postcssPlugins || []).slice();
  16029. plugins.unshift(cssVarsPlugin({ id: id.replace(/^data-v-/, ''), isProd }));
  16030. if (trim) {
  16031. plugins.push(trimPlugin());
  16032. }
  16033. if (scoped) {
  16034. plugins.push(scopedPlugin(id));
  16035. }
  16036. const postCSSOptions = Object.assign(Object.assign({}, postcssOptions), { to: filename, from: filename });
  16037. if (map) {
  16038. postCSSOptions.map = {
  16039. inline: false,
  16040. annotation: false,
  16041. prev: map
  16042. };
  16043. }
  16044. let result, code, outMap;
  16045. const errors = [];
  16046. if (preProcessedSource && preProcessedSource.errors.length) {
  16047. errors.push(...preProcessedSource.errors);
  16048. }
  16049. try {
  16050. result = postcss(plugins).process(source, postCSSOptions);
  16051. // In async mode, return a promise.
  16052. if (options.isAsync) {
  16053. return result
  16054. .then((result) => ({
  16055. code: result.css || '',
  16056. map: result.map && result.map.toJSON(),
  16057. errors,
  16058. rawResult: result
  16059. }))
  16060. .catch((error) => ({
  16061. code: '',
  16062. map: undefined,
  16063. errors: [...errors, error.message],
  16064. rawResult: undefined
  16065. }));
  16066. }
  16067. // force synchronous transform (we know we only have sync plugins)
  16068. code = result.css;
  16069. outMap = result.map;
  16070. }
  16071. catch (e) {
  16072. errors.push(e);
  16073. }
  16074. return {
  16075. code: code || ``,
  16076. map: outMap && outMap.toJSON(),
  16077. errors,
  16078. rawResult: result
  16079. };
  16080. }
  16081. function preprocess(options, preprocessor) {
  16082. return preprocessor(options.source, options.map, Object.assign({
  16083. filename: options.filename
  16084. }, options.preprocessOptions));
  16085. }
  16086. exports.compileScript = compileScript;
  16087. exports.compileStyle = compileStyle;
  16088. exports.compileStyleAsync = compileStyleAsync;
  16089. exports.compileTemplate = compileTemplate;
  16090. exports.generateCodeFrame = generateCodeFrame;
  16091. exports.parse = parse;
  16092. exports.parseComponent = parseComponent;
  16093. exports.rewriteDefault = rewriteDefault;